diff --git a/vs/x64/cooccur/.vs/cooccur/v14/.suo b/vs/x64/cooccur/.vs/cooccur/v14/.suo
new file mode 100644
index 0000000..25709fe
Binary files /dev/null and b/vs/x64/cooccur/.vs/cooccur/v14/.suo differ
diff --git a/vs/x64/cooccur/cooccur.VC.db b/vs/x64/cooccur/cooccur.VC.db
new file mode 100644
index 0000000..2f14b68
Binary files /dev/null and b/vs/x64/cooccur/cooccur.VC.db differ
diff --git a/vs/cooccur/cooccur.sln b/vs/x64/cooccur/cooccur.sln
similarity index 100%
rename from vs/cooccur/cooccur.sln
rename to vs/x64/cooccur/cooccur.sln
diff --git a/vs/cooccur/cooccur/cooccur.c b/vs/x64/cooccur/cooccur/cooccur.c
similarity index 100%
rename from vs/cooccur/cooccur/cooccur.c
rename to vs/x64/cooccur/cooccur/cooccur.c
diff --git a/vs/cooccur/cooccur/cooccur.vcxproj b/vs/x64/cooccur/cooccur/cooccur.vcxproj
similarity index 100%
rename from vs/cooccur/cooccur/cooccur.vcxproj
rename to vs/x64/cooccur/cooccur/cooccur.vcxproj
diff --git a/vs/cooccur/cooccur/cooccur.vcxproj.filters b/vs/x64/cooccur/cooccur/cooccur.vcxproj.filters
similarity index 100%
rename from vs/cooccur/cooccur/cooccur.vcxproj.filters
rename to vs/x64/cooccur/cooccur/cooccur.vcxproj.filters
diff --git a/vs/cooccur/cooccur/cooccur.vcxproj.user b/vs/x64/cooccur/cooccur/cooccur.vcxproj.user
similarity index 100%
rename from vs/cooccur/cooccur/cooccur.vcxproj.user
rename to vs/x64/cooccur/cooccur/cooccur.vcxproj.user
diff --git a/vs/x64/cooccur/cooccur/x64/Release/cooccur.Build.CppClean.log b/vs/x64/cooccur/cooccur/x64/Release/cooccur.Build.CppClean.log
new file mode 100644
index 0000000..6d1705a
--- /dev/null
+++ b/vs/x64/cooccur/cooccur/x64/Release/cooccur.Build.CppClean.log
@@ -0,0 +1,12 @@
+e:\ano\workspace\glove-win\vs\x64\cooccur\cooccur\x64\release\vc140.pdb
+e:\ano\workspace\glove-win\vs\x64\cooccur\cooccur\x64\release\cooccur.obj
+e:\ano\workspace\glove-win\vs\x64\cooccur\x64\release\cooccur.exe
+e:\ano\workspace\glove-win\vs\x64\cooccur\x64\release\cooccur.ipdb
+e:\ano\workspace\glove-win\vs\x64\cooccur\x64\release\cooccur.iobj
+e:\ano\workspace\glove-win\vs\x64\cooccur\x64\release\cooccur.pdb
+e:\ano\workspace\glove-win\vs\x64\cooccur\cooccur\x64\release\cooccur.tlog\cl.command.1.tlog
+e:\ano\workspace\glove-win\vs\x64\cooccur\cooccur\x64\release\cooccur.tlog\cl.read.1.tlog
+e:\ano\workspace\glove-win\vs\x64\cooccur\cooccur\x64\release\cooccur.tlog\cl.write.1.tlog
+e:\ano\workspace\glove-win\vs\x64\cooccur\cooccur\x64\release\cooccur.tlog\link.command.1.tlog
+e:\ano\workspace\glove-win\vs\x64\cooccur\cooccur\x64\release\cooccur.tlog\link.read.1.tlog
+e:\ano\workspace\glove-win\vs\x64\cooccur\cooccur\x64\release\cooccur.tlog\link.write.1.tlog
diff --git a/vs/x64/cooccur/cooccur/x64/Release/cooccur.log b/vs/x64/cooccur/cooccur/x64/Release/cooccur.log
new file mode 100644
index 0000000..37df984
--- /dev/null
+++ b/vs/x64/cooccur/cooccur/x64/Release/cooccur.log
@@ -0,0 +1,43 @@
+ cooccur.c
+cooccur.c(111): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+cooccur.c(240): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+cooccur.c(241): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+cooccur.c(276): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+cooccur.c(364): warning C4244: “=”: 从“__int64”转换到“int”,可能丢失数据
+cooccur.c(365): warning C4244: “=”: 从“__int64”转换到“int”,可能丢失数据
+cooccur.c(369): warning C4244: “=”: 从“__int64”转换到“int”,可能丢失数据
+cooccur.c(370): warning C4244: “=”: 从“__int64”转换到“int”,可能丢失数据
+cooccur.c(389): warning C4244: “=”: 从“double”转换到“__int64”,可能丢失数据
+cooccur.c(391): warning C4244: “函数”: 从“__int64”转换到“double”,可能丢失数据
+cooccur.c(302): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+cooccur.c(304): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+cooccur.c(306): warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1193): note: 参见“fscanf”的声明
+cooccur.c(333): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+cooccur.c(334): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+cooccur.c(335): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+cooccur.c(345): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+cooccur.c(346): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+cooccur.c(384): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+cooccur.c(388): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+cooccur.c(460): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+cooccur.c(461): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+cooccur.c(462): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+cooccur.c(463): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ 正在生成代码
+ All 27 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
+ 已完成代码的生成
+ cooccur.vcxproj -> E:\ano\Workspace\glove-win\vs\x64\cooccur\x64\Release\cooccur.exe
+ cooccur.vcxproj -> E:\ano\Workspace\glove-win\vs\x64\cooccur\x64\Release\cooccur.pdb (Full PDB)
diff --git a/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/CL.command.1.tlog b/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/CL.command.1.tlog
new file mode 100644
index 0000000..eada0e5
Binary files /dev/null and b/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/CL.command.1.tlog differ
diff --git a/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/CL.read.1.tlog b/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/CL.read.1.tlog
new file mode 100644
index 0000000..1e09d1b
Binary files /dev/null and b/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/CL.read.1.tlog differ
diff --git a/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/CL.write.1.tlog b/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/CL.write.1.tlog
new file mode 100644
index 0000000..adf0a4a
Binary files /dev/null and b/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/CL.write.1.tlog differ
diff --git a/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/cooccur.lastbuildstate b/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/cooccur.lastbuildstate
new file mode 100644
index 0000000..85087b1
--- /dev/null
+++ b/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/cooccur.lastbuildstate
@@ -0,0 +1,2 @@
+#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
+Release|x64|E:\ano\Workspace\glove-win\vs\x64\cooccur\|
diff --git a/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/link.command.1.tlog b/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/link.command.1.tlog
new file mode 100644
index 0000000..12b6ab8
Binary files /dev/null and b/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/link.command.1.tlog differ
diff --git a/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/link.read.1.tlog b/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/link.read.1.tlog
new file mode 100644
index 0000000..ee1c92a
Binary files /dev/null and b/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/link.read.1.tlog differ
diff --git a/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/link.write.1.tlog b/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/link.write.1.tlog
new file mode 100644
index 0000000..3425b82
Binary files /dev/null and b/vs/x64/cooccur/cooccur/x64/Release/cooccur.tlog/link.write.1.tlog differ
diff --git a/vs/x64/cooccur/cooccur/x64/Release/vc140.pdb b/vs/x64/cooccur/cooccur/x64/Release/vc140.pdb
new file mode 100644
index 0000000..d8bdc25
Binary files /dev/null and b/vs/x64/cooccur/cooccur/x64/Release/vc140.pdb differ
diff --git a/vs/x64/cooccur/x64/Release/cooccur.iobj b/vs/x64/cooccur/x64/Release/cooccur.iobj
new file mode 100644
index 0000000..30b3359
Binary files /dev/null and b/vs/x64/cooccur/x64/Release/cooccur.iobj differ
diff --git a/vs/x64/cooccur/x64/Release/cooccur.ipdb b/vs/x64/cooccur/x64/Release/cooccur.ipdb
new file mode 100644
index 0000000..b71db8b
Binary files /dev/null and b/vs/x64/cooccur/x64/Release/cooccur.ipdb differ
diff --git a/vs/x64/cooccur/x64/Release/cooccur.pdb b/vs/x64/cooccur/x64/Release/cooccur.pdb
new file mode 100644
index 0000000..d06a326
Binary files /dev/null and b/vs/x64/cooccur/x64/Release/cooccur.pdb differ
diff --git a/vs/x64/glove/.vs/glove/v14/.suo b/vs/x64/glove/.vs/glove/v14/.suo
new file mode 100644
index 0000000..91a829a
Binary files /dev/null and b/vs/x64/glove/.vs/glove/v14/.suo differ
diff --git a/vs/x64/glove/glove.VC.db b/vs/x64/glove/glove.VC.db
new file mode 100644
index 0000000..e1ad8bc
Binary files /dev/null and b/vs/x64/glove/glove.VC.db differ
diff --git a/vs/glove/glove.sln b/vs/x64/glove/glove.sln
similarity index 100%
rename from vs/glove/glove.sln
rename to vs/x64/glove/glove.sln
diff --git a/vs/glove/glove/glove.c b/vs/x64/glove/glove/glove.c
similarity index 100%
rename from vs/glove/glove/glove.c
rename to vs/x64/glove/glove/glove.c
diff --git a/vs/x64/glove/glove/glove.vcxproj b/vs/x64/glove/glove/glove.vcxproj
new file mode 100644
index 0000000..b970e90
--- /dev/null
+++ b/vs/x64/glove/glove/glove.vcxproj
@@ -0,0 +1,156 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ {A5F18589-3957-440A-A1A7-9BC03B3955B0}
+ Win32Proj
+ glove
+ 8.1
+
+
+
+ Application
+ true
+ v140
+ Unicode
+
+
+ Application
+ false
+ v140
+ true
+ Unicode
+
+
+ Application
+ true
+ v140
+ Unicode
+
+
+ Application
+ false
+ v140
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+ E:\ano\Workspace\pthreads\Pre-built.2\include;$(IncludePath)
+ E:\ano\Workspace\pthreads\Pre-built.2\dll\x86;$(ReferencePath)
+ E:\ano\Workspace\pthreads\Pre-built.2\lib\x86;$(LibraryPath)
+
+
+ false
+ E:\ano\Workspace\glove-win\vs\x64\pthreads.2\include;$(IncludePath)
+ E:\ano\Workspace\glove-win\vs\x64\pthreads.2\dll\x64;$(ReferencePath)
+ E:\ano\Workspace\glove-win\vs\x64\pthreads.2\lib\x64;$(LibraryPath)
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+
+
+
+
+
+
+ Level3
+ Disabled
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vs/glove/glove/glove.vcxproj.filters b/vs/x64/glove/glove/glove.vcxproj.filters
similarity index 100%
rename from vs/glove/glove/glove.vcxproj.filters
rename to vs/x64/glove/glove/glove.vcxproj.filters
diff --git a/vs/glove/glove/glove.vcxproj.user b/vs/x64/glove/glove/glove.vcxproj.user
similarity index 100%
rename from vs/glove/glove/glove.vcxproj.user
rename to vs/x64/glove/glove/glove.vcxproj.user
diff --git a/vs/x64/glove/glove/x64/Release/glove.log b/vs/x64/glove/glove/x64/Release/glove.log
new file mode 100644
index 0000000..6d0fbc7
--- /dev/null
+++ b/vs/x64/glove/glove/x64/Release/glove.log
@@ -0,0 +1,56 @@
+ glove.c
+glove.c(106): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+glove.c(189): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+glove.c(191): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+glove.c(193): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+glove.c(199): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+glove.c(201): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+glove.c(203): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+glove.c(211): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+glove.c(213): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+glove.c(216): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+glove.c(218): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+glove.c(220): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+glove.c(223): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+glove.c(225): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+glove.c(226): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+glove.c(229): warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1193): note: 参见“fscanf”的声明
+glove.c(248): warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1193): note: 参见“fscanf”的声明
+glove.c(256): warning C4244: “初始化”: 从“__int64”转换到“int”,可能丢失数据
+glove.c(297): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+glove.c(330): warning C4996: 'localtime': This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\time.h(505): note: 参见“localtime”的声明
+glove.c(425): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+glove.c(426): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+glove.c(427): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+glove.c(428): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+glove.c(430): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+glove.c(433): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+glove.c(434): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+glove.c(435): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+glove.c(439): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+ 正在生成代码
+e:\ano\workspace\glove-win\vs\x64\glove\glove\glove.c(171): warning C4716: “glove_thread”: 必须返回一个值
+ All 20 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
+ 已完成代码的生成
+ glove.vcxproj -> E:\ano\Workspace\glove-win\vs\x64\glove\x64\Release\glove.exe
+ glove.vcxproj -> E:\ano\Workspace\glove-win\vs\x64\glove\x64\Release\glove.pdb (Full PDB)
diff --git a/vs/x64/glove/glove/x64/Release/glove.tlog/CL.command.1.tlog b/vs/x64/glove/glove/x64/Release/glove.tlog/CL.command.1.tlog
new file mode 100644
index 0000000..71decdb
Binary files /dev/null and b/vs/x64/glove/glove/x64/Release/glove.tlog/CL.command.1.tlog differ
diff --git a/vs/x64/glove/glove/x64/Release/glove.tlog/CL.read.1.tlog b/vs/x64/glove/glove/x64/Release/glove.tlog/CL.read.1.tlog
new file mode 100644
index 0000000..cf0e329
Binary files /dev/null and b/vs/x64/glove/glove/x64/Release/glove.tlog/CL.read.1.tlog differ
diff --git a/vs/x64/glove/glove/x64/Release/glove.tlog/CL.write.1.tlog b/vs/x64/glove/glove/x64/Release/glove.tlog/CL.write.1.tlog
new file mode 100644
index 0000000..6895c02
Binary files /dev/null and b/vs/x64/glove/glove/x64/Release/glove.tlog/CL.write.1.tlog differ
diff --git a/vs/x64/glove/glove/x64/Release/glove.tlog/glove.lastbuildstate b/vs/x64/glove/glove/x64/Release/glove.tlog/glove.lastbuildstate
new file mode 100644
index 0000000..58a799d
--- /dev/null
+++ b/vs/x64/glove/glove/x64/Release/glove.tlog/glove.lastbuildstate
@@ -0,0 +1,2 @@
+#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
+Release|x64|E:\ano\Workspace\glove-win\vs\x64\glove\|
diff --git a/vs/x64/glove/glove/x64/Release/glove.tlog/link.command.1.tlog b/vs/x64/glove/glove/x64/Release/glove.tlog/link.command.1.tlog
new file mode 100644
index 0000000..6de039c
Binary files /dev/null and b/vs/x64/glove/glove/x64/Release/glove.tlog/link.command.1.tlog differ
diff --git a/vs/x64/glove/glove/x64/Release/glove.tlog/link.read.1.tlog b/vs/x64/glove/glove/x64/Release/glove.tlog/link.read.1.tlog
new file mode 100644
index 0000000..2475815
Binary files /dev/null and b/vs/x64/glove/glove/x64/Release/glove.tlog/link.read.1.tlog differ
diff --git a/vs/x64/glove/glove/x64/Release/glove.tlog/link.write.1.tlog b/vs/x64/glove/glove/x64/Release/glove.tlog/link.write.1.tlog
new file mode 100644
index 0000000..f1c8699
Binary files /dev/null and b/vs/x64/glove/glove/x64/Release/glove.tlog/link.write.1.tlog differ
diff --git a/vs/x64/glove/glove/x64/Release/vc140.pdb b/vs/x64/glove/glove/x64/Release/vc140.pdb
new file mode 100644
index 0000000..832a8cc
Binary files /dev/null and b/vs/x64/glove/glove/x64/Release/vc140.pdb differ
diff --git a/vs/x64/glove/x64/Release/glove.iobj b/vs/x64/glove/x64/Release/glove.iobj
new file mode 100644
index 0000000..4df6db0
Binary files /dev/null and b/vs/x64/glove/x64/Release/glove.iobj differ
diff --git a/vs/x64/glove/x64/Release/glove.ipdb b/vs/x64/glove/x64/Release/glove.ipdb
new file mode 100644
index 0000000..fe797a1
Binary files /dev/null and b/vs/x64/glove/x64/Release/glove.ipdb differ
diff --git a/vs/x64/glove/x64/Release/glove.pdb b/vs/x64/glove/x64/Release/glove.pdb
new file mode 100644
index 0000000..c8694ab
Binary files /dev/null and b/vs/x64/glove/x64/Release/glove.pdb differ
diff --git a/vs/pthreads.2/include/pthread.h b/vs/x64/pthreads.2/include/pthread.h
similarity index 100%
rename from vs/pthreads.2/include/pthread.h
rename to vs/x64/pthreads.2/include/pthread.h
diff --git a/vs/pthreads.2/include/sched.h b/vs/x64/pthreads.2/include/sched.h
similarity index 100%
rename from vs/pthreads.2/include/sched.h
rename to vs/x64/pthreads.2/include/sched.h
diff --git a/vs/pthreads.2/include/semaphore.h b/vs/x64/pthreads.2/include/semaphore.h
similarity index 100%
rename from vs/pthreads.2/include/semaphore.h
rename to vs/x64/pthreads.2/include/semaphore.h
diff --git a/vs/x64/shuffle/.vs/shuffle/v14/.suo b/vs/x64/shuffle/.vs/shuffle/v14/.suo
new file mode 100644
index 0000000..5345a86
Binary files /dev/null and b/vs/x64/shuffle/.vs/shuffle/v14/.suo differ
diff --git a/vs/x64/shuffle/shuffle.VC.db b/vs/x64/shuffle/shuffle.VC.db
new file mode 100644
index 0000000..638d3dc
Binary files /dev/null and b/vs/x64/shuffle/shuffle.VC.db differ
diff --git a/vs/shuffle/shuffle.sln b/vs/x64/shuffle/shuffle.sln
similarity index 100%
rename from vs/shuffle/shuffle.sln
rename to vs/x64/shuffle/shuffle.sln
diff --git a/vs/shuffle/shuffle/shuffle.c b/vs/x64/shuffle/shuffle/shuffle.c
similarity index 100%
rename from vs/shuffle/shuffle/shuffle.c
rename to vs/x64/shuffle/shuffle/shuffle.c
diff --git a/vs/shuffle/shuffle/shuffle.vcxproj b/vs/x64/shuffle/shuffle/shuffle.vcxproj
similarity index 100%
rename from vs/shuffle/shuffle/shuffle.vcxproj
rename to vs/x64/shuffle/shuffle/shuffle.vcxproj
diff --git a/vs/shuffle/shuffle/shuffle.vcxproj.filters b/vs/x64/shuffle/shuffle/shuffle.vcxproj.filters
similarity index 100%
rename from vs/shuffle/shuffle/shuffle.vcxproj.filters
rename to vs/x64/shuffle/shuffle/shuffle.vcxproj.filters
diff --git a/vs/shuffle/shuffle/shuffle.vcxproj.user b/vs/x64/shuffle/shuffle/shuffle.vcxproj.user
similarity index 100%
rename from vs/shuffle/shuffle/shuffle.vcxproj.user
rename to vs/x64/shuffle/shuffle/shuffle.vcxproj.user
diff --git a/vs/x64/shuffle/shuffle/x64/Release/shuffle.log b/vs/x64/shuffle/shuffle/x64/Release/shuffle.log
new file mode 100644
index 0000000..ddcef10
--- /dev/null
+++ b/vs/x64/shuffle/shuffle/x64/Release/shuffle.log
@@ -0,0 +1,22 @@
+ shuffle.c
+shuffle.c(91): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+shuffle.c(92): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+shuffle.c(120): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+shuffle.c(139): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+shuffle.c(140): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+shuffle.c(155): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+shuffle.c(156): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205): note: 参见“fopen”的声明
+shuffle.c(214): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+shuffle.c(215): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ 正在生成代码
+ All 15 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
+ 已完成代码的生成
+ shuffle.vcxproj -> E:\ano\Workspace\glove-win\vs\x64\shuffle\x64\Release\shuffle.exe
+ shuffle.vcxproj -> E:\ano\Workspace\glove-win\vs\x64\shuffle\x64\Release\shuffle.pdb (Full PDB)
diff --git a/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/CL.command.1.tlog b/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/CL.command.1.tlog
new file mode 100644
index 0000000..fa21d86
Binary files /dev/null and b/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/CL.command.1.tlog differ
diff --git a/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/CL.read.1.tlog b/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/CL.read.1.tlog
new file mode 100644
index 0000000..2e1673d
Binary files /dev/null and b/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/CL.read.1.tlog differ
diff --git a/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/CL.write.1.tlog b/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/CL.write.1.tlog
new file mode 100644
index 0000000..7c4d29a
Binary files /dev/null and b/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/CL.write.1.tlog differ
diff --git a/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/link.command.1.tlog b/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/link.command.1.tlog
new file mode 100644
index 0000000..d5f80c0
Binary files /dev/null and b/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/link.command.1.tlog differ
diff --git a/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/link.read.1.tlog b/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/link.read.1.tlog
new file mode 100644
index 0000000..4a8ac47
Binary files /dev/null and b/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/link.read.1.tlog differ
diff --git a/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/link.write.1.tlog b/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/link.write.1.tlog
new file mode 100644
index 0000000..e1809c4
Binary files /dev/null and b/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/link.write.1.tlog differ
diff --git a/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/shuffle.lastbuildstate b/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/shuffle.lastbuildstate
new file mode 100644
index 0000000..d5cff79
--- /dev/null
+++ b/vs/x64/shuffle/shuffle/x64/Release/shuffle.tlog/shuffle.lastbuildstate
@@ -0,0 +1,2 @@
+#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
+Release|x64|E:\ano\Workspace\glove-win\vs\x64\shuffle\|
diff --git a/vs/x64/shuffle/shuffle/x64/Release/vc140.pdb b/vs/x64/shuffle/shuffle/x64/Release/vc140.pdb
new file mode 100644
index 0000000..d36df3e
Binary files /dev/null and b/vs/x64/shuffle/shuffle/x64/Release/vc140.pdb differ
diff --git a/vs/x64/shuffle/x64/Release/shuffle.iobj b/vs/x64/shuffle/x64/Release/shuffle.iobj
new file mode 100644
index 0000000..2cf5c4e
Binary files /dev/null and b/vs/x64/shuffle/x64/Release/shuffle.iobj differ
diff --git a/vs/x64/shuffle/x64/Release/shuffle.ipdb b/vs/x64/shuffle/x64/Release/shuffle.ipdb
new file mode 100644
index 0000000..afe7d5a
Binary files /dev/null and b/vs/x64/shuffle/x64/Release/shuffle.ipdb differ
diff --git a/vs/x64/shuffle/x64/Release/shuffle.pdb b/vs/x64/shuffle/x64/Release/shuffle.pdb
new file mode 100644
index 0000000..82cf20d
Binary files /dev/null and b/vs/x64/shuffle/x64/Release/shuffle.pdb differ
diff --git a/vs/x64/vocab_count/.vs/vocab_count/v14/.suo b/vs/x64/vocab_count/.vs/vocab_count/v14/.suo
new file mode 100644
index 0000000..4ea34ec
Binary files /dev/null and b/vs/x64/vocab_count/.vs/vocab_count/v14/.suo differ
diff --git a/vs/x64/vocab_count/vocab_count.VC.db b/vs/x64/vocab_count/vocab_count.VC.db
new file mode 100644
index 0000000..66b5e07
Binary files /dev/null and b/vs/x64/vocab_count/vocab_count.VC.db differ
diff --git a/vs/vocab_count/vocab_count.sln b/vs/x64/vocab_count/vocab_count.sln
similarity index 100%
rename from vs/vocab_count/vocab_count.sln
rename to vs/x64/vocab_count/vocab_count.sln
diff --git a/vs/vocab_count/vocab_count/vocab_count.c b/vs/x64/vocab_count/vocab_count/vocab_count.c
similarity index 100%
rename from vs/vocab_count/vocab_count/vocab_count.c
rename to vs/x64/vocab_count/vocab_count/vocab_count.c
diff --git a/vs/vocab_count/vocab_count/vocab_count.vcxproj b/vs/x64/vocab_count/vocab_count/vocab_count.vcxproj
similarity index 100%
rename from vs/vocab_count/vocab_count/vocab_count.vcxproj
rename to vs/x64/vocab_count/vocab_count/vocab_count.vcxproj
diff --git a/vs/vocab_count/vocab_count/vocab_count.vcxproj.filters b/vs/x64/vocab_count/vocab_count/vocab_count.vcxproj.filters
similarity index 100%
rename from vs/vocab_count/vocab_count/vocab_count.vcxproj.filters
rename to vs/x64/vocab_count/vocab_count/vocab_count.vcxproj.filters
diff --git a/vs/vocab_count/vocab_count/vocab_count.vcxproj.user b/vs/x64/vocab_count/vocab_count/vocab_count.vcxproj.user
similarity index 100%
rename from vs/vocab_count/vocab_count/vocab_count.vcxproj.user
rename to vs/x64/vocab_count/vocab_count/vocab_count.vcxproj.user
diff --git a/vs/x64/vocab_count/vocab_count/x64/Release/vc140.pdb b/vs/x64/vocab_count/vocab_count/x64/Release/vc140.pdb
new file mode 100644
index 0000000..7184531
Binary files /dev/null and b/vs/x64/vocab_count/vocab_count/x64/Release/vc140.pdb differ
diff --git a/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.log b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.log
new file mode 100644
index 0000000..d74d64d
--- /dev/null
+++ b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.log
@@ -0,0 +1,11 @@
+ vocab_count.c
+vocab_count.c(101): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+vocab_count.c(133): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1769): note: 参见“sprintf”的声明
+vocab_count.c(134): warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
+ C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(1193): note: 参见“fscanf”的声明
+ 正在生成代码
+ All 19 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
+ 已完成代码的生成
+ vocab_count.vcxproj -> E:\ano\Workspace\glove-win\vs\x64\vocab_count\x64\Release\vocab_count.exe
+ vocab_count.vcxproj -> E:\ano\Workspace\glove-win\vs\x64\vocab_count\x64\Release\vocab_count.pdb (Full PDB)
diff --git a/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/CL.command.1.tlog b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/CL.command.1.tlog
new file mode 100644
index 0000000..5a520a2
Binary files /dev/null and b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/CL.command.1.tlog differ
diff --git a/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/CL.read.1.tlog b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/CL.read.1.tlog
new file mode 100644
index 0000000..0760ff7
Binary files /dev/null and b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/CL.read.1.tlog differ
diff --git a/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/CL.write.1.tlog b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/CL.write.1.tlog
new file mode 100644
index 0000000..e09b382
Binary files /dev/null and b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/CL.write.1.tlog differ
diff --git a/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/link.command.1.tlog b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/link.command.1.tlog
new file mode 100644
index 0000000..ca99b10
Binary files /dev/null and b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/link.command.1.tlog differ
diff --git a/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/link.read.1.tlog b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/link.read.1.tlog
new file mode 100644
index 0000000..8415d73
Binary files /dev/null and b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/link.read.1.tlog differ
diff --git a/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/link.write.1.tlog b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/link.write.1.tlog
new file mode 100644
index 0000000..8bcdbbf
Binary files /dev/null and b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/link.write.1.tlog differ
diff --git a/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/vocab_count.lastbuildstate b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/vocab_count.lastbuildstate
new file mode 100644
index 0000000..4ffe40d
--- /dev/null
+++ b/vs/x64/vocab_count/vocab_count/x64/Release/vocab_count.tlog/vocab_count.lastbuildstate
@@ -0,0 +1,2 @@
+#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
+Release|x64|E:\ano\Workspace\glove-win\vs\x64\vocab_count\|
diff --git a/vs/x64/vocab_count/x64/Release/vocab_count.iobj b/vs/x64/vocab_count/x64/Release/vocab_count.iobj
new file mode 100644
index 0000000..ea12aef
Binary files /dev/null and b/vs/x64/vocab_count/x64/Release/vocab_count.iobj differ
diff --git a/vs/x64/vocab_count/x64/Release/vocab_count.ipdb b/vs/x64/vocab_count/x64/Release/vocab_count.ipdb
new file mode 100644
index 0000000..c375c36
Binary files /dev/null and b/vs/x64/vocab_count/x64/Release/vocab_count.ipdb differ
diff --git a/vs/x64/vocab_count/x64/Release/vocab_count.pdb b/vs/x64/vocab_count/x64/Release/vocab_count.pdb
new file mode 100644
index 0000000..65012f1
Binary files /dev/null and b/vs/x64/vocab_count/x64/Release/vocab_count.pdb differ
diff --git a/vs/cooccur/.vs/cooccur/v14/.suo b/vs/x86/cooccur/.vs/cooccur/v14/.suo
similarity index 100%
rename from vs/cooccur/.vs/cooccur/v14/.suo
rename to vs/x86/cooccur/.vs/cooccur/v14/.suo
diff --git a/vs/cooccur/Release/cooccur.iobj b/vs/x86/cooccur/Release/cooccur.iobj
similarity index 100%
rename from vs/cooccur/Release/cooccur.iobj
rename to vs/x86/cooccur/Release/cooccur.iobj
diff --git a/vs/cooccur/Release/cooccur.ipdb b/vs/x86/cooccur/Release/cooccur.ipdb
similarity index 100%
rename from vs/cooccur/Release/cooccur.ipdb
rename to vs/x86/cooccur/Release/cooccur.ipdb
diff --git a/vs/cooccur/Release/cooccur.pdb b/vs/x86/cooccur/Release/cooccur.pdb
similarity index 100%
rename from vs/cooccur/Release/cooccur.pdb
rename to vs/x86/cooccur/Release/cooccur.pdb
diff --git a/vs/cooccur/cooccur.VC.db b/vs/x86/cooccur/cooccur.VC.db
similarity index 100%
rename from vs/cooccur/cooccur.VC.db
rename to vs/x86/cooccur/cooccur.VC.db
diff --git a/vs/x86/cooccur/cooccur.sln b/vs/x86/cooccur/cooccur.sln
new file mode 100644
index 0000000..cb2bb96
--- /dev/null
+++ b/vs/x86/cooccur/cooccur.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cooccur", "cooccur\cooccur.vcxproj", "{7B118E81-400D-4029-952E-10E8FDE806E1}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {7B118E81-400D-4029-952E-10E8FDE806E1}.Debug|x64.ActiveCfg = Debug|x64
+ {7B118E81-400D-4029-952E-10E8FDE806E1}.Debug|x64.Build.0 = Debug|x64
+ {7B118E81-400D-4029-952E-10E8FDE806E1}.Debug|x86.ActiveCfg = Debug|Win32
+ {7B118E81-400D-4029-952E-10E8FDE806E1}.Debug|x86.Build.0 = Debug|Win32
+ {7B118E81-400D-4029-952E-10E8FDE806E1}.Release|x64.ActiveCfg = Release|x64
+ {7B118E81-400D-4029-952E-10E8FDE806E1}.Release|x64.Build.0 = Release|x64
+ {7B118E81-400D-4029-952E-10E8FDE806E1}.Release|x86.ActiveCfg = Release|Win32
+ {7B118E81-400D-4029-952E-10E8FDE806E1}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/vs/cooccur/cooccur/Release/cooccur.Build.CppClean.log b/vs/x86/cooccur/cooccur/Release/cooccur.Build.CppClean.log
similarity index 100%
rename from vs/cooccur/cooccur/Release/cooccur.Build.CppClean.log
rename to vs/x86/cooccur/cooccur/Release/cooccur.Build.CppClean.log
diff --git a/vs/cooccur/cooccur/Release/cooccur.log b/vs/x86/cooccur/cooccur/Release/cooccur.log
similarity index 100%
rename from vs/cooccur/cooccur/Release/cooccur.log
rename to vs/x86/cooccur/cooccur/Release/cooccur.log
diff --git a/vs/cooccur/cooccur/Release/cooccur.tlog/CL.command.1.tlog b/vs/x86/cooccur/cooccur/Release/cooccur.tlog/CL.command.1.tlog
similarity index 100%
rename from vs/cooccur/cooccur/Release/cooccur.tlog/CL.command.1.tlog
rename to vs/x86/cooccur/cooccur/Release/cooccur.tlog/CL.command.1.tlog
diff --git a/vs/cooccur/cooccur/Release/cooccur.tlog/CL.read.1.tlog b/vs/x86/cooccur/cooccur/Release/cooccur.tlog/CL.read.1.tlog
similarity index 100%
rename from vs/cooccur/cooccur/Release/cooccur.tlog/CL.read.1.tlog
rename to vs/x86/cooccur/cooccur/Release/cooccur.tlog/CL.read.1.tlog
diff --git a/vs/cooccur/cooccur/Release/cooccur.tlog/CL.write.1.tlog b/vs/x86/cooccur/cooccur/Release/cooccur.tlog/CL.write.1.tlog
similarity index 100%
rename from vs/cooccur/cooccur/Release/cooccur.tlog/CL.write.1.tlog
rename to vs/x86/cooccur/cooccur/Release/cooccur.tlog/CL.write.1.tlog
diff --git a/vs/cooccur/cooccur/Release/cooccur.tlog/cooccur.lastbuildstate b/vs/x86/cooccur/cooccur/Release/cooccur.tlog/cooccur.lastbuildstate
similarity index 100%
rename from vs/cooccur/cooccur/Release/cooccur.tlog/cooccur.lastbuildstate
rename to vs/x86/cooccur/cooccur/Release/cooccur.tlog/cooccur.lastbuildstate
diff --git a/vs/cooccur/cooccur/Release/cooccur.tlog/link.command.1.tlog b/vs/x86/cooccur/cooccur/Release/cooccur.tlog/link.command.1.tlog
similarity index 100%
rename from vs/cooccur/cooccur/Release/cooccur.tlog/link.command.1.tlog
rename to vs/x86/cooccur/cooccur/Release/cooccur.tlog/link.command.1.tlog
diff --git a/vs/cooccur/cooccur/Release/cooccur.tlog/link.read.1.tlog b/vs/x86/cooccur/cooccur/Release/cooccur.tlog/link.read.1.tlog
similarity index 100%
rename from vs/cooccur/cooccur/Release/cooccur.tlog/link.read.1.tlog
rename to vs/x86/cooccur/cooccur/Release/cooccur.tlog/link.read.1.tlog
diff --git a/vs/cooccur/cooccur/Release/cooccur.tlog/link.write.1.tlog b/vs/x86/cooccur/cooccur/Release/cooccur.tlog/link.write.1.tlog
similarity index 100%
rename from vs/cooccur/cooccur/Release/cooccur.tlog/link.write.1.tlog
rename to vs/x86/cooccur/cooccur/Release/cooccur.tlog/link.write.1.tlog
diff --git a/vs/cooccur/cooccur/Release/vc140.pdb b/vs/x86/cooccur/cooccur/Release/vc140.pdb
similarity index 100%
rename from vs/cooccur/cooccur/Release/vc140.pdb
rename to vs/x86/cooccur/cooccur/Release/vc140.pdb
diff --git a/vs/x86/cooccur/cooccur/cooccur.c b/vs/x86/cooccur/cooccur/cooccur.c
new file mode 100644
index 0000000..0824e3c
--- /dev/null
+++ b/vs/x86/cooccur/cooccur/cooccur.c
@@ -0,0 +1,478 @@
+// Tool to calculate word-word cooccurrence statistics
+//
+// Copyright (c) 2014 The Board of Trustees of
+// The Leland Stanford Junior University. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+// For more information, bug reports, fixes, contact:
+// Jeffrey Pennington (jpennin@stanford.edu)
+// GlobalVectors@googlegroups.com
+// http://nlp.stanford.edu/projects/glove/
+
+#include
+#include
+#include
+#include
+
+#define TSIZE 1048576
+#define SEED 1159241
+#define HASHFN bitwisehash
+
+static const int MAX_STRING_LENGTH = 1000;
+#define _MAX_STRING_LENGTH 1000
+typedef double real;
+
+typedef struct cooccur_rec {
+ int word1;
+ int word2;
+ real val;
+} CREC;
+
+typedef struct cooccur_rec_id {
+ int word1;
+ int word2;
+ real val;
+ int id;
+} CRECID;
+
+typedef struct hashrec {
+ char *word;
+ long long id;
+ struct hashrec *next;
+} HASHREC;
+
+int verbose = 2; // 0, 1, or 2
+long long max_product; // Cutoff for product of word frequency ranks below which cooccurrence counts will be stored in a compressed full array
+long long overflow_length; // Number of cooccurrence records whose product exceeds max_product to store in memory before writing to disk
+int window_size = 15; // default context window size
+int symmetric = 1; // 0: asymmetric, 1: symmetric
+real memory_limit = 3; // soft limit, in gigabytes, used to estimate optimal array sizes
+char *vocab_file, *file_head;
+
+/* Efficient string comparison */
+int scmp(char *s1, char *s2) {
+ while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
+ return(*s1 - *s2);
+}
+
+/* Move-to-front hashing and hash function from Hugh Williams, http://www.seg.rmit.edu.au/code/zwh-ipl/ */
+
+/* Simple bitwise hash function */
+unsigned int bitwisehash(char *word, int tsize, unsigned int seed) {
+ char c;
+ unsigned int h;
+ h = seed;
+ for (; (c = *word) != '\0'; word++) h ^= ((h << 5) + c + (h >> 2));
+ return((unsigned int)((h & 0x7fffffff) % tsize));
+}
+
+/* Create hash table, initialise pointers to NULL */
+HASHREC ** inithashtable() {
+ int i;
+ HASHREC **ht;
+ ht = (HASHREC **)malloc(sizeof(HASHREC *) * TSIZE);
+ for (i = 0; i < TSIZE; i++) ht[i] = (HASHREC *)NULL;
+ return(ht);
+}
+
+/* Search hash table for given string, return record if found, else NULL */
+HASHREC *hashsearch(HASHREC **ht, char *w) {
+ HASHREC *htmp, *hprv;
+ unsigned int hval = HASHFN(w, TSIZE, SEED);
+ for (hprv = NULL, htmp = ht[hval]; htmp != NULL && scmp(htmp->word, w) != 0; hprv = htmp, htmp = htmp->next);
+ if (htmp != NULL && hprv != NULL) { // move to front on access
+ hprv->next = htmp->next;
+ htmp->next = ht[hval];
+ ht[hval] = htmp;
+ }
+ return(htmp);
+}
+
+/* Insert string in hash table, check for duplicates which should be absent */
+void hashinsert(HASHREC **ht, char *w, long long id) {
+ HASHREC *htmp, *hprv;
+ unsigned int hval = HASHFN(w, TSIZE, SEED);
+ for (hprv = NULL, htmp = ht[hval]; htmp != NULL && scmp(htmp->word, w) != 0; hprv = htmp, htmp = htmp->next);
+ if (htmp == NULL) {
+ htmp = (HASHREC *)malloc(sizeof(HASHREC));
+ htmp->word = (char *)malloc(strlen(w) + 1);
+ strcpy(htmp->word, w);
+ htmp->id = id;
+ htmp->next = NULL;
+ if (hprv == NULL) ht[hval] = htmp;
+ else hprv->next = htmp;
+ }
+ else fprintf(stderr, "Error, duplicate entry located: %s.\n", htmp->word);
+ return;
+}
+
+/* Read word from input stream */
+int get_word(char *word, FILE *fin) {
+ int i = 0, ch;
+ while (!feof(fin)) {
+ ch = fgetc(fin);
+ if (ch == 13) continue;
+ if ((ch == ' ') || (ch == '\t') || (ch == '\n')) {
+ if (i > 0) {
+ if (ch == '\n') ungetc(ch, fin);
+ break;
+ }
+ if (ch == '\n') return 1;
+ else continue;
+ }
+ word[i++] = ch;
+ if (i >= MAX_STRING_LENGTH - 1) i--; // truncate words that exceed max length
+ }
+ word[i] = 0;
+ return 0;
+}
+
+/* Write sorted chunk of cooccurrence records to file, accumulating duplicate entries */
+int write_chunk(CREC *cr, long long length, FILE *fout) {
+ if (length == 0) return 0;
+
+ long long a = 0;
+ CREC old = cr[a];
+
+ for (a = 1; a < length; a++) {
+ if (cr[a].word1 == old.word1 && cr[a].word2 == old.word2) {
+ old.val += cr[a].val;
+ continue;
+ }
+ fwrite(&old, sizeof(CREC), 1, fout);
+ old = cr[a];
+ }
+ fwrite(&old, sizeof(CREC), 1, fout);
+ return 0;
+}
+
+/* Check if two cooccurrence records are for the same two words, used for qsort */
+int compare_crec(const void *a, const void *b) {
+ int c;
+ if ((c = ((CREC *)a)->word1 - ((CREC *)b)->word1) != 0) return c;
+ else return (((CREC *)a)->word2 - ((CREC *)b)->word2);
+
+}
+
+/* Check if two cooccurrence records are for the same two words */
+int compare_crecid(CRECID a, CRECID b) {
+ int c;
+ if ((c = a.word1 - b.word1) != 0) return c;
+ else return a.word2 - b.word2;
+}
+
+/* Swap two entries of priority queue */
+void swap_entry(CRECID *pq, int i, int j) {
+ CRECID temp = pq[i];
+ pq[i] = pq[j];
+ pq[j] = temp;
+}
+
+/* Insert entry into priority queue */
+void insert(CRECID *pq, CRECID new, int size) {
+ int j = size - 1, p;
+ pq[j] = new;
+ while ((p = (j - 1) / 2) >= 0) {
+ if (compare_crecid(pq[p], pq[j]) > 0) { swap_entry(pq, p, j); j = p; }
+ else break;
+ }
+}
+
+/* Delete entry from priority queue */
+void delete(CRECID *pq, int size) {
+ int j, p = 0;
+ pq[p] = pq[size - 1];
+ while ((j = 2 * p + 1) < size - 1) {
+ if (j == size - 2) {
+ if (compare_crecid(pq[p], pq[j]) > 0) swap_entry(pq, p, j);
+ return;
+ }
+ else {
+ if (compare_crecid(pq[j], pq[j + 1]) < 0) {
+ if (compare_crecid(pq[p], pq[j]) > 0) { swap_entry(pq, p, j); p = j; }
+ else return;
+ }
+ else {
+ if (compare_crecid(pq[p], pq[j + 1]) > 0) { swap_entry(pq, p, j + 1); p = j + 1; }
+ else return;
+ }
+ }
+ }
+}
+
+/* Write top node of priority queue to file, accumulating duplicate entries */
+int merge_write(CRECID new, CRECID *old, FILE *fout) {
+ if (new.word1 == old->word1 && new.word2 == old->word2) {
+ old->val += new.val;
+ return 0; // Indicates duplicate entry
+ }
+ fwrite(old, sizeof(CREC), 1, fout);
+ *old = new;
+ return 1; // Actually wrote to file
+}
+
+/* Merge [num] sorted files of cooccurrence records */
+int merge_files(int num) {
+ int i, size;
+ long long counter = 0;
+ CRECID *pq, new, old;
+ char filename[200];
+ FILE **fid, *fout;
+ fid = malloc(sizeof(FILE) * num);
+ pq = malloc(sizeof(CRECID) * num);
+ fout = stdout;
+ if (verbose > 1) fprintf(stderr, "Merging cooccurrence files: processed 0 lines.");
+
+ /* Open all files and add first entry of each to priority queue */
+ for (i = 0; i < num; i++) {
+ sprintf(filename, "%s_%04d.bin", file_head, i);
+ fid[i] = fopen(filename, "rb");
+ if (fid[i] == NULL) { fprintf(stderr, "Unable to open file %s.\n", filename); return 1; }
+ fread(&new, sizeof(CREC), 1, fid[i]);
+ new.id = i;
+ insert(pq, new, i + 1);
+ }
+
+ /* Pop top node, save it in old to see if the next entry is a duplicate */
+ size = num;
+ old = pq[0];
+ i = pq[0].id;
+ delete(pq, size);
+ fread(&new, sizeof(CREC), 1, fid[i]);
+ if (feof(fid[i])) size--;
+ else {
+ new.id = i;
+ insert(pq, new, size);
+ }
+
+ /* Repeatedly pop top node and fill priority queue until files have reached EOF */
+ while (size > 0) {
+ counter += merge_write(pq[0], &old, fout); // Only count the lines written to file, not duplicates
+ if ((counter % 100000) == 0) if (verbose > 1) fprintf(stderr, "\033[39G%lld lines.", counter);
+ i = pq[0].id;
+ delete(pq, size);
+ fread(&new, sizeof(CREC), 1, fid[i]);
+ if (feof(fid[i])) size--;
+ else {
+ new.id = i;
+ insert(pq, new, size);
+ }
+ }
+ fwrite(&old, sizeof(CREC), 1, fout);
+ fprintf(stderr, "\033[0GMerging cooccurrence files: processed %lld lines.\n", ++counter);
+ for (i = 0;i 0) {
+ fprintf(stderr, "window size: %d\n", window_size);
+ if (symmetric == 0) fprintf(stderr, "context: asymmetric\n");
+ else fprintf(stderr, "context: symmetric\n");
+ }
+ if (verbose > 1) fprintf(stderr, "max product: %lld\n", max_product);
+ if (verbose > 1) fprintf(stderr, "overflow length: %lld\n", overflow_length);
+ sprintf(format, "%%%ds %%lld", MAX_STRING_LENGTH); // Format to read from vocab file, which has (irrelevant) frequency data
+ if (verbose > 1) fprintf(stderr, "Reading vocab from file \"%s\"...", vocab_file);
+ fid = fopen(vocab_file, "r");
+ if (fid == NULL) { fprintf(stderr, "Unable to open vocab file %s.\n", vocab_file); return 1; }
+ while (fscanf(fid, format, str, &id) != EOF) hashinsert(vocab_hash, str, ++j); // Here id is not used: inserting vocab words into hash table with their frequency rank, j
+ fclose(fid);
+ vocab_size = j;
+ j = 0;
+ if (verbose > 1) fprintf(stderr, "loaded %lld words.\nBuilding lookup table...", vocab_size);
+
+ /* Build auxiliary lookup table used to index into bigram_table */
+ lookup = (long long *)calloc(vocab_size + 1, sizeof(long long));
+ if (lookup == NULL) {
+ fprintf(stderr, "Couldn't allocate memory!");
+ return 1;
+ }
+ lookup[0] = 1;
+ for (a = 1; a <= vocab_size; a++) {
+ if ((lookup[a] = max_product / a) < vocab_size) lookup[a] += lookup[a - 1];
+ else lookup[a] = lookup[a - 1] + vocab_size;
+ }
+ if (verbose > 1) fprintf(stderr, "table contains %lld elements.\n", lookup[a - 1]);
+
+ /* Allocate memory for full array which will store all cooccurrence counts for words whose product of frequency ranks is less than max_product */
+ bigram_table = (real *)calloc(lookup[a - 1], sizeof(real));
+ if (bigram_table == NULL) {
+ fprintf(stderr, "Couldn't allocate memory!");
+ return 1;
+ }
+
+ fid = stdin;
+ sprintf(format, "%%%ds", MAX_STRING_LENGTH);
+ sprintf(filename, "%s_%04d.bin", file_head, fidcounter);
+ foverflow = fopen(filename, "w");
+ if (verbose > 1) fprintf(stderr, "Processing token: 0");
+
+ /* For each token in input stream, calculate a weighted cooccurrence sum within window_size */
+ while (1) {
+ if (ind >= overflow_length - window_size) { // If overflow buffer is (almost) full, sort it and write it to temporary file
+ qsort(cr, ind, sizeof(CREC), compare_crec);
+ write_chunk(cr, ind, foverflow);
+ fclose(foverflow);
+ fidcounter++;
+ sprintf(filename, "%s_%04d.bin", file_head, fidcounter);
+ foverflow = fopen(filename, "w");
+ ind = 0;
+ }
+ flag = get_word(str, fid);
+ if (feof(fid)) break;
+ if (flag == 1) { j = 0; continue; } // Newline, reset line index (j)
+ counter++;
+ if ((counter % 100000) == 0) if (verbose > 1) fprintf(stderr, "\033[19G%lld", counter);
+ htmp = hashsearch(vocab_hash, str);
+ if (htmp == NULL) continue; // Skip out-of-vocabulary words
+ w2 = htmp->id; // Target word (frequency rank)
+ for (k = j - 1; k >= ((j > window_size) ? j - window_size : 0); k--) { // Iterate over all words to the left of target word, but not past beginning of line
+ w1 = history[k % window_size]; // Context word (frequency rank)
+ if (w1 < max_product / w2) { // Product is small enough to store in a full array
+ bigram_table[lookup[w1 - 1] + w2 - 2] += 1.0 / ((real)(j - k)); // Weight by inverse of distance between words
+ if (symmetric > 0) bigram_table[lookup[w2 - 1] + w1 - 2] += 1.0 / ((real)(j - k)); // If symmetric context is used, exchange roles of w2 and w1 (ie look at right context too)
+ }
+ else { // Product is too big, data is likely to be sparse. Store these entries in a temporary buffer to be sorted, merged (accumulated), and written to file when it gets full.
+ cr[ind].word1 = w1;
+ cr[ind].word2 = w2;
+ cr[ind].val = 1.0 / ((real)(j - k));
+ ind++; // Keep track of how full temporary buffer is
+ if (symmetric > 0) { // Symmetric context
+ cr[ind].word1 = w2;
+ cr[ind].word2 = w1;
+ cr[ind].val = 1.0 / ((real)(j - k));
+ ind++;
+ }
+ }
+ }
+ history[j % window_size] = w2; // Target word is stored in circular buffer to become context word in the future
+ j++;
+ }
+
+ /* Write out temp buffer for the final time (it may not be full) */
+ if (verbose > 1) fprintf(stderr, "\033[0GProcessed %lld tokens.\n", counter);
+ qsort(cr, ind, sizeof(CREC), compare_crec);
+ write_chunk(cr, ind, foverflow);
+ sprintf(filename, "%s_0000.bin", file_head);
+
+ /* Write out full bigram_table, skipping zeros */
+ if (verbose > 1) fprintf(stderr, "Writing cooccurrences to disk");
+ fid = fopen(filename, "w");
+ j = 1e6;
+ for (x = 1; x <= vocab_size; x++) {
+ if ((long long)(0.75*log(vocab_size / x)) < j) { j = (long long)(0.75*log(vocab_size / x)); if (verbose > 1) fprintf(stderr, "."); } // log's to make it look (sort of) pretty
+ for (y = 1; y <= (lookup[x] - lookup[x - 1]); y++) {
+ if ((r = bigram_table[lookup[x - 1] - 2 + y]) != 0) {
+ fwrite(&x, sizeof(int), 1, fid);
+ fwrite(&y, sizeof(int), 1, fid);
+ fwrite(&r, sizeof(real), 1, fid);
+ }
+ }
+ }
+
+ if (verbose > 1) fprintf(stderr, "%d files in total.\n", fidcounter + 1);
+ fclose(fid);
+ fclose(foverflow);
+ free(cr);
+ free(lookup);
+ free(bigram_table);
+ free(vocab_hash);
+ return merge_files(fidcounter + 1); // Merge the sorted temporary files
+}
+
+int find_arg(char *str, int argc, char **argv) {
+ int i;
+ for (i = 1; i < argc; i++) {
+ if (!scmp(str, argv[i])) {
+ if (i == argc - 1) {
+ printf("No argument given for %s\n", str);
+ exit(1);
+ }
+ return i;
+ }
+ }
+ return -1;
+}
+
+int main(int argc, char **argv) {
+ int i;
+ real rlimit, n = 1e5;
+ vocab_file = malloc(sizeof(char) * MAX_STRING_LENGTH);
+ file_head = malloc(sizeof(char) * MAX_STRING_LENGTH);
+
+ if (argc == 1) {
+ printf("Tool to calculate word-word cooccurrence statistics\n");
+ printf("Author: Jeffrey Pennington (jpennin@stanford.edu)\n\n");
+ printf("Usage options:\n");
+ printf("\t-verbose \n");
+ printf("\t\tSet verbosity: 0, 1, or 2 (default)\n");
+ printf("\t-symmetric \n");
+ printf("\t\tIf = 0, only use left context; if = 1 (default), use left and right\n");
+ printf("\t-window-size \n");
+ printf("\t\tNumber of context words to the left (and to the right, if symmetric = 1); default 15\n");
+ printf("\t-vocab-file \n");
+ printf("\t\tFile containing vocabulary (truncated unigram counts, produced by 'vocab_count'); default vocab.txt\n");
+ printf("\t-memory \n");
+ printf("\t\tSoft limit for memory consumption, in GB -- based on simple heuristic, so not extremely accurate; default 4.0\n");
+ printf("\t-max-product \n");
+ printf("\t\tLimit the size of dense cooccurrence array by specifying the max product of the frequency counts of the two cooccurring words.\n\t\tThis value overrides that which is automatically produced by '-memory'. Typically only needs adjustment for use with very large corpora.\n");
+ printf("\t-overflow-length \n");
+ printf("\t\tLimit to length the sparse overflow array, which buffers cooccurrence data that does not fit in the dense array, before writing to disk. \n\t\tThis value overrides that which is automatically produced by '-memory'. Typically only needs adjustment for use with very large corpora.\n");
+ printf("\t-overflow-file \n");
+ printf("\t\tFilename, excluding extension, for temporary files; default overflow\n");
+
+ printf("\nExample usage:\n");
+ printf("./cooccur -verbose 2 -symmetric 0 -window-size 10 -vocab-file vocab.txt -memory 8.0 -overflow-file tempoverflow < corpus.txt > cooccurrences.bin\n\n");
+ return 0;
+ }
+
+ if ((i = find_arg((char *)"-verbose", argc, argv)) > 0) verbose = atoi(argv[i + 1]);
+ if ((i = find_arg((char *)"-symmetric", argc, argv)) > 0) symmetric = atoi(argv[i + 1]);
+ if ((i = find_arg((char *)"-window-size", argc, argv)) > 0) window_size = atoi(argv[i + 1]);
+ if ((i = find_arg((char *)"-vocab-file", argc, argv)) > 0) strcpy(vocab_file, argv[i + 1]);
+ else strcpy(vocab_file, (char *)"vocab.txt");
+ if ((i = find_arg((char *)"-overflow-file", argc, argv)) > 0) strcpy(file_head, argv[i + 1]);
+ else strcpy(file_head, (char *)"overflow");
+ if ((i = find_arg((char *)"-memory", argc, argv)) > 0) memory_limit = atof(argv[i + 1]);
+
+ /* The memory_limit determines a limit on the number of elements in bigram_table and the overflow buffer */
+ /* Estimate the maximum value that max_product can take so that this limit is still satisfied */
+ rlimit = 0.85 * (real)memory_limit * 1073741824 / (sizeof(CREC));
+ while (fabs(rlimit - n * (log(n) + 0.1544313298)) > 1e-3) n = rlimit / (log(n) + 0.1544313298);
+ max_product = (long long)n;
+ overflow_length = (long long)rlimit / 6; // 0.85 + 1/6 ~= 1
+
+ /* Override estimates by specifying limits explicitly on the command line */
+ if ((i = find_arg((char *)"-max-product", argc, argv)) > 0) max_product = atoll(argv[i + 1]);
+ if ((i = find_arg((char *)"-overflow-length", argc, argv)) > 0) overflow_length = atoll(argv[i + 1]);
+
+ return get_cooccurrence();
+}
\ No newline at end of file
diff --git a/vs/x86/cooccur/cooccur/cooccur.vcxproj b/vs/x86/cooccur/cooccur/cooccur.vcxproj
new file mode 100644
index 0000000..3eb4b2e
--- /dev/null
+++ b/vs/x86/cooccur/cooccur/cooccur.vcxproj
@@ -0,0 +1,150 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ {7B118E81-400D-4029-952E-10E8FDE806E1}
+ Win32Proj
+ cooccur
+ 8.1
+
+
+
+ Application
+ true
+ v140
+ Unicode
+
+
+ Application
+ false
+ v140
+ true
+ Unicode
+
+
+ Application
+ true
+ v140
+ Unicode
+
+
+ Application
+ false
+ v140
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+
+
+
+
+
+
+ Level3
+ Disabled
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vs/x86/cooccur/cooccur/cooccur.vcxproj.filters b/vs/x86/cooccur/cooccur/cooccur.vcxproj.filters
new file mode 100644
index 0000000..2f7e366
--- /dev/null
+++ b/vs/x86/cooccur/cooccur/cooccur.vcxproj.filters
@@ -0,0 +1,22 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ 源文件
+
+
+
\ No newline at end of file
diff --git a/vs/x86/cooccur/cooccur/cooccur.vcxproj.user b/vs/x86/cooccur/cooccur/cooccur.vcxproj.user
new file mode 100644
index 0000000..abe8dd8
--- /dev/null
+++ b/vs/x86/cooccur/cooccur/cooccur.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/vs/glove/.vs/glove/v14/.suo b/vs/x86/glove/.vs/glove/v14/.suo
similarity index 100%
rename from vs/glove/.vs/glove/v14/.suo
rename to vs/x86/glove/.vs/glove/v14/.suo
diff --git a/vs/glove/Release/glove.iobj b/vs/x86/glove/Release/glove.iobj
similarity index 100%
rename from vs/glove/Release/glove.iobj
rename to vs/x86/glove/Release/glove.iobj
diff --git a/vs/glove/Release/glove.ipdb b/vs/x86/glove/Release/glove.ipdb
similarity index 100%
rename from vs/glove/Release/glove.ipdb
rename to vs/x86/glove/Release/glove.ipdb
diff --git a/vs/glove/Release/glove.pdb b/vs/x86/glove/Release/glove.pdb
similarity index 100%
rename from vs/glove/Release/glove.pdb
rename to vs/x86/glove/Release/glove.pdb
diff --git a/vs/glove/glove.VC.db b/vs/x86/glove/glove.VC.db
similarity index 100%
rename from vs/glove/glove.VC.db
rename to vs/x86/glove/glove.VC.db
diff --git a/vs/x86/glove/glove.sln b/vs/x86/glove/glove.sln
new file mode 100644
index 0000000..5444955
--- /dev/null
+++ b/vs/x86/glove/glove.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glove", "glove\glove.vcxproj", "{A5F18589-3957-440A-A1A7-9BC03B3955B0}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A5F18589-3957-440A-A1A7-9BC03B3955B0}.Debug|x64.ActiveCfg = Debug|x64
+ {A5F18589-3957-440A-A1A7-9BC03B3955B0}.Debug|x64.Build.0 = Debug|x64
+ {A5F18589-3957-440A-A1A7-9BC03B3955B0}.Debug|x86.ActiveCfg = Debug|Win32
+ {A5F18589-3957-440A-A1A7-9BC03B3955B0}.Debug|x86.Build.0 = Debug|Win32
+ {A5F18589-3957-440A-A1A7-9BC03B3955B0}.Release|x64.ActiveCfg = Release|x64
+ {A5F18589-3957-440A-A1A7-9BC03B3955B0}.Release|x64.Build.0 = Release|x64
+ {A5F18589-3957-440A-A1A7-9BC03B3955B0}.Release|x86.ActiveCfg = Release|Win32
+ {A5F18589-3957-440A-A1A7-9BC03B3955B0}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/vs/glove/glove/Release/glove.Build.CppClean.log b/vs/x86/glove/glove/Release/glove.Build.CppClean.log
similarity index 100%
rename from vs/glove/glove/Release/glove.Build.CppClean.log
rename to vs/x86/glove/glove/Release/glove.Build.CppClean.log
diff --git a/vs/glove/glove/Release/glove.log b/vs/x86/glove/glove/Release/glove.log
similarity index 100%
rename from vs/glove/glove/Release/glove.log
rename to vs/x86/glove/glove/Release/glove.log
diff --git a/vs/glove/glove/Release/glove.tlog/CL.command.1.tlog b/vs/x86/glove/glove/Release/glove.tlog/CL.command.1.tlog
similarity index 100%
rename from vs/glove/glove/Release/glove.tlog/CL.command.1.tlog
rename to vs/x86/glove/glove/Release/glove.tlog/CL.command.1.tlog
diff --git a/vs/glove/glove/Release/glove.tlog/CL.read.1.tlog b/vs/x86/glove/glove/Release/glove.tlog/CL.read.1.tlog
similarity index 100%
rename from vs/glove/glove/Release/glove.tlog/CL.read.1.tlog
rename to vs/x86/glove/glove/Release/glove.tlog/CL.read.1.tlog
diff --git a/vs/glove/glove/Release/glove.tlog/CL.write.1.tlog b/vs/x86/glove/glove/Release/glove.tlog/CL.write.1.tlog
similarity index 100%
rename from vs/glove/glove/Release/glove.tlog/CL.write.1.tlog
rename to vs/x86/glove/glove/Release/glove.tlog/CL.write.1.tlog
diff --git a/vs/glove/glove/Release/glove.tlog/glove.lastbuildstate b/vs/x86/glove/glove/Release/glove.tlog/glove.lastbuildstate
similarity index 100%
rename from vs/glove/glove/Release/glove.tlog/glove.lastbuildstate
rename to vs/x86/glove/glove/Release/glove.tlog/glove.lastbuildstate
diff --git a/vs/glove/glove/Release/glove.tlog/link.command.1.tlog b/vs/x86/glove/glove/Release/glove.tlog/link.command.1.tlog
similarity index 100%
rename from vs/glove/glove/Release/glove.tlog/link.command.1.tlog
rename to vs/x86/glove/glove/Release/glove.tlog/link.command.1.tlog
diff --git a/vs/glove/glove/Release/glove.tlog/link.read.1.tlog b/vs/x86/glove/glove/Release/glove.tlog/link.read.1.tlog
similarity index 100%
rename from vs/glove/glove/Release/glove.tlog/link.read.1.tlog
rename to vs/x86/glove/glove/Release/glove.tlog/link.read.1.tlog
diff --git a/vs/glove/glove/Release/glove.tlog/link.write.1.tlog b/vs/x86/glove/glove/Release/glove.tlog/link.write.1.tlog
similarity index 100%
rename from vs/glove/glove/Release/glove.tlog/link.write.1.tlog
rename to vs/x86/glove/glove/Release/glove.tlog/link.write.1.tlog
diff --git a/vs/glove/glove/Release/vc140.pdb b/vs/x86/glove/glove/Release/vc140.pdb
similarity index 100%
rename from vs/glove/glove/Release/vc140.pdb
rename to vs/x86/glove/glove/Release/vc140.pdb
diff --git a/vs/x86/glove/glove/glove.c b/vs/x86/glove/glove/glove.c
new file mode 100644
index 0000000..48a331a
--- /dev/null
+++ b/vs/x86/glove/glove/glove.c
@@ -0,0 +1,452 @@
+// GloVe: Global Vectors for Word Representation
+//
+// Copyright (c) 2014 The Board of Trustees of
+// The Leland Stanford Junior University. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+// For more information, bug reports, fixes, contact:
+// Jeffrey Pennington (jpennin@stanford.edu)
+// GlobalVectors@googlegroups.com
+// http://nlp.stanford.edu/projects/glove/
+
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define posix_memalign(p, a, s) (((*(p)) = _aligned_malloc((s), (a))), *(p) ?0 :errno)
+
+#pragma comment(lib, "pthreadVC2.lib")
+
+#define _FILE_OFFSET_BITS 64
+#define MAX_STRING_LENGTH 1000
+
+typedef double real;
+
+typedef struct cooccur_rec {
+ int word1;
+ int word2;
+ real val;
+} CREC;
+
+int verbose = 2; // 0, 1, or 2
+int use_unk_vec = 1; // 0 or 1
+int num_threads = 8; // pthreads
+int num_iter = 25; // Number of full passes through cooccurrence matrix
+int vector_size = 50; // Word vector size
+int save_gradsq = 0; // By default don't save squared gradient values
+int use_binary = 0; // 0: save as text files; 1: save as binary; 2: both. For binary, save both word and context word vectors.
+int model = 2; // For text file output only. 0: concatenate word and context vectors (and biases) i.e. save everything; 1: Just save word vectors (no bias); 2: Save (word + context word) vectors (no biases)
+int checkpoint_every = 0; // checkpoint the model for every checkpoint_every iterations. Do nothing if checkpoint_every <= 0
+real eta = 0.05; // Initial learning rate
+real alpha = 0.75, x_max = 100.0; // Weighting function parameters, not extremely sensitive to corpus, though may need adjustment for very small or very large corpora
+real *W, *gradsq, *cost;
+long long num_lines, *lines_per_thread, vocab_size;
+char *vocab_file, *input_file, *save_W_file, *save_gradsq_file;
+
+/* Efficient string comparison */
+int scmp(char *s1, char *s2) {
+ while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
+ return(*s1 - *s2);
+}
+
+void initialize_parameters() {
+ long long a, b;
+ vector_size++; // Temporarily increment to allocate space for bias
+
+ /* Allocate space for word vectors and context word vectors, and correspodning gradsq */
+ a = posix_memalign((void **)&W, 128, 2 * vocab_size * (vector_size + 1) * sizeof(real)); // Might perform better than malloc
+ if (W == NULL) {
+ fprintf(stderr, "Error allocating memory for W\n");
+ exit(1);
+ }
+ a = posix_memalign((void **)&gradsq, 128, 2 * vocab_size * (vector_size + 1) * sizeof(real)); // Might perform better than malloc
+ if (gradsq == NULL) {
+ fprintf(stderr, "Error allocating memory for gradsq\n");
+ exit(1);
+ }
+ for (b = 0; b < vector_size; b++) for (a = 0; a < 2 * vocab_size; a++) W[a * vector_size + b] = (rand() / (real)RAND_MAX - 0.5) / vector_size;
+ for (b = 0; b < vector_size; b++) for (a = 0; a < 2 * vocab_size; a++) gradsq[a * vector_size + b] = 1.0; // So initial value of eta is equal to initial learning rate
+ vector_size--;
+}
+
+inline real check_nan(real update) {
+ if (isnan(update) || isinf(update)) {
+ fprintf(stderr, "\ncaught NaN in update");
+ return 0.;
+ }
+ else {
+ return update;
+ }
+}
+
+/* Train the GloVe model */
+void *glove_thread(void *vid) {
+ long long a, b, l1, l2;
+ long long id = *(long long*)vid;
+ CREC cr;
+ real diff, fdiff, temp1, temp2;
+ FILE *fin;
+ fin = fopen(input_file, "rb");
+ _fseeki64(fin, (num_lines / num_threads * id) * (sizeof(CREC)), SEEK_SET); //Threads spaced roughly equally throughout file
+ cost[id] = 0;
+
+ real* W_updates1 = (real*)malloc(vector_size * sizeof(real));
+ real* W_updates2 = (real*)malloc(vector_size * sizeof(real));
+ for (a = 0; a < lines_per_thread[id]; a++) {
+ fread(&cr, sizeof(CREC), 1, fin);
+ if (feof(fin)) break;
+ if (cr.word1 < 1 || cr.word2 < 1) { continue; }
+
+ /* Get location of words in W & gradsq */
+ l1 = (cr.word1 - 1LL) * (vector_size + 1); // cr word indices start at 1
+ l2 = ((cr.word2 - 1LL) + vocab_size) * (vector_size + 1); // shift by vocab_size to get separate vectors for context words
+
+ /* Calculate cost, save diff for gradients */
+ diff = 0;
+ for (b = 0; b < vector_size; b++) diff += W[b + l1] * W[b + l2]; // dot product of word and context word vector
+ diff += W[vector_size + l1] + W[vector_size + l2] - log(cr.val); // add separate bias for each word
+ fdiff = (cr.val > x_max) ? diff : pow(cr.val / x_max, alpha) * diff; // multiply weighting function (f) with diff
+
+ // Check for NaN and inf() in the diffs.
+ if (isnan(diff) || isnan(fdiff) || isinf(diff) || isinf(fdiff)) {
+ fprintf(stderr, "Caught NaN in diff for kdiff for thread. Skipping update");
+ continue;
+ }
+
+ cost[id] += 0.5 * fdiff * diff; // weighted squared error
+
+ /* Adaptive gradient updates */
+ fdiff *= eta; // for ease in calculating gradient
+ real W_updates1_sum = 0;
+ real W_updates2_sum = 0;
+ for (b = 0; b < vector_size; b++) {
+ // learning rate times gradient for word vectors
+ temp1 = fdiff * W[b + l2];
+ temp2 = fdiff * W[b + l1];
+ // adaptive updates
+ W_updates1[b] = temp1 / sqrt(gradsq[b + l1]);
+ W_updates2[b] = temp2 / sqrt(gradsq[b + l2]);
+ W_updates1_sum += W_updates1[b];
+ W_updates2_sum += W_updates2[b];
+ gradsq[b + l1] += temp1 * temp1;
+ gradsq[b + l2] += temp2 * temp2;
+ }
+ if (!isnan(W_updates1_sum) && !isinf(W_updates1_sum) && !isnan(W_updates2_sum) && !isinf(W_updates2_sum)) {
+ for (b = 0; b < vector_size; b++) {
+ W[b + l1] -= W_updates1[b];
+ W[b + l2] -= W_updates2[b];
+ }
+ }
+
+ // updates for bias terms
+ W[vector_size + l1] -= check_nan(fdiff / sqrt(gradsq[vector_size + l1]));
+ W[vector_size + l2] -= check_nan(fdiff / sqrt(gradsq[vector_size + l2]));
+ fdiff *= fdiff;
+ gradsq[vector_size + l1] += fdiff;
+ gradsq[vector_size + l2] += fdiff;
+
+ }
+ free(W_updates1);
+ free(W_updates2);
+
+ fclose(fin);
+ pthread_exit(NULL);
+}
+
+/* Save params to file */
+int save_params(int nb_iter) {
+ /*
+ * nb_iter is the number of iteration (= a full pass through the cooccurrence matrix).
+ * nb_iter > 0 => checkpointing the intermediate parameters, so nb_iter is in the filename of output file.
+ * else => saving the final paramters, so nb_iter is ignored.
+ */
+
+ long long a, b;
+ char format[20];
+ char output_file[MAX_STRING_LENGTH], output_file_gsq[MAX_STRING_LENGTH];
+ char *word = malloc(sizeof(char) * MAX_STRING_LENGTH + 1);
+ FILE *fid, *fout, *fgs;
+
+ if (use_binary > 0) { // Save parameters in binary file
+ if (nb_iter <= 0)
+ sprintf(output_file, "%s.bin", save_W_file);
+ else
+ sprintf(output_file, "%s.%03d.bin", save_W_file, nb_iter);
+
+ fout = fopen(output_file, "wb");
+ if (fout == NULL) { fprintf(stderr, "Unable to open file %s.\n", save_W_file); return 1; }
+ for (a = 0; a < 2 * (long long)vocab_size * (vector_size + 1); a++) fwrite(&W[a], sizeof(real), 1, fout);
+ fclose(fout);
+ if (save_gradsq > 0) {
+ if (nb_iter <= 0)
+ sprintf(output_file_gsq, "%s.bin", save_gradsq_file);
+ else
+ sprintf(output_file_gsq, "%s.%03d.bin", save_gradsq_file, nb_iter);
+
+ fgs = fopen(output_file_gsq, "wb");
+ if (fgs == NULL) { fprintf(stderr, "Unable to open file %s.\n", save_gradsq_file); return 1; }
+ for (a = 0; a < 2 * (long long)vocab_size * (vector_size + 1); a++) fwrite(&gradsq[a], sizeof(real), 1, fgs);
+ fclose(fgs);
+ }
+ }
+ if (use_binary != 1) { // Save parameters in text file
+ if (nb_iter <= 0)
+ sprintf(output_file, "%s.txt", save_W_file);
+ else
+ sprintf(output_file, "%s.%03d.txt", save_W_file, nb_iter);
+ if (save_gradsq > 0) {
+ if (nb_iter <= 0)
+ sprintf(output_file_gsq, "%s.txt", save_gradsq_file);
+ else
+ sprintf(output_file_gsq, "%s.%03d.txt", save_gradsq_file, nb_iter);
+
+ fgs = fopen(output_file_gsq, "wb");
+ if (fgs == NULL) { fprintf(stderr, "Unable to open file %s.\n", save_gradsq_file); return 1; }
+ }
+ fout = fopen(output_file, "wb");
+ if (fout == NULL) { fprintf(stderr, "Unable to open file %s.\n", save_W_file); return 1; }
+ fid = fopen(vocab_file, "r");
+ sprintf(format, "%%%ds", MAX_STRING_LENGTH);
+ if (fid == NULL) { fprintf(stderr, "Unable to open file %s.\n", vocab_file); return 1; }
+ for (a = 0; a < vocab_size; a++) {
+ if (fscanf(fid, format, word) == 0) return 1;
+ // input vocab cannot contain special keyword
+ if (strcmp(word, "") == 0) return 1;
+ fprintf(fout, "%s", word);
+ if (model == 0) { // Save all parameters (including bias)
+ for (b = 0; b < (vector_size + 1); b++) fprintf(fout, " %lf", W[a * (vector_size + 1) + b]);
+ for (b = 0; b < (vector_size + 1); b++) fprintf(fout, " %lf", W[(vocab_size + a) * (vector_size + 1) + b]);
+ }
+ if (model == 1) // Save only "word" vectors (without bias)
+ for (b = 0; b < vector_size; b++) fprintf(fout, " %lf", W[a * (vector_size + 1) + b]);
+ if (model == 2) // Save "word + context word" vectors (without bias)
+ for (b = 0; b < vector_size; b++) fprintf(fout, " %lf", W[a * (vector_size + 1) + b] + W[(vocab_size + a) * (vector_size + 1) + b]);
+ fprintf(fout, "\n");
+ if (save_gradsq > 0) { // Save gradsq
+ fprintf(fgs, "%s", word);
+ for (b = 0; b < (vector_size + 1); b++) fprintf(fgs, " %lf", gradsq[a * (vector_size + 1) + b]);
+ for (b = 0; b < (vector_size + 1); b++) fprintf(fgs, " %lf", gradsq[(vocab_size + a) * (vector_size + 1) + b]);
+ fprintf(fgs, "\n");
+ }
+ if (fscanf(fid, format, word) == 0) return 1; // Eat irrelevant frequency entry
+ }
+
+ if (use_unk_vec) {
+ real* unk_vec = (real*)calloc((vector_size + 1), sizeof(real));
+ real* unk_context = (real*)calloc((vector_size + 1), sizeof(real));
+ word = "";
+
+ int num_rare_words = vocab_size < 100 ? vocab_size : 100;
+
+ for (a = vocab_size - num_rare_words; a < vocab_size; a++) {
+ for (b = 0; b < (vector_size + 1); b++) {
+ unk_vec[b] += W[a * (vector_size + 1) + b] / num_rare_words;
+ unk_context[b] += W[(vocab_size + a) * (vector_size + 1) + b] / num_rare_words;
+ }
+ }
+
+ fprintf(fout, "%s", word);
+ if (model == 0) { // Save all parameters (including bias)
+ for (b = 0; b < (vector_size + 1); b++) fprintf(fout, " %lf", unk_vec[b]);
+ for (b = 0; b < (vector_size + 1); b++) fprintf(fout, " %lf", unk_context[b]);
+ }
+ if (model == 1) // Save only "word" vectors (without bias)
+ for (b = 0; b < vector_size; b++) fprintf(fout, " %lf", unk_vec[b]);
+ if (model == 2) // Save "word + context word" vectors (without bias)
+ for (b = 0; b < vector_size; b++) fprintf(fout, " %lf", unk_vec[b] + unk_context[b]);
+ fprintf(fout, "\n");
+
+ free(unk_vec);
+ free(unk_context);
+ }
+
+ fclose(fid);
+ fclose(fout);
+ if (save_gradsq > 0) fclose(fgs);
+ }
+ return 0;
+}
+
+/* Train model */
+int train_glove() {
+ long long a, file_size;
+ int save_params_return_code;
+ int b;
+ FILE *fin;
+ real total_cost = 0;
+
+ fprintf(stderr, "TRAINING MODEL\n");
+
+ fin = fopen(input_file, "rb");
+ if (fin == NULL) { fprintf(stderr, "Unable to open cooccurrence file %s.\n", input_file); return 1; }
+ _fseeki64(fin, 0, SEEK_END);
+ file_size = _ftelli64(fin);
+ num_lines = file_size / (sizeof(CREC)); // Assuming the file isn't corrupt and consists only of CREC's
+ fclose(fin);
+ fprintf(stderr, "Read %lld lines.\n", num_lines);
+ if (verbose > 1) fprintf(stderr, "Initializing parameters...");
+ initialize_parameters();
+ if (verbose > 1) fprintf(stderr, "done.\n");
+ if (verbose > 0) fprintf(stderr, "vector size: %d\n", vector_size);
+ if (verbose > 0) fprintf(stderr, "vocab size: %lld\n", vocab_size);
+ if (verbose > 0) fprintf(stderr, "x_max: %lf\n", x_max);
+ if (verbose > 0) fprintf(stderr, "alpha: %lf\n", alpha);
+ pthread_t *pt = (pthread_t *)malloc(num_threads * sizeof(pthread_t));
+ lines_per_thread = (long long *)malloc(num_threads * sizeof(long long));
+
+ time_t rawtime;
+ struct tm *info;
+ char time_buffer[80];
+ // Lock-free asynchronous SGD
+ for (b = 0; b < num_iter; b++) {
+ total_cost = 0;
+ for (a = 0; a < num_threads - 1; a++) lines_per_thread[a] = num_lines / num_threads;
+ lines_per_thread[a] = num_lines / num_threads + num_lines % num_threads;
+ long long *thread_ids = (long long*)malloc(sizeof(long long) * num_threads);
+ for (a = 0; a < num_threads; a++) thread_ids[a] = a;
+ for (a = 0; a < num_threads; a++) pthread_create(&pt[a], NULL, glove_thread, (void *)&thread_ids[a]);
+ for (a = 0; a < num_threads; a++) pthread_join(pt[a], NULL);
+ for (a = 0; a < num_threads; a++) total_cost += cost[a];
+ free(thread_ids);
+
+ time(&rawtime);
+ info = localtime(&rawtime);
+ strftime(time_buffer, 80, "%x - %I:%M.%S%p", info);
+ fprintf(stderr, "%s, iter: %03d, cost: %lf\n", time_buffer, b + 1, total_cost / num_lines);
+
+ if (checkpoint_every > 0 && (b + 1) % checkpoint_every == 0) {
+ fprintf(stderr, " saving itermediate parameters for iter %03d...", b + 1);
+ save_params_return_code = save_params(b + 1);
+ if (save_params_return_code != 0)
+ return save_params_return_code;
+ fprintf(stderr, "done.\n");
+ }
+
+ }
+ free(pt);
+ free(lines_per_thread);
+ return save_params(0);
+}
+
+int find_arg(char *str, int argc, char **argv) {
+ int i;
+ for (i = 1; i < argc; i++) {
+ if (!scmp(str, argv[i])) {
+ if (i == argc - 1) {
+ printf("No argument given for %s\n", str);
+ exit(1);
+ }
+ return i;
+ }
+ }
+ return -1;
+}
+
+int main(int argc, char **argv) {
+ int i;
+ FILE *fid;
+ vocab_file = malloc(sizeof(char) * MAX_STRING_LENGTH);
+ input_file = malloc(sizeof(char) * MAX_STRING_LENGTH);
+ save_W_file = malloc(sizeof(char) * MAX_STRING_LENGTH);
+ save_gradsq_file = malloc(sizeof(char) * MAX_STRING_LENGTH);
+ int result = 0;
+
+ if (argc == 1) {
+ printf("GloVe: Global Vectors for Word Representation, v0.2\n");
+ printf("Author: Jeffrey Pennington (jpennin@stanford.edu)\n\n");
+ printf("Usage options:\n");
+ printf("\t-verbose \n");
+ printf("\t\tSet verbosity: 0, 1, or 2 (default)\n");
+ printf("\t-vector-size \n");
+ printf("\t\tDimension of word vector representations (excluding bias term); default 50\n");
+ printf("\t-threads \n");
+ printf("\t\tNumber of threads; default 8\n");
+ printf("\t-iter \n");
+ printf("\t\tNumber of training iterations; default 25\n");
+ printf("\t-eta \n");
+ printf("\t\tInitial learning rate; default 0.05\n");
+ printf("\t-alpha \n");
+ printf("\t\tParameter in exponent of weighting function; default 0.75\n");
+ printf("\t-x-max \n");
+ printf("\t\tParameter specifying cutoff in weighting function; default 100.0\n");
+ printf("\t-binary \n");
+ printf("\t\tSave output in binary format (0: text, 1: binary, 2: both); default 0\n");
+ printf("\t-model \n");
+ printf("\t\tModel for word vector output (for text output only); default 2\n");
+ printf("\t\t 0: output all data, for both word and context word vectors, including bias terms\n");
+ printf("\t\t 1: output word vectors, excluding bias terms\n");
+ printf("\t\t 2: output word vectors + context word vectors, excluding bias terms\n");
+ printf("\t-input-file \n");
+ printf("\t\tBinary input file of shuffled cooccurrence data (produced by 'cooccur' and 'shuffle'); default cooccurrence.shuf.bin\n");
+ printf("\t-vocab-file \n");
+ printf("\t\tFile containing vocabulary (truncated unigram counts, produced by 'vocab_count'); default vocab.txt\n");
+ printf("\t-save-file \n");
+ printf("\t\tFilename, excluding extension, for word vector output; default vectors\n");
+ printf("\t-gradsq-file \n");
+ printf("\t\tFilename, excluding extension, for squared gradient output; default gradsq\n");
+ printf("\t-save-gradsq \n");
+ printf("\t\tSave accumulated squared gradients; default 0 (off); ignored if gradsq-file is specified\n");
+ printf("\t-checkpoint-every \n");
+ printf("\t\tCheckpoint a model every iterations; default 0 (off)\n");
+ printf("\nExample usage:\n");
+ printf("./glove -input-file cooccurrence.shuf.bin -vocab-file vocab.txt -save-file vectors -gradsq-file gradsq -verbose 2 -vector-size 100 -threads 16 -alpha 0.75 -x-max 100.0 -eta 0.05 -binary 2 -model 2\n\n");
+ result = 0;
+ }
+ else {
+ if ((i = find_arg((char *)"-verbose", argc, argv)) > 0) verbose = atoi(argv[i + 1]);
+ if ((i = find_arg((char *)"-vector-size", argc, argv)) > 0) vector_size = atoi(argv[i + 1]);
+ if ((i = find_arg((char *)"-iter", argc, argv)) > 0) num_iter = atoi(argv[i + 1]);
+ if ((i = find_arg((char *)"-threads", argc, argv)) > 0) num_threads = atoi(argv[i + 1]);
+ cost = malloc(sizeof(real) * num_threads);
+ if ((i = find_arg((char *)"-alpha", argc, argv)) > 0) alpha = atof(argv[i + 1]);
+ if ((i = find_arg((char *)"-x-max", argc, argv)) > 0) x_max = atof(argv[i + 1]);
+ if ((i = find_arg((char *)"-eta", argc, argv)) > 0) eta = atof(argv[i + 1]);
+ if ((i = find_arg((char *)"-binary", argc, argv)) > 0) use_binary = atoi(argv[i + 1]);
+ if ((i = find_arg((char *)"-model", argc, argv)) > 0) model = atoi(argv[i + 1]);
+ if (model != 0 && model != 1) model = 2;
+ if ((i = find_arg((char *)"-save-gradsq", argc, argv)) > 0) save_gradsq = atoi(argv[i + 1]);
+ if ((i = find_arg((char *)"-vocab-file", argc, argv)) > 0) strcpy(vocab_file, argv[i + 1]);
+ else strcpy(vocab_file, (char *)"vocab.txt");
+ if ((i = find_arg((char *)"-save-file", argc, argv)) > 0) strcpy(save_W_file, argv[i + 1]);
+ else strcpy(save_W_file, (char *)"vectors");
+ if ((i = find_arg((char *)"-gradsq-file", argc, argv)) > 0) {
+ strcpy(save_gradsq_file, argv[i + 1]);
+ save_gradsq = 1;
+ }
+ else if (save_gradsq > 0) strcpy(save_gradsq_file, (char *)"gradsq");
+ if ((i = find_arg((char *)"-input-file", argc, argv)) > 0) strcpy(input_file, argv[i + 1]);
+ else strcpy(input_file, (char *)"cooccurrence.shuf.bin");
+ if ((i = find_arg((char *)"-checkpoint-every", argc, argv)) > 0) checkpoint_every = atoi(argv[i + 1]);
+
+ vocab_size = 0;
+ fid = fopen(vocab_file, "r");
+ if (fid == NULL) { fprintf(stderr, "Unable to open vocab file %s.\n", vocab_file); return 1; }
+ while ((i = getc(fid)) != EOF) if (i == '\n') vocab_size++; // Count number of entries in vocab_file
+ fclose(fid);
+
+ result = train_glove();
+ free(cost);
+ }
+ free(vocab_file);
+ free(input_file);
+ free(save_W_file);
+ free(save_gradsq_file);
+ return result;
+}
\ No newline at end of file
diff --git a/vs/glove/glove/glove.vcxproj b/vs/x86/glove/glove/glove.vcxproj
similarity index 100%
rename from vs/glove/glove/glove.vcxproj
rename to vs/x86/glove/glove/glove.vcxproj
diff --git a/vs/x86/glove/glove/glove.vcxproj.filters b/vs/x86/glove/glove/glove.vcxproj.filters
new file mode 100644
index 0000000..1c8f923
--- /dev/null
+++ b/vs/x86/glove/glove/glove.vcxproj.filters
@@ -0,0 +1,22 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ 源文件
+
+
+
\ No newline at end of file
diff --git a/vs/x86/glove/glove/glove.vcxproj.user b/vs/x86/glove/glove/glove.vcxproj.user
new file mode 100644
index 0000000..abe8dd8
--- /dev/null
+++ b/vs/x86/glove/glove/glove.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/vs/x86/pthreads.2/include/pthread.h b/vs/x86/pthreads.2/include/pthread.h
new file mode 100644
index 0000000..25eca8e
--- /dev/null
+++ b/vs/x86/pthreads.2/include/pthread.h
@@ -0,0 +1,1369 @@
+/* This is an implementation of the threads API of POSIX 1003.1-2001.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * 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( PTHREAD_H )
+#define PTHREAD_H
+
+/*
+ * See the README file for an explanation of the pthreads-win32 version
+ * numbering scheme and how the DLL is named etc.
+ */
+#define PTW32_VERSION 2,9,1,0
+#define PTW32_VERSION_STRING "2, 9, 1, 0\0"
+
+/* There are three implementations of cancel cleanup.
+ * Note that pthread.h is included in both application
+ * compilation units and also internally for the library.
+ * The code here and within the library aims to work
+ * for all reasonable combinations of environments.
+ *
+ * The three implementations are:
+ *
+ * WIN32 SEH
+ * C
+ * C++
+ *
+ * Please note that exiting a push/pop block via
+ * "return", "exit", "break", or "continue" will
+ * lead to different behaviour amongst applications
+ * depending upon whether the library was built
+ * using SEH, C++, or C. For example, a library built
+ * with SEH will call the cleanup routine, while both
+ * C++ and C built versions will not.
+ */
+
+/*
+ * Define defaults for cleanup code.
+ * Note: Unless the build explicitly defines one of the following, then
+ * we default to standard C style cleanup. This style uses setjmp/longjmp
+ * in the cancelation and thread exit implementations and therefore won't
+ * do stack unwinding if linked to applications that have it (e.g.
+ * C++ apps). This is currently consistent with most/all commercial Unix
+ * POSIX threads implementations.
+ */
+#if !defined( __CLEANUP_SEH ) && !defined( __CLEANUP_CXX ) && !defined( __CLEANUP_C )
+# define __CLEANUP_C
+#endif
+
+#if defined( __CLEANUP_SEH ) && ( !defined( _MSC_VER ) && !defined(PTW32_RC_MSC))
+#error ERROR [__FILE__, line __LINE__]: SEH is not supported for this compiler.
+#endif
+
+/*
+ * Stop here if we are being included by the resource compiler.
+ */
+#if !defined(RC_INVOKED)
+
+#undef PTW32_LEVEL
+
+#if defined(_POSIX_SOURCE)
+#define PTW32_LEVEL 0
+/* Early POSIX */
+#endif
+
+#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
+#undef PTW32_LEVEL
+#define PTW32_LEVEL 1
+/* Include 1b, 1c and 1d */
+#endif
+
+#if defined(INCLUDE_NP)
+#undef PTW32_LEVEL
+#define PTW32_LEVEL 2
+/* Include Non-Portable extensions */
+#endif
+
+#define PTW32_LEVEL_MAX 3
+
+#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_LEVEL)
+#define PTW32_LEVEL PTW32_LEVEL_MAX
+/* Include everything */
+#endif
+
+#if defined(_UWIN)
+# define HAVE_STRUCT_TIMESPEC 1
+# define HAVE_SIGNAL_H 1
+# undef HAVE_PTW32_CONFIG_H
+# pragma comment(lib, "pthread")
+#endif
+
+/*
+ * -------------------------------------------------------------
+ *
+ *
+ * Module: pthread.h
+ *
+ * Purpose:
+ * Provides an implementation of PThreads based upon the
+ * standard:
+ *
+ * POSIX 1003.1-2001
+ * and
+ * The Single Unix Specification version 3
+ *
+ * (these two are equivalent)
+ *
+ * in order to enhance code portability between Windows,
+ * various commercial Unix implementations, and Linux.
+ *
+ * See the ANNOUNCE file for a full list of conforming
+ * routines and defined constants, and a list of missing
+ * routines and constants not defined in this implementation.
+ *
+ * Authors:
+ * There have been many contributors to this library.
+ * The initial implementation was contributed by
+ * John Bossom, and several others have provided major
+ * sections or revisions of parts of the implementation.
+ * Often significant effort has been contributed to
+ * find and fix important bugs and other problems to
+ * improve the reliability of the library, which sometimes
+ * is not reflected in the amount of code which changed as
+ * result.
+ * As much as possible, the contributors are acknowledged
+ * in the ChangeLog file in the source code distribution
+ * where their changes are noted in detail.
+ *
+ * Contributors are listed in the CONTRIBUTORS file.
+ *
+ * As usual, all bouquets go to the contributors, and all
+ * brickbats go to the project maintainer.
+ *
+ * Maintainer:
+ * The code base for this project is coordinated and
+ * eventually pre-tested, packaged, and made available by
+ *
+ * Ross Johnson
+ *
+ * QA Testers:
+ * Ultimately, the library is tested in the real world by
+ * a host of competent and demanding scientists and
+ * engineers who report bugs and/or provide solutions
+ * which are then fixed or incorporated into subsequent
+ * versions of the library. Each time a bug is fixed, a
+ * test case is written to prove the fix and ensure
+ * that later changes to the code don't reintroduce the
+ * same error. The number of test cases is slowly growing
+ * and therefore so is the code reliability.
+ *
+ * Compliance:
+ * See the file ANNOUNCE for the list of implemented
+ * and not-implemented routines and defined options.
+ * Of course, these are all defined is this file as well.
+ *
+ * Web site:
+ * The source code and other information about this library
+ * are available from
+ *
+ * http://sources.redhat.com/pthreads-win32/
+ *
+ * -------------------------------------------------------------
+ */
+
+/* Try to avoid including windows.h */
+#if (defined(__MINGW64__) || defined(__MINGW32__)) && defined(__cplusplus)
+#define PTW32_INCLUDE_WINDOWS_H
+#endif
+
+#if defined(PTW32_INCLUDE_WINDOWS_H)
+#include
+#endif
+
+#if defined(_MSC_VER) && _MSC_VER < 1300 || defined(__DMC__)
+/*
+ * VC++6.0 or early compiler's header has no DWORD_PTR type.
+ */
+typedef unsigned long DWORD_PTR;
+typedef unsigned long ULONG_PTR;
+#endif
+/*
+ * -----------------
+ * autoconf switches
+ * -----------------
+ */
+
+#if defined(HAVE_PTW32_CONFIG_H)
+#include "config.h"
+#endif /* HAVE_PTW32_CONFIG_H */
+
+#if !defined(NEED_FTIME)
+#include
+#else /* NEED_FTIME */
+/* use native WIN32 time API */
+#endif /* NEED_FTIME */
+
+#if defined(HAVE_SIGNAL_H)
+#include
+#endif /* HAVE_SIGNAL_H */
+
+#include
+
+/*
+ * Boolean values to make us independent of system includes.
+ */
+enum {
+ PTW32_FALSE = 0,
+ PTW32_TRUE = (! PTW32_FALSE)
+};
+
+/*
+ * This is a duplicate of what is in the autoconf config.h,
+ * which is only used when building the pthread-win32 libraries.
+ */
+
+#if !defined(PTW32_CONFIG_H)
+# if defined(WINCE)
+# define NEED_ERRNO
+# define NEED_SEM
+# endif
+# if defined(__MINGW64__)
+# define HAVE_STRUCT_TIMESPEC
+# define HAVE_MODE_T
+# elif defined(_UWIN) || defined(__MINGW32__)
+# define HAVE_MODE_T
+# endif
+#endif
+
+/*
+ *
+ */
+
+#if PTW32_LEVEL >= PTW32_LEVEL_MAX
+#if defined(NEED_ERRNO)
+#include "need_errno.h"
+#else
+#include
+#endif
+#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
+
+/*
+ * Several systems don't define some error numbers.
+ */
+#if !defined(ENOTSUP)
+# define ENOTSUP 48 /* This is the value in Solaris. */
+#endif
+
+#if !defined(ETIMEDOUT)
+# define ETIMEDOUT 10060 /* Same as WSAETIMEDOUT */
+#endif
+
+#if !defined(ENOSYS)
+# define ENOSYS 140 /* Semi-arbitrary value */
+#endif
+
+#if !defined(EDEADLK)
+# if defined(EDEADLOCK)
+# define EDEADLK EDEADLOCK
+# else
+# define EDEADLK 36 /* This is the value in MSVC. */
+# endif
+#endif
+
+/* POSIX 2008 - related to robust mutexes */
+#if !defined(EOWNERDEAD)
+# define EOWNERDEAD 43
+#endif
+#if !defined(ENOTRECOVERABLE)
+# define ENOTRECOVERABLE 44
+#endif
+
+#include
+
+/*
+ * To avoid including windows.h we define only those things that we
+ * actually need from it.
+ */
+#if !defined(PTW32_INCLUDE_WINDOWS_H)
+#if !defined(HANDLE)
+# define PTW32__HANDLE_DEF
+# define HANDLE void *
+#endif
+#if !defined(DWORD)
+# define PTW32__DWORD_DEF
+# define DWORD unsigned long
+#endif
+#endif
+
+#define HAVE_STRUCT_TIMESPEC
+#if !defined(HAVE_STRUCT_TIMESPEC)
+#define HAVE_STRUCT_TIMESPEC
+#if !defined(_TIMESPEC_DEFINED)
+#define _TIMESPEC_DEFINED
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+#endif /* _TIMESPEC_DEFINED */
+#endif /* HAVE_STRUCT_TIMESPEC */
+
+#if !defined(SIG_BLOCK)
+#define SIG_BLOCK 0
+#endif /* SIG_BLOCK */
+
+#if !defined(SIG_UNBLOCK)
+#define SIG_UNBLOCK 1
+#endif /* SIG_UNBLOCK */
+
+#if !defined(SIG_SETMASK)
+#define SIG_SETMASK 2
+#endif /* SIG_SETMASK */
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif /* __cplusplus */
+
+/*
+ * -------------------------------------------------------------
+ *
+ * POSIX 1003.1-2001 Options
+ * =========================
+ *
+ * Options are normally set in , which is not provided
+ * with pthreads-win32.
+ *
+ * For conformance with the Single Unix Specification (version 3), all of the
+ * options below are defined, and have a value of either -1 (not supported)
+ * or 200112L (supported).
+ *
+ * These options can neither be left undefined nor have a value of 0, because
+ * either indicates that sysconf(), which is not implemented, may be used at
+ * runtime to check the status of the option.
+ *
+ * _POSIX_THREADS (== 200112L)
+ * If == 200112L, you can use threads
+ *
+ * _POSIX_THREAD_ATTR_STACKSIZE (== 200112L)
+ * If == 200112L, you can control the size of a thread's
+ * stack
+ * pthread_attr_getstacksize
+ * pthread_attr_setstacksize
+ *
+ * _POSIX_THREAD_ATTR_STACKADDR (== -1)
+ * If == 200112L, you can allocate and control a thread's
+ * stack. If not supported, the following functions
+ * will return ENOSYS, indicating they are not
+ * supported:
+ * pthread_attr_getstackaddr
+ * pthread_attr_setstackaddr
+ *
+ * _POSIX_THREAD_PRIORITY_SCHEDULING (== -1)
+ * If == 200112L, you can use realtime scheduling.
+ * This option indicates that the behaviour of some
+ * implemented functions conforms to the additional TPS
+ * requirements in the standard. E.g. rwlocks favour
+ * writers over readers when threads have equal priority.
+ *
+ * _POSIX_THREAD_PRIO_INHERIT (== -1)
+ * If == 200112L, you can create priority inheritance
+ * mutexes.
+ * pthread_mutexattr_getprotocol +
+ * pthread_mutexattr_setprotocol +
+ *
+ * _POSIX_THREAD_PRIO_PROTECT (== -1)
+ * If == 200112L, you can create priority ceiling mutexes
+ * Indicates the availability of:
+ * pthread_mutex_getprioceiling
+ * pthread_mutex_setprioceiling
+ * pthread_mutexattr_getprioceiling
+ * pthread_mutexattr_getprotocol +
+ * pthread_mutexattr_setprioceiling
+ * pthread_mutexattr_setprotocol +
+ *
+ * _POSIX_THREAD_PROCESS_SHARED (== -1)
+ * If set, you can create mutexes and condition
+ * variables that can be shared with another
+ * process.If set, indicates the availability
+ * of:
+ * pthread_mutexattr_getpshared
+ * pthread_mutexattr_setpshared
+ * pthread_condattr_getpshared
+ * pthread_condattr_setpshared
+ *
+ * _POSIX_THREAD_SAFE_FUNCTIONS (== 200112L)
+ * If == 200112L you can use the special *_r library
+ * functions that provide thread-safe behaviour
+ *
+ * _POSIX_READER_WRITER_LOCKS (== 200112L)
+ * If == 200112L, you can use read/write locks
+ *
+ * _POSIX_SPIN_LOCKS (== 200112L)
+ * If == 200112L, you can use spin locks
+ *
+ * _POSIX_BARRIERS (== 200112L)
+ * If == 200112L, you can use barriers
+ *
+ * + These functions provide both 'inherit' and/or
+ * 'protect' protocol, based upon these macro
+ * settings.
+ *
+ * -------------------------------------------------------------
+ */
+
+/*
+ * POSIX Options
+ */
+#undef _POSIX_THREADS
+#define _POSIX_THREADS 200809L
+
+#undef _POSIX_READER_WRITER_LOCKS
+#define _POSIX_READER_WRITER_LOCKS 200809L
+
+#undef _POSIX_SPIN_LOCKS
+#define _POSIX_SPIN_LOCKS 200809L
+
+#undef _POSIX_BARRIERS
+#define _POSIX_BARRIERS 200809L
+
+#undef _POSIX_THREAD_SAFE_FUNCTIONS
+#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
+
+#undef _POSIX_THREAD_ATTR_STACKSIZE
+#define _POSIX_THREAD_ATTR_STACKSIZE 200809L
+
+/*
+ * The following options are not supported
+ */
+#undef _POSIX_THREAD_ATTR_STACKADDR
+#define _POSIX_THREAD_ATTR_STACKADDR -1
+
+#undef _POSIX_THREAD_PRIO_INHERIT
+#define _POSIX_THREAD_PRIO_INHERIT -1
+
+#undef _POSIX_THREAD_PRIO_PROTECT
+#define _POSIX_THREAD_PRIO_PROTECT -1
+
+/* TPS is not fully supported. */
+#undef _POSIX_THREAD_PRIORITY_SCHEDULING
+#define _POSIX_THREAD_PRIORITY_SCHEDULING -1
+
+#undef _POSIX_THREAD_PROCESS_SHARED
+#define _POSIX_THREAD_PROCESS_SHARED -1
+
+
+/*
+ * POSIX 1003.1-2001 Limits
+ * ===========================
+ *
+ * These limits are normally set in , which is not provided with
+ * pthreads-win32.
+ *
+ * PTHREAD_DESTRUCTOR_ITERATIONS
+ * Maximum number of attempts to destroy
+ * a thread's thread-specific data on
+ * termination (must be at least 4)
+ *
+ * PTHREAD_KEYS_MAX
+ * Maximum number of thread-specific data keys
+ * available per process (must be at least 128)
+ *
+ * PTHREAD_STACK_MIN
+ * Minimum supported stack size for a thread
+ *
+ * PTHREAD_THREADS_MAX
+ * Maximum number of threads supported per
+ * process (must be at least 64).
+ *
+ * SEM_NSEMS_MAX
+ * The maximum number of semaphores a process can have.
+ * (must be at least 256)
+ *
+ * SEM_VALUE_MAX
+ * The maximum value a semaphore can have.
+ * (must be at least 32767)
+ *
+ */
+#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS
+#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
+
+#undef PTHREAD_DESTRUCTOR_ITERATIONS
+#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
+
+#undef _POSIX_THREAD_KEYS_MAX
+#define _POSIX_THREAD_KEYS_MAX 128
+
+#undef PTHREAD_KEYS_MAX
+#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX
+
+#undef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 0
+
+#undef _POSIX_THREAD_THREADS_MAX
+#define _POSIX_THREAD_THREADS_MAX 64
+
+ /* Arbitrary value */
+#undef PTHREAD_THREADS_MAX
+#define PTHREAD_THREADS_MAX 2019
+
+#undef _POSIX_SEM_NSEMS_MAX
+#define _POSIX_SEM_NSEMS_MAX 256
+
+ /* Arbitrary value */
+#undef SEM_NSEMS_MAX
+#define SEM_NSEMS_MAX 1024
+
+#undef _POSIX_SEM_VALUE_MAX
+#define _POSIX_SEM_VALUE_MAX 32767
+
+#undef SEM_VALUE_MAX
+#define SEM_VALUE_MAX INT_MAX
+
+
+#if defined(__GNUC__) && !defined(__declspec)
+# error Please upgrade your GNU compiler to one that supports __declspec.
+#endif
+
+/*
+ * When building the library, you should define PTW32_BUILD so that
+ * the variables/functions are exported correctly. When using the library,
+ * do NOT define PTW32_BUILD, and then the variables/functions will
+ * be imported correctly.
+ */
+#if !defined(PTW32_STATIC_LIB)
+# if defined(PTW32_BUILD)
+# define PTW32_DLLPORT __declspec (dllexport)
+# else
+# define PTW32_DLLPORT __declspec (dllimport)
+# endif
+#else
+# define PTW32_DLLPORT
+#endif
+
+/*
+ * The Open Watcom C/C++ compiler uses a non-standard calling convention
+ * that passes function args in registers unless __cdecl is explicitly specified
+ * in exposed function prototypes.
+ *
+ * We force all calls to cdecl even though this could slow Watcom code down
+ * slightly. If you know that the Watcom compiler will be used to build both
+ * the DLL and application, then you can probably define this as a null string.
+ * Remember that pthread.h (this file) is used for both the DLL and application builds.
+ */
+#define PTW32_CDECL __cdecl
+
+#if defined(_UWIN) && PTW32_LEVEL >= PTW32_LEVEL_MAX
+# include
+#else
+/*
+ * Generic handle type - intended to extend uniqueness beyond
+ * that available with a simple pointer. It should scale for either
+ * IA-32 or IA-64.
+ */
+typedef struct {
+ void * p; /* Pointer to actual object */
+ unsigned int x; /* Extra information - reuse count etc */
+} ptw32_handle_t;
+
+typedef ptw32_handle_t pthread_t;
+typedef struct pthread_attr_t_ * pthread_attr_t;
+typedef struct pthread_once_t_ pthread_once_t;
+typedef struct pthread_key_t_ * pthread_key_t;
+typedef struct pthread_mutex_t_ * pthread_mutex_t;
+typedef struct pthread_mutexattr_t_ * pthread_mutexattr_t;
+typedef struct pthread_cond_t_ * pthread_cond_t;
+typedef struct pthread_condattr_t_ * pthread_condattr_t;
+#endif
+typedef struct pthread_rwlock_t_ * pthread_rwlock_t;
+typedef struct pthread_rwlockattr_t_ * pthread_rwlockattr_t;
+typedef struct pthread_spinlock_t_ * pthread_spinlock_t;
+typedef struct pthread_barrier_t_ * pthread_barrier_t;
+typedef struct pthread_barrierattr_t_ * pthread_barrierattr_t;
+
+/*
+ * ====================
+ * ====================
+ * POSIX Threads
+ * ====================
+ * ====================
+ */
+
+enum {
+/*
+ * pthread_attr_{get,set}detachstate
+ */
+ PTHREAD_CREATE_JOINABLE = 0, /* Default */
+ PTHREAD_CREATE_DETACHED = 1,
+
+/*
+ * pthread_attr_{get,set}inheritsched
+ */
+ PTHREAD_INHERIT_SCHED = 0,
+ PTHREAD_EXPLICIT_SCHED = 1, /* Default */
+
+/*
+ * pthread_{get,set}scope
+ */
+ PTHREAD_SCOPE_PROCESS = 0,
+ PTHREAD_SCOPE_SYSTEM = 1, /* Default */
+
+/*
+ * pthread_setcancelstate paramters
+ */
+ PTHREAD_CANCEL_ENABLE = 0, /* Default */
+ PTHREAD_CANCEL_DISABLE = 1,
+
+/*
+ * pthread_setcanceltype parameters
+ */
+ PTHREAD_CANCEL_ASYNCHRONOUS = 0,
+ PTHREAD_CANCEL_DEFERRED = 1, /* Default */
+
+/*
+ * pthread_mutexattr_{get,set}pshared
+ * pthread_condattr_{get,set}pshared
+ */
+ PTHREAD_PROCESS_PRIVATE = 0,
+ PTHREAD_PROCESS_SHARED = 1,
+
+/*
+ * pthread_mutexattr_{get,set}robust
+ */
+ PTHREAD_MUTEX_STALLED = 0, /* Default */
+ PTHREAD_MUTEX_ROBUST = 1,
+
+/*
+ * pthread_barrier_wait
+ */
+ PTHREAD_BARRIER_SERIAL_THREAD = -1
+};
+
+/*
+ * ====================
+ * ====================
+ * Cancelation
+ * ====================
+ * ====================
+ */
+#define PTHREAD_CANCELED ((void *)(size_t) -1)
+
+
+/*
+ * ====================
+ * ====================
+ * Once Key
+ * ====================
+ * ====================
+ */
+#define PTHREAD_ONCE_INIT { PTW32_FALSE, 0, 0, 0}
+
+struct pthread_once_t_
+{
+ int done; /* indicates if user function has been executed */
+ void * lock;
+ int reserved1;
+ int reserved2;
+};
+
+
+/*
+ * ====================
+ * ====================
+ * Object initialisers
+ * ====================
+ * ====================
+ */
+#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -1)
+#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -2)
+#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -3)
+
+/*
+ * Compatibility with LinuxThreads
+ */
+#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER
+#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP PTHREAD_ERRORCHECK_MUTEX_INITIALIZER
+
+#define PTHREAD_COND_INITIALIZER ((pthread_cond_t)(size_t) -1)
+
+#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t)(size_t) -1)
+
+#define PTHREAD_SPINLOCK_INITIALIZER ((pthread_spinlock_t)(size_t) -1)
+
+
+/*
+ * Mutex types.
+ */
+enum
+{
+ /* Compatibility with LinuxThreads */
+ PTHREAD_MUTEX_FAST_NP,
+ PTHREAD_MUTEX_RECURSIVE_NP,
+ PTHREAD_MUTEX_ERRORCHECK_NP,
+ PTHREAD_MUTEX_TIMED_NP = PTHREAD_MUTEX_FAST_NP,
+ PTHREAD_MUTEX_ADAPTIVE_NP = PTHREAD_MUTEX_FAST_NP,
+ /* For compatibility with POSIX */
+ PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_FAST_NP,
+ PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
+ PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
+ PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
+};
+
+
+typedef struct ptw32_cleanup_t ptw32_cleanup_t;
+
+#if defined(_MSC_VER)
+/* Disable MSVC 'anachronism used' warning */
+#pragma warning( disable : 4229 )
+#endif
+
+typedef void (* PTW32_CDECL ptw32_cleanup_callback_t)(void *);
+
+#if defined(_MSC_VER)
+#pragma warning( default : 4229 )
+#endif
+
+struct ptw32_cleanup_t
+{
+ ptw32_cleanup_callback_t routine;
+ void *arg;
+ struct ptw32_cleanup_t *prev;
+};
+
+#if defined(__CLEANUP_SEH)
+ /*
+ * WIN32 SEH version of cancel cleanup.
+ */
+
+#define pthread_cleanup_push( _rout, _arg ) \
+ { \
+ ptw32_cleanup_t _cleanup; \
+ \
+ _cleanup.routine = (ptw32_cleanup_callback_t)(_rout); \
+ _cleanup.arg = (_arg); \
+ __try \
+ { \
+
+#define pthread_cleanup_pop( _execute ) \
+ } \
+ __finally \
+ { \
+ if( _execute || AbnormalTermination()) \
+ { \
+ (*(_cleanup.routine))( _cleanup.arg ); \
+ } \
+ } \
+ }
+
+#else /* __CLEANUP_SEH */
+
+#if defined(__CLEANUP_C)
+
+ /*
+ * C implementation of PThreads cancel cleanup
+ */
+
+#define pthread_cleanup_push( _rout, _arg ) \
+ { \
+ ptw32_cleanup_t _cleanup; \
+ \
+ ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t) (_rout), (_arg) ); \
+
+#define pthread_cleanup_pop( _execute ) \
+ (void) ptw32_pop_cleanup( _execute ); \
+ }
+
+#else /* __CLEANUP_C */
+
+#if defined(__CLEANUP_CXX)
+
+ /*
+ * C++ version of cancel cleanup.
+ * - John E. Bossom.
+ */
+
+ class PThreadCleanup {
+ /*
+ * PThreadCleanup
+ *
+ * Purpose
+ * This class is a C++ helper class that is
+ * used to implement pthread_cleanup_push/
+ * pthread_cleanup_pop.
+ * The destructor of this class automatically
+ * pops the pushed cleanup routine regardless
+ * of how the code exits the scope
+ * (i.e. such as by an exception)
+ */
+ ptw32_cleanup_callback_t cleanUpRout;
+ void * obj;
+ int executeIt;
+
+ public:
+ PThreadCleanup() :
+ cleanUpRout( 0 ),
+ obj( 0 ),
+ executeIt( 0 )
+ /*
+ * No cleanup performed
+ */
+ {
+ }
+
+ PThreadCleanup(
+ ptw32_cleanup_callback_t routine,
+ void * arg ) :
+ cleanUpRout( routine ),
+ obj( arg ),
+ executeIt( 1 )
+ /*
+ * Registers a cleanup routine for 'arg'
+ */
+ {
+ }
+
+ ~PThreadCleanup()
+ {
+ if ( executeIt && ((void *) cleanUpRout != (void *) 0) )
+ {
+ (void) (*cleanUpRout)( obj );
+ }
+ }
+
+ void execute( int exec )
+ {
+ executeIt = exec;
+ }
+ };
+
+ /*
+ * C++ implementation of PThreads cancel cleanup;
+ * This implementation takes advantage of a helper
+ * class who's destructor automatically calls the
+ * cleanup routine if we exit our scope weirdly
+ */
+#define pthread_cleanup_push( _rout, _arg ) \
+ { \
+ PThreadCleanup cleanup((ptw32_cleanup_callback_t)(_rout), \
+ (void *) (_arg) );
+
+#define pthread_cleanup_pop( _execute ) \
+ cleanup.execute( _execute ); \
+ }
+
+#else
+
+#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined.
+
+#endif /* __CLEANUP_CXX */
+
+#endif /* __CLEANUP_C */
+
+#endif /* __CLEANUP_SEH */
+
+/*
+ * ===============
+ * ===============
+ * Methods
+ * ===============
+ * ===============
+ */
+
+/*
+ * PThread Attribute Functions
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_init (pthread_attr_t * attr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_destroy (pthread_attr_t * attr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getdetachstate (const pthread_attr_t * attr,
+ int *detachstate);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstackaddr (const pthread_attr_t * attr,
+ void **stackaddr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstacksize (const pthread_attr_t * attr,
+ size_t * stacksize);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setdetachstate (pthread_attr_t * attr,
+ int detachstate);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstackaddr (pthread_attr_t * attr,
+ void *stackaddr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstacksize (pthread_attr_t * attr,
+ size_t stacksize);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedparam (const pthread_attr_t *attr,
+ struct sched_param *param);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedparam (pthread_attr_t *attr,
+ const struct sched_param *param);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedpolicy (pthread_attr_t *,
+ int);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (const pthread_attr_t *,
+ int *);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr,
+ int inheritsched);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(const pthread_attr_t * attr,
+ int * inheritsched);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope (pthread_attr_t *,
+ int);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getscope (const pthread_attr_t *,
+ int *);
+
+/*
+ * PThread Functions
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_create (pthread_t * tid,
+ const pthread_attr_t * attr,
+ void *(PTW32_CDECL *start) (void *),
+ void *arg);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_detach (pthread_t tid);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_equal (pthread_t t1,
+ pthread_t t2);
+
+PTW32_DLLPORT void PTW32_CDECL pthread_exit (void *value_ptr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_join (pthread_t thread,
+ void **value_ptr);
+
+PTW32_DLLPORT pthread_t PTW32_CDECL pthread_self (void);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_cancel (pthread_t thread);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_setcancelstate (int state,
+ int *oldstate);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_setcanceltype (int type,
+ int *oldtype);
+
+PTW32_DLLPORT void PTW32_CDECL pthread_testcancel (void);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control,
+ void (PTW32_CDECL *init_routine) (void));
+
+#if PTW32_LEVEL >= PTW32_LEVEL_MAX
+PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute);
+
+PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup,
+ ptw32_cleanup_callback_t routine,
+ void *arg);
+#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
+
+/*
+ * Thread Specific Data Functions
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_key_create (pthread_key_t * key,
+ void (PTW32_CDECL *destructor) (void *));
+
+PTW32_DLLPORT int PTW32_CDECL pthread_key_delete (pthread_key_t key);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_setspecific (pthread_key_t key,
+ const void *value);
+
+PTW32_DLLPORT void * PTW32_CDECL pthread_getspecific (pthread_key_t key);
+
+
+/*
+ * Mutex Attribute Functions
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_init (pthread_mutexattr_t * attr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_destroy (pthread_mutexattr_t * attr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getpshared (const pthread_mutexattr_t
+ * attr,
+ int *pshared);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setpshared (pthread_mutexattr_t * attr,
+ int pshared);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind);
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setrobust(
+ pthread_mutexattr_t *attr,
+ int robust);
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getrobust(
+ const pthread_mutexattr_t * attr,
+ int * robust);
+
+/*
+ * Barrier Attribute Functions
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_init (pthread_barrierattr_t * attr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_destroy (pthread_barrierattr_t * attr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_getpshared (const pthread_barrierattr_t
+ * attr,
+ int *pshared);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_setpshared (pthread_barrierattr_t * attr,
+ int pshared);
+
+/*
+ * Mutex Functions
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_mutex_init (pthread_mutex_t * mutex,
+ const pthread_mutexattr_t * attr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_mutex_destroy (pthread_mutex_t * mutex);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_mutex_lock (pthread_mutex_t * mutex);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t * mutex,
+ const struct timespec *abstime);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_mutex_unlock (pthread_mutex_t * mutex);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_mutex_consistent (pthread_mutex_t * mutex);
+
+/*
+ * Spinlock Functions
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_spin_init (pthread_spinlock_t * lock, int pshared);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_spin_destroy (pthread_spinlock_t * lock);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_spin_lock (pthread_spinlock_t * lock);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_spin_trylock (pthread_spinlock_t * lock);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_spin_unlock (pthread_spinlock_t * lock);
+
+/*
+ * Barrier Functions
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_barrier_init (pthread_barrier_t * barrier,
+ const pthread_barrierattr_t * attr,
+ unsigned int count);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_barrier_destroy (pthread_barrier_t * barrier);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_barrier_wait (pthread_barrier_t * barrier);
+
+/*
+ * Condition Variable Attribute Functions
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_condattr_init (pthread_condattr_t * attr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_condattr_destroy (pthread_condattr_t * attr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_condattr_getpshared (const pthread_condattr_t * attr,
+ int *pshared);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_condattr_setpshared (pthread_condattr_t * attr,
+ int pshared);
+
+/*
+ * Condition Variable Functions
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_cond_init (pthread_cond_t * cond,
+ const pthread_condattr_t * attr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_cond_destroy (pthread_cond_t * cond);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_cond_wait (pthread_cond_t * cond,
+ pthread_mutex_t * mutex);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_cond_timedwait (pthread_cond_t * cond,
+ pthread_mutex_t * mutex,
+ const struct timespec *abstime);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_cond_signal (pthread_cond_t * cond);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_cond_broadcast (pthread_cond_t * cond);
+
+/*
+ * Scheduling
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_setschedparam (pthread_t thread,
+ int policy,
+ const struct sched_param *param);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_getschedparam (pthread_t thread,
+ int *policy,
+ struct sched_param *param);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_setconcurrency (int);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_getconcurrency (void);
+
+/*
+ * Read-Write Lock Functions
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_init(pthread_rwlock_t *lock,
+ const pthread_rwlockattr_t *attr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_destroy(pthread_rwlock_t *lock);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_tryrdlock(pthread_rwlock_t *);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_trywrlock(pthread_rwlock_t *);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_rdlock(pthread_rwlock_t *lock);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedrdlock(pthread_rwlock_t *lock,
+ const struct timespec *abstime);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_wrlock(pthread_rwlock_t *lock);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedwrlock(pthread_rwlock_t *lock,
+ const struct timespec *abstime);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_unlock(pthread_rwlock_t *lock);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_init (pthread_rwlockattr_t * attr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr,
+ int *pshared);
+
+PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr,
+ int pshared);
+
+#if PTW32_LEVEL >= PTW32_LEVEL_MAX - 1
+
+/*
+ * Signal Functions. Should be defined in but MSVC and MinGW32
+ * already have signal.h that don't define these.
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_kill(pthread_t thread, int sig);
+
+/*
+ * Non-portable functions
+ */
+
+/*
+ * Compatibility with Linux.
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr,
+ int kind);
+PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr,
+ int *kind);
+
+/*
+ * Possibly supported by other POSIX threads implementations
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_delay_np (struct timespec * interval);
+PTW32_DLLPORT int PTW32_CDECL pthread_num_processors_np(void);
+PTW32_DLLPORT unsigned __int64 PTW32_CDECL pthread_getunique_np(pthread_t thread);
+
+/*
+ * Useful if an application wants to statically link
+ * the lib rather than load the DLL at run-time.
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_attach_np(void);
+PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_detach_np(void);
+PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_attach_np(void);
+PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_detach_np(void);
+
+/*
+ * Features that are auto-detected at load/run time.
+ */
+PTW32_DLLPORT int PTW32_CDECL pthread_win32_test_features_np(int);
+enum ptw32_features {
+ PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE = 0x0001, /* System provides it. */
+ PTW32_ALERTABLE_ASYNC_CANCEL = 0x0002 /* Can cancel blocked threads. */
+};
+
+/*
+ * Register a system time change with the library.
+ * Causes the library to perform various functions
+ * in response to the change. Should be called whenever
+ * the application's top level window receives a
+ * WM_TIMECHANGE message. It can be passed directly to
+ * pthread_create() as a new thread if desired.
+ */
+PTW32_DLLPORT void * PTW32_CDECL pthread_timechange_handler_np(void *);
+
+#endif /*PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 */
+
+#if PTW32_LEVEL >= PTW32_LEVEL_MAX
+
+/*
+ * Returns the Win32 HANDLE for the POSIX thread.
+ */
+PTW32_DLLPORT HANDLE PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread);
+/*
+ * Returns the win32 thread ID for POSIX thread.
+ */
+PTW32_DLLPORT DWORD PTW32_CDECL pthread_getw32threadid_np (pthread_t thread);
+
+
+/*
+ * Protected Methods
+ *
+ * This function blocks until the given WIN32 handle
+ * is signaled or pthread_cancel had been called.
+ * This function allows the caller to hook into the
+ * PThreads cancel mechanism. It is implemented using
+ *
+ * WaitForMultipleObjects
+ *
+ * on 'waitHandle' and a manually reset WIN32 Event
+ * used to implement pthread_cancel. The 'timeout'
+ * argument to TimedWait is simply passed to
+ * WaitForMultipleObjects.
+ */
+PTW32_DLLPORT int PTW32_CDECL pthreadCancelableWait (HANDLE waitHandle);
+PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle,
+ DWORD timeout);
+
+#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
+
+/*
+ * Thread-Safe C Runtime Library Mappings.
+ */
+#if !defined(_UWIN)
+# if defined(NEED_ERRNO)
+ PTW32_DLLPORT int * PTW32_CDECL _errno( void );
+# else
+# if !defined(errno)
+# if (defined(_MT) || defined(_DLL))
+ __declspec(dllimport) extern int * __cdecl _errno(void);
+# define errno (*_errno())
+# endif
+# endif
+# endif
+#endif
+
+/*
+ * Some compiler environments don't define some things.
+ */
+#if defined(__BORLANDC__)
+# define _ftime ftime
+# define _timeb timeb
+#endif
+
+#if defined(__cplusplus)
+
+/*
+ * Internal exceptions
+ */
+class ptw32_exception {};
+class ptw32_exception_cancel : public ptw32_exception {};
+class ptw32_exception_exit : public ptw32_exception {};
+
+#endif
+
+#if PTW32_LEVEL >= PTW32_LEVEL_MAX
+
+/* FIXME: This is only required if the library was built using SEH */
+/*
+ * Get internal SEH tag
+ */
+PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void);
+
+#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
+
+#if !defined(PTW32_BUILD)
+
+#if defined(__CLEANUP_SEH)
+
+/*
+ * Redefine the SEH __except keyword to ensure that applications
+ * propagate our internal exceptions up to the library's internal handlers.
+ */
+#define __except( E ) \
+ __except( ( GetExceptionCode() == ptw32_get_exception_services_code() ) \
+ ? EXCEPTION_CONTINUE_SEARCH : ( E ) )
+
+#endif /* __CLEANUP_SEH */
+
+#if defined(__CLEANUP_CXX)
+
+/*
+ * Redefine the C++ catch keyword to ensure that applications
+ * propagate our internal exceptions up to the library's internal handlers.
+ */
+#if defined(_MSC_VER)
+ /*
+ * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll'
+ * if you want Pthread-Win32 cancelation and pthread_exit to work.
+ */
+
+#if !defined(PtW32NoCatchWarn)
+
+#pragma message("Specify \"/DPtW32NoCatchWarn\" compiler flag to skip this message.")
+#pragma message("------------------------------------------------------------------")
+#pragma message("When compiling applications with MSVC++ and C++ exception handling:")
+#pragma message(" Replace any 'catch( ... )' in routines called from POSIX threads")
+#pragma message(" with 'PtW32CatchAll' or 'CATCHALL' if you want POSIX thread")
+#pragma message(" cancelation and pthread_exit to work. For example:")
+#pragma message("")
+#pragma message(" #if defined(PtW32CatchAll)")
+#pragma message(" PtW32CatchAll")
+#pragma message(" #else")
+#pragma message(" catch(...)")
+#pragma message(" #endif")
+#pragma message(" {")
+#pragma message(" /* Catchall block processing */")
+#pragma message(" }")
+#pragma message("------------------------------------------------------------------")
+
+#endif
+
+#define PtW32CatchAll \
+ catch( ptw32_exception & ) { throw; } \
+ catch( ... )
+
+#else /* _MSC_VER */
+
+#define catch( E ) \
+ catch( ptw32_exception & ) { throw; } \
+ catch( E )
+
+#endif /* _MSC_VER */
+
+#endif /* __CLEANUP_CXX */
+
+#endif /* ! PTW32_BUILD */
+
+#if defined(__cplusplus)
+} /* End of extern "C" */
+#endif /* __cplusplus */
+
+#if defined(PTW32__HANDLE_DEF)
+# undef HANDLE
+#endif
+#if defined(PTW32__DWORD_DEF)
+# undef DWORD
+#endif
+
+#undef PTW32_LEVEL
+#undef PTW32_LEVEL_MAX
+
+#endif /* ! RC_INVOKED */
+
+#endif /* PTHREAD_H */
diff --git a/vs/x86/pthreads.2/include/sched.h b/vs/x86/pthreads.2/include/sched.h
new file mode 100644
index 0000000..f36a97a
--- /dev/null
+++ b/vs/x86/pthreads.2/include/sched.h
@@ -0,0 +1,183 @@
+/*
+ * Module: sched.h
+ *
+ * Purpose:
+ * Provides an implementation of POSIX realtime extensions
+ * as defined in
+ *
+ * POSIX 1003.1b-1993 (POSIX.1b)
+ *
+ * --------------------------------------------------------------------------
+ *
+ * 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(_SCHED_H)
+#define _SCHED_H
+
+#undef PTW32_SCHED_LEVEL
+
+#if defined(_POSIX_SOURCE)
+#define PTW32_SCHED_LEVEL 0
+/* Early POSIX */
+#endif
+
+#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
+#undef PTW32_SCHED_LEVEL
+#define PTW32_SCHED_LEVEL 1
+/* Include 1b, 1c and 1d */
+#endif
+
+#if defined(INCLUDE_NP)
+#undef PTW32_SCHED_LEVEL
+#define PTW32_SCHED_LEVEL 2
+/* Include Non-Portable extensions */
+#endif
+
+#define PTW32_SCHED_LEVEL_MAX 3
+
+#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_SCHED_LEVEL)
+#define PTW32_SCHED_LEVEL PTW32_SCHED_LEVEL_MAX
+/* Include everything */
+#endif
+
+
+#if defined(__GNUC__) && !defined(__declspec)
+# error Please upgrade your GNU compiler to one that supports __declspec.
+#endif
+
+/*
+ * When building the library, you should define PTW32_BUILD so that
+ * the variables/functions are exported correctly. When using the library,
+ * do NOT define PTW32_BUILD, and then the variables/functions will
+ * be imported correctly.
+ */
+#if !defined(PTW32_STATIC_LIB)
+# if defined(PTW32_BUILD)
+# define PTW32_DLLPORT __declspec (dllexport)
+# else
+# define PTW32_DLLPORT __declspec (dllimport)
+# endif
+#else
+# define PTW32_DLLPORT
+#endif
+
+/*
+ * This is a duplicate of what is in the autoconf config.h,
+ * which is only used when building the pthread-win32 libraries.
+ */
+
+#if !defined(PTW32_CONFIG_H)
+# if defined(WINCE)
+# define NEED_ERRNO
+# define NEED_SEM
+# endif
+# if defined(__MINGW64__)
+# define HAVE_STRUCT_TIMESPEC
+# define HAVE_MODE_T
+# elif defined(_UWIN) || defined(__MINGW32__)
+# define HAVE_MODE_T
+# endif
+#endif
+
+/*
+ *
+ */
+
+#if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX
+#if defined(NEED_ERRNO)
+#include "need_errno.h"
+#else
+#include
+#endif
+#endif /* PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX */
+
+#if (defined(__MINGW64__) || defined(__MINGW32__)) || defined(_UWIN)
+# if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX
+/* For pid_t */
+# include
+/* Required by Unix 98 */
+# include
+# else
+ typedef int pid_t;
+# endif
+#else
+ typedef int pid_t;
+#endif
+
+/* Thread scheduling policies */
+
+enum {
+ SCHED_OTHER = 0,
+ SCHED_FIFO,
+ SCHED_RR,
+ SCHED_MIN = SCHED_OTHER,
+ SCHED_MAX = SCHED_RR
+};
+
+struct sched_param {
+ int sched_priority;
+};
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif /* __cplusplus */
+
+PTW32_DLLPORT int __cdecl sched_yield (void);
+
+PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy);
+
+PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy);
+
+PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy);
+
+PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid);
+
+/*
+ * Note that this macro returns ENOTSUP rather than
+ * ENOSYS as might be expected. However, returning ENOSYS
+ * should mean that sched_get_priority_{min,max} are
+ * not implemented as well as sched_rr_get_interval.
+ * This is not the case, since we just don't support
+ * round-robin scheduling. Therefore I have chosen to
+ * return the same value as sched_setscheduler when
+ * SCHED_RR is passed to it.
+ */
+#define sched_rr_get_interval(_pid, _interval) \
+ ( errno = ENOTSUP, (int) -1 )
+
+
+#if defined(__cplusplus)
+} /* End of extern "C" */
+#endif /* __cplusplus */
+
+#undef PTW32_SCHED_LEVEL
+#undef PTW32_SCHED_LEVEL_MAX
+
+#endif /* !_SCHED_H */
+
diff --git a/vs/x86/pthreads.2/include/semaphore.h b/vs/x86/pthreads.2/include/semaphore.h
new file mode 100644
index 0000000..c6e9407
--- /dev/null
+++ b/vs/x86/pthreads.2/include/semaphore.h
@@ -0,0 +1,169 @@
+/*
+ * Module: semaphore.h
+ *
+ * Purpose:
+ * Semaphores aren't actually part of the PThreads standard.
+ * They are defined by the POSIX Standard:
+ *
+ * POSIX 1003.1b-1993 (POSIX.1b)
+ *
+ * --------------------------------------------------------------------------
+ *
+ * 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( SEMAPHORE_H )
+#define SEMAPHORE_H
+
+#undef PTW32_SEMAPHORE_LEVEL
+
+#if defined(_POSIX_SOURCE)
+#define PTW32_SEMAPHORE_LEVEL 0
+/* Early POSIX */
+#endif
+
+#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
+#undef PTW32_SEMAPHORE_LEVEL
+#define PTW32_SEMAPHORE_LEVEL 1
+/* Include 1b, 1c and 1d */
+#endif
+
+#if defined(INCLUDE_NP)
+#undef PTW32_SEMAPHORE_LEVEL
+#define PTW32_SEMAPHORE_LEVEL 2
+/* Include Non-Portable extensions */
+#endif
+
+#define PTW32_SEMAPHORE_LEVEL_MAX 3
+
+#if !defined(PTW32_SEMAPHORE_LEVEL)
+#define PTW32_SEMAPHORE_LEVEL PTW32_SEMAPHORE_LEVEL_MAX
+/* Include everything */
+#endif
+
+#if defined(__GNUC__) && ! defined (__declspec)
+# error Please upgrade your GNU compiler to one that supports __declspec.
+#endif
+
+/*
+ * When building the library, you should define PTW32_BUILD so that
+ * the variables/functions are exported correctly. When using the library,
+ * do NOT define PTW32_BUILD, and then the variables/functions will
+ * be imported correctly.
+ */
+#if !defined(PTW32_STATIC_LIB)
+# if defined(PTW32_BUILD)
+# define PTW32_DLLPORT __declspec (dllexport)
+# else
+# define PTW32_DLLPORT __declspec (dllimport)
+# endif
+#else
+# define PTW32_DLLPORT
+#endif
+
+/*
+ * This is a duplicate of what is in the autoconf config.h,
+ * which is only used when building the pthread-win32 libraries.
+ */
+
+#if !defined(PTW32_CONFIG_H)
+# if defined(WINCE)
+# define NEED_ERRNO
+# define NEED_SEM
+# endif
+# if defined(__MINGW64__)
+# define HAVE_STRUCT_TIMESPEC
+# define HAVE_MODE_T
+# elif defined(_UWIN) || defined(__MINGW32__)
+# define HAVE_MODE_T
+# endif
+#endif
+
+/*
+ *
+ */
+
+#if PTW32_SEMAPHORE_LEVEL >= PTW32_SEMAPHORE_LEVEL_MAX
+#if defined(NEED_ERRNO)
+#include "need_errno.h"
+#else
+#include
+#endif
+#endif /* PTW32_SEMAPHORE_LEVEL >= PTW32_SEMAPHORE_LEVEL_MAX */
+
+#define _POSIX_SEMAPHORES
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif /* __cplusplus */
+
+#if !defined(HAVE_MODE_T)
+typedef unsigned int mode_t;
+#endif
+
+
+typedef struct sem_t_ * sem_t;
+
+PTW32_DLLPORT int __cdecl sem_init (sem_t * sem,
+ int pshared,
+ unsigned int value);
+
+PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem);
+
+PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem);
+
+PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem);
+
+PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem,
+ const struct timespec * abstime);
+
+PTW32_DLLPORT int __cdecl sem_post (sem_t * sem);
+
+PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem,
+ int count);
+
+PTW32_DLLPORT int __cdecl sem_open (const char * name,
+ int oflag,
+ mode_t mode,
+ unsigned int value);
+
+PTW32_DLLPORT int __cdecl sem_close (sem_t * sem);
+
+PTW32_DLLPORT int __cdecl sem_unlink (const char * name);
+
+PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem,
+ int * sval);
+
+#if defined(__cplusplus)
+} /* End of extern "C" */
+#endif /* __cplusplus */
+
+#undef PTW32_SEMAPHORE_LEVEL
+#undef PTW32_SEMAPHORE_LEVEL_MAX
+
+#endif /* !SEMAPHORE_H */
diff --git a/vs/shuffle/.vs/shuffle/v14/.suo b/vs/x86/shuffle/.vs/shuffle/v14/.suo
similarity index 100%
rename from vs/shuffle/.vs/shuffle/v14/.suo
rename to vs/x86/shuffle/.vs/shuffle/v14/.suo
diff --git a/vs/shuffle/Release/shuffle.iobj b/vs/x86/shuffle/Release/shuffle.iobj
similarity index 100%
rename from vs/shuffle/Release/shuffle.iobj
rename to vs/x86/shuffle/Release/shuffle.iobj
diff --git a/vs/shuffle/Release/shuffle.ipdb b/vs/x86/shuffle/Release/shuffle.ipdb
similarity index 100%
rename from vs/shuffle/Release/shuffle.ipdb
rename to vs/x86/shuffle/Release/shuffle.ipdb
diff --git a/vs/shuffle/Release/shuffle.pdb b/vs/x86/shuffle/Release/shuffle.pdb
similarity index 100%
rename from vs/shuffle/Release/shuffle.pdb
rename to vs/x86/shuffle/Release/shuffle.pdb
diff --git a/vs/shuffle/shuffle.VC.db b/vs/x86/shuffle/shuffle.VC.db
similarity index 100%
rename from vs/shuffle/shuffle.VC.db
rename to vs/x86/shuffle/shuffle.VC.db
diff --git a/vs/x86/shuffle/shuffle.sln b/vs/x86/shuffle/shuffle.sln
new file mode 100644
index 0000000..ca88cbb
--- /dev/null
+++ b/vs/x86/shuffle/shuffle.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shuffle", "shuffle\shuffle.vcxproj", "{9E89B63A-F1D8-4604-8CEC-32E7FCDB6F4A}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {9E89B63A-F1D8-4604-8CEC-32E7FCDB6F4A}.Debug|x64.ActiveCfg = Debug|x64
+ {9E89B63A-F1D8-4604-8CEC-32E7FCDB6F4A}.Debug|x64.Build.0 = Debug|x64
+ {9E89B63A-F1D8-4604-8CEC-32E7FCDB6F4A}.Debug|x86.ActiveCfg = Debug|Win32
+ {9E89B63A-F1D8-4604-8CEC-32E7FCDB6F4A}.Debug|x86.Build.0 = Debug|Win32
+ {9E89B63A-F1D8-4604-8CEC-32E7FCDB6F4A}.Release|x64.ActiveCfg = Release|x64
+ {9E89B63A-F1D8-4604-8CEC-32E7FCDB6F4A}.Release|x64.Build.0 = Release|x64
+ {9E89B63A-F1D8-4604-8CEC-32E7FCDB6F4A}.Release|x86.ActiveCfg = Release|Win32
+ {9E89B63A-F1D8-4604-8CEC-32E7FCDB6F4A}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/vs/shuffle/shuffle/Release/shuffle.log b/vs/x86/shuffle/shuffle/Release/shuffle.log
similarity index 100%
rename from vs/shuffle/shuffle/Release/shuffle.log
rename to vs/x86/shuffle/shuffle/Release/shuffle.log
diff --git a/vs/shuffle/shuffle/Release/shuffle.tlog/CL.command.1.tlog b/vs/x86/shuffle/shuffle/Release/shuffle.tlog/CL.command.1.tlog
similarity index 100%
rename from vs/shuffle/shuffle/Release/shuffle.tlog/CL.command.1.tlog
rename to vs/x86/shuffle/shuffle/Release/shuffle.tlog/CL.command.1.tlog
diff --git a/vs/shuffle/shuffle/Release/shuffle.tlog/CL.read.1.tlog b/vs/x86/shuffle/shuffle/Release/shuffle.tlog/CL.read.1.tlog
similarity index 100%
rename from vs/shuffle/shuffle/Release/shuffle.tlog/CL.read.1.tlog
rename to vs/x86/shuffle/shuffle/Release/shuffle.tlog/CL.read.1.tlog
diff --git a/vs/shuffle/shuffle/Release/shuffle.tlog/CL.write.1.tlog b/vs/x86/shuffle/shuffle/Release/shuffle.tlog/CL.write.1.tlog
similarity index 100%
rename from vs/shuffle/shuffle/Release/shuffle.tlog/CL.write.1.tlog
rename to vs/x86/shuffle/shuffle/Release/shuffle.tlog/CL.write.1.tlog
diff --git a/vs/shuffle/shuffle/Release/shuffle.tlog/link.command.1.tlog b/vs/x86/shuffle/shuffle/Release/shuffle.tlog/link.command.1.tlog
similarity index 100%
rename from vs/shuffle/shuffle/Release/shuffle.tlog/link.command.1.tlog
rename to vs/x86/shuffle/shuffle/Release/shuffle.tlog/link.command.1.tlog
diff --git a/vs/shuffle/shuffle/Release/shuffle.tlog/link.read.1.tlog b/vs/x86/shuffle/shuffle/Release/shuffle.tlog/link.read.1.tlog
similarity index 100%
rename from vs/shuffle/shuffle/Release/shuffle.tlog/link.read.1.tlog
rename to vs/x86/shuffle/shuffle/Release/shuffle.tlog/link.read.1.tlog
diff --git a/vs/shuffle/shuffle/Release/shuffle.tlog/link.write.1.tlog b/vs/x86/shuffle/shuffle/Release/shuffle.tlog/link.write.1.tlog
similarity index 100%
rename from vs/shuffle/shuffle/Release/shuffle.tlog/link.write.1.tlog
rename to vs/x86/shuffle/shuffle/Release/shuffle.tlog/link.write.1.tlog
diff --git a/vs/shuffle/shuffle/Release/shuffle.tlog/shuffle.lastbuildstate b/vs/x86/shuffle/shuffle/Release/shuffle.tlog/shuffle.lastbuildstate
similarity index 100%
rename from vs/shuffle/shuffle/Release/shuffle.tlog/shuffle.lastbuildstate
rename to vs/x86/shuffle/shuffle/Release/shuffle.tlog/shuffle.lastbuildstate
diff --git a/vs/shuffle/shuffle/Release/vc140.pdb b/vs/x86/shuffle/shuffle/Release/vc140.pdb
similarity index 100%
rename from vs/shuffle/shuffle/Release/vc140.pdb
rename to vs/x86/shuffle/shuffle/Release/vc140.pdb
diff --git a/vs/x86/shuffle/shuffle/shuffle.c b/vs/x86/shuffle/shuffle/shuffle.c
new file mode 100644
index 0000000..e9ee205
--- /dev/null
+++ b/vs/x86/shuffle/shuffle/shuffle.c
@@ -0,0 +1,220 @@
+// Tool to shuffle entries of word-word cooccurrence files
+//
+// Copyright (c) 2014 The Board of Trustees of
+// The Leland Stanford Junior University. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+// For more information, bug reports, fixes, contact:
+// Jeffrey Pennington (jpennin@stanford.edu)
+// GlobalVectors@googlegroups.com
+// http://nlp.stanford.edu/projects/glove/
+
+#include
+#include
+#include
+
+#define MAX_STRING_LENGTH 1000
+
+static const long LRAND_MAX = ((long)RAND_MAX + 2) * (long)RAND_MAX;
+typedef double real;
+
+typedef struct cooccur_rec {
+ int word1;
+ int word2;
+ real val;
+} CREC;
+
+int verbose = 2; // 0, 1, or 2
+long long array_size = 2000000; // size of chunks to shuffle individually
+char *file_head; // temporary file string
+real memory_limit = 2.0; // soft limit, in gigabytes
+
+ /* Efficient string comparison */
+int scmp(char *s1, char *s2) {
+ while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
+ return(*s1 - *s2);
+}
+
+
+/* Generate uniformly distributed random long ints */
+static long rand_long(long n) {
+ long limit = LRAND_MAX - LRAND_MAX % n;
+ long rnd;
+ do {
+ rnd = ((long)RAND_MAX + 1) * (long)rand() + (long)rand();
+ } while (rnd >= limit);
+ return rnd % n;
+}
+
+/* Write contents of array to binary file */
+int write_chunk(CREC *array, long size, FILE *fout) {
+ long i = 0;
+ for (i = 0; i < size; i++) fwrite(&array[i], sizeof(CREC), 1, fout);
+ return 0;
+}
+
+/* Fisher-Yates shuffle */
+void shuffle(CREC *array, long n) {
+ long i, j;
+ CREC tmp;
+ for (i = n - 1; i > 0; i--) {
+ j = rand_long(i + 1);
+ tmp = array[j];
+ array[j] = array[i];
+ array[i] = tmp;
+ }
+}
+
+/* Merge shuffled temporary files; doesn't necessarily produce a perfect shuffle, but good enough */
+int shuffle_merge(int num) {
+ long i, j, k, l = 0;
+ int fidcounter = 0;
+ CREC *array;
+ char filename[MAX_STRING_LENGTH];
+ FILE **fid, *fout = stdout;
+
+ array = malloc(sizeof(CREC) * array_size);
+ fid = malloc(sizeof(FILE) * num);
+ for (fidcounter = 0; fidcounter < num; fidcounter++) { //num = number of temporary files to merge
+ sprintf(filename, "%s_%04d.bin", file_head, fidcounter);
+ fid[fidcounter] = fopen(filename, "rb");
+ if (fid[fidcounter] == NULL) {
+ fprintf(stderr, "Unable to open file %s.\n", filename);
+ return 1;
+ }
+ }
+ if (verbose > 0) fprintf(stderr, "Merging temp files: processed %ld lines.", l);
+
+ while (1) { //Loop until EOF in all files
+ i = 0;
+ //Read at most array_size values into array, roughly array_size/num from each temp file
+ for (j = 0; j < num; j++) {
+ if (feof(fid[j])) continue;
+ for (k = 0; k < array_size / num; k++) {
+ fread(&array[i], sizeof(CREC), 1, fid[j]);
+ if (feof(fid[j])) break;
+ i++;
+ }
+ }
+ if (i == 0) break;
+ l += i;
+ shuffle(array, i - 1); // Shuffles lines between temp files
+ write_chunk(array, i, fout);
+ if (verbose > 0) fprintf(stderr, "\033[31G%ld lines.", l);
+ }
+ fprintf(stderr, "\033[0GMerging temp files: processed %ld lines.", l);
+ for (fidcounter = 0; fidcounter < num; fidcounter++) {
+ fclose(fid[fidcounter]);
+ sprintf(filename, "%s_%04d.bin", file_head, fidcounter);
+ remove(filename);
+ }
+ fprintf(stderr, "\n\n");
+ free(array);
+ return 0;
+}
+
+/* Shuffle large input stream by splitting into chunks */
+int shuffle_by_chunks() {
+ long i = 0, l = 0;
+ int fidcounter = 0;
+ char filename[MAX_STRING_LENGTH];
+ CREC *array;
+ FILE *fin = stdin, *fid;
+ array = malloc(sizeof(CREC) * array_size);
+
+ fprintf(stderr, "SHUFFLING COOCCURRENCES\n");
+ if (verbose > 0) fprintf(stderr, "array size: %lld\n", array_size);
+ sprintf(filename, "%s_%04d.bin", file_head, fidcounter);
+ fid = fopen(filename, "w");
+ if (fid == NULL) {
+ fprintf(stderr, "Unable to open file %s.\n", filename);
+ return 1;
+ }
+ if (verbose > 1) fprintf(stderr, "Shuffling by chunks: processed 0 lines.");
+
+ while (1) { //Continue until EOF
+ if (i >= array_size) {// If array is full, shuffle it and save to temporary file
+ shuffle(array, i - 2);
+ l += i;
+ if (verbose > 1) fprintf(stderr, "\033[22Gprocessed %ld lines.", l);
+ write_chunk(array, i, fid);
+ fclose(fid);
+ fidcounter++;
+ sprintf(filename, "%s_%04d.bin", file_head, fidcounter);
+ fid = fopen(filename, "w");
+ if (fid == NULL) {
+ fprintf(stderr, "Unable to open file %s.\n", filename);
+ return 1;
+ }
+ i = 0;
+ }
+ fread(&array[i], sizeof(CREC), 1, fin);
+ if (feof(fin)) break;
+ i++;
+ }
+ shuffle(array, i - 2); //Last chunk may be smaller than array_size
+ write_chunk(array, i, fid);
+ l += i;
+ if (verbose > 1) fprintf(stderr, "\033[22Gprocessed %ld lines.\n", l);
+ if (verbose > 1) fprintf(stderr, "Wrote %d temporary file(s).\n", fidcounter + 1);
+ fclose(fid);
+ free(array);
+ return shuffle_merge(fidcounter + 1); // Merge and shuffle together temporary files
+}
+
+int find_arg(char *str, int argc, char **argv) {
+ int i;
+ for (i = 1; i < argc; i++) {
+ if (!scmp(str, argv[i])) {
+ if (i == argc - 1) {
+ printf("No argument given for %s\n", str);
+ exit(1);
+ }
+ return i;
+ }
+ }
+ return -1;
+}
+
+int main(int argc, char **argv) {
+ int i;
+ file_head = malloc(sizeof(char) * MAX_STRING_LENGTH);
+
+ if (argc == 1) {
+ printf("Tool to shuffle entries of word-word cooccurrence files\n");
+ printf("Author: Jeffrey Pennington (jpennin@stanford.edu)\n\n");
+ printf("Usage options:\n");
+ printf("\t-verbose \n");
+ printf("\t\tSet verbosity: 0, 1, or 2 (default)\n");
+ printf("\t-memory \n");
+ printf("\t\tSoft limit for memory consumption, in GB; default 4.0\n");
+ printf("\t-array-size \n");
+ printf("\t\tLimit to length the buffer which stores chunks of data to shuffle before writing to disk. \n\t\tThis value overrides that which is automatically produced by '-memory'.\n");
+ printf("\t-temp-file \n");
+ printf("\t\tFilename, excluding extension, for temporary files; default temp_shuffle\n");
+
+ printf("\nExample usage: (assuming 'cooccurrence.bin' has been produced by 'coccur')\n");
+ printf("./shuffle -verbose 2 -memory 8.0 < cooccurrence.bin > cooccurrence.shuf.bin\n");
+ return 0;
+ }
+
+ if ((i = find_arg((char *)"-verbose", argc, argv)) > 0) verbose = atoi(argv[i + 1]);
+ if ((i = find_arg((char *)"-temp-file", argc, argv)) > 0) strcpy(file_head, argv[i + 1]);
+ else strcpy(file_head, (char *)"temp_shuffle");
+ if ((i = find_arg((char *)"-memory", argc, argv)) > 0) memory_limit = atof(argv[i + 1]);
+ array_size = (long long)(0.95 * (real)memory_limit * 1073741824 / (sizeof(CREC)));
+ if ((i = find_arg((char *)"-array-size", argc, argv)) > 0) array_size = atoll(argv[i + 1]);
+ return shuffle_by_chunks();
+}
diff --git a/vs/x86/shuffle/shuffle/shuffle.vcxproj b/vs/x86/shuffle/shuffle/shuffle.vcxproj
new file mode 100644
index 0000000..cb22231
--- /dev/null
+++ b/vs/x86/shuffle/shuffle/shuffle.vcxproj
@@ -0,0 +1,150 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ {9E89B63A-F1D8-4604-8CEC-32E7FCDB6F4A}
+ Win32Proj
+ shuffle
+ 8.1
+
+
+
+ Application
+ true
+ v140
+ Unicode
+
+
+ Application
+ false
+ v140
+ true
+ Unicode
+
+
+ Application
+ true
+ v140
+ Unicode
+
+
+ Application
+ false
+ v140
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+
+
+
+
+
+
+ Level3
+ Disabled
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vs/x86/shuffle/shuffle/shuffle.vcxproj.filters b/vs/x86/shuffle/shuffle/shuffle.vcxproj.filters
new file mode 100644
index 0000000..099dff9
--- /dev/null
+++ b/vs/x86/shuffle/shuffle/shuffle.vcxproj.filters
@@ -0,0 +1,22 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ 源文件
+
+
+
\ No newline at end of file
diff --git a/vs/x86/shuffle/shuffle/shuffle.vcxproj.user b/vs/x86/shuffle/shuffle/shuffle.vcxproj.user
new file mode 100644
index 0000000..abe8dd8
--- /dev/null
+++ b/vs/x86/shuffle/shuffle/shuffle.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/vs/vocab_count/.vs/vocab_count/v14/.suo b/vs/x86/vocab_count/.vs/vocab_count/v14/.suo
similarity index 100%
rename from vs/vocab_count/.vs/vocab_count/v14/.suo
rename to vs/x86/vocab_count/.vs/vocab_count/v14/.suo
diff --git a/vs/vocab_count/Release/vocab_count.iobj b/vs/x86/vocab_count/Release/vocab_count.iobj
similarity index 100%
rename from vs/vocab_count/Release/vocab_count.iobj
rename to vs/x86/vocab_count/Release/vocab_count.iobj
diff --git a/vs/vocab_count/Release/vocab_count.ipdb b/vs/x86/vocab_count/Release/vocab_count.ipdb
similarity index 100%
rename from vs/vocab_count/Release/vocab_count.ipdb
rename to vs/x86/vocab_count/Release/vocab_count.ipdb
diff --git a/vs/vocab_count/Release/vocab_count.pdb b/vs/x86/vocab_count/Release/vocab_count.pdb
similarity index 100%
rename from vs/vocab_count/Release/vocab_count.pdb
rename to vs/x86/vocab_count/Release/vocab_count.pdb
diff --git a/vs/vocab_count/vocab_count.VC.db b/vs/x86/vocab_count/vocab_count.VC.db
similarity index 100%
rename from vs/vocab_count/vocab_count.VC.db
rename to vs/x86/vocab_count/vocab_count.VC.db
diff --git a/vs/x86/vocab_count/vocab_count.sln b/vs/x86/vocab_count/vocab_count.sln
new file mode 100644
index 0000000..8863bb5
--- /dev/null
+++ b/vs/x86/vocab_count/vocab_count.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vocab_count", "vocab_count\vocab_count.vcxproj", "{34BC0973-C203-4BCF-8A13-CF65647C8FDB}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {34BC0973-C203-4BCF-8A13-CF65647C8FDB}.Debug|x64.ActiveCfg = Debug|x64
+ {34BC0973-C203-4BCF-8A13-CF65647C8FDB}.Debug|x64.Build.0 = Debug|x64
+ {34BC0973-C203-4BCF-8A13-CF65647C8FDB}.Debug|x86.ActiveCfg = Debug|Win32
+ {34BC0973-C203-4BCF-8A13-CF65647C8FDB}.Debug|x86.Build.0 = Debug|Win32
+ {34BC0973-C203-4BCF-8A13-CF65647C8FDB}.Release|x64.ActiveCfg = Release|x64
+ {34BC0973-C203-4BCF-8A13-CF65647C8FDB}.Release|x64.Build.0 = Release|x64
+ {34BC0973-C203-4BCF-8A13-CF65647C8FDB}.Release|x86.ActiveCfg = Release|Win32
+ {34BC0973-C203-4BCF-8A13-CF65647C8FDB}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/vs/vocab_count/vocab_count/Release/vc140.pdb b/vs/x86/vocab_count/vocab_count/Release/vc140.pdb
similarity index 100%
rename from vs/vocab_count/vocab_count/Release/vc140.pdb
rename to vs/x86/vocab_count/vocab_count/Release/vc140.pdb
diff --git a/vs/vocab_count/vocab_count/Release/vocab_count.log b/vs/x86/vocab_count/vocab_count/Release/vocab_count.log
similarity index 100%
rename from vs/vocab_count/vocab_count/Release/vocab_count.log
rename to vs/x86/vocab_count/vocab_count/Release/vocab_count.log
diff --git a/vs/vocab_count/vocab_count/Release/vocab_count.tlog/CL.command.1.tlog b/vs/x86/vocab_count/vocab_count/Release/vocab_count.tlog/CL.command.1.tlog
similarity index 100%
rename from vs/vocab_count/vocab_count/Release/vocab_count.tlog/CL.command.1.tlog
rename to vs/x86/vocab_count/vocab_count/Release/vocab_count.tlog/CL.command.1.tlog
diff --git a/vs/vocab_count/vocab_count/Release/vocab_count.tlog/CL.read.1.tlog b/vs/x86/vocab_count/vocab_count/Release/vocab_count.tlog/CL.read.1.tlog
similarity index 100%
rename from vs/vocab_count/vocab_count/Release/vocab_count.tlog/CL.read.1.tlog
rename to vs/x86/vocab_count/vocab_count/Release/vocab_count.tlog/CL.read.1.tlog
diff --git a/vs/vocab_count/vocab_count/Release/vocab_count.tlog/CL.write.1.tlog b/vs/x86/vocab_count/vocab_count/Release/vocab_count.tlog/CL.write.1.tlog
similarity index 100%
rename from vs/vocab_count/vocab_count/Release/vocab_count.tlog/CL.write.1.tlog
rename to vs/x86/vocab_count/vocab_count/Release/vocab_count.tlog/CL.write.1.tlog
diff --git a/vs/vocab_count/vocab_count/Release/vocab_count.tlog/link.command.1.tlog b/vs/x86/vocab_count/vocab_count/Release/vocab_count.tlog/link.command.1.tlog
similarity index 100%
rename from vs/vocab_count/vocab_count/Release/vocab_count.tlog/link.command.1.tlog
rename to vs/x86/vocab_count/vocab_count/Release/vocab_count.tlog/link.command.1.tlog
diff --git a/vs/vocab_count/vocab_count/Release/vocab_count.tlog/link.read.1.tlog b/vs/x86/vocab_count/vocab_count/Release/vocab_count.tlog/link.read.1.tlog
similarity index 100%
rename from vs/vocab_count/vocab_count/Release/vocab_count.tlog/link.read.1.tlog
rename to vs/x86/vocab_count/vocab_count/Release/vocab_count.tlog/link.read.1.tlog
diff --git a/vs/vocab_count/vocab_count/Release/vocab_count.tlog/link.write.1.tlog b/vs/x86/vocab_count/vocab_count/Release/vocab_count.tlog/link.write.1.tlog
similarity index 100%
rename from vs/vocab_count/vocab_count/Release/vocab_count.tlog/link.write.1.tlog
rename to vs/x86/vocab_count/vocab_count/Release/vocab_count.tlog/link.write.1.tlog
diff --git a/vs/vocab_count/vocab_count/Release/vocab_count.tlog/vocab_count.lastbuildstate b/vs/x86/vocab_count/vocab_count/Release/vocab_count.tlog/vocab_count.lastbuildstate
similarity index 100%
rename from vs/vocab_count/vocab_count/Release/vocab_count.tlog/vocab_count.lastbuildstate
rename to vs/x86/vocab_count/vocab_count/Release/vocab_count.tlog/vocab_count.lastbuildstate
diff --git a/vs/x86/vocab_count/vocab_count/vocab_count.c b/vs/x86/vocab_count/vocab_count/vocab_count.c
new file mode 100644
index 0000000..45e83c1
--- /dev/null
+++ b/vs/x86/vocab_count/vocab_count/vocab_count.c
@@ -0,0 +1,213 @@
+// Tool to extract unigram counts
+//
+// GloVe: Global Vectors for Word Representation
+// Copyright (c) 2014 The Board of Trustees of
+// The Leland Stanford Junior University. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+// For more information, bug reports, fixes, contact:
+// Jeffrey Pennington (jpennin@stanford.edu)
+// GlobalVectors@googlegroups.com
+// http://nlp.stanford.edu/projects/glove/
+
+#include
+#include
+#include
+
+#define MAX_STRING_LENGTH 1000
+#define TSIZE 1048576
+#define SEED 1159241
+#define HASHFN bitwisehash
+
+typedef struct vocabulary {
+ char *word;
+ long long count;
+} VOCAB;
+
+typedef struct hashrec {
+ char *word;
+ long long count;
+ struct hashrec *next;
+} HASHREC;
+
+int verbose = 2; // 0, 1, or 2
+long long min_count = 1; // min occurrences for inclusion in vocab
+long long max_vocab = 0; // max_vocab = 0 for no limit
+
+
+ /* Efficient string comparison */
+int scmp(char *s1, char *s2) {
+ while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
+ return(*s1 - *s2);
+}
+
+
+/* Vocab frequency comparison; break ties alphabetically */
+int CompareVocabTie(const void *a, const void *b) {
+ long long c;
+ if ((c = ((VOCAB *)b)->count - ((VOCAB *)a)->count) != 0) return (c > 0 ? 1 : -1);
+ else return (scmp(((VOCAB *)a)->word, ((VOCAB *)b)->word));
+
+}
+
+/* Vocab frequency comparison; no tie-breaker */
+int CompareVocab(const void *a, const void *b) {
+ long long c;
+ if ((c = ((VOCAB *)b)->count - ((VOCAB *)a)->count) != 0) return (c > 0 ? 1 : -1);
+ else return 0;
+}
+
+/* Move-to-front hashing and hash function from Hugh Williams, http://www.seg.rmit.edu.au/code/zwh-ipl/ */
+
+/* Simple bitwise hash function */
+unsigned int bitwisehash(char *word, int tsize, unsigned int seed) {
+ char c;
+ unsigned int h;
+ h = seed;
+ for (; (c = *word) != '\0'; word++) h ^= ((h << 5) + c + (h >> 2));
+ return((unsigned int)((h & 0x7fffffff) % tsize));
+}
+
+/* Create hash table, initialise pointers to NULL */
+HASHREC ** inithashtable() {
+ int i;
+ HASHREC **ht;
+ ht = (HASHREC **)malloc(sizeof(HASHREC *) * TSIZE);
+ for (i = 0; i < TSIZE; i++) ht[i] = (HASHREC *)NULL;
+ return(ht);
+}
+
+/* Search hash table for given string, insert if not found */
+void hashinsert(HASHREC **ht, char *w) {
+ HASHREC *htmp, *hprv;
+ unsigned int hval = HASHFN(w, TSIZE, SEED);
+
+ for (hprv = NULL, htmp = ht[hval]; htmp != NULL && scmp(htmp->word, w) != 0; hprv = htmp, htmp = htmp->next);
+ if (htmp == NULL) {
+ htmp = (HASHREC *)malloc(sizeof(HASHREC));
+ htmp->word = (char *)malloc(strlen(w) + 1);
+ strcpy(htmp->word, w);
+ htmp->count = 1;
+ htmp->next = NULL;
+ if (hprv == NULL)
+ ht[hval] = htmp;
+ else
+ hprv->next = htmp;
+ }
+ else {
+ /* new records are not moved to front */
+ htmp->count++;
+ if (hprv != NULL) {
+ /* move to front on access */
+ hprv->next = htmp->next;
+ htmp->next = ht[hval];
+ ht[hval] = htmp;
+ }
+ }
+ return;
+}
+
+int get_counts() {
+ long long i = 0, j = 0, vocab_size = 12500;
+ char format[20];
+ char str[MAX_STRING_LENGTH + 1];
+ HASHREC **vocab_hash = inithashtable();
+ HASHREC *htmp;
+ VOCAB *vocab;
+ FILE *fid = stdin;
+
+ fprintf(stderr, "BUILDING VOCABULARY\n");
+ if (verbose > 1) fprintf(stderr, "Processed %lld tokens.", i);
+ sprintf(format, "%%%ds", MAX_STRING_LENGTH);
+ while (fscanf(fid, format, str) != EOF) { // Insert all tokens into hashtable
+ if (strcmp(str, "") == 0) {
+ fprintf(stderr, "\nError, vector found in corpus.\nPlease remove s from your corpus (e.g. cat text8 | sed -e 's///g' > text8.new)");
+ return 1;
+ }
+ hashinsert(vocab_hash, str);
+ if (((++i) % 100000) == 0) if (verbose > 1) fprintf(stderr, "\033[11G%lld tokens.", i);
+ }
+ if (verbose > 1) fprintf(stderr, "\033[0GProcessed %lld tokens.\n", i);
+ vocab = malloc(sizeof(VOCAB) * vocab_size);
+ for (i = 0; i < TSIZE; i++) { // Migrate vocab to array
+ htmp = vocab_hash[i];
+ while (htmp != NULL) {
+ vocab[j].word = htmp->word;
+ vocab[j].count = htmp->count;
+ j++;
+ if (j >= vocab_size) {
+ vocab_size += 2500;
+ vocab = (VOCAB *)realloc(vocab, sizeof(VOCAB) * vocab_size);
+ }
+ htmp = htmp->next;
+ }
+ }
+ if (verbose > 1) fprintf(stderr, "Counted %lld unique words.\n", j);
+ if (max_vocab > 0 && max_vocab < j)
+ // If the vocabulary exceeds limit, first sort full vocab by frequency without alphabetical tie-breaks.
+ // This results in pseudo-random ordering for words with same frequency, so that when truncated, the words span whole alphabet
+ qsort(vocab, j, sizeof(VOCAB), CompareVocab);
+ else max_vocab = j;
+ qsort(vocab, max_vocab, sizeof(VOCAB), CompareVocabTie); //After (possibly) truncating, sort (possibly again), breaking ties alphabetically
+
+ for (i = 0; i < max_vocab; i++) {
+ if (vocab[i].count < min_count) { // If a minimum frequency cutoff exists, truncate vocabulary
+ if (verbose > 0) fprintf(stderr, "Truncating vocabulary at min count %lld.\n", min_count);
+ break;
+ }
+ printf("%s %lld\n", vocab[i].word, vocab[i].count);
+ }
+
+ if (i == max_vocab && max_vocab < j) if (verbose > 0) fprintf(stderr, "Truncating vocabulary at size %lld.\n", max_vocab);
+ fprintf(stderr, "Using vocabulary of size %lld.\n\n", i);
+ return 0;
+}
+
+int find_arg(char *str, int argc, char **argv) {
+ int i;
+ for (i = 1; i < argc; i++) {
+ if (!scmp(str, argv[i])) {
+ if (i == argc - 1) {
+ printf("No argument given for %s\n", str);
+ exit(1);
+ }
+ return i;
+ }
+ }
+ return -1;
+}
+
+int main(int argc, char **argv) {
+ int i;
+ if (argc == 1) {
+ printf("Simple tool to extract unigram counts\n");
+ printf("Author: Jeffrey Pennington (jpennin@stanford.edu)\n\n");
+ printf("Usage options:\n");
+ printf("\t-verbose \n");
+ printf("\t\tSet verbosity: 0, 1, or 2 (default)\n");
+ printf("\t-max-vocab \n");
+ printf("\t\tUpper bound on vocabulary size, i.e. keep the most frequent words. The minimum frequency words are randomly sampled so as to obtain an even distribution over the alphabet.\n");
+ printf("\t-min-count \n");
+ printf("\t\tLower limit such that words which occur fewer than times are discarded.\n");
+ printf("\nExample usage:\n");
+ printf("./vocab_count -verbose 2 -max-vocab 100000 -min-count 10 < corpus.txt > vocab.txt\n");
+ return 0;
+ }
+
+ if ((i = find_arg((char *)"-verbose", argc, argv)) > 0) verbose = atoi(argv[i + 1]);
+ if ((i = find_arg((char *)"-max-vocab", argc, argv)) > 0) max_vocab = atoll(argv[i + 1]);
+ if ((i = find_arg((char *)"-min-count", argc, argv)) > 0) min_count = atoll(argv[i + 1]);
+ return get_counts();
+}
\ No newline at end of file
diff --git a/vs/x86/vocab_count/vocab_count/vocab_count.vcxproj b/vs/x86/vocab_count/vocab_count/vocab_count.vcxproj
new file mode 100644
index 0000000..270195e
--- /dev/null
+++ b/vs/x86/vocab_count/vocab_count/vocab_count.vcxproj
@@ -0,0 +1,150 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ {34BC0973-C203-4BCF-8A13-CF65647C8FDB}
+ Win32Proj
+ vocab_count
+ 8.1
+
+
+
+ Application
+ true
+ v140
+ Unicode
+
+
+ Application
+ false
+ v140
+ true
+ Unicode
+
+
+ Application
+ true
+ v140
+ Unicode
+
+
+ Application
+ false
+ v140
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+
+
+
+
+
+
+ Level3
+ Disabled
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vs/x86/vocab_count/vocab_count/vocab_count.vcxproj.filters b/vs/x86/vocab_count/vocab_count/vocab_count.vcxproj.filters
new file mode 100644
index 0000000..e9b42e7
--- /dev/null
+++ b/vs/x86/vocab_count/vocab_count/vocab_count.vcxproj.filters
@@ -0,0 +1,22 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ 源文件
+
+
+
\ No newline at end of file
diff --git a/vs/x86/vocab_count/vocab_count/vocab_count.vcxproj.user b/vs/x86/vocab_count/vocab_count/vocab_count.vcxproj.user
new file mode 100644
index 0000000..abe8dd8
--- /dev/null
+++ b/vs/x86/vocab_count/vocab_count/vocab_count.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file