Win32 GUI: The load/save other savestate dialog box defaults to the savestates folder now, and also defaults to the new NT/XP style open file dialog box (the bigger, fancier, better one).

Several project management changes:
 - Renamed all .c files to .cpp.
 - Added pthreads-win32 to the project (along with a couple fixups).  Future revisions will use pthreads code exclusively, and remove the need for win32/linux ifdefs in multithreaded code sections.
 - Added MTGS.cpp (but it's still empty yet)

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@500 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
Jake.Stine 2008-12-26 07:00:53 +00:00 committed by Gregory Hainaut
parent 8019062b04
commit a0148c6242
271 changed files with 22707 additions and 135 deletions

View File

@ -16,20 +16,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
// rewritten by zerofrog to add multithreading/gs caching to GS and VU1
#include <assert.h> #include <assert.h>
#include <vector> #include <vector>
#include <list> #include <list>
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#if defined(_WIN32)
#include <windows.h>
#endif
#include "Common.h" #include "Common.h"
#include "zlib.h"
#include "VU.h" #include "VU.h"
#include "GS.h" #include "GS.h"
#include "iR5900.h" #include "iR5900.h"

37
pcsx2/MTGS.cpp Normal file
View File

@ -0,0 +1,37 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2008 Pcsx2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <vector>
#include <list>
#include <cstring>
#include <cstdlib>
#if defined(_WIN32)
#include <windows.h>
#endif
#include "Common.h"
#include "VU.h"
#include "GS.h"
#include "iR5900.h"
#ifdef DEBUG
#define MTGS_LOG SysPrintf
#else
#define MTGS_LOG 0&&
#endif

View File

@ -1,5 +1,5 @@
#ifndef PATCHES_H_INCLUDED #ifndef _PCSX2_PATHS_H_
#define PATCHES_H_INCLUDED #define _PCSX2_PATHS_H_
#define CONFIG_DIR "inis" #define CONFIG_DIR "inis"
@ -15,4 +15,4 @@
#define LOGS_DIR "logs" #define LOGS_DIR "logs"
#endif//PATCHES_H_INCLUDED #endif

View File

@ -20,6 +20,7 @@
#define __SYSTEM_H__ #define __SYSTEM_H__
#include "Exceptions.h" #include "Exceptions.h"
#include "Paths.h"
int SysInit(); // Init mem and plugins int SysInit(); // Init mem and plugins
void SysReset(); // Resets the various PS2 cpus, sub-systems, and recompilers. void SysReset(); // Resets the various PS2 cpus, sub-systems, and recompilers.

View File

@ -16,6 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#if defined(_WIN32)
#include <windows.h>
#endif
#include "Misc.h" #include "Misc.h"
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -159,7 +163,6 @@ __forceinline void AtomicDecrement( s32& Target )
InterlockedDecrement( (volatile LONG*)&Target ); InterlockedDecrement( (volatile LONG*)&Target );
} }
__forceinline void _TIMESLICE() __forceinline void _TIMESLICE()
{ {
#ifdef _WIN32 #ifdef _WIN32

View File

@ -1544,12 +1544,13 @@ void Open_Mcd_Proc(HWND hW, int mcd) {
ofn.nFilterIndex = 1; ofn.nFilterIndex = 1;
ofn.lpstrFile = szFileName; ofn.lpstrFile = szFileName;
ofn.nMaxFile = 256; ofn.nMaxFile = 256;
ofn.lpstrInitialDir = "memcards"; ofn.lpstrInitialDir = MEMCARDS_DIR;
ofn.lpstrFileTitle = szFileTitle; ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = 256; ofn.nMaxFileTitle = 256;
ofn.lpstrTitle = NULL; ofn.lpstrTitle = NULL;
ofn.lpstrDefExt = "MC2"; ofn.lpstrDefExt = "MC2";
ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR; ofn.Flags =
OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_EXPLORER;
if (GetOpenFileName ((LPOPENFILENAME)&ofn)) { if (GetOpenFileName ((LPOPENFILENAME)&ofn)) {
Edit_SetText(GetDlgItem(hW,mcd == 1 ? IDC_MCD1 : IDC_MCD2), szFileName); Edit_SetText(GetDlgItem(hW,mcd == 1 ? IDC_MCD1 : IDC_MCD2), szFileName);
@ -1579,12 +1580,14 @@ void SaveFileDialog(HWND hW, int MC, char *dir, char *name) {
ofn.nFilterIndex = 1; ofn.nFilterIndex = 1;
ofn.lpstrFile = szFileName; ofn.lpstrFile = szFileName;
ofn.nMaxFile = 256; ofn.nMaxFile = 256;
ofn.lpstrInitialDir = "memcards"; ofn.lpstrInitialDir = MEMCARDS_DIR;
ofn.lpstrFileTitle = szFileTitle; ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = 256; ofn.nMaxFileTitle = 256;
ofn.lpstrTitle = NULL; ofn.lpstrTitle = NULL;
ofn.lpstrDefExt = "MC2"; ofn.lpstrDefExt = "MC2";
ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_OVERWRITEPROMPT | OFN_EXTENSIONDIFFERENT; ofn.Flags =
OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_OVERWRITEPROMPT |
OFN_EXTENSIONDIFFERENT | OFN_EXPLORER;
if (GetSaveFileName ((LPOPENFILENAME)&ofn)) if (GetSaveFileName ((LPOPENFILENAME)&ofn))
{ {

View File

@ -20,6 +20,7 @@
<Configurations> <Configurations>
<Configuration <Configuration
Name="Release vm (dev)|Win32" Name="Release vm (dev)|Win32"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1" ConfigurationType="1"
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\release.vsprops;.\vsprops\virtualmem.vsprops;.\vsprops\devbuild.vsprops" InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\release.vsprops;.\vsprops\virtualmem.vsprops;.\vsprops\devbuild.vsprops"
UseOfMFC="0" UseOfMFC="0"
@ -53,6 +54,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
SmallerTypeCheck="false" SmallerTypeCheck="false"
BufferSecurityCheck="true"
CompileAs="2" CompileAs="2"
/> />
<Tool <Tool
@ -66,7 +68,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
OutputFile="$(SolutionDir)\bin\pcsx2-vm.exe" OutputFile="&quot;$(SolutionDir)\bin\pcsx2-vm.exe&quot;"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
@ -93,6 +95,7 @@
</Configuration> </Configuration>
<Configuration <Configuration
Name="Debug vm|Win32" Name="Debug vm|Win32"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1" ConfigurationType="1"
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\debug.vsprops;.\vsprops\virtualmem.vsprops;.\vsprops\devbuild.vsprops" InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\debug.vsprops;.\vsprops\virtualmem.vsprops;.\vsprops\devbuild.vsprops"
UseOfMFC="0" UseOfMFC="0"
@ -141,7 +144,7 @@
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386" AdditionalOptions="/MACHINE:I386"
OutputFile="$(SolutionDir)\bin\pcsx2d-vm.exe" OutputFile="&quot;$(SolutionDir)\bin\pcsx2d-vm.exe&quot;"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
@ -168,6 +171,7 @@
</Configuration> </Configuration>
<Configuration <Configuration
Name="Debug vtlb|Win32" Name="Debug vtlb|Win32"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1" ConfigurationType="1"
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\debug.vsprops;.\vsprops\devbuild.vsprops" InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\debug.vsprops;.\vsprops\devbuild.vsprops"
UseOfMFC="0" UseOfMFC="0"
@ -217,7 +221,7 @@
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386" AdditionalOptions="/MACHINE:I386"
OutputFile="$(SolutionDir)\bin\pcsx2d-vtlb.exe" OutputFile="&quot;$(SolutionDir)\bin\pcsx2d-vtlb.exe&quot;"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
@ -244,6 +248,7 @@
</Configuration> </Configuration>
<Configuration <Configuration
Name="Release vtlb (dev)|Win32" Name="Release vtlb (dev)|Win32"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1" ConfigurationType="1"
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\release.vsprops;.\vsprops\devbuild.vsprops" InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\release.vsprops;.\vsprops\devbuild.vsprops"
UseOfMFC="0" UseOfMFC="0"
@ -277,7 +282,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="2" Optimization="2"
InlineFunctionExpansion="1" InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true" EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1" FavorSizeOrSpeed="1"
OmitFramePointers="true" OmitFramePointers="true"
@ -290,12 +295,9 @@
SmallerTypeCheck="false" SmallerTypeCheck="false"
RuntimeLibrary="0" RuntimeLibrary="0"
StructMemberAlignment="5" StructMemberAlignment="5"
BufferSecurityCheck="false" BufferSecurityCheck="true"
EnableFunctionLevelLinking="false" EnableFunctionLevelLinking="false"
PrecompiledHeaderFile=".\ReleaseTLB/pcsx2.pch" PrecompiledHeaderFile=".\ReleaseTLB/pcsx2.pch"
AssemblerListingLocation=".\ReleaseTLB/"
ObjectFile=".\ReleaseTLB/"
ProgramDataBaseFileName=".\ReleaseTLB/"
WarningLevel="3" WarningLevel="3"
SuppressStartupBanner="true" SuppressStartupBanner="true"
CompileAs="2" CompileAs="2"
@ -311,7 +313,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
OutputFile="$(SolutionDir)\bin\pcsx2-vtlb.exe" OutputFile="&quot;$(SolutionDir)\bin\pcsx2-vtlb.exe&quot;"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
@ -338,6 +340,7 @@
</Configuration> </Configuration>
<Configuration <Configuration
Name="Release vm (nondev)|Win32" Name="Release vm (nondev)|Win32"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1" ConfigurationType="1"
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\release.vsprops;.\vsprops\virtualmem.vsprops" InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\release.vsprops;.\vsprops\virtualmem.vsprops"
UseOfMFC="0" UseOfMFC="0"
@ -387,7 +390,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
OutputFile="$(SolutionDir)\bin\pcsx2r-vm.exe" OutputFile="&quot;$(SolutionDir)\bin\pcsx2r-vm.exe&quot;"
ProgramDatabaseFile="&quot;$(TargetDir)$(TargetName).pdb&quot;" ProgramDatabaseFile="&quot;$(TargetDir)$(TargetName).pdb&quot;"
/> />
<Tool <Tool
@ -450,8 +453,9 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
EnableFiberSafeOptimizations="true" EnableFiberSafeOptimizations="true"
PreprocessorDefinitions="NDEBUG" PreprocessorDefinitions="NDEBUG,WIN32_PTHREADS"
SmallerTypeCheck="false" SmallerTypeCheck="false"
BufferSecurityCheck="true"
EnableEnhancedInstructionSet="0" EnableEnhancedInstructionSet="0"
CompileAs="2" CompileAs="2"
/> />
@ -466,7 +470,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
OutputFile="$(SolutionDir)\bin\pcsx2r-vtlb.exe" OutputFile="&quot;$(SolutionDir)\bin\pcsx2r-vtlb.exe&quot;"
ProgramDatabaseFile="&quot;$(TargetDir)$(TargetName).pdb&quot;" ProgramDatabaseFile="&quot;$(TargetDir)$(TargetName).pdb&quot;"
/> />
<Tool <Tool
@ -500,7 +504,7 @@
Name="GUI" Name="GUI"
> >
<File <File
RelativePath="..\AboutDlg.c" RelativePath="..\AboutDlg.cpp"
> >
</File> </File>
<File <File
@ -512,11 +516,7 @@
> >
</File> </File>
<File <File
RelativePath="..\Cdrom02.ico" RelativePath="..\ConfigDlg.cpp"
>
</File>
<File
RelativePath="..\ConfigDlg.c"
> >
</File> </File>
<File <File
@ -524,11 +524,11 @@
> >
</File> </File>
<File <File
RelativePath="..\CpuDlg.c" RelativePath="..\CpuDlg.cpp"
> >
</File> </File>
<File <File
RelativePath="..\ini.c" RelativePath="..\ini.cpp"
> >
</File> </File>
<File <File
@ -540,31 +540,23 @@
> >
</File> </File>
<File <File
RelativePath="..\PatchBrowser.c" RelativePath="..\PatchBrowser.cpp"
> >
</File> </File>
<File <File
RelativePath="..\pcsx2.rc" RelativePath="..\RDebugger.cpp"
>
</File>
<File
RelativePath="..\RDebugger.c"
> >
</File> </File>
<File <File
RelativePath="..\RDebugger.h" RelativePath="..\RDebugger.h"
> >
</File> </File>
<File
RelativePath="..\resource.h"
>
</File>
<File <File
RelativePath="..\Win32.h" RelativePath="..\Win32.h"
> >
</File> </File>
<File <File
RelativePath="..\WinMain.c" RelativePath="..\WinMain.cpp"
> >
</File> </File>
<File <File
@ -575,7 +567,7 @@
Name="Debugger" Name="Debugger"
> >
<File <File
RelativePath=".\..\Debugger.c" RelativePath=".\..\Debugger.cpp"
> >
</File> </File>
<File <File
@ -583,11 +575,27 @@
> >
</File> </File>
<File <File
RelativePath=".\..\DebugMemory.c" RelativePath=".\..\DebugMemory.cpp"
> >
</File> </File>
<File <File
RelativePath=".\..\Debugreg.c" RelativePath=".\..\Debugreg.cpp"
>
</File>
</Filter>
<Filter
Name="Resources"
>
<File
RelativePath="..\Cdrom02.ico"
>
</File>
<File
RelativePath="..\pcsx2.rc"
>
</File>
<File
RelativePath="..\resource.h"
> >
</File> </File>
</Filter> </Filter>
@ -596,7 +604,7 @@
Name="Elf" Name="Elf"
> >
<File <File
RelativePath="..\..\Elfheader.c" RelativePath="..\..\Elfheader.cpp"
> >
</File> </File>
<File <File
@ -608,7 +616,7 @@
Name="Plugin system" Name="Plugin system"
> >
<File <File
RelativePath="..\..\Plugins.c" RelativePath="..\..\Plugins.cpp"
> >
</File> </File>
<File <File
@ -636,7 +644,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\Misc.c" RelativePath="..\..\Misc.cpp"
> >
</File> </File>
<File <File
@ -644,7 +652,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\Patch.c" RelativePath="..\..\Patch.cpp"
> >
</File> </File>
<File <File
@ -652,7 +660,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\PathUtils.c" RelativePath="..\..\PathUtils.cpp"
> >
</File> </File>
<File <File
@ -752,7 +760,7 @@
Name="rdebug" Name="rdebug"
> >
<File <File
RelativePath="..\..\rdebug\deci2.c" RelativePath="..\..\rdebug\deci2.cpp"
> >
</File> </File>
<File <File
@ -760,7 +768,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\rdebug\deci2_dbgp.c" RelativePath="..\..\rdebug\deci2_dbgp.cpp"
> >
</File> </File>
<File <File
@ -768,7 +776,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\rdebug\deci2_dcmp.c" RelativePath="..\..\rdebug\deci2_dcmp.cpp"
> >
</File> </File>
<File <File
@ -780,7 +788,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\rdebug\deci2_iloadp.c" RelativePath="..\..\rdebug\deci2_iloadp.cpp"
> >
</File> </File>
<File <File
@ -788,7 +796,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\rdebug\deci2_netmp.c" RelativePath="..\..\rdebug\deci2_netmp.cpp"
> >
</File> </File>
<File <File
@ -796,7 +804,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\rdebug\deci2_ttyp.c" RelativePath="..\..\rdebug\deci2_ttyp.cpp"
> >
</File> </File>
<File <File
@ -1487,7 +1495,7 @@
Name="EE" Name="EE"
> >
<File <File
RelativePath="..\..\Cache.c" RelativePath="..\..\Cache.cpp"
> >
</File> </File>
<File <File
@ -1495,11 +1503,11 @@
> >
</File> </File>
<File <File
RelativePath="..\..\COP0.c" RelativePath="..\..\COP0.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\Counters.c" RelativePath="..\..\Counters.cpp"
> >
<FileConfiguration <FileConfiguration
Name="Release vm (dev)|Win32" Name="Release vm (dev)|Win32"
@ -1537,15 +1545,15 @@
> >
</File> </File>
<File <File
RelativePath="..\..\FPU.c" RelativePath="..\..\FPU.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\Interpreter.c" RelativePath="..\..\Interpreter.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\InterTables.c" RelativePath="..\..\InterTables.cpp"
> >
</File> </File>
<File <File
@ -1553,11 +1561,11 @@
> >
</File> </File>
<File <File
RelativePath="..\..\MMI.c" RelativePath="..\..\MMI.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\R5900.c" RelativePath="..\..\R5900.cpp"
> >
</File> </File>
<File <File
@ -1565,7 +1573,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\Vif.c" RelativePath="..\..\Vif.cpp"
> >
</File> </File>
<File <File
@ -1573,7 +1581,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\VifDma.c" RelativePath="..\..\VifDma.cpp"
> >
</File> </File>
<File <File
@ -1588,7 +1596,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\x86\iCOP2.c" RelativePath="..\..\x86\iCOP2.cpp"
> >
</File> </File>
<File <File
@ -1600,7 +1608,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\x86\iCP0.c" RelativePath="..\..\x86\iCP0.cpp"
> >
</File> </File>
<File <File
@ -1608,7 +1616,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\x86\iFPU.c" RelativePath="..\..\x86\iFPU.cpp"
> >
<FileConfiguration <FileConfiguration
Name="Release vm (dev)|Win32" Name="Release vm (dev)|Win32"
@ -1664,7 +1672,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\x86\iMMI.c" RelativePath="..\..\x86\iMMI.cpp"
> >
</File> </File>
<File <File
@ -1708,7 +1716,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\x86\ir5900tables.c" RelativePath="..\..\x86\ir5900tables.cpp"
> >
<FileConfiguration <FileConfiguration
Name="Release vm (nondev)|Win32" Name="Release vm (nondev)|Win32"
@ -1739,39 +1747,39 @@
> >
</File> </File>
<File <File
RelativePath="..\..\x86\ix86-32\iR5900-32.c" RelativePath="..\..\x86\ix86-32\iR5900-32.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\x86\ix86-32\iR5900Arit.c" RelativePath="..\..\x86\ix86-32\iR5900Arit.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\x86\ix86-32\iR5900AritImm.c" RelativePath="..\..\x86\ix86-32\iR5900AritImm.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\x86\ix86-32\iR5900Branch.c" RelativePath="..\..\x86\ix86-32\iR5900Branch.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\x86\ix86-32\iR5900Jump.c" RelativePath="..\..\x86\ix86-32\iR5900Jump.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\x86\ix86-32\iR5900LoadStore.c" RelativePath="..\..\x86\ix86-32\iR5900LoadStore.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\x86\ix86-32\iR5900Move.c" RelativePath="..\..\x86\ix86-32\iR5900Move.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\x86\ix86-32\iR5900MultDiv.c" RelativePath="..\..\x86\ix86-32\iR5900MultDiv.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\x86\ix86-32\iR5900Shift.c" RelativePath="..\..\x86\ix86-32\iR5900Shift.cpp"
> >
</File> </File>
</Filter> </Filter>
@ -1780,11 +1788,11 @@
Name="Hw" Name="Hw"
> >
<File <File
RelativePath="..\..\FiFo.c" RelativePath="..\..\FiFo.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\Hw.c" RelativePath="..\..\Hw.cpp"
> >
</File> </File>
<File <File
@ -1792,7 +1800,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\SPR.c" RelativePath="..\..\SPR.cpp"
> >
</File> </File>
<File <File
@ -1803,7 +1811,7 @@
Name="Dynarec" Name="Dynarec"
> >
<File <File
RelativePath="..\..\x86\iHw.c" RelativePath="..\..\x86\iHw.cpp"
> >
</File> </File>
</Filter> </Filter>
@ -1813,7 +1821,7 @@
Name="Iop" Name="Iop"
> >
<File <File
RelativePath="..\..\CdRom.c" RelativePath="..\..\CdRom.cpp"
> >
</File> </File>
<File <File
@ -1821,7 +1829,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\CDVD.c" RelativePath="..\..\CDVD.cpp"
> >
</File> </File>
<File <File
@ -1829,7 +1837,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\PsxBios.c" RelativePath="..\..\PsxBios.cpp"
> >
</File> </File>
<File <File
@ -1845,7 +1853,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\PsxCounters.c" RelativePath="..\..\PsxCounters.cpp"
> >
</File> </File>
<File <File
@ -1853,7 +1861,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\PsxDma.c" RelativePath="..\..\PsxDma.cpp"
> >
</File> </File>
<File <File
@ -1861,7 +1869,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\PsxHw.c" RelativePath="..\..\PsxHw.cpp"
> >
</File> </File>
<File <File
@ -1869,11 +1877,11 @@
> >
</File> </File>
<File <File
RelativePath="..\..\PsxInterpreter.c" RelativePath="..\..\PsxInterpreter.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\PsxMem.c" RelativePath="..\..\PsxMem.cpp"
> >
</File> </File>
<File <File
@ -1881,7 +1889,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\PsxSio2.c" RelativePath="..\..\PsxSio2.cpp"
> >
</File> </File>
<File <File
@ -1889,7 +1897,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\R3000A.c" RelativePath="..\..\R3000A.cpp"
> >
</File> </File>
<File <File
@ -1897,7 +1905,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\Sio.c" RelativePath="..\..\Sio.cpp"
> >
</File> </File>
<File <File
@ -1908,11 +1916,11 @@
Name="Dynarec" Name="Dynarec"
> >
<File <File
RelativePath="..\..\x86\iPsxHw.c" RelativePath="..\..\x86\iPsxHw.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\x86\iPsxMem.c" RelativePath="..\..\x86\iPsxMem.cpp"
> >
</File> </File>
<File <File
@ -1933,7 +1941,7 @@
Name="IPU" Name="IPU"
> >
<File <File
RelativePath="..\..\IPU\coroutine.c" RelativePath="..\..\IPU\coroutine.cpp"
> >
</File> </File>
<File <File
@ -1945,7 +1953,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\Ipu\IPU.c" RelativePath="..\..\Ipu\IPU.cpp"
> >
</File> </File>
<File <File
@ -1953,7 +1961,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\Ipu\yuv2rgb.c" RelativePath="..\..\Ipu\yuv2rgb.cpp"
> >
</File> </File>
<File <File
@ -1964,11 +1972,11 @@
Name="mpeg2lib" Name="mpeg2lib"
> >
<File <File
RelativePath="..\..\Ipu\mpeg2lib\Idct.c" RelativePath="..\..\Ipu\mpeg2lib\Idct.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\Ipu\mpeg2lib\Mpeg.c" RelativePath="..\..\Ipu\mpeg2lib\Mpeg.cpp"
> >
</File> </File>
<File <File
@ -1985,7 +1993,7 @@
Name="memory" Name="memory"
> >
<File <File
RelativePath="..\..\Memory.c" RelativePath="..\..\Memory.cpp"
> >
</File> </File>
<File <File
@ -2004,6 +2012,10 @@
RelativePath="..\..\GS.h" RelativePath="..\..\GS.h"
> >
</File> </File>
<File
RelativePath="..\..\MTGS.cpp"
>
</File>
<Filter <Filter
Name="Dynarec" Name="Dynarec"
> >
@ -2021,7 +2033,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\VU0.c" RelativePath="..\..\VU0.cpp"
> >
</File> </File>
<File <File
@ -2029,15 +2041,15 @@
> >
</File> </File>
<File <File
RelativePath="..\..\VU0micro.c" RelativePath="..\..\VU0micro.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\VU1micro.c" RelativePath="..\..\VU1micro.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\VUflags.c" RelativePath="..\..\VUflags.cpp"
> >
</File> </File>
<File <File
@ -2049,7 +2061,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\VUops.c" RelativePath="..\..\VUops.cpp"
> >
</File> </File>
<File <File
@ -2060,7 +2072,7 @@
Name="Dynarec" Name="Dynarec"
> >
<File <File
RelativePath="..\..\x86\iVU0micro.c" RelativePath="..\..\x86\iVU0micro.cpp"
> >
</File> </File>
<File <File
@ -2068,7 +2080,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\x86\iVU1micro.c" RelativePath="..\..\x86\iVU1micro.cpp"
> >
</File> </File>
<File <File
@ -2109,7 +2121,7 @@
Name="Sif" Name="Sif"
> >
<File <File
RelativePath="..\..\Sif.c" RelativePath="..\..\Sif.cpp"
> >
</File> </File>
<File <File
@ -2125,7 +2137,7 @@
Name="Debug" Name="Debug"
> >
<File <File
RelativePath="..\..\DebugTools\cpuopsDebug.c" RelativePath="..\..\DebugTools\cpuopsDebug.cpp"
> >
</File> </File>
<File <File
@ -2141,27 +2153,27 @@
> >
</File> </File>
<File <File
RelativePath="..\..\DebugTools\DisR3000A.c" RelativePath="..\..\DebugTools\DisR3000A.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\DebugTools\DisR3000asm.c" RelativePath="..\..\DebugTools\DisR3000asm.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\DebugTools\DisR5900.c" RelativePath="..\..\DebugTools\DisR5900.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\DebugTools\DisR5900asm.c" RelativePath="..\..\DebugTools\DisR5900asm.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\DebugTools\DisVU0Micro.c" RelativePath="..\..\DebugTools\DisVU0Micro.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\DebugTools\DisVU1Micro.c" RelativePath="..\..\DebugTools\DisVU1Micro.cpp"
> >
</File> </File>
<File <File
@ -2178,7 +2190,7 @@
Name="ISO" Name="ISO"
> >
<File <File
RelativePath="..\..\CDVDiso.c" RelativePath="..\..\CDVDiso.cpp"
> >
</File> </File>
<File <File
@ -2186,7 +2198,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\CDVDisodrv.c" RelativePath="..\..\CDVDisodrv.cpp"
> >
</File> </File>
<File <File
@ -2198,7 +2210,7 @@
Name="DynarecEmitter" Name="DynarecEmitter"
> >
<File <File
RelativePath="..\..\x86\ix86\ix86.c" RelativePath="..\..\x86\ix86\ix86.cpp"
> >
</File> </File>
<File <File
@ -2206,23 +2218,23 @@
> >
</File> </File>
<File <File
RelativePath="..\..\x86\ix86\ix86_3dnow.c" RelativePath="..\..\x86\ix86\ix86_3dnow.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\x86\ix86\ix86_cpudetect.c" RelativePath="..\..\x86\ix86\ix86_cpudetect.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\x86\ix86\ix86_fpu.c" RelativePath="..\..\x86\ix86\ix86_fpu.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\x86\ix86\ix86_mmx.c" RelativePath="..\..\x86\ix86\ix86_mmx.cpp"
> >
</File> </File>
<File <File
RelativePath="..\..\x86\ix86\ix86_sse.c" RelativePath="..\..\x86\ix86\ix86_sse.cpp"
> >
</File> </File>
</Filter> </Filter>
@ -2243,7 +2255,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\Stats.c" RelativePath="..\..\Stats.cpp"
> >
</File> </File>
<File <File

View File

@ -0,0 +1,321 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="pthreads"
ProjectGUID="{26511268-2902-4997-8421-ECD7055F9E28}"
RootNamespace="pthreads"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(ProjectDir)\libs\$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(InputDir)&quot;"
PreprocessorDefinitions="PTW32_STATIC_LIB;WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
ExceptionHandling="0"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
StructMemberAlignment="5"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
BrowseInformation="1"
WarningLevel="3"
DebugInformationFormat="4"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)\$(ProjectName)-d.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(ProjectDir)\libs\$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
EnableFiberSafeOptimizations="true"
AdditionalIncludeDirectories="&quot;$(InputDir)&quot;"
PreprocessorDefinitions="PTW32_STATIC_LIB;WIN32;NDEBUG;_LIB"
StringPooling="true"
MinimalRebuild="true"
ExceptionHandling="0"
RuntimeLibrary="0"
StructMemberAlignment="5"
BufferSecurityCheck="false"
EnableFunctionLevelLinking="false"
UsePrecompiledHeader="0"
BrowseInformation="1"
WarningLevel="3"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\pthreads\attr.c"
>
</File>
<File
RelativePath="..\pthreads\barrier.c"
>
</File>
<File
RelativePath="..\pthreads\cancel.c"
>
</File>
<File
RelativePath="..\pthreads\cleanup.c"
>
</File>
<File
RelativePath="..\pthreads\condvar.c"
>
</File>
<File
RelativePath="..\pthreads\create.c"
>
</File>
<File
RelativePath="..\pthreads\errno.c"
>
</File>
<File
RelativePath="..\pthreads\exit.c"
>
</File>
<File
RelativePath="..\pthreads\fork.c"
>
</File>
<File
RelativePath="..\pthreads\global.c"
>
</File>
<File
RelativePath="..\pthreads\misc.c"
>
</File>
<File
RelativePath="..\pthreads\mutex.c"
>
</File>
<File
RelativePath="..\pthreads\nonportable.c"
>
</File>
<File
RelativePath="..\pthreads\private.c"
>
</File>
<File
RelativePath="..\pthreads\rwlock.c"
>
</File>
<File
RelativePath="..\pthreads\sched.c"
>
</File>
<File
RelativePath="..\pthreads\semaphore.c"
>
</File>
<File
RelativePath="..\pthreads\signal.c"
>
</File>
<File
RelativePath="..\pthreads\spin.c"
>
</File>
<File
RelativePath="..\pthreads\sync.c"
>
</File>
<File
RelativePath="..\pthreads\tsd.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\pthreads\config.h"
>
</File>
<File
RelativePath="..\pthreads\implement.h"
>
</File>
<File
RelativePath="..\pthreads\need_errno.h"
>
</File>
<File
RelativePath="..\pthreads\pthread.h"
>
</File>
<File
RelativePath="..\pthreads\sched.h"
>
</File>
<File
RelativePath="..\pthreads\semaphore.h"
>
</File>
</Filter>
<Filter
Name="Docs"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath="..\pthreads\ANNOUNCE"
>
</File>
<File
RelativePath="..\pthreads\BUGS"
>
</File>
<File
RelativePath="..\pthreads\CONTRIBUTORS"
>
</File>
<File
RelativePath="..\pthreads\COPYING"
>
</File>
<File
RelativePath="..\pthreads\FAQ"
>
</File>
<File
RelativePath="..\pthreads\MAINTAINERS"
>
</File>
<File
RelativePath="..\pthreads\NEWS"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -563,9 +563,29 @@ extern "C"
* that available with a simple pointer. It should scale for either * that available with a simple pointer. It should scale for either
* IA-32 or IA-64. * IA-32 or IA-64.
*/ */
typedef struct {
typedef struct _ptw32_handle_t {
void * p; /* Pointer to actual object */ void * p; /* Pointer to actual object */
unsigned int x; /* Extra information - reuse count etc */ unsigned int x; /* Extra information - reuse count etc */
#ifdef __cplusplus
// Added support for various operators so that the struct is
// more pthreads-compliant in behavior. (air)
const bool operator ==( const void* rightside )
{
return p == rightside;
}
const bool operator !=( const void* rightside )
{
return p != rightside;
}
bool operator =( void* rightside )
{
p = rightside;
}
#endif
} ptw32_handle_t; } ptw32_handle_t;
typedef ptw32_handle_t pthread_t; typedef ptw32_handle_t pthread_t;

View File

@ -0,0 +1,476 @@
PTHREADS-WIN32 RELEASE 2.8.0 (2006-12-22)
-----------------------------------------
Web Site: http://sources.redhat.com/pthreads-win32/
FTP Site: ftp://sources.redhat.com/pub/pthreads-win32
Maintainer: Ross Johnson <rpj@callisto.canberra.edu.au>
We are pleased to announce the availability of a new release of
Pthreads-win32, an Open Source Software implementation of the
Threads component of the POSIX 1003.1 2001 Standard for Microsoft's
Win32 environment. Some functions from other sections of POSIX
1003.1 2001 are also supported including semaphores and scheduling
functions.
Some common non-portable functions are also implemented for
additional compatibility, as are a few functions specific
to pthreads-win32 for easier integration with Win32 applications.
Pthreads-win32 is free software, distributed under the GNU Lesser
General Public License (LGPL).
Acknowledgements
----------------
This library is based originally on a Win32 pthreads
implementation contributed by John Bossom <John.Bossom@cognos.com>.
The implementation of Condition Variables uses algorithms developed
by Alexander Terekhov and Louis Thomas.
The implementation of POSIX mutexes has been improved by Thomas Pfaff
and later by Alexander Terekhov.
The implementation of Spinlocks and Barriers was contributed
by Ross Johnson.
The implementation of read/write locks was contributed by
Aurelio Medina and improved by Alexander Terekhov.
Many others have contributed significant time and effort to solve crutial
problems in order to make the library workable, robust and reliable.
Thanks to Xavier Leroy for granting permission to use and modify his
LinuxThreads manual pages.
Thanks to The Open Group for making the Single Unix Specification
publicly available - many of the manual pages included in the package
were extracted from it.
There is also a separate CONTRIBUTORS file. This file and others are
on the web site:
http://sources.redhat.com/pthreads-win32
As much as possible, the ChangeLog file acknowledges contributions to the
code base in more detail.
Changes since the last release
------------------------------
These are now documented in the NEWS file.
See the ChangeLog file also.
Known Bugs
----------
These are now documented in the BUGS file.
Level of standards conformance
------------------------------
The following POSIX 1003.1 2001 options are defined and set to 200112L:
_POSIX_THREADS
_POSIX_THREAD_SAFE_FUNCTIONS
_POSIX_THREAD_ATTR_STACKSIZE
_POSIX_THREAD_PRIORITY_SCHEDULING
_POSIX_SEMAPHORES
_POSIX_READER_WRITER_LOCKS
_POSIX_SPIN_LOCKS
_POSIX_BARRIERS
The following POSIX 1003.1 2001 options are defined and set to -1:
_POSIX_THREAD_ATTR_STACKADDR
_POSIX_THREAD_PRIO_INHERIT
_POSIX_THREAD_PRIO_PROTECT
_POSIX_THREAD_PROCESS_SHARED
The following POSIX 1003.1 2001 limits are defined and set:
_POSIX_THREAD_THREADS_MAX
_POSIX_SEM_VALUE_MAX
_POSIX_SEM_NSEMS_MAX
_POSIX_THREAD_KEYS_MAX
_POSIX_THREAD_DESTRUCTOR_ITERATIONS
PTHREAD_STACK_MIN
PTHREAD_THREADS_MAX
SEM_VALUE_MAX
SEM_NSEMS_MAX
PTHREAD_KEYS_MAX
PTHREAD_DESTRUCTOR_ITERATIONS
The following functions are implemented:
---------------------------
PThreads
---------------------------
pthread_attr_init
pthread_attr_destroy
pthread_attr_getdetachstate
pthread_attr_getstackaddr
pthread_attr_getstacksize
pthread_attr_setdetachstate
pthread_attr_setstackaddr
pthread_attr_setstacksize
pthread_create
pthread_detach
pthread_equal
pthread_exit
pthread_join
pthread_once
pthread_self
pthread_cancel
pthread_cleanup_pop
pthread_cleanup_push
pthread_setcancelstate
pthread_setcanceltype
pthread_testcancel
---------------------------
Thread Specific Data
---------------------------
pthread_key_create
pthread_key_delete
pthread_setspecific
pthread_getspecific
---------------------------
Mutexes
---------------------------
pthread_mutexattr_init
pthread_mutexattr_destroy
pthread_mutexattr_getpshared
pthread_mutexattr_setpshared
pthread_mutexattr_gettype
pthread_mutexattr_settype (types: PTHREAD_MUTEX_DEFAULT
PTHREAD_MUTEX_NORMAL
PTHREAD_MUTEX_ERRORCHECK
PTHREAD_MUTEX_RECURSIVE )
pthread_mutex_init
pthread_mutex_destroy
pthread_mutex_lock
pthread_mutex_trylock
pthread_mutex_timedlock
pthread_mutex_unlock
---------------------------
Condition Variables
---------------------------
pthread_condattr_init
pthread_condattr_destroy
pthread_condattr_getpshared
pthread_condattr_setpshared
pthread_cond_init
pthread_cond_destroy
pthread_cond_wait
pthread_cond_timedwait
pthread_cond_signal
pthread_cond_broadcast
---------------------------
Read/Write Locks
---------------------------
pthread_rwlock_init
pthread_rwlock_destroy
pthread_rwlock_tryrdlock
pthread_rwlock_trywrlock
pthread_rwlock_rdlock
pthread_rwlock_timedrdlock
pthread_rwlock_rwlock
pthread_rwlock_timedwrlock
pthread_rwlock_unlock
pthread_rwlockattr_init
pthread_rwlockattr_destroy
pthread_rwlockattr_getpshared
pthread_rwlockattr_setpshared
---------------------------
Spin Locks
---------------------------
pthread_spin_init
pthread_spin_destroy
pthread_spin_lock
pthread_spin_unlock
pthread_spin_trylock
---------------------------
Barriers
---------------------------
pthread_barrier_init
pthread_barrier_destroy
pthread_barrier_wait
pthread_barrierattr_init
pthread_barrierattr_destroy
pthread_barrierattr_getpshared
pthread_barrierattr_setpshared
---------------------------
Semaphores
---------------------------
sem_init
sem_destroy
sem_post
sem_wait
sem_trywait
sem_timedwait
sem_getvalue (# free if +ve, # of waiters if -ve)
sem_open (returns an error ENOSYS)
sem_close (returns an error ENOSYS)
sem_unlink (returns an error ENOSYS)
---------------------------
RealTime Scheduling
---------------------------
pthread_attr_getschedparam
pthread_attr_setschedparam
pthread_attr_getinheritsched
pthread_attr_setinheritsched
pthread_attr_getschedpolicy (only supports SCHED_OTHER)
pthread_attr_setschedpolicy (only supports SCHED_OTHER)
pthread_getschedparam
pthread_setschedparam
pthread_getconcurrency
pthread_setconcurrency
pthread_attr_getscope
pthread_attr_setscope (only supports PTHREAD_SCOPE_SYSTEM)
sched_get_priority_max
sched_get_priority_min
sched_rr_get_interval (returns an error ENOTSUP)
sched_setscheduler (only supports SCHED_OTHER)
sched_getscheduler (only supports SCHED_OTHER)
sched_yield
---------------------------
Signals
---------------------------
pthread_sigmask
pthread_kill (only supports zero sig value,
for thread validity checking)
---------------------------
Non-portable routines (see the README.NONPORTABLE file for usage)
---------------------------
pthread_getw32threadhandle_np
pthread_timechange_handler_np
pthread_delay_np
pthread_mutexattr_getkind_np
pthread_mutexattr_setkind_np (types: PTHREAD_MUTEX_FAST_NP,
PTHREAD_MUTEX_ERRORCHECK_NP,
PTHREAD_MUTEX_RECURSIVE_NP,
PTHREAD_MUTEX_ADAPTIVE_NP,
PTHREAD_MUTEX_TIMED_NP)
pthread_num_processors_np
pthread_win32_process_attach_np (Required when statically linking
the library)
pthread_win32_process_detach_np (Required when statically linking
the library)
pthread_win32_thread_attach_np (Required when statically linking
the library)
pthread_win32_thread_detach_np (Required when statically linking
the library)
---------------------------
Static Initializers
---------------------------
PTHREAD_ONCE_INIT
PTHREAD_MUTEX_INITIALIZER
PTHREAD_RECURSIVE_MUTEX_INITIALIZER
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
PTHREAD_ERRORCHECK_MUTEX_INITIALIZER
PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
PTHREAD_COND_INITIALIZER
PTHREAD_RWLOCK_INITIALIZER
PTHREAD_SPINLOCK_INITIALIZER
---------------------------
Thread-Safe C Runtime Library (macros)
---------------------------
strtok_r
asctime_r
ctime_r
gmtime_r
localtime_r
rand_r
The following functions are not implemented:
---------------------------
RealTime Scheduling
---------------------------
pthread_mutex_getprioceiling
pthread_mutex_setprioceiling
pthread_mutex_attr_getprioceiling
pthread_mutex_attr_getprotocol
pthread_mutex_attr_setprioceiling
pthread_mutex_attr_setprotocol
---------------------------
Fork Handlers
---------------------------
pthread_atfork
---------------------------
Stdio
---------------------------
flockfile
ftrylockfile
funlockfile
getc_unlocked
getchar_unlocked
putc_unlocked
putchar_unlocked
---------------------------
Thread-Safe C Runtime Library
---------------------------
readdir_r
getgrgid_r
getgrnam_r
getpwuid_r
getpwnam_r
---------------------------
Signals
---------------------------
sigtimedwait
sigwait
sigwaitinfo
---------------------------
General
---------------------------
sysconf
The library includes two non-API functions for creating cancellation
points in applications and libraries:
pthreadCancelableWait
pthreadCancelableTimedWait
Availability
------------
The prebuilt DLL, export libs (for both MSVC and Mingw32), and the header
files (pthread.h, semaphore.h, sched.h) are available along with the
complete source code.
The source code can be found at:
ftp://sources.redhat.com/pub/pthreads-win32
and as individual source code files at
ftp://sources.redhat.com/pub/pthreads-win32/source
The pre-built DLL, export libraries and include files can be found at:
ftp://sources.redhat.com/pub/pthreads-win32/dll-latest
Mailing List
------------
There is a mailing list for discussing pthreads on Win32. To join,
send email to:
pthreads-win32-subscribe@sourceware.cygnus.com
Application Development Environments
------------------------------------
See the README file for more information.
MSVC:
MSVC using SEH works. Distribute pthreadVSE.dll with your application.
MSVC using C++ EH works. Distribute pthreadVCE.dll with your application.
MSVC using C setjmp/longjmp works. Distribute pthreadVC.dll with your application.
Mingw32:
See the FAQ, Questions 6 and 10.
Mingw using C++ EH works. Distribute pthreadGCE.dll with your application.
Mingw using C setjmp/longjmp works. Distribute pthreadGC.dll with your application.
Cygwin: (http://sourceware.cygnus.com/cygwin/)
Developers using Cygwin will not need pthreads-win32 since it has POSIX threads
support. Refer to its documentation for details and extent.
UWIN:
UWIN is a complete Unix-like environment for Windows from AT&T. Pthreads-win32
doesn't currently support UWIN (and vice versa), but that may change in the
future.
Generally:
For convenience, the following pre-built files are available on the FTP site
(see Availability above):
pthread.h - for POSIX 1c threads
semaphore.h - for POSIX 1b semaphores
sched.h - for POSIX 1b scheduling
pthreadVCE.dll - built with MSVC++ compiler using C++ EH
pthreadVCE.lib
pthreadVC.dll - built with MSVC compiler using C setjmp/longjmp
pthreadVC.lib
pthreadVSE.dll - built with MSVC compiler using SEH
pthreadVSE.lib
pthreadGCE.dll - built with Mingw32 G++ 2.95.2-1
pthreadGC.dll - built with Mingw32 GCC 2.95.2-1 using setjmp/longjmp
libpthreadGCE.a - derived from pthreadGCE.dll
libpthreadGC.a - derived from pthreadGC.dll
gcc.dll - needed if distributing applications that use
pthreadGCE.dll (but see the FAQ Q 10 for the latest
related information)
These are the only files you need in order to build POSIX threads
applications for Win32 using either MSVC or Mingw32.
See the FAQ file in the source tree for additional information.
Documentation
-------------
For the authoritative reference, see the online POSIX
standard reference at:
http://www.OpenGroup.org
For POSIX Thread API programming, several reference books are
available:
Programming with POSIX Threads
David R. Butenhof
Addison-Wesley (pub)
Pthreads Programming
By Bradford Nichols, Dick Buttlar & Jacqueline Proulx Farrell
O'Reilly (pub)
On the web: see the links at the bottom of the pthreads-win32 site:
http://sources.redhat.com/pthreads-win32/
Currently, there is no documentation included in the package apart
from the copious comments in the source code.
Enjoy!
Ross Johnson

133
pcsx2/windows/pthreads/BUGS Normal file
View File

@ -0,0 +1,133 @@
----------
Known bugs
----------
1. Not strictly a bug, more of a gotcha.
Under MS VC++ (only tested with version 6.0), a term_func
set via the standard C++ set_terminate() function causes the
application to abort.
Notes from the MSVC++ manual:
1) A term_func() should call exit(), otherwise
abort() will be called on return to the caller.
A call to abort() raises SIGABRT and the default signal handler
for all signals terminates the calling program with
exit code 3.
2) A term_func() must not throw an exception. Therefore
term_func() should not call pthread_exit(), which
works by throwing an exception (pthreadVCE or pthreadVSE)
or by calling longjmp (pthreadVC).
Workaround: avoid using pthread_exit() in C++ applications. Exit
threads by dropping through the end of the thread routine.
2. Cancellation problems in optimised code
- Milan Gardian
This is suspected to be a compiler bug in VC6.0, and also seen in
VC7.0 and VS .NET 2003. The GNU C++ compiler does not have a problem
with this, and it has been reported that the Intel C++ 8.1 compiler
and Visual C++ 2005 Express Edition Beta2 pass tests\semaphore4.c
(which exposes the bug).
Workaround [rpj - 2 Feb 2002]
-----------------------------
[Please note: this workaround did not solve a similar problem in
snapshot-2004-11-03 or later, even though similar symptoms were seen.
tests\semaphore4.c fails in that snapshot for the VCE version of the
DLL.]
The problem disappears when /Ob0 is used, i.e. /O2 /Ob0 works OK,
but if you want to use inlining optimisation you can be much more
specific about where it's switched off and on by using a pragma.
So the inlining optimisation is interfering with the way that cleanup
handlers are run. It appears to relate to auto-inlining of class methods
since this is the only auto inlining that is performed at /O1 optimisation
(functions with the "inline" qualifier are also inlined, but the problem
doesn't appear to involve any such functions in the library or testsuite).
In order to confirm the inlining culprit, the following use of pragmas
eliminate the problem but I don't know how to make it transparent, putting
it in, say, pthread.h where pthread_cleanup_push defined as a macro.
#pragma inline_depth(0)
pthread_cleanup_push(handlerFunc, (void *) &arg);
/* ... */
pthread_cleanup_pop(0);
#pragma inline_depth()
Note the empty () pragma value after the pop macro. This resets depth to the
default. Or you can specify a non-zero depth here.
The pragma is also needed (and now used) within the library itself wherever
cleanup handlers are used (condvar.c and rwlock.c).
Use of these pragmas allows compiler optimisations /O1 and /O2 to be
used for either or both the library and applications.
Experimenting further, I found that wrapping the actual cleanup handler
function with #pragma auto_inline(off|on) does NOT work.
MSVC6.0 doesn't appear to support the C99 standard's _Pragma directive,
however, later versions may. This form is embeddable inside #define
macros, which would be ideal because it would mean that it could be added
to the push/pop macro definitions in pthread.h and hidden from the
application programmer.
[/rpj]
Original problem description
----------------------------
The cancellation (actually, cleanup-after-cancel) tests fail when using VC
(professional) optimisation switches (/O1 or /O2) in pthreads library. I
have not investigated which concrete optimisation technique causes this
problem (/Og, /Oi, /Ot, /Oy, /Ob1, /Gs, /Gf, /Gy, etc.), but here is a
summary of builds and corresponding failures:
* pthreads VSE (optimised tests): OK
* pthreads VCE (optimised tests): Failed "cleanup1" test (runtime)
* pthreads VSE (DLL in CRT, optimised tests): OK
* pthreads VCE (DLL in CRT, optimised tests): Failed "cleanup1" test
(runtime)
Please note that while in VSE version of the pthreads library the
optimisation does not really have any impact on the tests (they pass OK), in
VCE version addition of optimisation (/O2 in this case) causes the tests to
fail uniformly - either in "cleanup0" or "cleanup1" test cases.
Please note that all the tests above use default pthreads DLL (no
optimisations, linked with either static or DLL CRT, based on test type).
Therefore the problem lies not within the pthreads DLL but within the
compiled client code (the application using pthreads -> involvement of
"pthread.h").
I think the message of this section is that usage of VCE version of pthreads
in applications relying on cancellation/cleanup AND using optimisations for
creation of production code is highly unreliable for the current version of
the pthreads library.
3. The Borland Builder 5.5 version of the library produces memory read exceptions
in some tests.
4. pthread_barrier_wait() can deadlock if the number of potential calling
threads for a particular barrier is greater than the barrier count parameter
given to pthread_barrier_init() for that barrier.
This is due to the very lightweight implementation of pthread-win32 barriers.
To cope with more than "count" possible waiters, barriers must effectively
implement all the same safeguards as condition variables, making them much
"heavier" than at present.
The workaround is to ensure that no more than "count" threads attempt to wait
at the barrier.
5. Canceling a thread blocked on pthread_once appears not to work in the MSVC++
version of the library "pthreadVCE.dll". The test case "once3.c" hangs. I have no
clues on this at present. All other versions pass this test ok - pthreadsVC.dll,
pthreadsVSE.dll, pthreadsGC.dll and pthreadsGCE.dll.

View File

@ -0,0 +1,129 @@
Contributors (in approximate order of appearance)
[See also the ChangeLog file where individuals are
attributed in log entries. Likewise in the FAQ file.]
Ben Elliston bje at cygnus dot com
Initiated the project;
setup the project infrastructure (CVS, web page, etc.);
early prototype routines.
Ross Johnson rpj at callisto dot canberra dot edu dot au
early prototype routines;
ongoing project coordination/maintenance;
implementation of spin locks and barriers;
various enhancements;
bug fixes;
documentation;
testsuite.
Robert Colquhoun rjc at trump dot net dot au
Early bug fixes.
John E. Bossom John dot Bossom at cognos dot com
Contributed substantial original working implementation;
bug fixes;
ongoing guidance and standards interpretation.
Anders Norlander anorland at hem2 dot passagen dot se
Early enhancements and runtime checking for supported
Win32 routines.
Tor Lillqvist tml at iki dot fi
General enhancements;
early bug fixes to condition variables.
Scott Lightner scott at curriculum dot com
Bug fix.
Kevin Ruland Kevin dot Ruland at anheuser-busch dot com
Various bug fixes.
Mike Russo miker at eai dot com
Bug fix.
Mark E. Armstrong avail at pacbell dot net
Bug fixes.
Lorin Hochstein lmh at xiphos dot ca
general bug fixes; bug fixes to condition variables.
Peter Slacik Peter dot Slacik at tatramed dot sk
Bug fixes.
Mumit Khan khan at xraylith dot wisc dot edu
Fixes to work with Mingw32.
Milan Gardian mg at tatramed dot sk
Bug fixes and reports/analyses of obscure problems.
Aurelio Medina aureliom at crt dot com
First implementation of read-write locks.
Graham Dumpleton Graham dot Dumpleton at ra dot pad dot otc dot telstra dot com dot au
Bug fix in condition variables.
Tristan Savatier tristan at mpegtv dot com
WinCE port.
Erik Hensema erik at hensema dot xs4all dot nl
Bug fixes.
Rich Peters rpeters at micro-magic dot com
Todd Owen towen at lucidcalm dot dropbear dot id dot au
Bug fixes to dll loading.
Jason Nye jnye at nbnet dot nb dot ca
Implementation of async cancelation.
Fred Forester fforest at eticomm dot net
Kevin D. Clark kclark at cabletron dot com
David Baggett dmb at itasoftware dot com
Bug fixes.
Paul Redondo paul at matchvision dot com
Scott McCaskill scott at 3dfx dot com
Bug fixes.
Jef Gearhart jgearhart at tpssys dot com
Bug fix.
Arthur Kantor akantor at bexusa dot com
Mutex enhancements.
Steven Reddie smr at essemer dot com dot au
Bug fix.
Alexander Terekhov TEREKHOV at de dot ibm dot com
Re-implemented and improved read-write locks;
(with Louis Thomas) re-implemented and improved
condition variables;
enhancements to semaphores;
enhancements to mutexes;
new mutex implementation in 'futex' style;
suggested a robust implementation of pthread_once
similar to that implemented by V.Kliathcko;
system clock change handling re CV timeouts;
bug fixes.
Thomas Pfaff tpfaff at gmx dot net
Changes to make C version usable with C++ applications;
re-implemented mutex routines to avoid Win32 mutexes
and TryEnterCriticalSection;
procedure to fix Mingw32 thread-safety issues.
Franco Bez franco dot bez at gmx dot de
procedure to fix Mingw32 thread-safety issues.
Louis Thomas lthomas at arbitrade dot com
(with Alexander Terekhov) re-implemented and improved
condition variables.
David Korn dgk at research dot att dot com
Ported to UWIN.
Phil Frisbie, Jr. phil at hawksoft dot com
Bug fix.
Ralf Brese Ralf dot Brese at pdb4 dot siemens dot de
Bug fix.
prionx at juno dot com prionx at juno dot com
Bug fixes.
Max Woodbury mtew at cds dot duke dot edu
POSIX versioning conditionals;
reduced namespace pollution;
idea to separate routines to reduce statically
linked image sizes.
Rob Fanner rfanner at stonethree dot com
Bug fix.
Michael Johnson michaelj at maine dot rr dot com
Bug fix.
Nicolas Barry boozai at yahoo dot com
Bug fixes.
Piet van Bruggen pietvb at newbridges dot nl
Bug fix.
Makoto Kato raven at oldskool dot jp
AMD64 port.
Panagiotis E. Hadjidoukas peh at hpclab dot ceid dot upatras dot gr
Contributed the QueueUserAPCEx package which
makes preemptive async cancelation possible.
Will Bryant will dot bryant at ecosm dot com
Borland compiler patch and makefile.
Anuj Goyal anuj dot goyal at gmail dot com
Port to Digital Mars compiler.
Gottlob Frege gottlobfrege at gmail dot com
re-implemented pthread_once (version 2)
(pthread_once cancellation added by rpj).
Vladimir Kliatchko vladimir at kliatchko dot com
reimplemented pthread_once with the same form
as described by A.Terekhov (later version 2);
implementation of MCS (Mellor-Crummey/Scott) locks.

View File

@ -0,0 +1,150 @@
pthreads-win32 - a POSIX threads library for Microsoft Windows
This file is Copyrighted
------------------------
This file is covered under the following Copyright:
Copyright (C) 2001,2006 Ross P. Johnson
All rights reserved.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Pthreads-win32 is covered by the GNU Lesser General Public License
------------------------------------------------------------------
Pthreads-win32 is open software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation version 2.1 of the
License.
Pthreads-win32 is several binary link libraries, several modules,
associated interface definition files and scripts used to control
its compilation and installation.
Pthreads-win32 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
A copy of the GNU Lesser General Public License is distributed with
pthreads-win32 under the filename:
COPYING.LIB
You should have received a copy of the version 2.1 GNU Lesser General
Public License with pthreads-win32; if not, write to:
Free Software Foundation, Inc.
59 Temple Place
Suite 330
Boston, MA 02111-1307
USA
The contact addresses for pthreads-win32 is as follows:
Web: http://sources.redhat.com/pthreads-win32
Email: Ross Johnson
Please use: Firstname.Lastname@homemail.com.au
Pthreads-win32 copyrights and exception files
---------------------------------------------
With the exception of the files listed below, Pthreads-win32
is covered under the following GNU Lesser General Public License
Copyrights:
Pthreads-win32 - POSIX Threads Library for Win32
Copyright(C) 1998 John E. Bossom
Copyright(C) 1999,2006 Pthreads-win32 contributors
The current list of contributors is contained
in the file CONTRIBUTORS included with the source
code distribution. The current list of CONTRIBUTORS
can also be seen at the following WWW location:
http://sources.redhat.com/pthreads-win32/contributors.html
Contact Email: Ross Johnson
Please use: Firstname.Lastname@homemail.com.au
These files are not covered under one of the Copyrights listed above:
COPYING
COPYING.LIB
tests/rwlock7.c
This file, COPYING, is distributed under the Copyright found at the
top of this file. It is important to note that you may distribute
verbatim copies of this file but you may not modify this file.
The file COPYING.LIB, which contains a copy of the version 2.1
GNU Lesser General Public License, is itself copyrighted by the
Free Software Foundation, Inc. Please note that the Free Software
Foundation, Inc. does NOT have a copyright over Pthreads-win32,
only the COPYING.LIB that is supplied with pthreads-win32.
The file tests/rwlock7.c is derived from code written by
Dave Butenhof for his book 'Programming With POSIX(R) Threads'.
The original code was obtained by free download from his website
http://home.earthlink.net/~anneart/family/Threads/source.html
and did not contain a copyright or author notice. It is assumed to
be freely distributable.
In all cases one may use and distribute these exception files freely.
And because one may freely distribute the LGPL covered files, the
entire pthreads-win32 source may be freely used and distributed.
General Copyleft and License info
---------------------------------
For general information on Copylefts, see:
http://www.gnu.org/copyleft/
For information on GNU Lesser General Public Licenses, see:
http://www.gnu.org/copyleft/lesser.html
http://www.gnu.org/copyleft/lesser.txt
Why pthreads-win32 did not use the GNU General Public License
-------------------------------------------------------------
The goal of the pthreads-win32 project has been to
provide a quality and complete implementation of the POSIX
threads API for Microsoft Windows within the limits imposed
by virtue of it being a stand-alone library and not
linked directly to other POSIX compliant libraries. For
example, some functions and features, such as those based
on POSIX signals, are missing.
Pthreads-win32 is a library, available in several different
versions depending on supported compilers, and may be used
as a dynamically linked module or a statically linked set of
binary modules. It is not an application on it's own.
It was fully intended that pthreads-win32 be usable with
commercial software not covered by either the GPL or the LGPL
licenses. Pthreads-win32 has many contributors to it's
code base, many of whom have done so because they have
used the library in commercial or proprietry software
projects.
Releasing pthreads-win32 under the LGPL ensures that the
library can be used widely, while at the same time ensures
that bug fixes and improvements to the pthreads-win32 code
itself is returned to benefit all current and future users
of the library.
Although pthreads-win32 makes it possible for applications
that use POSIX threads to be ported to Win32 platforms, the
broader goal of the project is to encourage the use of open
standards, and in particular, to make it just a little easier
for developers writing Win32 applications to consider
widening the potential market for their products.

403
pcsx2/windows/pthreads/FAQ Normal file
View File

@ -0,0 +1,403 @@
=========================================
PTHREADS-WIN32 Frequently Asked Questions
=========================================
INDEX
-----
Q 1 What is it?
Q 2 Which of the several dll versions do I use?
or,
What are all these pthread*.dll and pthread*.lib files?
Q 3 What is the library naming convention?
Q 4 Cleanup code default style or: it used to work when I built
the library myself, but now it doesn't - why?
Q 5 Why is the default library version now less exception-friendly?
Q 6 Should I use Cygwin or Mingw32 as a development environment?
Q 7 Now that pthreads-win32 builds under Mingw32, why do I get
memory access violations (segfaults)?
Q 8 How do I use pthread.dll for Win32 (Visual C++ 5.0)
Q 9 Cancelation doesn't work for me, why?
Q 10 How do I generate pthreadGCE.dll and libpthreadw32.a for use
with Mingw32?
=============================================================================
Q 1 What is it?
---
Pthreads-win32 is an Open Source Software implementation of the
Threads component of the POSIX 1003.1c 1995 Standard for Microsoft's
Win32 environment. Some functions from POSIX 1003.1b are also
supported including semaphores. Other related functions include
the set of read-write lock functions. The library also supports
some of the functionality of the Open Group's Single Unix
specification, version 2, namely mutex types.
See the file "ANNOUNCE" for more information including standards
conformance details and list of supported routines.
------------------------------------------------------------------------------
Q 2 Which of the several dll versions do I use?
--- or,
What are all these pthread*.dll and pthread*.lib files?
Simply, you only use one of them, but you need to choose carefully.
The most important choice you need to make is whether to use a
version that uses exceptions internally, or not (there are versions
of the library that use exceptions as part of the thread
cancelation and cleanup implementation, and one that uses
setjmp/longjmp instead).
There is some contension amongst POSIX threads experts as
to how POSIX threads cancelation and exit should work
with languages that include exceptions and handlers, 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++ exception
handlers to be invoked as the stack unwinds during thread
exit, or not?
There seems to be more opinion in favour of using the
standard C version of the library (no EH) with C++ applications
since this appears to be the assumption commercial pthreads
implementations make. Therefore, if you use an EH version
of pthreads-win32 then you may be under the illusion that
your application will be portable, when in fact it is likely to
behave very differently linked with other pthreads libraries.
Now you may be asking: why have you kept the EH versions of
the 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 ...)
- 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.
------------------------------------------------------------------------------
Q 3 What is the library naming convention?
---
Because the library is being built using various exception
handling schemes and compilers - and because the library
may 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 implementations
of the different compilers. It should be possible to use the
standard C version from either compiler with C++ applications
built with a different compiler. If you use an EH version of
the library, then you must use the same compiler for the
application. This is another complication and dependency that
can 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 are
intended to be called via pthread_cleanup_push() must be
__cdecl.
Note 3: the intention is to also name either the VC or GC
version (it should be arbitrary) as pthread.dll, including
pthread.lib and libpthread.a as appropriate.
In general:
pthread[VG]{SE,CE,C}.dll
pthread[VG]{SE,CE,C}.lib
where:
[VG] indicates the compiler
V - MS VC
G - GNU C
{SE,CE,C} indicates the exception handling scheme
SE - Structured EH
CE - C++ EH
C - no exceptions - uses setjmp/longjmp
For example:
pthreadVSE.dll (MSVC/SEH)
pthreadGCE.dll (GNUC/C++ EH)
pthreadGC.dll (GNUC/not dependent on exceptions)
The GNU library archive file names have changed to:
libpthreadGCE.a
libpthreadGC.a
------------------------------------------------------------------------------
Q 4 Cleanup code default style or: it used to work when I built
--- the library myself, but now it doesn't - why?
Up to and including snapshot 2001-07-12, if not defined, the cleanup
style was determined automatically from 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 MSVC
These defines determine the style of cleanup (see pthread.h) and,
most importantly, the way that cancelation and thread exit (via
pthread_exit) is performed (see the routine ptw32_throw() in private.c).
In short, the exceptions versions of the library throw an exception
when a thread is canceled or exits (via pthread_exit()), which is
caught by a handler in the thread startup routine, so that the
the correct stack unwinding occurs regardless of where the thread
is when it's canceled or exits via pthread_exit().
After snapshot 2001-07-12, unless your build explicitly defines (e.g.
via a compiler option) __CLEANUP_SEH, __CLEANUP_CXX, or __CLEANUP_C, then
the build now ALWAYS defaults to __CLEANUP_C style cleanup. This style
uses setjmp/longjmp in the cancelation and pthread_exit implementations,
and therefore won't do stack unwinding even when linked to applications
that have it (e.g. C++ apps). This is for consistency with most/all
commercial Unix POSIX threads implementations.
Although it was not clearly documented before, it is still necessary to
build your application using the same __CLEANUP_* define as was
used for the version of the library that you link with, so that the
correct parts of pthread.h are included. That is, the possible
defines require the following library versions:
__CLEANUP_SEH pthreadVSE.dll
__CLEANUP_CXX pthreadVCE.dll or pthreadGCE.dll
__CLEANUP_C pthreadVC.dll or pthreadGC.dll
THE POINT OF ALL THIS IS: if you have not been defining one of these
explicitly, then the defaults have been set according to the compiler
and language you are using, as described at the top of this
section.
THIS NOW CHANGES, as has been explained above. For example:
If you were building your application with MSVC++ i.e. using C++
exceptions (rather than SEH) and not explicitly defining one of
__CLEANUP_*, then __CLEANUP_C++ was defined for you in pthread.h.
You should have been linking with pthreadVCE.dll, which does
stack unwinding.
If you now build your application as you had before, pthread.h will now
set __CLEANUP_C as the default style, and you will need to link
with pthreadVC.dll. Stack unwinding will now NOT occur when a
thread is canceled, nor when the thread calls pthread_exit().
Your application will now most likely behave differently to previous
versions, and in non-obvious ways. Most likely is that local
objects may not be destroyed or cleaned up after a thread
is canceled.
If you want the same behaviour as before, then you must now define
__CLEANUP_C++ explicitly using a compiler option and link with
pthreadVCE.dll as you did before.
------------------------------------------------------------------------------
Q 5 Why is the default library version now less exception-friendly?
---
Because most commercial Unix POSIX threads implementations don't allow you to
choose to have stack unwinding. (Compaq's TRU64 Unix is possibly an exception.)
Therefore, providing it in pthread-win32 as a default could be dangerous
and non-portable. We still provide the choice but you must now consciously
make it.
WHY NOT REMOVE THE EXCEPTIONS VERSIONS OF THE LIBRARY ALTOGETHER?
There are a few reasons:
- because there are well respected POSIX threads people who believe
that POSIX threads implementations should be exceptions-aware and
do the expected thing in that context. (There are equally respected
people who believe it should not be easily accessible, if it's there
at all.)
- because pthreads-win32 is one of the few implementations that has
the choice, perhaps the only freely available one, and so offers
a laboratory to people who may want to explore the effects;
- although the code will always be around somewhere for anyone who
wants it, once it's removed from the current version it will not be
nearly as visible to people who may have a use for it.
------------------------------------------------------------------------------
Q 6 Should I use Cygwin or Mingw32 as a development environment?
---
Important: see Q7 also.
Use Mingw32 with the MSVCRT library to build applications that use
the pthreads DLL.
Cygwin's own internal support for POSIX threads is growing.
Consult that project's documentation for more information.
------------------------------------------------------------------------------
Q 7 Now that pthreads-win32 builds under Mingw32, why do I get
--- memory access violations (segfaults)?
The latest Mingw32 package has thread-safe exception handling (see Q10).
Also, see Q6 above.
------------------------------------------------------------------------------
Q 8 How do I use pthread.dll for Win32 (Visual C++ 5.0)
---
>
> I'm a "rookie" when it comes to your pthread implementation. I'm currently
> desperately trying to install the prebuilt .dll file into my MSVC compiler.
> Could you please provide me with explicit instructions on how to do this (or
> direct me to a resource(s) where I can acquire such information)?
>
> Thank you,
>
You should have a .dll, .lib, .def, and three .h files. It is recommended
that you use pthreadVC.dll, rather than pthreadVCE.dll or pthreadVSE.dll
(see Q2 above).
The .dll can go in any directory listed in your PATH environment
variable, so putting it into C:\WINDOWS should work.
The .lib file can go in any directory listed in your LIB environment
variable.
The .h files can go in any directory listed in your INCLUDE
environment variable.
Or you might prefer to put the .lib and .h files into a new directory
and add its path to LIB and INCLUDE. You can probably do this easiest
by editing the file:-
C:\Program Files\DevStudio\vc\bin\vcvars32.bat
The .def file isn't used by anything in the pre-compiled version but
is included for information.
Cheers.
Ross
------------------------------------------------------------------------------
Q 9 Cancelation doesn't work for me, why?
---
> I'm investigating a problem regarding thread cancelation. The thread I want
> to cancel has PTHREAD_CANCEL_ASYNCHRONOUS, however, this piece of code
> blocks on the join():
>
> if ((retv = Pthread_cancel( recvThread )) == 0)
> {
> retv = Pthread_join( recvThread, 0 );
> }
>
> Pthread_* are just macro's; they call pthread_*.
>
> The thread recvThread seems to block on a select() call. It doesn't get
> cancelled.
>
> Two questions:
>
> 1) is this normal behaviour?
>
> 2) if not, how does the cancel mechanism work? I'm not very familliar to
> win32 programming, so I don't really understand how the *Event() family of
> calls work.
The answer to your first question is, normal POSIX behaviour would
be to asynchronously cancel the thread. However, even that doesn't
guarantee cancelation as the standard only says it should be
cancelled as soon as possible.
Snapshot 99-11-02 or earlier only partially supports asynchronous cancellation.
Snapshots since then simulate async cancelation by poking the address of
a cancelation routine into the PC of the threads context. This requires
the thread to be resumed in some way for the cancelation to actually
proceed. This is not true async cancelation, but it is as close as we've
been able to get to it.
If the thread you're trying to cancel is blocked (for instance, it could be
waiting for data from the network), it will only get cancelled when it unblocks
(when the data arrives). For true pre-emptive cancelation in these cases,
pthreads-win32 from snapshot 2004-05-16 can automatically recognise and use the
QueueUserAPCEx package by Panagiotis E. Hadjidoukas. This package is available
from the pthreads-win32 ftp site and is included in the pthreads-win32
self-unpacking zip from 2004-05-16 onwards.
Using deferred cancelation would normally be the way to go, however,
even though the POSIX threads standard lists a number of C library
functions that are defined as deferred cancelation points, there is
no hookup between those which are provided by Windows and the
pthreads-win32 library.
Incidently, it's worth noting for code portability that the older POSIX
threads standards cancelation point lists didn't include "select" because
(as I read in Butenhof) it wasn't part of POSIX. However, it does appear in
the SUSV3.
Effectively, the only mandatory cancelation points that pthreads-win32
recognises are those the library implements itself, ie.
pthread_testcancel
pthread_cond_wait
pthread_cond_timedwait
pthread_join
sem_wait
sem_timedwait
pthread_delay_np
The following routines from the non-mandatory list in SUSV3 are
cancelation points in pthreads-win32:
pthread_rwlock_wrlock
pthread_rwlock_timedwrlock
The following routines from the non-mandatory list in SUSV3 are not
cancelation points in pthreads-win32:
pthread_rwlock_rdlock
pthread_rwlock_timedrdlock
Pthreads-win32 also provides two functions that allow you to create
cancelation points within your application, but only for cases where
a thread is going to block on a Win32 handle. These are:
pthreadCancelableWait(HANDLE waitHandle) /* Infinite wait */
pthreadCancelableTimedWait(HANDLE waitHandle, DWORD timeout)
------------------------------------------------------------------------------
Q 10 How do I create thread-safe applications using
---- pthreadGCE.dll, libpthreadw32.a and Mingw32?
This should not be a problem with recent versions of MinGW32.
For early versions, see Thomas Pfaff's email at:
http://sources.redhat.com/ml/pthreads-win32/2002/msg00000.html
------------------------------------------------------------------------------

View File

@ -0,0 +1,4 @@
CVS Repository maintainers
Ross Johnson rpj@ise.canberra.edu.au
Ben Elliston bje@cygnus.com

1110
pcsx2/windows/pthreads/NEWS Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,593 @@
PTHREADS-WIN32
==============
Pthreads-win32 is free software, distributed under the GNU Lesser
General Public License (LGPL). See the file 'COPYING.LIB' for terms
and conditions. Also see the file 'COPYING' for information
specific to pthreads-win32, copyrights and the LGPL.
What is it?
-----------
Pthreads-win32 is an Open Source Software implementation of the
Threads component of the POSIX 1003.1c 1995 Standard (or later)
for Microsoft's Win32 environment. Some functions from POSIX
1003.1b are also supported including semaphores. Other related
functions include the set of read-write lock functions. The
library also supports some of the functionality of the Open
Group's Single Unix specification, version 2, namely mutex types,
plus some common and pthreads-win32 specific non-portable
routines (see README.NONPORTABLE).
See the file "ANNOUNCE" for more information including standards
conformance details and the list of supported and unsupported
routines.
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 exception
handling schemes and compilers - and because the library
may 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 implementations
of the different compilers. It should be possible to use the
standard C version from either compiler with C++ applications
built with a different compiler. If you use an EH version of
the library, then you must use the same compiler for the
application. This is another complication and dependency that
can 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 are
intended to be called via pthread_cleanup_push() must be
__cdecl.
Note 3: the intention was to also name either the VC or GC
version (it should be arbitrary) as pthread.dll, including
pthread.lib and libpthread.a as appropriate. This is no longer
likely to happen.
Note 4: the compatibility number was added so that applications
can differentiate between binary incompatible versions of the
libs and dlls.
In general:
pthread[VG]{SE,CE,C}c.dll
pthread[VG]{SE,CE,C}c.lib
where:
[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 version
of the library. E.g. pthreadVC2d.lib. Debugging versions contain
additional information for debugging (symbols etc) and are often not
optimised 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.a
Versioning numbering
--------------------
Version numbering is separate from the snapshot dating system, and
is the canonical version identification system embedded within the
DLL using the Microsoft version resource system. The versioning
system chosen follows the GNU Libtool system. See
http://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.0
Pthreads-win32 uses the first 3 following the Libtool convention.
The fourth is commonly used for the build number, but will be reserved
for future use.
current.revision.age.0
The 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 applications
always load a compatible pthreads-win32 DLL by using a DLL naming system
that is consistent with the version numbering system. It also allows
older and newer DLLs to coexist in the same filesystem so that older
applications can continue to be used. For pre .NET Windows systems,
this inevitably requires incompatible versions of the same DLLs to have
different names.
Pthreads-win32 has adopted the Cygwin convention of appending a single
integer number to the DLL name. The number used is based on the library
version number and is computed as 'current' - 'age'.
(See http://home.att.net/~perlspinr/libversioning.html for a nicely
detailed explanation.)
Using this method, DLL name/s will only change when the DLL's
backwards compatibility changes. Note that the addition of new
'interfaces' will not of itself change the DLL's compatibility for older
applications.
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 you
use 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 a
version that uses exceptions internally, or not. There are versions
of the library that use exceptions as part of the thread
cancelation and exit implementation. The default version uses
setjmp/longjmp.
There is some contension amongst POSIX threads experts as
to how POSIX threads cancelation and exit should work
with 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++ exception
handlers to be invoked as the stack unwinds during thread
exit, or not?
There seems to be more opinion in favour of using the
standard C version of the library (no EH) with C++ applications
for the reason that this appears to be the assumption commercial
pthreads implementations make. Therefore, if you use an EH version
of pthreads-win32 then you may be under the illusion that
your application will be portable, when in fact it is likely to
behave differently when linked with other pthreads libraries.
Now you may be asking: then why have you kept the EH versions of
the 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 POSIX
threads then you will need to replace the "catch(...)" with the macro
"PtW32Catch", eg.
#ifdef PtW32Catch
PtW32Catch {
...
}
#else
catch(...) {
...
}
#endif
Otherwise neither pthreads cancelation nor pthread_exit() will work
reliably when using versions of the library that use C++ exceptions
for 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 in
the same try/catch block. GNU G++ doesn't have this restriction.
Other name changes
------------------
All snapshots prior to and including snapshot 2000-08-13
used "_pthread_" as the prefix to library internal
functions, and "_PTHREAD_" to many library internal
macros. These have now been changed to "ptw32_" and "PTW32_"
respectively so as to not conflict with the ANSI standard's
reservation of identifiers beginning with "_" and "__" for
use by compiler implementations only.
If you have written any applications and you are linking
statically with the pthreads-win32 library then you may have
included a call to _pthread_processInitialize. You will
now have to change that to ptw32_processInitialize.
Cleanup code default style
--------------------------
Previously, if not defined, the cleanup style was determined automatically
from 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 MSVC
These defines determine the style of cleanup (see pthread.h) and,
most importantly, the way that cancelation and thread exit (via
pthread_exit) is performed (see the routine ptw32_throw()).
In short, the exceptions versions of the library throw an exception
when a thread is canceled, or exits via pthread_exit(). This exception is
caught by a handler in the thread startup routine, so that the
the correct stack unwinding occurs regardless of where the thread
is when it's canceled or exits via pthread_exit().
In this snapshot, unless the build explicitly defines (e.g. via a
compiler option) __CLEANUP_SEH, __CLEANUP_CXX, or __CLEANUP_C, then
the build NOW always defaults to __CLEANUP_C style cleanup. This style
uses setjmp/longjmp in the cancelation and pthread_exit implementations,
and therefore won't do stack unwinding even when linked to applications
that have it (e.g. C++ apps). This is for consistency with most/all
commercial Unix POSIX threads implementations.
Although it was not clearly documented before, it is still necessary to
build your application using the same __CLEANUP_* define as was
used for the version of the library that you link with, so that the
correct parts of pthread.h are included. That is, the possible
defines require the following library versions:
__CLEANUP_SEH pthreadVSE.dll
__CLEANUP_CXX pthreadVCE.dll or pthreadGCE.dll
__CLEANUP_C pthreadVC.dll or pthreadGC.dll
It is recommended that you let pthread.h use it's default __CLEANUP_C
for both library and application builds. That is, don't define any of
the above, and then link with pthreadVC.lib (MSVC or MSVC++) and
libpthreadGC.a (MinGW GCC or G++). The reason is explained below, but
another reason is that the prebuilt pthreadVCE.dll is currently broken.
Versions built with MSVC++ later than version 6 may not be broken, but I
can't verify this yet.
WHY ARE WE MAKING THE DEFAULT STYLE LESS EXCEPTION-FRIENDLY?
Because no commercial Unix POSIX threads implementation allows you to
choose to have stack unwinding. Therefore, providing it in pthread-win32
as a default is dangerous. We still provide the choice but unless
you consciously choose to do otherwise, your pthreads applications will
now run or crash in similar ways irrespective of the pthreads platform
you use. Or at least this is the hope.
Building under VC++ using C++ EH, Structured EH, or just C
----------------------------------------------------------
From the source directory run nmake without any arguments to list
help information. E.g.
$ nmake
Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
Run one of the following command lines:
nmake clean VCE (to build the MSVC dll with C++ exception handling)
nmake clean VSE (to build the MSVC dll with structured exception handling)
nmake clean VC (to build the MSVC dll with C cleanup code)
nmake clean VCE-inlined (to build the MSVC inlined dll with C++ exception handling)
nmake clean VSE-inlined (to build the MSVC inlined dll with structured exception handling)
nmake clean VC-inlined (to build the MSVC inlined dll with C cleanup code)
nmake clean VC-static (to build the MSVC static lib with C cleanup code)
nmake clean VCE-debug (to build the debug MSVC dll with C++ exception handling)
nmake clean VSE-debug (to build the debug MSVC dll with structured exception handling)
nmake clean VC-debug (to build the debug MSVC dll with C cleanup code)
nmake clean VCE-inlined-debug (to build the debug MSVC inlined dll with C++ exception handling)
nmake clean VSE-inlined-debug (to build the debug MSVC inlined dll with structured exception handling)
nmake clean VC-inlined-debug (to build the debug MSVC inlined dll with C cleanup code)
nmake clean VC-static-debug (to build the debug MSVC static lib with C cleanup code)
The pre-built dlls are normally built using the *-inlined targets.
You can run the testsuite by changing to the "tests" directory and
running nmake. E.g.:
$ cd tests
$ nmake
Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
Run one of the following command lines:
nmake clean VC (to test using VC dll with VC (no EH) applications)
nmake clean VCX (to test using VC dll with VC++ (EH) applications)
nmake clean VCE (to test using the VCE dll with VC++ EH applications)
nmake clean VSE (to test using VSE dll with VC (SEH) applications)
nmake clean VC-bench (to benchtest using VC dll with C bench app)
nmake clean VCX-bench (to benchtest using VC dll with C++ bench app)
nmake clean VCE-bench (to benchtest using VCE dll with C++ bench app)
nmake clean VSE-bench (to benchtest using VSE dll with SEH bench app)
nmake clean VC-static (to test using VC static lib with VC (no EH) applications)
Building under Mingw32
----------------------
The dll can be built easily with recent versions of Mingw32.
(The distributed versions are built using Mingw32 and MsysDTK
from www.mingw32.org.)
From the source directory, run make for help information. E.g.:
$ make
Run one of the following command lines:
make clean GC (to build the GNU C dll with C cleanup code)
make clean GCE (to build the GNU C dll with C++ exception handling)
make clean GC-inlined (to build the GNU C inlined dll with C cleanup code)
make clean GCE-inlined (to build the GNU C inlined dll with C++ exception handling)
make clean GC-static (to build the GNU C inlined static lib with C cleanup code)
make clean GC-debug (to build the GNU C debug dll with C cleanup code)
make clean GCE-debug (to build the GNU C debug dll with C++ exception handling)
make clean GC-inlined-debug (to build the GNU C inlined debug dll with C cleanup code)
make clean GCE-inlined-debug (to build the GNU C inlined debug dll with C++ exception handling)
make clean GC-static-debug (to build the GNU C inlined static debug lib with C cleanup code)
The pre-built dlls are normally built using the *-inlined targets.
You can run the testsuite by changing to the "tests" directory and
running make for help information. E.g.:
$ cd tests
$ make
Run one of the following command lines:
make clean GC (to test using GC dll with C (no EH) applications)
make clean GCX (to test using GC dll with C++ (EH) applications)
make clean GCE (to test using GCE dll with C++ (EH) applications)
make clean GC-bench (to benchtest using GNU C dll with C cleanup code)
make clean GCE-bench (to benchtest using GNU C dll with C++ exception handling)
make clean GC-static (to test using GC static lib with C (no EH) applications)
Building under Linux using the Mingw32 cross development tools
--------------------------------------------------------------
You can build the library without leaving Linux by using the Mingw32 cross
development toolchain. See http://www.libsdl.org/extras/win32/cross/ for
tools and info. The GNUmakefile contains some support for this, for example:
make CROSS=i386-mingw32msvc- clean GC-inlined
will build pthreadGCn.dll and libpthreadGCn.a (n=version#), provided your
cross-tools/bin directory is in your PATH (or use the cross-make.sh script
at the URL above).
Building the library as a statically linkable library
-----------------------------------------------------
General: PTW32_STATIC_LIB must be defined for both the library build and the
application build. The makefiles supplied and used by the following 'make'
command lines will define this for you.
MSVC (creates pthreadVCn.lib as a static link lib):
nmake clean VC-static
MinGW32 (creates libpthreadGCn.a as a static link lib):
make clean GC-static
Define PTW32_STATIC_LIB when building your application. Also, your
application must call a two non-portable routines to initialise the
some state on startup and cleanup before exit. One other routine needs
to be called to cleanup after any Win32 threads have called POSIX API
routines. See README.NONPORTABLE or the html reference manual pages for
details on these routines:
BOOL pthread_win32_process_attach_np (void);
BOOL pthread_win32_process_detach_np (void);
BOOL pthread_win32_thread_attach_np (void); // Currently a no-op
BOOL pthread_win32_thread_detach_np (void);
The tests makefiles have the same targets but only check that the
static library is statically linkable. They don't run the full
testsuite. To run the full testsuite, build the dlls and run the
dll test targets.
Building the library under Cygwin
---------------------------------
Cygwin is implementing it's own POSIX threads routines and these
will be the ones to use if you develop using Cygwin.
Ready to run binaries
---------------------
For convenience, the following ready-to-run files can be downloaded
from the FTP site (see under "Availability" below):
pthread.h
semaphore.h
sched.h
pthreadVC.dll - built with MSVC compiler using C setjmp/longjmp
pthreadVC.lib
pthreadVCE.dll - built with MSVC++ compiler using C++ EH
pthreadVCE.lib
pthreadVSE.dll - built with MSVC compiler using SEH
pthreadVSE.lib
pthreadGC.dll - built with Mingw32 GCC
libpthreadGC.a - derived from pthreadGC.dll
pthreadGCE.dll - built with Mingw32 G++
libpthreadGCE.a - derived from pthreadGCE.dll
As of August 2003 pthreads-win32 pthreadG* versions are built and tested
using the MinGW + MsysDTK environment current as of that date or later.
The following file MAY be needed for older MinGW environments.
gcc.dll - needed to build and run applications that use
pthreadGCE.dll.
Building applications with GNU compilers
----------------------------------------
If you're using pthreadGC.dll:
With the three header files, pthreadGC.dll and libpthreadGC.a in the
same directory as your application myapp.c, you could compile, link
and run myapp.c under Mingw32 as follows:
gcc -o myapp.exe myapp.c -I. -L. -lpthreadGC
myapp
Or put pthreadGC.dll in an appropriate directory in your PATH,
put libpthreadGC.a in your system lib directory, and
put the three header files in your system include directory,
then use:
gcc -o myapp.exe myapp.c -lpthreadGC
myapp
If you're using pthreadGCE.dll:
With the three header files, pthreadGCE.dll, gcc.dll and libpthreadGCE.a
in the same directory as your application myapp.c, you could compile,
link and run myapp.c under Mingw32 as follows:
gcc -x c++ -o myapp.exe myapp.c -I. -L. -lpthreadGCE
myapp
Or put pthreadGCE.dll and gcc.dll in an appropriate directory in
your PATH, put libpthreadGCE.a in your system lib directory, and
put the three header files in your system include directory,
then use:
gcc -x c++ -o myapp.exe myapp.c -lpthreadGCE
myapp
Availability
------------
The complete source code in either unbundled, self-extracting
Zip file, or tar/gzipped format can be found at:
ftp://sources.redhat.com/pub/pthreads-win32
The pre-built DLL, export libraries and matching pthread.h can
be found at:
ftp://sources.redhat.com/pub/pthreads-win32/dll-latest
Home page:
http://sources.redhat.com/pthreads-win32/
Mailing list
------------
There is a mailing list for discussing pthreads on Win32.
To join, send email to:
pthreads-win32-subscribe@sources.redhat.com
Unsubscribe by sending mail to:
pthreads-win32-unsubscribe@sources.redhat.com
Acknowledgements
----------------
See the ANNOUNCE file for acknowledgements.
See the 'CONTRIBUTORS' file for the list of contributors.
As much as possible, the ChangeLog file attributes
contributions and patches that have been incorporated
in the library to the individuals responsible.
Finally, thanks to all those who work on and contribute to the
POSIX and Single Unix Specification standards. The maturity of an
industry can be measured by it's open standards.
----
Ross Johnson
<rpj@callisto.canberra.edu.au>

View File

@ -0,0 +1,7 @@
Things that aren't done yet
---------------------------
1. Implement PTHREAD_PROCESS_SHARED for semaphores, mutexes,
condition variables, read/write locks, barriers.

View File

@ -0,0 +1,53 @@
/*
* attr.c
*
* Description:
* This translation unit agregates operations on thread attribute objects.
* It is used for inline optimisation.
*
* The included modules are used separately when static executable sizes
* must be minimised.
*
* --------------------------------------------------------------------------
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
* Copyright(C) 1999,2005 Pthreads-win32 contributors
*
* Contact Email: rpj@callisto.canberra.edu.au
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "pthread.h"
#include "implement.h"
#include "pthread_attr_init.c"
#include "pthread_attr_destroy.c"
#include "pthread_attr_getdetachstate.c"
#include "pthread_attr_setdetachstate.c"
#include "pthread_attr_getstackaddr.c"
#include "pthread_attr_setstackaddr.c"
#include "pthread_attr_getstacksize.c"
#include "pthread_attr_setstacksize.c"
#include "pthread_attr_getscope.c"
#include "pthread_attr_setscope.c"

View File

@ -0,0 +1,47 @@
/*
* barrier.c
*
* Description:
* This translation unit implements barrier primitives.
*
* --------------------------------------------------------------------------
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
* Copyright(C) 1999,2005 Pthreads-win32 contributors
*
* Contact Email: rpj@callisto.canberra.edu.au
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "pthread.h"
#include "implement.h"
#include "pthread_barrier_init.c"
#include "pthread_barrier_destroy.c"
#include "pthread_barrier_wait.c"
#include "pthread_barrierattr_init.c"
#include "pthread_barrierattr_destroy.c"
#include "pthread_barrierattr_getpshared.c"
#include "pthread_barrierattr_setpshared.c"

View File

@ -0,0 +1,44 @@
/*
* cancel.c
*
* Description:
* POSIX thread functions related to thread cancellation.
*
* --------------------------------------------------------------------------
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
* Copyright(C) 1999,2005 Pthreads-win32 contributors
*
* Contact Email: rpj@callisto.canberra.edu.au
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "pthread.h"
#include "implement.h"
#include "pthread_setcancelstate.c"
#include "pthread_setcanceltype.c"
#include "pthread_testcancel.c"
#include "pthread_cancel.c"

View File

@ -0,0 +1,148 @@
/*
* cleanup.c
*
* Description:
* This translation unit implements routines associated
* with cleaning up threads.
*
*
* --------------------------------------------------------------------------
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
* Copyright(C) 1999,2005 Pthreads-win32 contributors
*
* Contact Email: rpj@callisto.canberra.edu.au
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "pthread.h"
#include "implement.h"
/*
* The functions ptw32_pop_cleanup and ptw32_push_cleanup
* are implemented here for applications written in C with no
* SEH or C++ destructor support.
*/
ptw32_cleanup_t *
ptw32_pop_cleanup (int execute)
/*
* ------------------------------------------------------
* DOCPUBLIC
* This function pops the most recently pushed cleanup
* handler. If execute is nonzero, then the cleanup handler
* is executed if non-null.
*
* PARAMETERS
* execute
* if nonzero, execute the cleanup handler
*
*
* DESCRIPTION
* This function pops the most recently pushed cleanup
* handler. If execute is nonzero, then the cleanup handler
* is executed if non-null.
* NOTE: specify 'execute' as nonzero to avoid duplication
* of common cleanup code.
*
* RESULTS
* N/A
*
* ------------------------------------------------------
*/
{
ptw32_cleanup_t *cleanup;
cleanup = (ptw32_cleanup_t *) pthread_getspecific (ptw32_cleanupKey);
if (cleanup != NULL)
{
if (execute && (cleanup->routine != NULL))
{
(*cleanup->routine) (cleanup->arg);
}
pthread_setspecific (ptw32_cleanupKey, (void *) cleanup->prev);
}
return (cleanup);
} /* ptw32_pop_cleanup */
void
ptw32_push_cleanup (ptw32_cleanup_t * cleanup,
ptw32_cleanup_callback_t routine, void *arg)
/*
* ------------------------------------------------------
* DOCPUBLIC
* This function pushes a new cleanup handler onto the thread's stack
* of cleanup handlers. Each cleanup handler pushed onto the stack is
* popped and invoked with the argument 'arg' when
* a) the thread exits by calling 'pthread_exit',
* b) when the thread acts on a cancellation request,
* c) or when the thread calls pthread_cleanup_pop with a nonzero
* 'execute' argument
*
* PARAMETERS
* cleanup
* a pointer to an instance of pthread_cleanup_t,
*
* routine
* pointer to a cleanup handler,
*
* arg
* parameter to be passed to the cleanup handler
*
*
* DESCRIPTION
* This function pushes a new cleanup handler onto the thread's stack
* of cleanup handlers. Each cleanup handler pushed onto the stack is
* popped and invoked with the argument 'arg' when
* a) the thread exits by calling 'pthread_exit',
* b) when the thread acts on a cancellation request,
* c) or when the thrad calls pthread_cleanup_pop with a nonzero
* 'execute' argument
* NOTE: pthread_push_cleanup, ptw32_pop_cleanup must be paired
* in the same lexical scope.
*
* RESULTS
* pthread_cleanup_t *
* pointer to the previous cleanup
*
* ------------------------------------------------------
*/
{
cleanup->routine = routine;
cleanup->arg = arg;
cleanup->prev = (ptw32_cleanup_t *) pthread_getspecific (ptw32_cleanupKey);
pthread_setspecific (ptw32_cleanupKey, (void *) cleanup);
} /* ptw32_push_cleanup */

View File

@ -0,0 +1,50 @@
/*
* condvar.c
*
* Description:
* This translation unit implements condition variables and their primitives.
*
*
* --------------------------------------------------------------------------
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
* Copyright(C) 1999,2005 Pthreads-win32 contributors
*
* Contact Email: rpj@callisto.canberra.edu.au
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
*/
#include "pthread.h"
#include "implement.h"
#include "ptw32_cond_check_need_init.c"
#include "pthread_condattr_init.c"
#include "pthread_condattr_destroy.c"
#include "pthread_condattr_getpshared.c"
#include "pthread_condattr_setpshared.c"
#include "pthread_cond_init.c"
#include "pthread_cond_destroy.c"
#include "pthread_cond_wait.c"
#include "pthread_cond_signal.c"

View File

@ -0,0 +1,134 @@
/* config.h */
#ifndef PTW32_CONFIG_H
#define PTW32_CONFIG_H
/*********************************************************************
* Defaults: see target specific redefinitions below.
*********************************************************************/
/* We're building the pthreads-win32 library */
#define PTW32_BUILD
/* Do we know about the C type sigset_t? */
#undef HAVE_SIGSET_T
/* Define if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H
/* Define if you have the Borland TASM32 or compatible assembler. */
#undef HAVE_TASM32
/* Define if you don't have Win32 DuplicateHandle. (eg. WinCE) */
#undef NEED_DUPLICATEHANDLE
/* Define if you don't have Win32 _beginthreadex. (eg. WinCE) */
#undef NEED_CREATETHREAD
/* Define if you don't have Win32 errno. (eg. WinCE) */
#undef NEED_ERRNO
/* Define if you don't have Win32 calloc. (eg. WinCE) */
#undef NEED_CALLOC
/* Define if you don't have Win32 ftime. (eg. WinCE) */
#undef NEED_FTIME
/* Define if you don't have Win32 semaphores. (eg. WinCE 2.1 or earlier) */
#undef NEED_SEM
/* Define if you need to convert string parameters to unicode. (eg. WinCE) */
#undef NEED_UNICODE_CONSTS
/* Define if your C (not C++) compiler supports "inline" functions. */
#define HAVE_C_INLINE
/* Do we know about type mode_t? */
#undef HAVE_MODE_T
/* Define if you have the timespec struct */
#undef HAVE_STRUCT_TIMESPEC
/* Define if you don't have the GetProcessAffinityMask() */
#undef NEED_PROCESS_AFFINITY_MASK
/*
# ----------------------------------------------------------------------
# The library can be built with some alternative behaviour to better
# facilitate development of applications on Win32 that will be ported
# to other POSIX systems.
#
# Nothing described here will make the library non-compliant and strictly
# compliant applications will not be affected in any way, but
# applications that make assumptions that POSIX does not guarantee are
# not strictly compliant and may fail or misbehave with some settings.
#
# PTW32_THREAD_ID_REUSE_INCREMENT
# Purpose:
# POSIX says that applications should assume that thread IDs can be
# recycled. However, Solaris (and some other systems) use a [very large]
# sequence number as the thread ID, which provides virtual uniqueness.
# This provides a very high but finite level of safety for applications
# that are not meticulous in tracking thread lifecycles e.g. applications
# that call functions which target detached threads without some form of
# thread exit synchronisation.
#
# Usage:
# Set to any value in the range: 0 <= value < 2^wordsize.
# Set to 0 to emulate reusable thread ID behaviour like Linux or *BSD.
# Set to 1 for unique thread IDs like Solaris (this is the default).
# Set to some factor of 2^wordsize to emulate smaller word size types
# (i.e. will wrap sooner). This might be useful to emulate some embedded
# systems.
#
# define PTW32_THREAD_ID_REUSE_INCREMENT 0
#
# ----------------------------------------------------------------------
*/
#undef PTW32_THREAD_ID_REUSE_INCREMENT
/*********************************************************************
* Target specific groups
*
* If you find that these are incorrect or incomplete please report it
* to the pthreads-win32 maintainer. Thanks.
*********************************************************************/
#ifdef WINCE
#define NEED_DUPLICATEHANDLE
#define NEED_CREATETHREAD
#define NEED_ERRNO
#define NEED_CALLOC
#define NEED_FTIME
//#define NEED_SEM
#define NEED_UNICODE_CONSTS
#define NEED_PROCESS_AFFINITY_MASK
#endif
#ifdef _UWIN
#define HAVE_MODE_T
#define HAVE_STRUCT_TIMESPEC
#endif
#ifdef __GNUC__
#define HAVE_C_INLINE
#endif
#ifdef __MINGW32__
#define HAVE_MODE_T
#endif
#ifdef __BORLANDC__
#endif
#ifdef __WATCOMC__
#endif
#ifdef __DMC__
#define HAVE_SIGNAL_H
#define HAVE_C_INLINE
#endif
#endif

View File

@ -0,0 +1,305 @@
/*
* create.c
*
* Description:
* This translation unit implements routines associated with spawning a new
* thread.
*
* --------------------------------------------------------------------------
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
* Copyright(C) 1999,2005 Pthreads-win32 contributors
*
* Contact Email: rpj@callisto.canberra.edu.au
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "pthread.h"
#include "implement.h"
#ifndef _UWIN
#include <process.h>
#endif
int
pthread_create (pthread_t * tid,
const pthread_attr_t * attr,
void *(*start) (void *), void *arg)
/*
* ------------------------------------------------------
* DOCPUBLIC
* This function creates a thread running the start function,
* passing it the parameter value, 'arg'. The 'attr'
* argument specifies optional creation attributes.
* The identity of the new thread is returned
* via 'tid', which should not be NULL.
*
* PARAMETERS
* tid
* pointer to an instance of pthread_t
*
* attr
* optional pointer to an instance of pthread_attr_t
*
* start
* pointer to the starting routine for the new thread
*
* arg
* optional parameter passed to 'start'
*
*
* DESCRIPTION
* This function creates a thread running the start function,
* passing it the parameter value, 'arg'. The 'attr'
* argument specifies optional creation attributes.
* The identity of the new thread is returned
* via 'tid', which should not be the NULL pointer.
*
* RESULTS
* 0 successfully created thread,
* EINVAL attr invalid,
* EAGAIN insufficient resources.
*
* ------------------------------------------------------
*/
{
pthread_t thread;
ptw32_thread_t * tp;
register pthread_attr_t a;
HANDLE threadH = 0;
int result = EAGAIN;
int run = PTW32_TRUE;
ThreadParms *parms = NULL;
long stackSize;
int priority;
pthread_t self;
/*
* Before doing anything, check that tid can be stored through
* without invoking a memory protection error (segfault).
* Make sure that the assignment below can't be optimised out by the compiler.
* This is assured by conditionally assigning *tid again at the end.
*/
tid->x = 0;
if (attr != NULL)
{
a = *attr;
}
else
{
a = NULL;
}
if ((thread = ptw32_new ()).p == NULL)
{
goto FAIL0;
}
tp = (ptw32_thread_t *) thread.p;
priority = tp->sched_priority;
if ((parms = (ThreadParms *) malloc (sizeof (*parms))) == NULL)
{
goto FAIL0;
}
parms->tid = thread;
parms->start = start;
parms->arg = arg;
#if defined(HAVE_SIGSET_T)
/*
* Threads inherit their initial sigmask from their creator thread.
*/
self = pthread_self();
tp->sigmask = ((ptw32_thread_t *)self.p)->sigmask;
#endif /* HAVE_SIGSET_T */
if (a != NULL)
{
stackSize = a->stacksize;
tp->detachState = a->detachstate;
priority = a->param.sched_priority;
#if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL)
/* WinCE */
#else
/* Everything else */
/*
* Thread priority must be set to a valid system level
* without altering the value set by pthread_attr_setschedparam().
*/
/*
* PTHREAD_EXPLICIT_SCHED is the default because Win32 threads
* don't inherit their creator's priority. They are started with
* THREAD_PRIORITY_NORMAL (win32 value). The result of not supplying
* an 'attr' arg to pthread_create() is equivalent to defaulting to
* PTHREAD_EXPLICIT_SCHED and priority THREAD_PRIORITY_NORMAL.
*/
if (PTHREAD_INHERIT_SCHED == a->inheritsched)
{
/*
* If the thread that called pthread_create() is a Win32 thread
* then the inherited priority could be the result of a temporary
* system adjustment. This is not the case for POSIX threads.
*/
#if ! defined(HAVE_SIGSET_T)
self = pthread_self ();
#endif
priority = ((ptw32_thread_t *) self.p)->sched_priority;
}
#endif
}
else
{
/*
* Default stackSize
*/
stackSize = PTHREAD_STACK_MIN;
}
tp->state = run ? PThreadStateInitial : PThreadStateSuspended;
tp->keys = NULL;
/*
* Threads must be started in suspended mode and resumed if necessary
* after _beginthreadex returns us the handle. Otherwise we set up a
* race condition between the creating and the created threads.
* Note that we also retain a local copy of the handle for use
* by us in case thread.p->threadH gets NULLed later but before we've
* finished with it here.
*/
#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__)
tp->threadH =
threadH =
(HANDLE) _beginthreadex ((void *) NULL, /* No security info */
(unsigned) stackSize, /* default stack size */
ptw32_threadStart,
parms,
(unsigned)
CREATE_SUSPENDED,
(unsigned *) &(tp->thread));
if (threadH != 0)
{
if (a != NULL)
{
(void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority);
}
if (run)
{
ResumeThread (threadH);
}
}
#else /* __MINGW32__ && ! __MSVCRT__ */
/*
* This lock will force pthread_threadStart() to wait until we have
* the thread handle and have set the priority.
*/
(void) pthread_mutex_lock (&tp->cancelLock);
tp->threadH =
threadH =
(HANDLE) _beginthread (ptw32_threadStart, (unsigned) stackSize, /* default stack size */
parms);
/*
* Make the return code match _beginthreadex's.
*/
if (threadH == (HANDLE) - 1L)
{
tp->threadH = threadH = 0;
}
else
{
if (!run)
{
/*
* beginthread does not allow for create flags, so we do it now.
* Note that beginthread itself creates the thread in SUSPENDED
* mode, and then calls ResumeThread to start it.
*/
SuspendThread (threadH);
}
if (a != NULL)
{
(void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority);
}
}
(void) pthread_mutex_unlock (&tp->cancelLock);
#endif /* __MINGW32__ && ! __MSVCRT__ */
result = (threadH != 0) ? 0 : EAGAIN;
/*
* Fall Through Intentionally
*/
/*
* ------------
* Failure Code
* ------------
*/
FAIL0:
if (result != 0)
{
ptw32_threadDestroy (thread);
tp = NULL;
if (parms != NULL)
{
free (parms);
}
}
else
{
*tid = thread;
}
#ifdef _UWIN
if (result == 0)
pthread_count++;
#endif
return (result);
} /* pthread_create */

View File

@ -0,0 +1,92 @@
/*
* dll.c
*
* Description:
* This translation unit implements DLL initialisation.
*
* --------------------------------------------------------------------------
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
* Copyright(C) 1999,2005 Pthreads-win32 contributors
*
* Contact Email: rpj@callisto.canberra.edu.au
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifndef PTW32_STATIC_LIB
#include "pthread.h"
#include "implement.h"
#ifdef _MSC_VER
/*
* lpvReserved yields an unreferenced formal parameter;
* ignore it
*/
#pragma warning( disable : 4100 )
#endif
#ifdef __cplusplus
/*
* Dear c++: Please don't mangle this name. -thanks
*/
extern "C"
#endif /* __cplusplus */
BOOL WINAPI
DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
{
BOOL result = PTW32_TRUE;
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
result = pthread_win32_process_attach_np ();
break;
case DLL_THREAD_ATTACH:
/*
* A thread is being created
*/
result = pthread_win32_thread_attach_np ();
break;
case DLL_THREAD_DETACH:
/*
* A thread is exiting cleanly
*/
result = pthread_win32_thread_detach_np ();
break;
case DLL_PROCESS_DETACH:
(void) pthread_win32_thread_detach_np ();
result = pthread_win32_process_detach_np ();
break;
}
return (result);
} /* DllMain */
#endif /* PTW32_STATIC_LIB */

View File

@ -0,0 +1,94 @@
/*
* errno.c
*
* Description:
* This translation unit implements routines associated with spawning a new
* thread.
*
* --------------------------------------------------------------------------
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
* Copyright(C) 1999,2005 Pthreads-win32 contributors
*
* Contact Email: rpj@callisto.canberra.edu.au
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if defined(NEED_ERRNO)
#include "pthread.h"
#include "implement.h"
static int reallyBad = ENOMEM;
/*
* Re-entrant errno.
*
* Each thread has it's own errno variable in pthread_t.
*
* The benefit of using the pthread_t structure
* instead of another TSD key is TSD keys are limited
* on Win32 to 64 per process. Secondly, to implement
* it properly without using pthread_t you'd need
* to dynamically allocate an int on starting the thread
* and store it manually into TLS and then ensure that you free
* it on thread termination. We get all that for free
* by simply storing the errno on the pthread_t structure.
*
* MSVC and Mingw32 already have their own thread-safe errno.
*
* #if defined( _REENTRANT ) || defined( _MT )
* #define errno *_errno()
*
* int *_errno( void );
* #else
* extern int errno;
* #endif
*
*/
int *
_errno (void)
{
pthread_t self;
int *result;
if ((self = pthread_self ()) == NULL)
{
/*
* Yikes! unable to allocate a thread!
* Throw an exception? return an error?
*/
result = &reallyBad;
}
else
{
result = &(self->ptErrno);
}
return (result);
} /* _errno */
#endif /* (NEED_ERRNO) */

View File

@ -0,0 +1,44 @@
/*
* exit.c
*
* Description:
* This translation unit implements routines associated with exiting from
* a thread.
*
* --------------------------------------------------------------------------
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
* Copyright(C) 1999,2005 Pthreads-win32 contributors
*
* Contact Email: rpj@callisto.canberra.edu.au
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "pthread.h"
#include "implement.h"
#ifndef _UWIN
# include <process.h>
#endif
#include "pthread_exit.c"

Some files were not shown because too many files have changed in this diff Show More