# ensure LF endings on all checkouts
-configure.ac crlf=input
+configure.ac crlf=input
+config.rpath crlf=input
+configure.host crlf=input
+mkinstalldirs crlf=input
+*.sh crlf=input
# ensure native line endings on checkout
*.c crlf
*.h crlf
*.cs crlf
-*.sh crlf
*.il crlf
.gitattributes crlf
Ankh.NoLoad
*.gpState
.vscode/
+*.exp
# Tooling
_ReSharper*/
SUBMODULE_ERROR='Could not recursively update all git submodules. You may experience compilation problems if some submodules are out of date'
update_submodules:
- @$(srcdir)/scripts/update_submodules
+ @$(srcdir)/scripts/update_submodules.sh
.PHONY: update_submodules
EXTRA_DIST=README.md SUBMODULES.json versions.mk roslyn.mk coreclr.mk ms-test-suite.mk
CLASS=$(mcs_topdir)/class/lib/$(DEFAULT_PROFILE)
+TOOLS_CLASS=$(mcs_topdir)/class/lib/build
-with_mono_path = MONO_PATH=$(CLASS)
-RUNTIME = $(with_mono_path) $(abs_top_builddir)/runtime/mono-wrapper --debug
-MCS = $(RUNTIME) $(CSC) -nologo
-ILASM = $(RUNTIME) $(CLASS)/ilasm.exe
+RUNTIME = MONO_PATH=$(CLASS) $(abs_top_builddir)/runtime/mono-wrapper --debug
+TOOLS_RUNTIME = MONO_PATH=$(TOOLS_CLASS) $(abs_top_builddir)/runtime/mono-wrapper --debug
+MCS = $(TOOLS_RUNTIME) $(CSC) -nologo -noconfig -lib:$(CLASS) -r:System.dll -r:System.Core.dll -r:System.Xml.dll -r:Microsoft.CSharp.dll
+ILASM = $(TOOLS_RUNTIME) $(TOOLS_CLASS)/ilasm.exe
include versions.mk
include profiler-stress.mk
$(CORECLR_PATH)/tests/src/JIT/Methodical/Arrays/lcs/lcsmixed.cs \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Arrays/lcs/lcsval.cs \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Arrays/lcs/lcsvalbox.cs \
- $(CORECLR_PATH)/tests/src/JIT/Methodical/Arrays/misc/arrres.cs \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Arrays/misc/gcarr.cs \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Arrays/misc/selfref.cs \
$(CORECLR_PATH)/tests/src/JIT/Methodical/AsgOp/i4/i4.cs \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M02/b19171/jmp2blk.cs \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M02/b30251/b578931.cs \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b102533/DeadBlock.cs \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b268908/vars2.cs \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b320147/1086745236.cs \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b321799/repro.cs \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b338014/vsw338014.cs \
$(CORECLR_PATH)/tests/src/JIT/Regression/VS-ia64-JIT/V1.2-M02/b102729/b102729.cs \
$(CORECLR_PATH)/tests/src/JIT/Regression/VS-ia64-JIT/V1.2-M02/b102763/gcparamonstack.cs \
$(CORECLR_PATH)/tests/src/JIT/Regression/VS-ia64-JIT/V1.2-M02/b102886/ovf.cs \
- $(CORECLR_PATH)/tests/src/JIT/Regression/VS-ia64-JIT/V1.2-M02/b10828/redundant.cs \
$(CORECLR_PATH)/tests/src/JIT/Regression/VS-ia64-JIT/V1.2-M02/b19394/stringArray114.cs \
$(CORECLR_PATH)/tests/src/JIT/Regression/VS-ia64-JIT/V1.2-M02/b21015/test.cs \
$(CORECLR_PATH)/tests/src/JIT/Regression/VS-ia64-JIT/V1.2-M02/b26496/_1d6bgof.cs \
$(CORECLR_PATH)/tests/src/JIT/jit64/opt/cg/cgstress/CgStress3.cs \
$(CORECLR_PATH)/tests/src/JIT/jit64/opt/cse/HugeArray.cs \
$(CORECLR_PATH)/tests/src/JIT/jit64/opt/cse/HugeArray1.cs \
- $(CORECLR_PATH)/tests/src/JIT/jit64/opt/cse/HugeField1.cs \
$(CORECLR_PATH)/tests/src/JIT/jit64/opt/cse/HugeField2.cs \
$(CORECLR_PATH)/tests/src/JIT/jit64/opt/cse/arrayexpr1.cs \
$(CORECLR_PATH)/tests/src/JIT/jit64/opt/cse/arrayexpr2.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/components/stopwatch/co9600ctor.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/components/stopwatch/co9604get_isrunning.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/action/actionctor.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/action/actioninvoke.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/activator/activatorcreateinstance2.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/argumentexception/argumentexceptionctor1.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/argumentexception/argumentexceptionmessage.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/collections/ienumerator/ienumeratorreset.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/collections/ilist/ilistisfixedsize.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/collections/ilist/ilistitem.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/comparison/comparisonbegininvoke.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/comparison/comparisonendinvoke.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/comparison/comparisoninvoke.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/console/consoleseterror.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/console/consolesetout.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/datetime/datetimedate.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/datetime/datetimegethashcode.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/datetime/datetimehour.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/datetime/datetimekind.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/datetime/datetimemaxvalue.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/datetime/datetimemillisecond.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/datetime/datetimeminute.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/environment/environmentprocessorcount_cti.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/eventargs/eventargsctor.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/eventhandler/eventhandlerinvoke.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/eventhandler_generic/eventhandlerbegininvoke.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/eventhandler_generic/eventhandlerctor.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/eventhandler_generic/eventhandlerendinvoke.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/eventhandler_generic/eventhandlerinvoke.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/exception/exceptionctor1.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/exception/exceptionctor2.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/gc/gcgettotalmemory.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/gc/gckeepalive.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/gc/gcmaxgeneration.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/gc/gcreregisterforfinalize.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/gc/gcsuppressfinalize.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/gc/gcwaitforpendingfinalizers.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/calendarweekrule/calendarweekrulefirstday.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/charunicodeinfo/charunicodeinfogetnumericvalue2.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/charunicodeinfo/charunicodeinfogetunicodecategory1.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/charunicodeinfo/charunicodeinfogetunicodecategory2.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/compareinfo/compareinfocompare.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/compareinfo/compareinfocompare2.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/compareinfo/compareinfoindexof.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/compareinfo/compareinfoindexof2.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/compareinfo/compareinfoisprefix.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/compareinfo/compareinfoissuffix.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/compareinfo/compareinfolastindexof.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/compareoptions/compareoptionsignorecase.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/compareoptions/compareoptionsignorekanatype.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/compareoptions/compareoptionsignorenonspace.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/numberstyles/numberstylesnone.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/numberstyles/numberstylesnumber.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/regioninfo/regioninfocurrencysymbol.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/regioninfo/regioninfocurrentregion.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/regioninfo/regioninfoequals.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/regioninfo/regioninfogethashcode.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/regioninfo/regioninfoismetric.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/io/fileshare/fileshareread.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/io/fileshare/filesharereadwrite.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/io/fileshare/filesharewrite.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/io/filestream/filestreamdispose.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/io/ioexception/ioexceptionctor1.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/io/ioexception/ioexceptionctor2.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/io/memorystream/memorystreamctor.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/platformnotsupportedexception/platformnotsupportedexceptionctor1.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/platformnotsupportedexception/platformnotsupportedexceptionctor2.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/platformnotsupportedexception/platformnotsupportedexceptionctor3.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/predicate/predicatebegininvoke.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/predicate/predicateendinvoke.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/predicate/predicateinvoke.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/random/randomctor1.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/random/randomctor2.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/runtime/interopservices/marshal/marshalgetlastwin32error.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/runtime/interopservices/marshal/marshalreadint641.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/runtime/interopservices/marshal/marshalsizeof1.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/runtime/interopservices/marshal/marshalsizeof2.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/runtime/interopservices/marshalasattribute/marshalasattributearraysubtype.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/runtime/interopservices/marshalasattribute/marshalasattributector1.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/runtime/interopservices/marshalasattribute/marshalasattributector2.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringcompare9.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringcompareordinal1.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringcompareordinal2.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringcompareto1.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringconcat1.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringconcat2.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringconcat3.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringctor5.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringctorchar.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringempty.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringequals1.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringequals2.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringequals3.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringequals6.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringformat1.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringformat2.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/weakreference/weakreferencector1.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/weakreference/weakreferencector2b.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/weakreference/weakreferenceisaliveb.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/weakreference/weakreferencetargetb.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/weakreference/weakreferencetrackresurrection_cti.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/system/buffer/asurt_99893.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/system/collections/generic/hashset/regression_dev10_609271.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/system/delegate/generics/negativegenerics.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/system/delegate/miscellaneous/co6010delegateequalstwo.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/system/delegate/miscellaneous/co6031gethashcode.cs \
- $(CORECLR_PATH)/tests/src/CoreMangLib/system/delegate/regressions/devdivbugs/113347/ddb113347.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/system/guid/guid_parsing.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/system/lazyt/lazyttf.cs \
$(CORECLR_PATH)/tests/src/CoreMangLib/system/text/encoding/shift_jis.cs \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/1/Box_Unbox.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/1/Desktop/add.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/1/add.il \
- $(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/1/arglist64.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/1/array_tests.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/1/cpblk.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/1/field_tests.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/1/ldloca.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/2/Box_Unbox.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/2/add.il \
- $(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/2/arglist64.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/2/array_tests.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/2/cpblk.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/2/field_tests.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/4/Box_Unbox.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/4/Desktop/add.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/4/add.il \
- $(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/4/arglist64.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/4/array_tests.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/4/cpblk.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/4/field_tests.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/volatile/1/Box_Unbox.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/volatile/1/Desktop/add.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/volatile/1/add.il \
- $(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/volatile/1/arglist64.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/volatile/1/array_tests.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/volatile/1/cpblk.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/volatile/1/field_tests.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/leave/catch1.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/leave/catch2.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/leave/catch3.il \
- $(CORECLR_PATH)/tests/src/JIT/Directed/leave/filter1.il \
- $(CORECLR_PATH)/tests/src/JIT/Directed/leave/filter2.il \
- $(CORECLR_PATH)/tests/src/JIT/Directed/leave/filter3.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/leave/try1.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/leave/try2.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/leave/try3.il \
- $(CORECLR_PATH)/tests/src/JIT/Directed/refbyref/byrefconvert.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/shift/int8.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/shift/nativeint.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/shift/nativeuint.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/throwbox/finally.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/throwbox/rethrow.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/zeroinit/Dev10_863995.il \
- $(CORECLR_PATH)/tests/src/JIT/Directed/zeroinit/init_byte.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/zeroinit/init_int32.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/zeroinit/init_int64.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/zeroinit/init_struct.il \
- $(CORECLR_PATH)/tests/src/JIT/Directed/zeroinit/init_uint32.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/zeroinit/init_uint64.il \
$(CORECLR_PATH)/tests/src/JIT/Directed/zeroinit/tail.il \
$(CORECLR_PATH)/tests/src/JIT/Generics/ConstrainedCall/vt1.il \
$(CORECLR_PATH)/tests/src/JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_i4_u4.il \
$(CORECLR_PATH)/tests/src/JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_i8_i4.il \
$(CORECLR_PATH)/tests/src/JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_i8_u8.il \
- $(CORECLR_PATH)/tests/src/JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_r8_i.il \
- $(CORECLR_PATH)/tests/src/JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_r8_i4.il \
- $(CORECLR_PATH)/tests/src/JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_r8_i8.il \
$(CORECLR_PATH)/tests/src/JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_u4_i.il \
$(CORECLR_PATH)/tests/src/JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_u4_i4.il \
$(CORECLR_PATH)/tests/src/JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_u4_u1.il \
$(CORECLR_PATH)/tests/src/JIT/IL_Conformance/Old/Conformance_Base/ldc_sub_ovf_u2.il \
$(CORECLR_PATH)/tests/src/JIT/IL_Conformance/Old/Conformance_Base/ldc_sub_ovf_u4.il \
$(CORECLR_PATH)/tests/src/JIT/IL_Conformance/Old/Conformance_Base/ldc_sub_ovf_u8.il \
- $(CORECLR_PATH)/tests/src/JIT/Methodical/Arrays/huge_struct.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Arrays/lcs/lcs_ldlen.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Arrays/misc/lengthm2.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Arrays/misc/selfref.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/u_vfld.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/FPtrunc/convr4d.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/FPtrunc/convr8d.il \
- $(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/25params/25param1b.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/25params/25param1c.il \
- $(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/25params/25param3b.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/25params/25param3c.il \
- $(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/25params/25paramMixed.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/SEH/catchfault.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/SEH/catchfault_jmp.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/SEH/catchfault_tail.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/fptr/virtftn_t.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/implicit/fr4.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/implicit/fr8.il \
- $(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/implicit/i4u2.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/implicit/i4u4.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/implicit/i8u8.il \
- $(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/implicit/ii1.il \
- $(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/implicit/ii2.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/implicit/ii4.il \
- $(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/implicit/iu2.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/implicit/iu4.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/implicit/objref.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/thiscall/thisnull.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/casts/iface/iface2.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/casts/ilseq/typeEqualOp.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/cctor/misc/deadlock.il \
- $(CORECLR_PATH)/tests/src/JIT/Methodical/cctor/simple/Desktop/prefldinit3.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/cctor/simple/prefldinit1.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/cctor/simple/prefldinit2.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/cctor/simple/prefldinit4.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/flowgraph/dev10_bug679955/indexMinusOne.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/flowgraph/dev10_bug679955/volatileLocal1.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/flowgraph/dev10_bug679955/volatileLocal2.il \
- $(CORECLR_PATH)/tests/src/JIT/Methodical/int64/arrays/hugedim.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/int64/arrays/lcs_long.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/int64/arrays/lcs_ulong.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/int64/misc/binop.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/nonvirtualcall/tailcall.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/nonvirtualcall/valuetype.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/refany/array1.il \
- $(CORECLR_PATH)/tests/src/JIT/Methodical/refany/array2.il \
- $(CORECLR_PATH)/tests/src/JIT/Methodical/refany/array3.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/refany/native.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/refany/seq.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/refany/stress2.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/tailcall/compat_obj.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/tailcall/compat_v.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/tailcall/deep_array.il \
- $(CORECLR_PATH)/tests/src/JIT/Methodical/tailcall/deep_array_nz.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/tailcall/deep_gc.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/tailcall/deep_inst.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/tailcall/deep_value.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/varargs/callconv/gc_ctor.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/varargs/callconv/val_ctor.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/varargs/misc/Dev10_615402.il \
- $(CORECLR_PATH)/tests/src/JIT/Methodical/xxblk/cpblk3.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/xxblk/initblk3.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/xxobj/ldobj/ldobj_I.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/xxobj/ldobj/ldobj_I8.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/xxobj/operand/refanyval.il \
$(CORECLR_PATH)/tests/src/JIT/Methodical/xxobj/operand/unbox.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-EJIT/V1-M09.5-PDC/b16935/b16935.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-EJIT/V1-M11-Beta1/b44018/b44018.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-EJIT/V1-M11-Beta1/b45046/b45046.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-EJIT/V1-M12-Beta2/b26323/b26323.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-EJIT/V1-M12-Beta2/b35455/b35455.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b16881/b16881a.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b16881/b16881b.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b16886/b16886.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b16895/b16895.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b16896/b16896.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b16922/b16922.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b16928/b16928.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b20217/b20217.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b20249/b20249.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b25458/b25458.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b25459/b25459.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b25463/b25463.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b25468/b25468-ia64.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b25474/b25474.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b27657/b27657.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b27658/b27658.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b27880/b27880.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b27883/b27883.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b27917/b27917.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b28080/b28080.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b28522/b28522.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b28594/b28594.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b28595/b28595.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b28596/b28596.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b28597/b28597.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b28805/b28805.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b28806/b28806.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b28927/b28927.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b29583/b29583.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b30125/b30125.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b30792/b30792.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b30799/b30799.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b30838/b30838.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b05933/b05933.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b06435/b06435.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b06436/b06436.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b06595/b06595.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b06730/b06730.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b06754/b06754.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b07082/b07082.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b07411/b07411.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b07458/b07458.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b07704/b07704.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b08107/b08107.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b08109/b08109.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b08672/b08672.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b08797/b08797.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b28598/b28598.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b28949/b28949a.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b30868/b30868.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b31283/b31283.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b31289/b31289.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b31292/b31292.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b31423/b31423.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b70335/b70335.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b70354/b70354.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b70808/b70808.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b70909/b70909.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b70964/b70964.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b70967/b70967.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b70992/b70992.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b70994/b70994.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b71003/b71003.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b71179/b71179.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b71318/b71318.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b71722/b71722.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b71831/b71831.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b71869/b71869.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M01/b14617/b14617.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M01/b15617/arrayDim.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M01/b18049/loop2.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M02/b102962/t.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M02/b102962/t2.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M02/b102962/vc178279.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M02/b115932/t.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M02/b115932/t1.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M02/b118260/b118260.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M02/b138117/ldsfldainitonlyvt.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b091942/nullref.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b309555/x86-test-1084346006.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b323557/1087985874.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b353858/b353858.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b409617/b409617.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b415164/b415164.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b423755/Desktop/b423755.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-RTM/b471305/b471305.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-RTM/b475589/b475589.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-RTM/b489329/b489329.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-RTM/b518440/b518440.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-RTM/b598031/test.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/v2.1/b173313/b173313.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/v2.1/b193264/b193264.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/v2.1/b48850/b48850.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/Dev11/Dev11_468598/Test_HndIndex_10_Reordered.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/Dev11/Dev11_b473131/b473131.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/Dev11/Dev11_b473131/b473131_byte.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/Dev11/Dev11_b473131/b473131_fld.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/Dev11/Dev11_b473131/b473131_intptr.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/Dev11/Dev11_b473131/b473131_struct.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/Dev11/DevDiv2_11321/DevDiv2_11321.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/Dev11/External/Dev11_90434/UseUnalignedDouble.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/VS-ia64-JIT/M00/b102759/b102759.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/VS-ia64-JIT/V2.0-Beta2/b450688/b450688.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/VS-ia64-JIT/V2.0-RTM/b460385/b460385.il \
$(CORECLR_PATH)/tests/src/JIT/Regression/clr-x64-JIT/v4.0/b602182/b602182.il \
- $(CORECLR_PATH)/tests/src/JIT/Regression/v4/dev10_804810/dev10_804810.il \
$(CORECLR_PATH)/tests/src/JIT/jit64/localloc/zeroinit/zeroinit01_large.il \
$(CORECLR_PATH)/tests/src/JIT/jit64/localloc/zeroinit/zeroinit01_small.il \
$(CORECLR_PATH)/tests/src/JIT/jit64/opt/cg/il/jmp.il \
$(CORECLR_PATH)/tests/src/JIT/jit64/opt/regress/vswhidbey/481244/foo2.il \
$(CORECLR_PATH)/tests/src/JIT/jit64/regress/ddb/118414/118414.il \
$(CORECLR_PATH)/tests/src/JIT/jit64/regress/ddb/127931/127931.il \
- $(CORECLR_PATH)/tests/src/JIT/jit64/regress/phoenix/62322/test.il \
$(CORECLR_PATH)/tests/src/JIT/jit64/regress/vsw/102974/test.il \
$(CORECLR_PATH)/tests/src/JIT/jit64/regress/vsw/153682/test.il \
$(CORECLR_PATH)/tests/src/JIT/jit64/regress/vsw/266693/test.il \
CORECLR_DISABLED_TEST_IL_SRC += \
$(CORECLR_PATH)/tests/src/JIT/Directed/coverage/oldtests/lcliimpl.il
-
+
+# FIXME: these tests are baselined, i.e. we don't have time to investigate
+# them right now but want to make sure we don't introduce new regressions
+# in the rest of the tests
+CORECLR_DISABLED_TEST_CS_SRC += \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/eventhandler_generic/eventhandlerbegininvoke.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/action/actioninvoke.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/comparison/comparisonendinvoke.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/comparison/comparisonbegininvoke.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/datetime/datetimekind.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/eventhandler_generic/eventhandlerendinvoke.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/gc/gcreregisterforfinalize.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/compareinfo/compareinfocompare.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/compareinfo/compareinfoindexof.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/compareinfo/compareinfoisprefix.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/compareinfo/compareinfoissuffix.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/compareinfo/compareinfolastindexof.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/globalization/regioninfo/regioninfocurrentregion.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/io/filestream/filestreamdispose.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/predicate/predicateendinvoke.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/predicate/predicatebegininvoke.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/runtime/interopservices/marshal/marshalsizeof2.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringcompareto1.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringequals1.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringequals2.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/string/stringequals3.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/cti/system/weakreference/weakreferencetargetb.cs \
+ $(CORECLR_PATH)/tests/src/CoreMangLib/system/delegate/regressions/devdivbugs/113347/ddb113347.cs \
+ $(CORECLR_PATH)/tests/src/JIT/Methodical/Arrays/misc/arrres.cs \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b268908/vars2.cs \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/VS-ia64-JIT/V1.2-M02/b10828/redundant.cs \
+ $(CORECLR_PATH)/tests/src/JIT/jit64/opt/cse/HugeField1.cs
+
+CORECLR_DISABLED_TEST_IL_SRC += \
+ $(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/1/arglist64.il \
+ $(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/2/arglist64.il \
+ $(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/unaligned/4/arglist64.il \
+ $(CORECLR_PATH)/tests/src/JIT/Directed/PREFIX/volatile/1/arglist64.il \
+ $(CORECLR_PATH)/tests/src/JIT/Directed/leave/filter1.il \
+ $(CORECLR_PATH)/tests/src/JIT/Directed/leave/filter2.il \
+ $(CORECLR_PATH)/tests/src/JIT/Directed/leave/filter3.il \
+ $(CORECLR_PATH)/tests/src/JIT/Directed/refbyref/byrefconvert.il \
+ $(CORECLR_PATH)/tests/src/JIT/Directed/zeroinit/init_byte.il \
+ $(CORECLR_PATH)/tests/src/JIT/Directed/zeroinit/init_uint32.il \
+ $(CORECLR_PATH)/tests/src/JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_r8_i.il \
+ $(CORECLR_PATH)/tests/src/JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_r8_i4.il \
+ $(CORECLR_PATH)/tests/src/JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_r8_i8.il \
+ $(CORECLR_PATH)/tests/src/JIT/Methodical/Arrays/huge_struct.il \
+ $(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/25params/25param3b.il \
+ $(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/25params/25paramMixed.il \
+ $(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/implicit/i4u2.il \
+ $(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/implicit/ii1.il \
+ $(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/implicit/iu2.il \
+ $(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/implicit/ii2.il \
+ $(CORECLR_PATH)/tests/src/JIT/Methodical/cctor/simple/Desktop/prefldinit3.il \
+ $(CORECLR_PATH)/tests/src/JIT/Methodical/int64/arrays/hugedim.il \
+ $(CORECLR_PATH)/tests/src/JIT/Methodical/tailcall/deep_array_nz.il \
+ $(CORECLR_PATH)/tests/src/JIT/Methodical/refany/array3.il \
+ $(CORECLR_PATH)/tests/src/JIT/Methodical/refany/array2.il \
+ $(CORECLR_PATH)/tests/src/JIT/Methodical/xxblk/cpblk3.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-EJIT/V1-M11-Beta1/b44018/b44018.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b16895/b16895.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b25459/b25459.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b27883/b27883.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b27917/b27917.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b28597/b28597.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b30125/b30125.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b08107/b08107.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M10/b06595/b06595.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b31283/b31283.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b70909/b70909.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b71318/b71318.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M02/b102962/t.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M02/b102962/t2.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M02/b115932/t.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V1.2-M02/b115932/t1.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b091942/nullref.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-RTM/b471305/b471305.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/CLR-x86-JIT/V2.0-RTM/b475589/b475589.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/Dev11/Dev11_468598/Test_HndIndex_10_Reordered.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/Dev11/Dev11_b473131/b473131_struct.il \
+ $(CORECLR_PATH)/tests/src/JIT/Regression/v4/dev10_804810/dev10_804810.il \
+ $(CORECLR_PATH)/tests/src/JIT/jit64/regress/phoenix/62322/test.il \
+ $(CORECLR_PATH)/tests/src/JIT/Methodical/Invoke/25params/25param1b.il
+
+
# find all CoreCLR *.il test files that aren't mentioned in this file
CORECLR_DEFINED_IL_SRC = $(CORECLR_TEST_IL_SRC) $(CORECLR_DISABLED_TEST_IL_SRC)
CORECLR_UPSTREAM_IL_SRC=$(shell find "$(CORECLR_PATH)/tests" -iname "*.il")
PLATFORM_AOT_SUFFIX=.so
fi
+if test -z "$HOST_WIN32_TRUE"; then :
+PLATFORM_AOT_SUFFIX=.dll
+fi
+
AC_SUBST(PLATFORM_AOT_SUFFIX)
## PLATFORM_AOT_SUFFIX not so simple for windows :-)
AC_ARG_WITH(testing_aot_hybrid, [ --with-testing_aot_hybrid=yes,no If you want to build the testing_aot_hybrid assemblies (defaults to no)], [], [with_testing_aot_hybrid=default])
AC_ARG_WITH(testing_aot_full, [ --with-testing_aot_full=yes,no If you want to build the testing_aot_full assemblies (defaults to no)], [], [with_testing_aot_full=default])
AC_ARG_WITH(winaot, [ --with-winaot=yes,no If you want to build the Windows friendly AOT assemblies (defaults to no)], [], [with_winaot=default])
+AC_ARG_WITH(orbis, [ --with-orbis=yes,no If you want to build the Orbis assemblies (defaults to no)], [], [with_orbis=default])
+
AC_ARG_WITH(runtime_preset, [ --with-runtime_preset=net_4_x,all,aot,hybridaot,fullaot,bitcode Which default profile to build (defaults to net_4_x)], [], [with_runtime_preset=net_4_x])
with_testing_aot_hybrid_default=no
with_testing_aot_full_default=no
with_winaot_default=no
+with_orbis_default=no
with_bitcode_default=no
with_cooperative_gc_default=no
with_monotouch_tv_default=yes
with_xammac_default=yes
with_winaot_default=yes
+ with_orbis_default=yes
elif test x$with_runtime_preset = xfullaot; then
DISABLE_MCS_DOCS_default=yes
with_testing_aot_full_default=yes
mono_feature_disable_appdomains='yes'
AOT_BUILD_FLAGS="-O=gsharedvt --aot=full,$INVARIANT_AOT_OPTIONS"
+
AOT_RUN_FLAGS="--full-aot"
elif test x$with_runtime_preset = xbitcode; then
DISABLE_MCS_DOCS_default=yes
AOT_RUN_FLAGS=""
DISABLE_MCS_DOCS_default=yes
+elif test x$with_runtime_preset = xwinaot; then
+ DISABLE_MCS_DOCS_default=yes
+ with_winaot_default=yes
+ TEST_PROFILE=winaot
+
+ mono_feature_disable_com='yes'
+ mono_feature_disable_remoting='yes'
+ mono_feature_disable_reflection_emit_save='yes'
+ mono_feature_disable_reflection_emit='yes'
+ mono_feature_disable_appdomains='yes'
+
+ AOT_BUILD_FLAGS="--aot=full,$INVARIANT_AOT_OPTIONS"
+ AOT_RUN_FLAGS="--full-aot"
+elif test x$with_runtime_preset = xorbis; then
+ DISABLE_MCS_DOCS_default=yes
+ with_orbis_default=yes
+ TEST_PROFILE=orbis
+
+ mono_feature_disable_com='yes'
+ mono_feature_disable_remoting='yes'
+ mono_feature_disable_reflection_emit_save='yes'
+ mono_feature_disable_reflection_emit='yes'
+ mono_feature_disable_appdomains='yes'
+
+ AOT_BUILD_FLAGS="--aot=full,$INVARIANT_AOT_OPTIONS"
+ AOT_RUN_FLAGS="--full-aot"
else
with_profile4_x_default=yes
fi
if test "x$with_winaot" = "xdefault"; then
with_winaot=$with_winaot_default
fi
+if test "x$with_orbis" = "xdefault"; then
+ with_orbis=$with_orbis_default
+fi
AM_CONDITIONAL(INSTALL_4_x, [test "x$with_profile4_x" = "xyes"])
AM_CONDITIONAL(INSTALL_TESTING_AOT_HYBRID, [test "x$with_testing_aot_hybrid" != "xno"])
AM_CONDITIONAL(INSTALL_TESTING_AOT_FULL, [test "x$with_testing_aot_full" != "xno"])
AM_CONDITIONAL(INSTALL_WINAOT, [test "x$with_winaot" != "xno"])
-
-AC_SUBST(INSTALL_TESTING_AOT_HYBRID)
-AC_SUBST(INSTALL_TESTING_AOT_FULL)
+AM_CONDITIONAL(INSTALL_ORBIS, [test "x$with_orbis" != "xno"])
+AM_CONDITIONAL(FULL_AOT_TESTS, [test "x$TEST_PROFILE" = "xtesting_aot_full"] || [test "x$TEST_PROFILE" = "xwinaot"] || [test "x$TEST_PROFILE" = "xorbis"])
+AM_CONDITIONAL(HYBRID_AOT_TESTS, [test "x$TEST_PROFILE" = "xtesting_aot_hybrid"])
default_profile=net_4_x
if test -z "$INSTALL_MONODROID_TRUE"; then :
if test -z "$INSTALL_TESTING_AOT_FULL_TRUE"; then :
default_profile=testing_aot_full
fi
+if test -z "$INSTALL_WINAOT_TRUE"; then :
+ default_profile=winaot
+fi
+if test -z "$INSTALL_ORBIS_TRUE"; then :
+ default_profile=orbis
+fi
if test -z "$INSTALL_4_x_TRUE"; then :
default_profile=net_4_x
fi
AC_DEFINE(TARGET_OSX,1,[The JIT/AOT targets OSX])
CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DTARGET_OSX"
CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -DTARGET_OSX"
+ target_osx=yes
], [
AC_DEFINE(TARGET_IOS,1,[The JIT/AOT targets iOS])
CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DTARGET_IOS"
AC_DEFINE(TARGET_MACH,1,[The JIT/AOT targets Apple platforms])
fi
+AM_CONDITIONAL(TARGET_OSX, test x$target_osx = xyes)
+
if test "x$sizeof_register" = "x4"; then
AC_DEFINE(SIZEOF_REGISTER,4,[size of machine integer registers])
elif test "x$sizeof_register" = "x8"; then
if test x$host_win32 = xyes; then
if test "x$cross_compiling" = "xno"; then
mono_cfg_dir=`cygpath -w -a $mono_cfg_root`\\etc
- CSC="'"`cygpath -w -a $CSC`"'"
- CSC_LOCATION="'"`cygpath -w -a $CSC_LOCATION`"'"
+ CSC=`cygpath -m -a $CSC`
+ CSC_LOCATION=`cygpath -m -a $CSC_LOCATION`
else
mono_cfg_dir=`echo $mono_cfg_root | tr '/' '\\'`\\etc
fi
mono/tests/gc-descriptors/Makefile
mono/unit-tests/Makefile
mono/benchmark/Makefile
-mono/io-layer/Makefile
mono/mini/Makefile
mono/profiler/Makefile
m4/Makefile
])
# Update all submodules recursively to ensure everything is checked out
-$srcdir/scripts/update_submodules
+$srcdir/scripts/update_submodules.sh
if test x$host_win32 = xyes; then
# Get rid of 'cyg' prefixes in library names
Xamarin.TVOS: $with_monotouch_tv
Xamarin.Mac: $with_xammac
Windows AOT: $with_winaot
+ Orbis: $with_orbis
Test profiles: AOT Full ($with_testing_aot_full), AOT Hybrid ($with_testing_aot_hybrid)
JNI support: $jdk_headers_found
libgdiplus: $libgdiplus_msg
/mono-tools.tree
/mono-tools.zip
/AgilityPack.dll*
+/doxygen-output
clean-local:
-rm -Rf html
+ -rm -Rf doxygen-output
-rm -f deploy/* convert.exe* AgilityPack.dll*
-rm -f $(ASSEMBLED_DOCS)
AgilityPack.dll:
$(TOOL_MAKE) AgilityPack.dll
+doxygen:
+ doxygen doxyfile
+
+.PHONY: doxygen
--- /dev/null
+ALLOW_UNICODE_NAMES = NO
+ALPHABETICAL_INDEX = YES
+ALWAYS_DETAILED_SEC = NO
+AUTOLINK_SUPPORT = YES
+BRIEF_MEMBER_DESC = YES
+CALLER_GRAPH = YES
+CALL_GRAPH = YES
+CASE_SENSE_NAMES = NO
+CLASS_DIAGRAMS = YES
+COLS_IN_ALPHA_INDEX = 1
+CREATE_SUBDIRS = NO
+DIRECTORY_GRAPH = YES
+DOT_CLEANUP = YES
+DOT_IMAGE_FORMAT = svg
+DOT_MULTI_TARGETS = YES
+DOXYFILE_ENCODING = UTF-8
+ENABLE_PREPROCESSING = YES
+ENUM_VALUES_PER_LINE = 1
+EXCLUDE_SYMLINKS = NO
+EXPAND_ONLY_PREDEF = NO
+EXTENSION_MAPPING = c=C h=C
+EXTRACT_ALL = YES
+EXTRACT_STATIC = YES
+EXT_LINKS_IN_WINDOW = NO
+FILE_PATTERNS = *.c *.h
+FULL_PATH_NAMES = YES
+GENERATE_BUGLIST = YES
+GENERATE_DEPRECATEDLIST = YES
+GENERATE_HTML = YES
+GENERATE_PERLMOD = YES
+GENERATE_LEGEND = YES
+GENERATE_TESTLIST = YES
+GENERATE_TODOLIST = YES
+GENERATE_TREEVIEW = YES
+GRAPHICAL_HIERARCHY = YES
+HAVE_DOT = YES
+HIDE_UNDOC_RELATIONS = YES
+HTML_COLORSTYLE_GAMMA = 80
+HTML_COLORSTYLE_HUE = 220
+HTML_COLORSTYLE_SAT = 100
+HTML_DYNAMIC_SECTIONS = YES
+HTML_FILE_EXTENSION = .html
+HTML_INDEX_NUM_ENTRIES = 100
+HTML_OUTPUT = doxygen
+HTML_TIMESTAMP = YES
+INCLUDED_BY_GRAPH = YES
+INCLUDE_GRAPH = YES
+INHERIT_DOCS = YES
+INLINE_INHERITED_MEMB = NO
+INLINE_SOURCES = YES
+INPUT = ../mono
+INPUT_ENCODING = UTF-8
+INTERACTIVE_SVG = YES
+JAVADOC_AUTOBRIEF = NO
+LOOKUP_CACHE_SIZE = 0
+MACRO_EXPANSION = NO
+MARKDOWN_SUPPORT = YES
+MAX_INITIALIZER_LINES = 30
+MULTILINE_CPP_IS_BRIEF = NO
+OPTIMIZE_OUTPUT_FOR_C = YES
+OUTPUT_DIRECTORY = doxygen-output
+OUTPUT_LANGUAGE = English
+PROJECT_NAME = "Mono"
+QT_AUTOBRIEF = NO
+QUIET = NO
+RECURSIVE = YES
+REFERENCED_BY_RELATION = YES
+REFERENCES_LINK_SOURCE = YES
+REFERENCES_RELATION = YES
+REPEAT_BRIEF = YES
+SEARCHENGINE = YES
+SEARCH_INCLUDES = YES
+SEPARATE_MEMBER_PAGES = NO
+SHORT_NAMES = NO
+SHOW_FILES = YES
+SHOW_USED_FILES = YES
+SKIP_FUNCTION_MACROS = YES
+SORT_BRIEF_DOCS = YES
+SORT_GROUP_NAMES = YES
+SOURCE_BROWSER = YES
+SOURCE_TOOLTIPS = YES
+STRIP_CODE_COMMENTS = NO
+TAB_SIZE = 4
+TREEVIEW_WIDTH = 250
+TYPEDEF_HIDES_STRUCT = NO
+USE_HTAGS = NO
+USE_MDFILE_AS_MAINPAGE = ../README.md
+VERBATIM_HEADERS = YES
+WARNINGS = YES
+WARN_IF_DOC_ERROR = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_NO_PARAMDOC = NO
-Subproject commit 1764ddd3c198a0cf7986339694648cac273e0e9e
+Subproject commit 512ba41a94bec35ff0c395eb71a180fda23da95c
-Subproject commit 9e497a721510a76c233a52dabe3c05fbb2c4ba52
+Subproject commit f80cce4b1338b72b1b7637d4eb7675763adc13ab
-Subproject commit 8af05b5eed3e5999484b53a08dce9d89baee2afd
+Subproject commit d87c966d80c1274373ddafe3375bf1730cd430ed
-Subproject commit 606eb25118347c5c8eeb69d247fcfe4ecb43460c
+Subproject commit 69ce5c6b089b5c4bfebd7a6cd1bd7d90c0b05a03
+ltconfig crlf=input
+install-sh crlf=input
/BCC_MAKEFILE -crlf
/digimars.mak -crlf
mconfig.1 \
mcs.1 \
mdassembler.1 \
+ mdb2ppdb.1 \
mdoc.1 \
mdoc.5 \
mdoc-assemble.1 \
mozroots.1 \
pdb2mdb.1 \
permview.1 \
- prj2make.1 \
resgen.1 \
secutil.1 \
setreg.1 \
--- /dev/null
+.\"
+.\" mono manual page.
+.\" Copyright 2017 Microsoft
+.\"
+.TH Mono "Mono 4.8.0"
+.SH NAME
+mdb2ppdb \- Convert Mono's debug file format (MDB) to Portable Program
+Database (PPDB) file formatn
+.SH SYNOPSIS
+.PP
+.B mdb2ppdb input.mdb output.ppdb
+.SH DESCRIPTION
+\fImdb2ppdb\fP is a tool that can be used to convert debug information
+stored in the Mono debug file format (files with the extension .mdb)
+which both Mono's compiler and tools that used Mono's
+System.Reflection.Emit debug file format on Unix used into the new
+debug format Portable Program Database (files with the
+extension .ppdb).
+.SH MAILING LISTS
+Mailing lists are listed at the
+http://www.mono-project.com/community/help/mailing-lists/
+.SH WEB SITE
+http://www.mono-project.com
+.SH SEE ALSO
+.PP
+mcs(1), pdb2mdb(1)
+++ /dev/null
-.\"
-.\" mono manual page.
-.\" Author:
-.\" Francisco Martinez
-.\"
-.de Sp \" Vertical space (when we can't use .PP)
-.if t .sp .5v
-.if n .sp
-..
-.TH prj2make "prj2make 1.0"
-.SH NAME
-prj2make \- Makefile generator from Visual Studio and Sharp Develop
-solution files.
-.SH SYNOPSIS
-.PP
-.B prj2make options file
-.SH DESCRIPTIOn
-The \fIprj2make\fP tool will produce Makefiles or NMakefiles from
-Visual Studio solution files (files ending in .sln or .csproj) or
-SharpDevelop combine files (files ending in .cmbx or .prjx).
-.PP
-This tool is commonly used to compile on Unix source code which has
-been originally developed with Visual Studio or SharpDevelop.
-.PP
-This tool can also be used to convert Visual Studio project files
-(.sln or .csproj) into Sharp Develop .prjx/.cmbx files, use the
-`-csproj2prjx' for this.
-.PP
-By default
-.I prj2make
-will produce Makefiles suitable to be consumed by Unix Make. If your
-application needs to target nmake, you can use the option `-isNmake'.
-.SH OPTIONS
-.TP
-.I "-c", "-isCsc"
-Use csc instead of mcs on the generated files.
-.TP
-.I "-csproj2prjx"
-Runs in conversion mode, and turns a csproj/sln into a set of
-prjx/cmbx files.
-.TP
-.I "-n", "-isNmake"
-Produce makefiles suitable to be used by Nmake.
-.SH MAILING LISTS
-Visit http://lists.ximian.com/mailman/listinfo/mono-list for details.
-.SH WEB SITE
-Visit: http://www.mono-project.com for details
-.SH SEE ALSO
-.BR mcs(1), mono(1), make(1), mono-config(5)
-
xbuild_12_SUBDIRS := build class tools/xbuild
xbuild_14_SUBDIRS := build class tools/xbuild
winaot_SUBDIRS := build class
+orbis_SUBDIRS := build class
include build/rules.make
$(_boot_:%=profile-do--testing_aot_hybrid--%): profile-do--testing_aot_hybrid--%: profile-do--build--%
$(_boot_:%=profile-do--testing_aot_full--%): profile-do--testing_aot_full--%: profile-do--build--%
$(_boot_:%=profile-do--winaot--%): profile-do--winaot--%: profile-do--build--%
+$(_boot_:%=profile-do--orbis--%): profile-do--orbis--%: profile-do--build--%
$(_boot_:%=profile-do--build--%): profile-do--build--%: profile-do--basic--%
testcorlib:
NO_INSTALL = yes
MOBILE_DYNAMIC = yes
MOBILE_PROFILE = yes
+NO_CONSOLE = yes
NO_INSTALL = yes
AOT_FRIENDLY_PROFILE = yes
MOBILE_PROFILE = yes
+NO_CONSOLE = yes
PROFILE_DISABLE_BTLS=1
--- /dev/null
+#! -*- makefile -*-
+
+BOOTSTRAP_PROFILE = build
+
+BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_CSC)
+MCS = $(BOOTSTRAP_MCS)
+
+# Use system resgen as we don't want local System.Windows.Forms dependency
+RESGEN = resgen2
+
+profile-check:
+ @:
+
+DEFAULT_REFERENCES = -r:$(topdir)/class/lib/$(PROFILE)/mscorlib.dll
+
+PROFILE_MCS_FLAGS = \
+ -d:NET_1_1 \
+ -d:NET_2_0 \
+ -d:NET_2_1 \
+ -d:NET_3_5 \
+ -d:NET_4_0 \
+ -d:NET_4_5 \
+ -d:MONO \
+ -d:NETSTANDARD \
+ -d:MOBILE,MOBILE_LEGACY \
+ -d:FULL_AOT_DESKTOP \
+ -d:FULL_AOT_RUNTIME \
+ -d:DISABLE_REMOTING \
+ -d:DISABLE_COM \
+ -nowarn:1699 \
+ -nostdlib \
+ $(DEFAULT_REFERENCES) \
+ $(PLATFORM_DEBUG_FLAGS)
+
+FRAMEWORK_VERSION = 2.1
+
+# the tuner takes care of the install
+NO_INSTALL = yes
+AOT_FRIENDLY_PROFILE = yes
+ALWAYS_AOT = yes
+MOBILE_PROFILE = yes
+NO_VTS_TEST = yes
+NO_CONSOLE = yes
+
+# Note need for trailing comma. If you add, keep it
+PROFILE_TEST_HARNESS_EXCLUDES = MobileNotWorking,PKITS,
AOT_FRIENDLY_PROFILE = yes
MOBILE_PROFILE = yes
NO_VTS_TEST = yes
+NO_CONSOLE = yes
# Note need for trailing comma. If you add, keep it
PROFILE_TEST_HARNESS_EXCLUDES = MobileNotWorking,PKITS,
NO_INSTALL = yes
MOBILE_DYNAMIC = yes
-MOBILE_PROFILE = yes
\ No newline at end of file
+MOBILE_PROFILE = yes
+NO_CONSOLE = yes
NO_INSTALL = yes
MOBILE_DYNAMIC = yes
MOBILE_PROFILE = yes
+NO_CONSOLE = yes
PROFILE_DISABLE_BTLS=1
# be able to evaluate the .dylibs to make
ifneq ("$(wildcard $(topdir)/class/lib/$(PROFILE))","")
-AOT_PROFILE_ASSEMBLIES := $(sort $(patsubst .//%,%,$(filter-out %bare% %plaincore% %secxml% %Facades% %ilasm%,$(filter %.dll %.exe,$(wildcard $(topdir)/class/lib/$(PROFILE)/*)))))
+AOT_PROFILE_ASSEMBLIES := $(sort $(patsubst .//%,%,$(filter-out %.dll.dll %.exe.dll %bare% %plaincore% %secxml% %Facades% %ilasm%,$(filter %.dll %.exe,$(wildcard $(topdir)/class/lib/$(PROFILE)/*)))))
# This can run in parallel
.PHONY: aot-all-profile
+ifdef AOT_BUILD_FLAGS
aot-all-profile: $(patsubst %,%$(PLATFORM_AOT_SUFFIX),$(AOT_PROFILE_ASSEMBLIES))
+else
+aot-all-profile:
+ echo AOT_BUILD_FLAGS not set, skipping AOT.
+endif
+
+%.dll$(PLATFORM_AOT_SUFFIX): %.dll
+ @ mkdir -p $<_bitcode_tmp
+ $(Q_AOT) MONO_PATH="$(dir $<)" $(RUNTIME) $(RUNTIME_FLAGS) $(AOT_BUILD_FLAGS),temp-path=$<_bitcode_tmp --verbose $< > $@.aot-log
+ @ rm -rf $<_bitcode_tmp
-%$(PLATFORM_AOT_SUFFIX): %
- @ mkdir -p $*_bitcode_tmp
- $(Q_AOT) MONO_PATH="$(dir $*)" $(RUNTIME) $(RUNTIME_FLAGS) $(AOT_BUILD_FLAGS),temp-path=$*_bitcode_tmp --verbose $* > $@.aot-log
- @ rm -rf $*_bitcode_tmp
+%.exe$(PLATFORM_AOT_SUFFIX): %.exe
+ @ mkdir -p $<_bitcode_tmp
+ $(Q_AOT) MONO_PATH="$(dir $<)" $(RUNTIME) $(RUNTIME_FLAGS) $(AOT_BUILD_FLAGS),temp-path=$<_bitcode_tmp --verbose $< > $@.aot-log
+ @ rm -rf $<_bitcode_tmp
endif #ifneq ("$(wildcard $(topdir)/class/lib/$(PROFILE))","")
</PropertyGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<ItemGroup>\r
- <Compile Include="..\..\..\build\common\MonoTODOAttribute.cs" />\r
<Compile Include="AssemblyInfo.cs" />\r
<Compile Include="RegistryAclExtensions.cs" />\r
<Compile Include="TypeForwarders.cs" />\r </ItemGroup>\r
</PropertyGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<ItemGroup>\r
+ <Compile Include="..\..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbColumn.cs" />\r
+ <Compile Include="..\..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbDataReaderExtensions.Facade.cs" />\r
+ <Compile Include="..\..\..\..\external\corefx\src\System.Data.Common\src\System\Data\IColumnMappingCollection.cs" />\r
<Compile Include="AssemblyInfo.cs" />\r
- <Compile Include="DbColumn.cs" />\r
- <Compile Include="DbDataReaderExtensions.Facade.cs" />\r
- <Compile Include="IDbColumnSchemaGenerator.cs" />\r
<Compile Include="TypeForwarders.cs" />\r </ItemGroup>\r
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
Other similar extension points exist, see Microsoft.Common.targets.\r
</PropertyGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<ItemGroup>\r
- <Compile Include="..\..\..\build\common\MonoTODOAttribute.cs" />\r
+ <Compile Include="..\..\..\..\external\corefx\src\System.Runtime.Extensions\src\System\Globalization\Extensions.cs" />\r
+ <Compile Include="..\..\..\..\external\corefx\src\System.Runtime.Extensions\src\System\StringNormalizationExtensions.cs" />\r
<Compile Include="AssemblyInfo.cs" />\r
- <Compile Include="GlobalizationExtensions.cs" />\r
<Compile Include="SR.cs" />\r
- <Compile Include="StringNormalizationExtensions.cs" />\r
<Compile Include="TypeForwarders.cs" />\r </ItemGroup>\r
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
Other similar extension points exist, see Microsoft.Common.targets.\r
</PropertyGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<ItemGroup>\r
+ <Compile Include="..\..\..\..\external\corefx\src\System.Reflection.TypeExtensions\src\System\Reflection\Requires.cs" />\r
+ <Compile Include="..\..\..\..\external\corefx\src\System.Reflection.TypeExtensions\src\System\Reflection\TypeExtensions.cs" />\r
<Compile Include="AssemblyInfo.cs" />\r
- <Compile Include="Requires.cs" />\r
- <Compile Include="SR.cs" />\r
- <Compile Include="TypeExtensions.CoreCLR.cs" />\r
+ <Compile Include="corefx\SR.cs" />\r
<Compile Include="TypeForwarders.cs" />\r </ItemGroup>\r
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
Other similar extension points exist, see Microsoft.Common.targets.\r
</PropertyGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<ItemGroup>\r
+ <Compile Include="..\..\..\..\external\corefx\src\System.Runtime.Serialization.Primitives\src\System\Runtime\Serialization\ISerializationSurrogateProvider.cs" />\r
<Compile Include="AssemblyInfo.cs" />\r
- <Compile Include="ISerializationSurrogateProvider.cs" />\r
<Compile Include="TypeForwarders.cs" />\r </ItemGroup>\r
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
Other similar extension points exist, see Microsoft.Common.targets.\r
</PropertyGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<ItemGroup>\r
+ <Compile Include="..\..\..\..\external\corefx\src\System.Runtime.InteropServices\src\System\Security\SecureStringMarshal.cs" />\r
<Compile Include="AssemblyInfo.cs" />\r
- <Compile Include="SecureStringMarshal.cs" />\r
<Compile Include="TypeForwarders.cs" />\r </ItemGroup>\r
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
Other similar extension points exist, see Microsoft.Common.targets.\r
</PropertyGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<ItemGroup>\r
- <Compile Include="..\..\..\build\common\MonoTODOAttribute.cs" />\r
<Compile Include="AssemblyInfo.cs" />\r
<Compile Include="ThreadingAclExtensions.cs" />\r
<Compile Include="TypeForwarders.cs" />\r </ItemGroup>\r
<SchemaVersion>2.0</SchemaVersion>\r
<ProjectGuid>{E8BFEFD2-AAB9-45E6-8523-1F6AEB1918A2}</ProjectGuid>\r
<OutputType>Library</OutputType>\r
- <NoWarn>1699,1616,1699</NoWarn>\r
+ <NoWarn>1699,1616,1699,3021</NoWarn>\r
<OutputPath>./../../../class/lib/net_4_x/Facades</OutputPath>\r
<IntermediateOutputPath>obj-Facades</IntermediateOutputPath>\r
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>\r
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
<DebugSymbols>true</DebugSymbols>\r
<DebugType>full</DebugType>\r
- <NoWarn>1699,1616,1699</NoWarn>\r
+ <NoWarn>1699,1616,1699,3021</NoWarn>\r
<Optimize>false</Optimize>\r
<DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM</DefineConstants>\r
<ErrorReport>prompt</ErrorReport>\r
</PropertyGroup>\r
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
<DebugType>pdbonly</DebugType>\r
- <NoWarn>1699,1616,1699</NoWarn>\r
+ <NoWarn>1699,1616,1699,3021</NoWarn>\r
<Optimize>true</Optimize>\r
<DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM</DefineConstants>\r
<ErrorReport>prompt</ErrorReport>\r
</PropertyGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<ItemGroup>\r
+ <Compile Include="..\..\..\..\external\corefx\src\Common\src\System\HResults.cs" />\r
+ <Compile Include="..\..\..\..\external\corefx\src\System.Threading.Overlapped\src\System\Threading\ClrThreadPoolBoundHandle.cs" />\r
+ <Compile Include="..\..\..\..\external\corefx\src\System.Threading.Overlapped\src\System\Threading\ClrThreadPoolBoundHandleOverlapped.cs" />\r
+ <Compile Include="..\..\..\..\external\corefx\src\System.Threading.Overlapped\src\System\Threading\ClrThreadPoolPreAllocatedOverlapped.cs" />\r
+ <Compile Include="..\..\..\..\external\corefx\src\System.Threading.Overlapped\src\System\Threading\DeferredDisposableLifetime.cs" />\r
<Compile Include="AssemblyInfo.cs" />\r
- <Compile Include="ClrThreadPoolBoundHandle.cs" />\r
- <Compile Include="ClrThreadPoolBoundHandleOverlapped.cs" />\r
- <Compile Include="ClrThreadPoolPreAllocatedOverlapped.cs" />\r
- <Compile Include="DeferredDisposableLifetime.cs" />\r
- <Compile Include="HResults.cs" />\r
- <Compile Include="SR.cs" />\r
+ <Compile Include="corefx\SR.cs" />\r
<Compile Include="TypeForwarders.cs" />\r </ItemGroup>\r
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
Other similar extension points exist, see Microsoft.Common.targets.\r
</PropertyGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<ItemGroup>\r
+ <Compile Include="..\..\..\..\external\corefx\src\System.Xml.XPath.XDocument\src\System\Xml\XPath\XDocumentExtensions.cs" />\r
<Compile Include="AssemblyInfo.cs" />\r
- <Compile Include="TypeForwarders.cs" />\r
- <Compile Include="XDocumentExtensions.cs" />\r </ItemGroup>\r
+ <Compile Include="TypeForwarders.cs" />\r </ItemGroup>\r
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
Other similar extension points exist, see Microsoft.Common.targets.\r
<Target Name="BeforeBuild">\r
KEY_FILE = ../../msfinal.pub
SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699 /nowarn:618
-LIB_REFS = System System.Xml System.Xml.Linq System.Runtime.Serialization System.Core System.Numerics System.Net.Http \
+LIB_REFS = System System.Xml System.Xml.Linq System.Runtime.Serialization System.Core System.Numerics System.Net.Http System.Transactions \
System.IO.Compression System.Data System.ComponentModel.Composition System.IO.Compression.FileSystem \
Facades/System.Security.Cryptography.Algorithms
ifeq (2.1, $(FRAMEWORK_VERSION))
LIB_REFS += System.Web.Services
+else
+LIB_REFS += System.Web System.Drawing
endif
LIB_MCS_FLAGS = $(SIGN_FLAGS)
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.AppDomainUnloadedException))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.ApplicationException))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.ApplicationId))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.ArgIterator))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.ArgumentException))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.ArgumentNullException))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.ArgumentOutOfRangeException))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.RankException))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.ResolveEventArgs))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.ResolveEventHandler))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.RuntimeArgumentHandle))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.RuntimeFieldHandle))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.RuntimeMethodHandle))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.RuntimeTypeHandle))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Type))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.TypeAccessException))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.TypeCode))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.TypedReference))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.TypeInitializationException))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.TypeLoadException))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.TypeUnloadedException))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.ServicePointManager))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.SocketAddress))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.TransportContext))]
-[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.TransportType))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.UploadDataCompletedEventArgs))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.UploadDataCompletedEventHandler))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.UploadFileCompletedEventArgs))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Timers.ElapsedEventHandler))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Timers.Timer))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Timers.TimersDescriptionAttribute))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.CommittableTransaction))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.DependentCloneOption))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.DependentTransaction))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.Enlistment))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.EnlistmentOptions))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.EnterpriseServicesInteropOption))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.HostCurrentTransactionCallback))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.IDtcTransaction))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.IEnlistmentNotification))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.IPromotableSinglePhaseNotification))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.ISimpleTransactionSuperior))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.ISinglePhaseNotification))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.IsolationLevel))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.ITransactionPromoter))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.PreparingEnlistment))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.SinglePhaseEnlistment))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.SubordinateTransaction))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.Transaction))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionAbortedException))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionCompletedEventHandler))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionEventArgs))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionException))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionInDoubtException))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionInformation))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionInterop))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionManager))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionManagerCommunicationException))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionOptions))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionPromotionException))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionScope))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionScopeAsyncFlowOption))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionScopeOption))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionStartedEventHandler))]
+[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Transactions.TransactionStatus))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Web.HttpUtility))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Windows.Input.ICommand))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Xml.ConformanceLevel))]
System.Linq.Expressions System.Dynamic.Runtime System.Linq System.Threading.Tasks.Parallel System.Xml.ReaderWriter \
System.Diagnostics.Tools System.Reflection.Primitives System.Runtime.Extensions System.Runtime.InteropServices System.Text.Encoding.Extensions \
System.Runtime.Numerics System.Xml.XDocument System.Reflection.Extensions System.IO.FileSystem.Primitives System.IO.FileSystem \
-System.Diagnostics.FileVersionInfo System.Security.Cryptography.Primitives System.Security.Cryptography.Algorithms System.ValueTuple
+System.Diagnostics.FileVersionInfo System.Security.Cryptography.Primitives System.Security.Cryptography.Algorithms System.ValueTuple \
+System.Text.Encoding.CodePages
build_PARALLEL_SUBDIRS = $(basic_PARALLEL_SUBDIRS)
winaot_PARALLEL_SUBDIRS :=
+orbis_PARALLEL_SUBDIRS :=
+
mobile_only_SUBDIRS = System.Net.Ping System.Runtime.Serialization.Formatters System.Security.Cryptography.Csp System.Security.Cryptography.Pkcs \
System.Security.Cryptography.Cng
System.Numerics \
System.Xml.Linq \
System.Runtime.InteropServices.RuntimeInformation \
+ System.IO.Compression \
Mono.Cecil \
Mono.CompilerServices.SymbolWriter \
PEAPI \
xbuild_12_SUBDIRS := $(xbuild_4_0_dirs)
xbuild_14_SUBDIRS := $(xbuild_4_0_dirs) Microsoft.NuGet.Build.Tasks
winaot_SUBDIRS := $(winaot_dirs)
+orbis_SUBDIRS := $(monotouch_dirs)
include ../build/rules.make
Facades/System.IO.dll Facades/System.Runtime.InteropServices.dll Facades/System.Xml.ReaderWriter.dll Facades/System.Linq.Expressions.dll \
Facades/System.Runtime.Numerics.dll Facades/System.Xml.XDocument.dll Facades/System.IO.FileSystem.Primitives.dll Facades/System.IO.FileSystem.dll \
Facades/System.Diagnostics.FileVersionInfo.dll Facades/System.Security.Cryptography.Primitives.dll Facades/System.Security.Cryptography.Algorithms.dll \
- Facades/System.ValueTuple.dll
+ Facades/System.ValueTuple.dll Facades/System.Text.Encoding.CodePages.dll
monolite_files = $(build_files:%=lib/$(monolite_dir)/%)
if (Bag ["CodePage"] != null)
commandLine.AppendSwitchIfNotNull ("/codepage:", CodePage.ToString ());
- var dtype = DebugType;
- if (string.Equals (dtype, "full", StringComparison.OrdinalIgnoreCase) || string.Equals (dtype, "pdbonly", StringComparison.OrdinalIgnoreCase))
- dtype = "portable";
-
- commandLine.AppendSwitchIfNotNull ("/debug:", dtype);
+ commandLine.AppendSwitchIfNotNull ("/debug:", DebugType);
if (Bag ["DelaySign"] != null)
if (DelaySign)
#if XBUILD_14
Version46,
Version461,
+ Version462,
#endif
#if XBUILD_14
- VersionLatest = Version461
+ VersionLatest = Version462
#elif XBUILD_12
VersionLatest = Version451
#else
Path.Combine (lib_mono_dir, "net_4_x"), // Version451
Path.Combine (lib_mono_dir, "net_4_x"), // Version46
Path.Combine (lib_mono_dir, "net_4_x"), // Version461
+ Path.Combine (lib_mono_dir, "net_4_x"), // Version462
};
} else if (runningOnDotNet) {
mono_dir = new string [] {
Path.Combine (lib_mono_dir, "v4.0.30319"), // Version451
Path.Combine (lib_mono_dir, "v4.0.30319"), // Version46
Path.Combine (lib_mono_dir, "v4.0.30319"), // Version461
+ Path.Combine (lib_mono_dir, "v4.0.30319"), // Version462
};
} else {
mono_dir = new string [] {
Path.Combine (lib_mono_dir, "4.5"), // Version451
Path.Combine (lib_mono_dir, "4.5"), // Version46
Path.Combine (lib_mono_dir, "4.5"), // Version461
+ Path.Combine (lib_mono_dir, "4.5"), // Version462
};
}
[Test]
public void ExpandPropertyThenTrim ()
{
- string test = @"A
-B
-C
- ";
+ string test = "A\nB\nC\n ";
string project_xml = string.Format (@"<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<PropertyGroup>
<Test>{0}</Test>
--- /dev/null
+#include monotouch_Mono.CSharp.dll.sources
private void Emit (Expr originalExpr, Instruction inst)
{
- Instruction originalInst;
+ //Instruction originalInst;
if (this.instructionLookup != null) {
// TODO: Doesn't handle inherited contracts - need to check what to do in this case.
//if (this.instructionLookup.TryGetValue (originalExpr, out originalInst)) {
ModuleMirror main_module;
AssemblyName aname;
AssemblyDefinition meta;
+ AppDomainMirror domain;
Dictionary<string, long> typeCacheIgnoreCase = new Dictionary<string, long> (StringComparer.InvariantCultureIgnoreCase);
Dictionary<string, long> typeCache = new Dictionary<string, long> ();
}
}
+ // Since Protocol version 2.45
+ public AppDomainMirror Domain {
+ get {
+ if (domain == null) {
+ vm.CheckProtocolVersion (2, 45);
+ domain = vm.GetDomain (vm.conn.Assembly_GetIdDomain (id));
+ }
+ return domain;
+ }
+ }
+
public virtual AssemblyName GetName () {
if (aname == null) {
string name = vm.conn.Assembly_GetName (id);
struct SourceInfo {
public string source_file;
- public byte[] guid, hash;
+ public byte[] hash;
}
class DebugInfo {
* with newer runtimes, and vice versa.
*/
internal const int MAJOR_VERSION = 2;
- internal const int MINOR_VERSION = 44;
+ internal const int MINOR_VERSION = 45;
enum WPSuspendPolicy {
NONE = 0,
GET_MANIFEST_MODULE = 3,
GET_OBJECT = 4,
GET_TYPE = 5,
- GET_NAME = 6
+ GET_NAME = 6,
+ GET_DOMAIN = 7
}
enum CmdModule {
return SendReceive (CommandSet.ASSEMBLY, (int)CmdAssembly.GET_NAME, new PacketWriter ().WriteId (id)).ReadString ();
}
+ internal long Assembly_GetIdDomain (long id) {
+ return SendReceive (CommandSet.ASSEMBLY, (int)CmdAssembly.GET_DOMAIN, new PacketWriter ().WriteId (id)).ReadId ();
+ }
+
/*
* TYPE
*/
threadpool_io ();
return 0;
}
+ if (args.Length > 0 && args [0] == "attach") {
+ new Tests ().attach ();
+ return 0;
+ }
assembly_load ();
breakpoints ();
single_stepping ();
ss_recursive_chaotic ();
ss_fp_clobber ();
ss_no_frames ();
+ ss_await ();
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
ss_no_frames_3 ();
}
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public static void ss_await ()
+ {
+ ss_await_1 ().Wait ();//in
+ ss_await_1 ().Wait ();//over
+ ss_await_1 ().Wait ();//out before
+ ss_await_1 ().Wait ();//out after
+ ss_await_1_exc (true, true).Wait ();//in
+ ss_await_1_exc (true, true).Wait ();//over
+ ss_await_1_exc (true, true).Wait ();//out
+ try {
+ ss_await_1_exc (true, false).Wait ();//in
+ } catch { }
+ try {
+ ss_await_1_exc (true, false).Wait ();//over
+ } catch { }
+ try {
+ ss_await_1_exc (true, false).Wait ();//out
+ } catch { }
+ }
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public static async Task<int> ss_await_1 () {
+ var a = 1;
+ await Task.Delay (10);
+ return a + 2;
+ }
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public static async Task<int> ss_await_1_exc (bool exc, bool handled)
+ {
+ var a = 1;
+ await Task.Delay (10);
+ if (exc) {
+ if (handled) {
+ try {
+ throw new Exception ();
+ } catch {
+ }
+ } else {
+ throw new Exception ();
+ }
+ }
+ return a + 2;
+ }
+
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_no_frames_2 () {
}
streamOut.Close ();
var bsIn = t.Result;
}
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public void attach_break () {
+ }
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public void attach () {
+ AppDomain domain = AppDomain.CreateDomain ("domain");
+
+ CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
+ typeof (CrossDomain).Assembly.FullName, "CrossDomain");
+ o.assembly_load ();
+ o.type_load ();
+
+ // Wait for the client to attach
+ while (true) {
+ Thread.Sleep (200);
+ attach_break ();
+ }
+ }
}
public class SentinelClass : MarshalByRefObject {
public void assembly_load () {
Tests.assembly_load_in_domain ();
}
+
+ public void type_load () {
+ //Activator.CreateInstance (typeof (int).Assembly.GetType ("Microsoft.Win32.RegistryOptions"));
+ var is_server = System.Runtime.GCSettings.IsServerGC;
+ }
}
public class Foo
Start (false, args);
}
+ Diag.ProcessStartInfo CreateStartInfo (string[] args) {
+ var pi = new Diag.ProcessStartInfo ();
+
+ if (runtime != null) {
+ pi.FileName = runtime;
+ } else if (Path.DirectorySeparatorChar == '\\') {
+ string processExe = Diag.Process.GetCurrentProcess ().MainModule.FileName;
+ if (processExe != null) {
+ string fileName = Path.GetFileName (processExe);
+ if (fileName.StartsWith ("mono") && fileName.EndsWith (".exe"))
+ pi.FileName = processExe;
+ }
+ }
+ if (string.IsNullOrEmpty (pi.FileName))
+ pi.FileName = "mono";
+ pi.Arguments = String.Join (" ", args);
+ return pi;
+ }
+
void Start (bool forceExit, params string[] args) {
this.forceExit = forceExit;
if (!listening) {
- var pi = new Diag.ProcessStartInfo ();
-
- if (runtime != null) {
- pi.FileName = runtime;
- } else if (Path.DirectorySeparatorChar == '\\') {
- string processExe = Diag.Process.GetCurrentProcess ().MainModule.FileName;
- if (processExe != null) {
- string fileName = Path.GetFileName (processExe);
- if (fileName.StartsWith ("mono") && fileName.EndsWith (".exe"))
- pi.FileName = processExe;
- }
- }
- if (string.IsNullOrEmpty (pi.FileName))
- pi.FileName = "mono";
- pi.Arguments = String.Join (" ", args);
+ var pi = CreateStartInfo (args);
vm = VirtualMachineManager.Launch (pi, new LaunchOptions { AgentArgs = agent_args });
} else {
var ep = new IPEndPoint (IPAddress.Any, 10000);
f = e.Thread.GetFrames ()[0];
AssertValue (7.0, f.GetValue (f.Method.GetParameters ()[0]));
req.Disable ();
+
+ e = run_until ("ss_await");
+ e = step_in_await ("ss_await", e);//ss_await_1 ().Wait ();//in
+ e = step_in_await ("MoveNext", e);//{
+ e = step_in_await ("MoveNext", e);//var a = 1;
+ e = step_in_await ("MoveNext", e);//await Task.Delay (10);
+ e = step_in_await ("MoveNext", e);//return a + 2;
+ e = step_in_await ("MoveNext", e);//}
+ e = step_in_await ("ss_await", e);//ss_await_1 ().Wait ();//in
+
+ e = step_in_await ("ss_await", e);//ss_await_1 ().Wait ();//over
+ e = step_in_await ("MoveNext", e);//{
+ e = step_over_await ("MoveNext", e);//var a = 1;
+ e = step_over_await ("MoveNext", e);//await Task.Delay (10);
+ e = step_over_await ("MoveNext", e);//return a + 2;
+ e = step_over_await ("MoveNext", e);//}
+ e = step_over_await ("ss_await", e);//ss_await_1 ().Wait ();//over
+
+ e = step_in_await ("ss_await", e);//ss_await_1 ().Wait ();//out before
+ e = step_in_await ("MoveNext", e);//{
+ e = step_out_await ("ss_await", e);//ss_await_1 ().Wait ();//out before
+
+ e = step_in_await ("ss_await", e);//ss_await_1 ().Wait ();//out after
+ e = step_in_await ("MoveNext", e);//{
+ e = step_in_await ("MoveNext", e);//var a = 1;
+ e = step_in_await ("MoveNext", e);//await Task.Delay (10);
+ e = step_in_await ("MoveNext", e);//return a + 2;
+ e = step_out_await ("ss_await", e);//ss_await_1 ().Wait ();//out after
+
+ e = step_in_await ("ss_await", e);//ss_await_1_exc (true, true).Wait ();//in
+ e = step_in_await ("MoveNext", e);//{
+ e = step_in_await ("MoveNext", e);//var a = 1;
+ e = step_in_await ("MoveNext", e);//await Task.Delay (10);
+ e = step_in_await ("MoveNext", e);//if (exc)
+ e = step_in_await ("MoveNext", e);//{
+ e = step_in_await ("MoveNext", e);//if (handled)
+ e = step_in_await ("MoveNext", e);//{
+ e = step_in_await ("MoveNext", e);//try {
+ e = step_in_await ("MoveNext", e);//throw new Exception ();
+ e = step_in_await ("MoveNext", e);//catch
+ e = step_in_await ("MoveNext", e);//{
+ e = step_in_await ("MoveNext", e);//}
+ e = step_in_await ("MoveNext", e);//}
+ e = step_in_await ("MoveNext", e);//}
+ e = step_in_await ("MoveNext", e);//return a + 2;
+ e = step_in_await ("MoveNext", e);//}
+ e = step_in_await ("ss_await", e);//ss_await_1_exc (true, true).Wait ();//in
+
+ e = step_in_await ("ss_await", e);//ss_await_1_exc (true, true).Wait ();//over
+ e = step_in_await ("MoveNext", e);//{
+ e = step_over_await ("MoveNext", e);//var a = 1;
+ e = step_over_await ("MoveNext", e);//await Task.Delay (10);
+ e = step_over_await ("MoveNext", e);//if (exc)
+ e = step_over_await ("MoveNext", e);//{
+ e = step_over_await ("MoveNext", e);//if (handled)
+ e = step_over_await ("MoveNext", e);//{
+ e = step_over_await ("MoveNext", e);//try {
+ e = step_over_await ("MoveNext", e);//throw new Exception ();
+ e = step_over_await ("MoveNext", e);//catch
+ e = step_over_await ("MoveNext", e);//{
+ e = step_over_await ("MoveNext", e);//}
+ e = step_over_await ("MoveNext", e);//}
+ e = step_over_await ("MoveNext", e);//}
+ e = step_over_await ("MoveNext", e);//return a + 2;
+ e = step_over_await ("MoveNext", e);//}
+ e = step_over_await ("ss_await", e);//ss_await_1_exc (true, true).Wait ();//over
+
+ e = step_in_await ("ss_await", e);//ss_await_1_exc (true, true).Wait ();//out
+ e = step_in_await ("MoveNext", e);//{
+ e = step_out_await ("ss_await", e);//ss_await_1_exc (true, true).Wait ();//out
+
+ e = step_in_await ("ss_await", e);//try {
+ e = step_in_await ("ss_await", e);//ss_await_1_exc (true, false).Wait ();//in
+ e = step_in_await ("MoveNext", e);//{
+ e = step_in_await ("MoveNext", e);//var a = 1;
+ e = step_in_await ("MoveNext", e);//await Task.Delay (10);
+ e = step_in_await ("MoveNext", e);//if (exc)
+ e = step_in_await ("MoveNext", e);//{
+ e = step_in_await ("MoveNext", e);//if (handled)
+ e = step_in_await ("MoveNext", e);//} else {
+ e = step_in_await ("MoveNext", e);//throw new Exception ();
+ e = step_in_await ("ss_await", e);//catch
+ e = step_in_await ("ss_await", e);//{
+ e = step_in_await ("ss_await", e);//}
+ e = step_in_await ("ss_await", e);//try {
+
+ e = step_in_await ("ss_await", e);//ss_await_1_exc (true, false).Wait ();//over
+ e = step_in_await ("MoveNext", e);//{
+ e = step_over_await ("MoveNext", e);//var a = 1;
+ e = step_over_await ("MoveNext", e);//await Task.Delay (10);
+ e = step_over_await ("MoveNext", e);//if (exc)
+ e = step_over_await ("MoveNext", e);//{
+ e = step_over_await ("MoveNext", e);//if (handled)
+ e = step_over_await ("MoveNext", e);//} else {
+ e = step_over_await ("MoveNext", e);//throw new Exception ();
+ e = step_over_await ("ss_await", e);//catch
+ e = step_over_await ("ss_await", e);//{
+ e = step_over_await ("ss_await", e);//}
+ e = step_over_await ("ss_await", e);//try {
+
+ e = step_in_await ("ss_await", e);//ss_await_1_exc (true, false).Wait ();//out
+ e = step_in_await ("MoveNext", e);//{
+ e = step_out_await ("ss_await", e);//ss_await_1_exc (true, true).Wait ();//out
+ }
+
+ Event step_in_await (string method, Event e)
+ {
+ if (step_req != null)
+ step_req.Disable ();
+ create_step (e);
+ step_req.AssemblyFilter = new List<AssemblyMirror> () { entry_point.DeclaringType.Assembly };
+ var ef = step_into ();
+ assert_location (ef, method);
+ return ef;
+ }
+
+ Event step_over_await (string method, Event e)
+ {
+ if (step_req != null)
+ step_req.Disable ();
+ create_step (e);
+ step_req.AssemblyFilter = new List<AssemblyMirror> () { entry_point.DeclaringType.Assembly };
+ var ef = step_over ();
+ assert_location (ef, method);
+ return ef;
+ }
+
+ Event step_out_await (string method, Event e)
+ {
+ if (step_req != null)
+ step_req.Disable ();
+ create_step (e);
+ step_req.AssemblyFilter = new List<AssemblyMirror> () { entry_point.DeclaringType.Assembly };
+ var ef = step_out ();
+ assert_location (ef, method);
+ return ef;
}
[Test]
// d_method is from another domain
MethodMirror d_method = (e as BreakpointEvent).Method;
Assert.IsTrue (m != d_method);
+ Assert.AreEqual (domain, d_method.DeclaringType.Assembly.Domain);
var frames = e.Thread.GetFrames ();
Assert.AreEqual ("invoke_in_domain", frames [0].Method.Name);
vm.SetBreakpoint (cctor, 0);
vm.Resume ();
- var e = vm.GetNextEvent ();
+ var e = GetNextEvent ();
Assert.IsTrue (e is BreakpointEvent);
var req = create_step (e);
e = step_out (); // leave threadpool_bp
e = step_out (); // leave threadpool_io
}
+
+ [Test]
+ // Uses a fixed port
+ [Category("NotWorking")]
+ public void Attach () {
+ vm.Exit (0);
+
+ // Launch the app using server=y,suspend=n
+ var pi = CreateStartInfo (new string[] { "--debugger-agent=transport=dt_socket,address=127.0.0.1:10000,server=y,suspend=n", "dtest-app.exe", "attach" });
+ var process = Diag.Process.Start (pi);
+
+ // Wait for the app to reach the Sleep () in attach ().
+ Thread.Sleep (1000);
+ var ep = new IPEndPoint (IPAddress.Loopback, 10000);
+ vm = VirtualMachineManager.Connect (ep);
+
+ var load_req = vm.CreateAssemblyLoadRequest ();
+ load_req.Enable ();
+ vm.EnableEvents (EventType.TypeLoad);
+
+ Event vmstart = GetNextEvent ();
+ Assert.AreEqual (EventType.VMStart, vmstart.EventType);
+
+ // Get collected events
+ bool assembly_load_found = false;
+ bool type_load_found = false;
+ while (true) {
+ Event e = GetNextEvent ();
+
+ // AssemblyLoad
+ if (e is AssemblyLoadEvent) {
+ var assemblyload = e as AssemblyLoadEvent;
+
+ var amirror = assemblyload.Assembly;
+
+ if (amirror.GetName ().Name == "System.Transactions") {
+ assembly_load_found = true;
+ Assert.AreEqual ("domain", amirror.Domain.FriendlyName);
+ }
+
+ if (amirror.GetName ().Name == "dtest-app")
+ // Set a bp so we can break the event loop
+ vm.SetBreakpoint (amirror.EntryPoint.DeclaringType.GetMethod ("attach_break"), 0);
+ }
+ if (e is TypeLoadEvent) {
+ var typeload = e as TypeLoadEvent;
+
+ if (typeload.Type.Name == "GCSettings") {
+ type_load_found = true;
+ Assert.AreEqual ("domain", typeload.Type.Assembly.Domain.FriendlyName);
+ }
+ }
+
+ if (e is BreakpointEvent)
+ break;
+ }
+ Assert.IsTrue (assembly_load_found);
+ Assert.IsTrue (type_load_found);
+
+ vm.Exit (0);
+ vm = null;
+ }
+
}
}
public static Errno GetLastError ()
{
+ // Always call Marshal.GetLastWin32Error() before the OS check,
+ // even on Windows where we don't use the return value. If we do
+ // the OS check first Environment.OSVersion (if it happens to be
+ // the first ever access) will clobber Marshal.GetLastWin32Error()
+ // and we won't get the desired errno value on non-Windows platforms.
+ int errno = Marshal.GetLastWin32Error ();
if (Environment.OSVersion.Platform != PlatformID.Unix) {
// On Windows Marshal.GetLastWin32Error() doesn't take errno
// into account so we need to call Mono_Posix_Stdlib_GetLastError()
// which returns the value of errno in the C runtime
// libMonoPosixHelper.dll was linked against.
- return (Errno) _GetLastError ();
+ errno = _GetLastError ();
}
- return NativeConvert.ToErrno (Marshal.GetLastWin32Error ());
+ return NativeConvert.ToErrno (errno);
}
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
EntryPoint="Mono_Posix_Syscall_get_at_fdcwd")]
private static extern int get_at_fdcwd ();
- public static int AT_FDCWD { get { return get_at_fdcwd (); } }
+ public static readonly int AT_FDCWD = get_at_fdcwd ();
#endregion
[DllImport (MPH, EntryPoint="Mono_Posix_Syscall_L_ctermid")]
private static extern int _L_ctermid ();
- public static int L_ctermid { get { return _L_ctermid (); } }
+ public static readonly int L_ctermid = _L_ctermid ();
[DllImport (MPH, EntryPoint="Mono_Posix_Syscall_L_cuserid")]
private static extern int _L_cuserid ();
- public static int L_cuserid { get { return _L_cuserid (); } }
+ public static readonly int L_cuserid = _L_cuserid ();
internal static object getlogin_lock = new object ();
EntryPoint="Mono_Posix_Syscall_get_utime_omit")]
private static extern long get_utime_omit ();
- public static long UTIME_NOW { get { return get_utime_now (); } }
+ public static readonly long UTIME_NOW = get_utime_now ();
- public static long UTIME_OMIT { get { return get_utime_omit (); } }
+ public static readonly long UTIME_OMIT = get_utime_omit ();
[DllImport (MPH, SetLastError=true,
EntryPoint="Mono_Posix_Syscall_futimens")]
</PropertyGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<ItemGroup>\r
+ <Compile Include="..\..\build\common\AssemblyRef.cs" />\r
<Compile Include="..\..\build\common\Consts.cs" />\r
<Compile Include="..\..\build\common\Locale.cs" />\r
<Compile Include=".\Assembly\AssemblyInfo.cs" />\r
get; set;
}
+ internal string[] CertificateSearchPaths {
+ get; set;
+ }
+
/*
* If you set this here, then it will override 'ServicePointManager.SecurityProtocol'.
*/
UserSettings = other.UserSettings;
EnabledProtocols = other.EnabledProtocols;
EnabledCiphers = other.EnabledCiphers;
- TrustAnchors = other.TrustAnchors;
+ if (other.TrustAnchors != null)
+ TrustAnchors = new X509CertificateCollection (other.TrustAnchors);
+ if (other.CertificateSearchPaths != null) {
+ CertificateSearchPaths = new string [other.CertificateSearchPaths.Length];
+ other.CertificateSearchPaths.CopyTo (CertificateSearchPaths, 0);
+ }
+
cloned = true;
}
private static readonly string dllHintNameTable = "\0\0_CorDllMain\0";
private static readonly string runtimeEngineName = "mscoree.dll\0\0";
- private Section text, sdata, rsrc;
+ private Section text, sdata;
+ static readonly Section rsrc = null;
ArrayList data;
BinaryWriter reloc = new BinaryWriter(new MemoryStream());
uint dateStamp = 0;
LIBRARY = System.Core.dll
+ifeq ($(PROFILE),build)
+CSC_RUNTIME_FLAGS=--profile=aot:output=$(topdir)/class/lib/$(PROFILE)/csc.$(LIBRARY).aotprofile
+endif
+
REFERENCE_SOURCES_FLAGS = -d:FEATURE_PAL,PFX_LEGACY_3_5,FEATURE_NETCORE
LIB_REFS = System
LIB_MCS_FLAGS = $(REFERENCE_SOURCES_FLAGS) -d:INSIDE_SYSCORE -d:LIBC -unsafe -nowarn:436
<ItemGroup>\r
<Compile Include="..\..\..\external\corefx\src\Common\src\System\Collections\Generic\ArrayBuilder.cs" />\r
<Compile Include="..\..\..\external\corefx\src\Common\src\System\Collections\Generic\EnumerableHelpers.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\Common\src\System\Collections\Generic\EnumerableHelpers.Linq.cs" />\r
<Compile Include="..\..\..\external\corefx\src\Common\src\System\Collections\Generic\LargeArrayBuilder.cs" />\r
<Compile Include="..\..\..\external\corefx\src\Common\src\System\Collections\Generic\ReferenceEqualityComparer.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\Common\src\System\Collections\Generic\SparseArrayBuilder.cs" />\r
<Compile Include="..\..\..\external\corefx\src\Common\src\System\Dynamic\Utils\CacheDict.cs" />\r
<Compile Include="..\..\..\external\corefx\src\Common\src\System\Dynamic\Utils\ContractUtils.cs" />\r
<Compile Include="..\..\..\external\corefx\src\Common\src\System\Dynamic\Utils\ContractUtils.RequiresArrayRange.cs" />\r
<Compile Include="..\..\..\external\corefx\src\System.Linq.Expressions\src\System\Linq\Expressions\Compiler\CompilerScope.cs" />\r
<Compile Include="..\..\..\external\corefx\src\System.Linq.Expressions\src\System\Linq\Expressions\Compiler\CompilerScope.Storage.cs" />\r
<Compile Include="..\..\..\external\corefx\src\System.Linq.Expressions\src\System\Linq\Expressions\Compiler\DelegateHelpers.Generated.cs" />\r
- <Compile Include="..\..\..\external\corefx\src\System.Linq.Expressions\src\System\Linq\Expressions\Compiler\DelegateHelpers.netstandard1.7.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Linq.Expressions\src\System\Linq\Expressions\Compiler\DelegateHelpers.netstandard.cs" />\r
<Compile Include="..\..\..\external\corefx\src\System.Linq.Expressions\src\System\Linq\Expressions\Compiler\HoistedLocals.cs" />\r
<Compile Include="..\..\..\external\corefx\src\System.Linq.Expressions\src\System\Linq\Expressions\Compiler\ILGen.cs" />\r
<Compile Include="..\..\..\external\corefx\src\System.Linq.Expressions\src\System\Linq\Expressions\Compiler\KeyedQueue.cs" />\r
../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Common/ArrayBuilderExtensions.cs
../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Common/ConstantCheck.cs
../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/DelegateHelpers.Generated.cs
-../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/DelegateHelpers.netstandard1.7.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/DelegateHelpers.netstandard.cs
../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/HoistedLocals.cs
../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/TypeInfoExtensions.cs
../../../external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSite.cs
../../../external/corefx/src/Common/src/System/Collections/Generic/ArrayBuilder.cs
../../../external/corefx/src/Common/src/System/Collections/Generic/EnumerableHelpers.cs
+../../../external/corefx/src/Common/src/System/Collections/Generic/EnumerableHelpers.Linq.cs
../../../external/corefx/src/Common/src/System/Collections/Generic/LargeArrayBuilder.cs
+../../../external/corefx/src/Common/src/System/Collections/Generic/SparseArrayBuilder.cs
../../../external/corefx/src/Common/src/System/Dynamic/Utils/CacheDict.cs
../../../external/corefx/src/Common/src/System/Dynamic/Utils/ContractUtils.cs
public const string PropertyDoesNotHaveSetter = "The property '{0}' has no 'set' accessor";
public const string PropertyDoesNotHaveAccessor = "The property '{0}' has no 'get' or 'set' accessors";
public const string NotAMemberOfType = "'{0}' is not a member of type '{1}'";
+ public const string NotAMemberOfAnyType = "'{0}' is not a member of any type";
public const string ExpressionNotSupportedForType = "The expression '{0}' is not supported for type '{1}'";
public const string UnsupportedExpressionType = "The expression type '{0}' is not supported";
public const string ParameterExpressionNotValidAsDelegate = "ParameterExpression of type '{0}' cannot be used for delegate parameter of type '{1}'";
--- /dev/null
+#include testing_aot_full_System.Core.dll.sources
LIB_REFS = System System.Xml System.Core System.Numerics
LIB_MCS_FLAGS = \
-nowarn:219,414,649 \
+ -d:COREFX \
-d:PLATFORM_UNIX \
-d:USEOFFSET \
-d:MONO_PARTIAL_DATA_IMPORT \
Test/test-config-file \
Test/System.Data/binserialize/*.bin \
SqliteTest.db \
- referencesource.sources
+ corefx.common.sources
gen_OdbcConnection.cs: ../referencesource/System.Data/System/Data/ProviderBase/DbConnectionHelper.cs
sed -e "s/NAMESPACE/System.Data.Odbc/g" $< |\
<DebugType>full</DebugType>\r
<NoWarn>1699,219,414,649</NoWarn>\r
<Optimize>false</Optimize>\r
- <DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;PLATFORM_UNIX;USEOFFSET;MONO_PARTIAL_DATA_IMPORT</DefineConstants>\r
+ <DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;COREFX;PLATFORM_UNIX;USEOFFSET;MONO_PARTIAL_DATA_IMPORT</DefineConstants>\r
<ErrorReport>prompt</ErrorReport>\r
<WarningLevel>4</WarningLevel>\r
</PropertyGroup>\r
<DebugType>pdbonly</DebugType>\r
<NoWarn>1699,219,414,649</NoWarn>\r
<Optimize>true</Optimize>\r
- <DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;PLATFORM_UNIX;USEOFFSET;MONO_PARTIAL_DATA_IMPORT</DefineConstants>\r
+ <DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;COREFX;PLATFORM_UNIX;USEOFFSET;MONO_PARTIAL_DATA_IMPORT</DefineConstants>\r
<ErrorReport>prompt</ErrorReport>\r
<WarningLevel>4</WarningLevel>\r
</PropertyGroup>\r
</PropertyGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<ItemGroup>\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\AcceptRejectRule.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\AggregateType.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\BaseCollection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\CatalogLocation.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\ColumnTypeConverter.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\CommandBehavior.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\CommandType.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\AdapterSwitches.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\BigIntegerStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\BooleanStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\ByteStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\CharStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DataAdapter.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DataColumnMapping.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DataColumnMappingCollection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DataCommonEventSource.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DataRecordInternal.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DataStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DataTableMapping.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DataTableMappingCollection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DateTimeOffsetStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DateTimeStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbColumn.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbCommand.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DBCommandBuilder.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbConnection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbDataAdapter.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbDataRecord.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbDataSourceEnumerator.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbEnumerator.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbException.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbMetaDataCollectionNames.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbMetaDataColumnNames.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbParameter.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbParameterCollection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbProviderSpecificTypePropertyAttribute.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DBSchemaRow.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DBSchemaTable.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DbTransaction.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DecimalStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\DoubleStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\Groupbybehavior.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\IDbColumnSchemaGenerator.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\identifiercase.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\Int16Storage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\Int32Storage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\Int64Storage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\ObjectStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\RowUpdatedEventArgs.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\RowUpdatingEventArgs.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SByteStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SchemaTableColumn.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SchemaTableOptionalColumn.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SingleStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLConvert.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLTypes\SQLBinaryStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLTypes\SQlBooleanStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLTypes\SQLBytesStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLTypes\SQLByteStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLTypes\SQLCharsStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLTypes\SQLDateTimeStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLTypes\SQLDecimalStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLTypes\SQLDoubleStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLTypes\SQLGuidStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLTypes\SQLInt16Storage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLTypes\SQLInt32Storage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLTypes\SQLInt64Storage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLTypes\SQLMoneyStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLTypes\SQLSingleStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SQLTypes\SQLStringStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SqlUDTStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\StringStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\SupportedJoinOperators.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\TimeSpanStorage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\UInt16Storage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\UInt32Storage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Common\UInt64Storage.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\ConflictOptions.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\ConnectionState.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Constraint.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\ConstraintCollection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\ConstraintConverter.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\ConstraintEnumerator.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataColumn.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataColumnChangeEvent.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataColumnChangeEventHandler.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataColumnCollection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataColumnPropertyDescriptor.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataError.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataException.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataKey.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataRelation.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataRelationCollection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataRelationPropertyDescriptor.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataRow.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataRowAction.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataRowChangeEvent.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataRowChangeEventHandler.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataRowCollection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataRowCreatedEventHandler.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataRowState.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataRowVersion.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataRowView.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataSerializationFormat.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataSet.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataSetDateTime.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataSysAttribute.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataTable.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataTableClearEvent.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataTableClearEventHandler.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataTableCollection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataTableNewRowEvent.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataTableNewRowEventHandler.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataTablePropertyDescriptor.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataTableReader.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataTableReaderListener.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataTableTypeConverter.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataView.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataViewListener.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataViewManager.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataViewManagerListItemTypeDescriptor.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataViewRowState.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataViewSetting.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DataViewSettingCollection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DBConcurrencyException.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DbType.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\DefaultValueTypeConverter.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\FillErrorEventArgs.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\FillErrorEventHandler.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Filter\AggregateNode.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Filter\BinaryNode.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Filter\ConstNode.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Filter\DataExpression.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Filter\ExpressionNode.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Filter\ExpressionParser.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Filter\FilterException.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Filter\FunctionNode.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Filter\IFilter.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Filter\LookupNode.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Filter\NameNode.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Filter\Operators.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Filter\UnaryNode.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Filter\ZeroOpNode.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\ForeignKeyConstraint.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\IColumnMapping.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\IColumnMappingCollection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\IDataAdapter.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\IDataParameter.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\IDataParameterCollection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\IDataReader.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\IDataRecord.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\IDbCommand.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\IDbConnection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\IDbDataAdapter.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\IDbDataParameter.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\IDbTransaction.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\IsolationLevel.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\ITableMapping.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\ITableMappingCollection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\KeyRestrictionBehavior.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\LoadOption.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\MappingType.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\MergeFailedEvent.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\MergeFailedEventHandler.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Merger.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\MissingMappingAction.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\MissingSchemaAction.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\ParameterDirection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\PrimaryKeyTypeConverter.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\PropertyCollection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\ProviderBase\DataReaderContainer.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\ProviderBase\SchemaMapping.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Range.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\RbTree.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\RecordManager.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\RelatedView.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\RelationshipConverter.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Rule.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SchemaSerializationMode.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SchemaType.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Select.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\Selection.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SimpleType.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SqlDbType.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\INullable.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLBinary.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLBoolean.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLByte.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLBytes.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLChars.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SqlCharStream.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLDateTime.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLDecimal.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLDouble.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLGuid.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLInt16.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLInt32.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLInt64.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLMoney.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLResource.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLSingle.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLString.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SQLUtility.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\SQLTypes\SqlXml.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\StateChangeEvent.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\StateChangeEventHandler.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\StatementCompletedEventArgs.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\StatementCompletedEventHandler.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\StatementType.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\UniqueConstraint.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\UpdateRowSource.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\updatestatus.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\XDRSchema.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\XmlContent.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\XmlDataLoader.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\XMLDiffLoader.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\XmlKeywords.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\XmlReadMode.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\xmlsaver.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\XMLSchema.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\XmlToDatasetMap.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Data\XmlWriteMode.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Xml\BaseTreeIterator.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Xml\DataDocumentXPathNavigator.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Xml\DataPointer.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Xml\DataSetMappper.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Xml\IXmlDataVirtualNode.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Xml\RegionIterator.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Xml\TreeIterator.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Xml\XmlBoundElement.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Xml\XmlDataDocument.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Xml\XmlDataImplementation.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\System.Data.Common\src\System\Xml\XPathNodePointer.cs" />\r
<Compile Include="..\..\build\common\AssemblyRef.cs" />\r
<Compile Include="..\..\build\common\Consts.cs" />\r
<Compile Include="..\..\build\common\Locale.cs" />\r
<Compile Include="..\referencesource\System.Data\Misc\ExternDll.cs" />\r
<Compile Include="..\referencesource\System.Data\Misc\HResults.cs" />\r
<Compile Include="..\referencesource\System.Data\Misc\PrivilegedConfigurationManager.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\AcceptRejectRule.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\AggregateType.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\BaseCollection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\CatalogLocation.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\CodeGen\datacache.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\CodeGen\StrongTypingException.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\ColumnTypeConverter.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\CommandBehavior.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\CommandType.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\ActivityCorrelator.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\AdapterSwitches.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\AdapterUtil.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\BigIntegerStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\BooleanStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\ByteStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\CharStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DataAdapter.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DataColumnMapping.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DataColumnMappingCollection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DataRecordInternal.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DataStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DataTableMapping.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DataTableMappingCollection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DateTimeOffsetStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DateTimeStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DBCommand.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DBCommandBuilder.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DBConnection.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\DbConnectionOptions.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\DbConnectionPoolKey.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\DBConnectionString.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\DbConnectionStringBuilder.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\DbConnectionStringCommon.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DbDataAdapter.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\DBDataPermission.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\DBDataPermissionAttribute.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\DbDataReader.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\dbdatarecord.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DbDataSourceEnumerator.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\dbenumerator.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DbException.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DBParameter.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DbParameterCollection.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\DbProviderConfigurationHandler.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\DbProviderFactories.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\DbProviderFactoriesConfigurationHandler.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\DbProviderFactory.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DbProviderSpecificTypePropertyAttribute.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DBSchemaRow.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DBSchemaTable.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DbTransaction.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DecimalStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\DoubleStorage.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\FieldNameLookup.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\GreenMethods.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\Groupbybehavior.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\HandlerBase.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\identifiercase.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\Int16Storage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\Int32Storage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\Int64Storage.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\MultipartIdentifier.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\NameValuePair.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\NameValuePermission.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\NativeMethods.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\ObjectStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\RowUpdatedEventArgs.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\RowUpdatingEventArgs.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\SafeNativeMethods.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SByteStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SchemaTableColumn.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SchemaTableOptionalColumn.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SingleStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLConvert.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SQLBinaryStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SQlBooleanStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SQLBytesStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SQLByteStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SQLCharsStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SQLDateTimeStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SQLDecimalStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SQLDoubleStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SQLGuidStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SQLInt16Storage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SQLInt32Storage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SQLInt64Storage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SQLMoneyStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SQLSingleStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SQLStringStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SqlUDTStorage.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\SQLTypes\SqlXmlStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\StringStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\SupportedJoinOperators.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\System.Data_BID.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\TimeSpanStorage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\UInt16Storage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\UInt32Storage.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Common\UInt64Storage.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Common\UnsafeNativeMethods.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\ConflictOptions.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\ConnectionState.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Constraint.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\ConstraintCollection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\ConstraintConverter.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\ConstraintEnumerator.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataColumn.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataColumnChangeEvent.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataColumnChangeEventHandler.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataColumnCollection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataColumnPropertyDescriptor.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataError.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataException.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataKey.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataRelation.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataRelationCollection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataRelationPropertyDescriptor.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataRow.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataRowAction.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataRowChangeEvent.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataRowChangeEventHandler.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataRowCollection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataRowCreatedEventHandler.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataRowState.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataRowVersion.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataRowView.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataSerializationFormat.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\DataSet.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataSetDateTime.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataSysAttribute.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataTable.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataTableClearEvent.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataTableClearEventHandler.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataTableCollection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataTableNewRowEvent.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataTableNewRowEventHandler.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataTablePropertyDescriptor.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataTableReader.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataTableReaderListener.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataTableTypeConverter.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataView.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataViewListener.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataViewManager.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataViewManagerListItemTypeDescriptor.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataViewRowState.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataViewSetting.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DataViewSettingCollection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DBConcurrencyException.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\dbtype.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\DefaultValueTypeConverter.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\FillErrorEventArgs.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\FillErrorEventHandler.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Filter\AggregateNode.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Filter\BinaryNode.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Filter\ConstNode.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Filter\DataExpression.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Filter\ExpressionNode.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Filter\ExpressionParser.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Filter\FilterException.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Filter\FunctionNode.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Filter\IFilter.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Filter\LookupNode.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Filter\NameNode.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Filter\Operators.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Filter\UnaryNode.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Filter\ZeroOpNode.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\ForeignKeyConstraint.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\IColumnMapping.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\IColumnMappingCollection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\IDataAdapter.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\IDataParameter.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\IDataParameterCollection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\IDataReader.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\IDataRecord.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\IDbCommand.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\IDbConnection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\IDbDataAdapter.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\IDbDataParameter.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\IDbTransaction.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\IsolationLevel.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\ITableMapping.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\ITableMappingCollection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\LoadOption.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\MappingType.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\MergeFailedEvent.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\MergeFailedEventHandler.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Merger.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\MissingMappingAction.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\MissingSchemaAction.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Odbc\DbDataRecord.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Odbc\Odbc32.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Odbc\OdbcCommand.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\OleDb\RowBinding.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\OleDb\SafeHandles.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\OperationAbortedException.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\ParameterDirection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\PrimaryKeyTypeConverter.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\PropertyCollection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\ProviderBase\DataReaderContainer.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\ProviderBase\DbBuffer.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\ProviderBase\DbConnectionClosed.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\ProviderBase\DbConnectionFactory.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\ProviderBase\DbConnectionPoolIdentity.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\ProviderBase\DbConnectionPoolOptions.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\ProviderBase\DbConnectionPoolProviderInfo.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\ProviderBase\DbMetaDataCollectionNames.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\ProviderBase\DbMetaDataColumnNames.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\ProviderBase\DbMetaDataFactory.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\ProviderBase\DbReferenceCollection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\ProviderBase\SchemaMapping.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\ProviderBase\TimeoutTimer.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\ProviderBase\WrappedIUnknown.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Range.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\RbTree.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\RecordManager.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\RecordsAffectedEventArgs.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\RecordsAffectedEventHandler.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\RelatedView.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\RelationshipConverter.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Rule.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SchemaSerializationMode.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SchemaType.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Select.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\Selection.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SimpleType.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Sql\IBinarySerialize.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Sql\invalidudtexception.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\Sql\SqlDataSourceEnumerator.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\SqlClient\SqlUtil.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\SqlClient\TdsEnums.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\SqlClient\TdsParserStaticMethods.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SqlDbType.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\INullable.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLBinary.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLBoolean.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLByte.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLBytes.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLChars.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SqlCharStream.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLDateTime.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLDecimal.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLDouble.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLGuid.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLInt16.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLInt32.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLInt64.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLMoney.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLResource.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLSingle.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLString.cs" />\r
<Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SqlTypesSchemaImporter.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SQLUtility.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\SQLTypes\SqlXml.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\StateChangeEvent.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\StateChangeEventHandler.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\StatementType.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\UniqueConstraint.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\UpdateRowSource.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\updatestatus.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\XDRSchema.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\XmlContent.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\XmlDataLoader.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\XMLDiffLoader.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\XmlKeywords.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\XmlReadMode.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\xmlsaver.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\XMLSchema.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\XmlToDatasetMap.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\Data\XmlWriteMode.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\NewXml\BaseTreeIterator.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\NewXml\DataDocumentXPathNavigator.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\NewXml\DataPointer.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\NewXml\DataSetMappper.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\NewXml\IXmlDataVirtualNode.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\NewXml\RegionIterator.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\NewXml\TreeIterator.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\NewXml\XmlBoundElement.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\NewXml\XmlDataDocument.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\NewXml\XmlDataImplementation.cs" />\r
- <Compile Include="..\referencesource\System.Data\System\NewXml\XPathNodePointer.cs" />\r
<Compile Include="Assembly\AssemblyInfo.cs" />\r
+ <Compile Include="corefx\SR.cs" />\r
<Compile Include="Microsoft.SqlServer.Server\SqlDataRecord.cs" />\r
<Compile Include="Microsoft.SqlServer.Server\SqlMetaData.cs" />\r
<Compile Include="ReferenceSources\NativeOledbWrapper.cs" />\r
--- /dev/null
+../../../external/corefx/src/System.Data.Common/src/System/Data/AcceptRejectRule.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/AggregateType.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/BaseCollection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/CatalogLocation.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/ColumnTypeConverter.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/CommandBehavior.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/CommandType.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/AdapterSwitches.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/BigIntegerStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/BooleanStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/ByteStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/CharStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DataAdapter.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DataColumnMapping.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DataColumnMappingCollection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DataCommonEventSource.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DataRecordInternal.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DataStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DataTableMapping.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DataTableMappingCollection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DateTimeOffsetStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DateTimeStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DbColumn.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DbCommand.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DBCommandBuilder.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DbConnection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DbDataAdapter.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DbDataRecord.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DbDataSourceEnumerator.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DbEnumerator.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DbException.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DbMetaDataCollectionNames.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DbMetaDataColumnNames.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DbParameter.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DbParameterCollection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DbProviderSpecificTypePropertyAttribute.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DBSchemaRow.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DBSchemaTable.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DbTransaction.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DecimalStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/DoubleStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/Groupbybehavior.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/IDbColumnSchemaGenerator.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/identifiercase.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/Int16Storage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/Int32Storage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/Int64Storage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/ObjectStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/RowUpdatedEventArgs.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/RowUpdatingEventArgs.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SByteStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SchemaTableColumn.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SchemaTableOptionalColumn.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SingleStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLConvert.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLTypes/SQLBinaryStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLTypes/SQlBooleanStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLTypes/SQLBytesStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLTypes/SQLByteStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLTypes/SQLCharsStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDateTimeStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDecimalStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDoubleStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLTypes/SQLGuidStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt16Storage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt32Storage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt64Storage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLTypes/SQLMoneyStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLTypes/SQLSingleStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SQLTypes/SQLStringStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SqlUDTStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/StringStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/SupportedJoinOperators.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/TimeSpanStorage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/UInt16Storage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/UInt32Storage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Common/UInt64Storage.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/ConflictOptions.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/ConnectionState.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Constraint.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/ConstraintCollection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/ConstraintConverter.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/ConstraintEnumerator.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataColumn.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataColumnChangeEvent.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataColumnChangeEventHandler.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataColumnCollection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataColumnPropertyDescriptor.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataError.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataException.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataKey.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataRelation.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataRelationCollection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataRelationPropertyDescriptor.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataRow.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataRowAction.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataRowChangeEvent.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataRowChangeEventHandler.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataRowCollection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataRowCreatedEventHandler.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataRowState.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataRowVersion.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataRowView.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataSerializationFormat.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataSet.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataSetDateTime.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataSysAttribute.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataTable.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataTableClearEvent.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataTableClearEventHandler.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataTableCollection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataTableNewRowEvent.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataTableNewRowEventHandler.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataTablePropertyDescriptor.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataTableReader.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataTableReaderListener.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataTableTypeConverter.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataView.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataViewListener.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataViewManager.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataViewManagerListItemTypeDescriptor.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataViewRowState.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataViewSetting.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DataViewSettingCollection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DBConcurrencyException.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DbType.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/DefaultValueTypeConverter.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/FillErrorEventArgs.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/FillErrorEventHandler.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Filter/AggregateNode.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Filter/BinaryNode.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Filter/ConstNode.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Filter/DataExpression.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Filter/ExpressionNode.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Filter/ExpressionParser.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Filter/FilterException.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Filter/FunctionNode.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Filter/IFilter.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Filter/LookupNode.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Filter/NameNode.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Filter/Operators.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Filter/UnaryNode.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Filter/ZeroOpNode.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/ForeignKeyConstraint.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/IColumnMapping.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/IColumnMappingCollection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/IDataAdapter.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/IDataParameter.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/IDataParameterCollection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/IDataReader.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/IDataRecord.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/IDbCommand.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/IDbConnection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/IDbDataAdapter.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/IDbDataParameter.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/IDbTransaction.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/IsolationLevel.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/ITableMapping.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/ITableMappingCollection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/KeyRestrictionBehavior.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/LoadOption.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/MappingType.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/MergeFailedEvent.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/MergeFailedEventHandler.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Merger.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/MissingMappingAction.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/MissingSchemaAction.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/ParameterDirection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/PrimaryKeyTypeConverter.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/PropertyCollection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/ProviderBase/DataReaderContainer.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/ProviderBase/SchemaMapping.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Range.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/RbTree.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/RecordManager.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/RelatedView.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/RelationshipConverter.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Rule.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SchemaSerializationMode.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SchemaType.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Select.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/Selection.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SimpleType.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SqlDbType.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/INullable.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLBinary.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLBoolean.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLByte.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLBytes.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLChars.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SqlCharStream.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLDateTime.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLDouble.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLGuid.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLInt16.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLInt32.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLInt64.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLMoney.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLResource.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLSingle.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLString.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SQLUtility.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/SQLTypes/SqlXml.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/StateChangeEvent.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/StateChangeEventHandler.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/StatementCompletedEventArgs.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/StatementCompletedEventHandler.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/StatementType.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/UniqueConstraint.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/UpdateRowSource.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/updatestatus.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/XDRSchema.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/XmlContent.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/XmlDataLoader.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/XMLDiffLoader.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/XmlKeywords.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/XmlReadMode.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/xmlsaver.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/XMLSchema.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/XmlToDatasetMap.cs
+../../../external/corefx/src/System.Data.Common/src/System/Data/XmlWriteMode.cs
+../../../external/corefx/src/System.Data.Common/src/System/Xml/BaseTreeIterator.cs
+../../../external/corefx/src/System.Data.Common/src/System/Xml/DataDocumentXPathNavigator.cs
+../../../external/corefx/src/System.Data.Common/src/System/Xml/DataPointer.cs
+../../../external/corefx/src/System.Data.Common/src/System/Xml/DataSetMappper.cs
+../../../external/corefx/src/System.Data.Common/src/System/Xml/IXmlDataVirtualNode.cs
+../../../external/corefx/src/System.Data.Common/src/System/Xml/RegionIterator.cs
+../../../external/corefx/src/System.Data.Common/src/System/Xml/TreeIterator.cs
+../../../external/corefx/src/System.Data.Common/src/System/Xml/XmlBoundElement.cs
+../../../external/corefx/src/System.Data.Common/src/System/Xml/XmlDataImplementation.cs
+../../../external/corefx/src/System.Data.Common/src/System/Xml/XPathNodePointer.cs
+../../../external/corefx/src/System.Data.Common/src/System/Xml/XmlDataDocument.cs
+
+../referencesource/System.Data/Microsoft/SqlServer/Server/SqlTriggerContext.cs
+../referencesource/System.Data/Misc/ExternDll.cs
+../referencesource/System.Data/Misc/HResults.cs
+../referencesource/System.Data/System/Data/CodeGen/StrongTypingException.cs
+../referencesource/System.Data/System/Data/Common/ActivityCorrelator.cs
+../referencesource/System.Data/System/Data/Common/AdapterUtil.cs
+../referencesource/System.Data/System/Data/Common/DbConnectionOptions.cs
+../referencesource/System.Data/System/Data/Common/DbConnectionPoolKey.cs
+../referencesource/System.Data/System/Data/Common/DBConnectionString.cs
+../referencesource/System.Data/System/Data/Common/DbConnectionStringBuilder.cs
+../referencesource/System.Data/System/Data/Common/DbConnectionStringCommon.cs
+../referencesource/System.Data/System/Data/Common/DBDataPermission.cs
+../referencesource/System.Data/System/Data/Common/DBDataPermissionAttribute.cs
+../referencesource/System.Data/System/Data/Common/DbDataReader.cs
+../referencesource/System.Data/System/Data/Common/DbProviderFactory.cs
+../referencesource/System.Data/System/Data/Common/FieldNameLookup.cs
+../referencesource/System.Data/System/Data/Common/GreenMethods.cs
+../referencesource/System.Data/System/Data/Common/MultipartIdentifier.cs
+../referencesource/System.Data/System/Data/Common/NameValuePair.cs
+../referencesource/System.Data/System/Data/Common/NameValuePermission.cs
+../referencesource/System.Data/System/Data/Common/SQLTypes/SqlXmlStorage.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbType.cs
+../referencesource/System.Data/System/Data/OleDb/PropertyAttributes.cs
+../referencesource/System.Data/System/Data/OperationAbortedException.cs
+../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolAuthenticationContext.cs
+../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolAuthenticationContextKey.cs
+../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolOptions.cs
+../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolProviderInfo.cs
+../referencesource/System.Data/System/Data/ProviderBase/DbMetaDataFactory.cs
+../referencesource/System.Data/System/Data/ProviderBase/DbReferenceCollection.cs
+../referencesource/System.Data/System/Data/ProviderBase/TimeoutTimer.cs
+../referencesource/System.Data/System/Data/ProviderBase/WrappedIUnknown.cs
+../referencesource/System.Data/System/Data/Sql/IBinarySerialize.cs
+../referencesource/System.Data/System/Data/Sql/invalidudtexception.cs
+../referencesource/System.Data/System/Data/Sql/SqlDataSourceEnumerator.cs
+../referencesource/System.Data/System/Data/Sql/SqlFacetAttribute.cs
+../referencesource/System.Data/System/Data/Sql/SqlFunctionAttribute.cs
+../referencesource/System.Data/System/Data/Sql/SqlGenericUtil.cs
+../referencesource/System.Data/System/Data/Sql/SqlMethodAttribute.cs
+../referencesource/System.Data/System/Data/Sql/SqlNotificationRequest.cs
+../referencesource/System.Data/System/Data/Sql/SqlProcedureAttribute.cs
+../referencesource/System.Data/System/Data/Sql/SqlTriggerAttribute.cs
+../referencesource/System.Data/System/Data/Sql/SqlUserDefinedAggregateAttribute.cs
+../referencesource/System.Data/System/Data/Sql/SqlUserDefinedTypeAttribute.cs
+../referencesource/System.Data/System/Data/Sql/TriggerAction.cs
+../referencesource/System.Data/System/Data/SqlClient/ApplicationIntent.cs
+../referencesource/System.Data/System/Data/SqlClient/LocalDBAPI.cs
+../referencesource/System.Data/System/Data/SqlClient/SqlClientEncryptionType.cs
+../referencesource/System.Data/System/Data/SqlClient/SqlClientPermission.cs
+../referencesource/System.Data/System/Data/SqlClient/SqlConnectionString.cs
+../referencesource/System.Data/System/Data/SqlClient/SqlConnectionStringBuilder.cs
+../referencesource/System.Data/System/Data/SqlClient/SqlError.cs
+../referencesource/System.Data/System/Data/SqlClient/SqlErrorCollection.cs
+../referencesource/System.Data/System/Data/SqlClient/SqlInfoMessageEvent.cs
+../referencesource/System.Data/System/Data/SqlClient/SqlUtil.cs
+../referencesource/System.Data/System/Data/SqlClient/TdsEnums.cs
+../referencesource/System.Data/System/Data/SqlClient/TdsParserStaticMethods.cs
+../referencesource/System.Data/System/Data/DataSet.cs
\ No newline at end of file
--- /dev/null
+//
+// This file was generated by resx2sr tool
+//
+
+partial class SR
+{
+ public const string ADP_CollectionIndexString = "An {0} with {1} '{2}' is not contained by this {3}.";
+ public const string ADP_CollectionInvalidType = "The {0} only accepts non-null {1} type objects, not {2} objects.";
+ public const string ADP_CollectionIsNotParent = "The {0} is already contained by another {1}.";
+ public const string ADP_CollectionNullValue = "The {0} only accepts non-null {1} type objects.";
+ public const string ADP_CollectionRemoveInvalidObject = "Attempted to remove an {0} that is not contained by this {1}.";
+ public const string ADP_CollectionUniqueValue = "The {0}.{1} is required to be unique, '{2}' already exists in the collection.";
+ public const string ADP_ConnectionStateMsg_Closed = "The connection's current state is closed.";
+ public const string ADP_ConnectionStateMsg_Connecting = "The connection's current state is connecting.";
+ public const string ADP_ConnectionStateMsg_Open = "The connection's current state is open.";
+ public const string ADP_ConnectionStateMsg_OpenExecuting = "The connection's current state is executing.";
+ public const string ADP_ConnectionStateMsg_OpenFetching = "The connection's current state is fetching.";
+ public const string ADP_ConnectionStateMsg = "The connection's current state: {0}.";
+ public const string ADP_ConnectionStringSyntax = "Format of the initialization string does not conform to specification starting at index {0}.";
+ public const string ADP_DataReaderClosed = "Invalid attempt to call {0} when reader is closed.";
+ public const string ADP_EmptyString = "Expecting non-empty string for '{0}' parameter.";
+ public const string ADP_InvalidEnumerationValue = "The {0} enumeration value, {1}, is invalid.";
+ public const string ADP_InvalidKey = "Invalid keyword, contain one or more of 'no characters', 'control characters', 'leading or trailing whitespace' or 'leading semicolons'.";
+ public const string ADP_InvalidValue = "The value contains embedded nulls (\\\\u0000).";
+ public const string ADP_InvalidXMLBadVersion = "Invalid Xml; can only parse elements of version one.";
+ public const string Xml_SimpleTypeNotSupported = "DataSet doesn't support 'union' or 'list' as simpleType.";
+ public const string Xml_MissingAttribute = "Invalid {0} syntax: missing required '{1}' attribute.";
+ public const string Xml_ValueOutOfRange = "Value '{1}' is invalid for attribute '{0}'.";
+ public const string Xml_AttributeValues = "The value of attribute '{0}' should be '{1}' or '{2}'.";
+ public const string Xml_RelationParentNameMissing = "Parent table name is missing in relation '{0}'.";
+ public const string Xml_RelationChildNameMissing = "Child table name is missing in relation '{0}'.";
+ public const string Xml_RelationTableKeyMissing = "Parent table key is missing in relation '{0}'.";
+ public const string Xml_RelationChildKeyMissing = "Child table key is missing in relation '{0}'.";
+ public const string Xml_UndefinedDatatype = "Undefined data type: '{0}'.";
+ public const string Xml_DatatypeNotDefined = "Data type not defined.";
+ public const string Xml_InvalidField = "Invalid XPath selection inside field node. Cannot find: {0}.";
+ public const string Xml_InvalidSelector = "Invalid XPath selection inside selector node: {0}.";
+ public const string Xml_InvalidKey = "Invalid 'Key' node inside constraint named: {0}.";
+ public const string Xml_DuplicateConstraint = "The constraint name {0} is already used in the schema.";
+ public const string Xml_CannotConvert = " Cannot convert '{0}' to type '{1}'.";
+ public const string Xml_MissingRefer = "Missing '{0}' part in '{1}' constraint named '{2}'.";
+ public const string Xml_MismatchKeyLength = "Invalid Relation definition: different length keys.";
+ public const string Xml_CircularComplexType = "DataSet doesn't allow the circular reference in the ComplexType named '{0}'.";
+ public const string Xml_CannotInstantiateAbstract = "DataSet cannot instantiate an abstract ComplexType for the node {0}.";
+ public const string Xml_MultipleTargetConverterError = "An error occurred with the multiple target converter while writing an Xml Schema. See the inner exception for details.";
+ public const string Xml_MultipleTargetConverterEmpty = "An error occurred with the multiple target converter while writing an Xml Schema. A null or empty string was returned.";
+ public const string Xml_MergeDuplicateDeclaration = "Duplicated declaration '{0}'.";
+ public const string Xml_MissingTable = "Cannot load diffGram. Table '{0}' is missing in the destination dataset.";
+ public const string Xml_MissingSQL = "Cannot load diffGram. The 'sql' node is missing.";
+ public const string Xml_ColumnConflict = "Column name '{0}' is defined for different mapping types.";
+ public const string Xml_InvalidPrefix = "Prefix '{0}' is not valid, because it contains special characters.";
+ public const string Xml_NestedCircular = "Circular reference in self-nested table '{0}'.";
+ public const string Xml_FoundEntity = "DataSet cannot expand entities. Use XmlValidatingReader and set the EntityHandling property accordingly.";
+ public const string Xml_PolymorphismNotSupported = "Type '{0}' does not implement IXmlSerializable interface therefore can not proceed with serialization.";
+ public const string Xml_CanNotDeserializeObjectType = "Unable to proceed with deserialization. Data does not implement IXMLSerializable, therefore polymorphism is not supported.";
+ public const string Xml_DataTableInferenceNotSupported = "DataTable does not support schema inference from Xml.";
+ public const string Xml_MultipleParentRows = "Cannot proceed with serializing DataTable '{0}'. It contains a DataRow which has multiple parent rows on the same Foreign Key.";
+ public const string Xml_IsDataSetAttributeMissingInSchema = "IsDataSet attribute is missing in input Schema.";
+ public const string Xml_TooManyIsDataSetAtributeInSchema = "Cannot determine the DataSet Element. IsDataSet attribute exist more than once.";
+ public const string Xml_DynamicWithoutXmlSerializable = "DataSet will not serialize types that implement IDynamicMetaObjectProvider but do not also implement IXmlSerializable.";
+ public const string Expr_NYI = "The feature not implemented. {0}.";
+ public const string Expr_MissingOperand = "Syntax error: Missing operand after '{0}' operator.";
+ public const string Expr_TypeMismatch = "Type mismatch in expression '{0}'.";
+ public const string Expr_ExpressionTooComplex = "Expression is too complex.";
+ public const string Expr_UnboundName = "Cannot find column [{0}].";
+ public const string Expr_InvalidString = "The expression contains an invalid string constant: {0}.";
+ public const string Expr_UndefinedFunction = "The expression contains undefined function call {0}().";
+ public const string Expr_Syntax = "Syntax error in the expression.";
+ public const string Expr_FunctionArgumentCount = "Invalid number of arguments: function {0}().";
+ public const string Expr_MissingRightParen = "The expression is missing the closing parenthesis.";
+ public const string Expr_UnknownToken = "Cannot interpret token '{0}' at position {1}.";
+ public const string Expr_UnknownToken1 = "Expected {0}, but actual token at the position {2} is {1}.";
+ public const string Expr_DatatypeConvertion = "Cannot convert from {0} to {1}.";
+ public const string Expr_DatavalueConvertion = "Cannot convert value '{0}' to Type: {1}.";
+ public const string Expr_InvalidName = "Invalid column name [{0}].";
+ public const string Expr_InvalidDate = "The expression contains invalid date constant '{0}'.";
+ public const string Expr_NonConstantArgument = "Only constant expressions are allowed in the expression list for the IN operator.";
+ public const string Expr_InvalidPattern = "Error in Like operator: the string pattern '{0}' is invalid.";
+ public const string Expr_InWithoutParentheses = "Syntax error: The items following the IN keyword must be separated by commas and be enclosed in parentheses.";
+ public const string Expr_ArgumentType = "Type mismatch in function argument: {0}(), argument {1}, expected {2}.";
+ public const string Expr_ArgumentTypeInteger = "Type mismatch in function argument: {0}(), argument {1}, expected one of the Integer types.";
+ public const string Expr_TypeMismatchInBinop = "Cannot perform '{0}' operation on {1} and {2}.";
+ public const string Expr_AmbiguousBinop = "Operator '{0}' is ambiguous on operands of type '{1}' and '{2}'. Cannot mix signed and unsigned types. Please use explicit Convert() function.";
+ public const string Expr_InWithoutList = "Syntax error: The IN keyword must be followed by a non-empty list of expressions separated by commas, and also must be enclosed in parentheses.";
+ public const string Expr_UnsupportedOperator = "The expression contains unsupported operator '{0}'.";
+ public const string Expr_InvalidNameBracketing = "The expression contains invalid name: '{0}'.";
+ public const string Expr_MissingOperandBefore = "Syntax error: Missing operand before '{0}' operator.";
+ public const string Expr_TooManyRightParentheses = "The expression has too many closing parentheses.";
+ public const string Expr_UnresolvedRelation = "The table [{0}] involved in more than one relation. You must explicitly mention a relation name in the expression '{1}'.";
+ public const string Expr_AggregateArgument = "Syntax error in aggregate argument: Expecting a single column argument with possible 'Child' qualifier.";
+ public const string Expr_AggregateUnbound = "Unbound reference in the aggregate expression '{0}'.";
+ public const string Expr_EvalNoContext = "Cannot evaluate non-constant expression without current row.";
+ public const string Expr_ExpressionUnbound = "Unbound reference in the expression '{0}'.";
+ public const string Expr_ComputeNotAggregate = "Cannot evaluate. Expression '{0}' is not an aggregate.";
+ public const string Expr_FilterConvertion = "Filter expression '{0}' does not evaluate to a Boolean term.";
+ public const string Expr_InvalidType = "Invalid type name '{0}'.";
+ public const string Expr_LookupArgument = "Syntax error in Lookup expression: Expecting keyword 'Parent' followed by a single column argument with possible relation qualifier: Parent[(<relation_name>)].<column_name>.";
+ public const string Expr_InvokeArgument = "Need a row or a table to Invoke DataFilter.";
+ public const string Expr_ArgumentOutofRange = "{0}() argument is out of range.";
+ public const string Expr_IsSyntax = "Syntax error: Invalid usage of 'Is' operator. Correct syntax: <expression> Is [Not] Null.";
+ public const string Expr_Overflow = "Value is either too large or too small for Type '{0}'.";
+ public const string Expr_BindFailure = "Cannot find the parent relation '{0}'.";
+ public const string Expr_InvalidHoursArgument = "'hours' argument is out of range. Value must be between -14 and +14.";
+ public const string Expr_InvalidMinutesArgument = "'minutes' argument is out of range. Value must be between -59 and +59.";
+ public const string Expr_InvalidTimeZoneRange = "Provided range for time one exceeds total of 14 hours.";
+ public const string Expr_MismatchKindandTimeSpan = "Kind property of provided DateTime argument, does not match 'hours' and 'minutes' arguments.";
+ public const string Expr_UnsupportedType = "A DataColumn of type '{0}' does not support expression.";
+ public const string Data_EnforceConstraints = "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.";
+ public const string Data_CannotModifyCollection = "Collection itself is not modifiable.";
+ public const string Data_CaseInsensitiveNameConflict = "The given name '{0}' matches at least two names in the collection object with different cases, but does not match either of them with the same case.";
+ public const string Data_NamespaceNameConflict = "The given name '{0}' matches at least two names in the collection object with different namespaces.";
+ public const string Data_InvalidOffsetLength = "Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.";
+ public const string Data_ArgumentOutOfRange = "'{0}' argument is out of range.";
+ public const string Data_ArgumentNull = "'{0}' argument cannot be null.";
+ public const string Data_ArgumentContainsNull = "'{0}' argument contains null value.";
+ public const string DataColumns_OutOfRange = "Cannot find column {0}.";
+ public const string DataColumns_Add1 = "Column '{0}' already belongs to this DataTable.";
+ public const string DataColumns_Add2 = "Column '{0}' already belongs to another DataTable.";
+ public const string DataColumns_Add3 = "Cannot have more than one SimpleContent columns in a DataTable.";
+ public const string DataColumns_Add4 = "Cannot add a SimpleContent column to a table containing element columns or nested relations.";
+ public const string DataColumns_AddDuplicate = "A column named '{0}' already belongs to this DataTable.";
+ public const string DataColumns_AddDuplicate2 = "Cannot add a column named '{0}': a nested table with the same name already belongs to this DataTable.";
+ public const string DataColumns_AddDuplicate3 = "A column named '{0}' already belongs to this DataTable: cannot set a nested table name to the same name.";
+ public const string DataColumns_Remove = "Cannot remove a column that doesn't belong to this table.";
+ public const string DataColumns_RemovePrimaryKey = "Cannot remove this column, because it's part of the primary key.";
+ public const string DataColumns_RemoveChildKey = "Cannot remove this column, because it is part of the parent key for relationship {0}.";
+ public const string DataColumns_RemoveConstraint = "Cannot remove this column, because it is a part of the constraint {0} on the table {1}.";
+ public const string DataColumn_AutoIncrementAndExpression = "Cannot set AutoIncrement property for a computed column.";
+ public const string DataColumn_AutoIncrementAndDefaultValue = "Cannot set AutoIncrement property for a column with DefaultValue set.";
+ public const string DataColumn_DefaultValueAndAutoIncrement = "Cannot set a DefaultValue on an AutoIncrement column.";
+ public const string DataColumn_AutoIncrementSeed = "AutoIncrementStep must be a non-zero value.";
+ public const string DataColumn_NameRequired = "ColumnName is required when it is part of a DataTable.";
+ public const string DataColumn_ChangeDataType = "Cannot change DataType of a column once it has data.";
+ public const string DataColumn_NullDataType = "Column requires a valid DataType.";
+ public const string DataColumn_DefaultValueDataType = "The DefaultValue for column {0} is of type {1} and cannot be converted to {2}.";
+ public const string DataColumn_DefaultValueDataType1 = "The DefaultValue for the column is of type {0} and cannot be converted to {1}.";
+ public const string DataColumn_DefaultValueColumnDataType = "The DefaultValue for column {0} is of type {1}, but the column is of type {2}.";
+ public const string DataColumn_ReadOnlyAndExpression = "Cannot change ReadOnly property for the expression column.";
+ public const string DataColumn_UniqueAndExpression = "Cannot change Unique property for the expression column.";
+ public const string DataColumn_ExpressionAndUnique = "Cannot create an expression on a column that has AutoIncrement or Unique.";
+ public const string DataColumn_ExpressionAndReadOnly = "Cannot set expression because column cannot be made ReadOnly.";
+ public const string DataColumn_ExpressionAndConstraint = "Cannot set Expression property on column {0}, because it is a part of a constraint.";
+ public const string DataColumn_ExpressionInConstraint = "Cannot create a constraint based on Expression column {0}.";
+ public const string DataColumn_ExpressionCircular = "Cannot set Expression property due to circular reference in the expression.";
+ public const string DataColumn_NullKeyValues = "Column '{0}' has null values in it.";
+ public const string DataColumn_NullValues = "Column '{0}' does not allow nulls.";
+ public const string DataColumn_ReadOnly = "Column '{0}' is read only.";
+ public const string DataColumn_NonUniqueValues = "Column '{0}' contains non-unique values.";
+ public const string DataColumn_NotInTheTable = "Column '{0}' does not belong to table {1}.";
+ public const string DataColumn_NotInAnyTable = "Column must belong to a table.";
+ public const string DataColumn_SetFailed = "Couldn't store <{0}> in {1} Column. Expected type is {2}.";
+ public const string DataColumn_CannotSetToNull = "Cannot set Column '{0}' to be null. Please use DBNull instead.";
+ public const string DataColumn_LongerThanMaxLength = "Cannot set column '{0}'. The value violates the MaxLength limit of this column.";
+ public const string DataColumn_HasToBeStringType = "MaxLength applies to string data type only. You cannot set Column '{0}' property MaxLength to be non-negative number.";
+ public const string DataColumn_CannotSetMaxLength = "Cannot set Column '{0}' property MaxLength to '{1}'. There is at least one string in the table longer than the new limit.";
+ public const string DataColumn_CannotSetMaxLength2 = "Cannot set Column '{0}' property MaxLength. The Column is SimpleContent.";
+ public const string DataColumn_CannotSimpleContentType = "Cannot set Column '{0}' property DataType to {1}. The Column is SimpleContent.";
+ public const string DataColumn_CannotSimpleContent = "Cannot set Column '{0}' property MappingType to SimpleContent. The Column DataType is {1}.";
+ public const string DataColumn_ExceedMaxLength = "Column '{0}' exceeds the MaxLength limit.";
+ public const string DataColumn_NotAllowDBNull = "Column '{0}' does not allow DBNull.Value.";
+ public const string DataColumn_CannotChangeNamespace = "Cannot change the Column '{0}' property Namespace. The Column is SimpleContent.";
+ public const string DataColumn_AutoIncrementCannotSetIfHasData = "Cannot change AutoIncrement of a DataColumn with type '{0}' once it has data.";
+ public const string DataColumn_NotInTheUnderlyingTable = "Column '{0}' does not belong to underlying table '{1}'.";
+ public const string DataColumn_InvalidDataColumnMapping = "DataColumn with type '{0}' is a complexType. Can not serialize value of a complex type as Attribute";
+ public const string DataColumn_CannotSetDateTimeModeForNonDateTimeColumns = "The DateTimeMode can be set only on DataColumns of type DateTime.";
+ public const string DataColumn_DateTimeMode = "Cannot change DateTimeMode from '{0}' to '{1}' once the table has data.";
+ public const string DataColumn_INullableUDTwithoutStaticNull = "Type '{0}' does not contain static Null property or field.";
+ public const string DataColumn_UDTImplementsIChangeTrackingButnotIRevertible = "Type '{0}' does not implement IRevertibleChangeTracking; therefore can not proceed with RejectChanges().";
+ public const string DataColumn_SetAddedAndModifiedCalledOnNonUnchanged = "SetAdded and SetModified can only be called on DataRows with Unchanged DataRowState.";
+ public const string DataColumn_OrdinalExceedMaximun = "Ordinal '{0}' exceeds the maximum number.";
+ public const string DataColumn_NullableTypesNotSupported = "DataSet does not support System.Nullable<>.";
+ public const string DataConstraint_NoName = "Cannot change the name of a constraint to empty string when it is in the ConstraintCollection.";
+ public const string DataConstraint_Violation = "Cannot enforce constraints on constraint {0}.";
+ public const string DataConstraint_ViolationValue = "Column '{0}' is constrained to be unique. Value '{1}' is already present.";
+ public const string DataConstraint_NotInTheTable = "Constraint '{0}' does not belong to this DataTable.";
+ public const string DataConstraint_OutOfRange = "Cannot find constraint {0}.";
+ public const string DataConstraint_Duplicate = "Constraint matches constraint named {0} already in collection.";
+ public const string DataConstraint_DuplicateName = "A Constraint named '{0}' already belongs to this DataTable.";
+ public const string DataConstraint_UniqueViolation = "These columns don't currently have unique values.";
+ public const string DataConstraint_ForeignTable = "These columns don't point to this table.";
+ public const string DataConstraint_ParentValues = "This constraint cannot be enabled as not all values have corresponding parent values.";
+ public const string DataConstraint_AddFailed = "This constraint cannot be added since ForeignKey doesn't belong to table {0}.";
+ public const string DataConstraint_RemoveFailed = "Cannot remove a constraint that doesn't belong to this table.";
+ public const string DataConstraint_NeededForForeignKeyConstraint = "Cannot remove unique constraint '{0}'. Remove foreign key constraint '{1}' first.";
+ public const string DataConstraint_CascadeDelete = "Cannot delete this row because constraints are enforced on relation {0}, and deleting this row will strand child rows.";
+ public const string DataConstraint_CascadeUpdate = "Cannot make this change because constraints are enforced on relation {0}, and changing this value will strand child rows.";
+ public const string DataConstraint_ClearParentTable = "Cannot clear table {0} because ForeignKeyConstraint {1} enforces constraints and there are child rows in {2}.";
+ public const string DataConstraint_ForeignKeyViolation = "ForeignKeyConstraint {0} requires the child key values ({1}) to exist in the parent table.";
+ public const string DataConstraint_BadObjectPropertyAccess = "Property not accessible because '{0}'.";
+ public const string DataConstraint_RemoveParentRow = "Cannot remove this row because it has child rows, and constraints on relation {0} are enforced.";
+ public const string DataConstraint_AddPrimaryKeyConstraint = "Cannot add primary key constraint since primary key is already set for the table.";
+ public const string DataConstraint_CantAddConstraintToMultipleNestedTable = "Cannot add constraint to DataTable '{0}' which is a child table in two nested relations.";
+ public const string DataKey_TableMismatch = "Cannot create a Key from Columns that belong to different tables.";
+ public const string DataKey_NoColumns = "Cannot have 0 columns.";
+ public const string DataKey_TooManyColumns = "Cannot have more than {0} columns.";
+ public const string DataKey_DuplicateColumns = "Cannot create a Key when the same column is listed more than once: '{0}'";
+ public const string DataKey_RemovePrimaryKey = "Cannot remove unique constraint since it's the primary key of a table.";
+ public const string DataKey_RemovePrimaryKey1 = "Cannot remove unique constraint since it's the primary key of table {0}.";
+ public const string DataRelation_ColumnsTypeMismatch = "Parent Columns and Child Columns don't have type-matching columns.";
+ public const string DataRelation_KeyColumnsIdentical = "ParentKey and ChildKey are identical.";
+ public const string DataRelation_KeyLengthMismatch = "ParentColumns and ChildColumns should be the same length.";
+ public const string DataRelation_KeyZeroLength = "ParentColumns and ChildColumns must not be zero length.";
+ public const string DataRelation_ForeignRow = "The row doesn't belong to the same DataSet as this relation.";
+ public const string DataRelation_NoName = "RelationName is required when it is part of a DataSet.";
+ public const string DataRelation_ForeignTable = "GetChildRows requires a row whose Table is {0}, but the specified row's Table is {1}.";
+ public const string DataRelation_ForeignDataSet = "This relation should connect two tables in this DataSet to be added to this DataSet.";
+ public const string DataRelation_GetParentRowTableMismatch = "GetParentRow requires a row whose Table is {0}, but the specified row's Table is {1}.";
+ public const string DataRelation_SetParentRowTableMismatch = "SetParentRow requires a child row whose Table is {0}, but the specified row's Table is {1}.";
+ public const string DataRelation_DataSetMismatch = "Cannot have a relationship between tables in different DataSets.";
+ public const string DataRelation_TablesInDifferentSets = "Cannot create a relation between tables in different DataSets.";
+ public const string DataRelation_AlreadyExists = "A relation already exists for these child columns.";
+ public const string DataRelation_DoesNotExist = "This relation doesn't belong to this relation collection.";
+ public const string DataRelation_AlreadyInOtherDataSet = "This relation already belongs to another DataSet.";
+ public const string DataRelation_AlreadyInTheDataSet = "This relation already belongs to this DataSet.";
+ public const string DataRelation_DuplicateName = "A Relation named '{0}' already belongs to this DataSet.";
+ public const string DataRelation_NotInTheDataSet = "Relation {0} does not belong to this DataSet.";
+ public const string DataRelation_OutOfRange = "Cannot find relation {0}.";
+ public const string DataRelation_TableNull = "Cannot create a collection on a null table.";
+ public const string DataRelation_TableWasRemoved = "The table this collection displays relations for has been removed from its DataSet.";
+ public const string DataRelation_ChildTableMismatch = "Cannot add a relation to this table's ParentRelation collection where this table isn't the child table.";
+ public const string DataRelation_ParentTableMismatch = "Cannot add a relation to this table's ChildRelation collection where this table isn't the parent table.";
+ public const string DataRelation_RelationNestedReadOnly = "Cannot set the 'Nested' property to false for this relation.";
+ public const string DataRelation_TableCantBeNestedInTwoTables = "The same table '{0}' cannot be the child table in two nested relations.";
+ public const string DataRelation_LoopInNestedRelations = "The table ({0}) cannot be the child table to itself in nested relations.";
+ public const string DataRelation_CaseLocaleMismatch = "Cannot add a DataRelation or Constraint that has different Locale or CaseSensitive settings between its parent and child tables.";
+ public const string DataRelation_ParentOrChildColumnsDoNotHaveDataSet = "Cannot create a DataRelation if Parent or Child Columns are not in a DataSet.";
+ public const string DataRelation_InValidNestedRelation = "Nested table '{0}' which inherits its namespace cannot have multiple parent tables in different namespaces.";
+ public const string DataRelation_InValidNamespaceInNestedRelation = "Nested table '{0}' with empty namespace cannot have multiple parent tables in different namespaces.";
+ public const string DataRow_NotInTheDataSet = "The row doesn't belong to the same DataSet as this relation.";
+ public const string DataRow_NotInTheTable = "Cannot perform this operation on a row not in the table.";
+ public const string DataRow_ParentRowNotInTheDataSet = "This relation and child row don't belong to same DataSet.";
+ public const string DataRow_EditInRowChanging = "Cannot change a proposed value in the RowChanging event.";
+ public const string DataRow_EndEditInRowChanging = "Cannot call EndEdit() inside an OnRowChanging event.";
+ public const string DataRow_BeginEditInRowChanging = "Cannot call BeginEdit() inside the RowChanging event.";
+ public const string DataRow_CancelEditInRowChanging = "Cannot call CancelEdit() inside an OnRowChanging event. Throw an exception to cancel this update.";
+ public const string DataRow_DeleteInRowDeleting = "Cannot call Delete inside an OnRowDeleting event. Throw an exception to cancel this delete.";
+ public const string DataRow_ValuesArrayLength = "Input array is longer than the number of columns in this table.";
+ public const string DataRow_NoCurrentData = "There is no Current data to access.";
+ public const string DataRow_NoOriginalData = "There is no Original data to access.";
+ public const string DataRow_NoProposedData = "There is no Proposed data to access.";
+ public const string DataRow_RemovedFromTheTable = "This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row.";
+ public const string DataRow_DeletedRowInaccessible = "Deleted row information cannot be accessed through the row.";
+ public const string DataRow_InvalidVersion = "Version must be Original, Current, or Proposed.";
+ public const string DataRow_OutOfRange = "There is no row at position {0}.";
+ public const string DataRow_RowInsertOutOfRange = "The row insert position {0} is invalid.";
+ public const string DataRow_RowInsertMissing = "Values are missing in the rowOrder sequence for table '{0}'.";
+ public const string DataRow_RowOutOfRange = "The given DataRow is not in the current DataRowCollection.";
+ public const string DataRow_AlreadyInOtherCollection = "This row already belongs to another table.";
+ public const string DataRow_AlreadyInTheCollection = "This row already belongs to this table.";
+ public const string DataRow_AlreadyDeleted = "Cannot delete this row since it's already deleted.";
+ public const string DataRow_Empty = "This row is empty.";
+ public const string DataRow_AlreadyRemoved = "Cannot remove a row that's already been removed.";
+ public const string DataRow_MultipleParents = "A child row has multiple parents.";
+ public const string DataRow_InvalidRowBitPattern = "Unrecognized row state bit pattern.";
+ public const string DataSet_SetNameToEmpty = "Cannot change the name of the DataSet to an empty string.";
+ public const string DataSet_SetDataSetNameConflicting = "The name '{0}' is invalid. A DataSet cannot have the same name of the DataTable.";
+ public const string DataSet_UnsupportedSchema = "The schema namespace is invalid. Please use this one instead: {0}.";
+ public const string DataSet_CannotChangeCaseLocale = "Cannot change CaseSensitive or Locale property. This change would lead to at least one DataRelation or Constraint to have different Locale or CaseSensitive settings between its related tables.";
+ public const string DataSet_CannotChangeSchemaSerializationMode = "SchemaSerializationMode property can be set only if it is overridden by derived DataSet.";
+ public const string DataTable_ForeignPrimaryKey = "PrimaryKey columns do not belong to this table.";
+ public const string DataTable_CannotAddToSimpleContent = "Cannot add a nested relation or an element column to a table containing a SimpleContent column.";
+ public const string DataTable_NoName = "TableName is required when it is part of a DataSet.";
+ public const string DataTable_MultipleSimpleContentColumns = "DataTable already has a simple content column.";
+ public const string DataTable_MissingPrimaryKey = "Table doesn't have a primary key.";
+ public const string DataTable_InvalidSortString = " {0} isn't a valid Sort string entry.";
+ public const string DataTable_CanNotSerializeDataTableHierarchy = "Cannot serialize the DataTable. A DataTable being used in one or more DataColumn expressions is not a descendant of current DataTable.";
+ public const string DataTable_CanNotRemoteDataTable = "This DataTable can only be remoted as part of DataSet. One or more Expression Columns has reference to other DataTable(s).";
+ public const string DataTable_CanNotSetRemotingFormat = "Cannot have different remoting format property value for DataSet and DataTable.";
+ public const string DataTable_CanNotSerializeDataTableWithEmptyName = "Cannot serialize the DataTable. DataTable name is not set.";
+ public const string DataTable_DuplicateName = "A DataTable named '{0}' already belongs to this DataSet.";
+ public const string DataTable_DuplicateName2 = "A DataTable named '{0}' with the same Namespace '{1}' already belongs to this DataSet.";
+ public const string DataTable_SelfnestedDatasetConflictingName = "The table ({0}) cannot be the child table to itself in a nested relation: the DataSet name conflicts with the table name.";
+ public const string DataTable_DatasetConflictingName = "The name '{0}' is invalid. A DataTable cannot have the same name of the DataSet.";
+ public const string DataTable_AlreadyInOtherDataSet = "DataTable already belongs to another DataSet.";
+ public const string DataTable_AlreadyInTheDataSet = "DataTable already belongs to this DataSet.";
+ public const string DataTable_NotInTheDataSet = "Table {0} does not belong to this DataSet.";
+ public const string DataTable_OutOfRange = "Cannot find table {0}.";
+ public const string DataTable_InRelation = "Cannot remove a table that has existing relations. Remove relations first.";
+ public const string DataTable_InConstraint = "Cannot remove table {0}, because it referenced in ForeignKeyConstraint {1}. Remove the constraint first.";
+ public const string DataTable_TableNotFound = "DataTable '{0}' does not match to any DataTable in source.";
+ public const string DataMerge_MissingDefinition = "Target DataSet missing definition for {0}.";
+ public const string DataMerge_MissingConstraint = "Target DataSet missing {0} {1}.";
+ public const string DataMerge_DataTypeMismatch = "<target>.{0} and <source>.{0} have conflicting properties: DataType property mismatch.";
+ public const string DataMerge_PrimaryKeyMismatch = "<target>.PrimaryKey and <source>.PrimaryKey have different Length.";
+ public const string DataMerge_PrimaryKeyColumnsMismatch = "Mismatch columns in the PrimaryKey : <target>.{0} versus <source>.{1}.";
+ public const string DataMerge_ReltionKeyColumnsMismatch = "Relation {0} cannot be merged, because keys have mismatch columns.";
+ public const string DataMerge_MissingColumnDefinition = "Target table {0} missing definition for column {1}.";
+ public const string DataIndex_RecordStateRange = "The RowStates parameter must be set to a valid combination of values from the DataViewRowState enumeration.";
+ public const string DataIndex_FindWithoutSortOrder = "Find finds a row based on a Sort order, and no Sort order is specified.";
+ public const string DataIndex_KeyLength = "Expecting {0} value(s) for the key being indexed, but received {1} value(s).";
+ public const string DataStorage_AggregateException = "Invalid usage of aggregate function {0}() and Type: {1}.";
+ public const string DataStorage_InvalidStorageType = "Invalid storage type: {0}.";
+ public const string DataStorage_ProblematicChars = "The DataSet Xml persistency does not support the value '{0}' as Char value, please use Byte storage instead.";
+ public const string DataStorage_SetInvalidDataType = "Type of value has a mismatch with column type";
+ public const string DataStorage_IComparableNotDefined = " Type '{0}' does not implement IComparable interface. Comparison cannot be done.";
+ public const string DataView_SetFailed = "Cannot set {0}.";
+ public const string DataView_SetDataSetFailed = "Cannot change DataSet on a DataViewManager that's already the default view for a DataSet.";
+ public const string DataView_SetRowStateFilter = "RowStateFilter cannot show ModifiedOriginals and ModifiedCurrents at the same time.";
+ public const string DataView_SetTable = "Cannot change Table property on a DefaultView or a DataView coming from a DataViewManager.";
+ public const string DataView_CanNotSetDataSet = "Cannot change DataSet property once it is set.";
+ public const string DataView_CanNotUseDataViewManager = "DataSet must be set prior to using DataViewManager.";
+ public const string DataView_CanNotSetTable = "Cannot change Table property once it is set.";
+ public const string DataView_CanNotUse = "DataTable must be set prior to using DataView.";
+ public const string DataView_CanNotBindTable = "Cannot bind to DataTable with no name.";
+ public const string DataView_SetIListObject = "Cannot set an object into this list.";
+ public const string DataView_AddNewNotAllowNull = "Cannot call AddNew on a DataView where AllowNew is false.";
+ public const string DataView_NotOpen = "DataView is not open.";
+ public const string DataView_CreateChildView = "The relation is not parented to the table to which this DataView points.";
+ public const string DataView_CanNotDelete = "Cannot delete on a DataSource where AllowDelete is false.";
+ public const string DataView_CanNotEdit = "Cannot edit on a DataSource where AllowEdit is false.";
+ public const string DataView_GetElementIndex = "Index {0} is either negative or above rows count.";
+ public const string DataView_AddExternalObject = "Cannot add external objects to this list.";
+ public const string DataView_CanNotClear = "Cannot clear this list.";
+ public const string DataView_InsertExternalObject = "Cannot insert external objects to this list.";
+ public const string DataView_RemoveExternalObject = "Cannot remove objects not in the list.";
+ public const string DataROWView_PropertyNotFound = "{0} is neither a DataColumn nor a DataRelation for table {1}.";
+ public const string Range_Argument = "Min ({0}) must be less than or equal to max ({1}) in a Range object.";
+ public const string Range_NullRange = "This is a null range.";
+ public const string RecordManager_MinimumCapacity = "MinimumCapacity must be non-negative.";
+ public const string SqlConvert_ConvertFailed = " Cannot convert object of type '{0}' to object of type '{1}'.";
+ public const string DataSet_DefaultDataException = "Data Exception.";
+ public const string DataSet_DefaultConstraintException = "Constraint Exception.";
+ public const string DataSet_DefaultDeletedRowInaccessibleException = "Deleted rows inaccessible.";
+ public const string DataSet_DefaultDuplicateNameException = "Duplicate name not allowed.";
+ public const string DataSet_DefaultInRowChangingEventException = "Operation not supported in the RowChanging event.";
+ public const string DataSet_DefaultInvalidConstraintException = "Invalid constraint.";
+ public const string DataSet_DefaultMissingPrimaryKeyException = "Missing primary key.";
+ public const string DataSet_DefaultNoNullAllowedException = "Null not allowed.";
+ public const string DataSet_DefaultReadOnlyException = "Column is marked read only.";
+ public const string DataSet_DefaultRowNotInTableException = "Row not found in table.";
+ public const string DataSet_DefaultVersionNotFoundException = "Version not found.";
+ public const string Load_ReadOnlyDataModified = "ReadOnly Data is Modified.";
+ public const string DataTableReader_InvalidDataTableReader = "DataTableReader is invalid for current DataTable '{0}'.";
+ public const string DataTableReader_SchemaInvalidDataTableReader = "Schema of current DataTable '{0}' in DataTableReader has changed, DataTableReader is invalid.";
+ public const string DataTableReader_CannotCreateDataReaderOnEmptyDataSet = "DataTableReader Cannot be created. There is no DataTable in DataSet.";
+ public const string DataTableReader_DataTableReaderArgumentIsEmpty = "Cannot create DataTableReader. Argument is Empty.";
+ public const string DataTableReader_ArgumentContainsNullValue = "Cannot create DataTableReader. Arguments contain null value.";
+ public const string DataTableReader_InvalidRowInDataTableReader = "Current DataRow is either in Deleted or Detached state.";
+ public const string DataTableReader_DataTableCleared = "Current DataTable '{0}' is empty. There is no DataRow in DataTable.";
+ public const string RbTree_InvalidState = "DataTable internal index is corrupted: '{0}'.";
+ public const string RbTree_EnumerationBroken = "Collection was modified; enumeration operation might not execute.";
+ public const string NamedSimpleType_InvalidDuplicateNamedSimpleTypeDelaration = "Simple type '{0}' has already be declared with different '{1}'.";
+ public const string DataDom_Foliation = "Invalid foliation.";
+ public const string DataDom_TableNameChange = "Cannot change the table name once the associated DataSet is mapped to a loaded XML document.";
+ public const string DataDom_TableNamespaceChange = "Cannot change the table namespace once the associated DataSet is mapped to a loaded XML document.";
+ public const string DataDom_ColumnNameChange = "Cannot change the column name once the associated DataSet is mapped to a loaded XML document.";
+ public const string DataDom_ColumnNamespaceChange = "Cannot change the column namespace once the associated DataSet is mapped to a loaded XML document.";
+ public const string DataDom_ColumnMappingChange = "Cannot change the ColumnMapping property once the associated DataSet is mapped to a loaded XML document.";
+ public const string DataDom_TableColumnsChange = "Cannot add or remove columns from the table once the DataSet is mapped to a loaded XML document.";
+ public const string DataDom_DataSetTablesChange = "Cannot add or remove tables from the DataSet once the DataSet is mapped to a loaded XML document.";
+ public const string DataDom_DataSetNestedRelationsChange = "Cannot add, remove, or change Nested relations from the DataSet once the DataSet is mapped to a loaded XML document.";
+ public const string DataDom_DataSetNull = "The DataSet parameter is invalid. It cannot be null.";
+ public const string DataDom_DataSetNameChange = "Cannot change the DataSet name once the DataSet is mapped to a loaded XML document.";
+ public const string DataDom_CloneNode = "This type of node cannot be cloned: {0}.";
+ public const string DataDom_MultipleLoad = "Cannot load XmlDataDocument if it already contains data. Please use a new XmlDataDocument.";
+ public const string DataDom_MultipleDataSet = "DataSet can be associated with at most one XmlDataDocument. Cannot associate the DataSet with the current XmlDataDocument because the DataSet is already associated with another XmlDataDocument.";
+ public const string DataDom_NotSupport_GetElementById = "GetElementById() is not supported on DataDocument.";
+ public const string DataDom_NotSupport_EntRef = "Cannot create entity references on DataDocument.";
+ public const string DataDom_NotSupport_Clear = "Clear function on DateSet and DataTable is not supported on XmlDataDocument.";
+ public const string ConfigProviderNotFound = "Unable to find the requested .Net Framework Data Provider. It may not be installed.";
+ public const string ConfigProviderInvalid = "The requested .Net Framework Data Provider's implementation does not have an Instance field of a System.Data.Common.DbProviderFactory derived type.";
+ public const string ConfigProviderNotInstalled = "Failed to find or load the registered .Net Framework Data Provider.";
+ public const string ConfigProviderMissing = "The missing .Net Framework Data Provider's assembly qualified name is required.";
+ public const string ConfigBaseElementsOnly = "Only elements allowed.";
+ public const string ConfigBaseNoChildNodes = "Child nodes not allowed.";
+ public const string ConfigUnrecognizedAttributes = "Unrecognized attribute '{0}'.";
+ public const string ConfigUnrecognizedElement = "Unrecognized element.";
+ public const string ConfigSectionsUnique = "The '{0}' section can only appear once per config file.";
+ public const string ConfigRequiredAttributeMissing = "Required attribute '{0}' not found.";
+ public const string ConfigRequiredAttributeEmpty = "Required attribute '{0}' cannot be empty.";
+ public const string ADP_EmptyArray = "Expecting non-empty array for '{0}' parameter.";
+ public const string SQL_WrongType = "Expecting argument of type {1}, but received type {0}.";
+ public const string ADP_InvalidConnectionOptionValue = "Invalid value for key '{0}'.";
+ public const string ADP_KeywordNotSupported = "Keyword not supported: '{0}'.";
+ public const string ADP_InternalProviderError = "Internal .Net Framework Data Provider error {0}.";
+ public const string ADP_NoQuoteChange = "The QuotePrefix and QuoteSuffix properties cannot be changed once an Insert, Update, or Delete command has been generated.";
+ public const string ADP_MissingSourceCommand = "The DataAdapter.SelectCommand property needs to be initialized.";
+ public const string ADP_MissingSourceCommandConnection = "The DataAdapter.SelectCommand.Connection property needs to be initialized;";
+ public const string ADP_InvalidMultipartName = "{0} \"{1}\".";
+ public const string ADP_InvalidMultipartNameQuoteUsage = "{0} \"{1}\", incorrect usage of quotes.";
+ public const string ADP_InvalidMultipartNameToManyParts = "{0} \"{1}\", the current limit of \"{2}\" is insufficient.";
+ public const string ADP_ColumnSchemaExpression = "The column mapping from SourceColumn '{0}' failed because the DataColumn '{1}' is a computed column.";
+ public const string ADP_ColumnSchemaMismatch = "Inconvertible type mismatch between SourceColumn '{0}' of {1} and the DataColumn '{2}' of {3}.";
+ public const string ADP_ColumnSchemaMissing1 = "Missing the DataColumn '{0}' for the SourceColumn '{2}'.";
+ public const string ADP_ColumnSchemaMissing2 = "Missing the DataColumn '{0}' in the DataTable '{1}' for the SourceColumn '{2}'.";
+ public const string ADP_InvalidSourceColumn = "SourceColumn is required to be a non-empty string.";
+ public const string ADP_MissingColumnMapping = "Missing SourceColumn mapping for '{0}'.";
+ public const string ADP_NotSupportedEnumerationValue = "The {0} enumeration value, {1}, is not supported by the {2} method.";
+ public const string ADP_MissingTableSchema = "Missing the '{0}' DataTable for the '{1}' SourceTable.";
+ public const string ADP_InvalidSourceTable = "SourceTable is required to be a non-empty string";
+ public const string ADP_MissingTableMapping = "Missing SourceTable mapping: '{0}'";
+ public const string ADP_ConnectionRequired = "{0}: Connection property has not been initialized.";
+ public const string ADP_OpenConnectionRequired = "{0} requires an open and available Connection. {1}";
+ public const string ADP_ConnectionRequired_Insert = "Update requires the InsertCommand to have a connection object. The Connection property of the InsertCommand has not been initialized.";
+ public const string ADP_ConnectionRequired_Update = "Update requires the UpdateCommand to have a connection object. The Connection property of the UpdateCommand has not been initialized.";
+ public const string ADP_ConnectionRequired_Delete = "Update requires the DeleteCommand to have a connection object. The Connection property of the DeleteCommand has not been initialized.";
+ public const string ADP_ConnectionRequired_Batch = "Update requires a connection object. The Connection property has not been initialized.";
+ public const string ADP_ConnectionRequired_Clone = "Update requires the command clone to have a connection object. The Connection property of the command clone has not been initialized.";
+ public const string ADP_OpenConnectionRequired_Insert = "Update requires the {0}Command to have an open connection object. {1}";
+ public const string ADP_OpenConnectionRequired_Update = "Update requires the {0}Command to have an open connection object. {1}";
+ public const string ADP_OpenConnectionRequired_Delete = "Update requires the {0}Command to have an open connection object. {1}";
+ public const string ADP_OpenConnectionRequired_Clone = "Update requires the updating command to have an open connection object. {1}";
+ public const string ADP_MissingSelectCommand = "The SelectCommand property has not been initialized before calling '{0}'.";
+ public const string ADP_UnwantedStatementType = "The StatementType {0} is not expected here.";
+ public const string ADP_FillSchemaRequiresSourceTableName = "FillSchema: expected a non-empty string for the SourceTable name.";
+ public const string ADP_FillRequiresSourceTableName = "Fill: expected a non-empty string for the SourceTable name.";
+ public const string ADP_FillChapterAutoIncrement = "Hierarchical chapter columns must map to an AutoIncrement DataColumn.";
+ public const string ADP_MissingDataReaderFieldType = "DataReader.GetFieldType({0}) returned null.";
+ public const string ADP_OnlyOneTableForStartRecordOrMaxRecords = "Only specify one item in the dataTables array when using non-zero values for startRecords or maxRecords.";
+ public const string ADP_UpdateRequiresSourceTable = "Update unable to find TableMapping['{0}'] or DataTable '{0}'.";
+ public const string ADP_UpdateRequiresSourceTableName = "Update: expected a non-empty SourceTable name.";
+ public const string ADP_UpdateRequiresCommandClone = "Update requires the command clone to be valid.";
+ public const string ADP_UpdateRequiresCommandSelect = "Auto SQL generation during Update requires a valid SelectCommand.";
+ public const string ADP_UpdateRequiresCommandInsert = "Update requires a valid InsertCommand when passed DataRow collection with new rows.";
+ public const string ADP_UpdateRequiresCommandUpdate = "Update requires a valid UpdateCommand when passed DataRow collection with modified rows.";
+ public const string ADP_UpdateRequiresCommandDelete = "Update requires a valid DeleteCommand when passed DataRow collection with deleted rows.";
+ public const string ADP_UpdateMismatchRowTable = "DataRow[{0}] is from a different DataTable than DataRow[0].";
+ public const string ADP_RowUpdatedErrors = "RowUpdatedEvent: Errors occurred; no additional is information available.";
+ public const string ADP_RowUpdatingErrors = "RowUpdatingEvent: Errors occurred; no additional is information available.";
+ public const string ADP_ResultsNotAllowedDuringBatch = "When batching, the command's UpdatedRowSource property value of UpdateRowSource.FirstReturnedRecord or UpdateRowSource.Both is invalid.";
+ public const string ADP_UpdateConcurrencyViolation_Update = "Concurrency violation: the UpdateCommand affected {0} of the expected {1} records.";
+ public const string ADP_UpdateConcurrencyViolation_Delete = "Concurrency violation: the DeleteCommand affected {0} of the expected {1} records.";
+ public const string ADP_UpdateConcurrencyViolation_Batch = "Concurrency violation: the batched command affected {0} of the expected {1} records.";
+ public const string ADP_InvalidSourceBufferIndex = "Invalid source buffer (size of {0}) offset: {1}";
+ public const string ADP_InvalidDestinationBufferIndex = "Invalid destination buffer (size of {0}) offset: {1}";
+ public const string ADP_StreamClosed = "Invalid attempt to {0} when stream is closed.";
+ public const string ADP_InvalidSeekOrigin = "Specified SeekOrigin value is invalid.";
+ public const string ADP_DynamicSQLJoinUnsupported = "Dynamic SQL generation is not supported against multiple base tables.";
+ public const string ADP_DynamicSQLNoTableInfo = "Dynamic SQL generation is not supported against a SelectCommand that does not return any base table information.";
+ public const string ADP_DynamicSQLNoKeyInfoDelete = "Dynamic SQL generation for the DeleteCommand is not supported against a SelectCommand that does not return any key column information.";
+ public const string ADP_DynamicSQLNoKeyInfoUpdate = "Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.";
+ public const string ADP_DynamicSQLNoKeyInfoRowVersionDelete = "Dynamic SQL generation for the DeleteCommand is not supported against a SelectCommand that does not contain a row version column.";
+ public const string ADP_DynamicSQLNoKeyInfoRowVersionUpdate = "Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not contain a row version column.";
+ public const string ADP_DynamicSQLNestedQuote = "Dynamic SQL generation not supported against table names '{0}' that contain the QuotePrefix or QuoteSuffix character '{1}'.";
+ public const string SQL_InvalidBufferSizeOrIndex = "Buffer offset '{1}' plus the bytes available '{0}' is greater than the length of the passed in buffer.";
+ public const string SQL_InvalidDataLength = "Data length '{0}' is less than 0.";
+ public const string SqlMisc_NullString = "Null";
+ public const string SqlMisc_MessageString = "Message";
+ public const string SqlMisc_ArithOverflowMessage = "Arithmetic Overflow.";
+ public const string SqlMisc_DivideByZeroMessage = "Divide by zero error encountered.";
+ public const string SqlMisc_NullValueMessage = "Data is Null. This method or property cannot be called on Null values.";
+ public const string SqlMisc_TruncationMessage = "Numeric arithmetic causes truncation.";
+ public const string SqlMisc_DateTimeOverflowMessage = "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.";
+ public const string SqlMisc_ConcatDiffCollationMessage = "Two strings to be concatenated have different collation.";
+ public const string SqlMisc_CompareDiffCollationMessage = "Two strings to be compared have different collation.";
+ public const string SqlMisc_InvalidFlagMessage = "Invalid flag value.";
+ public const string SqlMisc_NumeToDecOverflowMessage = "Conversion from SqlDecimal to Decimal overflows.";
+ public const string SqlMisc_ConversionOverflowMessage = "Conversion overflows.";
+ public const string SqlMisc_InvalidDateTimeMessage = "Invalid SqlDateTime.";
+ public const string SqlMisc_TimeZoneSpecifiedMessage = "A time zone was specified. SqlDateTime does not support time zones.";
+ public const string SqlMisc_InvalidArraySizeMessage = "Invalid array size.";
+ public const string SqlMisc_InvalidPrecScaleMessage = "Invalid numeric precision/scale.";
+ public const string SqlMisc_FormatMessage = "The input wasn't in a correct format.";
+ public const string SqlMisc_SqlTypeMessage = "SqlType error.";
+ public const string SqlMisc_NoBufferMessage = "There is no buffer. Read or write operation failed.";
+ public const string SqlMisc_BufferInsufficientMessage = "The buffer is insufficient. Read or write operation failed.";
+ public const string SqlMisc_WriteNonZeroOffsetOnNullMessage = "Cannot write to non-zero offset, because current value is Null.";
+ public const string SqlMisc_WriteOffsetLargerThanLenMessage = "Cannot write from an offset that is larger than current length. It would leave uninitialized data in the buffer.";
+ public const string SqlMisc_NotFilledMessage = "SQL Type has not been loaded with data.";
+ public const string SqlMisc_AlreadyFilledMessage = "SQL Type has already been loaded with data.";
+ public const string SqlMisc_ClosedXmlReaderMessage = "Invalid attempt to access a closed XmlReader.";
+ public const string SqlMisc_InvalidOpStreamClosed = "Invalid attempt to call {0} when the stream is closed.";
+ public const string SqlMisc_InvalidOpStreamNonWritable = "Invalid attempt to call {0} when the stream non-writable.";
+ public const string SqlMisc_InvalidOpStreamNonReadable = "Invalid attempt to call {0} when the stream non-readable.";
+ public const string SqlMisc_InvalidOpStreamNonSeekable = "Invalid attempt to call {0} when the stream is non-seekable.";
+ public const string ADP_DBConcurrencyExceptionMessage = "DB concurrency violation.";
+ public const string ADP_OperationAborted = "Operation aborted.";
+ public const string ADP_OperationAbortedExceptionMessage = "Operation aborted due to an exception (see InnerException for details).";
+ public const string ADP_InvalidMaxRecords = "The MaxRecords value of {0} is invalid; the value must be >= 0.";
+ public const string ADP_CollectionIndexInt32 = "Invalid index {0} for this {1} with Count={2}.";
+ public const string ADP_MissingTableMappingDestination = "Missing TableMapping when TableMapping.DataSetTable='{0}'.";
+ public const string ADP_InvalidStartRecord = "The StartRecord value of {0} is invalid; the value must be >= 0.";
+ public const string DataDom_EnforceConstraintsShouldBeOff = "Please set DataSet.EnforceConstraints == false before trying to edit XmlDataDocument using XML operations.";
+ public const string DataColumns_RemoveExpression = "Cannot remove this column, because it is part of an expression: {0} = {1}.";
+ public const string DataRow_RowInsertTwice = "The rowOrder value={0} has been found twice for table named '{1}'.";
+ public const string Xml_ElementTypeNotFound = "Cannot find ElementType name='{0}'.";
+}
ReferenceSources/ThisAssembly.cs
ReferenceSources/Win32NativeMethods.cs
ReferenceSources/SqlInternalConnectionTds.cs
-
ReferenceSources/mobile_DbConnectionPoolCounters.cs
+corefx/SR.cs
+
Microsoft.SqlServer.Server/SqlDataRecord.cs
Microsoft.SqlServer.Server/SqlMetaData.cs
System.Data.Common/ExceptionHelper.cs
System.Data.Common/DbConnectionStringBuilderHelper.cs
-#include mobile_referencesource.sources
-
+MobileStubs.cs
+#include corefx.common.sources
+++ /dev/null
-MobileStubs.cs
-
-../referencesource/System.Data/Microsoft/SqlServer/Server/SqlTriggerContext.cs
-
-../referencesource/System.Data/Misc/ExternDll.cs
-../referencesource/System.Data/Misc/HResults.cs
-../referencesource/System.Data/System/Data/AcceptRejectRule.cs
-../referencesource/System.Data/System/Data/AggregateType.cs
-../referencesource/System.Data/System/Data/BaseCollection.cs
-../referencesource/System.Data/System/Data/CatalogLocation.cs
-../referencesource/System.Data/System/Data/CodeGen/StrongTypingException.cs
-../referencesource/System.Data/System/Data/ColumnTypeConverter.cs
-../referencesource/System.Data/System/Data/CommandBehavior.cs
-../referencesource/System.Data/System/Data/CommandType.cs
-../referencesource/System.Data/System/Data/Common/ActivityCorrelator.cs
-../referencesource/System.Data/System/Data/Common/AdapterSwitches.cs
-../referencesource/System.Data/System/Data/Common/AdapterUtil.cs
-../referencesource/System.Data/System/Data/Common/BigIntegerStorage.cs
-../referencesource/System.Data/System/Data/Common/BooleanStorage.cs
-../referencesource/System.Data/System/Data/Common/ByteStorage.cs
-../referencesource/System.Data/System/Data/Common/CharStorage.cs
-../referencesource/System.Data/System/Data/Common/DataAdapter.cs
-../referencesource/System.Data/System/Data/Common/DataColumnMappingCollection.cs
-../referencesource/System.Data/System/Data/Common/DataColumnMapping.cs
-../referencesource/System.Data/System/Data/Common/DataRecordInternal.cs
-../referencesource/System.Data/System/Data/Common/DataStorage.cs
-../referencesource/System.Data/System/Data/Common/DataTableMappingCollection.cs
-../referencesource/System.Data/System/Data/Common/DataTableMapping.cs
-../referencesource/System.Data/System/Data/Common/DateTimeOffsetStorage.cs
-../referencesource/System.Data/System/Data/Common/DateTimeStorage.cs
-../referencesource/System.Data/System/Data/Common/DBCommandBuilder.cs
-../referencesource/System.Data/System/Data/Common/DBCommand.cs
-../referencesource/System.Data/System/Data/Common/DBConnection.cs
-../referencesource/System.Data/System/Data/Common/DbConnectionOptions.cs
-../referencesource/System.Data/System/Data/Common/DbConnectionPoolKey.cs
-../referencesource/System.Data/System/Data/Common/DbConnectionStringBuilder.cs
-../referencesource/System.Data/System/Data/Common/DbConnectionStringCommon.cs
-../referencesource/System.Data/System/Data/Common/DBConnectionString.cs
-../referencesource/System.Data/System/Data/Common/DbDataAdapter.cs
-../referencesource/System.Data/System/Data/Common/DBDataPermissionAttribute.cs
-../referencesource/System.Data/System/Data/Common/DBDataPermission.cs
-../referencesource/System.Data/System/Data/Common/DbDataReader.cs
-../referencesource/System.Data/System/Data/Common/dbdatarecord.cs
-../referencesource/System.Data/System/Data/Common/DbDataSourceEnumerator.cs
-../referencesource/System.Data/System/Data/Common/dbenumerator.cs
-../referencesource/System.Data/System/Data/Common/DbException.cs
-../referencesource/System.Data/System/Data/Common/DbParameterCollection.cs
-../referencesource/System.Data/System/Data/Common/DBParameter.cs
-../referencesource/System.Data/System/Data/Common/DbProviderFactory.cs
-../referencesource/System.Data/System/Data/Common/DbProviderSpecificTypePropertyAttribute.cs
-../referencesource/System.Data/System/Data/Common/DBSchemaRow.cs
-../referencesource/System.Data/System/Data/Common/DBSchemaTable.cs
-../referencesource/System.Data/System/Data/Common/DbTransaction.cs
-../referencesource/System.Data/System/Data/Common/DecimalStorage.cs
-../referencesource/System.Data/System/Data/Common/DoubleStorage.cs
-../referencesource/System.Data/System/Data/Common/FieldNameLookup.cs
-../referencesource/System.Data/System/Data/Common/GreenMethods.cs
-../referencesource/System.Data/System/Data/Common/Groupbybehavior.cs
-../referencesource/System.Data/System/Data/Common/identifiercase.cs
-../referencesource/System.Data/System/Data/Common/Int16Storage.cs
-../referencesource/System.Data/System/Data/Common/Int32Storage.cs
-../referencesource/System.Data/System/Data/Common/Int64Storage.cs
-../referencesource/System.Data/System/Data/Common/MultipartIdentifier.cs
-../referencesource/System.Data/System/Data/Common/NameValuePair.cs
-../referencesource/System.Data/System/Data/Common/NameValuePermission.cs
-../referencesource/System.Data/System/Data/Common/ObjectStorage.cs
-../referencesource/System.Data/System/Data/Common/RowUpdatedEventArgs.cs
-../referencesource/System.Data/System/Data/Common/RowUpdatingEventArgs.cs
-../referencesource/System.Data/System/Data/Common/SByteStorage.cs
-../referencesource/System.Data/System/Data/Common/SchemaTableColumn.cs
-../referencesource/System.Data/System/Data/Common/SchemaTableOptionalColumn.cs
-../referencesource/System.Data/System/Data/Common/SingleStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLConvert.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLBinaryStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQlBooleanStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLBytesStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLByteStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLCharsStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLDateTimeStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLDecimalStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLDoubleStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLGuidStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLInt16Storage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLInt32Storage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLInt64Storage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLMoneyStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLSingleStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLStringStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SqlUDTStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SqlXmlStorage.cs
-../referencesource/System.Data/System/Data/Common/StringStorage.cs
-../referencesource/System.Data/System/Data/Common/SupportedJoinOperators.cs
-../referencesource/System.Data/System/Data/Common/TimeSpanStorage.cs
-../referencesource/System.Data/System/Data/Common/UInt16Storage.cs
-../referencesource/System.Data/System/Data/Common/UInt32Storage.cs
-../referencesource/System.Data/System/Data/Common/UInt64Storage.cs
-../referencesource/System.Data/System/Data/ConflictOptions.cs
-../referencesource/System.Data/System/Data/ConnectionState.cs
-../referencesource/System.Data/System/Data/ConstraintCollection.cs
-../referencesource/System.Data/System/Data/ConstraintConverter.cs
-../referencesource/System.Data/System/Data/Constraint.cs
-../referencesource/System.Data/System/Data/ConstraintEnumerator.cs
-../referencesource/System.Data/System/Data/DataColumnChangeEvent.cs
-../referencesource/System.Data/System/Data/DataColumnChangeEventHandler.cs
-../referencesource/System.Data/System/Data/DataColumnCollection.cs
-../referencesource/System.Data/System/Data/DataColumn.cs
-../referencesource/System.Data/System/Data/DataColumnPropertyDescriptor.cs
-../referencesource/System.Data/System/Data/DataError.cs
-../referencesource/System.Data/System/Data/DataException.cs
-../referencesource/System.Data/System/Data/DataKey.cs
-../referencesource/System.Data/System/Data/DataRelationCollection.cs
-../referencesource/System.Data/System/Data/DataRelation.cs
-../referencesource/System.Data/System/Data/DataRelationPropertyDescriptor.cs
-../referencesource/System.Data/System/Data/DataRowAction.cs
-../referencesource/System.Data/System/Data/DataRowChangeEvent.cs
-../referencesource/System.Data/System/Data/DataRowChangeEventHandler.cs
-../referencesource/System.Data/System/Data/DataRowCollection.cs
-../referencesource/System.Data/System/Data/DataRowCreatedEventHandler.cs
-../referencesource/System.Data/System/Data/DataRow.cs
-../referencesource/System.Data/System/Data/DataRowState.cs
-../referencesource/System.Data/System/Data/DataRowVersion.cs
-../referencesource/System.Data/System/Data/DataRowView.cs
-../referencesource/System.Data/System/Data/DataSerializationFormat.cs
-../referencesource/System.Data/System/Data/DataSet.cs
-../referencesource/System.Data/System/Data/DataSetDateTime.cs
-../referencesource/System.Data/System/Data/DataSysAttribute.cs
-../referencesource/System.Data/System/Data/DataTableClearEvent.cs
-../referencesource/System.Data/System/Data/DataTableClearEventHandler.cs
-../referencesource/System.Data/System/Data/DataTableCollection.cs
-../referencesource/System.Data/System/Data/DataTable.cs
-../referencesource/System.Data/System/Data/DataTableNewRowEvent.cs
-../referencesource/System.Data/System/Data/DataTableNewRowEventHandler.cs
-../referencesource/System.Data/System/Data/DataTablePropertyDescriptor.cs
-../referencesource/System.Data/System/Data/DataTableReader.cs
-../referencesource/System.Data/System/Data/DataTableReaderListener.cs
-../referencesource/System.Data/System/Data/DataTableTypeConverter.cs
-../referencesource/System.Data/System/Data/DataView.cs
-../referencesource/System.Data/System/Data/DataViewListener.cs
-../referencesource/System.Data/System/Data/DataViewManager.cs
-../referencesource/System.Data/System/Data/DataViewManagerListItemTypeDescriptor.cs
-../referencesource/System.Data/System/Data/DataViewRowState.cs
-../referencesource/System.Data/System/Data/DataViewSettingCollection.cs
-../referencesource/System.Data/System/Data/DataViewSetting.cs
-../referencesource/System.Data/System/Data/DBConcurrencyException.cs
-../referencesource/System.Data/System/Data/dbtype.cs
-../referencesource/System.Data/System/Data/DefaultValueTypeConverter.cs
-../referencesource/System.Data/System/Data/FillErrorEventArgs.cs
-../referencesource/System.Data/System/Data/FillErrorEventHandler.cs
-../referencesource/System.Data/System/Data/Filter/AggregateNode.cs
-../referencesource/System.Data/System/Data/Filter/BinaryNode.cs
-../referencesource/System.Data/System/Data/Filter/ConstNode.cs
-../referencesource/System.Data/System/Data/Filter/DataExpression.cs
-../referencesource/System.Data/System/Data/Filter/ExpressionNode.cs
-../referencesource/System.Data/System/Data/Filter/ExpressionParser.cs
-../referencesource/System.Data/System/Data/Filter/FilterException.cs
-../referencesource/System.Data/System/Data/Filter/FunctionNode.cs
-../referencesource/System.Data/System/Data/Filter/IFilter.cs
-../referencesource/System.Data/System/Data/Filter/LookupNode.cs
-../referencesource/System.Data/System/Data/Filter/NameNode.cs
-../referencesource/System.Data/System/Data/Filter/Operators.cs
-../referencesource/System.Data/System/Data/Filter/UnaryNode.cs
-../referencesource/System.Data/System/Data/Filter/ZeroOpNode.cs
-../referencesource/System.Data/System/Data/ForeignKeyConstraint.cs
-../referencesource/System.Data/System/Data/IColumnMappingCollection.cs
-../referencesource/System.Data/System/Data/IColumnMapping.cs
-../referencesource/System.Data/System/Data/IDataAdapter.cs
-../referencesource/System.Data/System/Data/IDataParameterCollection.cs
-../referencesource/System.Data/System/Data/IDataParameter.cs
-../referencesource/System.Data/System/Data/IDataReader.cs
-../referencesource/System.Data/System/Data/IDataRecord.cs
-../referencesource/System.Data/System/Data/IDbCommand.cs
-../referencesource/System.Data/System/Data/IDbConnection.cs
-../referencesource/System.Data/System/Data/IDbDataAdapter.cs
-../referencesource/System.Data/System/Data/IDbDataParameter.cs
-../referencesource/System.Data/System/Data/IDbTransaction.cs
-../referencesource/System.Data/System/Data/IsolationLevel.cs
-../referencesource/System.Data/System/Data/ITableMappingCollection.cs
-../referencesource/System.Data/System/Data/ITableMapping.cs
-../referencesource/System.Data/System/Data/LoadOption.cs
-../referencesource/System.Data/System/Data/MappingType.cs
-../referencesource/System.Data/System/Data/MergeFailedEvent.cs
-../referencesource/System.Data/System/Data/MergeFailedEventHandler.cs
-../referencesource/System.Data/System/Data/Merger.cs
-../referencesource/System.Data/System/Data/MissingMappingAction.cs
-../referencesource/System.Data/System/Data/MissingSchemaAction.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbType.cs
-../referencesource/System.Data/System/Data/OleDb/PropertyAttributes.cs
-../referencesource/System.Data/System/Data/OperationAbortedException.cs
-../referencesource/System.Data/System/Data/ParameterDirection.cs
-../referencesource/System.Data/System/Data/PrimaryKeyTypeConverter.cs
-../referencesource/System.Data/System/Data/PropertyCollection.cs
-../referencesource/System.Data/System/Data/ProviderBase/DataReaderContainer.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolAuthenticationContext.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolAuthenticationContextKey.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolOptions.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolProviderInfo.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbMetaDataCollectionNames.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbMetaDataColumnNames.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbMetaDataFactory.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbReferenceCollection.cs
-../referencesource/System.Data/System/Data/ProviderBase/SchemaMapping.cs
-../referencesource/System.Data/System/Data/ProviderBase/TimeoutTimer.cs
-../referencesource/System.Data/System/Data/ProviderBase/WrappedIUnknown.cs
-../referencesource/System.Data/System/Data/Range.cs
-../referencesource/System.Data/System/Data/RbTree.cs
-../referencesource/System.Data/System/Data/RecordManager.cs
-../referencesource/System.Data/System/Data/RecordsAffectedEventArgs.cs
-../referencesource/System.Data/System/Data/RecordsAffectedEventHandler.cs
-../referencesource/System.Data/System/Data/RelatedView.cs
-../referencesource/System.Data/System/Data/RelationshipConverter.cs
-../referencesource/System.Data/System/Data/Rule.cs
-../referencesource/System.Data/System/Data/SchemaSerializationMode.cs
-../referencesource/System.Data/System/Data/SchemaType.cs
-../referencesource/System.Data/System/Data/Select.cs
-../referencesource/System.Data/System/Data/Selection.cs
-../referencesource/System.Data/System/Data/SimpleType.cs
-../referencesource/System.Data/System/Data/SqlDbType.cs
-../referencesource/System.Data/System/Data/StateChangeEvent.cs
-../referencesource/System.Data/System/Data/StateChangeEventHandler.cs
-../referencesource/System.Data/System/Data/StatementType.cs
-../referencesource/System.Data/System/Data/UniqueConstraint.cs
-../referencesource/System.Data/System/Data/UpdateRowSource.cs
-../referencesource/System.Data/System/Data/updatestatus.cs
-../referencesource/System.Data/System/Data/XDRSchema.cs
-../referencesource/System.Data/System/Data/XmlContent.cs
-../referencesource/System.Data/System/Data/XmlDataLoader.cs
-../referencesource/System.Data/System/Data/XMLDiffLoader.cs
-../referencesource/System.Data/System/Data/XmlKeywords.cs
-../referencesource/System.Data/System/Data/XmlReadMode.cs
-../referencesource/System.Data/System/Data/xmlsaver.cs
-../referencesource/System.Data/System/Data/XMLSchema.cs
-../referencesource/System.Data/System/Data/XmlToDatasetMap.cs
-../referencesource/System.Data/System/Data/XmlWriteMode.cs
-../referencesource/System.Data/System/NewXml/BaseTreeIterator.cs
-../referencesource/System.Data/System/NewXml/DataDocumentXPathNavigator.cs
-../referencesource/System.Data/System/NewXml/DataPointer.cs
-../referencesource/System.Data/System/NewXml/DataSetMappper.cs
-../referencesource/System.Data/System/NewXml/IXmlDataVirtualNode.cs
-../referencesource/System.Data/System/NewXml/RegionIterator.cs
-../referencesource/System.Data/System/NewXml/TreeIterator.cs
-../referencesource/System.Data/System/NewXml/XmlBoundElement.cs
-../referencesource/System.Data/System/NewXml/XmlDataDocument.cs
-../referencesource/System.Data/System/NewXml/XmlDataImplementation.cs
-../referencesource/System.Data/System/NewXml/XPathNodePointer.cs
-
-../referencesource/System.Data/System/Data/Sql/IBinarySerialize.cs
-../referencesource/System.Data/System/Data/Sql/invalidudtexception.cs
-../referencesource/System.Data/System/Data/Sql/SqlDataSourceEnumerator.cs
-../referencesource/System.Data/System/Data/Sql/SqlFacetAttribute.cs
-../referencesource/System.Data/System/Data/Sql/SqlFunctionAttribute.cs
-../referencesource/System.Data/System/Data/Sql/SqlGenericUtil.cs
-../referencesource/System.Data/System/Data/Sql/SqlMethodAttribute.cs
-../referencesource/System.Data/System/Data/Sql/SqlNotificationRequest.cs
-../referencesource/System.Data/System/Data/Sql/SqlProcedureAttribute.cs
-../referencesource/System.Data/System/Data/Sql/SqlTriggerAttribute.cs
-../referencesource/System.Data/System/Data/Sql/SqlUserDefinedAggregateAttribute.cs
-../referencesource/System.Data/System/Data/Sql/SqlUserDefinedTypeAttribute.cs
-../referencesource/System.Data/System/Data/Sql/TriggerAction.cs
-
-../referencesource/System.Data/System/Data/SqlClient/ApplicationIntent.cs
-../referencesource/System.Data/System/Data/SqlClient/LocalDBAPI.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlClientEncryptionType.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlClientPermission.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlConnectionString.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlConnectionStringBuilder.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlError.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlErrorCollection.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlInfoMessageEvent.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlUtil.cs
-../referencesource/System.Data/System/Data/SqlClient/TdsEnums.cs
-../referencesource/System.Data/System/Data/SqlClient/TdsParserStaticMethods.cs
-
-../referencesource/System.Data/System/Data/SQLTypes/INullable.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLBinary.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLBoolean.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLByte.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLBytes.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLChars.cs
-../referencesource/System.Data/System/Data/SQLTypes/SqlCharStream.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLDateTime.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLDecimal.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLDouble.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLGuid.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLInt16.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLInt32.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLInt64.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLMoney.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLResource.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLSingle.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLString.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLUtility.cs
-../referencesource/System.Data/System/Data/SQLTypes/SqlXml.cs
ReferenceSources/Win32NativeMethods.cs
ReferenceSources/SqlInternalConnectionTds.cs
+corefx/SR.cs
+
Microsoft.SqlServer.Server/SqlDataRecord.cs
Microsoft.SqlServer.Server/SqlMetaData.cs
System.Data.SqlClient/SortOrder.cs
System.Data.Common/ExceptionHelper.cs
System.Data.Common/DbConnectionStringBuilderHelper.cs
-#include referencesource.sources
+../referencesource/System.Data/bid/inc/cs/bidPrivateBase.cs
+../referencesource/System.Data/Misc/PrivilegedConfigurationManager.cs
+../referencesource/System.Data/System/Data/CodeGen/datacache.cs
+../referencesource/System.Data/System/Data/Common/DbProviderConfigurationHandler.cs
+../referencesource/System.Data/System/Data/Common/DbProviderFactoriesConfigurationHandler.cs
+../referencesource/System.Data/System/Data/Common/DbProviderFactories.cs
+../referencesource/System.Data/System/Data/Common/HandlerBase.cs
+../referencesource/System.Data/System/Data/Common/NativeMethods.cs
+../referencesource/System.Data/System/Data/Common/SafeNativeMethods.cs
+../referencesource/System.Data/System/Data/Common/System.Data_BID.cs
+../referencesource/System.Data/System/Data/Common/UnsafeNativeMethods.cs
+../referencesource/System.Data/System/Data/Odbc/DbDataRecord.cs
+../referencesource/System.Data/System/Data/Odbc/Odbc32.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcCommandBuilder.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcCommand.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcConnection.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcConnectionFactory.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcConnectionHandle.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcConnectionOpen.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcConnectionPoolProviderInfo.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcConnectionStringbuilder.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcConnectionString.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcDataAdapter.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcDataReader.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcEnvironment.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcEnvironmentHandle.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcErrorCollection.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcError.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcException.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcFactory.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcHandle.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcInfoMessageEvent.cs
+../referencesource/System.Data/System/Data/Odbc/odbcmetadatacollectionnames.cs
+../referencesource/System.Data/System/Data/Odbc/odbcmetadatacolumnnames.cs
+../referencesource/System.Data/System/Data/Odbc/odbcmetadatafactory.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcParameterCollection.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcParameter.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcPermission.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcReferenceCollection.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcRowUpdatingEvent.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcStatementHandle.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcTransaction.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcType.cs
+../referencesource/System.Data/System/Data/Odbc/OdbcUtils.cs
+../referencesource/System.Data/System/Data/OleDb/ColumnBinding.cs
+../referencesource/System.Data/System/Data/OleDb/DBBindings.cs
+../referencesource/System.Data/System/Data/OleDb/DBPropSet.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbCommandBuilder.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbCommand.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbConnection.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbConnectionFactory.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbConnectionInternal.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbConnectionPoolGroupProviderInfo.cs
+../referencesource/System.Data/System/Data/OleDb/OledbConnectionStringbuilder.cs
+../referencesource/System.Data/System/Data/OleDb/oledbconnectionstring.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbDataAdapter.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbDataReader.cs
+../referencesource/System.Data/System/Data/OleDb/OLEDB_Enum.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbEnumerator.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbErrorCollection.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbError.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbException.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbFactory.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbHResult.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbInfoMessageEvent.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbInfoMessageEventHandler.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbLiteral.cs
+../referencesource/System.Data/System/Data/OleDb/oledbmetadatacollectionnames.cs
+../referencesource/System.Data/System/Data/OleDb/oledbmetadatacolumnnames.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbMetaDataFactory.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbParameterCollection.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbParameter.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbPermission.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbPropertySetGuid.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbPropertyStatus.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbReferenceCollection.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbRowUpdatedEvent.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbRowUpdatedEventHandler.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbRowUpdatingEvent.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbRowUpdatingEventHandler.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbSchemaGuid.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbStruct.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbTransaction.cs
+../referencesource/System.Data/System/Data/OleDb/OLEDB_Util.cs
+../referencesource/System.Data/System/Data/OleDb/OleDbWrapper.cs
+../referencesource/System.Data/System/Data/OleDb/PropertyIDSet.cs
+../referencesource/System.Data/System/Data/OleDb/PropertyInfoSet.cs
+../referencesource/System.Data/System/Data/OleDb/RowBinding.cs
+../referencesource/System.Data/System/Data/OleDb/SafeHandles.cs
+../referencesource/System.Data/System/Data/ProviderBase/DbBuffer.cs
+../referencesource/System.Data/System/Data/ProviderBase/DbConnectionClosed.cs
+../referencesource/System.Data/System/Data/ProviderBase/DbConnectionFactory.cs
+# ../referencesource/System.Data/System/Data/ProviderBase/DbConnectionHelper.cs
+../referencesource/System.Data/System/Data/ProviderBase/DbConnectionInternal.cs
+../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolCounters.cs
+../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPool.cs
+../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolGroup.cs
+../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolGroupProviderInfo.cs
+../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolIdentity.cs
+# ../referencesource/System.Data/System/Data/ProviderBase/DbParameterCollectionHelper.cs
+# ../referencesource/System.Data/System/Data/ProviderBase/DbParameterHelper.cs
+../referencesource/System.Data/System/Data/SQLTypes/SqlTypesSchemaImporter.cs
+
+#include corefx.common.sources
--- /dev/null
+#include mobile_System.Data.dll.sources
+++ /dev/null
-../referencesource/System.Data/bid/inc/cs/bidPrivateBase.cs
-
-../referencesource/System.Data/Microsoft/SqlServer/Server/SqlTriggerContext.cs
-
-../referencesource/System.Data/Misc/ExternDll.cs
-../referencesource/System.Data/Misc/HResults.cs
-../referencesource/System.Data/Misc/PrivilegedConfigurationManager.cs
-
-../referencesource/System.Data/System/Data/AcceptRejectRule.cs
-../referencesource/System.Data/System/Data/AggregateType.cs
-../referencesource/System.Data/System/Data/BaseCollection.cs
-../referencesource/System.Data/System/Data/CatalogLocation.cs
-../referencesource/System.Data/System/Data/CodeGen/datacache.cs
-../referencesource/System.Data/System/Data/CodeGen/StrongTypingException.cs
-../referencesource/System.Data/System/Data/ColumnTypeConverter.cs
-../referencesource/System.Data/System/Data/CommandBehavior.cs
-../referencesource/System.Data/System/Data/CommandType.cs
-../referencesource/System.Data/System/Data/Common/ActivityCorrelator.cs
-../referencesource/System.Data/System/Data/Common/AdapterSwitches.cs
-../referencesource/System.Data/System/Data/Common/AdapterUtil.cs
-../referencesource/System.Data/System/Data/Common/BigIntegerStorage.cs
-../referencesource/System.Data/System/Data/Common/BooleanStorage.cs
-../referencesource/System.Data/System/Data/Common/ByteStorage.cs
-../referencesource/System.Data/System/Data/Common/CharStorage.cs
-../referencesource/System.Data/System/Data/Common/DataAdapter.cs
-../referencesource/System.Data/System/Data/Common/DataColumnMappingCollection.cs
-../referencesource/System.Data/System/Data/Common/DataColumnMapping.cs
-../referencesource/System.Data/System/Data/Common/DataRecordInternal.cs
-../referencesource/System.Data/System/Data/Common/DataStorage.cs
-../referencesource/System.Data/System/Data/Common/DataTableMappingCollection.cs
-../referencesource/System.Data/System/Data/Common/DataTableMapping.cs
-../referencesource/System.Data/System/Data/Common/DateTimeOffsetStorage.cs
-../referencesource/System.Data/System/Data/Common/DateTimeStorage.cs
-../referencesource/System.Data/System/Data/Common/DBCommandBuilder.cs
-../referencesource/System.Data/System/Data/Common/DBCommand.cs
-../referencesource/System.Data/System/Data/Common/DBConnection.cs
-../referencesource/System.Data/System/Data/Common/DbConnectionOptions.cs
-../referencesource/System.Data/System/Data/Common/DbConnectionPoolKey.cs
-../referencesource/System.Data/System/Data/Common/DbConnectionStringBuilder.cs
-../referencesource/System.Data/System/Data/Common/DbConnectionStringCommon.cs
-../referencesource/System.Data/System/Data/Common/DBConnectionString.cs
-../referencesource/System.Data/System/Data/Common/DbDataAdapter.cs
-../referencesource/System.Data/System/Data/Common/DBDataPermissionAttribute.cs
-../referencesource/System.Data/System/Data/Common/DBDataPermission.cs
-../referencesource/System.Data/System/Data/Common/DbDataReader.cs
-../referencesource/System.Data/System/Data/Common/dbdatarecord.cs
-../referencesource/System.Data/System/Data/Common/DbDataSourceEnumerator.cs
-../referencesource/System.Data/System/Data/Common/dbenumerator.cs
-../referencesource/System.Data/System/Data/Common/DbException.cs
-../referencesource/System.Data/System/Data/Common/DbParameterCollection.cs
-../referencesource/System.Data/System/Data/Common/DBParameter.cs
-../referencesource/System.Data/System/Data/Common/DbProviderConfigurationHandler.cs
-../referencesource/System.Data/System/Data/Common/DbProviderFactoriesConfigurationHandler.cs
-../referencesource/System.Data/System/Data/Common/DbProviderFactories.cs
-../referencesource/System.Data/System/Data/Common/DbProviderFactory.cs
-../referencesource/System.Data/System/Data/Common/DbProviderSpecificTypePropertyAttribute.cs
-../referencesource/System.Data/System/Data/Common/DBSchemaRow.cs
-../referencesource/System.Data/System/Data/Common/DBSchemaTable.cs
-../referencesource/System.Data/System/Data/Common/DbTransaction.cs
-../referencesource/System.Data/System/Data/Common/DecimalStorage.cs
-../referencesource/System.Data/System/Data/Common/DoubleStorage.cs
-../referencesource/System.Data/System/Data/Common/FieldNameLookup.cs
-../referencesource/System.Data/System/Data/Common/GreenMethods.cs
-../referencesource/System.Data/System/Data/Common/Groupbybehavior.cs
-../referencesource/System.Data/System/Data/Common/HandlerBase.cs
-../referencesource/System.Data/System/Data/Common/identifiercase.cs
-../referencesource/System.Data/System/Data/Common/Int16Storage.cs
-../referencesource/System.Data/System/Data/Common/Int32Storage.cs
-../referencesource/System.Data/System/Data/Common/Int64Storage.cs
-../referencesource/System.Data/System/Data/Common/MultipartIdentifier.cs
-../referencesource/System.Data/System/Data/Common/NameValuePair.cs
-../referencesource/System.Data/System/Data/Common/NameValuePermission.cs
-../referencesource/System.Data/System/Data/Common/NativeMethods.cs
-../referencesource/System.Data/System/Data/Common/ObjectStorage.cs
-../referencesource/System.Data/System/Data/Common/RowUpdatedEventArgs.cs
-../referencesource/System.Data/System/Data/Common/RowUpdatingEventArgs.cs
-../referencesource/System.Data/System/Data/Common/SafeNativeMethods.cs
-../referencesource/System.Data/System/Data/Common/SByteStorage.cs
-../referencesource/System.Data/System/Data/Common/SchemaTableColumn.cs
-../referencesource/System.Data/System/Data/Common/SchemaTableOptionalColumn.cs
-../referencesource/System.Data/System/Data/Common/SingleStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLConvert.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLBinaryStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQlBooleanStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLBytesStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLByteStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLCharsStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLDateTimeStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLDecimalStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLDoubleStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLGuidStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLInt16Storage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLInt32Storage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLInt64Storage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLMoneyStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLSingleStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SQLStringStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SqlUDTStorage.cs
-../referencesource/System.Data/System/Data/Common/SQLTypes/SqlXmlStorage.cs
-../referencesource/System.Data/System/Data/Common/StringStorage.cs
-../referencesource/System.Data/System/Data/Common/SupportedJoinOperators.cs
-../referencesource/System.Data/System/Data/Common/System.Data_BID.cs
-../referencesource/System.Data/System/Data/Common/TimeSpanStorage.cs
-../referencesource/System.Data/System/Data/Common/UInt16Storage.cs
-../referencesource/System.Data/System/Data/Common/UInt32Storage.cs
-../referencesource/System.Data/System/Data/Common/UInt64Storage.cs
-../referencesource/System.Data/System/Data/Common/UnsafeNativeMethods.cs
-../referencesource/System.Data/System/Data/ConflictOptions.cs
-../referencesource/System.Data/System/Data/ConnectionState.cs
-../referencesource/System.Data/System/Data/ConstraintCollection.cs
-../referencesource/System.Data/System/Data/ConstraintConverter.cs
-../referencesource/System.Data/System/Data/Constraint.cs
-../referencesource/System.Data/System/Data/ConstraintEnumerator.cs
-../referencesource/System.Data/System/Data/DataColumnChangeEvent.cs
-../referencesource/System.Data/System/Data/DataColumnChangeEventHandler.cs
-../referencesource/System.Data/System/Data/DataColumnCollection.cs
-../referencesource/System.Data/System/Data/DataColumn.cs
-../referencesource/System.Data/System/Data/DataColumnPropertyDescriptor.cs
-../referencesource/System.Data/System/Data/DataError.cs
-../referencesource/System.Data/System/Data/DataException.cs
-../referencesource/System.Data/System/Data/DataKey.cs
-../referencesource/System.Data/System/Data/DataRelationCollection.cs
-../referencesource/System.Data/System/Data/DataRelation.cs
-../referencesource/System.Data/System/Data/DataRelationPropertyDescriptor.cs
-../referencesource/System.Data/System/Data/DataRowAction.cs
-../referencesource/System.Data/System/Data/DataRowChangeEvent.cs
-../referencesource/System.Data/System/Data/DataRowChangeEventHandler.cs
-../referencesource/System.Data/System/Data/DataRowCollection.cs
-../referencesource/System.Data/System/Data/DataRowCreatedEventHandler.cs
-../referencesource/System.Data/System/Data/DataRow.cs
-../referencesource/System.Data/System/Data/DataRowState.cs
-../referencesource/System.Data/System/Data/DataRowVersion.cs
-../referencesource/System.Data/System/Data/DataRowView.cs
-../referencesource/System.Data/System/Data/DataSerializationFormat.cs
-../referencesource/System.Data/System/Data/DataSet.cs
-../referencesource/System.Data/System/Data/DataSetDateTime.cs
-../referencesource/System.Data/System/Data/DataSysAttribute.cs
-../referencesource/System.Data/System/Data/DataTableClearEvent.cs
-../referencesource/System.Data/System/Data/DataTableClearEventHandler.cs
-../referencesource/System.Data/System/Data/DataTableCollection.cs
-../referencesource/System.Data/System/Data/DataTable.cs
-../referencesource/System.Data/System/Data/DataTableNewRowEvent.cs
-../referencesource/System.Data/System/Data/DataTableNewRowEventHandler.cs
-../referencesource/System.Data/System/Data/DataTablePropertyDescriptor.cs
-../referencesource/System.Data/System/Data/DataTableReader.cs
-../referencesource/System.Data/System/Data/DataTableReaderListener.cs
-../referencesource/System.Data/System/Data/DataTableTypeConverter.cs
-../referencesource/System.Data/System/Data/DataView.cs
-../referencesource/System.Data/System/Data/DataViewListener.cs
-../referencesource/System.Data/System/Data/DataViewManager.cs
-../referencesource/System.Data/System/Data/DataViewManagerListItemTypeDescriptor.cs
-../referencesource/System.Data/System/Data/DataViewRowState.cs
-../referencesource/System.Data/System/Data/DataViewSettingCollection.cs
-../referencesource/System.Data/System/Data/DataViewSetting.cs
-../referencesource/System.Data/System/Data/DBConcurrencyException.cs
-../referencesource/System.Data/System/Data/dbtype.cs
-../referencesource/System.Data/System/Data/DefaultValueTypeConverter.cs
-../referencesource/System.Data/System/Data/FillErrorEventArgs.cs
-../referencesource/System.Data/System/Data/FillErrorEventHandler.cs
-../referencesource/System.Data/System/Data/Filter/AggregateNode.cs
-../referencesource/System.Data/System/Data/Filter/BinaryNode.cs
-../referencesource/System.Data/System/Data/Filter/ConstNode.cs
-../referencesource/System.Data/System/Data/Filter/DataExpression.cs
-../referencesource/System.Data/System/Data/Filter/ExpressionNode.cs
-../referencesource/System.Data/System/Data/Filter/ExpressionParser.cs
-../referencesource/System.Data/System/Data/Filter/FilterException.cs
-../referencesource/System.Data/System/Data/Filter/FunctionNode.cs
-../referencesource/System.Data/System/Data/Filter/IFilter.cs
-../referencesource/System.Data/System/Data/Filter/LookupNode.cs
-../referencesource/System.Data/System/Data/Filter/NameNode.cs
-../referencesource/System.Data/System/Data/Filter/Operators.cs
-../referencesource/System.Data/System/Data/Filter/UnaryNode.cs
-../referencesource/System.Data/System/Data/Filter/ZeroOpNode.cs
-../referencesource/System.Data/System/Data/ForeignKeyConstraint.cs
-../referencesource/System.Data/System/Data/IColumnMappingCollection.cs
-../referencesource/System.Data/System/Data/IColumnMapping.cs
-../referencesource/System.Data/System/Data/IDataAdapter.cs
-../referencesource/System.Data/System/Data/IDataParameterCollection.cs
-../referencesource/System.Data/System/Data/IDataParameter.cs
-../referencesource/System.Data/System/Data/IDataReader.cs
-../referencesource/System.Data/System/Data/IDataRecord.cs
-../referencesource/System.Data/System/Data/IDbCommand.cs
-../referencesource/System.Data/System/Data/IDbConnection.cs
-../referencesource/System.Data/System/Data/IDbDataAdapter.cs
-../referencesource/System.Data/System/Data/IDbDataParameter.cs
-../referencesource/System.Data/System/Data/IDbTransaction.cs
-../referencesource/System.Data/System/Data/IsolationLevel.cs
-../referencesource/System.Data/System/Data/ITableMappingCollection.cs
-../referencesource/System.Data/System/Data/ITableMapping.cs
-../referencesource/System.Data/System/Data/LoadOption.cs
-../referencesource/System.Data/System/Data/MappingType.cs
-../referencesource/System.Data/System/Data/MergeFailedEvent.cs
-../referencesource/System.Data/System/Data/MergeFailedEventHandler.cs
-../referencesource/System.Data/System/Data/Merger.cs
-../referencesource/System.Data/System/Data/MissingMappingAction.cs
-../referencesource/System.Data/System/Data/MissingSchemaAction.cs
-../referencesource/System.Data/System/Data/Odbc/DbDataRecord.cs
-../referencesource/System.Data/System/Data/Odbc/Odbc32.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcCommandBuilder.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcCommand.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcConnection.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcConnectionFactory.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcConnectionHandle.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcConnectionOpen.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcConnectionPoolProviderInfo.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcConnectionStringbuilder.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcConnectionString.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcDataAdapter.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcDataReader.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcEnvironment.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcEnvironmentHandle.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcErrorCollection.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcError.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcException.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcFactory.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcHandle.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcInfoMessageEvent.cs
-../referencesource/System.Data/System/Data/Odbc/odbcmetadatacollectionnames.cs
-../referencesource/System.Data/System/Data/Odbc/odbcmetadatacolumnnames.cs
-../referencesource/System.Data/System/Data/Odbc/odbcmetadatafactory.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcParameterCollection.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcParameter.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcPermission.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcReferenceCollection.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcRowUpdatingEvent.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcStatementHandle.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcTransaction.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcType.cs
-../referencesource/System.Data/System/Data/Odbc/OdbcUtils.cs
-../referencesource/System.Data/System/Data/OleDb/ColumnBinding.cs
-../referencesource/System.Data/System/Data/OleDb/DBBindings.cs
-../referencesource/System.Data/System/Data/OleDb/DBPropSet.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbCommandBuilder.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbCommand.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbConnection.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbConnectionFactory.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbConnectionInternal.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbConnectionPoolGroupProviderInfo.cs
-../referencesource/System.Data/System/Data/OleDb/OledbConnectionStringbuilder.cs
-../referencesource/System.Data/System/Data/OleDb/oledbconnectionstring.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbDataAdapter.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbDataReader.cs
-../referencesource/System.Data/System/Data/OleDb/OLEDB_Enum.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbEnumerator.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbErrorCollection.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbError.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbException.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbFactory.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbHResult.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbInfoMessageEvent.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbInfoMessageEventHandler.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbLiteral.cs
-../referencesource/System.Data/System/Data/OleDb/oledbmetadatacollectionnames.cs
-../referencesource/System.Data/System/Data/OleDb/oledbmetadatacolumnnames.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbMetaDataFactory.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbParameterCollection.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbParameter.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbPermission.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbPropertySetGuid.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbPropertyStatus.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbReferenceCollection.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbRowUpdatedEvent.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbRowUpdatedEventHandler.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbRowUpdatingEvent.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbRowUpdatingEventHandler.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbSchemaGuid.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbStruct.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbTransaction.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbType.cs
-../referencesource/System.Data/System/Data/OleDb/OLEDB_Util.cs
-../referencesource/System.Data/System/Data/OleDb/OleDbWrapper.cs
-../referencesource/System.Data/System/Data/OleDb/PropertyAttributes.cs
-../referencesource/System.Data/System/Data/OleDb/PropertyIDSet.cs
-../referencesource/System.Data/System/Data/OleDb/PropertyInfoSet.cs
-../referencesource/System.Data/System/Data/OleDb/RowBinding.cs
-../referencesource/System.Data/System/Data/OleDb/SafeHandles.cs
-../referencesource/System.Data/System/Data/OperationAbortedException.cs
-../referencesource/System.Data/System/Data/ParameterDirection.cs
-../referencesource/System.Data/System/Data/PrimaryKeyTypeConverter.cs
-../referencesource/System.Data/System/Data/PropertyCollection.cs
-../referencesource/System.Data/System/Data/ProviderBase/DataReaderContainer.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbBuffer.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionClosed.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionFactory.cs
-# ../referencesource/System.Data/System/Data/ProviderBase/DbConnectionHelper.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionInternal.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolAuthenticationContext.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolAuthenticationContextKey.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolCounters.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPool.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolGroup.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolGroupProviderInfo.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolIdentity.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolOptions.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbConnectionPoolProviderInfo.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbMetaDataCollectionNames.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbMetaDataColumnNames.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbMetaDataFactory.cs
-# ../referencesource/System.Data/System/Data/ProviderBase/DbParameterCollectionHelper.cs
-# ../referencesource/System.Data/System/Data/ProviderBase/DbParameterHelper.cs
-../referencesource/System.Data/System/Data/ProviderBase/DbReferenceCollection.cs
-../referencesource/System.Data/System/Data/ProviderBase/SchemaMapping.cs
-../referencesource/System.Data/System/Data/ProviderBase/TimeoutTimer.cs
-../referencesource/System.Data/System/Data/ProviderBase/WrappedIUnknown.cs
-../referencesource/System.Data/System/Data/Range.cs
-../referencesource/System.Data/System/Data/RbTree.cs
-../referencesource/System.Data/System/Data/RecordManager.cs
-../referencesource/System.Data/System/Data/RecordsAffectedEventArgs.cs
-../referencesource/System.Data/System/Data/RecordsAffectedEventHandler.cs
-../referencesource/System.Data/System/Data/RelatedView.cs
-../referencesource/System.Data/System/Data/RelationshipConverter.cs
-../referencesource/System.Data/System/Data/Rule.cs
-../referencesource/System.Data/System/Data/SchemaSerializationMode.cs
-../referencesource/System.Data/System/Data/SchemaType.cs
-../referencesource/System.Data/System/Data/Select.cs
-../referencesource/System.Data/System/Data/Selection.cs
-../referencesource/System.Data/System/Data/SimpleType.cs
-../referencesource/System.Data/System/Data/SqlDbType.cs
-../referencesource/System.Data/System/Data/StateChangeEvent.cs
-../referencesource/System.Data/System/Data/StateChangeEventHandler.cs
-../referencesource/System.Data/System/Data/StatementType.cs
-../referencesource/System.Data/System/Data/UniqueConstraint.cs
-../referencesource/System.Data/System/Data/UpdateRowSource.cs
-../referencesource/System.Data/System/Data/updatestatus.cs
-../referencesource/System.Data/System/Data/XDRSchema.cs
-../referencesource/System.Data/System/Data/XmlContent.cs
-../referencesource/System.Data/System/Data/XmlDataLoader.cs
-../referencesource/System.Data/System/Data/XMLDiffLoader.cs
-../referencesource/System.Data/System/Data/XmlKeywords.cs
-../referencesource/System.Data/System/Data/XmlReadMode.cs
-../referencesource/System.Data/System/Data/xmlsaver.cs
-../referencesource/System.Data/System/Data/XMLSchema.cs
-../referencesource/System.Data/System/Data/XmlToDatasetMap.cs
-../referencesource/System.Data/System/Data/XmlWriteMode.cs
-../referencesource/System.Data/System/NewXml/BaseTreeIterator.cs
-../referencesource/System.Data/System/NewXml/DataDocumentXPathNavigator.cs
-../referencesource/System.Data/System/NewXml/DataPointer.cs
-../referencesource/System.Data/System/NewXml/DataSetMappper.cs
-../referencesource/System.Data/System/NewXml/IXmlDataVirtualNode.cs
-../referencesource/System.Data/System/NewXml/RegionIterator.cs
-../referencesource/System.Data/System/NewXml/TreeIterator.cs
-../referencesource/System.Data/System/NewXml/XmlBoundElement.cs
-../referencesource/System.Data/System/NewXml/XmlDataDocument.cs
-../referencesource/System.Data/System/NewXml/XmlDataImplementation.cs
-../referencesource/System.Data/System/NewXml/XPathNodePointer.cs
-
-../referencesource/System.Data/System/Data/Sql/IBinarySerialize.cs
-../referencesource/System.Data/System/Data/Sql/invalidudtexception.cs
-../referencesource/System.Data/System/Data/Sql/SqlDataSourceEnumerator.cs
-../referencesource/System.Data/System/Data/Sql/SqlFacetAttribute.cs
-../referencesource/System.Data/System/Data/Sql/SqlFunctionAttribute.cs
-../referencesource/System.Data/System/Data/Sql/SqlGenericUtil.cs
-../referencesource/System.Data/System/Data/Sql/SqlMethodAttribute.cs
-../referencesource/System.Data/System/Data/Sql/SqlNotificationRequest.cs
-../referencesource/System.Data/System/Data/Sql/SqlProcedureAttribute.cs
-../referencesource/System.Data/System/Data/Sql/SqlTriggerAttribute.cs
-../referencesource/System.Data/System/Data/Sql/SqlUserDefinedAggregateAttribute.cs
-../referencesource/System.Data/System/Data/Sql/SqlUserDefinedTypeAttribute.cs
-../referencesource/System.Data/System/Data/Sql/TriggerAction.cs
-
-../referencesource/System.Data/System/Data/SqlClient/ApplicationIntent.cs
-../referencesource/System.Data/System/Data/SqlClient/LocalDBAPI.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlClientEncryptionType.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlClientPermission.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlConnectionString.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlConnectionStringBuilder.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlError.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlErrorCollection.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlInfoMessageEvent.cs
-../referencesource/System.Data/System/Data/SqlClient/SqlUtil.cs
-../referencesource/System.Data/System/Data/SqlClient/TdsEnums.cs
-../referencesource/System.Data/System/Data/SqlClient/TdsParserStaticMethods.cs
-
-../referencesource/System.Data/System/Data/SQLTypes/INullable.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLBinary.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLBoolean.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLByte.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLBytes.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLChars.cs
-../referencesource/System.Data/System/Data/SQLTypes/SqlCharStream.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLDateTime.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLDecimal.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLDouble.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLGuid.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLInt16.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLInt32.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLInt64.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLMoney.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLResource.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLSingle.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLString.cs
-../referencesource/System.Data/System/Data/SQLTypes/SqlTypesSchemaImporter.cs
-../referencesource/System.Data/System/Data/SQLTypes/SQLUtility.cs
-../referencesource/System.Data/System/Data/SQLTypes/SqlXml.cs
</PropertyGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<ItemGroup>\r
- <Compile Include="..\..\..\external\corefx\src\System.IO.Compression\src\System\IO\Compression\Crc32Helper.cs" />\r
+ <Compile Include="..\..\..\external\corefx\src\Common\src\System\Threading\Tasks\TaskToApm.cs" />\r
<Compile Include="..\..\..\external\corefx\src\System.IO.Compression\src\System\IO\Compression\DeflateManaged\BlockType.cs" />\r
<Compile Include="..\..\..\external\corefx\src\System.IO.Compression\src\System\IO\Compression\DeflateManaged\CopyEncoder.cs" />\r
<Compile Include="..\..\..\external\corefx\src\System.IO.Compression\src\System\IO\Compression\DeflateManaged\DeflateInput.cs" />\r
<Compile Include="..\..\build\common\Consts.cs" />\r
<Compile Include="..\..\build\common\SR.cs" />\r
<Compile Include="AssemblyInfo.cs" />\r
+ <Compile Include="corefx\Crc32Helper.cs" />\r
<Compile Include="corefx\SR.cs" />\r
<Compile Include="corefx\ZipArchiveEntry.Mono.cs" />\r
<Compile Include="TypeForwarders.cs" />\r </ItemGroup>\r
AssemblyInfo.cs
TypeForwarders.cs
+corefx/Crc32Helper.cs
corefx/ZipArchiveEntry.Mono.cs
corefx/SR.cs
-../../../external/corefx/src/System.IO.Compression/src/System/IO/Compression/Crc32Helper.cs
+../../../external/corefx/src/Common/src/System/Threading/Tasks/TaskToApm.cs
+
../../../external/corefx/src/System.IO.Compression/src/System/IO/Compression/PositionPreservingWriteOnlyStreamWrapper.cs
../../../external/corefx/src/System.IO.Compression/src/System/IO/Compression/ZipArchive.cs
../../../external/corefx/src/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// File implements Slicing-by-8 CRC Generation, as described in
+// "Novel Table Lookup-Based Algorithms for High-Performance CRC Generation"
+// IEEE TRANSACTIONS ON COMPUTERS, VOL. 57, NO. 11, NOVEMBER 2008
+
+/*
+ * Copyright (c) 2004-2006 Intel Corporation - All Rights Reserved
+ *
+ *
+ * This software program is licensed subject to the BSD License,
+ * available at http://www.opensource.org/licenses/bsd-license.html.
+ */
+
+using System.Diagnostics;
+
+namespace System.IO.Compression
+{
+ /// <summary>
+ /// This class contains a managed Crc32 function as well as an indirection to the Interop.Zlib.Crc32 call.
+ /// Since Desktop compression uses this file alongside the Open ZipArchive, we cannot remove it
+ /// without breaking the Desktop build.
+ ///
+ /// Note that in CoreFX the ZlibCrc32 function is always called.
+ /// </summary>
+ internal static class Crc32Helper
+ {
+ // Calculate CRC based on the old CRC and the new bytes
+ // See RFC1952 for details.
+ public static uint UpdateCrc32(uint crc32, byte[] buffer, int offset, int length)
+ {
+ Debug.Assert((buffer != null) && (offset >= 0) && (length >= 0)
+ && (offset <= buffer.Length - length), "check the caller");
+#if FEATURE_ZLIB
+ return Interop.zlib.crc32(crc32, buffer, offset, length);
+#else
+ return ManagedCrc32(crc32, buffer, offset, length);
+#endif
+
+ }
+
+#if !FEATURE_ZLIB
+
+ // Generated tables for managed crc calculation.
+ // Each table n (starting at 0) contains remainders from the long division of
+ // all possible byte values, shifted by an offset of (n * 4 bits).
+ // The divisor used is the crc32 standard polynomial 0xEDB88320
+ // Please see cited paper for more details.
+ private static readonly uint[] s_crcTable_0 = new uint[256] {
+ 0x00000000u, 0x77073096u, 0xee0e612cu, 0x990951bau, 0x076dc419u,
+ 0x706af48fu, 0xe963a535u, 0x9e6495a3u, 0x0edb8832u, 0x79dcb8a4u,
+ 0xe0d5e91eu, 0x97d2d988u, 0x09b64c2bu, 0x7eb17cbdu, 0xe7b82d07u,
+ 0x90bf1d91u, 0x1db71064u, 0x6ab020f2u, 0xf3b97148u, 0x84be41deu,
+ 0x1adad47du, 0x6ddde4ebu, 0xf4d4b551u, 0x83d385c7u, 0x136c9856u,
+ 0x646ba8c0u, 0xfd62f97au, 0x8a65c9ecu, 0x14015c4fu, 0x63066cd9u,
+ 0xfa0f3d63u, 0x8d080df5u, 0x3b6e20c8u, 0x4c69105eu, 0xd56041e4u,
+ 0xa2677172u, 0x3c03e4d1u, 0x4b04d447u, 0xd20d85fdu, 0xa50ab56bu,
+ 0x35b5a8fau, 0x42b2986cu, 0xdbbbc9d6u, 0xacbcf940u, 0x32d86ce3u,
+ 0x45df5c75u, 0xdcd60dcfu, 0xabd13d59u, 0x26d930acu, 0x51de003au,
+ 0xc8d75180u, 0xbfd06116u, 0x21b4f4b5u, 0x56b3c423u, 0xcfba9599u,
+ 0xb8bda50fu, 0x2802b89eu, 0x5f058808u, 0xc60cd9b2u, 0xb10be924u,
+ 0x2f6f7c87u, 0x58684c11u, 0xc1611dabu, 0xb6662d3du, 0x76dc4190u,
+ 0x01db7106u, 0x98d220bcu, 0xefd5102au, 0x71b18589u, 0x06b6b51fu,
+ 0x9fbfe4a5u, 0xe8b8d433u, 0x7807c9a2u, 0x0f00f934u, 0x9609a88eu,
+ 0xe10e9818u, 0x7f6a0dbbu, 0x086d3d2du, 0x91646c97u, 0xe6635c01u,
+ 0x6b6b51f4u, 0x1c6c6162u, 0x856530d8u, 0xf262004eu, 0x6c0695edu,
+ 0x1b01a57bu, 0x8208f4c1u, 0xf50fc457u, 0x65b0d9c6u, 0x12b7e950u,
+ 0x8bbeb8eau, 0xfcb9887cu, 0x62dd1ddfu, 0x15da2d49u, 0x8cd37cf3u,
+ 0xfbd44c65u, 0x4db26158u, 0x3ab551ceu, 0xa3bc0074u, 0xd4bb30e2u,
+ 0x4adfa541u, 0x3dd895d7u, 0xa4d1c46du, 0xd3d6f4fbu, 0x4369e96au,
+ 0x346ed9fcu, 0xad678846u, 0xda60b8d0u, 0x44042d73u, 0x33031de5u,
+ 0xaa0a4c5fu, 0xdd0d7cc9u, 0x5005713cu, 0x270241aau, 0xbe0b1010u,
+ 0xc90c2086u, 0x5768b525u, 0x206f85b3u, 0xb966d409u, 0xce61e49fu,
+ 0x5edef90eu, 0x29d9c998u, 0xb0d09822u, 0xc7d7a8b4u, 0x59b33d17u,
+ 0x2eb40d81u, 0xb7bd5c3bu, 0xc0ba6cadu, 0xedb88320u, 0x9abfb3b6u,
+ 0x03b6e20cu, 0x74b1d29au, 0xead54739u, 0x9dd277afu, 0x04db2615u,
+ 0x73dc1683u, 0xe3630b12u, 0x94643b84u, 0x0d6d6a3eu, 0x7a6a5aa8u,
+ 0xe40ecf0bu, 0x9309ff9du, 0x0a00ae27u, 0x7d079eb1u, 0xf00f9344u,
+ 0x8708a3d2u, 0x1e01f268u, 0x6906c2feu, 0xf762575du, 0x806567cbu,
+ 0x196c3671u, 0x6e6b06e7u, 0xfed41b76u, 0x89d32be0u, 0x10da7a5au,
+ 0x67dd4accu, 0xf9b9df6fu, 0x8ebeeff9u, 0x17b7be43u, 0x60b08ed5u,
+ 0xd6d6a3e8u, 0xa1d1937eu, 0x38d8c2c4u, 0x4fdff252u, 0xd1bb67f1u,
+ 0xa6bc5767u, 0x3fb506ddu, 0x48b2364bu, 0xd80d2bdau, 0xaf0a1b4cu,
+ 0x36034af6u, 0x41047a60u, 0xdf60efc3u, 0xa867df55u, 0x316e8eefu,
+ 0x4669be79u, 0xcb61b38cu, 0xbc66831au, 0x256fd2a0u, 0x5268e236u,
+ 0xcc0c7795u, 0xbb0b4703u, 0x220216b9u, 0x5505262fu, 0xc5ba3bbeu,
+ 0xb2bd0b28u, 0x2bb45a92u, 0x5cb36a04u, 0xc2d7ffa7u, 0xb5d0cf31u,
+ 0x2cd99e8bu, 0x5bdeae1du, 0x9b64c2b0u, 0xec63f226u, 0x756aa39cu,
+ 0x026d930au, 0x9c0906a9u, 0xeb0e363fu, 0x72076785u, 0x05005713u,
+ 0x95bf4a82u, 0xe2b87a14u, 0x7bb12baeu, 0x0cb61b38u, 0x92d28e9bu,
+ 0xe5d5be0du, 0x7cdcefb7u, 0x0bdbdf21u, 0x86d3d2d4u, 0xf1d4e242u,
+ 0x68ddb3f8u, 0x1fda836eu, 0x81be16cdu, 0xf6b9265bu, 0x6fb077e1u,
+ 0x18b74777u, 0x88085ae6u, 0xff0f6a70u, 0x66063bcau, 0x11010b5cu,
+ 0x8f659effu, 0xf862ae69u, 0x616bffd3u, 0x166ccf45u, 0xa00ae278u,
+ 0xd70dd2eeu, 0x4e048354u, 0x3903b3c2u, 0xa7672661u, 0xd06016f7u,
+ 0x4969474du, 0x3e6e77dbu, 0xaed16a4au, 0xd9d65adcu, 0x40df0b66u,
+ 0x37d83bf0u, 0xa9bcae53u, 0xdebb9ec5u, 0x47b2cf7fu, 0x30b5ffe9u,
+ 0xbdbdf21cu, 0xcabac28au, 0x53b39330u, 0x24b4a3a6u, 0xbad03605u,
+ 0xcdd70693u, 0x54de5729u, 0x23d967bfu, 0xb3667a2eu, 0xc4614ab8u,
+ 0x5d681b02u, 0x2a6f2b94u, 0xb40bbe37u, 0xc30c8ea1u, 0x5a05df1bu,
+ 0x2d02ef8du
+ };
+ private static readonly uint[] s_crcTable_1 = new uint[256] {
+ 0x00000000u, 0x191B3141u, 0x32366282u, 0x2B2D53C3u, 0x646CC504u,
+ 0x7D77F445u, 0x565AA786u, 0x4F4196C7u, 0xC8D98A08u, 0xD1C2BB49u,
+ 0xFAEFE88Au, 0xE3F4D9CBu, 0xACB54F0Cu, 0xB5AE7E4Du, 0x9E832D8Eu,
+ 0x87981CCFu, 0x4AC21251u, 0x53D92310u, 0x78F470D3u, 0x61EF4192u,
+ 0x2EAED755u, 0x37B5E614u, 0x1C98B5D7u, 0x05838496u, 0x821B9859u,
+ 0x9B00A918u, 0xB02DFADBu, 0xA936CB9Au, 0xE6775D5Du, 0xFF6C6C1Cu,
+ 0xD4413FDFu, 0xCD5A0E9Eu, 0x958424A2u, 0x8C9F15E3u, 0xA7B24620u,
+ 0xBEA97761u, 0xF1E8E1A6u, 0xE8F3D0E7u, 0xC3DE8324u, 0xDAC5B265u,
+ 0x5D5DAEAAu, 0x44469FEBu, 0x6F6BCC28u, 0x7670FD69u, 0x39316BAEu,
+ 0x202A5AEFu, 0x0B07092Cu, 0x121C386Du, 0xDF4636F3u, 0xC65D07B2u,
+ 0xED705471u, 0xF46B6530u, 0xBB2AF3F7u, 0xA231C2B6u, 0x891C9175u,
+ 0x9007A034u, 0x179FBCFBu, 0x0E848DBAu, 0x25A9DE79u, 0x3CB2EF38u,
+ 0x73F379FFu, 0x6AE848BEu, 0x41C51B7Du, 0x58DE2A3Cu, 0xF0794F05u,
+ 0xE9627E44u, 0xC24F2D87u, 0xDB541CC6u, 0x94158A01u, 0x8D0EBB40u,
+ 0xA623E883u, 0xBF38D9C2u, 0x38A0C50Du, 0x21BBF44Cu, 0x0A96A78Fu,
+ 0x138D96CEu, 0x5CCC0009u, 0x45D73148u, 0x6EFA628Bu, 0x77E153CAu,
+ 0xBABB5D54u, 0xA3A06C15u, 0x888D3FD6u, 0x91960E97u, 0xDED79850u,
+ 0xC7CCA911u, 0xECE1FAD2u, 0xF5FACB93u, 0x7262D75Cu, 0x6B79E61Du,
+ 0x4054B5DEu, 0x594F849Fu, 0x160E1258u, 0x0F152319u, 0x243870DAu,
+ 0x3D23419Bu, 0x65FD6BA7u, 0x7CE65AE6u, 0x57CB0925u, 0x4ED03864u,
+ 0x0191AEA3u, 0x188A9FE2u, 0x33A7CC21u, 0x2ABCFD60u, 0xAD24E1AFu,
+ 0xB43FD0EEu, 0x9F12832Du, 0x8609B26Cu, 0xC94824ABu, 0xD05315EAu,
+ 0xFB7E4629u, 0xE2657768u, 0x2F3F79F6u, 0x362448B7u, 0x1D091B74u,
+ 0x04122A35u, 0x4B53BCF2u, 0x52488DB3u, 0x7965DE70u, 0x607EEF31u,
+ 0xE7E6F3FEu, 0xFEFDC2BFu, 0xD5D0917Cu, 0xCCCBA03Du, 0x838A36FAu,
+ 0x9A9107BBu, 0xB1BC5478u, 0xA8A76539u, 0x3B83984Bu, 0x2298A90Au,
+ 0x09B5FAC9u, 0x10AECB88u, 0x5FEF5D4Fu, 0x46F46C0Eu, 0x6DD93FCDu,
+ 0x74C20E8Cu, 0xF35A1243u, 0xEA412302u, 0xC16C70C1u, 0xD8774180u,
+ 0x9736D747u, 0x8E2DE606u, 0xA500B5C5u, 0xBC1B8484u, 0x71418A1Au,
+ 0x685ABB5Bu, 0x4377E898u, 0x5A6CD9D9u, 0x152D4F1Eu, 0x0C367E5Fu,
+ 0x271B2D9Cu, 0x3E001CDDu, 0xB9980012u, 0xA0833153u, 0x8BAE6290u,
+ 0x92B553D1u, 0xDDF4C516u, 0xC4EFF457u, 0xEFC2A794u, 0xF6D996D5u,
+ 0xAE07BCE9u, 0xB71C8DA8u, 0x9C31DE6Bu, 0x852AEF2Au, 0xCA6B79EDu,
+ 0xD37048ACu, 0xF85D1B6Fu, 0xE1462A2Eu, 0x66DE36E1u, 0x7FC507A0u,
+ 0x54E85463u, 0x4DF36522u, 0x02B2F3E5u, 0x1BA9C2A4u, 0x30849167u,
+ 0x299FA026u, 0xE4C5AEB8u, 0xFDDE9FF9u, 0xD6F3CC3Au, 0xCFE8FD7Bu,
+ 0x80A96BBCu, 0x99B25AFDu, 0xB29F093Eu, 0xAB84387Fu, 0x2C1C24B0u,
+ 0x350715F1u, 0x1E2A4632u, 0x07317773u, 0x4870E1B4u, 0x516BD0F5u,
+ 0x7A468336u, 0x635DB277u, 0xCBFAD74Eu, 0xD2E1E60Fu, 0xF9CCB5CCu,
+ 0xE0D7848Du, 0xAF96124Au, 0xB68D230Bu, 0x9DA070C8u, 0x84BB4189u,
+ 0x03235D46u, 0x1A386C07u, 0x31153FC4u, 0x280E0E85u, 0x674F9842u,
+ 0x7E54A903u, 0x5579FAC0u, 0x4C62CB81u, 0x8138C51Fu, 0x9823F45Eu,
+ 0xB30EA79Du, 0xAA1596DCu, 0xE554001Bu, 0xFC4F315Au, 0xD7626299u,
+ 0xCE7953D8u, 0x49E14F17u, 0x50FA7E56u, 0x7BD72D95u, 0x62CC1CD4u,
+ 0x2D8D8A13u, 0x3496BB52u, 0x1FBBE891u, 0x06A0D9D0u, 0x5E7EF3ECu,
+ 0x4765C2ADu, 0x6C48916Eu, 0x7553A02Fu, 0x3A1236E8u, 0x230907A9u,
+ 0x0824546Au, 0x113F652Bu, 0x96A779E4u, 0x8FBC48A5u, 0xA4911B66u,
+ 0xBD8A2A27u, 0xF2CBBCE0u, 0xEBD08DA1u, 0xC0FDDE62u, 0xD9E6EF23u,
+ 0x14BCE1BDu, 0x0DA7D0FCu, 0x268A833Fu, 0x3F91B27Eu, 0x70D024B9u,
+ 0x69CB15F8u, 0x42E6463Bu, 0x5BFD777Au, 0xDC656BB5u, 0xC57E5AF4u,
+ 0xEE530937u, 0xF7483876u, 0xB809AEB1u, 0xA1129FF0u, 0x8A3FCC33u,
+ 0x9324FD72u
+ };
+ private static readonly uint[] s_crcTable_2 = new uint[256] {
+ 0x00000000u, 0x01C26A37u, 0x0384D46Eu, 0x0246BE59u, 0x0709A8DCu,
+ 0x06CBC2EBu, 0x048D7CB2u, 0x054F1685u, 0x0E1351B8u, 0x0FD13B8Fu,
+ 0x0D9785D6u, 0x0C55EFE1u, 0x091AF964u, 0x08D89353u, 0x0A9E2D0Au,
+ 0x0B5C473Du, 0x1C26A370u, 0x1DE4C947u, 0x1FA2771Eu, 0x1E601D29u,
+ 0x1B2F0BACu, 0x1AED619Bu, 0x18ABDFC2u, 0x1969B5F5u, 0x1235F2C8u,
+ 0x13F798FFu, 0x11B126A6u, 0x10734C91u, 0x153C5A14u, 0x14FE3023u,
+ 0x16B88E7Au, 0x177AE44Du, 0x384D46E0u, 0x398F2CD7u, 0x3BC9928Eu,
+ 0x3A0BF8B9u, 0x3F44EE3Cu, 0x3E86840Bu, 0x3CC03A52u, 0x3D025065u,
+ 0x365E1758u, 0x379C7D6Fu, 0x35DAC336u, 0x3418A901u, 0x3157BF84u,
+ 0x3095D5B3u, 0x32D36BEAu, 0x331101DDu, 0x246BE590u, 0x25A98FA7u,
+ 0x27EF31FEu, 0x262D5BC9u, 0x23624D4Cu, 0x22A0277Bu, 0x20E69922u,
+ 0x2124F315u, 0x2A78B428u, 0x2BBADE1Fu, 0x29FC6046u, 0x283E0A71u,
+ 0x2D711CF4u, 0x2CB376C3u, 0x2EF5C89Au, 0x2F37A2ADu, 0x709A8DC0u,
+ 0x7158E7F7u, 0x731E59AEu, 0x72DC3399u, 0x7793251Cu, 0x76514F2Bu,
+ 0x7417F172u, 0x75D59B45u, 0x7E89DC78u, 0x7F4BB64Fu, 0x7D0D0816u,
+ 0x7CCF6221u, 0x798074A4u, 0x78421E93u, 0x7A04A0CAu, 0x7BC6CAFDu,
+ 0x6CBC2EB0u, 0x6D7E4487u, 0x6F38FADEu, 0x6EFA90E9u, 0x6BB5866Cu,
+ 0x6A77EC5Bu, 0x68315202u, 0x69F33835u, 0x62AF7F08u, 0x636D153Fu,
+ 0x612BAB66u, 0x60E9C151u, 0x65A6D7D4u, 0x6464BDE3u, 0x662203BAu,
+ 0x67E0698Du, 0x48D7CB20u, 0x4915A117u, 0x4B531F4Eu, 0x4A917579u,
+ 0x4FDE63FCu, 0x4E1C09CBu, 0x4C5AB792u, 0x4D98DDA5u, 0x46C49A98u,
+ 0x4706F0AFu, 0x45404EF6u, 0x448224C1u, 0x41CD3244u, 0x400F5873u,
+ 0x4249E62Au, 0x438B8C1Du, 0x54F16850u, 0x55330267u, 0x5775BC3Eu,
+ 0x56B7D609u, 0x53F8C08Cu, 0x523AAABBu, 0x507C14E2u, 0x51BE7ED5u,
+ 0x5AE239E8u, 0x5B2053DFu, 0x5966ED86u, 0x58A487B1u, 0x5DEB9134u,
+ 0x5C29FB03u, 0x5E6F455Au, 0x5FAD2F6Du, 0xE1351B80u, 0xE0F771B7u,
+ 0xE2B1CFEEu, 0xE373A5D9u, 0xE63CB35Cu, 0xE7FED96Bu, 0xE5B86732u,
+ 0xE47A0D05u, 0xEF264A38u, 0xEEE4200Fu, 0xECA29E56u, 0xED60F461u,
+ 0xE82FE2E4u, 0xE9ED88D3u, 0xEBAB368Au, 0xEA695CBDu, 0xFD13B8F0u,
+ 0xFCD1D2C7u, 0xFE976C9Eu, 0xFF5506A9u, 0xFA1A102Cu, 0xFBD87A1Bu,
+ 0xF99EC442u, 0xF85CAE75u, 0xF300E948u, 0xF2C2837Fu, 0xF0843D26u,
+ 0xF1465711u, 0xF4094194u, 0xF5CB2BA3u, 0xF78D95FAu, 0xF64FFFCDu,
+ 0xD9785D60u, 0xD8BA3757u, 0xDAFC890Eu, 0xDB3EE339u, 0xDE71F5BCu,
+ 0xDFB39F8Bu, 0xDDF521D2u, 0xDC374BE5u, 0xD76B0CD8u, 0xD6A966EFu,
+ 0xD4EFD8B6u, 0xD52DB281u, 0xD062A404u, 0xD1A0CE33u, 0xD3E6706Au,
+ 0xD2241A5Du, 0xC55EFE10u, 0xC49C9427u, 0xC6DA2A7Eu, 0xC7184049u,
+ 0xC25756CCu, 0xC3953CFBu, 0xC1D382A2u, 0xC011E895u, 0xCB4DAFA8u,
+ 0xCA8FC59Fu, 0xC8C97BC6u, 0xC90B11F1u, 0xCC440774u, 0xCD866D43u,
+ 0xCFC0D31Au, 0xCE02B92Du, 0x91AF9640u, 0x906DFC77u, 0x922B422Eu,
+ 0x93E92819u, 0x96A63E9Cu, 0x976454ABu, 0x9522EAF2u, 0x94E080C5u,
+ 0x9FBCC7F8u, 0x9E7EADCFu, 0x9C381396u, 0x9DFA79A1u, 0x98B56F24u,
+ 0x99770513u, 0x9B31BB4Au, 0x9AF3D17Du, 0x8D893530u, 0x8C4B5F07u,
+ 0x8E0DE15Eu, 0x8FCF8B69u, 0x8A809DECu, 0x8B42F7DBu, 0x89044982u,
+ 0x88C623B5u, 0x839A6488u, 0x82580EBFu, 0x801EB0E6u, 0x81DCDAD1u,
+ 0x8493CC54u, 0x8551A663u, 0x8717183Au, 0x86D5720Du, 0xA9E2D0A0u,
+ 0xA820BA97u, 0xAA6604CEu, 0xABA46EF9u, 0xAEEB787Cu, 0xAF29124Bu,
+ 0xAD6FAC12u, 0xACADC625u, 0xA7F18118u, 0xA633EB2Fu, 0xA4755576u,
+ 0xA5B73F41u, 0xA0F829C4u, 0xA13A43F3u, 0xA37CFDAAu, 0xA2BE979Du,
+ 0xB5C473D0u, 0xB40619E7u, 0xB640A7BEu, 0xB782CD89u, 0xB2CDDB0Cu,
+ 0xB30FB13Bu, 0xB1490F62u, 0xB08B6555u, 0xBBD72268u, 0xBA15485Fu,
+ 0xB853F606u, 0xB9919C31u, 0xBCDE8AB4u, 0xBD1CE083u, 0xBF5A5EDAu,
+ 0xBE9834EDu
+ };
+ private static readonly uint[] s_crcTable_3 = new uint[256] {
+ 0x00000000u, 0xB8BC6765u, 0xAA09C88Bu, 0x12B5AFEEu, 0x8F629757u,
+ 0x37DEF032u, 0x256B5FDCu, 0x9DD738B9u, 0xC5B428EFu, 0x7D084F8Au,
+ 0x6FBDE064u, 0xD7018701u, 0x4AD6BFB8u, 0xF26AD8DDu, 0xE0DF7733u,
+ 0x58631056u, 0x5019579Fu, 0xE8A530FAu, 0xFA109F14u, 0x42ACF871u,
+ 0xDF7BC0C8u, 0x67C7A7ADu, 0x75720843u, 0xCDCE6F26u, 0x95AD7F70u,
+ 0x2D111815u, 0x3FA4B7FBu, 0x8718D09Eu, 0x1ACFE827u, 0xA2738F42u,
+ 0xB0C620ACu, 0x087A47C9u, 0xA032AF3Eu, 0x188EC85Bu, 0x0A3B67B5u,
+ 0xB28700D0u, 0x2F503869u, 0x97EC5F0Cu, 0x8559F0E2u, 0x3DE59787u,
+ 0x658687D1u, 0xDD3AE0B4u, 0xCF8F4F5Au, 0x7733283Fu, 0xEAE41086u,
+ 0x525877E3u, 0x40EDD80Du, 0xF851BF68u, 0xF02BF8A1u, 0x48979FC4u,
+ 0x5A22302Au, 0xE29E574Fu, 0x7F496FF6u, 0xC7F50893u, 0xD540A77Du,
+ 0x6DFCC018u, 0x359FD04Eu, 0x8D23B72Bu, 0x9F9618C5u, 0x272A7FA0u,
+ 0xBAFD4719u, 0x0241207Cu, 0x10F48F92u, 0xA848E8F7u, 0x9B14583Du,
+ 0x23A83F58u, 0x311D90B6u, 0x89A1F7D3u, 0x1476CF6Au, 0xACCAA80Fu,
+ 0xBE7F07E1u, 0x06C36084u, 0x5EA070D2u, 0xE61C17B7u, 0xF4A9B859u,
+ 0x4C15DF3Cu, 0xD1C2E785u, 0x697E80E0u, 0x7BCB2F0Eu, 0xC377486Bu,
+ 0xCB0D0FA2u, 0x73B168C7u, 0x6104C729u, 0xD9B8A04Cu, 0x446F98F5u,
+ 0xFCD3FF90u, 0xEE66507Eu, 0x56DA371Bu, 0x0EB9274Du, 0xB6054028u,
+ 0xA4B0EFC6u, 0x1C0C88A3u, 0x81DBB01Au, 0x3967D77Fu, 0x2BD27891u,
+ 0x936E1FF4u, 0x3B26F703u, 0x839A9066u, 0x912F3F88u, 0x299358EDu,
+ 0xB4446054u, 0x0CF80731u, 0x1E4DA8DFu, 0xA6F1CFBAu, 0xFE92DFECu,
+ 0x462EB889u, 0x549B1767u, 0xEC277002u, 0x71F048BBu, 0xC94C2FDEu,
+ 0xDBF98030u, 0x6345E755u, 0x6B3FA09Cu, 0xD383C7F9u, 0xC1366817u,
+ 0x798A0F72u, 0xE45D37CBu, 0x5CE150AEu, 0x4E54FF40u, 0xF6E89825u,
+ 0xAE8B8873u, 0x1637EF16u, 0x048240F8u, 0xBC3E279Du, 0x21E91F24u,
+ 0x99557841u, 0x8BE0D7AFu, 0x335CB0CAu, 0xED59B63Bu, 0x55E5D15Eu,
+ 0x47507EB0u, 0xFFEC19D5u, 0x623B216Cu, 0xDA874609u, 0xC832E9E7u,
+ 0x708E8E82u, 0x28ED9ED4u, 0x9051F9B1u, 0x82E4565Fu, 0x3A58313Au,
+ 0xA78F0983u, 0x1F336EE6u, 0x0D86C108u, 0xB53AA66Du, 0xBD40E1A4u,
+ 0x05FC86C1u, 0x1749292Fu, 0xAFF54E4Au, 0x322276F3u, 0x8A9E1196u,
+ 0x982BBE78u, 0x2097D91Du, 0x78F4C94Bu, 0xC048AE2Eu, 0xD2FD01C0u,
+ 0x6A4166A5u, 0xF7965E1Cu, 0x4F2A3979u, 0x5D9F9697u, 0xE523F1F2u,
+ 0x4D6B1905u, 0xF5D77E60u, 0xE762D18Eu, 0x5FDEB6EBu, 0xC2098E52u,
+ 0x7AB5E937u, 0x680046D9u, 0xD0BC21BCu, 0x88DF31EAu, 0x3063568Fu,
+ 0x22D6F961u, 0x9A6A9E04u, 0x07BDA6BDu, 0xBF01C1D8u, 0xADB46E36u,
+ 0x15080953u, 0x1D724E9Au, 0xA5CE29FFu, 0xB77B8611u, 0x0FC7E174u,
+ 0x9210D9CDu, 0x2AACBEA8u, 0x38191146u, 0x80A57623u, 0xD8C66675u,
+ 0x607A0110u, 0x72CFAEFEu, 0xCA73C99Bu, 0x57A4F122u, 0xEF189647u,
+ 0xFDAD39A9u, 0x45115ECCu, 0x764DEE06u, 0xCEF18963u, 0xDC44268Du,
+ 0x64F841E8u, 0xF92F7951u, 0x41931E34u, 0x5326B1DAu, 0xEB9AD6BFu,
+ 0xB3F9C6E9u, 0x0B45A18Cu, 0x19F00E62u, 0xA14C6907u, 0x3C9B51BEu,
+ 0x842736DBu, 0x96929935u, 0x2E2EFE50u, 0x2654B999u, 0x9EE8DEFCu,
+ 0x8C5D7112u, 0x34E11677u, 0xA9362ECEu, 0x118A49ABu, 0x033FE645u,
+ 0xBB838120u, 0xE3E09176u, 0x5B5CF613u, 0x49E959FDu, 0xF1553E98u,
+ 0x6C820621u, 0xD43E6144u, 0xC68BCEAAu, 0x7E37A9CFu, 0xD67F4138u,
+ 0x6EC3265Du, 0x7C7689B3u, 0xC4CAEED6u, 0x591DD66Fu, 0xE1A1B10Au,
+ 0xF3141EE4u, 0x4BA87981u, 0x13CB69D7u, 0xAB770EB2u, 0xB9C2A15Cu,
+ 0x017EC639u, 0x9CA9FE80u, 0x241599E5u, 0x36A0360Bu, 0x8E1C516Eu,
+ 0x866616A7u, 0x3EDA71C2u, 0x2C6FDE2Cu, 0x94D3B949u, 0x090481F0u,
+ 0xB1B8E695u, 0xA30D497Bu, 0x1BB12E1Eu, 0x43D23E48u, 0xFB6E592Du,
+ 0xE9DBF6C3u, 0x516791A6u, 0xCCB0A91Fu, 0x740CCE7Au, 0x66B96194u,
+ 0xDE0506F1u
+ };
+ private static readonly uint[] s_crcTable_4 = new uint[256] {
+ 0x00000000u, 0x3D6029B0u, 0x7AC05360u, 0x47A07AD0u, 0xF580A6C0u,
+ 0xC8E08F70u, 0x8F40F5A0u, 0xB220DC10u, 0x30704BC1u, 0x0D106271u,
+ 0x4AB018A1u, 0x77D03111u, 0xC5F0ED01u, 0xF890C4B1u, 0xBF30BE61u,
+ 0x825097D1u, 0x60E09782u, 0x5D80BE32u, 0x1A20C4E2u, 0x2740ED52u,
+ 0x95603142u, 0xA80018F2u, 0xEFA06222u, 0xD2C04B92u, 0x5090DC43u,
+ 0x6DF0F5F3u, 0x2A508F23u, 0x1730A693u, 0xA5107A83u, 0x98705333u,
+ 0xDFD029E3u, 0xE2B00053u, 0xC1C12F04u, 0xFCA106B4u, 0xBB017C64u,
+ 0x866155D4u, 0x344189C4u, 0x0921A074u, 0x4E81DAA4u, 0x73E1F314u,
+ 0xF1B164C5u, 0xCCD14D75u, 0x8B7137A5u, 0xB6111E15u, 0x0431C205u,
+ 0x3951EBB5u, 0x7EF19165u, 0x4391B8D5u, 0xA121B886u, 0x9C419136u,
+ 0xDBE1EBE6u, 0xE681C256u, 0x54A11E46u, 0x69C137F6u, 0x2E614D26u,
+ 0x13016496u, 0x9151F347u, 0xAC31DAF7u, 0xEB91A027u, 0xD6F18997u,
+ 0x64D15587u, 0x59B17C37u, 0x1E1106E7u, 0x23712F57u, 0x58F35849u,
+ 0x659371F9u, 0x22330B29u, 0x1F532299u, 0xAD73FE89u, 0x9013D739u,
+ 0xD7B3ADE9u, 0xEAD38459u, 0x68831388u, 0x55E33A38u, 0x124340E8u,
+ 0x2F236958u, 0x9D03B548u, 0xA0639CF8u, 0xE7C3E628u, 0xDAA3CF98u,
+ 0x3813CFCBu, 0x0573E67Bu, 0x42D39CABu, 0x7FB3B51Bu, 0xCD93690Bu,
+ 0xF0F340BBu, 0xB7533A6Bu, 0x8A3313DBu, 0x0863840Au, 0x3503ADBAu,
+ 0x72A3D76Au, 0x4FC3FEDAu, 0xFDE322CAu, 0xC0830B7Au, 0x872371AAu,
+ 0xBA43581Au, 0x9932774Du, 0xA4525EFDu, 0xE3F2242Du, 0xDE920D9Du,
+ 0x6CB2D18Du, 0x51D2F83Du, 0x167282EDu, 0x2B12AB5Du, 0xA9423C8Cu,
+ 0x9422153Cu, 0xD3826FECu, 0xEEE2465Cu, 0x5CC29A4Cu, 0x61A2B3FCu,
+ 0x2602C92Cu, 0x1B62E09Cu, 0xF9D2E0CFu, 0xC4B2C97Fu, 0x8312B3AFu,
+ 0xBE729A1Fu, 0x0C52460Fu, 0x31326FBFu, 0x7692156Fu, 0x4BF23CDFu,
+ 0xC9A2AB0Eu, 0xF4C282BEu, 0xB362F86Eu, 0x8E02D1DEu, 0x3C220DCEu,
+ 0x0142247Eu, 0x46E25EAEu, 0x7B82771Eu, 0xB1E6B092u, 0x8C869922u,
+ 0xCB26E3F2u, 0xF646CA42u, 0x44661652u, 0x79063FE2u, 0x3EA64532u,
+ 0x03C66C82u, 0x8196FB53u, 0xBCF6D2E3u, 0xFB56A833u, 0xC6368183u,
+ 0x74165D93u, 0x49767423u, 0x0ED60EF3u, 0x33B62743u, 0xD1062710u,
+ 0xEC660EA0u, 0xABC67470u, 0x96A65DC0u, 0x248681D0u, 0x19E6A860u,
+ 0x5E46D2B0u, 0x6326FB00u, 0xE1766CD1u, 0xDC164561u, 0x9BB63FB1u,
+ 0xA6D61601u, 0x14F6CA11u, 0x2996E3A1u, 0x6E369971u, 0x5356B0C1u,
+ 0x70279F96u, 0x4D47B626u, 0x0AE7CCF6u, 0x3787E546u, 0x85A73956u,
+ 0xB8C710E6u, 0xFF676A36u, 0xC2074386u, 0x4057D457u, 0x7D37FDE7u,
+ 0x3A978737u, 0x07F7AE87u, 0xB5D77297u, 0x88B75B27u, 0xCF1721F7u,
+ 0xF2770847u, 0x10C70814u, 0x2DA721A4u, 0x6A075B74u, 0x576772C4u,
+ 0xE547AED4u, 0xD8278764u, 0x9F87FDB4u, 0xA2E7D404u, 0x20B743D5u,
+ 0x1DD76A65u, 0x5A7710B5u, 0x67173905u, 0xD537E515u, 0xE857CCA5u,
+ 0xAFF7B675u, 0x92979FC5u, 0xE915E8DBu, 0xD475C16Bu, 0x93D5BBBBu,
+ 0xAEB5920Bu, 0x1C954E1Bu, 0x21F567ABu, 0x66551D7Bu, 0x5B3534CBu,
+ 0xD965A31Au, 0xE4058AAAu, 0xA3A5F07Au, 0x9EC5D9CAu, 0x2CE505DAu,
+ 0x11852C6Au, 0x562556BAu, 0x6B457F0Au, 0x89F57F59u, 0xB49556E9u,
+ 0xF3352C39u, 0xCE550589u, 0x7C75D999u, 0x4115F029u, 0x06B58AF9u,
+ 0x3BD5A349u, 0xB9853498u, 0x84E51D28u, 0xC34567F8u, 0xFE254E48u,
+ 0x4C059258u, 0x7165BBE8u, 0x36C5C138u, 0x0BA5E888u, 0x28D4C7DFu,
+ 0x15B4EE6Fu, 0x521494BFu, 0x6F74BD0Fu, 0xDD54611Fu, 0xE03448AFu,
+ 0xA794327Fu, 0x9AF41BCFu, 0x18A48C1Eu, 0x25C4A5AEu, 0x6264DF7Eu,
+ 0x5F04F6CEu, 0xED242ADEu, 0xD044036Eu, 0x97E479BEu, 0xAA84500Eu,
+ 0x4834505Du, 0x755479EDu, 0x32F4033Du, 0x0F942A8Du, 0xBDB4F69Du,
+ 0x80D4DF2Du, 0xC774A5FDu, 0xFA148C4Du, 0x78441B9Cu, 0x4524322Cu,
+ 0x028448FCu, 0x3FE4614Cu, 0x8DC4BD5Cu, 0xB0A494ECu, 0xF704EE3Cu,
+ 0xCA64C78Cu
+ };
+ private static readonly uint[] s_crcTable_5 = new uint[256] {
+ 0x00000000u, 0xCB5CD3A5u, 0x4DC8A10Bu, 0x869472AEu, 0x9B914216u,
+ 0x50CD91B3u, 0xD659E31Du, 0x1D0530B8u, 0xEC53826Du, 0x270F51C8u,
+ 0xA19B2366u, 0x6AC7F0C3u, 0x77C2C07Bu, 0xBC9E13DEu, 0x3A0A6170u,
+ 0xF156B2D5u, 0x03D6029Bu, 0xC88AD13Eu, 0x4E1EA390u, 0x85427035u,
+ 0x9847408Du, 0x531B9328u, 0xD58FE186u, 0x1ED33223u, 0xEF8580F6u,
+ 0x24D95353u, 0xA24D21FDu, 0x6911F258u, 0x7414C2E0u, 0xBF481145u,
+ 0x39DC63EBu, 0xF280B04Eu, 0x07AC0536u, 0xCCF0D693u, 0x4A64A43Du,
+ 0x81387798u, 0x9C3D4720u, 0x57619485u, 0xD1F5E62Bu, 0x1AA9358Eu,
+ 0xEBFF875Bu, 0x20A354FEu, 0xA6372650u, 0x6D6BF5F5u, 0x706EC54Du,
+ 0xBB3216E8u, 0x3DA66446u, 0xF6FAB7E3u, 0x047A07ADu, 0xCF26D408u,
+ 0x49B2A6A6u, 0x82EE7503u, 0x9FEB45BBu, 0x54B7961Eu, 0xD223E4B0u,
+ 0x197F3715u, 0xE82985C0u, 0x23755665u, 0xA5E124CBu, 0x6EBDF76Eu,
+ 0x73B8C7D6u, 0xB8E41473u, 0x3E7066DDu, 0xF52CB578u, 0x0F580A6Cu,
+ 0xC404D9C9u, 0x4290AB67u, 0x89CC78C2u, 0x94C9487Au, 0x5F959BDFu,
+ 0xD901E971u, 0x125D3AD4u, 0xE30B8801u, 0x28575BA4u, 0xAEC3290Au,
+ 0x659FFAAFu, 0x789ACA17u, 0xB3C619B2u, 0x35526B1Cu, 0xFE0EB8B9u,
+ 0x0C8E08F7u, 0xC7D2DB52u, 0x4146A9FCu, 0x8A1A7A59u, 0x971F4AE1u,
+ 0x5C439944u, 0xDAD7EBEAu, 0x118B384Fu, 0xE0DD8A9Au, 0x2B81593Fu,
+ 0xAD152B91u, 0x6649F834u, 0x7B4CC88Cu, 0xB0101B29u, 0x36846987u,
+ 0xFDD8BA22u, 0x08F40F5Au, 0xC3A8DCFFu, 0x453CAE51u, 0x8E607DF4u,
+ 0x93654D4Cu, 0x58399EE9u, 0xDEADEC47u, 0x15F13FE2u, 0xE4A78D37u,
+ 0x2FFB5E92u, 0xA96F2C3Cu, 0x6233FF99u, 0x7F36CF21u, 0xB46A1C84u,
+ 0x32FE6E2Au, 0xF9A2BD8Fu, 0x0B220DC1u, 0xC07EDE64u, 0x46EAACCAu,
+ 0x8DB67F6Fu, 0x90B34FD7u, 0x5BEF9C72u, 0xDD7BEEDCu, 0x16273D79u,
+ 0xE7718FACu, 0x2C2D5C09u, 0xAAB92EA7u, 0x61E5FD02u, 0x7CE0CDBAu,
+ 0xB7BC1E1Fu, 0x31286CB1u, 0xFA74BF14u, 0x1EB014D8u, 0xD5ECC77Du,
+ 0x5378B5D3u, 0x98246676u, 0x852156CEu, 0x4E7D856Bu, 0xC8E9F7C5u,
+ 0x03B52460u, 0xF2E396B5u, 0x39BF4510u, 0xBF2B37BEu, 0x7477E41Bu,
+ 0x6972D4A3u, 0xA22E0706u, 0x24BA75A8u, 0xEFE6A60Du, 0x1D661643u,
+ 0xD63AC5E6u, 0x50AEB748u, 0x9BF264EDu, 0x86F75455u, 0x4DAB87F0u,
+ 0xCB3FF55Eu, 0x006326FBu, 0xF135942Eu, 0x3A69478Bu, 0xBCFD3525u,
+ 0x77A1E680u, 0x6AA4D638u, 0xA1F8059Du, 0x276C7733u, 0xEC30A496u,
+ 0x191C11EEu, 0xD240C24Bu, 0x54D4B0E5u, 0x9F886340u, 0x828D53F8u,
+ 0x49D1805Du, 0xCF45F2F3u, 0x04192156u, 0xF54F9383u, 0x3E134026u,
+ 0xB8873288u, 0x73DBE12Du, 0x6EDED195u, 0xA5820230u, 0x2316709Eu,
+ 0xE84AA33Bu, 0x1ACA1375u, 0xD196C0D0u, 0x5702B27Eu, 0x9C5E61DBu,
+ 0x815B5163u, 0x4A0782C6u, 0xCC93F068u, 0x07CF23CDu, 0xF6999118u,
+ 0x3DC542BDu, 0xBB513013u, 0x700DE3B6u, 0x6D08D30Eu, 0xA65400ABu,
+ 0x20C07205u, 0xEB9CA1A0u, 0x11E81EB4u, 0xDAB4CD11u, 0x5C20BFBFu,
+ 0x977C6C1Au, 0x8A795CA2u, 0x41258F07u, 0xC7B1FDA9u, 0x0CED2E0Cu,
+ 0xFDBB9CD9u, 0x36E74F7Cu, 0xB0733DD2u, 0x7B2FEE77u, 0x662ADECFu,
+ 0xAD760D6Au, 0x2BE27FC4u, 0xE0BEAC61u, 0x123E1C2Fu, 0xD962CF8Au,
+ 0x5FF6BD24u, 0x94AA6E81u, 0x89AF5E39u, 0x42F38D9Cu, 0xC467FF32u,
+ 0x0F3B2C97u, 0xFE6D9E42u, 0x35314DE7u, 0xB3A53F49u, 0x78F9ECECu,
+ 0x65FCDC54u, 0xAEA00FF1u, 0x28347D5Fu, 0xE368AEFAu, 0x16441B82u,
+ 0xDD18C827u, 0x5B8CBA89u, 0x90D0692Cu, 0x8DD55994u, 0x46898A31u,
+ 0xC01DF89Fu, 0x0B412B3Au, 0xFA1799EFu, 0x314B4A4Au, 0xB7DF38E4u,
+ 0x7C83EB41u, 0x6186DBF9u, 0xAADA085Cu, 0x2C4E7AF2u, 0xE712A957u,
+ 0x15921919u, 0xDECECABCu, 0x585AB812u, 0x93066BB7u, 0x8E035B0Fu,
+ 0x455F88AAu, 0xC3CBFA04u, 0x089729A1u, 0xF9C19B74u, 0x329D48D1u,
+ 0xB4093A7Fu, 0x7F55E9DAu, 0x6250D962u, 0xA90C0AC7u, 0x2F987869u,
+ 0xE4C4ABCCu
+ };
+ private static readonly uint[] s_crcTable_6 = new uint[256] {
+ 0x00000000u, 0xA6770BB4u, 0x979F1129u, 0x31E81A9Du, 0xF44F2413u,
+ 0x52382FA7u, 0x63D0353Au, 0xC5A73E8Eu, 0x33EF4E67u, 0x959845D3u,
+ 0xA4705F4Eu, 0x020754FAu, 0xC7A06A74u, 0x61D761C0u, 0x503F7B5Du,
+ 0xF64870E9u, 0x67DE9CCEu, 0xC1A9977Au, 0xF0418DE7u, 0x56368653u,
+ 0x9391B8DDu, 0x35E6B369u, 0x040EA9F4u, 0xA279A240u, 0x5431D2A9u,
+ 0xF246D91Du, 0xC3AEC380u, 0x65D9C834u, 0xA07EF6BAu, 0x0609FD0Eu,
+ 0x37E1E793u, 0x9196EC27u, 0xCFBD399Cu, 0x69CA3228u, 0x582228B5u,
+ 0xFE552301u, 0x3BF21D8Fu, 0x9D85163Bu, 0xAC6D0CA6u, 0x0A1A0712u,
+ 0xFC5277FBu, 0x5A257C4Fu, 0x6BCD66D2u, 0xCDBA6D66u, 0x081D53E8u,
+ 0xAE6A585Cu, 0x9F8242C1u, 0x39F54975u, 0xA863A552u, 0x0E14AEE6u,
+ 0x3FFCB47Bu, 0x998BBFCFu, 0x5C2C8141u, 0xFA5B8AF5u, 0xCBB39068u,
+ 0x6DC49BDCu, 0x9B8CEB35u, 0x3DFBE081u, 0x0C13FA1Cu, 0xAA64F1A8u,
+ 0x6FC3CF26u, 0xC9B4C492u, 0xF85CDE0Fu, 0x5E2BD5BBu, 0x440B7579u,
+ 0xE27C7ECDu, 0xD3946450u, 0x75E36FE4u, 0xB044516Au, 0x16335ADEu,
+ 0x27DB4043u, 0x81AC4BF7u, 0x77E43B1Eu, 0xD19330AAu, 0xE07B2A37u,
+ 0x460C2183u, 0x83AB1F0Du, 0x25DC14B9u, 0x14340E24u, 0xB2430590u,
+ 0x23D5E9B7u, 0x85A2E203u, 0xB44AF89Eu, 0x123DF32Au, 0xD79ACDA4u,
+ 0x71EDC610u, 0x4005DC8Du, 0xE672D739u, 0x103AA7D0u, 0xB64DAC64u,
+ 0x87A5B6F9u, 0x21D2BD4Du, 0xE47583C3u, 0x42028877u, 0x73EA92EAu,
+ 0xD59D995Eu, 0x8BB64CE5u, 0x2DC14751u, 0x1C295DCCu, 0xBA5E5678u,
+ 0x7FF968F6u, 0xD98E6342u, 0xE86679DFu, 0x4E11726Bu, 0xB8590282u,
+ 0x1E2E0936u, 0x2FC613ABu, 0x89B1181Fu, 0x4C162691u, 0xEA612D25u,
+ 0xDB8937B8u, 0x7DFE3C0Cu, 0xEC68D02Bu, 0x4A1FDB9Fu, 0x7BF7C102u,
+ 0xDD80CAB6u, 0x1827F438u, 0xBE50FF8Cu, 0x8FB8E511u, 0x29CFEEA5u,
+ 0xDF879E4Cu, 0x79F095F8u, 0x48188F65u, 0xEE6F84D1u, 0x2BC8BA5Fu,
+ 0x8DBFB1EBu, 0xBC57AB76u, 0x1A20A0C2u, 0x8816EAF2u, 0x2E61E146u,
+ 0x1F89FBDBu, 0xB9FEF06Fu, 0x7C59CEE1u, 0xDA2EC555u, 0xEBC6DFC8u,
+ 0x4DB1D47Cu, 0xBBF9A495u, 0x1D8EAF21u, 0x2C66B5BCu, 0x8A11BE08u,
+ 0x4FB68086u, 0xE9C18B32u, 0xD82991AFu, 0x7E5E9A1Bu, 0xEFC8763Cu,
+ 0x49BF7D88u, 0x78576715u, 0xDE206CA1u, 0x1B87522Fu, 0xBDF0599Bu,
+ 0x8C184306u, 0x2A6F48B2u, 0xDC27385Bu, 0x7A5033EFu, 0x4BB82972u,
+ 0xEDCF22C6u, 0x28681C48u, 0x8E1F17FCu, 0xBFF70D61u, 0x198006D5u,
+ 0x47ABD36Eu, 0xE1DCD8DAu, 0xD034C247u, 0x7643C9F3u, 0xB3E4F77Du,
+ 0x1593FCC9u, 0x247BE654u, 0x820CEDE0u, 0x74449D09u, 0xD23396BDu,
+ 0xE3DB8C20u, 0x45AC8794u, 0x800BB91Au, 0x267CB2AEu, 0x1794A833u,
+ 0xB1E3A387u, 0x20754FA0u, 0x86024414u, 0xB7EA5E89u, 0x119D553Du,
+ 0xD43A6BB3u, 0x724D6007u, 0x43A57A9Au, 0xE5D2712Eu, 0x139A01C7u,
+ 0xB5ED0A73u, 0x840510EEu, 0x22721B5Au, 0xE7D525D4u, 0x41A22E60u,
+ 0x704A34FDu, 0xD63D3F49u, 0xCC1D9F8Bu, 0x6A6A943Fu, 0x5B828EA2u,
+ 0xFDF58516u, 0x3852BB98u, 0x9E25B02Cu, 0xAFCDAAB1u, 0x09BAA105u,
+ 0xFFF2D1ECu, 0x5985DA58u, 0x686DC0C5u, 0xCE1ACB71u, 0x0BBDF5FFu,
+ 0xADCAFE4Bu, 0x9C22E4D6u, 0x3A55EF62u, 0xABC30345u, 0x0DB408F1u,
+ 0x3C5C126Cu, 0x9A2B19D8u, 0x5F8C2756u, 0xF9FB2CE2u, 0xC813367Fu,
+ 0x6E643DCBu, 0x982C4D22u, 0x3E5B4696u, 0x0FB35C0Bu, 0xA9C457BFu,
+ 0x6C636931u, 0xCA146285u, 0xFBFC7818u, 0x5D8B73ACu, 0x03A0A617u,
+ 0xA5D7ADA3u, 0x943FB73Eu, 0x3248BC8Au, 0xF7EF8204u, 0x519889B0u,
+ 0x6070932Du, 0xC6079899u, 0x304FE870u, 0x9638E3C4u, 0xA7D0F959u,
+ 0x01A7F2EDu, 0xC400CC63u, 0x6277C7D7u, 0x539FDD4Au, 0xF5E8D6FEu,
+ 0x647E3AD9u, 0xC209316Du, 0xF3E12BF0u, 0x55962044u, 0x90311ECAu,
+ 0x3646157Eu, 0x07AE0FE3u, 0xA1D90457u, 0x579174BEu, 0xF1E67F0Au,
+ 0xC00E6597u, 0x66796E23u, 0xA3DE50ADu, 0x05A95B19u, 0x34414184u,
+ 0x92364A30u
+ };
+ private static readonly uint[] s_crcTable_7 = new uint[256] {
+ 0x00000000u, 0xCCAA009Eu, 0x4225077Du, 0x8E8F07E3u, 0x844A0EFAu,
+ 0x48E00E64u, 0xC66F0987u, 0x0AC50919u, 0xD3E51BB5u, 0x1F4F1B2Bu,
+ 0x91C01CC8u, 0x5D6A1C56u, 0x57AF154Fu, 0x9B0515D1u, 0x158A1232u,
+ 0xD92012ACu, 0x7CBB312Bu, 0xB01131B5u, 0x3E9E3656u, 0xF23436C8u,
+ 0xF8F13FD1u, 0x345B3F4Fu, 0xBAD438ACu, 0x767E3832u, 0xAF5E2A9Eu,
+ 0x63F42A00u, 0xED7B2DE3u, 0x21D12D7Du, 0x2B142464u, 0xE7BE24FAu,
+ 0x69312319u, 0xA59B2387u, 0xF9766256u, 0x35DC62C8u, 0xBB53652Bu,
+ 0x77F965B5u, 0x7D3C6CACu, 0xB1966C32u, 0x3F196BD1u, 0xF3B36B4Fu,
+ 0x2A9379E3u, 0xE639797Du, 0x68B67E9Eu, 0xA41C7E00u, 0xAED97719u,
+ 0x62737787u, 0xECFC7064u, 0x205670FAu, 0x85CD537Du, 0x496753E3u,
+ 0xC7E85400u, 0x0B42549Eu, 0x01875D87u, 0xCD2D5D19u, 0x43A25AFAu,
+ 0x8F085A64u, 0x562848C8u, 0x9A824856u, 0x140D4FB5u, 0xD8A74F2Bu,
+ 0xD2624632u, 0x1EC846ACu, 0x9047414Fu, 0x5CED41D1u, 0x299DC2EDu,
+ 0xE537C273u, 0x6BB8C590u, 0xA712C50Eu, 0xADD7CC17u, 0x617DCC89u,
+ 0xEFF2CB6Au, 0x2358CBF4u, 0xFA78D958u, 0x36D2D9C6u, 0xB85DDE25u,
+ 0x74F7DEBBu, 0x7E32D7A2u, 0xB298D73Cu, 0x3C17D0DFu, 0xF0BDD041u,
+ 0x5526F3C6u, 0x998CF358u, 0x1703F4BBu, 0xDBA9F425u, 0xD16CFD3Cu,
+ 0x1DC6FDA2u, 0x9349FA41u, 0x5FE3FADFu, 0x86C3E873u, 0x4A69E8EDu,
+ 0xC4E6EF0Eu, 0x084CEF90u, 0x0289E689u, 0xCE23E617u, 0x40ACE1F4u,
+ 0x8C06E16Au, 0xD0EBA0BBu, 0x1C41A025u, 0x92CEA7C6u, 0x5E64A758u,
+ 0x54A1AE41u, 0x980BAEDFu, 0x1684A93Cu, 0xDA2EA9A2u, 0x030EBB0Eu,
+ 0xCFA4BB90u, 0x412BBC73u, 0x8D81BCEDu, 0x8744B5F4u, 0x4BEEB56Au,
+ 0xC561B289u, 0x09CBB217u, 0xAC509190u, 0x60FA910Eu, 0xEE7596EDu,
+ 0x22DF9673u, 0x281A9F6Au, 0xE4B09FF4u, 0x6A3F9817u, 0xA6959889u,
+ 0x7FB58A25u, 0xB31F8ABBu, 0x3D908D58u, 0xF13A8DC6u, 0xFBFF84DFu,
+ 0x37558441u, 0xB9DA83A2u, 0x7570833Cu, 0x533B85DAu, 0x9F918544u,
+ 0x111E82A7u, 0xDDB48239u, 0xD7718B20u, 0x1BDB8BBEu, 0x95548C5Du,
+ 0x59FE8CC3u, 0x80DE9E6Fu, 0x4C749EF1u, 0xC2FB9912u, 0x0E51998Cu,
+ 0x04949095u, 0xC83E900Bu, 0x46B197E8u, 0x8A1B9776u, 0x2F80B4F1u,
+ 0xE32AB46Fu, 0x6DA5B38Cu, 0xA10FB312u, 0xABCABA0Bu, 0x6760BA95u,
+ 0xE9EFBD76u, 0x2545BDE8u, 0xFC65AF44u, 0x30CFAFDAu, 0xBE40A839u,
+ 0x72EAA8A7u, 0x782FA1BEu, 0xB485A120u, 0x3A0AA6C3u, 0xF6A0A65Du,
+ 0xAA4DE78Cu, 0x66E7E712u, 0xE868E0F1u, 0x24C2E06Fu, 0x2E07E976u,
+ 0xE2ADE9E8u, 0x6C22EE0Bu, 0xA088EE95u, 0x79A8FC39u, 0xB502FCA7u,
+ 0x3B8DFB44u, 0xF727FBDAu, 0xFDE2F2C3u, 0x3148F25Du, 0xBFC7F5BEu,
+ 0x736DF520u, 0xD6F6D6A7u, 0x1A5CD639u, 0x94D3D1DAu, 0x5879D144u,
+ 0x52BCD85Du, 0x9E16D8C3u, 0x1099DF20u, 0xDC33DFBEu, 0x0513CD12u,
+ 0xC9B9CD8Cu, 0x4736CA6Fu, 0x8B9CCAF1u, 0x8159C3E8u, 0x4DF3C376u,
+ 0xC37CC495u, 0x0FD6C40Bu, 0x7AA64737u, 0xB60C47A9u, 0x3883404Au,
+ 0xF42940D4u, 0xFEEC49CDu, 0x32464953u, 0xBCC94EB0u, 0x70634E2Eu,
+ 0xA9435C82u, 0x65E95C1Cu, 0xEB665BFFu, 0x27CC5B61u, 0x2D095278u,
+ 0xE1A352E6u, 0x6F2C5505u, 0xA386559Bu, 0x061D761Cu, 0xCAB77682u,
+ 0x44387161u, 0x889271FFu, 0x825778E6u, 0x4EFD7878u, 0xC0727F9Bu,
+ 0x0CD87F05u, 0xD5F86DA9u, 0x19526D37u, 0x97DD6AD4u, 0x5B776A4Au,
+ 0x51B26353u, 0x9D1863CDu, 0x1397642Eu, 0xDF3D64B0u, 0x83D02561u,
+ 0x4F7A25FFu, 0xC1F5221Cu, 0x0D5F2282u, 0x079A2B9Bu, 0xCB302B05u,
+ 0x45BF2CE6u, 0x89152C78u, 0x50353ED4u, 0x9C9F3E4Au, 0x121039A9u,
+ 0xDEBA3937u, 0xD47F302Eu, 0x18D530B0u, 0x965A3753u, 0x5AF037CDu,
+ 0xFF6B144Au, 0x33C114D4u, 0xBD4E1337u, 0x71E413A9u, 0x7B211AB0u,
+ 0xB78B1A2Eu, 0x39041DCDu, 0xF5AE1D53u, 0x2C8E0FFFu, 0xE0240F61u,
+ 0x6EAB0882u, 0xA201081Cu, 0xA8C40105u, 0x646E019Bu, 0xEAE10678u,
+ 0x264B06E6u
+ };
+
+ private static uint ManagedCrc32(uint crc32, byte[] buffer, int offset, int length)
+ {
+ Debug.Assert(BitConverter.IsLittleEndian, "ManagedCrc32 Expects Little Endian");
+
+ uint term1, term2, term3 = 0;
+
+ crc32 ^= 0xFFFFFFFFU;
+ int runningLength = (length / 8) * 8;
+ int endBytes = length - runningLength;
+
+ for (int i = 0; i < runningLength / 8; i++)
+ {
+ crc32 ^= (uint)(buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24);
+ offset += 4;
+ term1 = s_crcTable_7[crc32 & 0x000000FF] ^
+ s_crcTable_6[(crc32 >> 8) & 0x000000FF];
+ term2 = crc32 >> 16;
+ crc32 = term1 ^
+ s_crcTable_5[term2 & 0x000000FF] ^
+ s_crcTable_4[(term2 >> 8) & 0x000000FF];
+
+
+ term3 = (uint)(buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24);
+ offset += 4;
+ term1 = s_crcTable_3[term3 & 0x000000FF] ^
+ s_crcTable_2[(term3 >> 8) & 0x000000FF];
+ term2 = term3 >> 16;
+ crc32 ^= term1 ^
+ s_crcTable_1[term2 & 0x000000FF] ^
+ s_crcTable_0[(term2 >> 8) & 0x000000FF];
+ }
+
+ for (int i = 0; i < endBytes; i++)
+ {
+ crc32 = s_crcTable_0[(crc32 ^ buffer[offset++]) & 0x000000FF] ^ (crc32 >> 8);
+ }
+
+ crc32 ^= 0xFFFFFFFFU;
+ return crc32;
+ }
+#endif
+ }
+}
\ No newline at end of file
--- /dev/null
+#include mobile_System.IdentityModel.dll.sources

XXX
666</foo></root>
--myboundary--
-<root/><root/><root/>".Replace ("\n", "\r\n").Replace ("XXX\r\n", "\n");
+<root/><root/><root/>".Replace ("\r\n", "\n").Replace ("\n", "\r\n").Replace ("XXX\r\n", "\n");
}
class MyStreamProvider : IStreamProvider
--- /dev/null
+#include mobile_System.Runtime.Serialization.dll.sources
--- /dev/null
+#include mobile_System.ServiceModel.Web.dll.sources
--- /dev/null
+#include mobile_System.ServiceModel.dll.sources
public string[] DependedOn = new string[] {};
}
+ // NOTE: information about these services is current as of Windows 10 / Server 2016,
+ // it may be different and cause test failures on other Windows versions
+
static ServiceInfo DISK_DRIVER_SERVICE = new ServiceInfo { ServiceName = "disk", DisplayName = "Disk Driver", ServiceType = ServiceType.KernelDriver };
static ServiceInfo ROUTING_AND_REMOTE_ACCESS_SERVICE = new ServiceInfo { ServiceName = "RemoteAccess", DisplayName = "Routing and Remote Access", DependedOn = new [] { "bfe", "http", "rasman", "rpcss" } };
static ServiceInfo SECONDARY_LOGON_SERVICE = new ServiceInfo { ServiceName = "seclogon", DisplayName = "Secondary Logon", Dependents = new [] { "te.service" } };
static ServiceInfo SECURITY_ACCOUNTS_MANAGER_SERVICE = new ServiceInfo { ServiceName = "SamSs", DisplayName = "Security Accounts Manager", Dependents = new [] { "browser", "ktmrm", "lanmanserver", "msdtc" }, DependedOn = new [] { "rpcss" } };
+ static ServiceInfo COMPLUS_EVENTSYSTEM_SERVICE = new ServiceInfo { ServiceName = "EventSystem", DisplayName = "COM+ Event System", ServiceType = ServiceType.Win32ShareProcess, Dependents = new [] { "comsysapp", "sens" }, DependedOn = new [] { "rpcss" } };
static ServiceInfo WINDOWS_IMAGE_ACQUISITION_SERVICE = new ServiceInfo { ServiceName = "stisvc", DisplayName = "Windows Image Acquisition (WIA)", ServiceType = ServiceType.Win32OwnProcess, DependedOn = new [] { "rpcss" } };
static ServiceInfo WINDOWS_SEARCH_SERVICE = new ServiceInfo { ServiceName = "WSearch", DisplayName = "Windows Search", ServiceType = ServiceType.Win32OwnProcess, Dependents = new [] { "wmpnetworksvc", "workfolderssvc" }, DependedOn = new [] { "rpcss" } };
static ServiceInfo WINDOWS_TIME_SERVICE = new ServiceInfo { ServiceName = "W32Time", DisplayName = "Windows Time" };
static ServiceInfo SHARE_PROCESS_SERVICE = WORKSTATION_SERVICE;
static ServiceInfo SERVICE_1_WITH_DEPENDENTS_AND_DEPENDED_ON = SECURITY_ACCOUNTS_MANAGER_SERVICE;
- static ServiceInfo SERVICE_2_WITH_DEPENDENTS_AND_DEPENDED_ON = WINDOWS_SEARCH_SERVICE;
+ static ServiceInfo SERVICE_2_WITH_DEPENDENTS_AND_DEPENDED_ON = COMPLUS_EVENTSYSTEM_SERVICE;
static ServiceInfo SERVICE_3_WITH_DEPENDENTS_AND_DEPENDED_ON = WORKSTATION_SERVICE;
static ServiceInfo SERVICE_WITH_MANY_DEPENDENTS = WORKSTATION_SERVICE;
namespace System.Transactions
{
public delegate Transaction HostCurrentTransactionCallback ();
- public delegate void TransactionCompletedEventHandler (object o,
+ public delegate void TransactionCompletedEventHandler (object sender,
TransactionEventArgs e);
- public delegate void TransactionStartedEventHandler (object o,
+ public delegate void TransactionStartedEventHandler (object sender,
TransactionEventArgs e);
}
return true;
}
+ public void SetDistributedTransactionIdentifier (IPromotableSinglePhaseNotification promotableNotification, Guid distributedTransactionIdentifier)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public bool EnlistPromotableSinglePhase (IPromotableSinglePhaseNotification promotableSinglePhaseNotification, Guid promoterType)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public byte[] GetPromotedToken ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public Guid PromoterType
+ {
+ get { throw new NotImplementedException (); }
+ }
+
[MonoTODO ("EnlistmentOptions being ignored")]
public Enlistment EnlistVolatile (
IEnlistmentNotification notification,
[Serializable]
public class TransactionException : SystemException
{
- protected TransactionException ()
+ public TransactionException ()
{
}
[Serializable]
public class TransactionInDoubtException : TransactionException
{
- protected TransactionInDoubtException ()
+ public TransactionInDoubtException ()
{
}
[MonoTODO]
public static class TransactionInterop
{
+ public static readonly Guid PromoterTypeDtc = new Guid ("14229753-FFE1-428D-82B7-DF73045CB8DA");
+
[MonoTODO]
public static IDtcTransaction GetDtcTransaction (Transaction transaction)
{
[Serializable]
public class TransactionManagerCommunicationException : TransactionException
{
- protected TransactionManagerCommunicationException ()
+ public TransactionManagerCommunicationException ()
{
}
[Serializable]
public class TransactionPromotionException : TransactionException
{
- protected TransactionPromotionException ()
+ public TransactionPromotionException ()
{
}
TransactionManager.DefaultTimeout, TransactionScopeAsyncFlowOption.Suppress);
}
+ public TransactionScope (Transaction transactionToUse,
+ TransactionScopeAsyncFlowOption asyncFlowOption)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public TransactionScope (Transaction transactionToUse,
+ TimeSpan scopeTimeout,
+ TransactionScopeAsyncFlowOption asyncFlowOption)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public TransactionScope (TransactionScopeOption scopeOption,
+ TransactionOptions transactionOptions,
+ TransactionScopeAsyncFlowOption asyncFlowOption)
+ {
+ throw new NotImplementedException ();
+ }
+
void Initialize (TransactionScopeOption scopeOption,
Transaction tx, TransactionOptions options,
DTCOption interop, TimeSpan timeout, TransactionScopeAsyncFlowOption asyncFlow)
[assembly: ComCompatibleVersion (1, 0, 3300, 0)]
[assembly: AllowPartiallyTrustedCallers]
-[assembly: SecurityCritical (SecurityCriticalScope.Explicit)]
-
// FIXME: We get collisions with this internalsVisibleTo because of Consts.cs and MonoTodo
//[assembly: InternalsVisibleTo ("System.ServiceModel.Web, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
string html = @"<span class=""activeCssClass"">
<span class=""field"">Active</span>:";
- Assert.IsTrue (p.IndexOf (html) != -1, "#Y1");
+ Assert.IsTrue (p.IndexOf (html.Replace ("\r\n", "\n")) != -1, "#Y1");
}
static void CssClass_OnLoad (Page p)
string pageHtml = t.Run ();
string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
- Assert.AreEqual (originalHtml_1, renderedHtml, "#A1");
+ Assert.AreEqual (originalHtml_1.Replace ("\r\n", "\n"), renderedHtml, "#A1");
FormRequest fr = new FormRequest (t.Response, "form1");
fr.Controls.Add ("__EVENTTARGET");
pageHtml = t.Run ();
renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
- Assert.AreEqual (originalHtml_2, renderedHtml, "#A2");
+ Assert.AreEqual (originalHtml_2.Replace ("\r\n", "\n"), renderedHtml, "#A2");
}
[Test (Description="Bug #535701, test 2")]
string pageHtml = t.Run ();
string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
- Assert.AreEqual (originalHtml_1, renderedHtml, "#A1");
+ Assert.AreEqual (originalHtml_1.Replace ("\r\n", "\n"), renderedHtml, "#A1");
FormRequest fr = new FormRequest (t.Response, "form1");
fr.Controls.Add ("__EVENTTARGET");
pageHtml = t.Run ();
renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
- Assert.AreEqual (originalHtml_2, renderedHtml, "#A2");
+ Assert.AreEqual (originalHtml_2.Replace ("\r\n", "\n"), renderedHtml, "#A2");
}
[Test (Description="Bug #604053")]
--- /dev/null
+#include mobile_System.Web.Services.dll.sources
System.Web.UI.WebControls/RangeValidatorTest.cs
System.Web.UI.WebControls/RectangleHotSpotTest.cs
System.Web.UI.WebControls/RegularExpressionValidatorTest.cs
-System.Web.UI.WebControls/RepeatInfoTest.auto.cs
System.Web.UI.WebControls/RepeatInfoTest.auto.4.0.cs
System.Web.UI.WebControls/RepeatInfoTest.cs
System.Web.UI.WebControls/RepeatInfoUser.cs
string originalHtml = @"<!--[if IE 6]>
<link rel=""styleheet"" type=""text/css"" href=""~/compat-ie6.css""></link>
<![endif]-->";
- HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
+ HtmlDiff.AssertAreEqual (originalHtml.Replace ("\r\n","\n"), renderedHtml, "#A1");
}
[Test (Description="Bug #400807")]
string originalHtml = @"<!-- comment start
<input id=""testBox"" type=""checkbox"" name=""testBox"" />
comment end -->";
- HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
+ HtmlDiff.AssertAreEqual (originalHtml.Replace ("\r\n","\n"), renderedHtml, "#A1");
}
[Test]
<td colspan=""0"" class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#0");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#0");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(2,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(4,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#2");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#2");
}
[Test]
<td colspan=""10"" class=""Footer-1"">(10,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#3");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#3");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#4");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#4");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(10,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#5");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#5");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(8,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#6");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#6");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(14,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#7");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#7");
}
[Test]
<td colspan=""6"" class=""Footer-1"">(18,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#8");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#8");
}
[Test]
<td colspan=""6"" class=""Footer-1"">(14,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#9");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#9");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, true);
string exp = @"(0,Header,-1)(1,Footer,-1)";
- Assert.AreEqual (exp, v, "#10");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#10");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Footer,-1)";
- Assert.AreEqual (exp, v, "#11");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#11");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Footer,-1)";
- Assert.AreEqual (exp, v, "#12");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#12");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)(9,Item,4)(10,Footer,-1)";
- Assert.AreEqual (exp, v, "#13");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#13");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, true);
string exp = @"(0,Header,-1)(1,Footer,-1)";
- Assert.AreEqual (exp, v, "#14");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#14");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)(9,Item,4)(10,Footer,-1)";
- Assert.AreEqual (exp, v, "#15");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#15");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,2)(4,Separator,2)(5,Item,1)(6,Separator,1)(7,Item,3)(8,Footer,-1)";
- Assert.AreEqual (exp, v, "#16");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#16");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,4)(4,Separator,4)(5,Item,1)(6,Separator,1)(7,Item,5)(8,Separator,5)(9,Item,2)(10,Separator,2)(11,Item,6)(12,Item,3)(13,Separator,3)(14,Footer,-1)";
- Assert.AreEqual (exp, v, "#17");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#17");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,3)(4,Separator,3)(5,Item,6)(6,Separator,6)(7,Item,1)(8,Separator,1)(9,Item,4)(10,Separator,4)(11,Item,7)(12,Separator,7)(13,Item,2)(14,Separator,2)(15,Item,5)(16,Separator,5)(17,Item,8)(18,Footer,-1)";
- Assert.AreEqual (exp, v, "#18");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#18");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,3)(4,Separator,3)(5,Item,5)(6,Separator,5)(7,Item,1)(8,Separator,1)(9,Item,4)(10,Separator,4)(11,Item,6)(12,Item,2)(13,Separator,2)(14,Footer,-1)";
- Assert.AreEqual (exp, v, "#19");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#19");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#20");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#20");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#21");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#21");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#22");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#22");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)(9,Item,4)(10,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#23");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#23");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#24");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#24");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)<br />(3,Item,1)(4,Separator,1)<br />(5,Item,2)(6,Separator,2)<br />(7,Item,3)(8,Separator,3)<br />(9,Item,4)<br />(10,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#25");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#25");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)<br />(5,Item,2)(6,Separator,2)(7,Item,3)<br />(8,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#26");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#26");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)<br />(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)<br />(9,Item,4)(10,Separator,4)(11,Item,5)(12,Separator,5)<br />(13,Item,6)<br />(14,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#27");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#27");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, true);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)<br />(7,Item,3)(8,Separator,3)(9,Item,4)(10,Separator,4)(11,Item,5)(12,Separator,5)<br />(13,Item,6)(14,Separator,6)(15,Item,7)(16,Separator,7)(17,Item,8)<br />(18,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#28");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#28");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, true);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)<br />(7,Item,3)(8,Separator,3)(9,Item,4)(10,Separator,4)(11,Item,5)(12,Separator,5)<br />(13,Item,6)<br />(14,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#29");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#29");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, true);
string exp = @"(0,Header,-1)(1,Footer,-1)";
- Assert.AreEqual (exp, v, "#30");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#30");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Footer,-1)";
- Assert.AreEqual (exp, v, "#31");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#31");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Footer,-1)";
- Assert.AreEqual (exp, v, "#32");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#32");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)(9,Item,4)(10,Footer,-1)";
- Assert.AreEqual (exp, v, "#33");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#33");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, true);
string exp = @"(0,Header,-1)(1,Footer,-1)";
- Assert.AreEqual (exp, v, "#34");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#34");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)(9,Item,4)(10,Footer,-1)";
- Assert.AreEqual (exp, v, "#35");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#35");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,2)(4,Separator,2)(5,Item,1)(6,Separator,1)(7,Item,3)(8,Footer,-1)";
- Assert.AreEqual (exp, v, "#36");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#36");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,4)(4,Separator,4)(5,Item,1)(6,Separator,1)(7,Item,5)(8,Separator,5)(9,Item,2)(10,Separator,2)(11,Item,6)(12,Item,3)(13,Separator,3)(14,Footer,-1)";
- Assert.AreEqual (exp, v, "#37");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#37");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,3)(4,Separator,3)(5,Item,6)(6,Separator,6)(7,Item,1)(8,Separator,1)(9,Item,4)(10,Separator,4)(11,Item,7)(12,Separator,7)(13,Item,2)(14,Separator,2)(15,Item,5)(16,Separator,5)(17,Item,8)(18,Footer,-1)";
- Assert.AreEqual (exp, v, "#38");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#38");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,3)(4,Separator,3)(5,Item,5)(6,Separator,5)(7,Item,1)(8,Separator,1)(9,Item,4)(10,Separator,4)(11,Item,6)(12,Item,2)(13,Separator,2)(14,Footer,-1)";
- Assert.AreEqual (exp, v, "#39");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#39");
}
[Test]
<td colspan=""0"" class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#80");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#80");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(2,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#81");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#81");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(4,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#82");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#82");
}
[Test]
<td colspan=""10"" class=""Footer-1"">(10,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#83");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#83");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#84");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#84");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(10,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#85");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#85");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(8,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#86");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#86");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(14,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#87");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#87");
}
[Test]
<td colspan=""6"" class=""Footer-1"">(18,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#88");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#88");
}
[Test]
<td colspan=""6"" class=""Footer-1"">(14,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#89");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#89");
}
[Test]
<td class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#90");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#90");
}
[Test]
<td class=""Footer-1"">(2,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#91");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#91");
}
[Test]
<td class=""Footer-1"">(4,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#92");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#92");
}
[Test]
<td class=""Footer-1"">(10,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#93");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#93");
}
[Test]
<td class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#94");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#94");
}
[Test]
<td class=""Footer-1"">(10,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#95");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#95");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(8,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#96");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#96");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(14,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#97");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#97");
}
[Test]
<td colspan=""6"" class=""Footer-1"">(18,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#98");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#98");
}
[Test]
<td colspan=""6"" class=""Footer-1"">(14,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#99");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#99");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#100");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#100");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#101");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#101");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#102");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#102");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)(9,Item,4)(10,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#103");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#103");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#104");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#104");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)<br />(3,Item,1)(4,Separator,1)<br />(5,Item,2)(6,Separator,2)<br />(7,Item,3)(8,Separator,3)<br />(9,Item,4)<br />(10,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#105");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#105");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)<br />(5,Item,2)(6,Separator,2)(7,Item,3)<br />(8,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#106");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#106");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)<br />(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)<br />(9,Item,4)(10,Separator,4)(11,Item,5)(12,Separator,5)<br />(13,Item,6)<br />(14,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#107");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#107");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)<br />(7,Item,3)(8,Separator,3)(9,Item,4)(10,Separator,4)(11,Item,5)(12,Separator,5)<br />(13,Item,6)(14,Separator,6)(15,Item,7)(16,Separator,7)(17,Item,8)<br />(18,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#108");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#108");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)<br />(7,Item,3)(8,Separator,3)(9,Item,4)(10,Separator,4)(11,Item,5)(12,Separator,5)<br />(13,Item,6)<br />(14,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#109");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#109");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#110");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#110");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#111");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#111");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Separator,0)<br />(3,Item,1)<br />(4,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#112");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#112");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Separator,0)<br />(3,Item,1)<br />(4,Separator,1)<br />(5,Item,2)<br />(6,Separator,2)<br />(7,Item,3)<br />(8,Separator,3)<br />(9,Item,4)<br />(10,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#113");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#113");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#114");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#114");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Separator,0)<br />(3,Item,1)<br />(4,Separator,1)<br />(5,Item,2)<br />(6,Separator,2)<br />(7,Item,3)<br />(8,Separator,3)<br />(9,Item,4)<br />(10,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#115");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#115");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,2)(4,Separator,2)<br />(5,Item,1)(6,Separator,1)(7,Item,3)<br />(8,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#116");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#116");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,4)(4,Separator,4)<br />(5,Item,1)(6,Separator,1)(7,Item,5)(8,Separator,5)<br />(9,Item,2)(10,Separator,2)(11,Item,6)<br />(12,Item,3)(13,Separator,3)<br />(14,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#117");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#117");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,3)(4,Separator,3)(5,Item,6)(6,Separator,6)<br />(7,Item,1)(8,Separator,1)(9,Item,4)(10,Separator,4)(11,Item,7)(12,Separator,7)<br />(13,Item,2)(14,Separator,2)(15,Item,5)(16,Separator,5)(17,Item,8)<br />(18,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#118");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#118");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, true);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,3)(4,Separator,3)(5,Item,5)(6,Separator,5)<br />(7,Item,1)(8,Separator,1)(9,Item,4)(10,Separator,4)(11,Item,6)<br />(12,Item,2)(13,Separator,2)<br />(14,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#119");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#119");
}
[Test]
<td colspan=""0"" class=""Footer-1"">(0,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#160");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#160");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#161");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#161");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(3,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#162");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#162");
}
[Test]
<td colspan=""10"" class=""Footer-1"">(9,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#163");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#163");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(0,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#164");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#164");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(9,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#165");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#165");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(7,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#166");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#166");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(13,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#167");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#167");
}
[Test]
<td colspan=""6"" class=""Footer-1"">(17,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#168");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#168");
}
[Test]
<td colspan=""6"" class=""Footer-1"">(13,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#169");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#169");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, true);
string exp = @"(0,Footer,-1)";
- Assert.AreEqual (exp, v, "#170");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#170");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, true);
string exp = @"(0,Item,0)(1,Footer,-1)";
- Assert.AreEqual (exp, v, "#171");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#171");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,1)(3,Footer,-1)";
- Assert.AreEqual (exp, v, "#172");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#172");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)(8,Item,4)(9,Footer,-1)";
- Assert.AreEqual (exp, v, "#173");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#173");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, true);
string exp = @"(0,Footer,-1)";
- Assert.AreEqual (exp, v, "#174");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#174");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)(8,Item,4)(9,Footer,-1)";
- Assert.AreEqual (exp, v, "#175");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#175");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,2)(3,Separator,2)(4,Item,1)(5,Separator,1)(6,Item,3)(7,Footer,-1)";
- Assert.AreEqual (exp, v, "#176");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#176");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,4)(3,Separator,4)(4,Item,1)(5,Separator,1)(6,Item,5)(7,Separator,5)(8,Item,2)(9,Separator,2)(10,Item,6)(11,Item,3)(12,Separator,3)(13,Footer,-1)";
- Assert.AreEqual (exp, v, "#177");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#177");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,3)(3,Separator,3)(4,Item,6)(5,Separator,6)(6,Item,1)(7,Separator,1)(8,Item,4)(9,Separator,4)(10,Item,7)(11,Separator,7)(12,Item,2)(13,Separator,2)(14,Item,5)(15,Separator,5)(16,Item,8)(17,Footer,-1)";
- Assert.AreEqual (exp, v, "#178");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#178");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,3)(3,Separator,3)(4,Item,5)(5,Separator,5)(6,Item,1)(7,Separator,1)(8,Item,4)(9,Separator,4)(10,Item,6)(11,Item,2)(12,Separator,2)(13,Footer,-1)";
- Assert.AreEqual (exp, v, "#179");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#179");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#180");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#180");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#181");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#181");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)(3,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#182");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#182");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)(8,Item,4)(9,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#183");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#183");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#184");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#184");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)<br />(2,Item,1)(3,Separator,1)<br />(4,Item,2)(5,Separator,2)<br />(6,Item,3)(7,Separator,3)<br />(8,Item,4)<br />(9,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#185");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#185");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)<br />(4,Item,2)(5,Separator,2)(6,Item,3)<br />(7,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#186");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#186");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)<br />(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)<br />(8,Item,4)(9,Separator,4)(10,Item,5)(11,Separator,5)<br />(12,Item,6)<br />(13,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#187");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#187");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, true);
string exp = @"<span>(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)<br />(6,Item,3)(7,Separator,3)(8,Item,4)(9,Separator,4)(10,Item,5)(11,Separator,5)<br />(12,Item,6)(13,Separator,6)(14,Item,7)(15,Separator,7)(16,Item,8)<br />(17,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#188");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#188");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, true);
string exp = @"<span>(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)<br />(6,Item,3)(7,Separator,3)(8,Item,4)(9,Separator,4)(10,Item,5)(11,Separator,5)<br />(12,Item,6)<br />(13,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#189");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#189");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, true);
string exp = @"(0,Footer,-1)";
- Assert.AreEqual (exp, v, "#190");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#190");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, true);
string exp = @"(0,Item,0)(1,Footer,-1)";
- Assert.AreEqual (exp, v, "#191");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#191");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,1)(3,Footer,-1)";
- Assert.AreEqual (exp, v, "#192");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#192");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)(8,Item,4)(9,Footer,-1)";
- Assert.AreEqual (exp, v, "#193");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#193");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, true);
string exp = @"(0,Footer,-1)";
- Assert.AreEqual (exp, v, "#194");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#194");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)(8,Item,4)(9,Footer,-1)";
- Assert.AreEqual (exp, v, "#195");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#195");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,2)(3,Separator,2)(4,Item,1)(5,Separator,1)(6,Item,3)(7,Footer,-1)";
- Assert.AreEqual (exp, v, "#196");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#196");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,4)(3,Separator,4)(4,Item,1)(5,Separator,1)(6,Item,5)(7,Separator,5)(8,Item,2)(9,Separator,2)(10,Item,6)(11,Item,3)(12,Separator,3)(13,Footer,-1)";
- Assert.AreEqual (exp, v, "#197");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#197");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,3)(3,Separator,3)(4,Item,6)(5,Separator,6)(6,Item,1)(7,Separator,1)(8,Item,4)(9,Separator,4)(10,Item,7)(11,Separator,7)(12,Item,2)(13,Separator,2)(14,Item,5)(15,Separator,5)(16,Item,8)(17,Footer,-1)";
- Assert.AreEqual (exp, v, "#198");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#198");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,3)(3,Separator,3)(4,Item,5)(5,Separator,5)(6,Item,1)(7,Separator,1)(8,Item,4)(9,Separator,4)(10,Item,6)(11,Item,2)(12,Separator,2)(13,Footer,-1)";
- Assert.AreEqual (exp, v, "#199");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#199");
}
[Test]
<td colspan=""0"" class=""Footer-1"">(0,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#240");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#240");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#241");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#241");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(3,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#242");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#242");
}
[Test]
<td colspan=""10"" class=""Footer-1"">(9,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#243");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#243");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(0,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#244");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#244");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(9,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#245");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#245");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(7,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#246");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#246");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(13,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#247");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#247");
}
[Test]
<td colspan=""6"" class=""Footer-1"">(17,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#248");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#248");
}
[Test]
<td colspan=""6"" class=""Footer-1"">(13,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#249");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#249");
}
[Test]
<td class=""Footer-1"">(0,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#250");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#250");
}
[Test]
<td class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#251");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#251");
}
[Test]
<td class=""Footer-1"">(3,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#252");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#252");
}
[Test]
<td class=""Footer-1"">(9,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#253");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#253");
}
[Test]
<td class=""Footer-1"">(0,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#254");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#254");
}
[Test]
<td class=""Footer-1"">(9,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#255");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#255");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(7,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#256");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#256");
}
[Test]
<td colspan=""4"" class=""Footer-1"">(13,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#257");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#257");
}
[Test]
<td colspan=""6"" class=""Footer-1"">(17,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#258");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#258");
}
[Test]
<td colspan=""6"" class=""Footer-1"">(13,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#259");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#259");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#260");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#260");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#261");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#261");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)(3,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#262");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#262");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)(8,Item,4)(9,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#263");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#263");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#264");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#264");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)<br />(2,Item,1)(3,Separator,1)<br />(4,Item,2)(5,Separator,2)<br />(6,Item,3)(7,Separator,3)<br />(8,Item,4)<br />(9,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#265");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#265");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)<br />(4,Item,2)(5,Separator,2)(6,Item,3)<br />(7,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#266");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#266");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)<br />(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)<br />(8,Item,4)(9,Separator,4)(10,Item,5)(11,Separator,5)<br />(12,Item,6)<br />(13,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#267");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#267");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span>(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)<br />(6,Item,3)(7,Separator,3)(8,Item,4)(9,Separator,4)(10,Item,5)(11,Separator,5)<br />(12,Item,6)(13,Separator,6)(14,Item,7)(15,Separator,7)(16,Item,8)<br />(17,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#268");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#268");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span>(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)<br />(6,Item,3)(7,Separator,3)(8,Item,4)(9,Separator,4)(10,Item,5)(11,Separator,5)<br />(12,Item,6)<br />(13,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#269");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#269");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#270");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#270");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#271");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#271");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Separator,0)<br />(2,Item,1)<br />(3,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#272");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#272");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Separator,0)<br />(2,Item,1)<br />(3,Separator,1)<br />(4,Item,2)<br />(5,Separator,2)<br />(6,Item,3)<br />(7,Separator,3)<br />(8,Item,4)<br />(9,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#273");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#273");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#274");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#274");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Separator,0)<br />(2,Item,1)<br />(3,Separator,1)<br />(4,Item,2)<br />(5,Separator,2)<br />(6,Item,3)<br />(7,Separator,3)<br />(8,Item,4)<br />(9,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#275");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#275");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,2)(3,Separator,2)<br />(4,Item,1)(5,Separator,1)(6,Item,3)<br />(7,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#276");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#276");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,4)(3,Separator,4)<br />(4,Item,1)(5,Separator,1)(6,Item,5)(7,Separator,5)<br />(8,Item,2)(9,Separator,2)(10,Item,6)<br />(11,Item,3)(12,Separator,3)<br />(13,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#277");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#277");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span>(0,Item,0)(1,Separator,0)(2,Item,3)(3,Separator,3)(4,Item,6)(5,Separator,6)<br />(6,Item,1)(7,Separator,1)(8,Item,4)(9,Separator,4)(10,Item,7)(11,Separator,7)<br />(12,Item,2)(13,Separator,2)(14,Item,5)(15,Separator,5)(16,Item,8)<br />(17,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#278");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#278");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, true);
string exp = @"<span>(0,Item,0)(1,Separator,0)(2,Item,3)(3,Separator,3)(4,Item,5)(5,Separator,5)<br />(6,Item,1)(7,Separator,1)(8,Item,4)(9,Separator,4)(10,Item,6)<br />(11,Item,2)(12,Separator,2)<br />(13,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#279");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#279");
}
[Test]
<td colspan=""0"" class=""Header-1"">(0,Header,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#320");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#320");
}
[Test]
<td class=""Item0"">(1,Item,0)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#321");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#321");
}
[Test]
<td class=""Item0"">(1,Item,0)</td><td class=""Separator0"">(2,Separator,0)</td><td class=""Item1"">(3,Item,1)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#322");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#322");
}
[Test]
<td class=""Item0"">(1,Item,0)</td><td class=""Separator0"">(2,Separator,0)</td><td class=""Item1"">(3,Item,1)</td><td class=""Separator1"">(4,Separator,1)</td><td class=""Item2"">(5,Item,2)</td><td class=""Separator2"">(6,Separator,2)</td><td class=""Item3"">(7,Item,3)</td><td class=""Separator3"">(8,Separator,3)</td><td class=""Item4"">(9,Item,4)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#323");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#323");
}
[Test]
<td colspan=""2"" class=""Header-1"">(0,Header,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#324");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#324");
}
[Test]
<td class=""Item4"">(9,Item,4)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#325");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#325");
}
[Test]
<td class=""Item2"">(5,Item,2)</td><td class=""Separator2"">(6,Separator,2)</td><td class=""Item3"">(7,Item,3)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#326");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#326");
}
[Test]
<td class=""Item6"">(13,Item,6)</td><td></td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#327");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#327");
}
[Test]
<td class=""Item6"">(13,Item,6)</td><td class=""Separator6"">(14,Separator,6)</td><td class=""Item7"">(15,Item,7)</td><td class=""Separator7"">(16,Separator,7)</td><td class=""Item8"">(17,Item,8)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#328");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#328");
}
[Test]
<td class=""Item6"">(13,Item,6)</td><td></td><td></td><td></td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#329");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#329");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, true);
string exp = @"(0,Header,-1)";
- Assert.AreEqual (exp, v, "#330");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#330");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)";
- Assert.AreEqual (exp, v, "#331");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#331");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)";
- Assert.AreEqual (exp, v, "#332");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#332");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)(9,Item,4)";
- Assert.AreEqual (exp, v, "#333");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#333");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, true);
string exp = @"(0,Header,-1)";
- Assert.AreEqual (exp, v, "#334");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#334");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)(9,Item,4)";
- Assert.AreEqual (exp, v, "#335");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#335");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,2)(4,Separator,2)(5,Item,1)(6,Separator,1)(7,Item,3)";
- Assert.AreEqual (exp, v, "#336");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#336");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,4)(4,Separator,4)(5,Item,1)(6,Separator,1)(7,Item,5)(8,Separator,5)(9,Item,2)(10,Separator,2)(11,Item,6)(12,Item,3)(13,Separator,3)";
- Assert.AreEqual (exp, v, "#337");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#337");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,3)(4,Separator,3)(5,Item,6)(6,Separator,6)(7,Item,1)(8,Separator,1)(9,Item,4)(10,Separator,4)(11,Item,7)(12,Separator,7)(13,Item,2)(14,Separator,2)(15,Item,5)(16,Separator,5)(17,Item,8)";
- Assert.AreEqual (exp, v, "#338");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#338");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,3)(4,Separator,3)(5,Item,5)(6,Separator,5)(7,Item,1)(8,Separator,1)(9,Item,4)(10,Separator,4)(11,Item,6)(12,Item,2)(13,Separator,2)";
- Assert.AreEqual (exp, v, "#339");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#339");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)</span>";
- Assert.AreEqual (exp, v, "#340");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#340");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)</span>";
- Assert.AreEqual (exp, v, "#341");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#341");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)</span>";
- Assert.AreEqual (exp, v, "#342");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#342");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)(9,Item,4)</span>";
- Assert.AreEqual (exp, v, "#343");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#343");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)</span>";
- Assert.AreEqual (exp, v, "#344");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#344");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)<br />(3,Item,1)(4,Separator,1)<br />(5,Item,2)(6,Separator,2)<br />(7,Item,3)(8,Separator,3)<br />(9,Item,4)<br /></span>";
- Assert.AreEqual (exp, v, "#345");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#345");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)<br />(5,Item,2)(6,Separator,2)(7,Item,3)<br /></span>";
- Assert.AreEqual (exp, v, "#346");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#346");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)<br />(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)<br />(9,Item,4)(10,Separator,4)(11,Item,5)(12,Separator,5)<br />(13,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#347");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#347");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, true);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)<br />(7,Item,3)(8,Separator,3)(9,Item,4)(10,Separator,4)(11,Item,5)(12,Separator,5)<br />(13,Item,6)(14,Separator,6)(15,Item,7)(16,Separator,7)(17,Item,8)<br /></span>";
- Assert.AreEqual (exp, v, "#348");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#348");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, true);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)<br />(7,Item,3)(8,Separator,3)(9,Item,4)(10,Separator,4)(11,Item,5)(12,Separator,5)<br />(13,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#349");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#349");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, true);
string exp = @"(0,Header,-1)";
- Assert.AreEqual (exp, v, "#350");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#350");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)";
- Assert.AreEqual (exp, v, "#351");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#351");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)";
- Assert.AreEqual (exp, v, "#352");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#352");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)(9,Item,4)";
- Assert.AreEqual (exp, v, "#353");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#353");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, true);
string exp = @"(0,Header,-1)";
- Assert.AreEqual (exp, v, "#354");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#354");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)(9,Item,4)";
- Assert.AreEqual (exp, v, "#355");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#355");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,2)(4,Separator,2)(5,Item,1)(6,Separator,1)(7,Item,3)";
- Assert.AreEqual (exp, v, "#356");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#356");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,4)(4,Separator,4)(5,Item,1)(6,Separator,1)(7,Item,5)(8,Separator,5)(9,Item,2)(10,Separator,2)(11,Item,6)(12,Item,3)(13,Separator,3)";
- Assert.AreEqual (exp, v, "#357");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#357");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,3)(4,Separator,3)(5,Item,6)(6,Separator,6)(7,Item,1)(8,Separator,1)(9,Item,4)(10,Separator,4)(11,Item,7)(12,Separator,7)(13,Item,2)(14,Separator,2)(15,Item,5)(16,Separator,5)(17,Item,8)";
- Assert.AreEqual (exp, v, "#358");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#358");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, true);
string exp = @"(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,3)(4,Separator,3)(5,Item,5)(6,Separator,5)(7,Item,1)(8,Separator,1)(9,Item,4)(10,Separator,4)(11,Item,6)(12,Item,2)(13,Separator,2)";
- Assert.AreEqual (exp, v, "#359");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#359");
}
[Test]
<td colspan=""0"" class=""Header-1"">(0,Header,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#400");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#400");
}
[Test]
<td class=""Item0"">(1,Item,0)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#401");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#401");
}
[Test]
<td class=""Item0"">(1,Item,0)</td><td class=""Separator0"">(2,Separator,0)</td><td class=""Item1"">(3,Item,1)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#402");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#402");
}
[Test]
<td class=""Item0"">(1,Item,0)</td><td class=""Separator0"">(2,Separator,0)</td><td class=""Item1"">(3,Item,1)</td><td class=""Separator1"">(4,Separator,1)</td><td class=""Item2"">(5,Item,2)</td><td class=""Separator2"">(6,Separator,2)</td><td class=""Item3"">(7,Item,3)</td><td class=""Separator3"">(8,Separator,3)</td><td class=""Item4"">(9,Item,4)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#403");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#403");
}
[Test]
<td colspan=""2"" class=""Header-1"">(0,Header,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#404");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#404");
}
[Test]
<td class=""Item4"">(9,Item,4)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#405");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#405");
}
[Test]
<td class=""Item2"">(5,Item,2)</td><td class=""Separator2"">(6,Separator,2)</td><td class=""Item3"">(7,Item,3)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#406");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#406");
}
[Test]
<td class=""Item6"">(13,Item,6)</td><td></td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#407");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#407");
}
[Test]
<td class=""Item6"">(13,Item,6)</td><td class=""Separator6"">(14,Separator,6)</td><td class=""Item7"">(15,Item,7)</td><td class=""Separator7"">(16,Separator,7)</td><td class=""Item8"">(17,Item,8)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#408");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#408");
}
[Test]
<td class=""Item6"">(13,Item,6)</td><td></td><td></td><td></td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#409");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#409");
}
[Test]
<td class=""Header-1"">(0,Header,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#410");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#410");
}
[Test]
<td class=""Item0"">(1,Item,0)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#411");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#411");
}
[Test]
<td class=""Item1"">(3,Item,1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#412");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#412");
}
[Test]
<td class=""Item4"">(9,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#413");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#413");
}
[Test]
<td class=""Header-1"">(0,Header,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#414");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#414");
}
[Test]
<td class=""Item4"">(9,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#415");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#415");
}
[Test]
<td class=""Item1"">(5,Item,1)</td><td class=""Separator1"">(6,Separator,1)</td><td class=""Item3"">(7,Item,3)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#416");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#416");
}
[Test]
<td class=""Item3"">(12,Item,3)</td><td class=""Separator3"">(13,Separator,3)</td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#417");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#417");
}
[Test]
<td class=""Item2"">(13,Item,2)</td><td class=""Separator2"">(14,Separator,2)</td><td class=""Item5"">(15,Item,5)</td><td class=""Separator5"">(16,Separator,5)</td><td class=""Item8"">(17,Item,8)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#418");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#418");
}
[Test]
<td class=""Item2"">(12,Item,2)</td><td class=""Separator2"">(13,Separator,2)</td><td></td><td></td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#419");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#419");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)</span>";
- Assert.AreEqual (exp, v, "#420");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#420");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)</span>";
- Assert.AreEqual (exp, v, "#421");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#421");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)</span>";
- Assert.AreEqual (exp, v, "#422");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#422");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)(9,Item,4)</span>";
- Assert.AreEqual (exp, v, "#423");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#423");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)</span>";
- Assert.AreEqual (exp, v, "#424");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#424");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)<br />(3,Item,1)(4,Separator,1)<br />(5,Item,2)(6,Separator,2)<br />(7,Item,3)(8,Separator,3)<br />(9,Item,4)<br /></span>";
- Assert.AreEqual (exp, v, "#425");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#425");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)<br />(5,Item,2)(6,Separator,2)(7,Item,3)<br /></span>";
- Assert.AreEqual (exp, v, "#426");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#426");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)<br />(5,Item,2)(6,Separator,2)(7,Item,3)(8,Separator,3)<br />(9,Item,4)(10,Separator,4)(11,Item,5)(12,Separator,5)<br />(13,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#427");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#427");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)<br />(7,Item,3)(8,Separator,3)(9,Item,4)(10,Separator,4)(11,Item,5)(12,Separator,5)<br />(13,Item,6)(14,Separator,6)(15,Item,7)(16,Separator,7)(17,Item,8)<br /></span>";
- Assert.AreEqual (exp, v, "#428");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#428");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,1)(4,Separator,1)(5,Item,2)(6,Separator,2)<br />(7,Item,3)(8,Separator,3)(9,Item,4)(10,Separator,4)(11,Item,5)(12,Separator,5)<br />(13,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#429");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#429");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br /></span>";
- Assert.AreEqual (exp, v, "#430");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#430");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)</span>";
- Assert.AreEqual (exp, v, "#431");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#431");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Separator,0)<br />(3,Item,1)</span>";
- Assert.AreEqual (exp, v, "#432");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#432");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Separator,0)<br />(3,Item,1)<br />(4,Separator,1)<br />(5,Item,2)<br />(6,Separator,2)<br />(7,Item,3)<br />(8,Separator,3)<br />(9,Item,4)</span>";
- Assert.AreEqual (exp, v, "#433");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#433");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br /></span>";
- Assert.AreEqual (exp, v, "#434");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#434");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Separator,0)<br />(3,Item,1)<br />(4,Separator,1)<br />(5,Item,2)<br />(6,Separator,2)<br />(7,Item,3)<br />(8,Separator,3)<br />(9,Item,4)</span>";
- Assert.AreEqual (exp, v, "#435");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#435");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,2)(4,Separator,2)<br />(5,Item,1)(6,Separator,1)(7,Item,3)</span>";
- Assert.AreEqual (exp, v, "#436");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#436");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,4)(4,Separator,4)<br />(5,Item,1)(6,Separator,1)(7,Item,5)(8,Separator,5)<br />(9,Item,2)(10,Separator,2)(11,Item,6)<br />(12,Item,3)(13,Separator,3)</span>";
- Assert.AreEqual (exp, v, "#437");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#437");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,3)(4,Separator,3)(5,Item,6)(6,Separator,6)<br />(7,Item,1)(8,Separator,1)(9,Item,4)(10,Separator,4)(11,Item,7)(12,Separator,7)<br />(13,Item,2)(14,Separator,2)(15,Item,5)(16,Separator,5)(17,Item,8)</span>";
- Assert.AreEqual (exp, v, "#438");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#438");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, true);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Separator,0)(3,Item,3)(4,Separator,3)(5,Item,5)(6,Separator,5)<br />(7,Item,1)(8,Separator,1)(9,Item,4)(10,Separator,4)(11,Item,6)<br />(12,Item,2)(13,Separator,2)</span>";
- Assert.AreEqual (exp, v, "#439");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#439");
}
[Test]
string exp = @"<table class=""mainstyle"">
</table>";
- Assert.AreEqual (exp, v, "#480");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#480");
}
[Test]
<td class=""Item0"">(0,Item,0)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#481");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#481");
}
[Test]
<td class=""Item0"">(0,Item,0)</td><td class=""Separator0"">(1,Separator,0)</td><td class=""Item1"">(2,Item,1)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#482");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#482");
}
[Test]
<td class=""Item0"">(0,Item,0)</td><td class=""Separator0"">(1,Separator,0)</td><td class=""Item1"">(2,Item,1)</td><td class=""Separator1"">(3,Separator,1)</td><td class=""Item2"">(4,Item,2)</td><td class=""Separator2"">(5,Separator,2)</td><td class=""Item3"">(6,Item,3)</td><td class=""Separator3"">(7,Separator,3)</td><td class=""Item4"">(8,Item,4)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#483");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#483");
}
[Test]
string exp = @"<table class=""mainstyle"">
</table>";
- Assert.AreEqual (exp, v, "#484");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#484");
}
[Test]
<td class=""Item4"">(8,Item,4)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#485");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#485");
}
[Test]
<td class=""Item2"">(4,Item,2)</td><td class=""Separator2"">(5,Separator,2)</td><td class=""Item3"">(6,Item,3)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#486");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#486");
}
[Test]
<td class=""Item6"">(12,Item,6)</td><td></td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#487");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#487");
}
[Test]
<td class=""Item6"">(12,Item,6)</td><td class=""Separator6"">(13,Separator,6)</td><td class=""Item7"">(14,Item,7)</td><td class=""Separator7"">(15,Separator,7)</td><td class=""Item8"">(16,Item,8)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#488");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#488");
}
[Test]
<td class=""Item6"">(12,Item,6)</td><td></td><td></td><td></td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#489");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#489");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, true);
string exp = @"";
- Assert.AreEqual (exp, v, "#490");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#490");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, true);
string exp = @"(0,Item,0)";
- Assert.AreEqual (exp, v, "#491");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#491");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,1)";
- Assert.AreEqual (exp, v, "#492");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#492");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)(8,Item,4)";
- Assert.AreEqual (exp, v, "#493");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#493");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, true);
string exp = @"";
- Assert.AreEqual (exp, v, "#494");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#494");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)(8,Item,4)";
- Assert.AreEqual (exp, v, "#495");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#495");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,2)(3,Separator,2)(4,Item,1)(5,Separator,1)(6,Item,3)";
- Assert.AreEqual (exp, v, "#496");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#496");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,4)(3,Separator,4)(4,Item,1)(5,Separator,1)(6,Item,5)(7,Separator,5)(8,Item,2)(9,Separator,2)(10,Item,6)(11,Item,3)(12,Separator,3)";
- Assert.AreEqual (exp, v, "#497");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#497");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,3)(3,Separator,3)(4,Item,6)(5,Separator,6)(6,Item,1)(7,Separator,1)(8,Item,4)(9,Separator,4)(10,Item,7)(11,Separator,7)(12,Item,2)(13,Separator,2)(14,Item,5)(15,Separator,5)(16,Item,8)";
- Assert.AreEqual (exp, v, "#498");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#498");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,3)(3,Separator,3)(4,Item,5)(5,Separator,5)(6,Item,1)(7,Separator,1)(8,Item,4)(9,Separator,4)(10,Item,6)(11,Item,2)(12,Separator,2)";
- Assert.AreEqual (exp, v, "#499");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#499");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, true);
string exp = @"<span class=""mainstyle""></span>";
- Assert.AreEqual (exp, v, "#500");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#500");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)</span>";
- Assert.AreEqual (exp, v, "#501");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#501");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)</span>";
- Assert.AreEqual (exp, v, "#502");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#502");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)(8,Item,4)</span>";
- Assert.AreEqual (exp, v, "#503");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#503");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, true);
string exp = @"<span class=""mainstyle""></span>";
- Assert.AreEqual (exp, v, "#504");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#504");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)<br />(2,Item,1)(3,Separator,1)<br />(4,Item,2)(5,Separator,2)<br />(6,Item,3)(7,Separator,3)<br />(8,Item,4)<br /></span>";
- Assert.AreEqual (exp, v, "#505");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#505");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)<br />(4,Item,2)(5,Separator,2)(6,Item,3)<br /></span>";
- Assert.AreEqual (exp, v, "#506");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#506");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)<br />(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)<br />(8,Item,4)(9,Separator,4)(10,Item,5)(11,Separator,5)<br />(12,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#507");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#507");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, true);
string exp = @"<span>(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)<br />(6,Item,3)(7,Separator,3)(8,Item,4)(9,Separator,4)(10,Item,5)(11,Separator,5)<br />(12,Item,6)(13,Separator,6)(14,Item,7)(15,Separator,7)(16,Item,8)<br /></span>";
- Assert.AreEqual (exp, v, "#508");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#508");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, true);
string exp = @"<span>(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)<br />(6,Item,3)(7,Separator,3)(8,Item,4)(9,Separator,4)(10,Item,5)(11,Separator,5)<br />(12,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#509");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#509");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, true);
string exp = @"";
- Assert.AreEqual (exp, v, "#510");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#510");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, true);
string exp = @"(0,Item,0)";
- Assert.AreEqual (exp, v, "#511");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#511");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,1)";
- Assert.AreEqual (exp, v, "#512");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#512");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)(8,Item,4)";
- Assert.AreEqual (exp, v, "#513");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#513");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, true);
string exp = @"";
- Assert.AreEqual (exp, v, "#514");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#514");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)(8,Item,4)";
- Assert.AreEqual (exp, v, "#515");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#515");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,2)(3,Separator,2)(4,Item,1)(5,Separator,1)(6,Item,3)";
- Assert.AreEqual (exp, v, "#516");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#516");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,4)(3,Separator,4)(4,Item,1)(5,Separator,1)(6,Item,5)(7,Separator,5)(8,Item,2)(9,Separator,2)(10,Item,6)(11,Item,3)(12,Separator,3)";
- Assert.AreEqual (exp, v, "#517");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#517");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,3)(3,Separator,3)(4,Item,6)(5,Separator,6)(6,Item,1)(7,Separator,1)(8,Item,4)(9,Separator,4)(10,Item,7)(11,Separator,7)(12,Item,2)(13,Separator,2)(14,Item,5)(15,Separator,5)(16,Item,8)";
- Assert.AreEqual (exp, v, "#518");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#518");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, true);
string exp = @"(0,Item,0)(1,Separator,0)(2,Item,3)(3,Separator,3)(4,Item,5)(5,Separator,5)(6,Item,1)(7,Separator,1)(8,Item,4)(9,Separator,4)(10,Item,6)(11,Item,2)(12,Separator,2)";
- Assert.AreEqual (exp, v, "#519");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#519");
}
[Test]
string exp = @"<table class=""mainstyle"">
</table>";
- Assert.AreEqual (exp, v, "#560");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#560");
}
[Test]
<td class=""Item0"">(0,Item,0)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#561");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#561");
}
[Test]
<td class=""Item0"">(0,Item,0)</td><td class=""Separator0"">(1,Separator,0)</td><td class=""Item1"">(2,Item,1)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#562");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#562");
}
[Test]
<td class=""Item0"">(0,Item,0)</td><td class=""Separator0"">(1,Separator,0)</td><td class=""Item1"">(2,Item,1)</td><td class=""Separator1"">(3,Separator,1)</td><td class=""Item2"">(4,Item,2)</td><td class=""Separator2"">(5,Separator,2)</td><td class=""Item3"">(6,Item,3)</td><td class=""Separator3"">(7,Separator,3)</td><td class=""Item4"">(8,Item,4)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#563");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#563");
}
[Test]
string exp = @"<table class=""mainstyle"">
</table>";
- Assert.AreEqual (exp, v, "#564");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#564");
}
[Test]
<td class=""Item4"">(8,Item,4)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#565");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#565");
}
[Test]
<td class=""Item2"">(4,Item,2)</td><td class=""Separator2"">(5,Separator,2)</td><td class=""Item3"">(6,Item,3)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#566");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#566");
}
[Test]
<td class=""Item6"">(12,Item,6)</td><td></td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#567");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#567");
}
[Test]
<td class=""Item6"">(12,Item,6)</td><td class=""Separator6"">(13,Separator,6)</td><td class=""Item7"">(14,Item,7)</td><td class=""Separator7"">(15,Separator,7)</td><td class=""Item8"">(16,Item,8)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#568");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#568");
}
[Test]
<td class=""Item6"">(12,Item,6)</td><td></td><td></td><td></td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#569");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#569");
}
[Test]
string exp = @"<table class=""mainstyle"">
</table>";
- Assert.AreEqual (exp, v, "#570");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#570");
}
[Test]
<td class=""Item0"">(0,Item,0)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#571");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#571");
}
[Test]
<td class=""Item1"">(2,Item,1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#572");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#572");
}
[Test]
<td class=""Item4"">(8,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#573");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#573");
}
[Test]
string exp = @"<table class=""mainstyle"">
</table>";
- Assert.AreEqual (exp, v, "#574");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#574");
}
[Test]
<td class=""Item4"">(8,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#575");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#575");
}
[Test]
<td class=""Item1"">(4,Item,1)</td><td class=""Separator1"">(5,Separator,1)</td><td class=""Item3"">(6,Item,3)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#576");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#576");
}
[Test]
<td class=""Item3"">(11,Item,3)</td><td class=""Separator3"">(12,Separator,3)</td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#577");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#577");
}
[Test]
<td class=""Item2"">(12,Item,2)</td><td class=""Separator2"">(13,Separator,2)</td><td class=""Item5"">(14,Item,5)</td><td class=""Separator5"">(15,Separator,5)</td><td class=""Item8"">(16,Item,8)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#578");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#578");
}
[Test]
<td class=""Item2"">(11,Item,2)</td><td class=""Separator2"">(12,Separator,2)</td><td></td><td></td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#579");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#579");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle""></span>";
- Assert.AreEqual (exp, v, "#580");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#580");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)</span>";
- Assert.AreEqual (exp, v, "#581");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#581");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)</span>";
- Assert.AreEqual (exp, v, "#582");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#582");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)(8,Item,4)</span>";
- Assert.AreEqual (exp, v, "#583");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#583");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle""></span>";
- Assert.AreEqual (exp, v, "#584");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#584");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)<br />(2,Item,1)(3,Separator,1)<br />(4,Item,2)(5,Separator,2)<br />(6,Item,3)(7,Separator,3)<br />(8,Item,4)<br /></span>";
- Assert.AreEqual (exp, v, "#585");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#585");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)<br />(4,Item,2)(5,Separator,2)(6,Item,3)<br /></span>";
- Assert.AreEqual (exp, v, "#586");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#586");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)<br />(4,Item,2)(5,Separator,2)(6,Item,3)(7,Separator,3)<br />(8,Item,4)(9,Separator,4)(10,Item,5)(11,Separator,5)<br />(12,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#587");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#587");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span>(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)<br />(6,Item,3)(7,Separator,3)(8,Item,4)(9,Separator,4)(10,Item,5)(11,Separator,5)<br />(12,Item,6)(13,Separator,6)(14,Item,7)(15,Separator,7)(16,Item,8)<br /></span>";
- Assert.AreEqual (exp, v, "#588");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#588");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span>(0,Item,0)(1,Separator,0)(2,Item,1)(3,Separator,1)(4,Item,2)(5,Separator,2)<br />(6,Item,3)(7,Separator,3)(8,Item,4)(9,Separator,4)(10,Item,5)(11,Separator,5)<br />(12,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#589");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#589");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle""></span>";
- Assert.AreEqual (exp, v, "#590");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#590");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)</span>";
- Assert.AreEqual (exp, v, "#591");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#591");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Separator,0)<br />(2,Item,1)</span>";
- Assert.AreEqual (exp, v, "#592");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#592");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Separator,0)<br />(2,Item,1)<br />(3,Separator,1)<br />(4,Item,2)<br />(5,Separator,2)<br />(6,Item,3)<br />(7,Separator,3)<br />(8,Item,4)</span>";
- Assert.AreEqual (exp, v, "#593");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#593");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle""></span>";
- Assert.AreEqual (exp, v, "#594");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#594");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Separator,0)<br />(2,Item,1)<br />(3,Separator,1)<br />(4,Item,2)<br />(5,Separator,2)<br />(6,Item,3)<br />(7,Separator,3)<br />(8,Item,4)</span>";
- Assert.AreEqual (exp, v, "#595");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#595");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,2)(3,Separator,2)<br />(4,Item,1)(5,Separator,1)(6,Item,3)</span>";
- Assert.AreEqual (exp, v, "#596");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#596");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Separator,0)(2,Item,4)(3,Separator,4)<br />(4,Item,1)(5,Separator,1)(6,Item,5)(7,Separator,5)<br />(8,Item,2)(9,Separator,2)(10,Item,6)<br />(11,Item,3)(12,Separator,3)</span>";
- Assert.AreEqual (exp, v, "#597");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#597");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span>(0,Item,0)(1,Separator,0)(2,Item,3)(3,Separator,3)(4,Item,6)(5,Separator,6)<br />(6,Item,1)(7,Separator,1)(8,Item,4)(9,Separator,4)(10,Item,7)(11,Separator,7)<br />(12,Item,2)(13,Separator,2)(14,Item,5)(15,Separator,5)(16,Item,8)</span>";
- Assert.AreEqual (exp, v, "#598");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#598");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, true);
string exp = @"<span>(0,Item,0)(1,Separator,0)(2,Item,3)(3,Separator,3)(4,Item,5)(5,Separator,5)<br />(6,Item,1)(7,Separator,1)(8,Item,4)(9,Separator,4)(10,Item,6)<br />(11,Item,2)(12,Separator,2)</span>";
- Assert.AreEqual (exp, v, "#599");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#599");
}
[Test]
<td colspan=""0"" class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#640");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#640");
}
[Test]
<td class=""Footer-1"">(2,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#641");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#641");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(3,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#642");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#642");
}
[Test]
<td colspan=""5"" class=""Footer-1"">(6,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#643");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#643");
}
[Test]
<td class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#644");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#644");
}
[Test]
<td class=""Footer-1"">(6,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#645");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#645");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(5,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#646");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#646");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(8,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#647");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#647");
}
[Test]
<td colspan=""3"" class=""Footer-1"">(10,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#648");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#648");
}
[Test]
<td colspan=""3"" class=""Footer-1"">(8,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#649");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#649");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, false);
string exp = @"(0,Header,-1)(1,Footer,-1)";
- Assert.AreEqual (exp, v, "#650");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#650");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Footer,-1)";
- Assert.AreEqual (exp, v, "#651");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#651");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,1)(3,Footer,-1)";
- Assert.AreEqual (exp, v, "#652");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#652");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,1)(3,Item,2)(4,Item,3)(5,Item,4)(6,Footer,-1)";
- Assert.AreEqual (exp, v, "#653");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#653");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, false);
string exp = @"(0,Header,-1)(1,Footer,-1)";
- Assert.AreEqual (exp, v, "#654");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#654");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,1)(3,Item,2)(4,Item,3)(5,Item,4)(6,Footer,-1)";
- Assert.AreEqual (exp, v, "#655");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#655");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,2)(3,Item,1)(4,Item,3)(5,Footer,-1)";
- Assert.AreEqual (exp, v, "#656");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#656");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,4)(3,Item,1)(4,Item,5)(5,Item,2)(6,Item,6)(7,Item,3)(8,Footer,-1)";
- Assert.AreEqual (exp, v, "#657");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#657");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,3)(3,Item,6)(4,Item,1)(5,Item,4)(6,Item,7)(7,Item,2)(8,Item,5)(9,Item,8)(10,Footer,-1)";
- Assert.AreEqual (exp, v, "#658");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#658");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,3)(3,Item,5)(4,Item,1)(5,Item,4)(6,Item,6)(7,Item,2)(8,Footer,-1)";
- Assert.AreEqual (exp, v, "#659");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#659");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#660");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#660");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#661");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#661");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Item,1)(3,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#662");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#662");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Item,1)(3,Item,2)(4,Item,3)(5,Item,4)(6,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#663");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#663");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#664");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#664");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Item,1)<br />(3,Item,2)<br />(4,Item,3)<br />(5,Item,4)<br />(6,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#665");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#665");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Item,1)<br />(3,Item,2)(4,Item,3)<br />(5,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#666");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#666");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Item,1)<br />(3,Item,2)(4,Item,3)<br />(5,Item,4)(6,Item,5)<br />(7,Item,6)<br />(8,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#667");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#667");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, false);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Item,1)(3,Item,2)<br />(4,Item,3)(5,Item,4)(6,Item,5)<br />(7,Item,6)(8,Item,7)(9,Item,8)<br />(10,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#668");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#668");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, true, false);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Item,1)(3,Item,2)<br />(4,Item,3)(5,Item,4)(6,Item,5)<br />(7,Item,6)<br />(8,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#669");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#669");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, false);
string exp = @"(0,Header,-1)(1,Footer,-1)";
- Assert.AreEqual (exp, v, "#670");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#670");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Footer,-1)";
- Assert.AreEqual (exp, v, "#671");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#671");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,1)(3,Footer,-1)";
- Assert.AreEqual (exp, v, "#672");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#672");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,1)(3,Item,2)(4,Item,3)(5,Item,4)(6,Footer,-1)";
- Assert.AreEqual (exp, v, "#673");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#673");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, false);
string exp = @"(0,Header,-1)(1,Footer,-1)";
- Assert.AreEqual (exp, v, "#674");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#674");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,1)(3,Item,2)(4,Item,3)(5,Item,4)(6,Footer,-1)";
- Assert.AreEqual (exp, v, "#675");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#675");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,2)(3,Item,1)(4,Item,3)(5,Footer,-1)";
- Assert.AreEqual (exp, v, "#676");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#676");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,4)(3,Item,1)(4,Item,5)(5,Item,2)(6,Item,6)(7,Item,3)(8,Footer,-1)";
- Assert.AreEqual (exp, v, "#677");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#677");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,3)(3,Item,6)(4,Item,1)(5,Item,4)(6,Item,7)(7,Item,2)(8,Item,5)(9,Item,8)(10,Footer,-1)";
- Assert.AreEqual (exp, v, "#678");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#678");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, true, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,3)(3,Item,5)(4,Item,1)(5,Item,4)(6,Item,6)(7,Item,2)(8,Footer,-1)";
- Assert.AreEqual (exp, v, "#679");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#679");
}
[Test]
<td colspan=""0"" class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#720");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#720");
}
[Test]
<td class=""Footer-1"">(2,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#721");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#721");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(3,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#722");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#722");
}
[Test]
<td colspan=""5"" class=""Footer-1"">(6,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#723");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#723");
}
[Test]
<td class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#724");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#724");
}
[Test]
<td class=""Footer-1"">(6,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#725");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#725");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(5,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#726");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#726");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(8,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#727");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#727");
}
[Test]
<td colspan=""3"" class=""Footer-1"">(10,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#728");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#728");
}
[Test]
<td colspan=""3"" class=""Footer-1"">(8,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#729");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#729");
}
[Test]
<td class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#730");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#730");
}
[Test]
<td class=""Footer-1"">(2,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#731");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#731");
}
[Test]
<td class=""Footer-1"">(3,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#732");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#732");
}
[Test]
<td class=""Footer-1"">(6,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#733");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#733");
}
[Test]
<td class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#734");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#734");
}
[Test]
<td class=""Footer-1"">(6,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#735");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#735");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(5,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#736");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#736");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(8,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#737");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#737");
}
[Test]
<td colspan=""3"" class=""Footer-1"">(10,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#738");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#738");
}
[Test]
<td colspan=""3"" class=""Footer-1"">(8,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#739");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#739");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#740");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#740");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#741");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#741");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Item,1)(3,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#742");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#742");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Item,1)(3,Item,2)(4,Item,3)(5,Item,4)(6,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#743");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#743");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#744");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#744");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Item,1)<br />(3,Item,2)<br />(4,Item,3)<br />(5,Item,4)<br />(6,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#745");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#745");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Item,1)<br />(3,Item,2)(4,Item,3)<br />(5,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#746");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#746");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Item,1)<br />(3,Item,2)(4,Item,3)<br />(5,Item,4)(6,Item,5)<br />(7,Item,6)<br />(8,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#747");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#747");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Item,1)(3,Item,2)<br />(4,Item,3)(5,Item,4)(6,Item,5)<br />(7,Item,6)(8,Item,7)(9,Item,8)<br />(10,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#748");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#748");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Item,1)(3,Item,2)<br />(4,Item,3)(5,Item,4)(6,Item,5)<br />(7,Item,6)<br />(8,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#749");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#749");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#750");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#750");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#751");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#751");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Item,1)<br />(3,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#752");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#752");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Item,1)<br />(3,Item,2)<br />(4,Item,3)<br />(5,Item,4)<br />(6,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#753");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#753");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#754");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#754");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Item,1)<br />(3,Item,2)<br />(4,Item,3)<br />(5,Item,4)<br />(6,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#755");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#755");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Item,2)<br />(3,Item,1)(4,Item,3)<br />(5,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#756");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#756");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Item,4)<br />(3,Item,1)(4,Item,5)<br />(5,Item,2)(6,Item,6)<br />(7,Item,3)<br />(8,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#757");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#757");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Item,3)(3,Item,6)<br />(4,Item,1)(5,Item,4)(6,Item,7)<br />(7,Item,2)(8,Item,5)(9,Item,8)<br />(10,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#758");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#758");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, true, false);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Item,3)(3,Item,5)<br />(4,Item,1)(5,Item,4)(6,Item,6)<br />(7,Item,2)<br />(8,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#759");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#759");
}
[Test]
<td colspan=""0"" class=""Footer-1"">(0,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#800");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#800");
}
[Test]
<td class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#801");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#801");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(2,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#802");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#802");
}
[Test]
<td colspan=""5"" class=""Footer-1"">(5,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#803");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#803");
}
[Test]
<td class=""Footer-1"">(0,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#804");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#804");
}
[Test]
<td class=""Footer-1"">(5,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#805");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#805");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(4,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#806");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#806");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(7,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#807");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#807");
}
[Test]
<td colspan=""3"" class=""Footer-1"">(9,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#808");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#808");
}
[Test]
<td colspan=""3"" class=""Footer-1"">(7,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#809");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#809");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, false);
string exp = @"(0,Footer,-1)";
- Assert.AreEqual (exp, v, "#810");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#810");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, false);
string exp = @"(0,Item,0)(1,Footer,-1)";
- Assert.AreEqual (exp, v, "#811");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#811");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, false);
string exp = @"(0,Item,0)(1,Item,1)(2,Footer,-1)";
- Assert.AreEqual (exp, v, "#812");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#812");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, false);
string exp = @"(0,Item,0)(1,Item,1)(2,Item,2)(3,Item,3)(4,Item,4)(5,Footer,-1)";
- Assert.AreEqual (exp, v, "#813");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#813");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, false);
string exp = @"(0,Footer,-1)";
- Assert.AreEqual (exp, v, "#814");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#814");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, false);
string exp = @"(0,Item,0)(1,Item,1)(2,Item,2)(3,Item,3)(4,Item,4)(5,Footer,-1)";
- Assert.AreEqual (exp, v, "#815");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#815");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, false);
string exp = @"(0,Item,0)(1,Item,2)(2,Item,1)(3,Item,3)(4,Footer,-1)";
- Assert.AreEqual (exp, v, "#816");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#816");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, false);
string exp = @"(0,Item,0)(1,Item,4)(2,Item,1)(3,Item,5)(4,Item,2)(5,Item,6)(6,Item,3)(7,Footer,-1)";
- Assert.AreEqual (exp, v, "#817");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#817");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, false);
string exp = @"(0,Item,0)(1,Item,3)(2,Item,6)(3,Item,1)(4,Item,4)(5,Item,7)(6,Item,2)(7,Item,5)(8,Item,8)(9,Footer,-1)";
- Assert.AreEqual (exp, v, "#818");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#818");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, false, true, false);
string exp = @"(0,Item,0)(1,Item,3)(2,Item,5)(3,Item,1)(4,Item,4)(5,Item,6)(6,Item,2)(7,Footer,-1)";
- Assert.AreEqual (exp, v, "#819");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#819");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#820");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#820");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#821");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#821");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)(2,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#822");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#822");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)(2,Item,2)(3,Item,3)(4,Item,4)(5,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#823");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#823");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#824");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#824");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Item,1)<br />(2,Item,2)<br />(3,Item,3)<br />(4,Item,4)<br />(5,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#825");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#825");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)<br />(2,Item,2)(3,Item,3)<br />(4,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#826");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#826");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)<br />(2,Item,2)(3,Item,3)<br />(4,Item,4)(5,Item,5)<br />(6,Item,6)<br />(7,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#827");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#827");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, false);
string exp = @"<span>(0,Item,0)(1,Item,1)(2,Item,2)<br />(3,Item,3)(4,Item,4)(5,Item,5)<br />(6,Item,6)(7,Item,7)(8,Item,8)<br />(9,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#828");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#828");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, true, false);
string exp = @"<span>(0,Item,0)(1,Item,1)(2,Item,2)<br />(3,Item,3)(4,Item,4)(5,Item,5)<br />(6,Item,6)<br />(7,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#829");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#829");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, false);
string exp = @"(0,Footer,-1)";
- Assert.AreEqual (exp, v, "#830");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#830");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, false);
string exp = @"(0,Item,0)(1,Footer,-1)";
- Assert.AreEqual (exp, v, "#831");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#831");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, false);
string exp = @"(0,Item,0)(1,Item,1)(2,Footer,-1)";
- Assert.AreEqual (exp, v, "#832");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#832");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, false);
string exp = @"(0,Item,0)(1,Item,1)(2,Item,2)(3,Item,3)(4,Item,4)(5,Footer,-1)";
- Assert.AreEqual (exp, v, "#833");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#833");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, false);
string exp = @"(0,Footer,-1)";
- Assert.AreEqual (exp, v, "#834");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#834");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, false);
string exp = @"(0,Item,0)(1,Item,1)(2,Item,2)(3,Item,3)(4,Item,4)(5,Footer,-1)";
- Assert.AreEqual (exp, v, "#835");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#835");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, false);
string exp = @"(0,Item,0)(1,Item,2)(2,Item,1)(3,Item,3)(4,Footer,-1)";
- Assert.AreEqual (exp, v, "#836");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#836");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, false);
string exp = @"(0,Item,0)(1,Item,4)(2,Item,1)(3,Item,5)(4,Item,2)(5,Item,6)(6,Item,3)(7,Footer,-1)";
- Assert.AreEqual (exp, v, "#837");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#837");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, false);
string exp = @"(0,Item,0)(1,Item,3)(2,Item,6)(3,Item,1)(4,Item,4)(5,Item,7)(6,Item,2)(7,Item,5)(8,Item,8)(9,Footer,-1)";
- Assert.AreEqual (exp, v, "#838");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#838");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, true, false);
string exp = @"(0,Item,0)(1,Item,3)(2,Item,5)(3,Item,1)(4,Item,4)(5,Item,6)(6,Item,2)(7,Footer,-1)";
- Assert.AreEqual (exp, v, "#839");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#839");
}
[Test]
<td colspan=""0"" class=""Footer-1"">(0,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#880");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#880");
}
[Test]
<td class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#881");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#881");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(2,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#882");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#882");
}
[Test]
<td colspan=""5"" class=""Footer-1"">(5,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#883");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#883");
}
[Test]
<td class=""Footer-1"">(0,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#884");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#884");
}
[Test]
<td class=""Footer-1"">(5,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#885");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#885");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(4,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#886");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#886");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(7,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#887");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#887");
}
[Test]
<td colspan=""3"" class=""Footer-1"">(9,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#888");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#888");
}
[Test]
<td colspan=""3"" class=""Footer-1"">(7,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#889");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#889");
}
[Test]
<td class=""Footer-1"">(0,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#890");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#890");
}
[Test]
<td class=""Footer-1"">(1,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#891");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#891");
}
[Test]
<td class=""Footer-1"">(2,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#892");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#892");
}
[Test]
<td class=""Footer-1"">(5,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#893");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#893");
}
[Test]
<td class=""Footer-1"">(0,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#894");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#894");
}
[Test]
<td class=""Footer-1"">(5,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#895");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#895");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(4,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#896");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#896");
}
[Test]
<td colspan=""2"" class=""Footer-1"">(7,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#897");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#897");
}
[Test]
<td colspan=""3"" class=""Footer-1"">(9,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#898");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#898");
}
[Test]
<td colspan=""3"" class=""Footer-1"">(7,Footer,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#899");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#899");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#900");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#900");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#901");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#901");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)(2,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#902");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#902");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)(2,Item,2)(3,Item,3)(4,Item,4)(5,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#903");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#903");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#904");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#904");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Item,1)<br />(2,Item,2)<br />(3,Item,3)<br />(4,Item,4)<br />(5,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#905");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#905");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)<br />(2,Item,2)(3,Item,3)<br />(4,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#906");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#906");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)<br />(2,Item,2)(3,Item,3)<br />(4,Item,4)(5,Item,5)<br />(6,Item,6)<br />(7,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#907");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#907");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span>(0,Item,0)(1,Item,1)(2,Item,2)<br />(3,Item,3)(4,Item,4)(5,Item,5)<br />(6,Item,6)(7,Item,7)(8,Item,8)<br />(9,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#908");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#908");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span>(0,Item,0)(1,Item,1)(2,Item,2)<br />(3,Item,3)(4,Item,4)(5,Item,5)<br />(6,Item,6)<br />(7,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#909");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#909");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#910");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#910");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#911");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#911");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Item,1)<br />(2,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#912");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#912");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Item,1)<br />(2,Item,2)<br />(3,Item,3)<br />(4,Item,4)<br />(5,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#913");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#913");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#914");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#914");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Item,1)<br />(2,Item,2)<br />(3,Item,3)<br />(4,Item,4)<br />(5,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#915");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#915");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,2)<br />(2,Item,1)(3,Item,3)<br />(4,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#916");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#916");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,4)<br />(2,Item,1)(3,Item,5)<br />(4,Item,2)(5,Item,6)<br />(6,Item,3)<br />(7,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#917");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#917");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span>(0,Item,0)(1,Item,3)(2,Item,6)<br />(3,Item,1)(4,Item,4)(5,Item,7)<br />(6,Item,2)(7,Item,5)(8,Item,8)<br />(9,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#918");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#918");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, true, false);
string exp = @"<span>(0,Item,0)(1,Item,3)(2,Item,5)<br />(3,Item,1)(4,Item,4)(5,Item,6)<br />(6,Item,2)<br />(7,Footer,-1)</span>";
- Assert.AreEqual (exp, v, "#919");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#919");
}
[Test]
<td colspan=""0"" class=""Header-1"">(0,Header,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#960");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#960");
}
[Test]
<td class=""Item0"">(1,Item,0)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#961");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#961");
}
[Test]
<td class=""Item0"">(1,Item,0)</td><td class=""Item1"">(2,Item,1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#962");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#962");
}
[Test]
<td class=""Item0"">(1,Item,0)</td><td class=""Item1"">(2,Item,1)</td><td class=""Item2"">(3,Item,2)</td><td class=""Item3"">(4,Item,3)</td><td class=""Item4"">(5,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#963");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#963");
}
[Test]
<td class=""Header-1"">(0,Header,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#964");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#964");
}
[Test]
<td class=""Item4"">(5,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#965");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#965");
}
[Test]
<td class=""Item2"">(3,Item,2)</td><td class=""Item3"">(4,Item,3)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#966");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#966");
}
[Test]
<td class=""Item6"">(7,Item,6)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#967");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#967");
}
[Test]
<td class=""Item6"">(7,Item,6)</td><td class=""Item7"">(8,Item,7)</td><td class=""Item8"">(9,Item,8)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#968");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#968");
}
[Test]
<td class=""Item6"">(7,Item,6)</td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#969");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#969");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, false);
string exp = @"(0,Header,-1)";
- Assert.AreEqual (exp, v, "#970");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#970");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)";
- Assert.AreEqual (exp, v, "#971");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#971");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,1)";
- Assert.AreEqual (exp, v, "#972");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#972");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,1)(3,Item,2)(4,Item,3)(5,Item,4)";
- Assert.AreEqual (exp, v, "#973");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#973");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, false);
string exp = @"(0,Header,-1)";
- Assert.AreEqual (exp, v, "#974");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#974");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,1)(3,Item,2)(4,Item,3)(5,Item,4)";
- Assert.AreEqual (exp, v, "#975");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#975");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,2)(3,Item,1)(4,Item,3)";
- Assert.AreEqual (exp, v, "#976");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#976");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,4)(3,Item,1)(4,Item,5)(5,Item,2)(6,Item,6)(7,Item,3)";
- Assert.AreEqual (exp, v, "#977");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#977");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,3)(3,Item,6)(4,Item,1)(5,Item,4)(6,Item,7)(7,Item,2)(8,Item,5)(9,Item,8)";
- Assert.AreEqual (exp, v, "#978");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#978");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,3)(3,Item,5)(4,Item,1)(5,Item,4)(6,Item,6)(7,Item,2)";
- Assert.AreEqual (exp, v, "#979");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#979");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)</span>";
- Assert.AreEqual (exp, v, "#980");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#980");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)</span>";
- Assert.AreEqual (exp, v, "#981");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#981");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Item,1)</span>";
- Assert.AreEqual (exp, v, "#982");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#982");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Item,1)(3,Item,2)(4,Item,3)(5,Item,4)</span>";
- Assert.AreEqual (exp, v, "#983");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#983");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)</span>";
- Assert.AreEqual (exp, v, "#984");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#984");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Item,1)<br />(3,Item,2)<br />(4,Item,3)<br />(5,Item,4)<br /></span>";
- Assert.AreEqual (exp, v, "#985");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#985");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Item,1)<br />(3,Item,2)(4,Item,3)<br /></span>";
- Assert.AreEqual (exp, v, "#986");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#986");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Item,1)<br />(3,Item,2)(4,Item,3)<br />(5,Item,4)(6,Item,5)<br />(7,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#987");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#987");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, false);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Item,1)(3,Item,2)<br />(4,Item,3)(5,Item,4)(6,Item,5)<br />(7,Item,6)(8,Item,7)(9,Item,8)<br /></span>";
- Assert.AreEqual (exp, v, "#988");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#988");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, true, false, false);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Item,1)(3,Item,2)<br />(4,Item,3)(5,Item,4)(6,Item,5)<br />(7,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#989");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#989");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, false);
string exp = @"(0,Header,-1)";
- Assert.AreEqual (exp, v, "#990");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#990");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)";
- Assert.AreEqual (exp, v, "#991");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#991");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,1)";
- Assert.AreEqual (exp, v, "#992");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#992");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,1)(3,Item,2)(4,Item,3)(5,Item,4)";
- Assert.AreEqual (exp, v, "#993");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#993");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, false);
string exp = @"(0,Header,-1)";
- Assert.AreEqual (exp, v, "#994");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#994");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,1)(3,Item,2)(4,Item,3)(5,Item,4)";
- Assert.AreEqual (exp, v, "#995");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#995");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,2)(3,Item,1)(4,Item,3)";
- Assert.AreEqual (exp, v, "#996");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#996");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,4)(3,Item,1)(4,Item,5)(5,Item,2)(6,Item,6)(7,Item,3)";
- Assert.AreEqual (exp, v, "#997");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#997");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,3)(3,Item,6)(4,Item,1)(5,Item,4)(6,Item,7)(7,Item,2)(8,Item,5)(9,Item,8)";
- Assert.AreEqual (exp, v, "#998");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#998");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, true, false, false);
string exp = @"(0,Header,-1)(1,Item,0)(2,Item,3)(3,Item,5)(4,Item,1)(5,Item,4)(6,Item,6)(7,Item,2)";
- Assert.AreEqual (exp, v, "#999");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#999");
}
[Test]
<td colspan=""0"" class=""Header-1"">(0,Header,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1040");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1040");
}
[Test]
<td class=""Item0"">(1,Item,0)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1041");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1041");
}
[Test]
<td class=""Item0"">(1,Item,0)</td><td class=""Item1"">(2,Item,1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1042");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1042");
}
[Test]
<td class=""Item0"">(1,Item,0)</td><td class=""Item1"">(2,Item,1)</td><td class=""Item2"">(3,Item,2)</td><td class=""Item3"">(4,Item,3)</td><td class=""Item4"">(5,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1043");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1043");
}
[Test]
<td class=""Header-1"">(0,Header,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1044");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1044");
}
[Test]
<td class=""Item4"">(5,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1045");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1045");
}
[Test]
<td class=""Item2"">(3,Item,2)</td><td class=""Item3"">(4,Item,3)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1046");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1046");
}
[Test]
<td class=""Item6"">(7,Item,6)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1047");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1047");
}
[Test]
<td class=""Item6"">(7,Item,6)</td><td class=""Item7"">(8,Item,7)</td><td class=""Item8"">(9,Item,8)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1048");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1048");
}
[Test]
<td class=""Item6"">(7,Item,6)</td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1049");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1049");
}
[Test]
<td class=""Header-1"">(0,Header,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1050");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1050");
}
[Test]
<td class=""Item0"">(1,Item,0)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1051");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1051");
}
[Test]
<td class=""Item1"">(2,Item,1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1052");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1052");
}
[Test]
<td class=""Item4"">(5,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1053");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1053");
}
[Test]
<td class=""Header-1"">(0,Header,-1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1054");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1054");
}
[Test]
<td class=""Item4"">(5,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1055");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1055");
}
[Test]
<td class=""Item1"">(3,Item,1)</td><td class=""Item3"">(4,Item,3)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1056");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1056");
}
[Test]
<td class=""Item3"">(7,Item,3)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1057");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1057");
}
[Test]
<td class=""Item2"">(7,Item,2)</td><td class=""Item5"">(8,Item,5)</td><td class=""Item8"">(9,Item,8)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1058");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1058");
}
[Test]
<td class=""Item2"">(7,Item,2)</td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1059");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1059");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)</span>";
- Assert.AreEqual (exp, v, "#1060");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1060");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)</span>";
- Assert.AreEqual (exp, v, "#1061");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1061");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Item,1)</span>";
- Assert.AreEqual (exp, v, "#1062");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1062");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)(1,Item,0)(2,Item,1)(3,Item,2)(4,Item,3)(5,Item,4)</span>";
- Assert.AreEqual (exp, v, "#1063");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1063");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)</span>";
- Assert.AreEqual (exp, v, "#1064");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1064");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Item,1)<br />(3,Item,2)<br />(4,Item,3)<br />(5,Item,4)<br /></span>";
- Assert.AreEqual (exp, v, "#1065");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1065");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Item,1)<br />(3,Item,2)(4,Item,3)<br /></span>";
- Assert.AreEqual (exp, v, "#1066");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1066");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Item,1)<br />(3,Item,2)(4,Item,3)<br />(5,Item,4)(6,Item,5)<br />(7,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#1067");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1067");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Item,1)(3,Item,2)<br />(4,Item,3)(5,Item,4)(6,Item,5)<br />(7,Item,6)(8,Item,7)(9,Item,8)<br /></span>";
- Assert.AreEqual (exp, v, "#1068");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1068");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Item,1)(3,Item,2)<br />(4,Item,3)(5,Item,4)(6,Item,5)<br />(7,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#1069");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1069");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br /></span>";
- Assert.AreEqual (exp, v, "#1070");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1070");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)</span>";
- Assert.AreEqual (exp, v, "#1071");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1071");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Item,1)</span>";
- Assert.AreEqual (exp, v, "#1072");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1072");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Item,1)<br />(3,Item,2)<br />(4,Item,3)<br />(5,Item,4)</span>";
- Assert.AreEqual (exp, v, "#1073");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1073");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br /></span>";
- Assert.AreEqual (exp, v, "#1074");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1074");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)<br />(2,Item,1)<br />(3,Item,2)<br />(4,Item,3)<br />(5,Item,4)</span>";
- Assert.AreEqual (exp, v, "#1075");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1075");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Item,2)<br />(3,Item,1)(4,Item,3)</span>";
- Assert.AreEqual (exp, v, "#1076");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1076");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span class=""mainstyle"">(0,Header,-1)<br />(1,Item,0)(2,Item,4)<br />(3,Item,1)(4,Item,5)<br />(5,Item,2)(6,Item,6)<br />(7,Item,3)</span>";
- Assert.AreEqual (exp, v, "#1077");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1077");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Item,3)(3,Item,6)<br />(4,Item,1)(5,Item,4)(6,Item,7)<br />(7,Item,2)(8,Item,5)(9,Item,8)</span>";
- Assert.AreEqual (exp, v, "#1078");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1078");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, true, false, false);
string exp = @"<span>(0,Header,-1)<br />(1,Item,0)(2,Item,3)(3,Item,5)<br />(4,Item,1)(5,Item,4)(6,Item,6)<br />(7,Item,2)</span>";
- Assert.AreEqual (exp, v, "#1079");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1079");
}
[Test]
string exp = @"<table class=""mainstyle"">
</table>";
- Assert.AreEqual (exp, v, "#1120");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1120");
}
[Test]
<td class=""Item0"">(0,Item,0)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1121");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1121");
}
[Test]
<td class=""Item0"">(0,Item,0)</td><td class=""Item1"">(1,Item,1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1122");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1122");
}
[Test]
<td class=""Item0"">(0,Item,0)</td><td class=""Item1"">(1,Item,1)</td><td class=""Item2"">(2,Item,2)</td><td class=""Item3"">(3,Item,3)</td><td class=""Item4"">(4,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1123");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1123");
}
[Test]
string exp = @"<table class=""mainstyle"">
</table>";
- Assert.AreEqual (exp, v, "#1124");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1124");
}
[Test]
<td class=""Item4"">(4,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1125");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1125");
}
[Test]
<td class=""Item2"">(2,Item,2)</td><td class=""Item3"">(3,Item,3)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1126");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1126");
}
[Test]
<td class=""Item6"">(6,Item,6)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1127");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1127");
}
[Test]
<td class=""Item6"">(6,Item,6)</td><td class=""Item7"">(7,Item,7)</td><td class=""Item8"">(8,Item,8)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1128");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1128");
}
[Test]
<td class=""Item6"">(6,Item,6)</td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1129");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1129");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, false);
string exp = @"";
- Assert.AreEqual (exp, v, "#1130");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1130");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, false);
string exp = @"(0,Item,0)";
- Assert.AreEqual (exp, v, "#1131");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1131");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, false);
string exp = @"(0,Item,0)(1,Item,1)";
- Assert.AreEqual (exp, v, "#1132");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1132");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, false);
string exp = @"(0,Item,0)(1,Item,1)(2,Item,2)(3,Item,3)(4,Item,4)";
- Assert.AreEqual (exp, v, "#1133");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1133");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, false);
string exp = @"";
- Assert.AreEqual (exp, v, "#1134");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1134");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, false);
string exp = @"(0,Item,0)(1,Item,1)(2,Item,2)(3,Item,3)(4,Item,4)";
- Assert.AreEqual (exp, v, "#1135");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1135");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, false);
string exp = @"(0,Item,0)(1,Item,2)(2,Item,1)(3,Item,3)";
- Assert.AreEqual (exp, v, "#1136");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1136");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, false);
string exp = @"(0,Item,0)(1,Item,4)(2,Item,1)(3,Item,5)(4,Item,2)(5,Item,6)(6,Item,3)";
- Assert.AreEqual (exp, v, "#1137");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1137");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, false);
string exp = @"(0,Item,0)(1,Item,3)(2,Item,6)(3,Item,1)(4,Item,4)(5,Item,7)(6,Item,2)(7,Item,5)(8,Item,8)";
- Assert.AreEqual (exp, v, "#1138");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1138");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Table, true, false, false, false);
string exp = @"(0,Item,0)(1,Item,3)(2,Item,5)(3,Item,1)(4,Item,4)(5,Item,6)(6,Item,2)";
- Assert.AreEqual (exp, v, "#1139");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1139");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, false);
string exp = @"<span class=""mainstyle""></span>";
- Assert.AreEqual (exp, v, "#1140");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1140");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)</span>";
- Assert.AreEqual (exp, v, "#1141");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1141");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)</span>";
- Assert.AreEqual (exp, v, "#1142");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1142");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)(2,Item,2)(3,Item,3)(4,Item,4)</span>";
- Assert.AreEqual (exp, v, "#1143");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1143");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, false);
string exp = @"<span class=""mainstyle""></span>";
- Assert.AreEqual (exp, v, "#1144");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1144");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Item,1)<br />(2,Item,2)<br />(3,Item,3)<br />(4,Item,4)<br /></span>";
- Assert.AreEqual (exp, v, "#1145");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1145");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)<br />(2,Item,2)(3,Item,3)<br /></span>";
- Assert.AreEqual (exp, v, "#1146");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1146");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)<br />(2,Item,2)(3,Item,3)<br />(4,Item,4)(5,Item,5)<br />(6,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#1147");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1147");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, false);
string exp = @"<span>(0,Item,0)(1,Item,1)(2,Item,2)<br />(3,Item,3)(4,Item,4)(5,Item,5)<br />(6,Item,6)(7,Item,7)(8,Item,8)<br /></span>";
- Assert.AreEqual (exp, v, "#1148");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1148");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, true, false, false, false);
string exp = @"<span>(0,Item,0)(1,Item,1)(2,Item,2)<br />(3,Item,3)(4,Item,4)(5,Item,5)<br />(6,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#1149");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1149");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, false);
string exp = @"";
- Assert.AreEqual (exp, v, "#1150");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1150");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, false);
string exp = @"(0,Item,0)";
- Assert.AreEqual (exp, v, "#1151");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1151");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, false);
string exp = @"(0,Item,0)(1,Item,1)";
- Assert.AreEqual (exp, v, "#1152");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1152");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, false);
string exp = @"(0,Item,0)(1,Item,1)(2,Item,2)(3,Item,3)(4,Item,4)";
- Assert.AreEqual (exp, v, "#1153");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1153");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, false);
string exp = @"";
- Assert.AreEqual (exp, v, "#1154");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1154");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, false);
string exp = @"(0,Item,0)(1,Item,1)(2,Item,2)(3,Item,3)(4,Item,4)";
- Assert.AreEqual (exp, v, "#1155");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1155");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, false);
string exp = @"(0,Item,0)(1,Item,2)(2,Item,1)(3,Item,3)";
- Assert.AreEqual (exp, v, "#1156");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1156");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, false);
string exp = @"(0,Item,0)(1,Item,4)(2,Item,1)(3,Item,5)(4,Item,2)(5,Item,6)(6,Item,3)";
- Assert.AreEqual (exp, v, "#1157");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1157");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, false);
string exp = @"(0,Item,0)(1,Item,3)(2,Item,6)(3,Item,1)(4,Item,4)(5,Item,7)(6,Item,2)(7,Item,5)(8,Item,8)";
- Assert.AreEqual (exp, v, "#1158");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1158");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, true, false, false, false);
string exp = @"(0,Item,0)(1,Item,3)(2,Item,5)(3,Item,1)(4,Item,4)(5,Item,6)(6,Item,2)";
- Assert.AreEqual (exp, v, "#1159");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1159");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.UnorderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.UnorderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.UnorderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.UnorderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.UnorderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.UnorderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.UnorderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.UnorderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.UnorderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.UnorderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.UnorderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.UnorderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.UnorderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.UnorderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.OrderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.OrderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.OrderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.OrderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.OrderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.OrderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.OrderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.OrderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.OrderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.OrderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.OrderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.OrderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.OrderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.OrderedList, true, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.")
}
[Test]
string exp = @"<table class=""mainstyle"">
</table>";
- Assert.AreEqual (exp, v, "#1200");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1200");
}
[Test]
<td class=""Item0"">(0,Item,0)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1201");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1201");
}
[Test]
<td class=""Item0"">(0,Item,0)</td><td class=""Item1"">(1,Item,1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1202");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1202");
}
[Test]
<td class=""Item0"">(0,Item,0)</td><td class=""Item1"">(1,Item,1)</td><td class=""Item2"">(2,Item,2)</td><td class=""Item3"">(3,Item,3)</td><td class=""Item4"">(4,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1203");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1203");
}
[Test]
string exp = @"<table class=""mainstyle"">
</table>";
- Assert.AreEqual (exp, v, "#1204");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1204");
}
[Test]
<td class=""Item4"">(4,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1205");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1205");
}
[Test]
<td class=""Item2"">(2,Item,2)</td><td class=""Item3"">(3,Item,3)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1206");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1206");
}
[Test]
<td class=""Item6"">(6,Item,6)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1207");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1207");
}
[Test]
<td class=""Item6"">(6,Item,6)</td><td class=""Item7"">(7,Item,7)</td><td class=""Item8"">(8,Item,8)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1208");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1208");
}
[Test]
<td class=""Item6"">(6,Item,6)</td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1209");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1209");
}
[Test]
string exp = @"<table class=""mainstyle"">
</table>";
- Assert.AreEqual (exp, v, "#1210");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1210");
}
[Test]
<td class=""Item0"">(0,Item,0)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1211");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1211");
}
[Test]
<td class=""Item1"">(1,Item,1)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1212");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1212");
}
[Test]
<td class=""Item4"">(4,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1213");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1213");
}
[Test]
string exp = @"<table class=""mainstyle"">
</table>";
- Assert.AreEqual (exp, v, "#1214");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1214");
}
[Test]
<td class=""Item4"">(4,Item,4)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1215");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1215");
}
[Test]
<td class=""Item1"">(2,Item,1)</td><td class=""Item3"">(3,Item,3)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1216");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1216");
}
[Test]
<td class=""Item3"">(6,Item,3)</td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1217");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1217");
}
[Test]
<td class=""Item2"">(6,Item,2)</td><td class=""Item5"">(7,Item,5)</td><td class=""Item8"">(8,Item,8)</td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1218");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1218");
}
[Test]
<td class=""Item2"">(6,Item,2)</td><td></td><td></td>
</tr>
</table>";
- Assert.AreEqual (exp, v, "#1219");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1219");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle""></span>";
- Assert.AreEqual (exp, v, "#1220");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1220");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)</span>";
- Assert.AreEqual (exp, v, "#1221");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1221");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)</span>";
- Assert.AreEqual (exp, v, "#1222");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1222");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)(2,Item,2)(3,Item,3)(4,Item,4)</span>";
- Assert.AreEqual (exp, v, "#1223");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1223");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle""></span>";
- Assert.AreEqual (exp, v, "#1224");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1224");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Item,1)<br />(2,Item,2)<br />(3,Item,3)<br />(4,Item,4)<br /></span>";
- Assert.AreEqual (exp, v, "#1225");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1225");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)<br />(2,Item,2)(3,Item,3)<br /></span>";
- Assert.AreEqual (exp, v, "#1226");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1226");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,1)<br />(2,Item,2)(3,Item,3)<br />(4,Item,4)(5,Item,5)<br />(6,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#1227");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1227");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span>(0,Item,0)(1,Item,1)(2,Item,2)<br />(3,Item,3)(4,Item,4)(5,Item,5)<br />(6,Item,6)(7,Item,7)(8,Item,8)<br /></span>";
- Assert.AreEqual (exp, v, "#1228");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1228");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span>(0,Item,0)(1,Item,1)(2,Item,2)<br />(3,Item,3)(4,Item,4)(5,Item,5)<br />(6,Item,6)<br /></span>";
- Assert.AreEqual (exp, v, "#1229");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1229");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle""></span>";
- Assert.AreEqual (exp, v, "#1230");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1230");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 1, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)</span>";
- Assert.AreEqual (exp, v, "#1231");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1231");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 2, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Item,1)</span>";
- Assert.AreEqual (exp, v, "#1232");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1232");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (0, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Item,1)<br />(2,Item,2)<br />(3,Item,3)<br />(4,Item,4)</span>";
- Assert.AreEqual (exp, v, "#1233");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1233");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 0, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle""></span>";
- Assert.AreEqual (exp, v, "#1234");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1234");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (1, 5, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)<br />(1,Item,1)<br />(2,Item,2)<br />(3,Item,3)<br />(4,Item,4)</span>";
- Assert.AreEqual (exp, v, "#1235");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1235");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,2)<br />(2,Item,1)(3,Item,3)</span>";
- Assert.AreEqual (exp, v, "#1236");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1236");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span class=""mainstyle"">(0,Item,0)(1,Item,4)<br />(2,Item,1)(3,Item,5)<br />(4,Item,2)(5,Item,6)<br />(6,Item,3)</span>";
- Assert.AreEqual (exp, v, "#1237");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1237");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span>(0,Item,0)(1,Item,3)(2,Item,6)<br />(3,Item,1)(4,Item,4)(5,Item,7)<br />(6,Item,2)(7,Item,5)(8,Item,8)</span>";
- Assert.AreEqual (exp, v, "#1238");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1238");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Vertical, RepeatLayout.Flow, false, false, false, false);
string exp = @"<span>(0,Item,0)(1,Item,3)(2,Item,5)<br />(3,Item,1)(4,Item,4)(5,Item,6)<br />(6,Item,2)</span>";
- Assert.AreEqual (exp, v, "#1239");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1239");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.UnorderedList, false, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.UnorderedList, false, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.UnorderedList, false, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.UnorderedList, false, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
}
[Test]
string exp = @"<ul class=""mainstyle"">
</ul>";
- Assert.AreEqual (exp, v, "#1250");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1250");
}
[Test]
<li>(0,Item,0)</li>
</ul>";
- Assert.AreEqual (exp, v, "#1251");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1251");
}
[Test]
<li>(1,Item,1)</li>
</ul>";
- Assert.AreEqual (exp, v, "#1252");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1252");
}
[Test]
<li>(4,Item,4)</li>
</ul>";
- Assert.AreEqual (exp, v, "#1253");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1253");
}
[Test]
string exp = @"<ul class=""mainstyle"">
</ul>";
- Assert.AreEqual (exp, v, "#1254");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1254");
}
[Test]
<li>(4,Item,4)</li>
</ul>";
- Assert.AreEqual (exp, v, "#1255");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1255");
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 4, RepeatDirection.Horizontal, RepeatLayout.OrderedList, false, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (2, 7, RepeatDirection.Horizontal, RepeatLayout.OrderedList, false, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 9, RepeatDirection.Horizontal, RepeatLayout.OrderedList, false, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
}
[Test]
string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest (3, 7, RepeatDirection.Horizontal, RepeatLayout.OrderedList, false, false, false, false);
- // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.")
+ // Exception: System.InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.")
}
[Test]
string exp = @"<ol class=""mainstyle"">
</ol>";
- Assert.AreEqual (exp, v, "#1270");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1270");
}
[Test]
<li>(0,Item,0)</li>
</ol>";
- Assert.AreEqual (exp, v, "#1271");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1271");
}
[Test]
<li>(1,Item,1)</li>
</ol>";
- Assert.AreEqual (exp, v, "#1272");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1272");
}
[Test]
<li>(4,Item,4)</li>
</ol>";
- Assert.AreEqual (exp, v, "#1273");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1273");
}
[Test]
string exp = @"<ol class=""mainstyle"">
</ol>";
- Assert.AreEqual (exp, v, "#1274");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1274");
}
[Test]
<li>(4,Item,4)</li>
</ol>";
- Assert.AreEqual (exp, v, "#1275");
+ Assert.AreEqual (exp.Replace ("\r\n", "\n"), v, "#1275");
}
[Test]
sep ? "true" : "false");
if (ex == null) {
sb.AppendFormat (@" string exp = @""{0}"";
- Assert.AreEqual (exp, v, ""#{1}"");
+ Assert.AreEqual (exp.Replace (""\r\n"", ""\n""), v, ""#{1}"");
}}
", exp, num);
} else {
LIBRARY = System.Windows.Forms.DataVisualization.dll
LIB_REFS = System System.Drawing System.Windows.Forms System.Core System.Data System.Xml
-LIB_MCS_FLAGS =
+LIB_MCS_FLAGS = -nowarn:67
TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
EXTRA_DISTFILES =
<SchemaVersion>2.0</SchemaVersion>\r
<ProjectGuid>{C6A36476-0B2B-45BA-B4DD-05C39E63F3BE}</ProjectGuid>\r
<OutputType>Library</OutputType>\r
- <NoWarn>1699</NoWarn>\r
+ <NoWarn>1699,67</NoWarn>\r
<OutputPath>./../../class/lib/net_4_x</OutputPath>\r
<IntermediateOutputPath>obj-net_4_x</IntermediateOutputPath>\r
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>\r
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
<DebugSymbols>true</DebugSymbols>\r
<DebugType>full</DebugType>\r
- <NoWarn>1699</NoWarn>\r
+ <NoWarn>1699,67</NoWarn>\r
<Optimize>false</Optimize>\r
<DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM</DefineConstants>\r
<ErrorReport>prompt</ErrorReport>\r
</PropertyGroup>\r
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
<DebugType>pdbonly</DebugType>\r
- <NoWarn>1699</NoWarn>\r
+ <NoWarn>1699,67</NoWarn>\r
<Optimize>true</Optimize>\r
<DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM</DefineConstants>\r
<ErrorReport>prompt</ErrorReport>\r
public DataManipulator DataManipulator { get; private set;}
public Object DataSource { get; set; }
protected override Size DefaultSize { get { return base.DefaultSize; } }//FIXME
- public Font Font { get; set; }
public override Color ForeColor { get; set; }
public NamedImagesCollection Images { get; private set;}
public bool IsSoftShadows { get; set; }
public double RenderingDpiY { get; set; }
public ChartSerializer Serializer { get; private set; }
public SeriesCollection Series { get; private set; }
- public Size Size { get; set; }
public bool SuppressExceptions { get; set; }
public TextAntiAliasingQuality TextAntiAliasingQuality { get; set; }
public TitleCollection Titles { get; private set;}
string ret = @"<one>
<two>Some data.</two>
</one>";
- Assert.AreEqual (ret, nav.OuterXml.Replace ("\r\n", "\n"), "#1");
+ Assert.AreEqual (ret.Replace ("\r\n", "\n"), nav.OuterXml.Replace ("\r\n", "\n"), "#1");
}
[Test]
</child1>
<child2 />
<child3 />";
- Assert.AreEqual (result, n.OuterXml.Replace ("\r\n", "\n"), "#1");
+ Assert.AreEqual (result.Replace ("\r\n", "\n"), n.OuterXml.Replace ("\r\n", "\n"), "#1");
}
[Test] // bug #376191
StringWriter sw_raw = new StringWriter ();
t.Transform (d, null, sw_raw);
- Assert.AreEqual (ref_out, sw_raw.ToString ().Replace ("\r\n", "\n"));
+ Assert.AreEqual (ref_out.Replace ("\r\n", "\n"), sw_raw.ToString ().Replace ("\r\n", "\n"));
}
// http://support.microsoft.com/default.aspx?scid=kb;en-us;829014
public void CreateEvidenceForUrl_Basic ()
{
Evidence e = XmlSecureResolver.CreateEvidenceForUrl (null);
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
Assert.AreEqual (0, e.Count, "null");
#else
Assert.IsNull (e);
#endif
e = XmlSecureResolver.CreateEvidenceForUrl (String.Empty);
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
Assert.AreEqual (0, e.Count, "String.Empty");
#else
Assert.IsNull (e);
<!--AAA-->
<root />";
- Assert.AreEqual (xml, sw.ToString ().Replace ("\r\n", "\n"), "#1");
+ Assert.AreEqual (xml.Replace ("\r\n", "\n"), sw.ToString ().Replace ("\r\n", "\n"), "#1");
}
[Test]
--- /dev/null
+#include mobile_System.Xml.dll.sources
static Exception GetException (MonoBtlsSslError status)
{
- var error = MonoBtlsError.GetError ();
+ string file;
+ int line;
+ var error = MonoBtlsError.GetError (out file, out line);
+ if (error == 0)
+ return new MonoBtlsException (status);
+
var text = MonoBtlsError.GetErrorString (error);
- return new MonoBtlsException ("{0} {1}", status, text);
+
+ string message;
+ if (file != null)
+ message = string.Format ("{0} {1}\n at {2}:{3}", status, text, file, line);
+ else
+ message = string.Format ("{0} {1}", status, text);
+ return new MonoBtlsException (message);
}
public override bool ProcessHandshake ()
isAuthenticated = true;
}
- void SetupCertificateStore ()
- {
- MonoBtlsProvider.SetupCertificateStore (ctx.CertificateStore);
-
- if (Settings != null && Settings.TrustAnchors != null) {
- var trust = IsServer ? MonoBtlsX509TrustKind.TRUST_CLIENT : MonoBtlsX509TrustKind.TRUST_SERVER;
- ctx.CertificateStore.AddCollection (Settings.TrustAnchors, trust);
- }
- }
-
void InitializeConnection ()
{
ctx = new MonoBtlsSslCtx ();
ctx.SetDebugBio (errbio);
#endif
- SetupCertificateStore ();
+ MonoBtlsProvider.SetupCertificateStore (ctx.CertificateStore, Settings, IsServer);
if (!IsServer || AskForClientCertificate)
ctx.SetVerifyCallback (VerifyCallback, false);
[DllImport (MonoBtlsObject.BTLS_DYLIB)]
extern static void mono_btls_error_clear_error ();
+ [DllImport (MonoBtlsObject.BTLS_DYLIB)]
+ extern static int mono_btls_error_peek_error_line (out IntPtr file, out int line);
+
+ [DllImport (MonoBtlsObject.BTLS_DYLIB)]
+ extern static int mono_btls_error_get_error_line (out IntPtr file, out int line);
+
[DllImport (MonoBtlsObject.BTLS_DYLIB)]
extern static void mono_btls_error_get_error_string_n (int error, IntPtr buf, int len);
Marshal.FreeHGlobal (buffer);
}
}
+
+ public static int PeekError (out string file, out int line)
+ {
+ IntPtr filePtr;
+ var error = mono_btls_error_peek_error_line (out filePtr, out line);
+ if (filePtr != IntPtr.Zero)
+ file = Marshal.PtrToStringAnsi (filePtr);
+ else
+ file = null;
+ return error;
+ }
+
+ public static int GetError (out string file, out int line)
+ {
+ IntPtr filePtr;
+ var error = mono_btls_error_get_error_line (out filePtr, out line);
+ if (filePtr != IntPtr.Zero)
+ file = Marshal.PtrToStringAnsi (filePtr);
+ else
+ file = null;
+ return error;
+ }
}
}
#endif
using (var nativeChain = MonoBtlsProvider.GetNativeChain (certificates))
using (var param = GetVerifyParam (targetHost, serverMode))
using (var storeCtx = new MonoBtlsX509StoreCtx ()) {
- SetupCertificateStore (store);
+ SetupCertificateStore (store, validator.Settings, serverMode);
storeCtx.Initialize (store, nativeChain);
}
}
+ internal static void SetupCertificateStore (MonoBtlsX509Store store, MonoTlsSettings settings, bool server)
+ {
+ if (settings?.CertificateSearchPaths == null)
+ AddTrustedRoots (store, settings, server);
+
+#if MONODROID
+ SetupCertificateStore (store);
+ return;
+#else
+ if (settings?.CertificateSearchPaths == null) {
+ SetupCertificateStore (store);
+ return;
+ }
+
+ foreach (var path in settings.CertificateSearchPaths) {
+ if (string.Equals (path, "@default", StringComparison.Ordinal)) {
+ AddTrustedRoots (store, settings, server);
+ AddUserStore (store);
+ AddMachineStore (store);
+ } else if (string.Equals (path, "@user", StringComparison.Ordinal))
+ AddUserStore (store);
+ else if (string.Equals (path, "@machine", StringComparison.Ordinal))
+ AddMachineStore (store);
+ else if (string.Equals (path, "@trusted", StringComparison.Ordinal))
+ AddTrustedRoots (store, settings, server);
+ else if (path.StartsWith ("@pem:", StringComparison.Ordinal)) {
+ var realPath = path.Substring (5);
+ if (Directory.Exists (realPath))
+ store.AddDirectoryLookup (realPath, MonoBtlsX509FileType.PEM);
+ } else if (path.StartsWith ("@der:", StringComparison.Ordinal)) {
+ var realPath = path.Substring (5);
+ if (Directory.Exists (realPath))
+ store.AddDirectoryLookup (realPath, MonoBtlsX509FileType.ASN1);
+ } else {
+ if (Directory.Exists (path))
+ store.AddDirectoryLookup (path, MonoBtlsX509FileType.PEM);
+ }
+ }
+#endif
+ }
+
internal static void SetupCertificateStore (MonoBtlsX509Store store)
{
#if MONODROID
store.SetDefaultPaths ();
store.AddAndroidLookup ();
#else
+ AddUserStore (store);
+ AddMachineStore (store);
+#endif
+ }
+
+#if !MONODROID
+ static void AddUserStore (MonoBtlsX509Store store)
+ {
var userPath = MonoBtlsX509StoreManager.GetStorePath (MonoBtlsX509StoreType.UserTrustedRoots);
if (Directory.Exists (userPath))
store.AddDirectoryLookup (userPath, MonoBtlsX509FileType.PEM);
+ }
+
+ static void AddMachineStore (MonoBtlsX509Store store)
+ {
var machinePath = MonoBtlsX509StoreManager.GetStorePath (MonoBtlsX509StoreType.MachineTrustedRoots);
if (Directory.Exists (machinePath))
store.AddDirectoryLookup (machinePath, MonoBtlsX509FileType.PEM);
+ }
#endif
+
+ static void AddTrustedRoots (MonoBtlsX509Store store, MonoTlsSettings settings, bool server)
+ {
+ if (settings?.TrustAnchors == null)
+ return;
+ var trust = server ? MonoBtlsX509TrustKind.TRUST_CLIENT : MonoBtlsX509TrustKind.TRUST_SERVER;
+ store.AddCollection (settings.TrustAnchors, trust);
}
public static string GetSystemStoreLocation ()
[DllImport (BTLS_DYLIB)]
extern static IntPtr mono_btls_x509_lookup_peek_lookup (IntPtr handle);
+ MonoBtlsX509Store store;
MonoBtlsX509LookupType type;
List<MonoBtlsX509LookupMono> monoLookups;
-#if FIXME
- // Do we need this?
- internal MonoBtlsX509Lookup (BoringX509LookupHandle handle)
- : base (handle)
- {
- }
-#endif
-
static BoringX509LookupHandle Create_internal (MonoBtlsX509Store store, MonoBtlsX509LookupType type)
{
var handle = mono_btls_x509_lookup_new (
internal MonoBtlsX509Lookup (MonoBtlsX509Store store, MonoBtlsX509LookupType type)
: base (Create_internal (store, type))
{
+ this.store = store;
this.type = type;
}
var ret = mono_btls_x509_lookup_add_mono (
Handle.DangerousGetHandle (), monoLookup.Handle.DangerousGetHandle ());
CheckError (ret);
+ monoLookup.Install (this);
if (monoLookups == null)
monoLookups = new List<MonoBtlsX509LookupMono> ();
}
}
+ internal void AddCertificate (MonoBtlsX509 certificate)
+ {
+ store.AddCertificate (certificate);
+ }
+
protected override void Close ()
{
try {
IntPtr instance;
BySubjectFunc bySubjectFunc;
IntPtr bySubjectFuncPtr;
+ MonoBtlsX509Lookup lookup;
internal MonoBtlsX509LookupMono ()
: base (new BoringX509LookupMonoHandle (mono_btls_x509_lookup_mono_new ()))
mono_btls_x509_lookup_mono_init (Handle.DangerousGetHandle (), instance, bySubjectFuncPtr);
}
+ internal void Install (MonoBtlsX509Lookup lookup)
+ {
+ if (this.lookup != null)
+ throw new InvalidOperationException ();
+ this.lookup = lookup;
+ }
+
+ protected void AddCertificate (MonoBtlsX509 certificate)
+ {
+ lookup.AddCertificate (certificate);
+ }
+
protected abstract MonoBtlsX509 OnGetBySubject (MonoBtlsX509Name name);
#if MONOTOUCH
protected override MonoBtlsX509 OnGetBySubject (MonoBtlsX509Name name)
{
- Console.WriteLine ("COLLECTION LOOKUP: {0:x} - {1}", name.GetHash (), name.GetString ());
Initialize ();
var hash = name.GetHash ();
+ MonoBtlsX509 found = null;
+
for (int i = 0; i < certificates.Length; i++) {
- if (hashes [i] == hash)
- return certificates [i];
+ if (hashes [i] != hash)
+ continue;
+ found = certificates [i];
+ AddCertificate (found);
}
- return null;
+ return found;
}
protected override void Close ()
internal void AddTrustedRoots ()
{
- var systemRoot = MonoBtlsProvider.GetSystemStoreLocation ();
- LoadLocations (null, systemRoot);
+ MonoBtlsProvider.SetupCertificateStore (this);
}
public MonoBtlsX509Lookup AddLookup (MonoBtlsX509LookupType type)
void Import (byte[] data)
{
- // Does it look like PEM?
- if ((data.Length > 0) && (data [0] != 0x30))
- x509 = MonoBtlsX509.LoadFromData (data, MonoBtlsX509Format.PEM);
- else
- x509 = MonoBtlsX509.LoadFromData (data, MonoBtlsX509Format.DER);
+ if (data != null) {
+ // Does it look like PEM?
+ if ((data.Length > 0) && (data [0] != 0x30))
+ x509 = MonoBtlsX509.LoadFromData (data, MonoBtlsX509Format.PEM);
+ else
+ x509 = MonoBtlsX509.LoadFromData (data, MonoBtlsX509Format.DER);
+ }
}
void ImportPkcs12 (byte[] data, string password)
}
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
// and you must have discovery access to the combined path
// note: the cache behaviour is tested in the CAS tests
if (SecurityManager.SecurityEnabled) {
public string FileName {
get {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
if (SecurityManager.SecurityEnabled) {
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, filename).Demand ();
}
public static FileVersionInfo GetVersionInfo (string fileName)
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
if (SecurityManager.SecurityEnabled) {
new FileIOPermission (FileIOPermissionAccess.Read, fileName).Demand ();
}
return (new Process (new SafeProcessHandle (proc, false), processId));
}
+ public static Process[] GetProcessesByName(string processName, string machineName)
+ {
+ if (machineName == null)
+ throw new ArgumentNullException ("machineName");
+
+ if (!IsLocalMachine (machineName))
+ throw new NotImplementedException ();
+
+ Process[] processes = GetProcesses ();
+ if (processes.Length == 0)
+ return processes;
+
+ int size = 0;
+
+ for (int i = 0; i < processes.Length; i++) {
+ try {
+ if (String.Compare (processName, processes[i].ProcessName, true) == 0)
+ processes [size++] = processes[i];
+ } catch (SystemException) {
+ /* The process might exit between GetProcesses_internal and GetProcessById */
+ }
+ }
+
+ Array.Resize<Process> (ref processes, size);
+
+ return processes;
+ }
+
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static int[] GetProcesses_internal();
namespace System.Net.NetworkInformation {
-#if !MOBILE
+#if WIN_PLATFORM
class Win32IPAddressCollection : IPAddressCollection
{
public static readonly Win32IPAddressCollection Empty = new Win32IPAddressCollection (IntPtr.Zero);
}
}
-#if !MOBILE
+#if WIN_PLATFORM
class Win32IPGlobalProperties : IPGlobalProperties
{
public const int AF_INET = 2;
}
public override string DhcpScopeName {
- get { return Win32_FIXED_INFO.Instance.ScopeId; }
+ get { return Win32NetworkInterface.FixedInfo.ScopeId; }
}
public override string DomainName {
- get { return Win32_FIXED_INFO.Instance.DomainName; }
+ get { return Win32NetworkInterface.FixedInfo.DomainName; }
}
public override string HostName {
- get { return Win32_FIXED_INFO.Instance.HostName; }
+ get { return Win32NetworkInterface.FixedInfo.HostName; }
}
public override bool IsWinsProxy {
- get { return Win32_FIXED_INFO.Instance.EnableProxy != 0; }
+ get { return Win32NetworkInterface.FixedInfo.EnableProxy != 0; }
}
public override NetBiosNodeType NodeType {
- get { return Win32_FIXED_INFO.Instance.NodeType; }
+ get { return Win32NetworkInterface.FixedInfo.NodeType; }
}
// PInvokes
}
}
-#if !MOBILE
+#if WIN_PLATFORM
class Win32IPGlobalStatistics : IPGlobalStatistics
{
Win32_MIB_IPSTATS info;
protected UnixNetworkInterface iface;
List <IPAddress> addresses;
IPAddressCollection dns_servers;
- string dns_suffix;
- DateTime last_parse;
public UnixIPInterfaceProperties (UnixNetworkInterface iface, List <IPAddress> addresses)
{
#else
static Regex ns = new Regex (@"\s*nameserver\s+(?<address>.*)");
static Regex search = new Regex (@"\s*search\s+(?<domain>.*)");
+
+ string dns_suffix;
+ DateTime last_parse;
+
void ParseResolvConf ()
{
try {
}
}
-#if !MOBILE
+#if WIN_PLATFORM
class Win32IPInterfaceProperties2 : IPInterfaceProperties
{
readonly Win32_IP_ADAPTER_ADDRESSES addr;
public override IPv4InterfaceProperties GetIPv4Properties ()
{
Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
- return v4info != null ? new Win32IPv4InterfaceProperties (v4info, mib4) : null;
+ return new Win32IPv4InterfaceProperties (v4info, mib4);
}
public override IPv6InterfaceProperties GetIPv6Properties ()
{
Win32_IP_ADAPTER_INFO v6info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib6.Index);
- return v6info != null ? new Win32IPv6InterfaceProperties (mib6) : null;
+ return new Win32IPv6InterfaceProperties (mib6);
}
public override IPAddressInformationCollection AnycastAddresses {
get {
Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
// FIXME: should ipv6 DhcpServer be considered?
- return v4info != null ? new Win32IPAddressCollection (v4info.DhcpServer) : Win32IPAddressCollection.Empty;
+ try {
+ return new Win32IPAddressCollection (v4info.DhcpServer);
+ } catch (IndexOutOfRangeException) {
+ return Win32IPAddressCollection.Empty;
+ }
}
}
public override GatewayIPAddressInformationCollection GatewayAddresses {
get {
- Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
- // FIXME: should ipv6 DhcpServer be considered?
-
var col = new GatewayIPAddressInformationCollection ();
- if (v4info != null) {
+ try {
+ Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
+ // FIXME: should ipv6 DhcpServer be considered?
+
var a = v4info.GatewayList;
if (!String.IsNullOrEmpty (a.IpAddress)) {
col.InternalAdd(new SystemGatewayIPAddressInformation(IPAddress.Parse (a.IpAddress)));
AddSubsequently (a.Next, col);
}
- }
-
+ } catch (IndexOutOfRangeException) {}
return col;
}
}
}
public override bool IsDnsEnabled {
- get { return Win32_FIXED_INFO.Instance.EnableDns != 0; }
+ get { return Win32NetworkInterface.FixedInfo.EnableDns != 0; }
}
public override bool IsDynamicDnsEnabled {
public override UnicastIPAddressInformationCollection UnicastAddresses {
get {
- Win32_IP_ADAPTER_INFO ai = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
- // FIXME: should ipv6 DhcpServer be considered?
- return ai != null ? Win32FromUnicast (addr.FirstUnicastAddress) : new UnicastIPAddressInformationCollection ();
+ try {
+ Win32_IP_ADAPTER_INFO ai = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
+ // FIXME: should ipv6 DhcpServer be considered?
+ return Win32FromUnicast (addr.FirstUnicastAddress);
+ } catch (IndexOutOfRangeException) {
+ return new UnicastIPAddressInformationCollection ();
+ }
}
}
public override IPAddressCollection WinsServersAddresses {
get {
- Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
- // FIXME: should ipv6 DhcpServer be considered?
- return v4info != null ? new Win32IPAddressCollection (v4info.PrimaryWinsServer, v4info.SecondaryWinsServer) : Win32IPAddressCollection.Empty;
+ try {
+ Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index);
+ // FIXME: should ipv6 DhcpServer be considered?
+ return new Win32IPAddressCollection (v4info.PrimaryWinsServer, v4info.SecondaryWinsServer);
+ } catch (IndexOutOfRangeException) {
+ return Win32IPAddressCollection.Empty;
+ }
}
}
}
}
-#if !MOBILE
+#if WIN_PLATFORM
sealed class Win32IPv4InterfaceProperties : IPv4InterfaceProperties
{
[DllImport ("iphlpapi.dll")]
public override bool IsForwardingEnabled {
// Is it the right answer? In Vista there is MIB_IPINTERFACEROW.ForwardingEnabled, but not in former versions.
- get { return Win32_FIXED_INFO.Instance.EnableRouting != 0; }
+ get { return Win32NetworkInterface.FixedInfo.EnableRouting != 0; }
}
public override int Mtu {
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Net.NetworkInformation {
-#if !MOBILE
+#if WIN_PLATFORM
class Win32IPv4InterfaceStatistics : IPv4InterfaceStatistics
{
Win32_MIB_IFROW info;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Net.NetworkInformation {
-#if !MOBILE
+#if WIN_PLATFORM
class Win32IPv6InterfaceProperties : IPv6InterfaceProperties
{
Win32_MIB_IFROW mib;
}
}
-#if !MOBILE
+#if WIN_PLATFORM
class Win32IcmpV4Statistics : IcmpV4Statistics
{
Win32_MIBICMPSTATS iin, iout;
public const int RouterRenumbering = 138;
}
-#if !MOBILE
+#if WIN_PLATFORM
class Win32IcmpV6Statistics : IcmpV6Statistics
{
Win32_MIBICMPSTATS_EX iin, iout;
}
}
-#if !MOBILE
+#if WIN_PLATFORM
class Win32NetworkInterfaceAPI : NetworkInterfaceFactory
{
private const string IPHLPAPI = "iphlpapi.dll";
[DllImport (IPHLPAPI, SetLastError = true)]
- static extern int GetAdaptersAddresses (uint family, uint flags, IntPtr reserved, byte [] info, ref int size);
+ static extern int GetAdaptersAddresses (uint family, uint flags, IntPtr reserved, IntPtr info, ref int size);
[DllImport (IPHLPAPI)]
static extern uint GetBestInterfaceEx (byte[] ipAddress, out int index);
- unsafe static Win32_IP_ADAPTER_ADDRESSES [] GetAdaptersAddresses ()
+ static Win32_IP_ADAPTER_ADDRESSES [] GetAdaptersAddresses ()
{
- byte [] bytes = null;
+ IntPtr ptr = IntPtr.Zero;
int len = 0;
- GetAdaptersAddresses (0, 0, IntPtr.Zero, bytes, ref len);
- bytes = new byte [len];
- int ret = GetAdaptersAddresses (0, 0, IntPtr.Zero, bytes, ref len);
+ GetAdaptersAddresses (0, 0, IntPtr.Zero, ptr, ref len);
+ ptr = Marshal.AllocHGlobal(len);
+ int ret = GetAdaptersAddresses (0, 0, IntPtr.Zero, ptr, ref len);
if (ret != 0)
throw new NetworkInformationException (ret);
List<Win32_IP_ADAPTER_ADDRESSES> l = new List<Win32_IP_ADAPTER_ADDRESSES> ();
- fixed (byte* ptr = bytes) {
- Win32_IP_ADAPTER_ADDRESSES info;
- for (IntPtr p = (IntPtr) ptr; p != IntPtr.Zero; p = info.Next) {
- info = new Win32_IP_ADAPTER_ADDRESSES ();
- Marshal.PtrToStructure (p, info);
- l.Add (info);
- }
+ Win32_IP_ADAPTER_ADDRESSES info;
+ for (IntPtr p = ptr; p != IntPtr.Zero; p = info.Next) {
+ info = Marshal.PtrToStructure<Win32_IP_ADAPTER_ADDRESSES> (p);
+ l.Add (info);
}
+
return l.ToArray ();
}
return new LinuxNetworkInterfaceAPI ();
}
-#if !MOBILE
+#if WIN_PLATFORM
Version windowsVer51 = new Version (5, 1);
if (Environment.OSVersion.Version >= windowsVer51)
return new Win32NetworkInterfaceAPI ();
}
}
-#if !MOBILE
+#if WIN_PLATFORM
class Win32NetworkInterface2 : NetworkInterface
{
[DllImport ("iphlpapi.dll", SetLastError = true)]
- static extern int GetAdaptersInfo (byte [] info, ref int size);
+ static extern int GetAdaptersInfo (IntPtr info, ref int size);
[DllImport ("iphlpapi.dll", SetLastError = true)]
static extern int GetIfEntry (ref Win32_MIB_IFROW row);
foreach (Win32_IP_ADAPTER_INFO info in GetAdaptersInfo ())
if (info.Index == index)
return info;
- return null;
+ throw new IndexOutOfRangeException ("No adapter found for index " + index);
}
- unsafe static Win32_IP_ADAPTER_INFO [] GetAdaptersInfo ()
+ static Win32_IP_ADAPTER_INFO [] GetAdaptersInfo ()
{
- byte [] bytes = null;
int len = 0;
- GetAdaptersInfo (bytes, ref len);
- bytes = new byte [len];
- int ret = GetAdaptersInfo (bytes, ref len);
+ IntPtr ptr = IntPtr.Zero;
+ GetAdaptersInfo (ptr, ref len);
+ ptr = Marshal.AllocHGlobal(len);
+ int ret = GetAdaptersInfo (ptr, ref len);
if (ret != 0)
throw new NetworkInformationException (ret);
List<Win32_IP_ADAPTER_INFO> l = new List<Win32_IP_ADAPTER_INFO> ();
- fixed (byte* ptr = bytes) {
- Win32_IP_ADAPTER_INFO info;
- for (IntPtr p = (IntPtr) ptr; p != IntPtr.Zero; p = info.Next) {
- info = new Win32_IP_ADAPTER_INFO ();
- Marshal.PtrToStructure (p, info);
- l.Add (info);
- }
+ Win32_IP_ADAPTER_INFO info;
+ for (IntPtr p = ptr; p != IntPtr.Zero; p = info.Next) {
+ info = Marshal.PtrToStructure<Win32_IP_ADAPTER_INFO> (p);
+ l.Add (info);
}
return l.ToArray ();
}
return Send (addresses [0], timeout, buffer, options);
}
- static IPAddress GetNonLoopbackIP ()
+ static IPAddress GetNonLoopbackIPV4 ()
{
#pragma warning disable 618
foreach (IPAddress addr in Dns.GetHostByName (Dns.GetHostName ()).AddressList)
- if (!IPAddress.IsLoopback (addr))
+ if (!IPAddress.IsLoopback (addr) && addr.AddressFamily == AddressFamily.InterNetwork)
return addr;
#pragma warning restore 618
private PingReply SendPrivileged (IPAddress address, int timeout, byte [] buffer, PingOptions options)
{
IPEndPoint target = new IPEndPoint (address, 0);
- IPEndPoint client = new IPEndPoint (GetNonLoopbackIP (), 0);
+ IPEndPoint client = new IPEndPoint (GetNonLoopbackIPV4 (), 0);
// FIXME: support IPv6
using (Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp)) {
}
}
-#if !MOBILE
+#if WIN_PLATFORM
class Win32TcpStatistics : TcpStatistics
{
Win32_MIB_TCPSTATS info;
}
}
-#if !MOBILE
+#if WIN_PLATFORM
class Win32UdpStatistics : UdpStatistics
{
Win32_MIB_UDPSTATS info;
using System.Diagnostics.Contracts;
namespace System.Net.NetworkInformation {
-#if !MOBILE
+#if WIN_PLATFORM
class Win32UnicastIPAddressInformation : UnicastIPAddressInformation
{
Win32_IP_ADAPTER_UNICAST_ADDRESS info;
namespace System.Net.NetworkInformation
{
- // They are mostly defined in iptypes.h (included by iphlpapi.h).
- // grep around /usr/include/w32api/* for identifiers you are curious.
- [StructLayout (LayoutKind.Sequential)]
- class Win32_FIXED_INFO
- {
- // Can't have unresolvable pinvokes on ios
-#if !MOBILE
+
+ class Win32NetworkInterface {
+ // Can't have unresolvable pinvokes on ios
+#if WIN_PLATFORM
[DllImport ("iphlpapi.dll", SetLastError = true)]
- static extern int GetNetworkParams (byte [] bytes, ref int size);
+ static extern int GetNetworkParams (IntPtr ptr, ref int size);
#endif
- static Win32_FIXED_INFO fixed_info;
+ static Win32_FIXED_INFO fixedInfo;
+ static bool initialized = false;
- public static Win32_FIXED_INFO Instance {
+ public static Win32_FIXED_INFO FixedInfo {
get {
- if (fixed_info == null)
- fixed_info = GetInstance ();
- return fixed_info;
- }
- }
-
- static Win32_FIXED_INFO GetInstance ()
- {
-#if !MOBILE
- int len = 0;
- byte [] bytes = null;
- GetNetworkParams (null, ref len);
- bytes = new byte [len];
- GetNetworkParams (bytes, ref len);
- Win32_FIXED_INFO info = new Win32_FIXED_INFO ();
- unsafe {
- fixed (byte* ptr = bytes) {
- Marshal.PtrToStructure ((IntPtr) ptr, info);
- }
- }
- return info;
+ if (!initialized) {
+#if WIN_PLATFORM
+ int len = 0;
+ IntPtr ptr = IntPtr.Zero;
+ GetNetworkParams (ptr, ref len);
+ ptr = Marshal.AllocHGlobal(len);
+ GetNetworkParams (ptr, ref len);
+ fixedInfo = Marshal.PtrToStructure<Win32_FIXED_INFO> (ptr);
#else
- throw new NotImplementedException ();
+ throw new NotImplementedException ();
#endif
+ initialized = true;
+ }
+ return fixedInfo;
+ }
}
+ }
+
+ // They are mostly defined in iptypes.h (included by iphlpapi.h).
+ // grep around /usr/include/w32api/* for identifiers you are curious.
+
+ [StructLayout (LayoutKind.Sequential)]
+ struct Win32_FIXED_INFO
+ {
const int MAX_HOSTNAME_LEN = 128;
const int MAX_DOMAIN_NAME_LEN = 128;
const int MAX_SCOPE_ID_LEN = 256;
-
[MarshalAs (UnmanagedType.ByValTStr, SizeConst = MAX_HOSTNAME_LEN + 4)]
public string HostName;
[MarshalAs (UnmanagedType.ByValTStr, SizeConst = MAX_DOMAIN_NAME_LEN + 4)]
}
[StructLayout (LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- class Win32_IP_ADAPTER_ADDRESSES {
+ struct Win32_IP_ADAPTER_ADDRESSES {
public AlignmentUnion Alignment;
public IntPtr Next; // to Win32_IP_ADAPTER_ADDRESSES
[MarshalAs (UnmanagedType.LPStr)]
}
[StructLayout (LayoutKind.Sequential)]
- class Win32_IP_ADAPTER_INFO
+ struct Win32_IP_ADAPTER_INFO
{
const int MAX_ADAPTER_NAME_LENGTH = 256;
const int MAX_ADAPTER_DESCRIPTION_LENGTH = 128;
SynchronizationContext sc1 = new SynchronizationContext ();\r
SynchronizationContext sc2 = new SynchronizationContext ();\r
\r
-#if MOBILE && !MONODROID\r
+#if MONOTOUCH || XAMMAC\r
Assert.IsNotNull (SynchronizationContext.Current, "A1");\r
#else\r
Assert.IsNull (SynchronizationContext.Current, "A1");\r
}
}
#endif // MONO_FEATURE_PROCESS_START
+
+ [Test]
+ public void GetProcessesByName()
+ {
+ // This should return Process[0] or a Process[] with all the "foo" programs running
+ Process.GetProcessesByName ("foo");
+ }
}
}
Error: 0 :
bulldog Transfer: 0 : hoge, relatedActivityId=00000000-0000-0000-0000-000000000000
";
- Assert.AreEqual (expected, sw.ToString ().Replace ("\r\n", "\n"));
+ Assert.AreEqual (expected.Replace ("\r\n", "\n"), sw.ToString ().Replace ("\r\n", "\n"));
}
[Test]
Timestamp={1}
bulldog Transfer: 0 : hoge, relatedActivityId=00000000-0000-0000-0000-000000000000
", date.ToString ("o"), time); // date and time are in current culture
- Assert.AreEqual (expected, sw.ToString ().Replace ("\r\n", "\n"));
+ Assert.AreEqual (expected.Replace ("\r\n", "\n"), sw.ToString ().Replace ("\r\n", "\n"));
}
class MyTraceListener : TraceListener
[Test]
[Category ("NotOnMac")]
- public void ConnectedProperty ()
- {
+#if FULL_AOT_DESKTOP
+ [Ignore ("https://bugzilla.xamarin.com/show_bug.cgi?id=52157")]
+#endif
+ public void ConnectedProperty ()
+ {
TcpListener listener = new TcpListener (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
listener.Start();
"BeginSend #4");
}
- IPEndPoint ep = new IPEndPoint (Dns.GetHostEntry (string.Empty).AddressList[0], 1236);
-
+ IPAddress[] addresses = Dns.GetHostEntry (string.Empty).AddressList;
+ IPEndPoint ep = null;
+ foreach (IPAddress a in addresses) {
+ if (a.AddressFamily == AddressFamily.InterNetwork) {
+ ep = new IPEndPoint (a, 1236);
+ break;
+ }
+ }
BSCalledBack.Reset ();
client.BeginSend (bytes, bytes.Length, ep,
int port = NetworkHelpers.FindFreePort ();;
var h = new HttpListener ();
- h.Prefixes.Add ("http://" + machineAddress [0] + ":" + port + "/");
- h.Start ();
+ // Listen on the first IPV4 interface
+ foreach (IPAddress a in machineAddress) {
+ if (a.AddressFamily == AddressFamily.InterNetwork) {
+ h.Prefixes.Add ("http://" + a + ":" + port + "/");
+ h.Start ();
+ break;
+ }
+ }
try {
var c = new TcpClient ("localhost", port);
--- /dev/null
+#include common.sources
--- /dev/null
+#include testing_aot_full_System_test.dll.exclude.sources
LIBRARY = WindowsBase.dll
LIB_REFS = System System.Xml
-LIB_MCS_FLAGS = -unsafe
+LIB_MCS_FLAGS = -unsafe -nowarn:67,618
TEST_MCS_FLAGS = -unsafe
TEST_LIB_REFS = WindowsBase System System.Xml System.Core System.IO.Compression
<SchemaVersion>2.0</SchemaVersion>\r
<ProjectGuid>{A8F39368-ECD9-41A5-A562-CC7C82B3CC86}</ProjectGuid>\r
<OutputType>Library</OutputType>\r
- <NoWarn>1699</NoWarn>\r
+ <NoWarn>1699,67,618</NoWarn>\r
<OutputPath>./../../class/lib/net_4_x</OutputPath>\r
<IntermediateOutputPath>obj-net_4_x</IntermediateOutputPath>\r
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>\r
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
<DebugSymbols>true</DebugSymbols>\r
<DebugType>full</DebugType>\r
- <NoWarn>1699</NoWarn>\r
+ <NoWarn>1699,67,618</NoWarn>\r
<Optimize>false</Optimize>\r
<DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM</DefineConstants>\r
<ErrorReport>prompt</ErrorReport>\r
</PropertyGroup>\r
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
<DebugType>pdbonly</DebugType>\r
- <NoWarn>1699</NoWarn>\r
+ <NoWarn>1699,67,618</NoWarn>\r
<Optimize>true</Optimize>\r
<DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM</DefineConstants>\r
<ErrorReport>prompt</ErrorReport>\r
ifndef SKIP_AOT
-profile_file=$(wildcard $(topdir)/class/lib/build/csc.aotprofile)
+profile_file:=$(wildcard $(topdir)/class/lib/build/csc.*.aotprofile)
ifneq ($(profile_file),)
-profile_arg=,profile=$(profile_file)
+comma:=,
+space:=
+space+=
+profile_arg:=$(subst $(space)$(comma),$(comma),$(foreach pf,$(profile_file),$(comma)profile=$(strip $(pf))))
endif
ifdef PLATFORM_AOT_SUFFIX
$(mscorlib_aot_image): $(mscorlib_dll) $(runtime_dep)
$(Q_AOT) MONO_PATH='$(the_libdir)' > $(PROFILE)_aot.log 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg) --debug $(mscorlib_dll) || (cat $(PROFILE)_aot.log; exit 1)
-# Disabled as it hits AOT too big limit
$(csc_MC_image): $(csc_MC_dll) $(runtime_dep)
$(Q_AOT) MONO_PATH='$(the_libdir)' > $(PROFILE)_aot.log 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg),outfile=$(csc_MC_image) --debug $(csc_MC_dll) || (cat $(PROFILE)_aot.log; exit 1)
-# Disabled as it hits AOT too big limit
$(csc_MCS_image): $(csc_MCS_dll) $(runtime_dep)
$(Q_AOT) MONO_PATH='$(the_libdir)' > $(PROFILE)_aot.log 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg),outfile=$(csc_MCS_image) --debug $(csc_MCS_dll) || (cat $(PROFILE)_aot.log; exit 1)
ifdef ENABLE_AOT
-CSC_IMAGES = $(csc_aot_image) $(csc_SRM_image) $(csc_SCI_image)
+CSC_IMAGES = $(csc_aot_image) $(csc_SRM_image) $(csc_SCI_image) $(csc_MC_image) $(csc_MCS_image)
clean-local:
-rm -f $(mscorlib_aot_image) $(mcs_aot_image) $(CSC_IMAGES) $(PROFILE)_aot.log
# AOT build profile to speed up build
ifeq ($(PROFILE),build)
-# $(mscorlib_aot_image) is disabled due to runtime bug #50434
-IMAGES =
+IMAGES = $(mscorlib_aot_image)
ifdef MCS_MODE
IMAGES += $(mcs_aot_image)
-
-install-local:
-
else
IMAGES += $(CSC_IMAGES)
-
-install-local:
- $(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
- $(INSTALL_LIB) $(CSC_IMAGES) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
-
endif
all-local: $(IMAGES)
+install-local:
endif
ifeq ($(PROFILE), $(DEFAULT_PROFILE))
-IMAGES = $(mscorlib_aot_image) $(mcs_aot_image)
-
-ifdef MCS_MODE
-IMAGES += $(CSC_IMAGES)
-endif
+IMAGES = $(mscorlib_aot_image) $(mcs_aot_image) $(CSC_IMAGES)
all-local: $(IMAGES)
install-local:
$(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
- $(INSTALL_LIB) $(mscorlib_aot_image) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
- $(INSTALL_LIB) $(mcs_aot_image) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
+ $(INSTALL_LIB) $(IMAGES) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
+
endif
endif
endif
ifeq ($(PROFILE),build)
-CSC_RUNTIME_FLAGS=--profile=aot:output=$(topdir)/class/lib/build/csc.aotprofile
+CSC_RUNTIME_FLAGS=--profile=aot:output=$(topdir)/class/lib/$(PROFILE)/csc.$(LIBRARY).aotprofile
endif
RESOURCE_STRINGS = ../referencesource/mscorlib/mscorlib.txt
TEST_MCS_FLAGS += -d:MONO_FEATURE_MULTIPLE_APPDOMAINS
endif
+ifndef NO_CONSOLE
+LIB_MCS_FLAGS += -d:MONO_FEATURE_CONSOLE
+endif
+
WARNING_ABOUT_DISABLED_WARNING=1635
LOCAL_MCS_FLAGS = -unsafe -nostdlib -nowarn:612,618,$(WARNING_ABOUT_DISABLED_WARNING) -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC $(REFERENCE_SOURCES_FLAGS)
DEFAULT_REFERENCES =
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOBILE
+#if WIN_PLATFORM
using System;
using System.Text;
namespace Microsoft.Win32
{
-#if MOBILE
+#if MOBILE && !WIN_PLATFORM
public sealed class RegistryKey : IDisposable
{
internal RegistryKey (RegistryHive hiveId)
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOBILE
+#if WIN_PLATFORM
namespace Microsoft.Win32
{
public enum RegistryKeyPermissionCheck
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOBILE
+#if WIN_PLATFORM
using System;
using System.Collections;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOBILE
+#if WIN_PLATFORM
using System;
using System.Collections;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOBILE
+#if WIN_PLATFORM
using System;
using System.Runtime.InteropServices;
public partial class AppDomain
{
- internal String GetTargetFrameworkName()
- {
- return ".NETFramework,Version=v4.5";
- }
-
internal static bool IsAppXModel ()
{
return false;
public virtual string GetFileName()
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
if (SecurityManager.SecurityEnabled && (fileName != null) && (fileName.Length > 0)) {
string fn = Path.GetFullPath (fileName);
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, fn).Demand ();
// The above is an internal value used by Path.GetTempFile to
// get a file with 600 permissions, regardless of the umask
// settings. If a value "1" must be introduced here, update
- // both metadata/file-io.c and Path.GetTempFile
+ // both metadata/w32file.c and Path.GetTempFile
//
}
}
SecurityManager.EnsureElevatedPermissions (); // this is a no-op outside moonlight
-#if !MOBILE
+#if MONO_FEATURE_CAS
if (SecurityManager.SecurityEnabled) {
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, fullpath).Demand ();
}
return InsecureGetFullPath (path);
}
-#if !MOBILE
+#if WIN_PLATFORM
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa364963%28v=vs.85%29.aspx
[DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern int GetFullPathName(string path, int numBufferChars, StringBuilder buffer, ref IntPtr lpFilePartOrNull);
buffer = new StringBuilder(length);
GetFullPathName(path, length, buffer, ref ptr);
}
+
return buffer.ToString();
}
internal static string WindowsDriveAdjustment (string path)
{
+
// three special cases to consider when a drive is specified
if (path.Length < 2) {
if (path.Length == 1 && (path[0] == '\\' || path[0] == '/'))
string msg = Locale.GetText ("The specified path is not of a legal form (empty).");
throw new ArgumentException (msg);
}
-#if !MOBILE
+#if WIN_PLATFORM
// adjust for drives, i.e. a special case for windows
if (Environment.IsRunningOnWindows)
path = WindowsDriveAdjustment (path);
else {
string ret = String.Join (DirectorySeparatorStr, dirs, 0, target);
if (Environment.IsRunningOnWindows) {
-#if !MOBILE
+#if WIN_PLATFORM
// append leading '\' of the UNC path that was lost in STEP 3.
if (isUnc)
ret = Path.DirectorySeparatorStr + ret;
throw new ArgumentException (Locale.GetText ("Path is empty"));
if (path.IndexOfAny (Path.InvalidPathChars) != -1)
throw new ArgumentException (Locale.GetText ("Path contains invalid chars"));
-#if !MOBILE
+#if WIN_PLATFORM
if (Environment.IsRunningOnWindows) {
int idx = path.IndexOf (':');
if (idx >= 0 && idx != 1)
sealed class TypeBuilderInstantiation :
TypeInfo
{
- #region Keep in sync with object-internals.h
+ #region Keep in sync with object-internals.h MonoReflectionGenericClass
#pragma warning disable 649
internal Type generic_type;
Type[] type_arguments;
if (!suppressSecurityChecks)
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
#pragma warning disable 618
new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();
#pragma warning restore 618
throw new InsufficientExecutionStackException ();
}
+ public static bool TryEnsureSufficientExecutionStack ()
+ {
+ return SufficientExecutionStack ();
+ }
+
[MonoTODO("Currently a no-op")]
public static void ExecuteCodeWithGuaranteedCleanup (TryCode code, CleanupCode backoutCode, Object userData)
{
public abstract class NativeObjectSecurity : CommonObjectSecurity
{
ExceptionFromErrorCode exception_from_error_code;
-#if !MOBILE
+#if WIN_PLATFORM
ResourceType resource_type;
#endif
internal NativeObjectSecurity (CommonSecurityDescriptor securityDescriptor, ResourceType resourceType)
: base (securityDescriptor)
{
-#if !MOBILE
+#if WIN_PLATFORM
resource_type = resourceType;
#endif
}
: base (isContainer)
{
exception_from_error_code = exceptionFromErrorCode;
-#if !MOBILE
+#if WIN_PLATFORM
resource_type = resourceType;
#endif
}
internal virtual int InternalGet (SafeHandle handle,
AccessControlSections includeSections)
{
-#if MOBILE
+#if !WIN_PLATFORM
throw new PlatformNotSupportedException ();
#else
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
internal virtual int InternalGet (string name,
AccessControlSections includeSections)
{
-#if MOBILE
+#if !WIN_PLATFORM
throw new PlatformNotSupportedException ();
#else
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
#endif
}
-#if MOBILE
+#if !WIN_PLATFORM
internal virtual int InternalSet (SafeHandle handle, AccessControlSections includeSections)
{
throw new PlatformNotSupportedException ();
}
#if MOBILE
- [Conditional ("FEATURE_MONO_CAS")]
+ [Conditional ("MONO_FEATURE_CAS")]
#else
[MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
#endif
public abstract IPermission Copy ();
#if MOBILE
- [Conditional ("FEATURE_MONO_CAS")]
+ [Conditional ("MONO_FEATURE_CAS")]
#endif
public void Demand ()
{
}
#if MOBILE
- [Conditional ("FEATURE_MONO_CAS")]
+ [Conditional ("MONO_FEATURE_CAS")]
#else
[MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
#endif
}
#if MOBILE
- [Conditional ("FEATURE_MONO_CAS")]
+ [Conditional ("MONO_FEATURE_CAS")]
#else
[MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
#endif
}
#if MOBILE
- [Conditional ("FEATURE_MONO_CAS")]
+ [Conditional ("MONO_FEATURE_CAS")]
#else
[MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
#endif
}
#if MOBILE
- [Conditional ("FEATURE_MONO_CAS")]
+ [Conditional ("MONO_FEATURE_CAS")]
#else
[MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
#endif
}
#if MOBILE
- [Conditional ("FEATURE_MONO_CAS")]
+ [Conditional ("MONO_FEATURE_CAS")]
#else
[MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
#endif
}
#if MOBILE
- [Conditional ("FEATURE_MONO_CAS")]
+ [Conditional ("MONO_FEATURE_CAS")]
#else
[MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
#endif
private int abort_state_handle;
/* thread_id is only accessed from unmanaged code */
internal Int64 thread_id;
-
- /* start_notify is used by the runtime to signal that Start()
- * is ok to return
- */
private IntPtr stack_ptr;
private UIntPtr static_data; /* GC-tracked */
private IntPtr runtime_thread_info;
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOBILE
+#if MONO_FEATURE_CONSOLE
using System.Text;
using System.Runtime.InteropServices;
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOBILE
+#if MONO_FEATURE_CONSOLE
using System;
using System.Text;
{
public static partial class Console
{
-#if !MOBILE
+#if MONO_FEATURE_CONSOLE
private class WindowsConsole
{
public static bool ctrlHandlerAdded = false;
static Console ()
{
+#if MONO_FEATURE_CONSOLE
if (Environment.IsRunningOnWindows) {
-#if !MOBILE
//
// On Windows, follow the Windows tradition
//
// Use Latin 1 as it is fast and UTF-8 is never used as console code page
inputEncoding = outputEncoding = Encoding.Default;
}
+ } else
#endif
- } else {
+ {
//
// On Unix systems (128), do not output the
// UTF-8 ZWNBSP (zero-width non-breaking space).
static void SetupStreams (Encoding inputEncoding, Encoding outputEncoding)
{
-#if !MOBILE
+#if MONO_FEATURE_CONSOLE
if (!Environment.IsRunningOnWindows && ConsoleDriver.IsConsole) {
stdin = new CStreamReader (OpenStandardInput (0), inputEncoding);
stdout = TextWriter.Synchronized (new CStreamWriter (OpenStandardOutput (0), outputEncoding, true) { AutoFlush = true });
stderr = TextWriter.Synchronized (new CStreamWriter (OpenStandardError (0), outputEncoding, true) { AutoFlush = true });
} else
-#endif
+#endif
{
stdin = TextReader.Synchronized (new UnexceptionalStreamReader (OpenStandardInput (0), inputEncoding));
stdout.WriteLine (String.Format (format, args));
}
-
-#if !MOBILE
+#if MONO_FEATURE_CONSOLE
public static int Read ()
{
if ((stdin is CStreamReader) && ConsoleDriver.IsConsole) {
{
return stdin.ReadLine ();
}
-
#endif
// FIXME: Console should use these encodings when changed
}
}
-#if !MOBILE
+#if MONO_FEATURE_CONSOLE
public static ConsoleColor BackgroundColor {
get { return ConsoleDriver.BackgroundColor; }
set { ConsoleDriver.BackgroundColor = value; }
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOBILE
+#if MONO_FEATURE_CONSOLE
using System.IO;
using System.Runtime.CompilerServices;
/// </summary>
public static string GetEnvironmentVariable (string variable)
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
if (SecurityManager.SecurityEnabled) {
new EnvironmentPermission (EnvironmentPermissionAccess.Read, variable).Demand ();
}
else
dir = UnixGetFolderPath (folder, option);
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
if ((dir != null) && (dir.Length > 0) && SecurityManager.SecurityEnabled) {
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, dir).Demand ();
}
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOBILE
+#if MONO_FEATURE_CONSOLE
using System.Runtime.InteropServices;
using System.Text;
namespace System {
// https://github.com/dotnet/corefx
// src/System.Console/src/System/ConsolePal.Unix.cs
//
-#if !MOBILE
+#if MONO_FEATURE_CONSOLE
//
// Defining this writes the output to console.log
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOBILE
+#if MONO_FEATURE_CONSOLE
// These values are taken from 'man 5 terminfo' and /usr/include/term.h.
// They are the indexes for the numeric capabilities in a terminfo file.
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOBILE
+#if MONO_FEATURE_CONSOLE
using System.IO;
using System.Text;
namespace System {
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOBILE
+#if MONO_FEATURE_CONSOLE
// These values are taken from 'man 5 terminfo' and /usr/include/term.h.
// They are the indexes for the string capabilities in a terminfo file.
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+// Inspired by various parts of CoreRT, most notably TimeZoneInfo.WinRT.cs.
+
+#if !FULL_AOT_DESKTOP || WIN_PLATFORM
+
+using Microsoft.Win32;
+using System;
+using System.Collections;
+using System.Diagnostics;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.Diagnostics.Contracts;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading;
+
+namespace System
+{
+ partial class TimeZoneInfo
+ {
+
+ internal struct SYSTEMTIME
+ {
+ internal ushort wYear;
+ internal ushort wMonth;
+ internal ushort wDayOfWeek;
+ internal ushort wDay;
+ internal ushort wHour;
+ internal ushort wMinute;
+ internal ushort wSecond;
+ internal ushort wMilliseconds;
+ }
+
+ [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct TIME_ZONE_INFORMATION
+ {
+ internal int Bias;
+ [MarshalAs (UnmanagedType.ByValTStr, SizeConst=32)]
+ internal string StandardName;
+ internal SYSTEMTIME StandardDate;
+ internal int StandardBias;
+ [MarshalAs (UnmanagedType.ByValTStr, SizeConst=32)]
+ internal string DaylightName;
+ internal SYSTEMTIME DaylightDate;
+ internal int DaylightBias;
+ }
+
+ [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct DYNAMIC_TIME_ZONE_INFORMATION
+ {
+ internal TIME_ZONE_INFORMATION TZI;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)]
+ internal string TimeZoneKeyName;
+ internal byte DynamicDaylightTimeDisabled;
+ }
+
+ internal const uint TIME_ZONE_ID_INVALID = 0xffffffff;
+ internal const uint ERROR_NO_MORE_ITEMS = 259;
+
+ [DllImport ("api-ms-win-core-timezone-l1-1-0.dll")]
+ internal extern static uint EnumDynamicTimeZoneInformation (uint dwIndex, out DYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation);
+ [DllImport ("api-ms-win-core-timezone-l1-1-0.dll")]
+ internal extern static uint GetDynamicTimeZoneInformation (out DYNAMIC_TIME_ZONE_INFORMATION pTimeZoneInformation);
+ [DllImport ("api-ms-win-core-timezone-l1-1-0.dll")]
+ internal extern static uint GetDynamicTimeZoneInformationEffectiveYears(ref DYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation, out uint FirstYear, out uint LastYear);
+ [DllImport ("api-ms-win-core-timezone-l1-1-0.dll")]
+ internal extern static bool GetTimeZoneInformationForYear(ushort wYear, ref DYNAMIC_TIME_ZONE_INFORMATION pdtzi, out TIME_ZONE_INFORMATION ptzi);
+
+ internal static AdjustmentRule CreateAdjustmentRuleFromTimeZoneInformation (ref DYNAMIC_TIME_ZONE_INFORMATION timeZoneInformation, DateTime startDate, DateTime endDate, int defaultBaseUtcOffset)
+ {
+ bool supportsDst = (timeZoneInformation.TZI.StandardDate.wMonth != 0);
+
+ if (!supportsDst) {
+ if (timeZoneInformation.TZI.Bias == defaultBaseUtcOffset) {
+ // this rule will not contain any information to be used to adjust dates. just ignore it
+ return null;
+ }
+
+ return AdjustmentRule.CreateAdjustmentRule (
+ startDate,
+ endDate,
+ TimeSpan.Zero, // no daylight saving transition
+ TransitionTime.CreateFixedDateRule (DateTime.MinValue, 1, 1),
+ TransitionTime.CreateFixedDateRule (DateTime.MinValue.AddMilliseconds(1), 1, 1),
+ new TimeSpan(0, defaultBaseUtcOffset - timeZoneInformation.TZI.Bias, 0)); // Bias delta is all what we need from this rule
+ }
+
+ //
+ // Create an AdjustmentRule with TransitionTime objects
+ //
+ TransitionTime daylightTransitionStart;
+ if (!TransitionTimeFromTimeZoneInformation (timeZoneInformation, out daylightTransitionStart, true /* start date */)) {
+ return null;
+ }
+
+ TransitionTime daylightTransitionEnd;
+ if (!TransitionTimeFromTimeZoneInformation (timeZoneInformation, out daylightTransitionEnd, false /* end date */)) {
+ return null;
+ }
+
+ if (daylightTransitionStart.Equals(daylightTransitionEnd)) {
+ // this happens when the time zone does support DST but the OS has DST disabled
+ return null;
+ }
+
+ return AdjustmentRule.CreateAdjustmentRule (
+ startDate,
+ endDate,
+ new TimeSpan (0, -timeZoneInformation.TZI.DaylightBias, 0),
+ (TransitionTime) daylightTransitionStart,
+ (TransitionTime) daylightTransitionEnd,
+ new TimeSpan (0, defaultBaseUtcOffset - timeZoneInformation.TZI.Bias, 0));
+ }
+
+ //
+ // TransitionTimeFromTimeZoneInformation -
+ //
+ // Converts a TimeZoneInformation (REG_TZI_FORMAT struct) to a TransitionTime
+ //
+ // * when the argument 'readStart' is true the corresponding daylightTransitionTimeStart field is read
+ // * when the argument 'readStart' is false the corresponding dayightTransitionTimeEnd field is read
+ //
+ private static bool TransitionTimeFromTimeZoneInformation (DYNAMIC_TIME_ZONE_INFORMATION timeZoneInformation, out TransitionTime transitionTime, bool readStartDate)
+ {
+ //
+ // SYSTEMTIME -
+ //
+ // If the time zone does not support daylight saving time or if the caller needs
+ // to disable daylight saving time, the wMonth member in the SYSTEMTIME structure
+ // must be zero. If this date is specified, the DaylightDate value in the
+ // TIME_ZONE_INFORMATION structure must also be specified. Otherwise, the system
+ // assumes the time zone data is invalid and no changes will be applied.
+ //
+ bool supportsDst = (timeZoneInformation.TZI.StandardDate.wMonth != 0);
+
+ if (!supportsDst) {
+ transitionTime = default (TransitionTime);
+ return false;
+ }
+
+ //
+ // SYSTEMTIME -
+ //
+ // * FixedDateRule -
+ // If the Year member is not zero, the transition date is absolute; it will only occur one time
+ //
+ // * FloatingDateRule -
+ // To select the correct day in the month, set the Year member to zero, the Hour and Minute
+ // members to the transition time, the DayOfWeek member to the appropriate weekday, and the
+ // Day member to indicate the occurence of the day of the week within the month (first through fifth).
+ //
+ // Using this notation, specify the 2:00a.m. on the first Sunday in April as follows:
+ // Hour = 2,
+ // Month = 4,
+ // DayOfWeek = 0,
+ // Day = 1.
+ //
+ // Specify 2:00a.m. on the last Thursday in October as follows:
+ // Hour = 2,
+ // Month = 10,
+ // DayOfWeek = 4,
+ // Day = 5.
+ //
+ if (readStartDate) {
+ //
+ // read the "daylightTransitionStart"
+ //
+ if (timeZoneInformation.TZI.DaylightDate.wYear == 0) {
+ transitionTime = TransitionTime.CreateFloatingDateRule (
+ new DateTime (1, /* year */
+ 1, /* month */
+ 1, /* day */
+ timeZoneInformation.TZI.DaylightDate.wHour,
+ timeZoneInformation.TZI.DaylightDate.wMinute,
+ timeZoneInformation.TZI.DaylightDate.wSecond,
+ timeZoneInformation.TZI.DaylightDate.wMilliseconds),
+ timeZoneInformation.TZI.DaylightDate.wMonth,
+ timeZoneInformation.TZI.DaylightDate.wDay, /* Week 1-5 */
+ (DayOfWeek)timeZoneInformation.TZI.DaylightDate.wDayOfWeek);
+ } else {
+ transitionTime = TransitionTime.CreateFixedDateRule (
+ new DateTime (1, /* year */
+ 1, /* month */
+ 1, /* day */
+ timeZoneInformation.TZI.DaylightDate.wHour,
+ timeZoneInformation.TZI.DaylightDate.wMinute,
+ timeZoneInformation.TZI.DaylightDate.wSecond,
+ timeZoneInformation.TZI.DaylightDate.wMilliseconds),
+ timeZoneInformation.TZI.DaylightDate.wMonth,
+ timeZoneInformation.TZI.DaylightDate.wDay);
+ }
+ } else {
+ //
+ // read the "daylightTransitionEnd"
+ //
+ if (timeZoneInformation.TZI.StandardDate.wYear == 0) {
+ transitionTime = TransitionTime.CreateFloatingDateRule (
+ new DateTime (1, /* year */
+ 1, /* month */
+ 1, /* day */
+ timeZoneInformation.TZI.StandardDate.wHour,
+ timeZoneInformation.TZI.StandardDate.wMinute,
+ timeZoneInformation.TZI.StandardDate.wSecond,
+ timeZoneInformation.TZI.StandardDate.wMilliseconds),
+ timeZoneInformation.TZI.StandardDate.wMonth,
+ timeZoneInformation.TZI.StandardDate.wDay, /* Week 1-5 */
+ (DayOfWeek)timeZoneInformation.TZI.StandardDate.wDayOfWeek);
+ } else {
+ transitionTime = TransitionTime.CreateFixedDateRule (
+ new DateTime (1, /* year */
+ 1, /* month */
+ 1, /* day */
+ timeZoneInformation.TZI.StandardDate.wHour,
+ timeZoneInformation.TZI.StandardDate.wMinute,
+ timeZoneInformation.TZI.StandardDate.wSecond,
+ timeZoneInformation.TZI.StandardDate.wMilliseconds),
+ timeZoneInformation.TZI.StandardDate.wMonth,
+ timeZoneInformation.TZI.StandardDate.wDay);
+ }
+ }
+
+ return true;
+ }
+
+ internal static TimeZoneInfo TryCreateTimeZone (DYNAMIC_TIME_ZONE_INFORMATION timeZoneInformation)
+ {
+ uint firstYear = 0, lastYear = 0;
+ AdjustmentRule rule;
+ AdjustmentRule[] zoneRules = null;
+ int defaultBaseUtcOffset = timeZoneInformation.TZI.Bias;
+
+ if (String.IsNullOrEmpty (timeZoneInformation.TimeZoneKeyName))
+ return null;
+
+ //
+ // First get the adjustment rules
+ //
+
+ try {
+ if (GetDynamicTimeZoneInformationEffectiveYears (ref timeZoneInformation, out firstYear, out lastYear) == 0) {
+ firstYear = lastYear = 0;
+ }
+ } catch {
+ // If we don't have GetDynamicTimeZoneInformationEffectiveYears()
+ firstYear = lastYear = 0;
+ }
+
+ if (firstYear == lastYear) {
+ rule = CreateAdjustmentRuleFromTimeZoneInformation (ref timeZoneInformation, DateTime.MinValue.Date, DateTime.MaxValue.Date, defaultBaseUtcOffset);
+ if (rule != null)
+ zoneRules = new AdjustmentRule [1] { rule };
+ } else {
+ DYNAMIC_TIME_ZONE_INFORMATION dtzi = default (DYNAMIC_TIME_ZONE_INFORMATION);
+ List<AdjustmentRule> rules = new List<AdjustmentRule> ();
+ //
+ // First rule
+ //
+
+ if (!GetTimeZoneInformationForYear ((ushort) firstYear, ref timeZoneInformation, out dtzi.TZI))
+ return null;
+ rule = CreateAdjustmentRuleFromTimeZoneInformation (ref dtzi, DateTime.MinValue.Date, new DateTime ((int) firstYear, 12, 31), defaultBaseUtcOffset);
+ if (rule != null)
+ rules.Add (rule);
+
+ for (uint i = firstYear + 1; i < lastYear; i++) {
+ if (!GetTimeZoneInformationForYear ((ushort) i, ref timeZoneInformation, out dtzi.TZI))
+ return null;
+ rule = CreateAdjustmentRuleFromTimeZoneInformation (ref dtzi, new DateTime ((int) i, 1, 1), new DateTime ((int) i, 12, 31), defaultBaseUtcOffset);
+ if (rule != null)
+ rules.Add (rule);
+ }
+
+ //
+ // Last rule
+ //
+
+ if (!GetTimeZoneInformationForYear ((ushort) lastYear, ref timeZoneInformation, out dtzi.TZI))
+ return null;
+ rule = CreateAdjustmentRuleFromTimeZoneInformation (ref dtzi, new DateTime ((int) lastYear, 1, 1), DateTime.MaxValue.Date, defaultBaseUtcOffset);
+ if (rule != null)
+ rules.Add (rule);
+
+ if (rules.Count > 0)
+ zoneRules = rules.ToArray ();
+ }
+
+ return new TimeZoneInfo (
+ timeZoneInformation.TimeZoneKeyName,
+ new TimeSpan (0, -(timeZoneInformation.TZI.Bias), 0),
+ timeZoneInformation.TZI.StandardName, // we use the display name as the standared names
+ timeZoneInformation.TZI.StandardName,
+ timeZoneInformation.TZI.DaylightName,
+ zoneRules,
+ false);
+ }
+
+ internal static TimeZoneInfo GetLocalTimeZoneInfoWinRTFallback ()
+ {
+ try {
+ DYNAMIC_TIME_ZONE_INFORMATION dtzi;
+ var result = GetDynamicTimeZoneInformation (out dtzi);
+ if (result == TIME_ZONE_ID_INVALID)
+ return Utc;
+ TimeZoneInfo timeZoneInfo = TryCreateTimeZone (dtzi);
+ return timeZoneInfo != null ? timeZoneInfo : Utc;
+ } catch {
+ return Utc;
+ }
+ }
+
+ internal static TimeZoneInfo FindSystemTimeZoneByIdWinRTFallback (string id)
+ {
+ foreach (var tzi in GetSystemTimeZones ()) {
+ if (String.Compare (id, tzi.Id, StringComparison.Ordinal) == 0)
+ return tzi;
+ }
+
+ throw new TimeZoneNotFoundException ();
+ }
+
+ internal static List<TimeZoneInfo> GetSystemTimeZonesWinRTFallback ()
+ {
+ var result = new List<TimeZoneInfo> ();
+ try {
+ uint index = 0;
+ DYNAMIC_TIME_ZONE_INFORMATION dtzi;
+ while (EnumDynamicTimeZoneInformation (index++, out dtzi) != ERROR_NO_MORE_ITEMS) {
+ var timeZoneInfo = TryCreateTimeZone (dtzi);
+ if (timeZoneInfo != null)
+ result.Add (timeZoneInfo);
+ }
+ } catch {
+ // EnumDynamicTimeZoneInformation() might not be available.
+ }
+
+ if (result.Count == 0)
+ result.Add (Local);
+ return result;
+ }
+ }
+}
+
+#endif // !FULL_AOT_DESKTOP || WIN_PLATFORM
#if !MONODROID && !MONOTOUCH && !XAMMAC
static TimeZoneInfo CreateLocal ()
{
-#if !FULL_AOT_DESKTOP
+#if !FULL_AOT_DESKTOP || WIN_PLATFORM
if (IsWindows && LocalZoneKey != null) {
string name = (string)LocalZoneKey.GetValue ("TimeZoneKeyName");
if (name == null)
name = TrimSpecial (name);
if (name != null)
return TimeZoneInfo.FindSystemTimeZoneById (name);
+ } else if (IsWindows) {
+ return GetLocalTimeZoneInfoWinRTFallback ();
}
#endif
static void GetSystemTimeZonesCore (List<TimeZoneInfo> systemTimeZones)
{
-#if !FULL_AOT_DESKTOP
+#if !FULL_AOT_DESKTOP || WIN_PLATFORM
if (TimeZoneKey != null) {
foreach (string id in TimeZoneKey.GetSubKeyNames ()) {
try {
} catch {}
}
+ return;
+ } else if (IsWindows) {
+ systemTimeZones.AddRange (GetSystemTimeZonesWinRTFallback ());
return;
}
#endif
#endif
private AdjustmentRule [] adjustmentRules;
-#if !MOBILE || !FULL_AOT_DESKTOP
+#if !MOBILE || !FULL_AOT_DESKTOP || WIN_PLATFORM
/// <summary>
/// Determine whether windows of not (taken Stephane Delcroix's code)
/// </summary>
return str.Substring (Istart, Iend-Istart+1);
}
-#if !FULL_AOT_DESKTOP
+#if !FULL_AOT_DESKTOP || WIN_PLATFORM
static RegistryKey timeZoneKey;
static RegistryKey TimeZoneKey {
get {
if (!IsWindows)
return null;
- return timeZoneKey = Registry.LocalMachine.OpenSubKey (
- "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
- false);
+ try {
+ return timeZoneKey = Registry.LocalMachine.OpenSubKey (
+ "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
+ false);
+ } catch {
+ return null;
+ }
}
}
if (!IsWindows)
return null;
- return localZoneKey = Registry.LocalMachine.OpenSubKey (
- "SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation", false);
+ try {
+ return localZoneKey = Registry.LocalMachine.OpenSubKey (
+ "SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation", false);
+ } catch {
+ return null;
+ }
}
}
#endif
-#endif // !MOBILE || !FULL_AOT_DESKTOP
+#endif // !MOBILE || !FULL_AOT_DESKTOP || WIN_PLATFORM
private static bool TryAddTicks (DateTime date, long ticks, out DateTime result, DateTimeKind kind = DateTimeKind.Unspecified)
{
//FIXME: this method should check for cached values in systemTimeZones
if (id == null)
throw new ArgumentNullException ("id");
-#if !MOBILE
+#if WIN_PLATFORM
if (TimeZoneKey != null)
{
if (id == "Coordinated Universal Time")
if (key == null)
throw new TimeZoneNotFoundException ();
return FromRegistryKey(id, key);
+ } else if (IsWindows) {
+ return FindSystemTimeZoneByIdWinRTFallback (id);
}
#endif
// Local requires special logic that already exists in the Local property (bug #326)
}
#endif
-#if !MOBILE
+#if WIN_PLATFORM
private static TimeZoneInfo FromRegistryKey (string id, RegistryKey key)
{
byte [] reg_tzi = (byte []) key.GetValue ("TZI");
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !MOBILE
+#if MONO_FEATURE_CONSOLE
using System.Runtime.InteropServices;
using System.Text;
namespace System {
Assert.Throws<TypeLoadException> (delegate { var ft = r.GetField("sr").FieldType; });
}
+ [Test]
+ public void GetGenericTypeDefinitionAfterCreateReturnsBuilder () {
+ var aname = new AssemblyName ("genericDefnAfterCreate");
+ var ab = AppDomain.CurrentDomain.DefineDynamicAssembly (aname, AssemblyBuilderAccess.Run);
+ var mb = ab.DefineDynamicModule (aname.Name);
+ var buildX = mb.DefineType ("X", TypeAttributes.Public);
+ buildX.DefineGenericParameters ("T", "U");
+ var x = buildX.CreateType ();
+ var inst = x.MakeGenericType (typeof (string), typeof (int));
+ var defX = inst.GetGenericTypeDefinition ();
+
+ Assert.AreSame (buildX, defX);
+ }
}
}
// aot may assert when loading. This assumes that it's
// safe to greedly load everything.
#if FULL_AOT_DESKTOP
- string [] names = { "testing_aot_full_corlib_test" };
+ string [] names = { "testing_aot_full_corlib_test", "winaot_corlib_test" };
#else
string [] names = { "corlib_test_net_1_1", "corlib_test_net_2_0", "corlib_test_net_4_0", "corlib_test_net_4_5", "net_4_x_corlib_test", "corlib_plattest", "mscorlibtests", "BclTests" };
#endif
// (C) 2004 Motus Technologies Inc. (http://www.motus.com)
//
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
using NUnit.Framework;
using System;
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
using System;
using System.Security;
}
}
-#endif
\ No newline at end of file
+#endif
using System.Globalization;
using System.Security.Principal;
using System.Threading;
+using System.Threading.Tasks;
using System.Reflection;
using System.Collections.Generic;
using SD = System.Diagnostics;
}
#endif // MONO_FEATURE_MULTIPLE_APPDOMAINS
+ [Test]
+ public void SetNameInThreadPoolThread ()
+ {
+ for (int i = 0; i < 10; ++i) {
+ Task t = Task.Run (delegate () {
+ Thread.CurrentThread.Name = "x/" + i;
+ Assert.AreEqual (Thread.CurrentThread.Name, "x/" + i, "#1");
+
+ try {
+ Thread.CurrentThread.Name = "y/" + i;
+ Assert.Fail ("#2");
+ } catch (InvalidOperationException) {
+ }
+ });
+
+ t.Wait ();
+ }
+ }
+
void CheckIsRunning (string s, Thread t)
{
int c = counter;
Delegate.CreateDelegate(typeof(Action), this, m);
}
+ [Test]
+ public void ReflectedTypeInheritedVirtualMethod ()
+ {
+ var a = new DerivedClass ();
+
+ Action m = a.MyMethod;
+ Assert.AreEqual (typeof (BaseClass), m.Method.ReflectedType);
+ }
+
+ class BaseClass
+ {
+ public virtual void MyMethod() {
+ Console.WriteLine ("Base method");
+ }
+ }
+
+ class DerivedClass : BaseClass
+ {
+ }
+
public void AnyGenericMethod<T>()
{
}
dto.ToLocalTime ();
}
-#if MOBILE
+#if !WIN_PLATFORM
// On device we cannot read the OS file system to look for /etc/localtime
// and /usr/share/zoneinfo - so we must initialize the BCL TimeZoneInfo
// from NSTimeZoneInfo. The tests here check the code paths between the
// now it fails on Snow Leopard the same way (incomplete data) with iOS5 simulator (OS update ?)
// but it *never*ever* failed on devices
incomplete_data_on_simulator_only_bug = true;
-#if XAMCORE_2_0 || MONOTOUCH
+#if MONOTOUCH
#if XAMCORE_2_0
if (ObjCRuntime.Runtime.Arch == ObjCRuntime.Arch.SIMULATOR)
if (MonoTouch.ObjCRuntime.Runtime.Arch == MonoTouch.ObjCRuntime.Arch.SIMULATOR)
#endif
Assert.Ignore ("known to fail on some iOS simulator versions - see source comments");
-#endif // XAMCORE_2_0 || MONOTOUCH
+#endif // MONOTOUCH
}
}
#endif
<DebugType>full</DebugType>\r
<NoWarn>612,618,1635,1699</NoWarn>\r
<Optimize>false</Optimize>\r
- <DefineConstants>TRACE;INSIDE_CORLIB;MONO_CULTURE_DATA;LIBC;FEATURE_PAL;GENERICS_WORK;FEATURE_LIST_PREDICATES;FEATURE_SERIALIZATION;FEATURE_ASCII;FEATURE_LATIN1;FEATURE_UTF7;FEATURE_UTF32;MONO_HYBRID_ENCODING_SUPPORT;FEATURE_ASYNC_IO;NEW_EXPERIMENTAL_ASYNC_IO;FEATURE_UTF32;FEATURE_EXCEPTIONDISPATCHINFO;FEATURE_CORRUPTING_EXCEPTIONS;FEATURE_EXCEPTION_NOTIFICATIONS;FEATURE_STRONGNAME_MIGRATION;FEATURE_USE_LCID;FEATURE_FUSION;FEATURE_CRYPTO;FEATURE_X509_SECURESTRINGS;FEATURE_SYNCHRONIZATIONCONTEXT;FEATURE_SYNCHRONIZATIONCONTEXT_WAIT;HAS_CORLIB_CONTRACTS;FEATURE_MACL;FEATURE_REMOTING;MONO_COM;FEATURE_COMINTEROP;FEATURE_ROLE_BASED_SECURITY;MONO_FEATURE_THREAD_ABORT;MONO_FEATURE_THREAD_SUSPEND_RESUME;MONO_FEATURE_MULTIPLE_APPDOMAINS;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;FEATURE_PAL;GENERICS_WORK;FEATURE_LIST_PREDICATES;FEATURE_SERIALIZATION;FEATURE_ASCII;FEATURE_LATIN1;FEATURE_UTF7;FEATURE_UTF32;MONO_HYBRID_ENCODING_SUPPORT;FEATURE_ASYNC_IO;NEW_EXPERIMENTAL_ASYNC_IO;FEATURE_UTF32;FEATURE_EXCEPTIONDISPATCHINFO;FEATURE_CORRUPTING_EXCEPTIONS;FEATURE_EXCEPTION_NOTIFICATIONS;FEATURE_STRONGNAME_MIGRATION;FEATURE_USE_LCID;FEATURE_FUSION;FEATURE_CRYPTO;FEATURE_X509_SECURESTRINGS;FEATURE_SYNCHRONIZATIONCONTEXT;FEATURE_SYNCHRONIZATIONCONTEXT_WAIT;HAS_CORLIB_CONTRACTS;FEATURE_MACL;FEATURE_REMOTING;MONO_COM;FEATURE_COMINTEROP;FEATURE_ROLE_BASED_SECURITY;MONO_FEATURE_THREAD_ABORT;MONO_FEATURE_THREAD_SUSPEND_RESUME;MONO_FEATURE_MULTIPLE_APPDOMAINS</DefineConstants>\r
+ <DefineConstants>TRACE;INSIDE_CORLIB;MONO_CULTURE_DATA;LIBC;FEATURE_PAL;GENERICS_WORK;FEATURE_LIST_PREDICATES;FEATURE_SERIALIZATION;FEATURE_ASCII;FEATURE_LATIN1;FEATURE_UTF7;FEATURE_UTF32;MONO_HYBRID_ENCODING_SUPPORT;FEATURE_ASYNC_IO;NEW_EXPERIMENTAL_ASYNC_IO;FEATURE_UTF32;FEATURE_EXCEPTIONDISPATCHINFO;FEATURE_CORRUPTING_EXCEPTIONS;FEATURE_EXCEPTION_NOTIFICATIONS;FEATURE_STRONGNAME_MIGRATION;FEATURE_USE_LCID;FEATURE_FUSION;FEATURE_CRYPTO;FEATURE_X509_SECURESTRINGS;FEATURE_SYNCHRONIZATIONCONTEXT;FEATURE_SYNCHRONIZATIONCONTEXT_WAIT;HAS_CORLIB_CONTRACTS;FEATURE_MACL;FEATURE_REMOTING;MONO_COM;FEATURE_COMINTEROP;FEATURE_ROLE_BASED_SECURITY;MONO_FEATURE_THREAD_ABORT;MONO_FEATURE_THREAD_SUSPEND_RESUME;MONO_FEATURE_MULTIPLE_APPDOMAINS;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;FEATURE_PAL;GENERICS_WORK;FEATURE_LIST_PREDICATES;FEATURE_SERIALIZATION;FEATURE_ASCII;FEATURE_LATIN1;FEATURE_UTF7;FEATURE_UTF32;MONO_HYBRID_ENCODING_SUPPORT;FEATURE_ASYNC_IO;NEW_EXPERIMENTAL_ASYNC_IO;FEATURE_UTF32;FEATURE_EXCEPTIONDISPATCHINFO;FEATURE_CORRUPTING_EXCEPTIONS;FEATURE_EXCEPTION_NOTIFICATIONS;FEATURE_STRONGNAME_MIGRATION;FEATURE_USE_LCID;FEATURE_FUSION;FEATURE_CRYPTO;FEATURE_X509_SECURESTRINGS;FEATURE_SYNCHRONIZATIONCONTEXT;FEATURE_SYNCHRONIZATIONCONTEXT_WAIT;HAS_CORLIB_CONTRACTS;FEATURE_MACL;FEATURE_REMOTING;MONO_COM;FEATURE_COMINTEROP;FEATURE_ROLE_BASED_SECURITY;MONO_FEATURE_THREAD_ABORT;MONO_FEATURE_THREAD_SUSPEND_RESUME;MONO_FEATURE_MULTIPLE_APPDOMAINS;MONO_FEATURE_CONSOLE</DefineConstants>\r
<ErrorReport>prompt</ErrorReport>\r
<WarningLevel>4</WarningLevel>\r
</PropertyGroup>\r
<DebugType>pdbonly</DebugType>\r
<NoWarn>612,618,1635,1699</NoWarn>\r
<Optimize>true</Optimize>\r
- <DefineConstants>INSIDE_CORLIB;MONO_CULTURE_DATA;LIBC;FEATURE_PAL;GENERICS_WORK;FEATURE_LIST_PREDICATES;FEATURE_SERIALIZATION;FEATURE_ASCII;FEATURE_LATIN1;FEATURE_UTF7;FEATURE_UTF32;MONO_HYBRID_ENCODING_SUPPORT;FEATURE_ASYNC_IO;NEW_EXPERIMENTAL_ASYNC_IO;FEATURE_UTF32;FEATURE_EXCEPTIONDISPATCHINFO;FEATURE_CORRUPTING_EXCEPTIONS;FEATURE_EXCEPTION_NOTIFICATIONS;FEATURE_STRONGNAME_MIGRATION;FEATURE_USE_LCID;FEATURE_FUSION;FEATURE_CRYPTO;FEATURE_X509_SECURESTRINGS;FEATURE_SYNCHRONIZATIONCONTEXT;FEATURE_SYNCHRONIZATIONCONTEXT_WAIT;HAS_CORLIB_CONTRACTS;FEATURE_MACL;FEATURE_REMOTING;MONO_COM;FEATURE_COMINTEROP;FEATURE_ROLE_BASED_SECURITY;MONO_FEATURE_THREAD_ABORT;MONO_FEATURE_THREAD_SUSPEND_RESUME;MONO_FEATURE_MULTIPLE_APPDOMAINS;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;FEATURE_PAL;GENERICS_WORK;FEATURE_LIST_PREDICATES;FEATURE_SERIALIZATION;FEATURE_ASCII;FEATURE_LATIN1;FEATURE_UTF7;FEATURE_UTF32;MONO_HYBRID_ENCODING_SUPPORT;FEATURE_ASYNC_IO;NEW_EXPERIMENTAL_ASYNC_IO;FEATURE_UTF32;FEATURE_EXCEPTIONDISPATCHINFO;FEATURE_CORRUPTING_EXCEPTIONS;FEATURE_EXCEPTION_NOTIFICATIONS;FEATURE_STRONGNAME_MIGRATION;FEATURE_USE_LCID;FEATURE_FUSION;FEATURE_CRYPTO;FEATURE_X509_SECURESTRINGS;FEATURE_SYNCHRONIZATIONCONTEXT;FEATURE_SYNCHRONIZATIONCONTEXT_WAIT;HAS_CORLIB_CONTRACTS;FEATURE_MACL;FEATURE_REMOTING;MONO_COM;FEATURE_COMINTEROP;FEATURE_ROLE_BASED_SECURITY;MONO_FEATURE_THREAD_ABORT;MONO_FEATURE_THREAD_SUSPEND_RESUME;MONO_FEATURE_MULTIPLE_APPDOMAINS</DefineConstants>\r
+ <DefineConstants>INSIDE_CORLIB;MONO_CULTURE_DATA;LIBC;FEATURE_PAL;GENERICS_WORK;FEATURE_LIST_PREDICATES;FEATURE_SERIALIZATION;FEATURE_ASCII;FEATURE_LATIN1;FEATURE_UTF7;FEATURE_UTF32;MONO_HYBRID_ENCODING_SUPPORT;FEATURE_ASYNC_IO;NEW_EXPERIMENTAL_ASYNC_IO;FEATURE_UTF32;FEATURE_EXCEPTIONDISPATCHINFO;FEATURE_CORRUPTING_EXCEPTIONS;FEATURE_EXCEPTION_NOTIFICATIONS;FEATURE_STRONGNAME_MIGRATION;FEATURE_USE_LCID;FEATURE_FUSION;FEATURE_CRYPTO;FEATURE_X509_SECURESTRINGS;FEATURE_SYNCHRONIZATIONCONTEXT;FEATURE_SYNCHRONIZATIONCONTEXT_WAIT;HAS_CORLIB_CONTRACTS;FEATURE_MACL;FEATURE_REMOTING;MONO_COM;FEATURE_COMINTEROP;FEATURE_ROLE_BASED_SECURITY;MONO_FEATURE_THREAD_ABORT;MONO_FEATURE_THREAD_SUSPEND_RESUME;MONO_FEATURE_MULTIPLE_APPDOMAINS;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;FEATURE_PAL;GENERICS_WORK;FEATURE_LIST_PREDICATES;FEATURE_SERIALIZATION;FEATURE_ASCII;FEATURE_LATIN1;FEATURE_UTF7;FEATURE_UTF32;MONO_HYBRID_ENCODING_SUPPORT;FEATURE_ASYNC_IO;NEW_EXPERIMENTAL_ASYNC_IO;FEATURE_UTF32;FEATURE_EXCEPTIONDISPATCHINFO;FEATURE_CORRUPTING_EXCEPTIONS;FEATURE_EXCEPTION_NOTIFICATIONS;FEATURE_STRONGNAME_MIGRATION;FEATURE_USE_LCID;FEATURE_FUSION;FEATURE_CRYPTO;FEATURE_X509_SECURESTRINGS;FEATURE_SYNCHRONIZATIONCONTEXT;FEATURE_SYNCHRONIZATIONCONTEXT_WAIT;HAS_CORLIB_CONTRACTS;FEATURE_MACL;FEATURE_REMOTING;MONO_COM;FEATURE_COMINTEROP;FEATURE_ROLE_BASED_SECURITY;MONO_FEATURE_THREAD_ABORT;MONO_FEATURE_THREAD_SUSPEND_RESUME;MONO_FEATURE_MULTIPLE_APPDOMAINS;MONO_FEATURE_CONSOLE</DefineConstants>\r
<ErrorReport>prompt</ErrorReport>\r
<WarningLevel>4</WarningLevel>\r
</PropertyGroup>\r
<Compile Include="System\TimeZoneInfo.cs" />\r
<Compile Include="System\TimeZoneInfo.MonoTouch.cs" />\r
<Compile Include="System\TimeZoneInfo.Serialization.cs" />\r
+ <Compile Include="System\TimeZoneInfo.WinRT.cs" />\r
<Compile Include="System\TypeCode.cs" />\r
<Compile Include="System\TypeIdentifier.cs" />\r
<Compile Include="System\TypeSpec.cs" />\r
System/TimeZoneInfo.Android.cs
System/TimeZoneInfo.MonoTouch.cs
System/TimeZoneInfo.Serialization.cs
+System/TimeZoneInfo.WinRT.cs
../../build/common/MonoTODOAttribute.cs
System/TypeIdentifier.cs
System/TypeSpec.cs
--- /dev/null
+#include testing_aot_full_corlib_test.dll.exclude.sources
--- /dev/null
+#include corlib_test.dll.sources
LIBRARY_PACKAGE = monodoc
# Remove a bunch of "obsolete"-type warning for Lucene.NET
# also activate legacy mode to compile old monodoc.dll api
-LOCAL_MCS_FLAGS = /nowarn:618,612,672,809 /define:LEGACY_MODE
+LOCAL_MCS_FLAGS = /nowarn:618,612,672,809,414,649 /define:LEGACY_MODE
JAY_FLAGS = -ct
<SchemaVersion>2.0</SchemaVersion>\r
<ProjectGuid>{0248869F-8D3B-4AB2-B976-B2A9AF1319A9}</ProjectGuid>\r
<OutputType>Library</OutputType>\r
- <NoWarn>618,612,672,809,1699,169,164,162,168,219,618,612</NoWarn>\r
+ <NoWarn>618,612,672,809,414,649,1699,169,164,162,168,219,618,612</NoWarn>\r
<OutputPath>./../../class/lib/net_4_x</OutputPath>\r
<IntermediateOutputPath>obj-net_4_x</IntermediateOutputPath>\r
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>\r
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
<DebugSymbols>true</DebugSymbols>\r
<DebugType>full</DebugType>\r
- <NoWarn>618,612,672,809,1699,169,164,162,168,219,618,612</NoWarn>\r
+ <NoWarn>618,612,672,809,414,649,1699,169,164,162,168,219,618,612</NoWarn>\r
<Optimize>false</Optimize>\r
<DefineConstants>TRACE;LEGACY_MODE;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM</DefineConstants>\r
<ErrorReport>prompt</ErrorReport>\r
</PropertyGroup>\r
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
<DebugType>pdbonly</DebugType>\r
- <NoWarn>618,612,672,809,1699,169,164,162,168,219,618,612</NoWarn>\r
+ <NoWarn>618,612,672,809,414,649,1699,169,164,162,168,219,618,612</NoWarn>\r
<Optimize>true</Optimize>\r
<DefineConstants>LEGACY_MODE;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM</DefineConstants>\r
<ErrorReport>prompt</ErrorReport>\r
/// </devdoc>
internal static class SecurityUtils {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
private static volatile ReflectionPermission memberAccessPermission = null;
private static volatile ReflectionPermission restrictedMemberAccessPermission = null;
#endif
private static void DemandReflectionAccess(Type type) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
try {
MemberAccessPermission.Demand();
}
[SecuritySafeCritical]
private static void DemandGrantSet(Assembly assembly) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
PermissionSet targetGrantSet = assembly.PermissionSet;
targetGrantSet.AddPermission(RestrictedMemberAccessPermission);
targetGrantSet.Demand();
}
private static bool HasReflectionPermission(Type type) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
try {
DemandReflectionAccess(type);
return true;
// The World of Compile
//
internal void Compile(NavigatorInput input, XmlResolver xmlResolver, Evidence evidence) {
-#if !FEATURE_MONO_CAS
+#if !MONO_FEATURE_CAS
evidence = null;
#endif
Debug.Assert(input != null);
//\\ this.Prefix = "<Prefix>";
tableInitClass.Statements.Add(Assign(Property(This(), "Prefix"), Str(table.Prefix)));
}
- if (table.tableNamespace != null) {
+ if (table._tableNamespace != null) {
//\\ this.Namespace = <Namespace>;
tableInitClass.Statements.Add(Assign(Property(This(), "Namespace"), Str(table.Namespace)));
}
//\\ this.MinimumCapacity = <MinimumCapacity>;
tableInitClass.Statements.Add(Assign(Property(This(), "MinimumCapacity"), Primitive(table.MinimumCapacity)));
}
- if (table.displayExpression != null) {
+ if (table._displayExpression != null) {
//\\ this.DisplayExpression = "<DisplayExpression>";
tableInitClass.Statements.Add(Assign(Property(This(), "DisplayExpression"), Str(table.DisplayExpressionInternal)));
}
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
static internal Stream GetFileStream(string filename) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
(new FileIOPermission(FileIOPermissionAccess.Read, filename)).Assert();
try {
return new FileStream(filename,FileMode.Open,FileAccess.Read,FileShare.Read);
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
static internal FileVersionInfo GetVersionInfo(string filename) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
(new FileIOPermission(FileIOPermissionAccess.Read, filename)).Assert(); // MDAC 62038
try {
return FileVersionInfo.GetVersionInfo(filename); // MDAC 60411
return (null != _restrictions);
}
}
-}
-
-namespace System.Data { // MDAC 83087
-
-[Serializable]
-
- public enum KeyRestrictionBehavior { // V1.0.5000
- AllowOnly = 0,
- PreventUsage = 1,
- }
-}
+}
\ No newline at end of file
catch (OverflowException) {
throw ExprException.Overflow(typeof(SqlXml));
}
- throw ExceptionBuilder.AggregateException(kind, DataType);
+ throw ExceptionBuilder.AggregateException(kind, _dataType);
}
override public int Compare(int recordNo1, int recordNo2) {
Debug.Assert(defaultValue != null, "It should not have been set to null.");
if (defaultValue == DBNull.Value && this.implementsINullable) { // for perf I dont access property
if (_storage != null)
- defaultValue = _storage.NullValue;
+ defaultValue = _storage._nullValue;
else if (this.isSqlType)
defaultValue = SqlConvert.ChangeTypeForDefaultValue(defaultValue, this.dataType, FormatProvider);
else if (this.implementsINullable) {
internal bool IsCloneable {
get {
Debug.Assert(null != _storage, "no storage");
- return _storage.IsCloneable;
+ return _storage._isCloneable;
}
}
internal bool IsStringType {
get {
Debug.Assert(null != _storage, "no storage");
- return _storage.IsStringType;
+ return _storage._isStringType;
}
}
internal bool IsValueType {
get {
Debug.Assert(null != _storage, "no storage");
- return _storage.IsValueType;
+ return _storage._isValueType;
}
}
internal void FreeRecord(int record) {
Debug.Assert(null != _storage, "no storage");
- _storage.Set(record, _storage.NullValue);
+ _storage.Set(record, _storage._nullValue);
}
/// <devdoc>
return;
if (sortIndex != null) {
- if (sortIndex.IsKeyInIndex(_storage.NullValue)) {// here we do use strong typed NULL for Sql types
+ if (sortIndex.IsKeyInIndex(_storage._nullValue)) {// here we do use strong typed NULL for Sql types
throw ExceptionBuilder.NullKeyValues(ColumnName);
}
}
internal bool IsCustomType {
get {
if (null != _storage)
- return _storage.IsCustomDefinedType;
+ return _storage._isCustomDefinedType;
return DataStorage.IsTypeCustomType(DataType);
}
}
using System.Runtime.Versioning;
using System.Runtime.CompilerServices;
+#if !COREFX
/// <devdoc>
/// <para>
/// Represents an in-memory cache of data.
}
}
+#endif
#if !NO_CODEDOM
public class DataSetSchemaImporterExtension : SchemaImporterExtension {
internal class XMLSchema {
internal static TypeConverter GetConverter(Type type) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
HostProtectionAttribute protAttrib = new HostProtectionAttribute();
protAttrib.SharedState = true;
CodeAccessPermission permission = (CodeAccessPermission)protAttrib.CreatePermission();
return TypeDescriptor.GetConverter(type);
}
finally {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
CodeAccessPermission.RevertAssert();
#endif
}
internal bool RequiresMemberAccessForWrite(SecurityException securityException)
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
EnsureMethodsImported();
if (!IsTypeVisible(UnderlyingType))
}
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
[Fx.Tag.SecurityNote(Critical = "Holds instance of SecurityPermission that we will Demand for SerializationFormatter."
+ " Should not be modified to something else.")]
[SecurityCritical]
[SecuritySafeCritical]
public void DemandSerializationFormatterPermission()
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
if (!demandedSerializationFormatterPermission)
{
Globals.SerializationFormatterPermission.Demand();
[SecuritySafeCritical]
public void DemandMemberAccessPermission()
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
if (!demandedMemberAccessPermission)
{
Globals.MemberAccessPermission.Demand();
[MethodImpl(MethodImplOptions.NoInlining)]
internal void GetObjectData(ISerializable obj, SerializationInfo serInfo, StreamingContext context)
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
// Demand the serialization formatter permission every time
Globals.SerializationFormatterPermission.Demand();
#endif
[SecurityCritical]
internal static bool IsInFullTrust()
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
if (!SecurityManager.CurrentThreadRequiresSecurityContextCapture())
{
return true;
[SecurityCritical]
internal static bool CheckAppDomainPermissions(PermissionSet permissions)
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
return AppDomain.CurrentDomain.IsHomogenous &&
permissions.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet);
#else
[SecurityCritical]
internal static bool HasEtwPermissions()
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
//Currently unrestricted permissions are required to create Etw provider.
PermissionSet permissions = new PermissionSet(PermissionState.Unrestricted);
return CheckAppDomainPermissions(permissions);
[SecuritySafeCritical]
get
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
if (!checkedForFullTrust)
{
inFullTrust = AppDomain.CurrentDomain.IsFullyTrusted;
[PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
public partial class XmlSecureResolver : XmlResolver {
XmlResolver resolver;
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
PermissionSet permissionSet;
#endif
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
public XmlSecureResolver(XmlResolver resolver, string securityUrl) : this(resolver, CreateEvidenceForUrl(securityUrl)) {}
public XmlSecureResolver(XmlResolver resolver, Evidence evidence) : this(resolver, SecurityManager.GetStandardSandbox(evidence)) {}
public XmlSecureResolver(XmlResolver resolver, PermissionSet permissionSet) {
this.resolver = resolver;
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
this.permissionSet = permissionSet;
#endif
}
}
public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
permissionSet.PermitOnly();
#endif
return resolver.GetEntity(absoluteUri, role, ofObjectToReturn);
}
public static Evidence CreateEvidenceForUrl(string securityUrl) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
Evidence evidence = new Evidence();
if (securityUrl != null && securityUrl.Length > 0) {
evidence.AddHostEvidence(new Url(securityUrl));
#endif
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
[Serializable]
private class UncDirectory : EvidenceBase, IIdentityPermissionFactory {
private string uncDir;
[PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
public partial class XmlSecureResolver : XmlResolver {
public override Task<object> GetEntityAsync(Uri absoluteUri, string role, Type ofObjectToReturn) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
permissionSet.PermitOnly();
#endif
return resolver.GetEntityAsync(absoluteUri, role, ofObjectToReturn);
if (stylesheet == null) {
throw new ArgumentNullException("stylesheet");
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
if (evidence == null) {
evidence = new Evidence();
}
else {
args = new Type[] {receiverType};
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
IntSecurity.FullReflection.Assert();
#endif
try {
else {
args = new Type[] {receiverType};
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
IntSecurity.FullReflection.Assert();
#endif
try {
/// a single object to be re-used for more than one type.
/// </devdoc>
private object CreateInstance(Type type) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
if ((!(type.IsPublic || type.IsNestedPublic)) && (type.Assembly == typeof(DebugTypeDescriptor).Assembly)) {
IntSecurity.FullReflection.Demand();
}
[HostProtection(SharedState = true)]
internal static class IntSecurity {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
public static readonly CodeAccessPermission UnmanagedCode = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
public static readonly CodeAccessPermission FullReflection = new ReflectionPermission(PermissionState.Unrestricted);
#endif
public static string UnsafeGetFullPath(string fileName) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
string full = fileName;
FileIOPermission fiop = new FileIOPermission(PermissionState.None);
else {
args = new Type[] {receiverType};
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
IntSecurity.FullReflection.Assert();
try {
#endif
resetMethod = FindMethod(componentClass, "Reset" + Name, args, typeof(void), /* publicOnly= */ false);
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
}
finally {
CodeAccessPermission.RevertAssert();
args = new Type[] {receiverType};
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
IntSecurity.FullReflection.Assert();
try {
#endif
shouldSerializeMethod = FindMethod(componentClass, "ShouldSerialize" + Name,
args, typeof(Boolean), /* publicOnly= */ false);
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
}
finally {
CodeAccessPermission.RevertAssert();
Type converterType = GetTypeFromName(instanceAttr.ConverterTypeName);
if (converterType != null && typeof(TypeConverter).IsAssignableFrom(converterType))
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
try {
IntSecurity.FullReflection.Assert();
#endif
return (TypeConverter)ReflectTypeDescriptionProvider.CreateInstance(converterType, _type);
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
} finally {
CodeAccessPermission.RevertAssert();
}
Type converterType = GetTypeFromName(typeAttr.ConverterTypeName);
if (converterType != null && typeof(TypeConverter).IsAssignableFrom(converterType))
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
try {
IntSecurity.FullReflection.Assert();
#endif
_converter = (TypeConverter)ReflectTypeDescriptionProvider.CreateInstance(converterType, _type);
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
} finally {
CodeAccessPermission.RevertAssert();
}
{
throw new ArgumentNullException("type");
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
PermissionSet typeDescriptorPermission = new PermissionSet(PermissionState.None);
typeDescriptorPermission.AddPermission(new TypeDescriptorPermission(TypeDescriptorPermissionFlags.RestrictedRegistrationAccess));
{
throw new ArgumentNullException("instance");
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
Type type = instance.GetType();
PermissionSet typeDescriptorPermission = new PermissionSet(PermissionState.None);
// sense that they provide a public API while not necessarily being public themselves. As such,
// we need to allow instantiation of internal TypeDescriptionProviders. See the thread attached
// to VSWhidbey #500522 for a more detailed discussion.
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
IntSecurity.FullReflection.Assert();
try {
#endif
prov = (TypeDescriptionProvider)Activator.CreateInstance(providerType);
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
}
finally {
CodeAccessPermission.RevertAssert();
{
throw new ArgumentNullException("type");
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
PermissionSet typeDescriptorPermission = new PermissionSet(PermissionState.None);
typeDescriptorPermission.AddPermission(new TypeDescriptorPermission(TypeDescriptorPermissionFlags.RestrictedRegistrationAccess));
{
throw new ArgumentNullException("instance");
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
Type type = instance.GetType();
PermissionSet typeDescriptorPermission = new PermissionSet(PermissionState.None);
}
protected Win32Exception(SerializationInfo info, StreamingContext context) : base (info, context) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
IntSecurity.UnmanagedCode.Demand();
#endif
nativeErrorCode = info.GetInt32("NativeErrorCode");
Debug.WriteLineIf(RuntimeLicenseContextSwitch.TraceVerbose,"rawfile: " + rawFile);
string codeBase;
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
// FileIOPermission is required for ApplicationBase in URL-hosted domains
FileIOPermission perm = new FileIOPermission(PermissionState.Unrestricted);
perm.Assert();
// file://fullpath/foo.exe
//
string fileName;
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
FileIOPermission perm = new FileIOPermission(PermissionState.Unrestricted);
perm.Assert();
try
else if(!resourceAssembly.IsDynamic) { // EscapedCodeBase won't be supported by emitted assemblies anyway
Debug.WriteLineIf(RuntimeLicenseContextSwitch.TraceVerbose,"resourceAssembly is not null");
string fileName;
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
FileIOPermission perm = new FileIOPermission(PermissionState.Unrestricted);
perm.Assert();
#endif
}
finally
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
CodeAccessPermission.RevertAssert();
#endif
}
static Stream OpenRead(Uri resourceUri) {
Stream result = null;
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
PermissionSet perms = new PermissionSet(PermissionState.Unrestricted);
perms.Assert();
catch (Exception e) {
Debug.Fail(e.ToString());
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
finally {
CodeAccessPermission.RevertAssert();
}
public static TraceListenerCollection Listeners {
[HostProtection(SharedState=true)]
get {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
// Do a full damand
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
#endif
/// </devdoc>
[System.Diagnostics.Conditional("TRACE")]
public static void Close() {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
// Do a full damand
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
#endif
get {
if (stackTrace == null)
stackTrace = Environment.StackTrace;
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
else
new EnvironmentPermission(PermissionState.Unrestricted).Demand();
#endif
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
private static void InitProcessInfo() {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
// Demand unmanaged code permission
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
#endif
internal static string AppName {
get {
if (appName == null) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
new EnvironmentPermission(EnvironmentPermissionAccess.Read, "Path").Assert();
#endif
appName = Path.GetFileName(Environment.GetCommandLineArgs()[0]);
}
private static void DemandReflectionAccess(Type type) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
try {
MemberAccessPermission.Demand();
}
[SecuritySafeCritical]
private static void DemandGrantSet(Assembly assembly) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
PermissionSet targetGrantSet = assembly.PermissionSet;
targetGrantSet.AddPermission(RestrictedMemberAccessPermission);
targetGrantSet.Demand();
set
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.ControlPolicyPermission.Demand();
#endif
Instance.CredentialPolicy = value;
/// </devdoc>
public static void Register(IAuthenticationModule authenticationModule)
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.UnmanagedPermission.Demand();
#endif
Instance.Register(authenticationModule);
/// </devdoc>
public static void Unregister(IAuthenticationModule authenticationModule)
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.UnmanagedPermission.Demand();
#endif
Instance.Unregister(authenticationModule);
/// </devdoc>
public static void Unregister(string authenticationScheme)
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.UnmanagedPermission.Demand();
#endif
Instance.Unregister(authenticationScheme);
get {
//This check will not allow to use local user credentials at will.
//Hence the username will not be exposed to the network
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
new EnvironmentPermission(EnvironmentPermissionAccess.Read, "USERNAME").Demand();
#endif
return SystemNetworkCredential.defaultCredential;
get {
//This check will not allow to use local user credentials at will.
//Hence the username will not be exposed to the network
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
new EnvironmentPermission(EnvironmentPermissionAccess.Read, "USERNAME").Demand();
#endif
return SystemNetworkCredential.defaultCredential;
private static void DemandCallback(object state)
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
((CodeAccessPermission) state).Demand();
#endif
}
internal static class ExceptionHelper
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
internal static readonly KeyContainerPermission KeyContainerPermissionOpen = new KeyContainerPermission(KeyContainerPermissionFlags.Open);
internal static readonly WebPermission WebPermissionUnrestricted = new WebPermission(NetworkAccess.Connect);
internal static readonly SecurityPermission UnmanagedPermission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
/// </devdoc>
public class NetworkCredential : ICredentials,ICredentialsByHost {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
private static volatile EnvironmentPermission m_environmentUserNamePermission;
private static volatile EnvironmentPermission m_environmentDomainNamePermission;
private static readonly object lockingObject = new object();
}
#endif //!FEATURE_PAL
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
void InitializePart1() {
if (m_environmentUserNamePermission == null) {
lock(lockingObject) {
/// </devdoc>
public string UserName {
get {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
InitializePart1();
m_environmentUserNamePermission.Demand();
#endif
/// </devdoc>
public string Password {
get {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.UnmanagedPermission.Demand();
#endif
return InternalGetPassword();
/// </devdoc>
public SecureString SecurePassword {
get {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.UnmanagedPermission.Demand();
#endif
return InternalGetSecurePassword().Copy();
/// </devdoc>
public string Domain {
get {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
InitializePart1();
m_environmentDomainNamePermission.Demand();
#endif
{
#if MONODROID
return new AndroidIPGlobalProperties ();
-#elif MONOTOUCH || XAMMAC || MOBILE
+#elif MONOTOUCH || XAMMAC
return new UnixIPGlobalProperties ();
#elif MONO
switch (Environment.OSVersion.Platform) {
}
return new UnixIPGlobalProperties ();
default:
+#if WIN_PLATFORM
return new Win32IPGlobalProperties ();
+#else
+ return new UnixIPGlobalProperties ();
+#endif
}
#else
(new NetworkInformationPermission(NetworkInformationAccess.Read)).Demand();
{
/// Returns objects that describe the network interfaces on the local computer.
public static NetworkInterface[] GetAllNetworkInterfaces(){
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
(new NetworkInformationPermission(NetworkInformationAccess.Read)).Demand();
#endif
return SystemNetworkInterface.GetNetworkInterfaces();
return m_BindIPEndPointDelegate;
}
set {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.InfrastructurePermission.Demand();
#endif
m_BindIPEndPointDelegate = value;
throw new NotSupportedException(SR.GetString(SR.net_servicePointAddressNotSupportedInHostMode));
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
// Don't let low-trust apps discover the proxy information.
if (m_ProxyServicePoint)
{
throw new ArgumentNullException("creator");
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
return RequestCacheManager.GetBinding(string.Empty).Policy;
}
set {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
// This is a replacement of RequestCachePermission demand since we are not including the latest in the product.
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
{
get
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
return InternalDefaultWebProxy;
set
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
InternalDefaultWebProxy = value;
//
public static IWebProxy GetSystemWebProxy()
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
return InternalGetSystemWebProxy();
// demand the same permissions, then we should remove our
// demand here.
//
- #if FEATURE_MONO_CAS
+ #if MONO_FEATURE_CAS
ExceptionHelper.KeyContainerPermissionOpen.Demand();
#endif
// For v 1.1 compat We want to ensure the store is opened under the **process** acount.
//
try {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
using (WindowsIdentity.Impersonate(IntPtr.Zero))
#endif
{
// Note: We call a user certificate selection delegate under permission
// assert but the signature of the delegate is unique so it's safe
//
- #if FEATURE_MONO_CAS
+ #if MONO_FEATURE_CAS
[StorePermission(SecurityAction.Assert, Unrestricted=true)]
#endif
private bool AcquireClientCredentials(ref byte[] thumbPrint)
// Note: We call a user certificate selection delegate under permission
// assert but the signature of the delegate is unique so it's safe
//
- #if FEATURE_MONO_CAS
+ #if MONO_FEATURE_CAS
[StorePermission(SecurityAction.Assert, Unrestricted=true)]
#endif
private bool AcquireServerCredentials(ref byte[] thumbPrint)
//
// For v 1.1 compat We want to ensure the credential are accessed under >>process<< acount.
//
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
using (WindowsIdentity.Impersonate(IntPtr.Zero))
#endif
{
//SECURITY: The scenario is allowed in semitrust StorePermission is asserted for Chain.Build
// A user callback has unique signature so it is safe to call it under permisison assert.
//
- #if FEATURE_MONO_CAS
+ #if MONO_FEATURE_CAS
[StorePermission(SecurityAction.Assert, Unrestricted=true)]
#endif
internal bool VerifyRemoteCertificate(RemoteCertValidationCallback remoteCertValidationCallback)
//
public override int Count {
get {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
return m_SyncTable.Count;
//
public override ICollection Keys {
get {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
return m_SyncTable.Keys;
public override object SyncRoot {
[HostProtection(Synchronization=true)]
get {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
return m_SyncTable;
//
public override ICollection Values {
get {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
if (m_ValuesWrapper == null)
}
//
public override void Clear() {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
m_SyncTable.Clear();
}
//
public override bool ContainsValue(string value) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
foreach (SpnToken spnToken in m_SyncTable.Values)
// We have to unwrap the SpnKey and just expose the Spn
public override void CopyTo(Array array, int index) {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
CheckCopyToArguments(array, index, Count);
}
//
public override IEnumerator GetEnumerator() {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
try {
Uri uri = new Uri(key);
key = uri.GetParts(UriComponents.Scheme | UriComponents.Host | UriComponents.Port | UriComponents.Path, UriFormat.SafeUnescaped);
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
new WebPermission(NetworkAccess.Connect, new Uri(key)).Demand();
#endif
}
/// </devdoc>
public IWebProxy Proxy {
get {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
if (!m_ProxySet) {
}
}
set {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
m_Proxy = value;
/// </devdoc>
[Obsolete("This method has been deprecated. Please use the proxy selected for you by default. http://go.microsoft.com/fwlink/?linkid=14202")]
public static WebProxy GetDefaultProxy() {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
return new WebProxy(true);
if (useRegistry) {
// just make the proxy advanced, don't populate with any settings
// note - this will happen in the context of the user performing the deserialization (their proxy settings get read)
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
UnsafeUpdateFromRegistry();
//
public static void Register(UriParser uriParser, string schemeName, int defaultPort)
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ExceptionHelper.InfrastructurePermission.Demand();
#endif
if (uriParser == null)
* This method is internal virtual so the jit does not inline it.
*/
[
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
HostProtection(MayLeakOnAbort=true),
#endif
MethodImplAttribute(MethodImplOptions.NoInlining)
#if !(SILVERLIGHT || FULL_AOT_RUNTIME)
/// <devdoc>
/// </devdoc>
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
[HostProtection(MayLeakOnAbort=true)]
#endif
[ResourceExposure(ResourceScope.Machine)] // The AssemblyName is interesting.
/// <devdoc>
/// </devdoc>
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
[HostProtection(MayLeakOnAbort=true)]
#endif
[ResourceExposure(ResourceScope.Machine)] // The AssemblyName is interesting.
CompileToAssemblyInternal(regexinfos, assemblyname, attributes, null);
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
[HostProtection(MayLeakOnAbort=true)]
#endif
[ResourceExposure(ResourceScope.Machine)]
// <SECREVIEW> Regex only generates string manipulation, so this is ok.
// </SECREVIEW>
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
new ReflectionPermission(PermissionState.Unrestricted).Assert();
#endif
try {
#endif
}
finally {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
CodeAccessPermission.RevertAssert();
#endif
}
// <SECREVIEW> Regex only generates string manipulation, so this is ok.
// </SECREVIEW>
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
new ReflectionPermission(PermissionState.Unrestricted).Assert();
#endif
try {
factory = c.FactoryInstanceFromCode(code, options);
}
finally {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
CodeAccessPermission.RevertAssert();
#endif
}
Type factory;
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
new ReflectionPermission(PermissionState.Unrestricted).Assert();
#endif
try {
c.GenerateRegexType(pattern, options, fullname, regexes[i].IsPublic, code, tree, factory, mTimeout);
}
finally {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
CodeAccessPermission.RevertAssert();
#endif
}
// SECREVIEW : Regex only generates string manipulation, so this is
// : ok.
//
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
new ReflectionPermission(PermissionState.Unrestricted).Assert();
#endif
try {
CustomAttributeBuilder transparencyAttribute = new CustomAttributeBuilder(transparencyCtor, new object[0]);
assemblyAttributes.Add(transparencyAttribute);
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
ConstructorInfo securityRulesCtor = typeof(SecurityRulesAttribute).GetConstructor(new Type[] { typeof(SecurityRuleSet) });
CustomAttributeBuilder securityRulesAttribute =
new CustomAttributeBuilder(securityRulesCtor, new object[] { SecurityRuleSet.Level2 });
}
}
finally {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
CodeAccessPermission.RevertAssert();
#endif
}
/// multiple threads.</para>
/// </devdoc>
#if !SILVERLIGHT
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
[HostProtection(Synchronization=true)]
#endif
static public Group Synchronized(Group inner) {
/// </devdoc>
#if !SILVERLIGHT
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
[HostProtection(Synchronization=true)]
#endif
static public Match Synchronized(Match inner) {
protected internal override RegexRunner CreateInstance() {
CompiledRegexRunner runner = new CompiledRegexRunner();
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
new ReflectionPermission(PermissionState.Unrestricted).Assert();
#endif
runner.SetDelegates((NoParamDelegate) goMethod.CreateDelegate(typeof(NoParamDelegate)),
return GetProcessesByName(processName, ".");
}
+#if !MONO
/// <devdoc>
/// <para>
/// Creates an array of <see cref='System.Diagnostics.Process'/> components that are associated with process resources on a
list.CopyTo(temp, 0);
return temp;
}
+#endif
/// <devdoc>
/// <para>
[System.Security.SecurityCritical] // auto-generated
internal virtual String InternalToString()
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
try
{
#pragma warning disable 618
bool safeToReturn = false;
try {
if (!isInvalidPath) {
-#if !FEATURE_CORECLR && FEATURE_MONO_CAS
+#if !FEATURE_CORECLR && MONO_FEATURE_CAS
FileIOPermission.QuickDemand(FileIOPermissionAccess.PathDiscovery, path, false, false);
#endif
safeToReturn = true;
[System.Security.SecurityCritical] // auto-generated
private FileInfo(SerializationInfo info, StreamingContext context) : base(info, context)
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
#if !FEATURE_CORECLR
FileIOPermission.QuickDemand(FileIOPermissionAccess.Read, FullPath, false, false);
#endif
String directoryName = Path.GetDirectoryName(FullPath);
if (directoryName != null)
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, DisplayPath, FullPath);
state.EnsureState();
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
public override void Delete()
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Write, DisplayPath, FullPath);
state.EnsureState();
// Do a demand on the combined path so that we can fail early in case of deny
demandPaths[1] = Directory.GetDemandDir(normalizedSearchPath, true);
_checkHost = checkHost;
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
if (checkHost)
{
// For filters like foo\*.cs we need to verify if the directory foo is not denied access.
// Do a demand on the combined path so that we can fail early in case of deny
demandPaths[1] = Directory.GetDemandDir(normalizedSearchPath, true);
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
if (checkHost)
{
[System.Security.SecurityCritical]
internal void DoDemand(String fullPathToDemand)
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
if(_checkHost) {
String demandDir = Directory.GetDemandDir(fullPathToDemand, true);
internal override FileInfo CreateObject(SearchResult result)
{
String name = result.FullPath;
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, name);
state.EnsureState();
String name = result.FullPath;
String permissionName = name + "\\.";
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, permissionName);
state.EnsureState();
String name = result.FullPath;
String permissionName = name + "\\.";
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, permissionName);
state.EnsureState();
Contract.Assert(isFile);
String name = result.FullPath;
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, name);
state.EnsureState();
using System;
using System.Collections;
using System.Security;
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
using System.Security.Permissions;
#endif
using Microsoft.Win32;
namespace System.IO {
[Serializable]
-#if !FEATURE_CORECLR && FEATURE_MONO_CAS
+#if !FEATURE_CORECLR && MONO_FEATURE_CAS
[FileIOPermissionAttribute(SecurityAction.InheritanceDemand,Unrestricted=true)]
#endif
[ComVisible(true)]
demandDir = Directory.GetDemandDir(FullPath, true);
else
demandDir = FullPath;
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
FileSecurityState sourceState = new FileSecurityState(FileSecurityStateAccess.PathDiscovery, String.Empty, demandDir);
sourceState.EnsureState();
demandDir = Directory.GetDemandDir(FullPath, true);
else
demandDir = FullPath;
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
#if !FEATURE_CORECLR
FileIOPermission.QuickDemand(FileIOPermissionAccess.PathDiscovery, demandDir);
#endif
[System.Security.SecuritySafeCritical]
#endif
set {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
#if !FEATURE_CORECLR
FileIOPermission.QuickDemand(FileIOPermissionAccess.Write, FullPath);
#endif
[ComVisible(false)]
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
#if !FEATURE_CORECLR
FileIOPermission.QuickDemand(FileIOPermissionAccess.PathDiscovery, FullPath);
#endif
if (_isOpen) {
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CalledTwice"));
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
if (!skipSecurityCheck) {
#pragma warning disable 618
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
if (_isOpen)
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CalledTwice"));
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
if (!skipSecurityCheck)
#pragma warning disable 618
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
// Don't use Assembly manifest, but grovel on disk for a file.
try
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
new System.Security.Permissions.FileIOPermission(System.Security.Permissions.PermissionState.Unrestricted).Assert();
#endif
}
finally
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
System.Security.CodeAccessPermission.RevertAssert();
#endif
}
// write to the temp directory (enforced via a Windows ACL). Fall back to a MemoryStream.
Stream dataSection = null; // Either a FileStream or a MemoryStream
String tempFile = null;
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
PermissionSet permSet = new PermissionSet(PermissionState.None);
permSet.AddPermission(new EnvironmentPermission(PermissionState.Unrestricted));
permSet.AddPermission(new FileIOPermission(PermissionState.Unrestricted));
#endif
try {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
permSet.Assert();
#endif
tempFile = Path.GetTempFileName();
dataSection = new MemoryStream();
}
finally {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
PermissionSet.RevertAssert();
#endif
}
throw new MissingMethodException(Environment.GetResourceString("MissingConstructor_Name", FullName));
}
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
// If we're creating a delegate, we're about to call a
// constructor taking an integer to represent a target
// method. Since this is very difficult (and expensive)
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
#endif // FEATURE_CORECLR
}
-#endif // FEATURE_MONO_CAS
+#endif // MONO_FEATURE_CAS
if (invokeMethod.GetParametersNoCopy().Length == 0)
{
if (args.Length != 0)
return null;
#endif
String dir = GetRuntimeDirectoryImpl();
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
new FileIOPermission(FileIOPermissionAccess.PathDiscovery, dir).Demand();
#endif
return dir;
String path = sb.ToString();
#endif
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
// Do security check
new FileIOPermission(FileIOPermissionAccess.PathDiscovery, path).Demand();
#endif
private BinaryMethodReturn binaryMethodReturn;
private bool bIsCrossAppDomain;
#endif
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
private static FileIOPermission sfileIOPermission = new FileIOPermission(PermissionState.Unrestricted);
#endif
private SerStack ValueFixupStack
if (bSimpleAssembly)
{
try {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
sfileIOPermission.Assert();
#endif
try {
#endif // FEATURE_FUSION
}
finally {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
CodeAccessPermission.RevertAssert();
#endif
}
else {
try
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
sfileIOPermission.Assert();
#endif
try {
assm = Assembly.Load(assemblyName);
}
finally {
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
CodeAccessPermission.RevertAssert();
#endif
}
if ( !FormatterServices.UnsafeTypeForwardersIsEnabled() && sourceAssembly != destAssembly )
{
// we have a type forward to attribute !
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
// we can try to see if the dest assembly has less permissionSet
if (!destAssembly.PermissionSet.IsSubsetOf(sourceAssembly.PermissionSet))
#endif
typeFowardedFromAssembly = Assembly.Load(typeInfo.AssemblyString);
}
catch { }
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
if (typeFowardedFromAssembly != sourceAssembly)
{
// throw security exception
}
else
{
-#if FEATURE_MONO_CAS
+#if MONO_FEATURE_CAS
// throw security exception
throw new SecurityException() { Demanded = sourceAssembly.PermissionSet };
#endif
public abstract class Report {
private static int error_count;
- private static int mark_count;
private static bool quiet;
/* Current file being processed */
private static string file_path;
test-853.cs -text
-test-861.cs -text
\ No newline at end of file
+test-861.cs -text
+test-908.cs crlf=input
+test-debug-*.cs crlf=input
+support-test-debug-04.cs crlf=input
cccheck \
security \
mdbrebase \
+ mdb2ppdb \
ikdasm \
mono-symbolicate \
linker-analyzer
static void RewriteAssembly (string assemblyLocation, Dictionary<string, string> resourcesStrings, CmdOptions options)
{
- Stream pdbSymbols = null;
-
var debugSymbols = Path.ChangeExtension (assemblyLocation, "pdb");
- if (File.Exists (debugSymbols))
- pdbSymbols = File.Open (debugSymbols, FileMode.Open, FileAccess.ReadWrite);
+ var useDebugSymbols = File.Exists (debugSymbols);
var readerParameters = new ReaderParameters {
ReadWrite = true,
};
- if (pdbSymbols != null) {
- readerParameters.ReadSymbols = true;
+ if (useDebugSymbols) {
readerParameters.SymbolReaderProvider = new PortablePdbReaderProvider ();
- readerParameters.SymbolStream = pdbSymbols;
}
using (var assembly = AssemblyDefinition.ReadAssembly (assemblyLocation, readerParameters)) {
var writerParameters = new WriterParameters ();
- if (pdbSymbols != null) {
- writerParameters.WriteSymbols = true;
- writerParameters.SymbolStream = pdbSymbols;
+ if (useDebugSymbols) {
writerParameters.SymbolWriterProvider = new PortablePdbWriterProvider ();
- pdbSymbols.Seek (0, SeekOrigin.Begin);
}
assembly.Write (writerParameters);
}
-
- pdbSymbols?.Dispose ();
}
static bool LoadGetResourceStrings (Dictionary<string, string> resourcesStrings, CmdOptions options)
--- /dev/null
+thisdir = tools/mdb2ppdb
+SUBDIRS =
+include ../../build/rules.make
+
+PROGRAM = mdb2ppdb.exe
+
+LOCAL_MCS_FLAGS =
+LIB_REFS = Mono.Cecil Mono.Cecil.Mdb
+
+include ../../build/executable.make
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<!-- WARNING: this file is autogenerated, don't modify it. Edit the .sources file of the corresponding assembly instead if you want to add/remove C# source files. -->\r
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <PropertyGroup>\r
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+ <ProductVersion>9.0.30729</ProductVersion>\r
+ <SchemaVersion>2.0</SchemaVersion>\r
+ <ProjectGuid>{3252021D-F3DE-425F-B4A6-20B2B02EE3A4}</ProjectGuid>\r
+ <OutputType>Exe</OutputType>\r
+ <NoWarn>1699</NoWarn>\r
+ <OutputPath>./../../class/lib/net_4_x</OutputPath>\r
+ <IntermediateOutputPath>obj-net_4_x</IntermediateOutputPath>\r
+ <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>\r
+ <NoStdLib>True</NoStdLib>\r
+ \r
+ <NoConfig>True</NoConfig>\r
+ \r
+ <AppDesignerFolder>Properties</AppDesignerFolder>\r
+ <RootNamespace>\r
+ </RootNamespace>\r
+ <AssemblyName>mdb2ppdb</AssemblyName>\r
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
+ <FileAlignment>512</FileAlignment>\r
+ </PropertyGroup>\r
+ \r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+ <DebugSymbols>true</DebugSymbols>\r
+ <DebugType>full</DebugType>\r
+ <NoWarn>1699</NoWarn>\r
+ <Optimize>false</Optimize>\r
+ <DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+ <DebugType>pdbonly</DebugType>\r
+ <NoWarn>1699</NoWarn>\r
+ <Optimize>true</Optimize>\r
+ <DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ </PropertyGroup>\r
+ <!-- Set AddAdditionalExplicitAssemblyReferences to false, otherwise if targetting .NET4.0, \r
+ Microsoft.NETFramework.props will force a dependency on the assembly System.Core. This\r
+ is a problem to compile the Mono mscorlib.dll -->\r
+ <PropertyGroup>\r
+ <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>\r
+ </PropertyGroup>\r
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+ <ItemGroup>\r
+ <Compile Include="mdb2ppdb.cs" />\r </ItemGroup>\r
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
+ Other similar extension points exist, see Microsoft.Common.targets.\r
+ <Target Name="BeforeBuild">\r
+ </Target>\r
+ <Target Name="AfterBuild">\r
+ </Target>\r
+ -->\r
+ <PropertyGroup>\r
+ <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
+
+ </PreBuildEvent>\r
+ <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">\r
+\r
+ </PreBuildEvent>\r
+ <PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
+
+ </PostBuildEvent>\r
+ <PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">\r
+\r
+ </PostBuildEvent>\r
+ </PropertyGroup>\r
+ <ItemGroup>\r
+ <ProjectReference Include="../../class/corlib/corlib-net_4_x.csproj">\r
+ <Project>{2CA6026B-2DC8-4C4C-A12C-1E8234049DB7}</Project>\r
+ <Name>corlib-net_4_x</Name>\r
+ </ProjectReference>\r
+ <ProjectReference Include="../../class/legacy/Mono.Cecil/Mono.Cecil-net_4_x.csproj">\r
+ <Project>{6DE38817-EC25-433A-AE58-0D30C5E6C460}</Project>\r
+ <Name>Mono.Cecil-net_4_x</Name>\r
+ </ProjectReference>\r
+ <ProjectReference Include="../../class/Mono.Cecil.Mdb/Mono.Cecil.Mdb-net_4_x.csproj">\r
+ <Project>{CF14D34A-F69B-47FB-A99C-D25C77198F30}</Project>\r
+ <Name>Mono.Cecil.Mdb-net_4_x</Name>\r
+ </ProjectReference>\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <Folder Include="Properties\" />\r
+ </ItemGroup>\r
+</Project>\r
+
--- /dev/null
+using System;
+using Mono.Cecil;
+using Mono.Cecil.Cil;
+using Mono.Cecil.Mdb;
+
+public class Driver
+{
+ public static void Main (String[] args) {
+ //
+ // The assembly itself needs to be changed to add some data needed to
+ // find the matching .pdb file.
+ //
+ if (args.Length != 2) {
+ Console.Error.WriteLine ("Usage: mdb2pdb <input assembly> <output assembly>");
+ Environment.Exit (1);
+ }
+
+ string infile = args [0];
+ string outfile = args [1];
+
+ if (infile == outfile) {
+ Console.Error.WriteLine ("Input and output file names needs to be different.");
+ Environment.Exit (1);
+ }
+
+ var reader_parameters = new ReaderParameters {
+ SymbolReaderProvider = new MdbReaderProvider (),
+ };
+ using (var module = ModuleDefinition.ReadModule (infile, reader_parameters)) {
+ var writer_parameters = new WriterParameters {
+ SymbolWriterProvider = new PortablePdbWriterProvider (),
+ };
+
+ module.Write (outfile, writer_parameters);
+ }
+ }
+}
--- /dev/null
+mdb2ppdb.cs
Test/DocTest.dll-v2:
-rm -f Test/DocTest.cs
cp Test/DocTest-v1.cs Test/DocTest.cs
- cd Test && patch -p0 < DocTest-v2.patch
+ cd Test && patch --binary -p0 < DocTest-v2.patch
-rm -f Test/DocTest.dll
$(MAKE) TEST_CSCFLAGS=$(TEST_CSCFLAGS) Test/DocTest.dll
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<exception cref="T:System.ArgumentException">To be added; from:
+ <see cref="M:System.Dynamic.Utils.ContractUtils.RequiresNotNull(System.Object,System.String)" />,
+ <see cref="M:System.Linq.Expressions.Error.TypeMustBeDerivedFromSystemDelegate" /></exception>
+ <exception cref="T:System.ArgumentNullException">To be added; from:
+ <see cref="M:System.Dynamic.Utils.ContractUtils.RequiresNotNull(System.Object,System.String)" />,
<see cref="M:System.Linq.Expressions.Error.TypeMustBeDerivedFromSystemDelegate" /></exception>
</Docs>
</Member>
<c>M:Mono.DocTest.Widget.Dynamic0(System.Object,System.Object)</c>
</remarks>
<exception cref="T:System.ArgumentException">To be added; from:
+ <see cref="M:System.Dynamic.Utils.ContractUtils.RequiresNotNull(System.Object,System.String)" />,
+ <see cref="M:System.Linq.Expressions.Error.TypeMustBeDerivedFromSystemDelegate" /></exception>
+ <exception cref="T:System.ArgumentNullException">To be added; from:
+ <see cref="M:System.Dynamic.Utils.ContractUtils.RequiresNotNull(System.Object,System.String)" />,
<see cref="M:System.Linq.Expressions.Error.TypeMustBeDerivedFromSystemDelegate" /></exception>
</Docs>
</Member>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<exception cref="T:System.ArgumentException">To be added; from:
+ <see cref="M:System.Dynamic.Utils.ContractUtils.RequiresNotNull(System.Object,System.String)" />,
+ <see cref="M:System.Linq.Expressions.Error.TypeMustBeDerivedFromSystemDelegate" /></exception>
+ <exception cref="T:System.ArgumentNullException">To be added; from:
+ <see cref="M:System.Dynamic.Utils.ContractUtils.RequiresNotNull(System.Object,System.String)" />,
<see cref="M:System.Linq.Expressions.Error.TypeMustBeDerivedFromSystemDelegate" /></exception>
</Docs>
</Member>
<returns>To be added.</returns>
<remarks>To be added.</remarks>
<exception cref="T:System.ArgumentException">To be added; from:
+ <see cref="M:System.Dynamic.Utils.ContractUtils.RequiresNotNull(System.Object,System.String)" />,
+ <see cref="M:System.Linq.Expressions.Error.TypeMustBeDerivedFromSystemDelegate" /></exception>
+ <exception cref="T:System.ArgumentNullException">To be added; from:
+ <see cref="M:System.Dynamic.Utils.ContractUtils.RequiresNotNull(System.Object,System.String)" />,
<see cref="M:System.Linq.Expressions.Error.TypeMustBeDerivedFromSystemDelegate" /></exception>
</Docs>
</Member>
<span class="NotEntered">Documentation for this section has not yet been entered.</span>
</td>
</tr>
+ <tr valign="top">
+ <td>
+ <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.ArgumentNullException">ArgumentNullException</a>
+ </td>
+ <td>
+ <span class="NotEntered">Documentation for this section has not yet been entered.</span>
+ </td>
+ </tr>
</table>
</blockquote>
<h2 class="Section">Remarks</h2>
<c>M:Mono.DocTest.Widget.Dynamic0(System.Object,System.Object)</c>
</remarks>
<exception cref="T:System.ArgumentException">To be added; from:
+ <see cref="M:System.Dynamic.Utils.ContractUtils.RequiresNotNull(System.Object,System.String)" />,
+ <see cref="M:System.Linq.Expressions.Error.TypeMustBeDerivedFromSystemDelegate" /></exception>
+ <exception cref="T:System.ArgumentNullException">To be added; from:
+ <see cref="M:System.Dynamic.Utils.ContractUtils.RequiresNotNull(System.Object,System.String)" />,
<see cref="M:System.Linq.Expressions.Error.TypeMustBeDerivedFromSystemDelegate" /></exception>
</member>
<member name="M:Mono.DocTest.Widget.Dynamic1(System.Collections.Generic.Dictionary{System.Object,System.String})">
var pdb = asm.Name.Name + ".pdb";
pdb = Path.Combine (Path.GetDirectoryName (filename), pdb);
+ if (!File.Exists (pdb))
+ throw new FileNotFoundException ("PDB file doesn't exist: " + pdb);
+
using (var stream = File.OpenRead (pdb)) {
+ if (IsPortablePdb (stream))
+ throw new PortablePdbNotSupportedException ();
+
var funcs = PdbFile.LoadFunctions (stream, true);
Converter.Convert (asm, funcs, new MonoSymbolWriter (filename));
}
}
+ static bool IsPortablePdb (FileStream stream)
+ {
+ const uint ppdb_signature = 0x424a5342;
+
+ var position = stream.Position;
+ try {
+ var reader = new BinaryReader (stream);
+ return reader.ReadUInt32 () == ppdb_signature;
+ } finally {
+ stream.Position = position;
+ }
+ }
+
internal Converter (MonoSymbolWriter mdb)
{
this.mdb = mdb;
}
}
+ public class PortablePdbNotSupportedException : Exception {
+ }
+
class Driver {
static void Main (string [] args)
if (!File.Exists (asm))
Usage ();
- var assembly = AssemblyDefinition.ReadAssembly (asm);
-
- var pdb = assembly.Name.Name + ".pdb";
- pdb = Path.Combine (Path.GetDirectoryName (asm), pdb);
-
- if (!File.Exists (pdb))
+ try {
+ Converter.Convert (asm);
+ } catch (FileNotFoundException ex) {
Usage ();
-
- using (var stream = File.OpenRead (pdb)) {
- Convert (assembly, stream, new MonoSymbolWriter (asm));
+ } catch (PortablePdbNotSupportedException) {
+ Console.WriteLine ("Error: A portable PDB can't be converted to mdb.");
+ Environment.Exit (2);
}
- }
-
- static void Convert (AssemblyDefinition assembly, Stream pdb, MonoSymbolWriter mdb)
- {
- try {
- Converter.Convert (assembly, PdbFile.LoadFunctions (pdb, true), mdb);
- } catch (Exception e) {
- Error (e);
+ catch (Exception ex) {
+ Error (ex);
}
}
{
Console.WriteLine ("Fatal error:");
Console.WriteLine (e);
+
+ Environment.Exit (1);
}
}
}
return 0;
}
- if (extra.Count != 1) {
+ if (extra.Count < 1) {
ShowHelp (p);
return 2;
}
Project project;
ConsoleReportPrinter printer;
+#pragma warning disable 169
// this does nothing but adds strong reference to Microsoft.Build.Tasks*.dll that we need to load consistently.
Microsoft.Build.Tasks.Copy dummy;
+#pragma warning restore
public static void Main (string[] args)
{
+ Console.ForegroundColor = ConsoleColor.DarkRed;
+ Console.WriteLine ();
+ Console.WriteLine (">>>> xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<<");
+ Console.WriteLine ();
+ Console.ResetColor ();
+
+
MainClass mc = new MainClass ();
mc.args = args;
mc.Execute ();
$(INSTALL_DATA) frameworks/net_4.6.xml $(DESTDIR)$(NETFRAMEWORK_DIR)/v4.6/RedistList/FrameworkList.xml
$(MKINSTALLDIRS) $(DESTDIR)$(NETFRAMEWORK_DIR)/v4.6.1/RedistList
$(INSTALL_DATA) frameworks/net_4.6.1.xml $(DESTDIR)$(NETFRAMEWORK_DIR)/v4.6.1/RedistList/FrameworkList.xml
+ $(MKINSTALLDIRS) $(DESTDIR)$(NETFRAMEWORK_DIR)/v4.6.2/RedistList
+ $(INSTALL_DATA) frameworks/net_4.6.2.xml $(DESTDIR)$(NETFRAMEWORK_DIR)/v4.6.2/RedistList/FrameworkList.xml
install-pcl-targets:
$(MKINSTALLDIRS) $(DESTDIR)$(PORTABLE_TARGETS_DIR)
frameworks/net_4.5.2.xml \
frameworks/net_4.6.xml \
frameworks/net_4.6.1.xml \
+ frameworks/net_4.6.2.xml \
targets/Microsoft.WebApplication.targets \
$(NUGET_BUILDTASKS_REPO_DIR)/src/Microsoft.NuGet.Build.Tasks/ImportBeforeAfter/Microsoft.NuGet.ImportBefore.props \
$(NUGET_BUILDTASKS_REPO_DIR)/src/Microsoft.NuGet.Build.Tasks/ImportBeforeAfter/Microsoft.NuGet.ImportAfter.targets \
Condition="'$(TargetFrameworkIdentifier)' == '' or '$(TargetFrameworkIdentifier)' == '.NETFramework'"
DependsOnTargets="$(GetFrameworkPathsDependsOn)">
<GetFrameworkPath>
- <Output Condition="'$(TargetFrameworkVersion)' == 'v4.5' or '$(TargetFrameworkVersion)' == 'v4.5.1' or '$(TargetFrameworkVersion)' == 'v4.5.2' or '$(TargetFrameworkVersion)' == 'v4.6' or '$(TargetFrameworkVersion)' == 'v4.6.1'"
+ <Output Condition="'$(TargetFrameworkVersion)' == 'v4.5' or '$(TargetFrameworkVersion)' == 'v4.5.1' or '$(TargetFrameworkVersion)' == 'v4.5.2' or '$(TargetFrameworkVersion)' == 'v4.6' or '$(TargetFrameworkVersion)' == 'v4.6.1' or '$(TargetFrameworkVersion)' == 'v4.6.2'"
TaskParameter="FrameworkVersion45Path"
ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
<Output Condition="'$(TargetFrameworkVersion)' == 'v4.0'"
</CreateProperty>
<Warning Text="TargetFrameworkVersion '$(TargetFrameworkVersion)' not supported by this toolset (ToolsVersion: $(MSBuildToolsVersion))."
- Condition="'$(TargetFrameworkVersion)' != 'v4.6.1' and '$(TargetFrameworkVersion)' != 'v4.6' and '$(TargetFrameworkVersion)' != 'v4.5.2' and '$(TargetFrameworkVersion)' != 'v4.5.1' and '$(TargetFrameworkVersion)' != 'v4.5' and '$(TargetFrameworkVersion)' != 'v4.0' and '$(TargetFrameworkVersion)' != 'v3.5' and '$(TargetFrameworkVersion)' != 'v3.0' and '$(TargetFrameworkVersion)' != 'v2.0'"/>
+ Condition="'$(TargetFrameworkVersion)' != 'v4.6.2' and '$(TargetFrameworkVersion)' != 'v4.6.1' and '$(TargetFrameworkVersion)' != 'v4.6' and '$(TargetFrameworkVersion)' != 'v4.5.2' and '$(TargetFrameworkVersion)' != 'v4.5.1' and '$(TargetFrameworkVersion)' != 'v4.5' and '$(TargetFrameworkVersion)' != 'v4.0' and '$(TargetFrameworkVersion)' != 'v3.5' and '$(TargetFrameworkVersion)' != 'v3.0' and '$(TargetFrameworkVersion)' != 'v2.0'"/>
</Target>
<PropertyGroup>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<FileList Name=".NET Framework 4.6.2" TargetFrameworkDirectory="..\..\..\..\4.5">
+</FileList>
endif
if CROSS_COMPILING
-SUBDIRS = $(btls_dirs) arch utils io-layer cil metadata $(sgen_dirs) mini dis profiler
+SUBDIRS = $(btls_dirs) arch utils cil metadata $(sgen_dirs) mini dis profiler
else
if INSTALL_MONOTOUCH
-SUBDIRS = $(btls_dirs) arch utils io-layer metadata $(sgen_dirs) mini profiler
+SUBDIRS = $(btls_dirs) arch utils metadata $(sgen_dirs) mini profiler
monotouch-do-build:
@list='$(SUBDIRS)'; for subdir in $$list; do \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target); \
done;
else
-SUBDIRS = $(btls_dirs) arch utils io-layer cil metadata $(sgen_dirs) mini dis tests unit-tests benchmark profiler
+SUBDIRS = $(btls_dirs) arch utils cil metadata $(sgen_dirs) mini dis tests unit-tests benchmark profiler
endif
endif
-DIST_SUBDIRS = btls arch utils io-layer cil metadata $(sgen_dirs) mini dis tests unit-tests benchmark profiler
+DIST_SUBDIRS = btls arch utils cil metadata $(sgen_dirs) mini dis tests unit-tests benchmark profiler
char xx : 4;
char r3 : 4;
char r4 : 4;
-} __attribute__ ((packed)) RRD_Format;
+} __attribute__ ((__packed__)) RRD_Format;
typedef struct {
short op;
int b2 : 4;
int d2 : 20;
char op2;
-} __attribute__ ((packed)) RXY_Format;
+} __attribute__ ((__packed__)) RXY_Format;
typedef struct {
char op;
short dl2 : 12;
char dh2;
char op2;
-} __attribute__ ((packed)) RSY_Format_1;
+} __attribute__ ((__packed__)) RSY_Format_1;
typedef struct {
char op1;
short dl2 : 12;
char dh2;
char op2;
-} __attribute__ ((packed)) RSY_Format_2;
+} __attribute__ ((__packed__)) RSY_Format_2;
typedef struct {
char op1;
short d1 : 12;
char yy;
char op2;
-} __attribute__ ((packed)) RSL_Format;
+} __attribute__ ((__packed__)) RSL_Format;
typedef struct {
char op;
char r1 : 4;
char r3 : 4;
short i2;
-} __attribute__ ((packed)) RSI_Format;
+} __attribute__ ((__packed__)) RSI_Format;
typedef struct {
char op1;
char m1 : 4;
char op2 : 4;
short i2;
-} __attribute__ ((packed)) RI_Format;
+} __attribute__ ((__packed__)) RI_Format;
typedef struct {
char op1;
short i2;
char xx;
char op2;
-} __attribute__ ((packed)) RIE_Format_1;
+} __attribute__ ((__packed__)) RIE_Format_1;
typedef struct {
char op1;
char m2 : 4;
char xx : 4;
char op2;
-} __attribute__ ((packed)) RIE_Format_2;
+} __attribute__ ((__packed__)) RIE_Format_2;
typedef struct {
char op1;
short d;
char i;
char op2;
-} __attribute__ ((packed)) RIE_Format_3;
+} __attribute__ ((__packed__)) RIE_Format_3;
typedef struct {
char op1;
char m3 : 4;
char xx : 4;
char op2;
-} __attribute__ ((packed)) RIE_Format_4;
+} __attribute__ ((__packed__)) RIE_Format_4;
typedef struct {
char op1;
short ri2;
char xx;
char op2;
-} __attribute__ ((packed)) RIE_Format_5;
+} __attribute__ ((__packed__)) RIE_Format_5;
typedef struct {
char op1;
char i4;
char i5;
char op2;
-} __attribute__ ((packed)) RIE_Format_6;
+} __attribute__ ((__packed__)) RIE_Format_6;
typedef struct {
char op1;
short i2;
char xx;
char op2;
-} __attribute__ ((packed)) RIE_Format_7;
+} __attribute__ ((__packed__)) RIE_Format_7;
typedef struct {
char op1;
int d4 : 12;
char i2;
char op2;
-} __attribute__ ((packed)) RIS_Format;
+} __attribute__ ((__packed__)) RIS_Format;
typedef struct {
char op1;
char r1 : 4;
char op2 : 4;
int i2;
-} __attribute__ ((packed)) RIL_Format_1;
+} __attribute__ ((__packed__)) RIL_Format_1;
typedef struct {
char op1;
char m1 : 4;
char op2 : 4;
int i2;
-} __attribute__ ((packed)) RIL_Format_2;
+} __attribute__ ((__packed__)) RIL_Format_2;
typedef struct {
short op1;
char m3 : 4;
char xx : 4;
char op2;
-} __attribute__ ((packed)) RXE_Format;
+} __attribute__ ((__packed__)) RXE_Format;
typedef struct {
char op;
char i2;
short b1 : 4;
short d1 : 12;
-} __attribute__ ((packed)) SI_Format;
+} __attribute__ ((__packed__)) SI_Format;
typedef struct {
short op;
char b1 : 4;
short d1 : 12;
short i2;
-} __attribute__ ((packed)) SIL_Format;
+} __attribute__ ((__packed__)) SIL_Format;
typedef struct {
char op1;
char b1 : 4;
int d1 : 20;
char op2;
-} __attribute__ ((packed)) SIY_Format;
+} __attribute__ ((__packed__)) SIY_Format;
typedef struct {
char op1;
short b3 : 4;
short d3 : 12;
short ri2;
-} __attribute__ ((packed)) SMI_Format;
+} __attribute__ ((__packed__)) SMI_Format;
typedef struct {
short op;
short b2 : 4;
short d2 : 12;
-} __attribute__ ((packed)) S_Format;
+} __attribute__ ((__packed__)) S_Format;
typedef struct {
char op;
short d1 : 12;
short b2 : 4;
short d2 : 12;
-} __attribute__ ((packed)) SS_Format_1;
+} __attribute__ ((__packed__)) SS_Format_1;
typedef struct {
char op;
short d1 : 12;
short b2 : 4;
short d2 : 12;
-} __attribute__ ((packed)) SS_Format_2;
+} __attribute__ ((__packed__)) SS_Format_2;
typedef struct {
char op;
short d1 : 12;
short b2 : 4;
short d2 : 12;
-} __attribute__ ((packed)) SS_Format_3;
+} __attribute__ ((__packed__)) SS_Format_3;
typedef struct {
char op;
short d2 : 12;
short b4 : 4;
short d4 : 12;
-} __attribute__ ((packed)) SS_Format_4;
+} __attribute__ ((__packed__)) SS_Format_4;
typedef struct {
short op;
short d1 : 12;
short b2 : 4;
short d2 : 12;
-} __attribute__ ((packed)) SSE_Format;
+} __attribute__ ((__packed__)) SSE_Format;
typedef struct {
short op;
short d1 : 12;
short b2 : 4;
short d2 : 12;
-} __attribute__ ((packed)) SSF_Format;
+} __attribute__ ((__packed__)) SSF_Format;
typedef struct {
short op1;
char m3 : 4;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRIa_Format;
+} __attribute__ ((__packed__)) VRIa_Format;
typedef struct {
short op1;
char m4 : 4;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRIb_Format;
+} __attribute__ ((__packed__)) VRIb_Format;
typedef struct {
short op1;
char m4 : 4;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRIc_Format;
+} __attribute__ ((__packed__)) VRIc_Format;
typedef struct {
short op1;
char m5 : 4;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRId_Format;
+} __attribute__ ((__packed__)) VRId_Format;
typedef struct {
short op1;
char m4 : 4;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRIe_Format;
+} __attribute__ ((__packed__)) VRIe_Format;
typedef struct {
short op1;
char m3 : 4;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRRa_Format;
+} __attribute__ ((__packed__)) VRRa_Format;
typedef struct {
short op1;
char m4 : 4;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRRb_Format;
+} __attribute__ ((__packed__)) VRRb_Format;
typedef struct {
short op1;
char m3 : 4;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRRc_Format;
+} __attribute__ ((__packed__)) VRRc_Format;
typedef struct {
short op1;
char v4 : 4;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRRd_Format;
+} __attribute__ ((__packed__)) VRRd_Format;
typedef struct {
short op1;
char v4 : 4;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRRe_Format;
+} __attribute__ ((__packed__)) VRRe_Format;
typedef struct {
short op1;
short xx;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRRf_Format;
+} __attribute__ ((__packed__)) VRRf_Format;
typedef struct {
short op1;
char m4 : 4;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRSa_Format;
+} __attribute__ ((__packed__)) VRSa_Format;
typedef struct {
short op1;
char m4 : 4;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRSb_Format;
+} __attribute__ ((__packed__)) VRSb_Format;
typedef struct {
short op1;
char m4 : 4;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRSc_Format;
+} __attribute__ ((__packed__)) VRSc_Format;
typedef struct {
short op1;
char m3 : 4;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRV_Format;
+} __attribute__ ((__packed__)) VRV_Format;
typedef struct {
short op1;
char m3 : 4;
char rxb : 4;
char op2;
-} __attribute__ ((packed)) VRX_Format;
+} __attribute__ ((__packed__)) VRX_Format;
#define s390_emit16(c, x) do \
{ \
} size_data;
/*========================= End of Typedefs ========================*/
-\f
+
/*------------------------------------------------------------------*/
/* */
/* Name - add_general */
}
/*========================= End of Function ========================*/
-\f
+
/*------------------------------------------------------------------*/
/* */
/* Name - calculate_sizes */
}
/*========================= End of Function ========================*/
-\f
+
/*------------------------------------------------------------------*/
/* */
/* Name - emit_prolog */
}
/*========================= End of Function ========================*/
-\f
+
/*------------------------------------------------------------------*/
/* */
/* Name - emit_save_parameters */
}
/*========================= End of Function ========================*/
-\f
+
/*------------------------------------------------------------------*/
/* */
/* Name - alloc_code_memory */
}
/*========================= End of Function ========================*/
-\f
+
/*------------------------------------------------------------------*/
/* */
/* Name - emit_call_and_store_retval */
}
/*========================= End of Function ========================*/
-\f
+
/*------------------------------------------------------------------*/
/* */
/* Name - emit_epilog */
}
/*========================= End of Function ========================*/
-\f
+
/*------------------------------------------------------------------*/
/* */
/* Name - mono_arch_create_trampoline. */
}
/*========================= End of Function ========================*/
-\f
+
/*------------------------------------------------------------------*/
/* */
/* Name - mono_arch_create_method_pointer */
message (WARNING "SET ARCH: ${BTLS_ARCH}")
set (CMAKE_SYSTEM_PROCESSOR "${BTLS_ARCH}")
endif ()
-if (BUILD_DYNAMIC_BTLS)
-set (C_CXX_FLAGS "-Wall -Wsign-compare -Wmissing-field-initializers -fPIC -ggdb -fvisibility=hidden")
-elseif (BUILD_SHARED_LIBS)
+
set (C_CXX_FLAGS "-Wall -Wsign-compare -Wmissing-field-initializers -fPIC -ggdb -fvisibility=hidden")
-else ()
-set (C_CXX_FLAGS "-Wall -Wsign-compare -Wmissing-field-initializers -ggdb -fvisibility=hidden")
-endif()
+
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_CXX_FLAGS} ${BTLS_CFLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${C_CXX_FLAGS} ${BTLS_CFLAGS}")
set (CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${BTLS_CFLAGS}")
${BORINGSSL_OBJECTS}
)
-if (BUILD_SHARED_LIBS)
- add_library (mono-btls-shared SHARED ${MONO_BTLS_SOURCES})
-else ()
- add_library (mono-btls-static STATIC ${MONO_BTLS_SOURCES})
-endif ()
+add_library (mono-btls-shared SHARED ${MONO_BTLS_SOURCES})
-EXTRA_DIST = \
+MONO_BTLS_SOURCES_FILES = \
btls-bio.c \
btls-bio.h \
btls-error.c \
btls-x509-verify-param.h \
CMakeLists.txt
+EXTRA_DIST = $(MONO_BTLS_SOURCES_FILES)
+
CMAKE_VERBOSE=$(if $(V),VERBOSE=1,)
CMAKE_ARGS = -D CMAKE_INSTALL_PREFIX:PATH=$(prefix) -D BTLS_ROOT:PATH=$(BTLS_ROOT) \
-D SRC_DIR:PATH=$(abs_top_srcdir)/mono/btls -D BTLS_CFLAGS:STRING="$(BTLS_CFLAGS)"
-all-local: build-shared/libmono-btls-shared$(libsuffix) build-static/libmono-btls-static.a
+all-local: build-shared/libmono-btls-shared$(libsuffix)
build-shared/Makefile:
-mkdir -p build-shared
(cd build-shared && CC="$(CC)" CXX="$(CXX)" $(CMAKE) $(CMAKE_ARGS) $(BTLS_CMAKE_ARGS) -DBUILD_SHARED_LIBS=1 $(abs_top_srcdir)/mono/btls)
-build-shared/libmono-btls-shared$(libsuffix): build-shared/Makefile
+build-shared/libmono-btls-shared$(libsuffix): build-shared/Makefile $(MONO_BTLS_SOURCES_FILES)
$(MAKE) -C build-shared $(CMAKE_VERBOSE)
-build-static/Makefile:
- -mkdir -p build-static
- (cd build-static && CC="$(CC)" CXX="$(CXX)" $(CMAKE) $(CMAKE_ARGS) $(BTLS_CMAKE_ARGS) $(abs_top_srcdir)/mono/btls)
-
-build-static/libmono-btls-static.a: build-static/Makefile
- $(MAKE) -C build-static $(CMAKE_VERBOSE)
-
clean-local:
- -rm -rf build-static
-rm -rf build-shared
install-exec-local:
return ERR_get_error ();
}
+MONO_API int
+mono_btls_error_peek_error_line (const char **file, int *line)
+{
+ return ERR_peek_error_line (file, line);
+}
+
+MONO_API int
+mono_btls_error_get_error_line (const char **file, int *line)
+{
+ return ERR_get_error_line (file, line);
+}
+
MONO_API void
mono_btls_error_clear_error (void)
{
void
mono_btls_error_clear_error (void);
+int
+mono_btls_error_peek_error_line (const char **file, int *line);
+
+int
+mono_btls_error_get_error_line (const char **file, int *line);
+
void
mono_btls_error_get_error_string_n (int error, char *buf, int len);
memset (ctx, 0, sizeof (MonoBtlsSslCtx));
ctx->references = 1;
ctx->ctx = SSL_CTX_new (TLS_method ());
+
+ // enable the default ciphers but disable any RC4 based ciphers
+ // since they're insecure: RFC 7465 "Prohibiting RC4 Cipher Suites"
+ SSL_CTX_set_cipher_list (ctx->ctx, "DEFAULT:!RC4");
+
+ // disable SSLv2 and SSLv3 by default, they are deprecated
+ // and should generally not be used according to the openssl docs
+ SSL_CTX_set_options (ctx->ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);
+
return ctx;
}
ptr->ctx = mono_btls_ssl_ctx_up_ref (ctx);
ptr->ssl = SSL_new (mono_btls_ssl_ctx_get_ctx (ptr->ctx));
- SSL_set_options (ptr->ssl, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);
-
return ptr;
}
#else
#ifdef __GNUC__
-#define MONO_API __attribute__ ((visibility ("default")))
+#define MONO_API __attribute__ ((__visibility__ ("default")))
#else
#define MONO_API
#endif
runtime_lib= \
$(metadata_lib) \
$(gc_lib) \
- $(top_builddir)/mono/io-layer/libwapi.la \
$(top_builddir)/mono/utils/libmonoutils.la \
$(GLIB_LIBS) $(LIBICONV)
+++ /dev/null
-/semantic.cache
-/.deps
-/.libs
-/Makefile
-/Makefile.in
-/mono-handle-d
-/*.lo
-/*.la
-/*.o
-/.project
-/.cproject
-/TAGS
+++ /dev/null
-
-noinst_LTLIBRARIES = libwapi.la
-
-AM_CPPFLAGS = \
- $(GLIB_CFLAGS) \
- $(LIBGC_CPPFLAGS) \
- -DMONO_BINDIR=\""$(bindir)"\" \
- -I$(top_srcdir) \
- $(SHARED_CFLAGS)
-
-libwapiincludedir = $(includedir)/mono-$(API_VER)/mono/io-layer
-
-OTHER_H = \
- error.h \
- io.h \
- io-trace.h \
- io-layer.h \
- io-portability.h \
- sockets.h \
- uglify.h \
- wapi.h \
- wapi-remap.h
-
-OTHER_SRC = \
- error.c \
- error.h \
- io.c \
- io.h \
- io-portability.c \
- io-portability.h \
- io-private.h \
- io-layer.h \
- locking.c \
- posix.c \
- sockets.c \
- sockets.h \
- socket-private.h \
- socket-wrappers.h \
- uglify.h \
- wapi_glob.h \
- wapi_glob.c \
- wapi.h \
- wapi-private.h \
- wapi.c
-
-
-WINDOWS_H = \
- io-layer.h
-
-WINDOWS_SRC = \
- io-layer.h \
- io-layer-dummy.c
-
-if HOST_WIN32
-libwapi_la_SOURCES = $(WINDOWS_SRC) $(WINDOWS_H)
-else
-libwapi_la_SOURCES = $(OTHER_SRC) $(OTHER_H)
-endif
-if PLATFORM_DARWIN
-libwapi_la_LIBADD = -lproc
-endif
-
-EXTRA_DIST = \
- $(WINDOWS_SRC)
- $(OTHER_SRC)
-
-
+++ /dev/null
-/*
- * error.c: Error reporting
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#include <config.h>
-#include <glib.h>
-#include <pthread.h>
-#include <string.h>
-#include <errno.h>
-
-#include "mono/io-layer/wapi.h"
-#include "mono/io-layer/wapi-private.h"
-#include "mono/utils/mono-lazy-init.h"
-
-static pthread_key_t error_key;
-static mono_lazy_init_t error_key_once = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED;
-
-static void error_init(void)
-{
- int ret;
-
- ret = pthread_key_create(&error_key, NULL);
- g_assert (ret == 0);
-}
-
-static void error_cleanup (void)
-{
- int ret;
-
- ret = pthread_key_delete (error_key);
- g_assert (ret == 0);
-}
-
-void _wapi_error_cleanup (void)
-{
- mono_lazy_cleanup (&error_key_once, error_cleanup);
-}
-
-/**
- * GetLastError:
- *
- * Retrieves the last error that occurred in the calling thread.
- *
- * Return value: The error code for the last error that happened on
- * the calling thread.
- */
-guint32 GetLastError(void)
-{
- guint32 err;
- void *errptr;
-
- if (_wapi_has_shut_down)
- return 0;
- mono_lazy_initialize(&error_key_once, error_init);
- errptr=pthread_getspecific(error_key);
- err=GPOINTER_TO_UINT(errptr);
-
- return(err);
-}
-
-/**
- * SetLastError:
- * @code: The error code.
- *
- * Sets the error code in the calling thread.
- */
-void SetLastError(guint32 code)
-{
- int ret;
-
- if (_wapi_has_shut_down)
- return;
- /* Set the thread-local error code */
- mono_lazy_initialize(&error_key_once, error_init);
- ret = pthread_setspecific(error_key, GUINT_TO_POINTER(code));
- g_assert (ret == 0);
-}
-
-guint32
-errno_to_WSA (guint32 code, const gchar *function_name)
-{
- gint result = -1;
- char *sys_error;
- gchar *msg;
-
- switch (code) {
- case 0: result = ERROR_SUCCESS; break;
- case EACCES: result = WSAEACCES; break;
-#ifdef EADDRINUSE
- case EADDRINUSE: result = WSAEADDRINUSE; break;
-#endif
-#ifdef EAFNOSUPPORT
- case EAFNOSUPPORT: result = WSAEAFNOSUPPORT; break;
-#endif
-#if EAGAIN != EWOULDBLOCK
- case EAGAIN: result = WSAEWOULDBLOCK; break;
-#endif
-#ifdef EALREADY
- case EALREADY: result = WSAEALREADY; break;
-#endif
- case EBADF: result = WSAENOTSOCK; break;
-#ifdef ECONNABORTED
- case ECONNABORTED: result = WSAENETDOWN; break;
-#endif
-#ifdef ECONNREFUSED
- case ECONNREFUSED: result = WSAECONNREFUSED; break;
-#endif
-#ifdef ECONNRESET
- case ECONNRESET: result = WSAECONNRESET; break;
-#endif
- case EFAULT: result = WSAEFAULT; break;
-#ifdef EHOSTUNREACH
- case EHOSTUNREACH: result = WSAEHOSTUNREACH; break;
-#endif
-#ifdef EINPROGRESS
- case EINPROGRESS: result = WSAEINPROGRESS; break;
-#endif
- case EINTR: result = WSAEINTR; break;
- case EINVAL: result = WSAEINVAL; break;
- /*FIXME: case EIO: result = WSAE????; break; */
-#ifdef EISCONN
- case EISCONN: result = WSAEISCONN; break;
-#endif
- /* FIXME: case ELOOP: result = WSA????; break; */
- case EMFILE: result = WSAEMFILE; break;
-#ifdef EMSGSIZE
- case EMSGSIZE: result = WSAEMSGSIZE; break;
-#endif
- /* FIXME: case ENAMETOOLONG: result = WSAEACCES; break; */
-#ifdef ENETUNREACH
- case ENETUNREACH: result = WSAENETUNREACH; break;
-#endif
-#ifdef ENOBUFS
- case ENOBUFS: result = WSAENOBUFS; break; /* not documented */
-#endif
- /* case ENOENT: result = WSAE????; break; */
- case ENOMEM: result = WSAENOBUFS; break;
-#ifdef ENOPROTOOPT
- case ENOPROTOOPT: result = WSAENOPROTOOPT; break;
-#endif
-#ifdef ENOSR
- case ENOSR: result = WSAENETDOWN; break;
-#endif
-#ifdef ENOTCONN
- case ENOTCONN: result = WSAENOTCONN; break;
-#endif
- /*FIXME: case ENOTDIR: result = WSAE????; break; */
-#ifdef ENOTSOCK
- case ENOTSOCK: result = WSAENOTSOCK; break;
-#endif
- case ENOTTY: result = WSAENOTSOCK; break;
-#ifdef EOPNOTSUPP
- case EOPNOTSUPP: result = WSAEOPNOTSUPP; break;
-#endif
- case EPERM: result = WSAEACCES; break;
- case EPIPE: result = WSAESHUTDOWN; break;
-#ifdef EPROTONOSUPPORT
- case EPROTONOSUPPORT: result = WSAEPROTONOSUPPORT; break;
-#endif
-#if ERESTARTSYS
- case ERESTARTSYS: result = WSAENETDOWN; break;
-#endif
- /*FIXME: case EROFS: result = WSAE????; break; */
-#ifdef ESOCKTNOSUPPORT
- case ESOCKTNOSUPPORT: result = WSAESOCKTNOSUPPORT; break;
-#endif
-#ifdef ETIMEDOUT
- case ETIMEDOUT: result = WSAETIMEDOUT; break;
-#endif
-#ifdef EWOULDBLOCK
- case EWOULDBLOCK: result = WSAEWOULDBLOCK; break;
-#endif
-#ifdef EADDRNOTAVAIL
- case EADDRNOTAVAIL: result = WSAEADDRNOTAVAIL; break;
-#endif
- /* This might happen with unix sockets */
- case ENOENT: result = WSAECONNREFUSED; break;
-#ifdef EDESTADDRREQ
- case EDESTADDRREQ: result = WSAEDESTADDRREQ; break;
-#endif
-#ifdef EHOSTDOWN
- case EHOSTDOWN: result = WSAEHOSTDOWN; break;
-#endif
-#ifdef ENETDOWN
- case ENETDOWN: result = WSAENETDOWN; break;
-#endif
- case ENODEV: result = WSAENETDOWN; break;
- default:
- sys_error = strerror (code);
- msg = g_locale_to_utf8 (sys_error, strlen (sys_error), NULL, NULL, NULL);
- if (function_name == NULL)
- function_name = __func__;
-
- g_warning ("%s: Need to translate %d [%s] into winsock error",
- function_name, code, msg);
-
- g_free (msg);
- result = WSASYSCALLFAILURE;
- }
-
- return result;
-}
-
-gint
-_wapi_get_win32_file_error (gint err)
-{
- gint ret;
- /* mapping ideas borrowed from wine. they may need some work */
-
- switch (err) {
- case EACCES: case EPERM: case EROFS:
- ret = ERROR_ACCESS_DENIED;
- break;
-
- case EAGAIN:
- ret = ERROR_SHARING_VIOLATION;
- break;
-
- case EBUSY:
- ret = ERROR_LOCK_VIOLATION;
- break;
-
- case EEXIST:
- ret = ERROR_FILE_EXISTS;
- break;
-
- case EINVAL: case ESPIPE:
- ret = ERROR_SEEK;
- break;
-
- case EISDIR:
- ret = ERROR_CANNOT_MAKE;
- break;
-
- case ENFILE: case EMFILE:
- ret = ERROR_TOO_MANY_OPEN_FILES;
- break;
-
- case ENOENT: case ENOTDIR:
- ret = ERROR_FILE_NOT_FOUND;
- break;
-
- case ENOSPC:
- ret = ERROR_HANDLE_DISK_FULL;
- break;
-
- case ENOTEMPTY:
- ret = ERROR_DIR_NOT_EMPTY;
- break;
-
- case ENOEXEC:
- ret = ERROR_BAD_FORMAT;
- break;
-
- case ENAMETOOLONG:
- ret = ERROR_FILENAME_EXCED_RANGE;
- break;
-
-#ifdef EINPROGRESS
- case EINPROGRESS:
- ret = ERROR_IO_PENDING;
- break;
-#endif
-
- case ENOSYS:
- ret = ERROR_NOT_SUPPORTED;
- break;
-
- case EBADF:
- ret = ERROR_INVALID_HANDLE;
- break;
-
- case EIO:
- ret = ERROR_INVALID_HANDLE;
- break;
-
- case EINTR:
- ret = ERROR_IO_PENDING; /* best match I could find */
- break;
-
- case EPIPE:
- ret = ERROR_WRITE_FAULT;
- break;
-
- default:
- g_message ("Unknown errno: %s\n", g_strerror (err));
- ret = ERROR_GEN_FAILURE;
- break;
- }
-
- return ret;
-}
-
+++ /dev/null
-/*
- * error.h: Error reporting
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_ERROR_H_
-#define _WAPI_ERROR_H_
-
-typedef enum {
- ERROR_SUCCESS = 0,
- ERROR_FILE_NOT_FOUND = 2,
- ERROR_PATH_NOT_FOUND = 3,
- ERROR_TOO_MANY_OPEN_FILES = 4,
- ERROR_ACCESS_DENIED = 5,
- ERROR_INVALID_HANDLE = 6,
- ERROR_NOT_ENOUGH_MEMORY = 8,
- ERROR_BAD_FORMAT = 11,
- ERROR_INVALID_ACCESS = 12,
- ERROR_INVALID_DATA = 13,
- ERROR_OUTOFMEMORY = 14,
- ERROR_NOT_SAME_DEVICE = 17,
- ERROR_NO_MORE_FILES = 18,
- ERROR_BAD_LENGTH = 24,
- ERROR_SEEK = 25,
- ERROR_WRITE_FAULT = 29,
- ERROR_GEN_FAILURE = 31,
- ERROR_SHARING_VIOLATION = 32,
- ERROR_LOCK_VIOLATION = 33,
- ERROR_HANDLE_DISK_FULL = 39,
- ERROR_NOT_SUPPORTED = 50,
- ERROR_FILE_EXISTS = 80,
- ERROR_CANNOT_MAKE = 82,
- ERROR_INVALID_PARAMETER = 87,
- ERROR_INVALID_NAME = 123,
- ERROR_PROC_NOT_FOUND = 127,
- ERROR_DIR_NOT_EMPTY = 145,
- ERROR_ALREADY_EXISTS = 183,
- ERROR_BAD_EXE_FORMAT = 193,
- ERROR_FILENAME_EXCED_RANGE = 206,
- ERROR_DIRECTORY = 267,
- ERROR_IO_PENDING = 997,
- ERROR_ENCRYPTION_FAILED = 6000,
- WSAEINTR = 10004,
- WSAEBADF = 10009,
- WSAEACCES = 10013,
- WSAEFAULT = 10014,
- WSAEINVAL = 10022,
- WSAEMFILE = 10024,
- WSAEWOULDBLOCK = 10035,
- WSAEINPROGRESS = 10036,
- WSAEALREADY = 10037,
- WSAENOTSOCK = 10038,
- WSAEDESTADDRREQ = 10039,
- WSAEMSGSIZE = 10040,
- WSAENOPROTOOPT = 10042,
- WSAEPROTONOSUPPORT = 10043,
- WSAESOCKTNOSUPPORT = 10044,
- WSAEOPNOTSUPP = 10045,
- WSAEAFNOSUPPORT = 10047,
- WSAEADDRINUSE = 10048,
- WSAEADDRNOTAVAIL = 10049,
- WSAENETDOWN = 10050,
- WSAENETUNREACH = 10051,
- WSAECONNRESET = 10054,
- WSAENOBUFS = 10055,
- WSAEISCONN = 10056,
- WSAENOTCONN = 10057,
- WSAESHUTDOWN = 10058,
- WSAETIMEDOUT = 10060,
- WSAECONNREFUSED = 10061,
- WSAEHOSTDOWN = 10064,
- WSAEHOSTUNREACH = 10065,
- WSASYSCALLFAILURE = 10107,
-} WapiError;
-
-G_BEGIN_DECLS
-
-guint32 GetLastError (void);
-void SetLastError (guint32 code);
-guint32 errno_to_WSA (guint32 code, const char *function_name);
-gint _wapi_get_win32_file_error (gint err);
-void _wapi_error_cleanup (void);
-
-G_END_DECLS
-
-#endif /* _WAPI_ERROR_H_ */
+++ /dev/null
-/*
- * io-layer-dummy.c: Dummy file to fill the library on windows
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-extern char *_mono_iolayer_dummylib;
-char *_mono_iolayer_dummylib="This is a dummy library that isn't needed on Windows";
+++ /dev/null
-/*
- * io-layer.h: Include the right files depending on platform. This
- * file is the only entry point into the io-layer library.
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _MONO_IOLAYER_IOLAYER_H_
-#define _MONO_IOLAYER_IOLAYER_H_
-
-#include <config.h>
-#include <glib.h>
-
-#if defined(__WIN32__) || defined(_WIN32)
-/* Native win32 */
-#define __USE_W32_SOCKETS
-#include <winsock2.h>
-#include <windows.h>
-#include <winbase.h>
-/*
- * The mingw version says:
- * /usr/i686-pc-mingw32/sys-root/mingw/include/ws2tcpip.h:38:2: error: #error "ws2tcpip.h is not compatible with winsock.h. Include winsock2.h instead."
- */
-#ifdef _MSC_VER
-#include <ws2tcpip.h>
-#endif
-#include <psapi.h>
-
- /*
- * Workaround for missing WSAPOLLFD typedef in mingw's winsock2.h that is required for mswsock.h below.
- * Remove once http://sourceforge.net/p/mingw/bugs/1980/ is fixed.
- */
-#if defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION == 4
-typedef struct pollfd {
- SOCKET fd;
- short events;
- short revents;
-} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
-#endif
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#include <mswsock.h>
-#endif
-
-#else /* EVERYONE ELSE */
-#include "mono/io-layer/wapi.h"
-#include "mono/io-layer/uglify.h"
-#endif /* HOST_WIN32 */
-
-#ifdef __native_client__
-#include "mono/metadata/nacl-stub.h"
-#endif
-
-#endif /* _MONO_IOLAYER_IOLAYER_H_ */
+++ /dev/null
-/*
- * io-portability.c: Optional filename mangling to try to cope with
- * badly-written non-portable windows apps
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * Copyright (c) 2006 Novell, Inc.
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-
-#include <config.h>
-#include <glib.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#ifdef HAVE_DIRENT_H
-# include <dirent.h>
-#endif
-#include <utime.h>
-#include <sys/stat.h>
-
-#include <mono/io-layer/error.h>
-#include <mono/io-layer/wapi_glob.h>
-#include <mono/io-layer/io-portability.h>
-#include <mono/utils/mono-io-portability.h>
-
-#undef DEBUG
-
-int _wapi_open (const char *pathname, int flags, mode_t mode)
-{
- int fd;
- gchar *located_filename;
-
- if (flags & O_CREAT) {
- located_filename = mono_portability_find_file (pathname, FALSE);
- if (located_filename == NULL) {
- fd = open (pathname, flags, mode);
- } else {
- fd = open (located_filename, flags, mode);
- g_free (located_filename);
- }
- } else {
- fd = open (pathname, flags, mode);
- if (fd == -1 &&
- (errno == ENOENT || errno == ENOTDIR) &&
- IS_PORTABILITY_SET) {
- int saved_errno = errno;
- located_filename = mono_portability_find_file (pathname, TRUE);
-
- if (located_filename == NULL) {
- errno = saved_errno;
- return (-1);
- }
-
- fd = open (located_filename, flags, mode);
- g_free (located_filename);
- }
- }
-
-
- return(fd);
-}
-
-int _wapi_access (const char *pathname, int mode)
-{
- int ret;
-
- ret = access (pathname, mode);
- if (ret == -1 &&
- (errno == ENOENT || errno == ENOTDIR) &&
- IS_PORTABILITY_SET) {
- int saved_errno = errno;
- gchar *located_filename = mono_portability_find_file (pathname, TRUE);
-
- if (located_filename == NULL) {
- errno = saved_errno;
- return(-1);
- }
-
- ret = access (located_filename, mode);
- g_free (located_filename);
- }
-
- return(ret);
-}
-
-int _wapi_chmod (const char *pathname, mode_t mode)
-{
- int ret;
-
- ret = chmod (pathname, mode);
- if (ret == -1 &&
- (errno == ENOENT || errno == ENOTDIR) &&
- IS_PORTABILITY_SET) {
- int saved_errno = errno;
- gchar *located_filename = mono_portability_find_file (pathname, TRUE);
-
- if (located_filename == NULL) {
- errno = saved_errno;
- return(-1);
- }
-
- ret = chmod (located_filename, mode);
- g_free (located_filename);
- }
-
- return(ret);
-}
-
-int _wapi_utime (const char *filename, const struct utimbuf *buf)
-{
- int ret;
-
- ret = utime (filename, buf);
- if (ret == -1 &&
- errno == ENOENT &&
- IS_PORTABILITY_SET) {
- int saved_errno = errno;
- gchar *located_filename = mono_portability_find_file (filename, TRUE);
-
- if (located_filename == NULL) {
- errno = saved_errno;
- return(-1);
- }
-
- ret = utime (located_filename, buf);
- g_free (located_filename);
- }
-
- return(ret);
-}
-
-int _wapi_unlink (const char *pathname)
-{
- int ret;
-
- ret = unlink (pathname);
- if (ret == -1 &&
- (errno == ENOENT || errno == ENOTDIR || errno == EISDIR) &&
- IS_PORTABILITY_SET) {
- int saved_errno = errno;
- gchar *located_filename = mono_portability_find_file (pathname, TRUE);
-
- if (located_filename == NULL) {
- errno = saved_errno;
- return(-1);
- }
-
- ret = unlink (located_filename);
- g_free (located_filename);
- }
-
- return(ret);
-}
-
-int _wapi_rename (const char *oldpath, const char *newpath)
-{
- int ret;
- gchar *located_newpath = mono_portability_find_file (newpath, FALSE);
-
- if (located_newpath == NULL) {
- ret = rename (oldpath, newpath);
- } else {
- ret = rename (oldpath, located_newpath);
-
- if (ret == -1 &&
- (errno == EISDIR || errno == ENAMETOOLONG ||
- errno == ENOENT || errno == ENOTDIR || errno == EXDEV) &&
- IS_PORTABILITY_SET) {
- int saved_errno = errno;
- gchar *located_oldpath = mono_portability_find_file (oldpath, TRUE);
-
- if (located_oldpath == NULL) {
- g_free (located_oldpath);
- g_free (located_newpath);
-
- errno = saved_errno;
- return(-1);
- }
-
- ret = rename (located_oldpath, located_newpath);
- g_free (located_oldpath);
- }
- g_free (located_newpath);
- }
-
- return(ret);
-}
-
-int _wapi_stat (const char *path, struct stat *buf)
-{
- int ret;
-
- ret = stat (path, buf);
- if (ret == -1 &&
- (errno == ENOENT || errno == ENOTDIR) &&
- IS_PORTABILITY_SET) {
- int saved_errno = errno;
- gchar *located_filename = mono_portability_find_file (path, TRUE);
-
- if (located_filename == NULL) {
- errno = saved_errno;
- return(-1);
- }
-
- ret = stat (located_filename, buf);
- g_free (located_filename);
- }
-
- return(ret);
-}
-
-int _wapi_lstat (const char *path, struct stat *buf)
-{
- int ret;
-
- ret = lstat (path, buf);
- if (ret == -1 &&
- (errno == ENOENT || errno == ENOTDIR) &&
- IS_PORTABILITY_SET) {
- int saved_errno = errno;
- gchar *located_filename = mono_portability_find_file (path, TRUE);
-
- if (located_filename == NULL) {
- errno = saved_errno;
- return(-1);
- }
-
- ret = lstat (located_filename, buf);
- g_free (located_filename);
- }
-
- return(ret);
-}
-
-int _wapi_mkdir (const char *pathname, mode_t mode)
-{
- int ret;
- gchar *located_filename = mono_portability_find_file (pathname, FALSE);
-
- if (located_filename == NULL) {
- ret = mkdir (pathname, mode);
- } else {
- ret = mkdir (located_filename, mode);
- g_free (located_filename);
- }
-
- return(ret);
-}
-
-int _wapi_rmdir (const char *pathname)
-{
- int ret;
-
- ret = rmdir (pathname);
- if (ret == -1 &&
- (errno == ENOENT || errno == ENOTDIR || errno == ENAMETOOLONG) &&
- IS_PORTABILITY_SET) {
- int saved_errno = errno;
- gchar *located_filename = mono_portability_find_file (pathname, TRUE);
-
- if (located_filename == NULL) {
- errno = saved_errno;
- return(-1);
- }
-
- ret = rmdir (located_filename);
- g_free (located_filename);
- }
-
- return(ret);
-}
-
-int _wapi_chdir (const char *path)
-{
- int ret;
-
- ret = chdir (path);
- if (ret == -1 &&
- (errno == ENOENT || errno == ENOTDIR || errno == ENAMETOOLONG) &&
- IS_PORTABILITY_SET) {
- int saved_errno = errno;
- gchar *located_filename = mono_portability_find_file (path, TRUE);
-
- if (located_filename == NULL) {
- errno = saved_errno;
- return(-1);
- }
-
- ret = chdir (located_filename);
- g_free (located_filename);
- }
-
- return(ret);
-}
-
-gchar *_wapi_basename (const gchar *filename)
-{
- gchar *new_filename = g_strdup (filename), *ret;
-
- if (IS_PORTABILITY_SET) {
- g_strdelimit (new_filename, "\\", '/');
- }
-
- if (IS_PORTABILITY_DRIVE &&
- g_ascii_isalpha (new_filename[0]) &&
- (new_filename[1] == ':')) {
- int len = strlen (new_filename);
-
- g_memmove (new_filename, new_filename + 2, len - 2);
- new_filename[len - 2] = '\0';
- }
-
- ret = g_path_get_basename (new_filename);
- g_free (new_filename);
-
- return(ret);
-}
-
-gchar *_wapi_dirname (const gchar *filename)
-{
- gchar *new_filename = g_strdup (filename), *ret;
-
- if (IS_PORTABILITY_SET) {
- g_strdelimit (new_filename, "\\", '/');
- }
-
- if (IS_PORTABILITY_DRIVE &&
- g_ascii_isalpha (new_filename[0]) &&
- (new_filename[1] == ':')) {
- int len = strlen (new_filename);
-
- g_memmove (new_filename, new_filename + 2, len - 2);
- new_filename[len - 2] = '\0';
- }
-
- ret = g_path_get_dirname (new_filename);
- g_free (new_filename);
-
- return(ret);
-}
-
-GDir *_wapi_g_dir_open (const gchar *path, guint flags, GError **error)
-{
- GDir *ret;
-
- ret = g_dir_open (path, flags, error);
- if (ret == NULL &&
- ((*error)->code == G_FILE_ERROR_NOENT ||
- (*error)->code == G_FILE_ERROR_NOTDIR ||
- (*error)->code == G_FILE_ERROR_NAMETOOLONG) &&
- IS_PORTABILITY_SET) {
- gchar *located_filename = mono_portability_find_file (path, TRUE);
- GError *tmp_error = NULL;
-
- if (located_filename == NULL) {
- return(NULL);
- }
-
- ret = g_dir_open (located_filename, flags, &tmp_error);
- g_free (located_filename);
- if (tmp_error == NULL) {
- g_clear_error (error);
- }
- }
-
- return(ret);
-}
-
-
-static gint
-file_compare (gconstpointer a, gconstpointer b)
-{
- gchar *astr = *(gchar **) a;
- gchar *bstr = *(gchar **) b;
-
- return strcmp (astr, bstr);
-}
-
-static gint
-get_errno_from_g_file_error (gint error)
-{
- switch (error) {
-#ifdef EACCESS
- case G_FILE_ERROR_ACCES:
- error = EACCES;
- break;
-#endif
-#ifdef ENAMETOOLONG
- case G_FILE_ERROR_NAMETOOLONG:
- error = ENAMETOOLONG;
- break;
-#endif
-#ifdef ENOENT
- case G_FILE_ERROR_NOENT:
- error = ENOENT;
- break;
-#endif
-#ifdef ENOTDIR
- case G_FILE_ERROR_NOTDIR:
- error = ENOTDIR;
- break;
-#endif
-#ifdef ENXIO
- case G_FILE_ERROR_NXIO:
- error = ENXIO;
- break;
-#endif
-#ifdef ENODEV
- case G_FILE_ERROR_NODEV:
- error = ENODEV;
- break;
-#endif
-#ifdef EROFS
- case G_FILE_ERROR_ROFS:
- error = EROFS;
- break;
-#endif
-#ifdef ETXTBSY
- case G_FILE_ERROR_TXTBSY:
- error = ETXTBSY;
- break;
-#endif
-#ifdef EFAULT
- case G_FILE_ERROR_FAULT:
- error = EFAULT;
- break;
-#endif
-#ifdef ELOOP
- case G_FILE_ERROR_LOOP:
- error = ELOOP;
- break;
-#endif
-#ifdef ENOSPC
- case G_FILE_ERROR_NOSPC:
- error = ENOSPC;
- break;
-#endif
-#ifdef ENOMEM
- case G_FILE_ERROR_NOMEM:
- error = ENOMEM;
- break;
-#endif
-#ifdef EMFILE
- case G_FILE_ERROR_MFILE:
- error = EMFILE;
- break;
-#endif
-#ifdef ENFILE
- case G_FILE_ERROR_NFILE:
- error = ENFILE;
- break;
-#endif
-#ifdef EBADF
- case G_FILE_ERROR_BADF:
- error = EBADF;
- break;
-#endif
-#ifdef EINVAL
- case G_FILE_ERROR_INVAL:
- error = EINVAL;
- break;
-#endif
-#ifdef EPIPE
- case G_FILE_ERROR_PIPE:
- error = EPIPE;
- break;
-#endif
-#ifdef EAGAIN
- case G_FILE_ERROR_AGAIN:
- error = EAGAIN;
- break;
-#endif
-#ifdef EINTR
- case G_FILE_ERROR_INTR:
- error = EINTR;
- break;
-#endif
-#ifdef EWIO
- case G_FILE_ERROR_IO:
- error = EIO;
- break;
-#endif
-#ifdef EPERM
- case G_FILE_ERROR_PERM:
- error = EPERM;
- break;
-#endif
- case G_FILE_ERROR_FAILED:
- error = ERROR_INVALID_PARAMETER;
- break;
- }
-
- return error;
-}
-
-/* scandir using glib */
-gint _wapi_io_scandir (const gchar *dirname, const gchar *pattern,
- gchar ***namelist)
-{
- GError *error = NULL;
- GDir *dir;
- GPtrArray *names;
- gint result;
- wapi_glob_t glob_buf;
- int flags = 0, i;
-
- dir = _wapi_g_dir_open (dirname, 0, &error);
- if (dir == NULL) {
- /* g_dir_open returns ENOENT on directories on which we don't
- * have read/x permission */
- gint errnum = get_errno_from_g_file_error (error->code);
- g_error_free (error);
- if (errnum == ENOENT &&
- !_wapi_access (dirname, F_OK) &&
- _wapi_access (dirname, R_OK|X_OK)) {
- errnum = EACCES;
- }
-
- errno = errnum;
- return -1;
- }
-
- if (IS_PORTABILITY_CASE) {
- flags = WAPI_GLOB_IGNORECASE;
- }
-
- result = _wapi_glob (dir, pattern, flags, &glob_buf);
- if (g_str_has_suffix (pattern, ".*")) {
- /* Special-case the patterns ending in '.*', as
- * windows also matches entries with no extension with
- * this pattern.
- *
- * TODO: should this be a MONO_IOMAP option?
- */
- gchar *pattern2 = g_strndup (pattern, strlen (pattern) - 2);
- gint result2;
-
- g_dir_rewind (dir);
- result2 = _wapi_glob (dir, pattern2, flags | WAPI_GLOB_APPEND | WAPI_GLOB_UNIQUE, &glob_buf);
-
- g_free (pattern2);
-
- if (result != 0) {
- result = result2;
- }
- }
-
- g_dir_close (dir);
- if (glob_buf.gl_pathc == 0) {
- return(0);
- } else if (result != 0) {
- return(-1);
- }
-
- names = g_ptr_array_new ();
- for (i = 0; i < glob_buf.gl_pathc; i++) {
- g_ptr_array_add (names, g_strdup (glob_buf.gl_pathv[i]));
- }
-
- _wapi_globfree (&glob_buf);
-
- result = names->len;
- if (result > 0) {
- g_ptr_array_sort (names, file_compare);
- g_ptr_array_set_size (names, result + 1);
-
- *namelist = (gchar **) g_ptr_array_free (names, FALSE);
- } else {
- g_ptr_array_free (names, TRUE);
- }
-
- return result;
-}
+++ /dev/null
-/*
- * io-portability.h: Optional filename mangling to try to cope with
- * badly-written non-portable windows apps
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * Copyright (C) 2006 Novell, Inc.
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-
-#ifndef _WAPI_IO_PORTABILITY_H_
-#define _WAPI_IO_PORTABILITY_H_
-
-#include <glib.h>
-#include <sys/types.h>
-#include <utime.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-G_BEGIN_DECLS
-
-extern int _wapi_open (const char *pathname, int flags, mode_t mode);
-extern int _wapi_access (const char *pathname, int mode);
-extern int _wapi_chmod (const char *pathname, mode_t mode);
-extern int _wapi_utime (const char *filename, const struct utimbuf *buf);
-extern int _wapi_unlink (const char *pathname);
-extern int _wapi_rename (const char *oldpath, const char *newpath);
-extern int _wapi_stat (const char *path, struct stat *buf);
-extern int _wapi_lstat (const char *path, struct stat *buf);
-extern int _wapi_mkdir (const char *pathname, mode_t mode);
-extern int _wapi_rmdir (const char *pathname);
-extern int _wapi_chdir (const char *path);
-extern gchar *_wapi_basename (const gchar *filename);
-extern gchar *_wapi_dirname (const gchar *filename);
-extern GDir *_wapi_g_dir_open (const gchar *path, guint flags, GError **error);
-extern gint _wapi_io_scandir (const gchar *dirname, const gchar *pattern,
- gchar ***namelist);
-
-G_END_DECLS
-
-#endif /* _WAPI_IO_PORTABILITY_H_ */
+++ /dev/null
-/*
- * io-private.h: Private definitions for file, console and find handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- * Copyright 2011 Xamarin Inc
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-
-#ifndef _WAPI_IO_PRIVATE_H_
-#define _WAPI_IO_PRIVATE_H_
-
-#include <config.h>
-#include <glib.h>
-#ifdef HAVE_DIRENT_H
-#include <dirent.h>
-#endif
-
-#include <mono/io-layer/io.h>
-#include <mono/io-layer/wapi-private.h>
-
-extern gboolean _wapi_lock_file_region (int fd, off_t offset, off_t length);
-extern gboolean _wapi_unlock_file_region (int fd, off_t offset, off_t length);
-extern gpointer _wapi_stdhandle_create (int fd, const gchar *name);
-
-/* Currently used for both FILE, CONSOLE and PIPE handle types. This may
- * have to change in future.
- */
-struct _WapiHandle_file
-{
- gchar *filename;
- struct _WapiFileShare *share_info; /* Pointer into shared mem */
- int fd;
- guint32 security_attributes;
- guint32 fileaccess;
- guint32 sharemode;
- guint32 attrs;
-};
-
-struct _WapiHandle_find
-{
- gchar **namelist;
- gchar *dir_part;
- int num;
- size_t count;
-};
-
-#endif /* _WAPI_IO_PRIVATE_H_ */
+++ /dev/null
-/*
- * io-trace.h: tracing macros
- *
- * Authors:
- * Marek Habersack <grendel@twistedcode.net>
- *
- * Copyright 2016 Xamarin, Inc (http://xamarin.com/)
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-
-#ifndef __IO_TRACE_H
-
-#ifdef DISABLE_IO_LAYER_TRACE
-#define MONO_TRACE(...)
-#else
-#include "mono/utils/mono-logger-internals.h"
-#define MONO_TRACE(...) mono_trace (__VA_ARGS__)
-#endif
-
-#endif
+++ /dev/null
-/*
- * io.c: File, console and find handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- * Copyright (c) 2002-2006 Novell, Inc.
- * Copyright 2011 Xamarin Inc (http://www.xamarin.com).
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-
-#include <config.h>
-#include <glib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/stat.h>
-#ifdef HAVE_SYS_STATVFS_H
-#include <sys/statvfs.h>
-#endif
-#if defined(HAVE_SYS_STATFS_H)
-#include <sys/statfs.h>
-#endif
-#if defined(HAVE_SYS_PARAM_H) && defined(HAVE_SYS_MOUNT_H)
-#include <sys/param.h>
-#include <sys/mount.h>
-#endif
-#include <sys/types.h>
-#include <stdio.h>
-#include <utime.h>
-#ifdef __linux__
-#include <sys/ioctl.h>
-#include <linux/fs.h>
-#include <mono/utils/linux_magic.h>
-#endif
-
-#include <mono/io-layer/wapi.h>
-#include <mono/io-layer/wapi-private.h>
-#include <mono/io-layer/io-private.h>
-#include <mono/io-layer/io-portability.h>
-#include <mono/io-layer/io-trace.h>
-#include <mono/utils/strenc.h>
-#include <mono/utils/mono-once.h>
-#include <mono/utils/mono-logger-internals.h>
-#include <mono/metadata/w32handle.h>
-
-/*
- * If SHM is disabled, this will point to a hash of _WapiFileShare structures, otherwise
- * it will be NULL. We use this instead of _wapi_fileshare_layout to avoid allocating a
- * 4MB array.
- */
-static GHashTable *file_share_hash;
-static mono_mutex_t file_share_mutex;
-
-static void
-time_t_to_filetime (time_t timeval, WapiFileTime *filetime)
-{
- guint64 ticks;
-
- ticks = ((guint64)timeval * 10000000) + 116444736000000000ULL;
- filetime->dwLowDateTime = ticks & 0xFFFFFFFF;
- filetime->dwHighDateTime = ticks >> 32;
-}
-
-static void
-_wapi_handle_share_release (_WapiFileShare *share_info)
-{
- /* Prevent new entries racing with us */
- mono_os_mutex_lock (&file_share_mutex);
-
- g_assert (share_info->handle_refs > 0);
- share_info->handle_refs -= 1;
-
- if (share_info->handle_refs == 0)
- g_hash_table_remove (file_share_hash, share_info);
-
- mono_os_mutex_unlock (&file_share_mutex);
-}
-
-static gint
-wapi_share_info_equal (gconstpointer ka, gconstpointer kb)
-{
- const _WapiFileShare *s1 = (const _WapiFileShare *)ka;
- const _WapiFileShare *s2 = (const _WapiFileShare *)kb;
-
- return (s1->device == s2->device && s1->inode == s2->inode) ? 1 : 0;
-}
-
-static guint
-wapi_share_info_hash (gconstpointer data)
-{
- const _WapiFileShare *s = (const _WapiFileShare *)data;
-
- return s->inode;
-}
-
-static gboolean
-_wapi_handle_get_or_set_share (guint64 device, guint64 inode, guint32 new_sharemode, guint32 new_access,
- guint32 *old_sharemode, guint32 *old_access, struct _WapiFileShare **share_info)
-{
- struct _WapiFileShare *file_share;
- gboolean exists = FALSE;
-
- /* Prevent new entries racing with us */
- mono_os_mutex_lock (&file_share_mutex);
-
- _WapiFileShare tmp;
-
- /*
- * Instead of allocating a 4MB array, we use a hash table to keep track of this
- * info. This is needed even if SHM is disabled, to track sharing inside
- * the current process.
- */
- if (!file_share_hash)
- file_share_hash = g_hash_table_new_full (wapi_share_info_hash, wapi_share_info_equal, NULL, g_free);
-
- tmp.device = device;
- tmp.inode = inode;
-
- file_share = (_WapiFileShare *)g_hash_table_lookup (file_share_hash, &tmp);
- if (file_share) {
- *old_sharemode = file_share->sharemode;
- *old_access = file_share->access;
- *share_info = file_share;
-
- g_assert (file_share->handle_refs > 0);
- file_share->handle_refs += 1;
-
- exists = TRUE;
- } else {
- file_share = g_new0 (_WapiFileShare, 1);
-
- file_share->device = device;
- file_share->inode = inode;
- file_share->opened_by_pid = wapi_getpid ();
- file_share->sharemode = new_sharemode;
- file_share->access = new_access;
- file_share->handle_refs = 1;
- *share_info = file_share;
-
- g_hash_table_insert (file_share_hash, file_share, file_share);
- }
-
- mono_os_mutex_unlock (&file_share_mutex);
-
- return(exists);
-}
-
-static void file_close (gpointer handle, gpointer data);
-static void file_details (gpointer data);
-static const gchar* file_typename (void);
-static gsize file_typesize (void);
-static WapiFileType file_getfiletype(void);
-static gboolean file_read(gpointer handle, gpointer buffer,
- guint32 numbytes, guint32 *bytesread,
- WapiOverlapped *overlapped);
-static gboolean file_write(gpointer handle, gconstpointer buffer,
- guint32 numbytes, guint32 *byteswritten,
- WapiOverlapped *overlapped);
-static gboolean file_flush(gpointer handle);
-static guint32 file_seek(gpointer handle, gint32 movedistance,
- gint32 *highmovedistance, WapiSeekMethod method);
-static gboolean file_setendoffile(gpointer handle);
-static guint32 file_getfilesize(gpointer handle, guint32 *highsize);
-static gboolean file_getfiletime(gpointer handle, WapiFileTime *create_time,
- WapiFileTime *last_access,
- WapiFileTime *last_write);
-static gboolean file_setfiletime(gpointer handle,
- const WapiFileTime *create_time,
- const WapiFileTime *last_access,
- const WapiFileTime *last_write);
-static guint32 GetDriveTypeFromPath (const gchar *utf8_root_path_name);
-
-/* File handle is only signalled for overlapped IO */
-static MonoW32HandleOps _wapi_file_ops = {
- file_close, /* close */
- NULL, /* signal */
- NULL, /* own */
- NULL, /* is_owned */
- NULL, /* special_wait */
- NULL, /* prewait */
- file_details, /* details */
- file_typename, /* typename */
- file_typesize, /* typesize */
-};
-
-static void console_close (gpointer handle, gpointer data);
-static void console_details (gpointer data);
-static const gchar* console_typename (void);
-static gsize console_typesize (void);
-static WapiFileType console_getfiletype(void);
-static gboolean console_read(gpointer handle, gpointer buffer,
- guint32 numbytes, guint32 *bytesread,
- WapiOverlapped *overlapped);
-static gboolean console_write(gpointer handle, gconstpointer buffer,
- guint32 numbytes, guint32 *byteswritten,
- WapiOverlapped *overlapped);
-
-/* Console is mostly the same as file, except it can block waiting for
- * input or output
- */
-static MonoW32HandleOps _wapi_console_ops = {
- console_close, /* close */
- NULL, /* signal */
- NULL, /* own */
- NULL, /* is_owned */
- NULL, /* special_wait */
- NULL, /* prewait */
- console_details, /* details */
- console_typename, /* typename */
- console_typesize, /* typesize */
-};
-
-static const gchar* find_typename (void);
-static gsize find_typesize (void);
-
-static MonoW32HandleOps _wapi_find_ops = {
- NULL, /* close */
- NULL, /* signal */
- NULL, /* own */
- NULL, /* is_owned */
- NULL, /* special_wait */
- NULL, /* prewait */
- NULL, /* details */
- find_typename, /* typename */
- find_typesize, /* typesize */
-};
-
-static void pipe_close (gpointer handle, gpointer data);
-static void pipe_details (gpointer data);
-static const gchar* pipe_typename (void);
-static gsize pipe_typesize (void);
-static WapiFileType pipe_getfiletype (void);
-static gboolean pipe_read (gpointer handle, gpointer buffer, guint32 numbytes,
- guint32 *bytesread, WapiOverlapped *overlapped);
-static gboolean pipe_write (gpointer handle, gconstpointer buffer,
- guint32 numbytes, guint32 *byteswritten,
- WapiOverlapped *overlapped);
-
-/* Pipe handles
- */
-static MonoW32HandleOps _wapi_pipe_ops = {
- pipe_close, /* close */
- NULL, /* signal */
- NULL, /* own */
- NULL, /* is_owned */
- NULL, /* special_wait */
- NULL, /* prewait */
- pipe_details, /* details */
- pipe_typename, /* typename */
- pipe_typesize, /* typesize */
-};
-
-static const struct {
- /* File, console and pipe handles */
- WapiFileType (*getfiletype)(void);
-
- /* File, console and pipe handles */
- gboolean (*readfile)(gpointer handle, gpointer buffer,
- guint32 numbytes, guint32 *bytesread,
- WapiOverlapped *overlapped);
- gboolean (*writefile)(gpointer handle, gconstpointer buffer,
- guint32 numbytes, guint32 *byteswritten,
- WapiOverlapped *overlapped);
- gboolean (*flushfile)(gpointer handle);
-
- /* File handles */
- guint32 (*seek)(gpointer handle, gint32 movedistance,
- gint32 *highmovedistance, WapiSeekMethod method);
- gboolean (*setendoffile)(gpointer handle);
- guint32 (*getfilesize)(gpointer handle, guint32 *highsize);
- gboolean (*getfiletime)(gpointer handle, WapiFileTime *create_time,
- WapiFileTime *last_access,
- WapiFileTime *last_write);
- gboolean (*setfiletime)(gpointer handle,
- const WapiFileTime *create_time,
- const WapiFileTime *last_access,
- const WapiFileTime *last_write);
-} io_ops[MONO_W32HANDLE_COUNT]={
- {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
- /* file */
- {file_getfiletype,
- file_read, file_write,
- file_flush, file_seek,
- file_setendoffile,
- file_getfilesize,
- file_getfiletime,
- file_setfiletime},
- /* console */
- {console_getfiletype,
- console_read,
- console_write,
- NULL, NULL, NULL, NULL, NULL, NULL},
- /* thread */
- {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
- /* sem */
- {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
- /* mutex */
- {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
- /* event */
- {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
- /* socket (will need at least read and write) */
- {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
- /* find */
- {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
- /* process */
- {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
- /* pipe */
- {pipe_getfiletype,
- pipe_read,
- pipe_write,
- NULL, NULL, NULL, NULL, NULL, NULL},
-};
-
-static gboolean lock_while_writing = FALSE;
-
-/* Some utility functions.
- */
-
-/*
- * Check if a file is writable by the current user.
- *
- * This is is a best effort kind of thing. It assumes a reasonable sane set
- * of permissions by the underlying OS.
- *
- * We generally assume that basic unix permission bits are authoritative. Which might not
- * be the case under systems with extended permissions systems (posix ACLs, SELinux, OSX/iOS sandboxing, etc)
- *
- * The choice of access as the fallback is due to the expected lower overhead compared to trying to open the file.
- *
- * The only expected problem with using access are for root, setuid or setgid programs as access is not consistent
- * under those situations. It's to be expected that this should not happen in practice as those bits are very dangerous
- * and should not be used with a dynamic runtime.
- */
-static gboolean
-is_file_writable (struct stat *st, const char *path)
-{
-#if __APPLE__
- // OS X Finder "locked" or `ls -lO` "uchg".
- // This only covers one of several cases where an OS X file could be unwritable through special flags.
- if (st->st_flags & (UF_IMMUTABLE|SF_IMMUTABLE))
- return 0;
-#endif
-
- /* Is it globally writable? */
- if (st->st_mode & S_IWOTH)
- return 1;
-
- /* Am I the owner? */
- if ((st->st_uid == geteuid ()) && (st->st_mode & S_IWUSR))
- return 1;
-
- /* Am I in the same group? */
- if ((st->st_gid == getegid ()) && (st->st_mode & S_IWGRP))
- return 1;
-
- /* Fallback to using access(2). It's not ideal as it might not take into consideration euid/egid
- * but it's the only sane option we have on unix.
- */
- return access (path, W_OK) == 0;
-}
-
-
-static guint32 _wapi_stat_to_file_attributes (const gchar *pathname,
- struct stat *buf,
- struct stat *lbuf)
-{
- guint32 attrs = 0;
- gchar *filename;
-
- /* FIXME: this could definitely be better, but there seems to
- * be no pattern to the attributes that are set
- */
-
- /* Sockets (0140000) != Directory (040000) + Regular file (0100000) */
- if (S_ISSOCK (buf->st_mode))
- buf->st_mode &= ~S_IFSOCK; /* don't consider socket protection */
-
- filename = _wapi_basename (pathname);
-
- if (S_ISDIR (buf->st_mode)) {
- attrs = FILE_ATTRIBUTE_DIRECTORY;
- if (!is_file_writable (buf, pathname)) {
- attrs |= FILE_ATTRIBUTE_READONLY;
- }
- if (filename[0] == '.') {
- attrs |= FILE_ATTRIBUTE_HIDDEN;
- }
- } else {
- if (!is_file_writable (buf, pathname)) {
- attrs = FILE_ATTRIBUTE_READONLY;
-
- if (filename[0] == '.') {
- attrs |= FILE_ATTRIBUTE_HIDDEN;
- }
- } else if (filename[0] == '.') {
- attrs = FILE_ATTRIBUTE_HIDDEN;
- } else {
- attrs = FILE_ATTRIBUTE_NORMAL;
- }
- }
-
- if (lbuf != NULL) {
- if (S_ISLNK (lbuf->st_mode)) {
- attrs |= FILE_ATTRIBUTE_REPARSE_POINT;
- }
- }
-
- g_free (filename);
-
- return attrs;
-}
-
-static void
-_wapi_set_last_error_from_errno (void)
-{
- SetLastError (_wapi_get_win32_file_error (errno));
-}
-
-static void _wapi_set_last_path_error_from_errno (const gchar *dir,
- const gchar *path)
-{
- if (errno == ENOENT) {
- /* Check the path - if it's a missing directory then
- * we need to set PATH_NOT_FOUND not FILE_NOT_FOUND
- */
- gchar *dirname;
-
-
- if (dir == NULL) {
- dirname = _wapi_dirname (path);
- } else {
- dirname = g_strdup (dir);
- }
-
- if (_wapi_access (dirname, F_OK) == 0) {
- SetLastError (ERROR_FILE_NOT_FOUND);
- } else {
- SetLastError (ERROR_PATH_NOT_FOUND);
- }
-
- g_free (dirname);
- } else {
- _wapi_set_last_error_from_errno ();
- }
-}
-
-/* Handle ops.
- */
-static void file_close (gpointer handle, gpointer data)
-{
- struct _WapiHandle_file *file_handle = (struct _WapiHandle_file *)data;
- int fd = file_handle->fd;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing file handle %p [%s]", __func__, handle,
- file_handle->filename);
-
- if (file_handle->attrs & FILE_FLAG_DELETE_ON_CLOSE)
- _wapi_unlink (file_handle->filename);
-
- g_free (file_handle->filename);
-
- if (file_handle->share_info)
- _wapi_handle_share_release (file_handle->share_info);
-
- close (fd);
-}
-
-static void file_details (gpointer data)
-{
- struct _WapiHandle_file *file = (struct _WapiHandle_file *)data;
-
- g_print ("[%20s] acc: %c%c%c, shr: %c%c%c, attrs: %5u",
- file->filename,
- file->fileaccess&GENERIC_READ?'R':'.',
- file->fileaccess&GENERIC_WRITE?'W':'.',
- file->fileaccess&GENERIC_EXECUTE?'X':'.',
- file->sharemode&FILE_SHARE_READ?'R':'.',
- file->sharemode&FILE_SHARE_WRITE?'W':'.',
- file->sharemode&FILE_SHARE_DELETE?'D':'.',
- file->attrs);
-}
-
-static const gchar* file_typename (void)
-{
- return "File";
-}
-
-static gsize file_typesize (void)
-{
- return sizeof (struct _WapiHandle_file);
-}
-
-static WapiFileType file_getfiletype(void)
-{
- return(FILE_TYPE_DISK);
-}
-
-static gboolean file_read(gpointer handle, gpointer buffer,
- guint32 numbytes, guint32 *bytesread,
- WapiOverlapped *overlapped)
-{
- struct _WapiHandle_file *file_handle;
- gboolean ok;
- int fd, ret;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
- (gpointer *)&file_handle);
- if(ok==FALSE) {
- g_warning ("%s: error looking up file handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- fd = file_handle->fd;
- if(bytesread!=NULL) {
- *bytesread=0;
- }
-
- if(!(file_handle->fileaccess & GENERIC_READ) &&
- !(file_handle->fileaccess & GENERIC_ALL)) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
- __func__, handle, file_handle->fileaccess);
-
- SetLastError (ERROR_ACCESS_DENIED);
- return(FALSE);
- }
-
- do {
- ret = read (fd, buffer, numbytes);
- } while (ret == -1 && errno == EINTR &&
- !mono_thread_info_is_interrupt_state (info));
-
- if(ret==-1) {
- gint err = errno;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read of handle %p error: %s", __func__,
- handle, strerror(err));
- SetLastError (_wapi_get_win32_file_error (err));
- return(FALSE);
- }
-
- if (bytesread != NULL) {
- *bytesread = ret;
- }
-
- return(TRUE);
-}
-
-static gboolean file_write(gpointer handle, gconstpointer buffer,
- guint32 numbytes, guint32 *byteswritten,
- WapiOverlapped *overlapped G_GNUC_UNUSED)
-{
- struct _WapiHandle_file *file_handle;
- gboolean ok;
- int ret, fd;
- off_t current_pos = 0;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
- (gpointer *)&file_handle);
- if(ok==FALSE) {
- g_warning ("%s: error looking up file handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- fd = file_handle->fd;
-
- if(byteswritten!=NULL) {
- *byteswritten=0;
- }
-
- if(!(file_handle->fileaccess & GENERIC_WRITE) &&
- !(file_handle->fileaccess & GENERIC_ALL)) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
-
- SetLastError (ERROR_ACCESS_DENIED);
- return(FALSE);
- }
-
- if (lock_while_writing) {
- /* Need to lock the region we're about to write to,
- * because we only do advisory locking on POSIX
- * systems
- */
- current_pos = lseek (fd, (off_t)0, SEEK_CUR);
- if (current_pos == -1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p lseek failed: %s", __func__,
- handle, strerror (errno));
- _wapi_set_last_error_from_errno ();
- return(FALSE);
- }
-
- if (_wapi_lock_file_region (fd, current_pos,
- numbytes) == FALSE) {
- /* The error has already been set */
- return(FALSE);
- }
- }
-
- do {
- ret = write (fd, buffer, numbytes);
- } while (ret == -1 && errno == EINTR &&
- !mono_thread_info_is_interrupt_state (info));
-
- if (lock_while_writing) {
- _wapi_unlock_file_region (fd, current_pos, numbytes);
- }
-
- if (ret == -1) {
- if (errno == EINTR) {
- ret = 0;
- } else {
- _wapi_set_last_error_from_errno ();
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write of handle %p error: %s",
- __func__, handle, strerror(errno));
-
- return(FALSE);
- }
- }
- if (byteswritten != NULL) {
- *byteswritten = ret;
- }
- return(TRUE);
-}
-
-static gboolean file_flush(gpointer handle)
-{
- struct _WapiHandle_file *file_handle;
- gboolean ok;
- int ret, fd;
-
- ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
- (gpointer *)&file_handle);
- if(ok==FALSE) {
- g_warning ("%s: error looking up file handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- fd = file_handle->fd;
-
- if(!(file_handle->fileaccess & GENERIC_WRITE) &&
- !(file_handle->fileaccess & GENERIC_ALL)) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
-
- SetLastError (ERROR_ACCESS_DENIED);
- return(FALSE);
- }
-
- ret=fsync(fd);
- if (ret==-1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fsync of handle %p error: %s", __func__, handle,
- strerror(errno));
-
- _wapi_set_last_error_from_errno ();
- return(FALSE);
- }
-
- return(TRUE);
-}
-
-static guint32 file_seek(gpointer handle, gint32 movedistance,
- gint32 *highmovedistance, WapiSeekMethod method)
-{
- struct _WapiHandle_file *file_handle;
- gboolean ok;
- gint64 offset, newpos;
- int whence, fd;
- guint32 ret;
-
- ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
- (gpointer *)&file_handle);
- if(ok==FALSE) {
- g_warning ("%s: error looking up file handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(INVALID_SET_FILE_POINTER);
- }
-
- fd = file_handle->fd;
-
- if(!(file_handle->fileaccess & GENERIC_READ) &&
- !(file_handle->fileaccess & GENERIC_WRITE) &&
- !(file_handle->fileaccess & GENERIC_ALL)) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
-
- SetLastError (ERROR_ACCESS_DENIED);
- return(INVALID_SET_FILE_POINTER);
- }
-
- switch(method) {
- case FILE_BEGIN:
- whence=SEEK_SET;
- break;
- case FILE_CURRENT:
- whence=SEEK_CUR;
- break;
- case FILE_END:
- whence=SEEK_END;
- break;
- default:
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: invalid seek type %d", __func__, method);
-
- SetLastError (ERROR_INVALID_PARAMETER);
- return(INVALID_SET_FILE_POINTER);
- }
-
-#ifdef HAVE_LARGE_FILE_SUPPORT
- if(highmovedistance==NULL) {
- offset=movedistance;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setting offset to %lld (low %d)", __func__,
- offset, movedistance);
- } else {
- offset=((gint64) *highmovedistance << 32) | (guint32)movedistance;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setting offset to %lld 0x%llx (high %d 0x%x, low %d 0x%x)", __func__, offset, offset, *highmovedistance, *highmovedistance, movedistance, movedistance);
- }
-#else
- offset=movedistance;
-#endif
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: moving handle %p by %lld bytes from %d", __func__,
- handle, (long long)offset, whence);
-
-#ifdef PLATFORM_ANDROID
- /* bionic doesn't support -D_FILE_OFFSET_BITS=64 */
- newpos=lseek64(fd, offset, whence);
-#else
- newpos=lseek(fd, offset, whence);
-#endif
- if(newpos==-1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: lseek on handle %p returned error %s",
- __func__, handle, strerror(errno));
-
- _wapi_set_last_error_from_errno ();
- return(INVALID_SET_FILE_POINTER);
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: lseek returns %lld", __func__, newpos);
-
-#ifdef HAVE_LARGE_FILE_SUPPORT
- ret=newpos & 0xFFFFFFFF;
- if(highmovedistance!=NULL) {
- *highmovedistance=newpos>>32;
- }
-#else
- ret=newpos;
- if(highmovedistance!=NULL) {
- /* Accurate, but potentially dodgy :-) */
- *highmovedistance=0;
- }
-#endif
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: move of handle %p returning %d/%d", __func__,
- handle, ret, highmovedistance==NULL?0:*highmovedistance);
-
- return(ret);
-}
-
-static gboolean file_setendoffile(gpointer handle)
-{
- struct _WapiHandle_file *file_handle;
- gboolean ok;
- struct stat statbuf;
- off_t pos;
- int ret, fd;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
- (gpointer *)&file_handle);
- if(ok==FALSE) {
- g_warning ("%s: error looking up file handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
- fd = file_handle->fd;
-
- if(!(file_handle->fileaccess & GENERIC_WRITE) &&
- !(file_handle->fileaccess & GENERIC_ALL)) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
-
- SetLastError (ERROR_ACCESS_DENIED);
- return(FALSE);
- }
-
- /* Find the current file position, and the file length. If
- * the file position is greater than the length, write to
- * extend the file with a hole. If the file position is less
- * than the length, truncate the file.
- */
-
- ret=fstat(fd, &statbuf);
- if(ret==-1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__,
- handle, strerror(errno));
-
- _wapi_set_last_error_from_errno ();
- return(FALSE);
- }
-
- pos=lseek(fd, (off_t)0, SEEK_CUR);
- if(pos==-1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p lseek failed: %s", __func__,
- handle, strerror(errno));
-
- _wapi_set_last_error_from_errno ();
- return(FALSE);
- }
-
-#ifdef FTRUNCATE_DOESNT_EXTEND
- off_t size = statbuf.st_size;
- /* I haven't bothered to write the configure.ac stuff for this
- * because I don't know if any platform needs it. I'm leaving
- * this code just in case though
- */
- if(pos>size) {
- /* Extend the file. Use write() here, because some
- * manuals say that ftruncate() behaviour is undefined
- * when the file needs extending. The POSIX spec says
- * that on XSI-conformant systems it extends, so if
- * every system we care about conforms, then we can
- * drop this write.
- */
- do {
- ret = write (fd, "", 1);
- } while (ret == -1 && errno == EINTR &&
- !mono_thread_info_is_interrupt_state (info));
-
- if(ret==-1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p extend write failed: %s", __func__, handle, strerror(errno));
-
- _wapi_set_last_error_from_errno ();
- return(FALSE);
- }
-
- /* And put the file position back after the write */
- ret = lseek (fd, pos, SEEK_SET);
- if (ret == -1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p second lseek failed: %s",
- __func__, handle, strerror(errno));
-
- _wapi_set_last_error_from_errno ();
- return(FALSE);
- }
- }
-#endif
-
-/* Native Client has no ftruncate function, even in standalone sel_ldr. */
-#ifndef __native_client__
- /* always truncate, because the extend write() adds an extra
- * byte to the end of the file
- */
- do {
- ret=ftruncate(fd, pos);
- }
- while (ret==-1 && errno==EINTR && !mono_thread_info_is_interrupt_state (info));
- if(ret==-1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p ftruncate failed: %s", __func__,
- handle, strerror(errno));
-
- _wapi_set_last_error_from_errno ();
- return(FALSE);
- }
-#endif
-
- return(TRUE);
-}
-
-static guint32 file_getfilesize(gpointer handle, guint32 *highsize)
-{
- struct _WapiHandle_file *file_handle;
- gboolean ok;
- struct stat statbuf;
- guint32 size;
- int ret;
- int fd;
-
- ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
- (gpointer *)&file_handle);
- if(ok==FALSE) {
- g_warning ("%s: error looking up file handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(INVALID_FILE_SIZE);
- }
- fd = file_handle->fd;
-
- if(!(file_handle->fileaccess & GENERIC_READ) &&
- !(file_handle->fileaccess & GENERIC_WRITE) &&
- !(file_handle->fileaccess & GENERIC_ALL)) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
-
- SetLastError (ERROR_ACCESS_DENIED);
- return(INVALID_FILE_SIZE);
- }
-
- /* If the file has a size with the low bits 0xFFFFFFFF the
- * caller can't tell if this is an error, so clear the error
- * value
- */
- SetLastError (ERROR_SUCCESS);
-
- ret = fstat(fd, &statbuf);
- if (ret == -1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__,
- handle, strerror(errno));
-
- _wapi_set_last_error_from_errno ();
- return(INVALID_FILE_SIZE);
- }
-
- /* fstat indicates block devices as zero-length, so go a different path */
-#ifdef BLKGETSIZE64
- if (S_ISBLK(statbuf.st_mode)) {
- guint64 bigsize;
- if (ioctl(fd, BLKGETSIZE64, &bigsize) < 0) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p ioctl BLKGETSIZE64 failed: %s",
- __func__, handle, strerror(errno));
-
- _wapi_set_last_error_from_errno ();
- return(INVALID_FILE_SIZE);
- }
-
- size = bigsize & 0xFFFFFFFF;
- if (highsize != NULL) {
- *highsize = bigsize>>32;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning block device size %d/%d",
- __func__, size, *highsize);
-
- return(size);
- }
-#endif
-
-#ifdef HAVE_LARGE_FILE_SUPPORT
- size = statbuf.st_size & 0xFFFFFFFF;
- if (highsize != NULL) {
- *highsize = statbuf.st_size>>32;
- }
-#else
- if (highsize != NULL) {
- /* Accurate, but potentially dodgy :-) */
- *highsize = 0;
- }
- size = statbuf.st_size;
-#endif
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning size %d/%d", __func__, size, *highsize);
-
- return(size);
-}
-
-static gboolean file_getfiletime(gpointer handle, WapiFileTime *create_time,
- WapiFileTime *last_access,
- WapiFileTime *last_write)
-{
- struct _WapiHandle_file *file_handle;
- gboolean ok;
- struct stat statbuf;
- guint64 create_ticks, access_ticks, write_ticks;
- int ret, fd;
-
- ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
- (gpointer *)&file_handle);
- if(ok==FALSE) {
- g_warning ("%s: error looking up file handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
- fd = file_handle->fd;
-
- if(!(file_handle->fileaccess & GENERIC_READ) &&
- !(file_handle->fileaccess & GENERIC_ALL)) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
- __func__, handle, file_handle->fileaccess);
-
- SetLastError (ERROR_ACCESS_DENIED);
- return(FALSE);
- }
-
- ret=fstat(fd, &statbuf);
- if(ret==-1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__, handle,
- strerror(errno));
-
- _wapi_set_last_error_from_errno ();
- return(FALSE);
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: atime: %ld ctime: %ld mtime: %ld", __func__,
- statbuf.st_atime, statbuf.st_ctime,
- statbuf.st_mtime);
-
- /* Try and guess a meaningful create time by using the older
- * of atime or ctime
- */
- /* The magic constant comes from msdn documentation
- * "Converting a time_t Value to a File Time"
- */
- if(statbuf.st_atime < statbuf.st_ctime) {
- create_ticks=((guint64)statbuf.st_atime*10000000)
- + 116444736000000000ULL;
- } else {
- create_ticks=((guint64)statbuf.st_ctime*10000000)
- + 116444736000000000ULL;
- }
-
- access_ticks=((guint64)statbuf.st_atime*10000000)+116444736000000000ULL;
- write_ticks=((guint64)statbuf.st_mtime*10000000)+116444736000000000ULL;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: aticks: %llu cticks: %llu wticks: %llu", __func__,
- access_ticks, create_ticks, write_ticks);
-
- if(create_time!=NULL) {
- create_time->dwLowDateTime = create_ticks & 0xFFFFFFFF;
- create_time->dwHighDateTime = create_ticks >> 32;
- }
-
- if(last_access!=NULL) {
- last_access->dwLowDateTime = access_ticks & 0xFFFFFFFF;
- last_access->dwHighDateTime = access_ticks >> 32;
- }
-
- if(last_write!=NULL) {
- last_write->dwLowDateTime = write_ticks & 0xFFFFFFFF;
- last_write->dwHighDateTime = write_ticks >> 32;
- }
-
- return(TRUE);
-}
-
-static gboolean file_setfiletime(gpointer handle,
- const WapiFileTime *create_time G_GNUC_UNUSED,
- const WapiFileTime *last_access,
- const WapiFileTime *last_write)
-{
- struct _WapiHandle_file *file_handle;
- gboolean ok;
- struct utimbuf utbuf;
- struct stat statbuf;
- guint64 access_ticks, write_ticks;
- int ret, fd;
-
- ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
- (gpointer *)&file_handle);
- if(ok==FALSE) {
- g_warning ("%s: error looking up file handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
- fd = file_handle->fd;
-
- if(!(file_handle->fileaccess & GENERIC_WRITE) &&
- !(file_handle->fileaccess & GENERIC_ALL)) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
-
- SetLastError (ERROR_ACCESS_DENIED);
- return(FALSE);
- }
-
- if(file_handle->filename == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p unknown filename", __func__, handle);
-
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- /* Get the current times, so we can put the same times back in
- * the event that one of the FileTime structs is NULL
- */
- ret=fstat (fd, &statbuf);
- if(ret==-1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__, handle,
- strerror(errno));
-
- SetLastError (ERROR_INVALID_PARAMETER);
- return(FALSE);
- }
-
- if(last_access!=NULL) {
- access_ticks=((guint64)last_access->dwHighDateTime << 32) +
- last_access->dwLowDateTime;
- /* This is (time_t)0. We can actually go to INT_MIN,
- * but this will do for now.
- */
- if (access_ticks < 116444736000000000ULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt to set access time too early",
- __func__);
- SetLastError (ERROR_INVALID_PARAMETER);
- return(FALSE);
- }
-
- if (sizeof (utbuf.actime) == 4 && ((access_ticks - 116444736000000000ULL) / 10000000) > INT_MAX) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt to set write time that is too big for a 32bits time_t",
- __func__);
- SetLastError (ERROR_INVALID_PARAMETER);
- return(FALSE);
- }
-
- utbuf.actime=(access_ticks - 116444736000000000ULL) / 10000000;
- } else {
- utbuf.actime=statbuf.st_atime;
- }
-
- if(last_write!=NULL) {
- write_ticks=((guint64)last_write->dwHighDateTime << 32) +
- last_write->dwLowDateTime;
- /* This is (time_t)0. We can actually go to INT_MIN,
- * but this will do for now.
- */
- if (write_ticks < 116444736000000000ULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt to set write time too early",
- __func__);
- SetLastError (ERROR_INVALID_PARAMETER);
- return(FALSE);
- }
- if (sizeof (utbuf.modtime) == 4 && ((write_ticks - 116444736000000000ULL) / 10000000) > INT_MAX) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt to set write time that is too big for a 32bits time_t",
- __func__);
- SetLastError (ERROR_INVALID_PARAMETER);
- return(FALSE);
- }
-
- utbuf.modtime=(write_ticks - 116444736000000000ULL) / 10000000;
- } else {
- utbuf.modtime=statbuf.st_mtime;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setting handle %p access %ld write %ld", __func__,
- handle, utbuf.actime, utbuf.modtime);
-
- ret = _wapi_utime (file_handle->filename, &utbuf);
- if (ret == -1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p [%s] utime failed: %s", __func__,
- handle, file_handle->filename, strerror(errno));
-
- SetLastError (ERROR_INVALID_PARAMETER);
- return(FALSE);
- }
-
- return(TRUE);
-}
-
-static void console_close (gpointer handle, gpointer data)
-{
- struct _WapiHandle_file *console_handle = (struct _WapiHandle_file *)data;
- int fd = console_handle->fd;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing console handle %p", __func__, handle);
-
- g_free (console_handle->filename);
-
- if (fd > 2) {
- if (console_handle->share_info)
- _wapi_handle_share_release (console_handle->share_info);
- close (fd);
- }
-}
-
-static void console_details (gpointer data)
-{
- file_details (data);
-}
-
-static const gchar* console_typename (void)
-{
- return "Console";
-}
-
-static gsize console_typesize (void)
-{
- return sizeof (struct _WapiHandle_file);
-}
-
-static WapiFileType console_getfiletype(void)
-{
- return(FILE_TYPE_CHAR);
-}
-
-static gboolean console_read(gpointer handle, gpointer buffer,
- guint32 numbytes, guint32 *bytesread,
- WapiOverlapped *overlapped G_GNUC_UNUSED)
-{
- struct _WapiHandle_file *console_handle;
- gboolean ok;
- int ret, fd;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_CONSOLE,
- (gpointer *)&console_handle);
- if(ok==FALSE) {
- g_warning ("%s: error looking up console handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
- fd = console_handle->fd;
-
- if(bytesread!=NULL) {
- *bytesread=0;
- }
-
- if(!(console_handle->fileaccess & GENERIC_READ) &&
- !(console_handle->fileaccess & GENERIC_ALL)) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
- __func__, handle, console_handle->fileaccess);
-
- SetLastError (ERROR_ACCESS_DENIED);
- return(FALSE);
- }
-
- do {
- ret=read(fd, buffer, numbytes);
- } while (ret==-1 && errno==EINTR && !mono_thread_info_is_interrupt_state (info));
-
- if(ret==-1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read of handle %p error: %s", __func__, handle,
- strerror(errno));
-
- _wapi_set_last_error_from_errno ();
- return(FALSE);
- }
-
- if(bytesread!=NULL) {
- *bytesread=ret;
- }
-
- return(TRUE);
-}
-
-static gboolean console_write(gpointer handle, gconstpointer buffer,
- guint32 numbytes, guint32 *byteswritten,
- WapiOverlapped *overlapped G_GNUC_UNUSED)
-{
- struct _WapiHandle_file *console_handle;
- gboolean ok;
- int ret, fd;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_CONSOLE,
- (gpointer *)&console_handle);
- if(ok==FALSE) {
- g_warning ("%s: error looking up console handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
- fd = console_handle->fd;
-
- if(byteswritten!=NULL) {
- *byteswritten=0;
- }
-
- if(!(console_handle->fileaccess & GENERIC_WRITE) &&
- !(console_handle->fileaccess & GENERIC_ALL)) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, console_handle->fileaccess);
-
- SetLastError (ERROR_ACCESS_DENIED);
- return(FALSE);
- }
-
- do {
- ret = write(fd, buffer, numbytes);
- } while (ret == -1 && errno == EINTR &&
- !mono_thread_info_is_interrupt_state (info));
-
- if (ret == -1) {
- if (errno == EINTR) {
- ret = 0;
- } else {
- _wapi_set_last_error_from_errno ();
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write of handle %p error: %s",
- __func__, handle, strerror(errno));
-
- return(FALSE);
- }
- }
- if(byteswritten!=NULL) {
- *byteswritten=ret;
- }
-
- return(TRUE);
-}
-
-static const gchar* find_typename (void)
-{
- return "Find";
-}
-
-static gsize find_typesize (void)
-{
- return sizeof (struct _WapiHandle_find);
-}
-
-static void pipe_close (gpointer handle, gpointer data)
-{
- struct _WapiHandle_file *pipe_handle = (struct _WapiHandle_file*)data;
- int fd = pipe_handle->fd;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing pipe handle %p fd %d", __func__, handle, fd);
-
- /* No filename with pipe handles */
-
- if (pipe_handle->share_info)
- _wapi_handle_share_release (pipe_handle->share_info);
-
- close (fd);
-}
-
-static void pipe_details (gpointer data)
-{
- file_details (data);
-}
-
-static const gchar* pipe_typename (void)
-{
- return "Pipe";
-}
-
-static gsize pipe_typesize (void)
-{
- return sizeof (struct _WapiHandle_file);
-}
-
-static WapiFileType pipe_getfiletype(void)
-{
- return(FILE_TYPE_PIPE);
-}
-
-static gboolean pipe_read (gpointer handle, gpointer buffer,
- guint32 numbytes, guint32 *bytesread,
- WapiOverlapped *overlapped G_GNUC_UNUSED)
-{
- struct _WapiHandle_file *pipe_handle;
- gboolean ok;
- int ret, fd;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_PIPE,
- (gpointer *)&pipe_handle);
- if(ok==FALSE) {
- g_warning ("%s: error looking up pipe handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
- fd = pipe_handle->fd;
-
- if(bytesread!=NULL) {
- *bytesread=0;
- }
-
- if(!(pipe_handle->fileaccess & GENERIC_READ) &&
- !(pipe_handle->fileaccess & GENERIC_ALL)) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
- __func__, handle, pipe_handle->fileaccess);
-
- SetLastError (ERROR_ACCESS_DENIED);
- return(FALSE);
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: reading up to %d bytes from pipe %p", __func__,
- numbytes, handle);
-
- do {
- ret=read(fd, buffer, numbytes);
- } while (ret==-1 && errno==EINTR && !mono_thread_info_is_interrupt_state (info));
-
- if (ret == -1) {
- if (errno == EINTR) {
- ret = 0;
- } else {
- _wapi_set_last_error_from_errno ();
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read of handle %p error: %s", __func__,
- handle, strerror(errno));
-
- return(FALSE);
- }
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read %d bytes from pipe %p", __func__, ret, handle);
-
- if(bytesread!=NULL) {
- *bytesread=ret;
- }
-
- return(TRUE);
-}
-
-static gboolean pipe_write(gpointer handle, gconstpointer buffer,
- guint32 numbytes, guint32 *byteswritten,
- WapiOverlapped *overlapped G_GNUC_UNUSED)
-{
- struct _WapiHandle_file *pipe_handle;
- gboolean ok;
- int ret, fd;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_PIPE,
- (gpointer *)&pipe_handle);
- if(ok==FALSE) {
- g_warning ("%s: error looking up pipe handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
- fd = pipe_handle->fd;
-
- if(byteswritten!=NULL) {
- *byteswritten=0;
- }
-
- if(!(pipe_handle->fileaccess & GENERIC_WRITE) &&
- !(pipe_handle->fileaccess & GENERIC_ALL)) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, pipe_handle->fileaccess);
-
- SetLastError (ERROR_ACCESS_DENIED);
- return(FALSE);
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: writing up to %d bytes to pipe %p", __func__, numbytes,
- handle);
-
- do {
- ret = write (fd, buffer, numbytes);
- } while (ret == -1 && errno == EINTR &&
- !mono_thread_info_is_interrupt_state (info));
-
- if (ret == -1) {
- if (errno == EINTR) {
- ret = 0;
- } else {
- _wapi_set_last_error_from_errno ();
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write of handle %p error: %s", __func__,
- handle, strerror(errno));
-
- return(FALSE);
- }
- }
- if(byteswritten!=NULL) {
- *byteswritten=ret;
- }
-
- return(TRUE);
-}
-
-static int convert_flags(guint32 fileaccess, guint32 createmode)
-{
- int flags=0;
-
- switch(fileaccess) {
- case GENERIC_READ:
- flags=O_RDONLY;
- break;
- case GENERIC_WRITE:
- flags=O_WRONLY;
- break;
- case GENERIC_READ|GENERIC_WRITE:
- flags=O_RDWR;
- break;
- default:
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unknown access type 0x%x", __func__,
- fileaccess);
- break;
- }
-
- switch(createmode) {
- case CREATE_NEW:
- flags|=O_CREAT|O_EXCL;
- break;
- case CREATE_ALWAYS:
- flags|=O_CREAT|O_TRUNC;
- break;
- case OPEN_EXISTING:
- break;
- case OPEN_ALWAYS:
- flags|=O_CREAT;
- break;
- case TRUNCATE_EXISTING:
- flags|=O_TRUNC;
- break;
- default:
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unknown create mode 0x%x", __func__,
- createmode);
- break;
- }
-
- return(flags);
-}
-
-#if 0 /* unused */
-static mode_t convert_perms(guint32 sharemode)
-{
- mode_t perms=0600;
-
- if(sharemode&FILE_SHARE_READ) {
- perms|=044;
- }
- if(sharemode&FILE_SHARE_WRITE) {
- perms|=022;
- }
-
- return(perms);
-}
-#endif
-
-static gboolean share_allows_open (struct stat *statbuf, guint32 sharemode,
- guint32 fileaccess,
- struct _WapiFileShare **share_info)
-{
- gboolean file_already_shared;
- guint32 file_existing_share, file_existing_access;
-
- file_already_shared = _wapi_handle_get_or_set_share (statbuf->st_dev, statbuf->st_ino, sharemode, fileaccess, &file_existing_share, &file_existing_access, share_info);
-
- if (file_already_shared) {
- /* The reference to this share info was incremented
- * when we looked it up, so be careful to put it back
- * if we conclude we can't use this file.
- */
- if (file_existing_share == 0) {
- /* Quick and easy, no possibility to share */
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing = NONE", __func__, fileaccess);
-
- _wapi_handle_share_release (*share_info);
-
- return(FALSE);
- }
-
- if (((file_existing_share == FILE_SHARE_READ) &&
- (fileaccess != GENERIC_READ)) ||
- ((file_existing_share == FILE_SHARE_WRITE) &&
- (fileaccess != GENERIC_WRITE))) {
- /* New access mode doesn't match up */
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing: 0x%x", __func__, fileaccess, file_existing_share);
-
- _wapi_handle_share_release (*share_info);
-
- return(FALSE);
- }
-
- if (((file_existing_access & GENERIC_READ) &&
- !(sharemode & FILE_SHARE_READ)) ||
- ((file_existing_access & GENERIC_WRITE) &&
- !(sharemode & FILE_SHARE_WRITE))) {
- /* New share mode doesn't match up */
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Access mode prevents open: requested share: 0x%x, file has access: 0x%x", __func__, sharemode, file_existing_access);
-
- _wapi_handle_share_release (*share_info);
-
- return(FALSE);
- }
- } else {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: New file!", __func__);
- }
-
- return(TRUE);
-}
-
-
-static gboolean
-share_allows_delete (struct stat *statbuf, struct _WapiFileShare **share_info)
-{
- gboolean file_already_shared;
- guint32 file_existing_share, file_existing_access;
-
- file_already_shared = _wapi_handle_get_or_set_share (statbuf->st_dev, statbuf->st_ino, FILE_SHARE_DELETE, GENERIC_READ, &file_existing_share, &file_existing_access, share_info);
-
- if (file_already_shared) {
- /* The reference to this share info was incremented
- * when we looked it up, so be careful to put it back
- * if we conclude we can't use this file.
- */
- if (file_existing_share == 0) {
- /* Quick and easy, no possibility to share */
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing = NONE", __func__, (*share_info)->access);
-
- _wapi_handle_share_release (*share_info);
-
- return(FALSE);
- }
-
- if (!(file_existing_share & FILE_SHARE_DELETE)) {
- /* New access mode doesn't match up */
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing: 0x%x", __func__, (*share_info)->access, file_existing_share);
-
- _wapi_handle_share_release (*share_info);
-
- return(FALSE);
- }
- } else {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: New file!", __func__);
- }
-
- return(TRUE);
-}
-
-/**
- * CreateFile:
- * @name: a pointer to a NULL-terminated unicode string, that names
- * the file or other object to create.
- * @fileaccess: specifies the file access mode
- * @sharemode: whether the file should be shared. This parameter is
- * currently ignored.
- * @security: Ignored for now.
- * @createmode: specifies whether to create a new file, whether to
- * overwrite an existing file, whether to truncate the file, etc.
- * @attrs: specifies file attributes and flags. On win32 attributes
- * are characteristics of the file, not the handle, and are ignored
- * when an existing file is opened. Flags give the library hints on
- * how to process a file to optimise performance.
- * @template: the handle of an open %GENERIC_READ file that specifies
- * attributes to apply to a newly created file, ignoring @attrs.
- * Normally this parameter is NULL. This parameter is ignored when an
- * existing file is opened.
- *
- * Creates a new file handle. This only applies to normal files:
- * pipes are handled by CreatePipe(), and console handles are created
- * with GetStdHandle().
- *
- * Return value: the new handle, or %INVALID_HANDLE_VALUE on error.
- */
-gpointer CreateFile(const gunichar2 *name, guint32 fileaccess,
- guint32 sharemode, WapiSecurityAttributes *security,
- guint32 createmode, guint32 attrs,
- gpointer template_ G_GNUC_UNUSED)
-{
- struct _WapiHandle_file file_handle = {0};
- gpointer handle;
- int flags=convert_flags(fileaccess, createmode);
- /*mode_t perms=convert_perms(sharemode);*/
- /* we don't use sharemode, because that relates to sharing of
- * the file when the file is open and is already handled by
- * other code, perms instead are the on-disk permissions and
- * this is a sane default.
- */
- mode_t perms=0666;
- gchar *filename;
- int fd, ret;
- MonoW32HandleType handle_type;
- struct stat statbuf;
-
- if (attrs & FILE_ATTRIBUTE_TEMPORARY)
- perms = 0600;
-
- if (attrs & FILE_ATTRIBUTE_ENCRYPTED){
- SetLastError (ERROR_ENCRYPTION_FAILED);
- return INVALID_HANDLE_VALUE;
- }
-
- if (name == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return(INVALID_HANDLE_VALUE);
- }
-
- filename = mono_unicode_to_external (name);
- if (filename == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return(INVALID_HANDLE_VALUE);
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening %s with share 0x%x and access 0x%x", __func__,
- filename, sharemode, fileaccess);
-
- fd = _wapi_open (filename, flags, perms);
-
- /* If we were trying to open a directory with write permissions
- * (e.g. O_WRONLY or O_RDWR), this call will fail with
- * EISDIR. However, this is a bit bogus because calls to
- * manipulate the directory (e.g. SetFileTime) will still work on
- * the directory because they use other API calls
- * (e.g. utime()). Hence, if we failed with the EISDIR error, try
- * to open the directory again without write permission.
- */
- if (fd == -1 && errno == EISDIR)
- {
- /* Try again but don't try to make it writable */
- fd = _wapi_open (filename, flags & ~(O_RDWR|O_WRONLY), perms);
- }
-
- if (fd == -1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error opening file %s: %s", __func__, filename,
- strerror(errno));
- _wapi_set_last_path_error_from_errno (NULL, filename);
- g_free (filename);
-
- return(INVALID_HANDLE_VALUE);
- }
-
- if (fd >= mono_w32handle_fd_reserve) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big", __func__);
-
- SetLastError (ERROR_TOO_MANY_OPEN_FILES);
-
- close (fd);
- g_free (filename);
-
- return(INVALID_HANDLE_VALUE);
- }
-
- ret = fstat (fd, &statbuf);
- if (ret == -1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fstat error of file %s: %s", __func__,
- filename, strerror (errno));
- _wapi_set_last_error_from_errno ();
- g_free (filename);
- close (fd);
-
- return(INVALID_HANDLE_VALUE);
- }
-#ifdef __native_client__
- /* Workaround: Native Client currently returns the same fake inode
- * for all files, so do a simple hash on the filename so we don't
- * use the same share info for each file.
- */
- statbuf.st_ino = g_str_hash(filename);
-#endif
-
- if (share_allows_open (&statbuf, sharemode, fileaccess,
- &file_handle.share_info) == FALSE) {
- SetLastError (ERROR_SHARING_VIOLATION);
- g_free (filename);
- close (fd);
-
- return (INVALID_HANDLE_VALUE);
- }
- if (file_handle.share_info == NULL) {
- /* No space, so no more files can be opened */
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: No space in the share table", __func__);
-
- SetLastError (ERROR_TOO_MANY_OPEN_FILES);
- close (fd);
- g_free (filename);
-
- return(INVALID_HANDLE_VALUE);
- }
-
- file_handle.filename = filename;
-
- if(security!=NULL) {
- //file_handle->security_attributes=_wapi_handle_scratch_store (
- //security, sizeof(WapiSecurityAttributes));
- }
-
- file_handle.fd = fd;
- file_handle.fileaccess=fileaccess;
- file_handle.sharemode=sharemode;
- file_handle.attrs=attrs;
-
-#ifdef HAVE_POSIX_FADVISE
- if (attrs & FILE_FLAG_SEQUENTIAL_SCAN)
- posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL);
- if (attrs & FILE_FLAG_RANDOM_ACCESS)
- posix_fadvise (fd, 0, 0, POSIX_FADV_RANDOM);
-#endif
-
-#ifdef F_RDAHEAD
- if (attrs & FILE_FLAG_SEQUENTIAL_SCAN)
- fcntl(fd, F_RDAHEAD, 1);
-#endif
-
-#ifndef S_ISFIFO
-#define S_ISFIFO(m) ((m & S_IFIFO) != 0)
-#endif
- if (S_ISFIFO (statbuf.st_mode)) {
- handle_type = MONO_W32HANDLE_PIPE;
- /* maintain invariant that pipes have no filename */
- file_handle.filename = NULL;
- g_free (filename);
- filename = NULL;
- } else if (S_ISCHR (statbuf.st_mode)) {
- handle_type = MONO_W32HANDLE_CONSOLE;
- } else {
- handle_type = MONO_W32HANDLE_FILE;
- }
-
- handle = mono_w32handle_new_fd (handle_type, fd, &file_handle);
- if (handle == INVALID_HANDLE_VALUE) {
- g_warning ("%s: error creating file handle", __func__);
- g_free (filename);
- close (fd);
-
- SetLastError (ERROR_GEN_FAILURE);
- return(INVALID_HANDLE_VALUE);
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning handle %p", __func__, handle);
-
- return(handle);
-}
-
-/**
- * DeleteFile:
- * @name: a pointer to a NULL-terminated unicode string, that names
- * the file to be deleted.
- *
- * Deletes file @name.
- *
- * Return value: %TRUE on success, %FALSE otherwise.
- */
-gboolean DeleteFile(const gunichar2 *name)
-{
- gchar *filename;
- int retval;
- gboolean ret = FALSE;
- guint32 attrs;
-#if 0
- struct stat statbuf;
- struct _WapiFileShare *shareinfo;
-#endif
-
- if(name==NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return(FALSE);
- }
-
- filename=mono_unicode_to_external(name);
- if(filename==NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return(FALSE);
- }
-
- attrs = GetFileAttributes (name);
- if (attrs == INVALID_FILE_ATTRIBUTES) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: file attributes error", __func__);
- /* Error set by GetFileAttributes() */
- g_free (filename);
- return(FALSE);
- }
-
-#if 0
- /* Check to make sure sharing allows us to open the file for
- * writing. See bug 323389.
- *
- * Do the checks that don't need an open file descriptor, for
- * simplicity's sake. If we really have to do the full checks
- * then we can implement that later.
- */
- if (_wapi_stat (filename, &statbuf) < 0) {
- _wapi_set_last_path_error_from_errno (NULL, filename);
- g_free (filename);
- return(FALSE);
- }
-
- if (share_allows_open (&statbuf, 0, GENERIC_WRITE,
- &shareinfo) == FALSE) {
- SetLastError (ERROR_SHARING_VIOLATION);
- g_free (filename);
- return FALSE;
- }
- if (shareinfo)
- _wapi_handle_share_release (shareinfo);
-#endif
-
- retval = _wapi_unlink (filename);
-
- if (retval == -1) {
- _wapi_set_last_path_error_from_errno (NULL, filename);
- } else {
- ret = TRUE;
- }
-
- g_free(filename);
-
- return(ret);
-}
-
-/**
- * MoveFile:
- * @name: a pointer to a NULL-terminated unicode string, that names
- * the file to be moved.
- * @dest_name: a pointer to a NULL-terminated unicode string, that is the
- * new name for the file.
- *
- * Renames file @name to @dest_name.
- * MoveFile sets ERROR_ALREADY_EXISTS if the destination exists, except
- * when it is the same file as the source. In that case it silently succeeds.
- *
- * Return value: %TRUE on success, %FALSE otherwise.
- */
-gboolean MoveFile (const gunichar2 *name, const gunichar2 *dest_name)
-{
- gchar *utf8_name, *utf8_dest_name;
- int result, errno_copy;
- struct stat stat_src, stat_dest;
- gboolean ret = FALSE;
- struct _WapiFileShare *shareinfo;
-
- if(name==NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return(FALSE);
- }
-
- utf8_name = mono_unicode_to_external (name);
- if (utf8_name == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return FALSE;
- }
-
- if(dest_name==NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
-
- g_free (utf8_name);
- SetLastError (ERROR_INVALID_NAME);
- return(FALSE);
- }
-
- utf8_dest_name = mono_unicode_to_external (dest_name);
- if (utf8_dest_name == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
-
- g_free (utf8_name);
- SetLastError (ERROR_INVALID_NAME);
- return FALSE;
- }
-
- /*
- * In C# land we check for the existence of src, but not for dest.
- * We check it here and return the failure if dest exists and is not
- * the same file as src.
- */
- if (_wapi_stat (utf8_name, &stat_src) < 0) {
- if (errno != ENOENT || _wapi_lstat (utf8_name, &stat_src) < 0) {
- _wapi_set_last_path_error_from_errno (NULL, utf8_name);
- g_free (utf8_name);
- g_free (utf8_dest_name);
- return FALSE;
- }
- }
-
- if (!_wapi_stat (utf8_dest_name, &stat_dest)) {
- if (stat_dest.st_dev != stat_src.st_dev ||
- stat_dest.st_ino != stat_src.st_ino) {
- g_free (utf8_name);
- g_free (utf8_dest_name);
- SetLastError (ERROR_ALREADY_EXISTS);
- return FALSE;
- }
- }
-
- /* Check to make that we have delete sharing permission.
- * See https://bugzilla.xamarin.com/show_bug.cgi?id=17009
- *
- * Do the checks that don't need an open file descriptor, for
- * simplicity's sake. If we really have to do the full checks
- * then we can implement that later.
- */
- if (share_allows_delete (&stat_src, &shareinfo) == FALSE) {
- SetLastError (ERROR_SHARING_VIOLATION);
- return FALSE;
- }
- if (shareinfo)
- _wapi_handle_share_release (shareinfo);
-
- result = _wapi_rename (utf8_name, utf8_dest_name);
- errno_copy = errno;
-
- if (result == -1) {
- switch(errno_copy) {
- case EEXIST:
- SetLastError (ERROR_ALREADY_EXISTS);
- break;
-
- case EXDEV:
- /* Ignore here, it is dealt with below */
- break;
-
- case ENOENT:
- /* We already know src exists. Must be dest that doesn't exist. */
- _wapi_set_last_path_error_from_errno (NULL, utf8_dest_name);
- break;
-
- default:
- _wapi_set_last_error_from_errno ();
- }
- }
-
- g_free (utf8_name);
- g_free (utf8_dest_name);
-
- if (result != 0 && errno_copy == EXDEV) {
- if (S_ISDIR (stat_src.st_mode)) {
- SetLastError (ERROR_NOT_SAME_DEVICE);
- return FALSE;
- }
- /* Try a copy to the new location, and delete the source */
- if (CopyFile (name, dest_name, TRUE)==FALSE) {
- /* CopyFile will set the error */
- return(FALSE);
- }
-
- return(DeleteFile (name));
- }
-
- if (result == 0) {
- ret = TRUE;
- }
-
- return(ret);
-}
-
-static gboolean
-write_file (int src_fd, int dest_fd, struct stat *st_src, gboolean report_errors)
-{
- int remain, n;
- char *buf, *wbuf;
- int buf_size = st_src->st_blksize;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- buf_size = buf_size < 8192 ? 8192 : (buf_size > 65536 ? 65536 : buf_size);
- buf = (char *) g_malloc (buf_size);
-
- for (;;) {
- remain = read (src_fd, buf, buf_size);
- if (remain < 0) {
- if (errno == EINTR && !mono_thread_info_is_interrupt_state (info))
- continue;
-
- if (report_errors)
- _wapi_set_last_error_from_errno ();
-
- g_free (buf);
- return FALSE;
- }
- if (remain == 0) {
- break;
- }
-
- wbuf = buf;
- while (remain > 0) {
- if ((n = write (dest_fd, wbuf, remain)) < 0) {
- if (errno == EINTR && !mono_thread_info_is_interrupt_state (info))
- continue;
-
- if (report_errors)
- _wapi_set_last_error_from_errno ();
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write failed.", __func__);
- g_free (buf);
- return FALSE;
- }
-
- remain -= n;
- wbuf += n;
- }
- }
-
- g_free (buf);
- return TRUE ;
-}
-
-/**
- * CopyFile:
- * @name: a pointer to a NULL-terminated unicode string, that names
- * the file to be copied.
- * @dest_name: a pointer to a NULL-terminated unicode string, that is the
- * new name for the file.
- * @fail_if_exists: if TRUE and dest_name exists, the copy will fail.
- *
- * Copies file @name to @dest_name
- *
- * Return value: %TRUE on success, %FALSE otherwise.
- */
-gboolean CopyFile (const gunichar2 *name, const gunichar2 *dest_name,
- gboolean fail_if_exists)
-{
- gchar *utf8_src, *utf8_dest;
- int src_fd, dest_fd;
- struct stat st, dest_st;
- struct utimbuf dest_time;
- gboolean ret = TRUE;
- int ret_utime;
-
- if(name==NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return(FALSE);
- }
-
- utf8_src = mono_unicode_to_external (name);
- if (utf8_src == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion of source returned NULL",
- __func__);
-
- SetLastError (ERROR_INVALID_PARAMETER);
- return(FALSE);
- }
-
- if(dest_name==NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: dest is NULL", __func__);
-
- g_free (utf8_src);
- SetLastError (ERROR_INVALID_NAME);
- return(FALSE);
- }
-
- utf8_dest = mono_unicode_to_external (dest_name);
- if (utf8_dest == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion of dest returned NULL",
- __func__);
-
- SetLastError (ERROR_INVALID_PARAMETER);
-
- g_free (utf8_src);
-
- return(FALSE);
- }
-
- src_fd = _wapi_open (utf8_src, O_RDONLY, 0);
- if (src_fd < 0) {
- _wapi_set_last_path_error_from_errno (NULL, utf8_src);
-
- g_free (utf8_src);
- g_free (utf8_dest);
-
- return(FALSE);
- }
-
- if (fstat (src_fd, &st) < 0) {
- _wapi_set_last_error_from_errno ();
-
- g_free (utf8_src);
- g_free (utf8_dest);
- close (src_fd);
-
- return(FALSE);
- }
-
- /* Before trying to open/create the dest, we need to report a 'file busy'
- * error if src and dest are actually the same file. We do the check here to take
- * advantage of the IOMAP capability */
- if (!_wapi_stat (utf8_dest, &dest_st) && st.st_dev == dest_st.st_dev &&
- st.st_ino == dest_st.st_ino) {
-
- g_free (utf8_src);
- g_free (utf8_dest);
- close (src_fd);
-
- SetLastError (ERROR_SHARING_VIOLATION);
- return (FALSE);
- }
-
- if (fail_if_exists) {
- dest_fd = _wapi_open (utf8_dest, O_WRONLY | O_CREAT | O_EXCL, st.st_mode);
- } else {
- /* FIXME: it kinda sucks that this code path potentially scans
- * the directory twice due to the weird SetLastError()
- * behavior. */
- dest_fd = _wapi_open (utf8_dest, O_WRONLY | O_TRUNC, st.st_mode);
- if (dest_fd < 0) {
- /* The file does not exist, try creating it */
- dest_fd = _wapi_open (utf8_dest, O_WRONLY | O_CREAT | O_TRUNC, st.st_mode);
- } else {
- /* Apparently this error is set if we
- * overwrite the dest file
- */
- SetLastError (ERROR_ALREADY_EXISTS);
- }
- }
- if (dest_fd < 0) {
- _wapi_set_last_error_from_errno ();
-
- g_free (utf8_src);
- g_free (utf8_dest);
- close (src_fd);
-
- return(FALSE);
- }
-
- if (!write_file (src_fd, dest_fd, &st, TRUE))
- ret = FALSE;
-
- close (src_fd);
- close (dest_fd);
-
- dest_time.modtime = st.st_mtime;
- dest_time.actime = st.st_atime;
- ret_utime = utime (utf8_dest, &dest_time);
- if (ret_utime == -1)
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: file [%s] utime failed: %s", __func__, utf8_dest, strerror(errno));
-
- g_free (utf8_src);
- g_free (utf8_dest);
-
- return ret;
-}
-
-static gchar*
-convert_arg_to_utf8 (const gunichar2 *arg, const gchar *arg_name)
-{
- gchar *utf8_ret;
-
- if (arg == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %s is NULL", __func__, arg_name);
- SetLastError (ERROR_INVALID_NAME);
- return NULL;
- }
-
- utf8_ret = mono_unicode_to_external (arg);
- if (utf8_ret == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion of %s returned NULL",
- __func__, arg_name);
- SetLastError (ERROR_INVALID_PARAMETER);
- return NULL;
- }
-
- return utf8_ret;
-}
-
-gboolean
-ReplaceFile (const gunichar2 *replacedFileName, const gunichar2 *replacementFileName,
- const gunichar2 *backupFileName, guint32 replaceFlags,
- gpointer exclude, gpointer reserved)
-{
- int result, backup_fd = -1,replaced_fd = -1;
- gchar *utf8_replacedFileName, *utf8_replacementFileName = NULL, *utf8_backupFileName = NULL;
- struct stat stBackup;
- gboolean ret = FALSE;
-
- if (!(utf8_replacedFileName = convert_arg_to_utf8 (replacedFileName, "replacedFileName")))
- return FALSE;
- if (!(utf8_replacementFileName = convert_arg_to_utf8 (replacementFileName, "replacementFileName")))
- goto replace_cleanup;
- if (backupFileName != NULL) {
- if (!(utf8_backupFileName = convert_arg_to_utf8 (backupFileName, "backupFileName")))
- goto replace_cleanup;
- }
-
- if (utf8_backupFileName) {
- // Open the backup file for read so we can restore the file if an error occurs.
- backup_fd = _wapi_open (utf8_backupFileName, O_RDONLY, 0);
- result = _wapi_rename (utf8_replacedFileName, utf8_backupFileName);
- if (result == -1)
- goto replace_cleanup;
- }
-
- result = _wapi_rename (utf8_replacementFileName, utf8_replacedFileName);
- if (result == -1) {
- _wapi_set_last_path_error_from_errno (NULL, utf8_replacementFileName);
- _wapi_rename (utf8_backupFileName, utf8_replacedFileName);
- if (backup_fd != -1 && !fstat (backup_fd, &stBackup)) {
- replaced_fd = _wapi_open (utf8_backupFileName, O_WRONLY | O_CREAT | O_TRUNC,
- stBackup.st_mode);
-
- if (replaced_fd == -1)
- goto replace_cleanup;
-
- write_file (backup_fd, replaced_fd, &stBackup, FALSE);
- }
-
- goto replace_cleanup;
- }
-
- ret = TRUE;
-
-replace_cleanup:
- g_free (utf8_replacedFileName);
- g_free (utf8_replacementFileName);
- g_free (utf8_backupFileName);
- if (backup_fd != -1)
- close (backup_fd);
- if (replaced_fd != -1)
- close (replaced_fd);
- return ret;
-}
-
-/**
- * GetStdHandle:
- * @stdhandle: specifies the file descriptor
- *
- * Returns a handle for stdin, stdout, or stderr. Always returns the
- * same handle for the same @stdhandle.
- *
- * Return value: the handle, or %INVALID_HANDLE_VALUE on error
- */
-
-static mono_mutex_t stdhandle_mutex;
-
-gpointer GetStdHandle(WapiStdHandle stdhandle)
-{
- struct _WapiHandle_file *file_handle;
- gpointer handle;
- int fd;
- const gchar *name;
- gboolean ok;
-
- switch(stdhandle) {
- case STD_INPUT_HANDLE:
- fd = 0;
- name = "<stdin>";
- break;
-
- case STD_OUTPUT_HANDLE:
- fd = 1;
- name = "<stdout>";
- break;
-
- case STD_ERROR_HANDLE:
- fd = 2;
- name = "<stderr>";
- break;
-
- default:
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unknown standard handle type", __func__);
-
- SetLastError (ERROR_INVALID_PARAMETER);
- return(INVALID_HANDLE_VALUE);
- }
-
- handle = GINT_TO_POINTER (fd);
-
- mono_os_mutex_lock (&stdhandle_mutex);
-
- ok = mono_w32handle_lookup (handle, MONO_W32HANDLE_CONSOLE,
- (gpointer *)&file_handle);
- if (ok == FALSE) {
- /* Need to create this console handle */
- handle = _wapi_stdhandle_create (fd, name);
-
- if (handle == INVALID_HANDLE_VALUE) {
- SetLastError (ERROR_NO_MORE_FILES);
- goto done;
- }
- } else {
- /* Add a reference to this handle */
- mono_w32handle_ref (handle);
- }
-
- done:
- mono_os_mutex_unlock (&stdhandle_mutex);
-
- return(handle);
-}
-
-/**
- * ReadFile:
- * @handle: The file handle to read from. The handle must have
- * %GENERIC_READ access.
- * @buffer: The buffer to store read data in
- * @numbytes: The maximum number of bytes to read
- * @bytesread: The actual number of bytes read is stored here. This
- * value can be zero if the handle is positioned at the end of the
- * file.
- * @overlapped: points to a required %WapiOverlapped structure if
- * @handle has the %FILE_FLAG_OVERLAPPED option set, should be NULL
- * otherwise.
- *
- * If @handle does not have the %FILE_FLAG_OVERLAPPED option set, this
- * function reads up to @numbytes bytes from the file from the current
- * file position, and stores them in @buffer. If there are not enough
- * bytes left in the file, just the amount available will be read.
- * The actual number of bytes read is stored in @bytesread.
-
- * If @handle has the %FILE_FLAG_OVERLAPPED option set, the current
- * file position is ignored and the read position is taken from data
- * in the @overlapped structure.
- *
- * Return value: %TRUE if the read succeeds (even if no bytes were
- * read due to an attempt to read past the end of the file), %FALSE on
- * error.
- */
-gboolean ReadFile(gpointer handle, gpointer buffer, guint32 numbytes,
- guint32 *bytesread, WapiOverlapped *overlapped)
-{
- MonoW32HandleType type;
-
- type = mono_w32handle_get_type (handle);
-
- if(io_ops[type].readfile==NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- return(io_ops[type].readfile (handle, buffer, numbytes, bytesread,
- overlapped));
-}
-
-/**
- * WriteFile:
- * @handle: The file handle to write to. The handle must have
- * %GENERIC_WRITE access.
- * @buffer: The buffer to read data from.
- * @numbytes: The maximum number of bytes to write.
- * @byteswritten: The actual number of bytes written is stored here.
- * If the handle is positioned at the file end, the length of the file
- * is extended. This parameter may be %NULL.
- * @overlapped: points to a required %WapiOverlapped structure if
- * @handle has the %FILE_FLAG_OVERLAPPED option set, should be NULL
- * otherwise.
- *
- * If @handle does not have the %FILE_FLAG_OVERLAPPED option set, this
- * function writes up to @numbytes bytes from @buffer to the file at
- * the current file position. If @handle is positioned at the end of
- * the file, the file is extended. The actual number of bytes written
- * is stored in @byteswritten.
- *
- * If @handle has the %FILE_FLAG_OVERLAPPED option set, the current
- * file position is ignored and the write position is taken from data
- * in the @overlapped structure.
- *
- * Return value: %TRUE if the write succeeds, %FALSE on error.
- */
-gboolean WriteFile(gpointer handle, gconstpointer buffer, guint32 numbytes,
- guint32 *byteswritten, WapiOverlapped *overlapped)
-{
- MonoW32HandleType type;
-
- type = mono_w32handle_get_type (handle);
-
- if(io_ops[type].writefile==NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- return(io_ops[type].writefile (handle, buffer, numbytes, byteswritten,
- overlapped));
-}
-
-/**
- * FlushFileBuffers:
- * @handle: Handle to open file. The handle must have
- * %GENERIC_WRITE access.
- *
- * Flushes buffers of the file and causes all unwritten data to
- * be written.
- *
- * Return value: %TRUE on success, %FALSE otherwise.
- */
-gboolean FlushFileBuffers(gpointer handle)
-{
- MonoW32HandleType type;
-
- type = mono_w32handle_get_type (handle);
-
- if(io_ops[type].flushfile==NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- return(io_ops[type].flushfile (handle));
-}
-
-/**
- * SetEndOfFile:
- * @handle: The file handle to set. The handle must have
- * %GENERIC_WRITE access.
- *
- * Moves the end-of-file position to the current position of the file
- * pointer. This function is used to truncate or extend a file.
- *
- * Return value: %TRUE on success, %FALSE otherwise.
- */
-gboolean SetEndOfFile(gpointer handle)
-{
- MonoW32HandleType type;
-
- type = mono_w32handle_get_type (handle);
-
- if (io_ops[type].setendoffile == NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- return(io_ops[type].setendoffile (handle));
-}
-
-/**
- * SetFilePointer:
- * @handle: The file handle to set. The handle must have
- * %GENERIC_READ or %GENERIC_WRITE access.
- * @movedistance: Low 32 bits of a signed value that specifies the
- * number of bytes to move the file pointer.
- * @highmovedistance: Pointer to the high 32 bits of a signed value
- * that specifies the number of bytes to move the file pointer, or
- * %NULL.
- * @method: The starting point for the file pointer move.
- *
- * Sets the file pointer of an open file.
- *
- * The distance to move the file pointer is calculated from
- * @movedistance and @highmovedistance: If @highmovedistance is %NULL,
- * @movedistance is the 32-bit signed value; otherwise, @movedistance
- * is the low 32 bits and @highmovedistance a pointer to the high 32
- * bits of a 64 bit signed value. A positive distance moves the file
- * pointer forward from the position specified by @method; a negative
- * distance moves the file pointer backward.
- *
- * If the library is compiled without large file support,
- * @highmovedistance is ignored and its value is set to zero on a
- * successful return.
- *
- * Return value: On success, the low 32 bits of the new file pointer.
- * If @highmovedistance is not %NULL, the high 32 bits of the new file
- * pointer are stored there. On failure, %INVALID_SET_FILE_POINTER.
- */
-guint32 SetFilePointer(gpointer handle, gint32 movedistance,
- gint32 *highmovedistance, WapiSeekMethod method)
-{
- MonoW32HandleType type;
-
- type = mono_w32handle_get_type (handle);
-
- if (io_ops[type].seek == NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
- return(INVALID_SET_FILE_POINTER);
- }
-
- return(io_ops[type].seek (handle, movedistance, highmovedistance,
- method));
-}
-
-/**
- * GetFileType:
- * @handle: The file handle to test.
- *
- * Finds the type of file @handle.
- *
- * Return value: %FILE_TYPE_UNKNOWN - the type of the file @handle is
- * unknown. %FILE_TYPE_DISK - @handle is a disk file.
- * %FILE_TYPE_CHAR - @handle is a character device, such as a console.
- * %FILE_TYPE_PIPE - @handle is a named or anonymous pipe.
- */
-WapiFileType GetFileType(gpointer handle)
-{
- MonoW32HandleType type;
-
- type = mono_w32handle_get_type (handle);
-
- if (io_ops[type].getfiletype == NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
- return(FILE_TYPE_UNKNOWN);
- }
-
- return(io_ops[type].getfiletype ());
-}
-
-/**
- * GetFileSize:
- * @handle: The file handle to query. The handle must have
- * %GENERIC_READ or %GENERIC_WRITE access.
- * @highsize: If non-%NULL, the high 32 bits of the file size are
- * stored here.
- *
- * Retrieves the size of the file @handle.
- *
- * If the library is compiled without large file support, @highsize
- * has its value set to zero on a successful return.
- *
- * Return value: On success, the low 32 bits of the file size. If
- * @highsize is non-%NULL then the high 32 bits of the file size are
- * stored here. On failure %INVALID_FILE_SIZE is returned.
- */
-guint32 GetFileSize(gpointer handle, guint32 *highsize)
-{
- MonoW32HandleType type;
-
- type = mono_w32handle_get_type (handle);
-
- if (io_ops[type].getfilesize == NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
- return(INVALID_FILE_SIZE);
- }
-
- return(io_ops[type].getfilesize (handle, highsize));
-}
-
-/**
- * GetFileTime:
- * @handle: The file handle to query. The handle must have
- * %GENERIC_READ access.
- * @create_time: Points to a %WapiFileTime structure to receive the
- * number of ticks since the epoch that file was created. May be
- * %NULL.
- * @last_access: Points to a %WapiFileTime structure to receive the
- * number of ticks since the epoch when file was last accessed. May be
- * %NULL.
- * @last_write: Points to a %WapiFileTime structure to receive the
- * number of ticks since the epoch when file was last written to. May
- * be %NULL.
- *
- * Finds the number of ticks since the epoch that the file referenced
- * by @handle was created, last accessed and last modified. A tick is
- * a 100 nanosecond interval. The epoch is Midnight, January 1 1601
- * GMT.
- *
- * Create time isn't recorded on POSIX file systems or reported by
- * stat(2), so that time is guessed by returning the oldest of the
- * other times.
- *
- * Return value: %TRUE on success, %FALSE otherwise.
- */
-gboolean GetFileTime(gpointer handle, WapiFileTime *create_time,
- WapiFileTime *last_access, WapiFileTime *last_write)
-{
- MonoW32HandleType type;
-
- type = mono_w32handle_get_type (handle);
-
- if (io_ops[type].getfiletime == NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- return(io_ops[type].getfiletime (handle, create_time, last_access,
- last_write));
-}
-
-/**
- * SetFileTime:
- * @handle: The file handle to set. The handle must have
- * %GENERIC_WRITE access.
- * @create_time: Points to a %WapiFileTime structure that contains the
- * number of ticks since the epoch that the file was created. May be
- * %NULL.
- * @last_access: Points to a %WapiFileTime structure that contains the
- * number of ticks since the epoch when the file was last accessed.
- * May be %NULL.
- * @last_write: Points to a %WapiFileTime structure that contains the
- * number of ticks since the epoch when the file was last written to.
- * May be %NULL.
- *
- * Sets the number of ticks since the epoch that the file referenced
- * by @handle was created, last accessed or last modified. A tick is
- * a 100 nanosecond interval. The epoch is Midnight, January 1 1601
- * GMT.
- *
- * Create time isn't recorded on POSIX file systems, and is ignored.
- *
- * Return value: %TRUE on success, %FALSE otherwise.
- */
-gboolean SetFileTime(gpointer handle, const WapiFileTime *create_time,
- const WapiFileTime *last_access,
- const WapiFileTime *last_write)
-{
- MonoW32HandleType type;
-
- type = mono_w32handle_get_type (handle);
-
- if (io_ops[type].setfiletime == NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- return(io_ops[type].setfiletime (handle, create_time, last_access,
- last_write));
-}
-
-/* A tick is a 100-nanosecond interval. File time epoch is Midnight,
- * January 1 1601 GMT
- */
-
-#define TICKS_PER_MILLISECOND 10000L
-#define TICKS_PER_SECOND 10000000L
-#define TICKS_PER_MINUTE 600000000L
-#define TICKS_PER_HOUR 36000000000LL
-#define TICKS_PER_DAY 864000000000LL
-
-#define isleap(y) ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
-
-static const guint16 mon_yday[2][13]={
- {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
- {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366},
-};
-
-/**
- * FileTimeToSystemTime:
- * @file_time: Points to a %WapiFileTime structure that contains the
- * number of ticks to convert.
- * @system_time: Points to a %WapiSystemTime structure to receive the
- * broken-out time.
- *
- * Converts a tick count into broken-out time values.
- *
- * Return value: %TRUE on success, %FALSE otherwise.
- */
-gboolean FileTimeToSystemTime(const WapiFileTime *file_time,
- WapiSystemTime *system_time)
-{
- gint64 file_ticks, totaldays, rem, y;
- const guint16 *ip;
-
- if(system_time==NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: system_time NULL", __func__);
-
- SetLastError (ERROR_INVALID_PARAMETER);
- return(FALSE);
- }
-
- file_ticks=((gint64)file_time->dwHighDateTime << 32) +
- file_time->dwLowDateTime;
-
- /* Really compares if file_ticks>=0x8000000000000000
- * (LLONG_MAX+1) but we're working with a signed value for the
- * year and day calculation to work later
- */
- if(file_ticks<0) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: file_time too big", __func__);
-
- SetLastError (ERROR_INVALID_PARAMETER);
- return(FALSE);
- }
-
- totaldays=(file_ticks / TICKS_PER_DAY);
- rem = file_ticks % TICKS_PER_DAY;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld rem: %lld", __func__, totaldays, rem);
-
- system_time->wHour=rem/TICKS_PER_HOUR;
- rem %= TICKS_PER_HOUR;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hour: %d rem: %lld", __func__, system_time->wHour, rem);
-
- system_time->wMinute = rem / TICKS_PER_MINUTE;
- rem %= TICKS_PER_MINUTE;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Minute: %d rem: %lld", __func__, system_time->wMinute,
- rem);
-
- system_time->wSecond = rem / TICKS_PER_SECOND;
- rem %= TICKS_PER_SECOND;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Second: %d rem: %lld", __func__, system_time->wSecond,
- rem);
-
- system_time->wMilliseconds = rem / TICKS_PER_MILLISECOND;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Milliseconds: %d", __func__,
- system_time->wMilliseconds);
-
- /* January 1, 1601 was a Monday, according to Emacs calendar */
- system_time->wDayOfWeek = ((1 + totaldays) % 7) + 1;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Day of week: %d", __func__, system_time->wDayOfWeek);
-
- /* This algorithm to find year and month given days from epoch
- * from glibc
- */
- y=1601;
-
-#define DIV(a, b) ((a) / (b) - ((a) % (b) < 0))
-#define LEAPS_THRU_END_OF(y) (DIV(y, 4) - DIV (y, 100) + DIV (y, 400))
-
- while(totaldays < 0 || totaldays >= (isleap(y)?366:365)) {
- /* Guess a corrected year, assuming 365 days per year */
- gint64 yg = y + totaldays / 365 - (totaldays % 365 < 0);
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld yg: %lld y: %lld", __func__,
- totaldays, yg,
- y);
- g_message("%s: LEAPS(yg): %lld LEAPS(y): %lld", __func__,
- LEAPS_THRU_END_OF(yg-1), LEAPS_THRU_END_OF(y-1));
-
- /* Adjust days and y to match the guessed year. */
- totaldays -= ((yg - y) * 365
- + LEAPS_THRU_END_OF (yg - 1)
- - LEAPS_THRU_END_OF (y - 1));
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld", __func__, totaldays);
- y = yg;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: y: %lld", __func__, y);
- }
-
- system_time->wYear = y;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Year: %d", __func__, system_time->wYear);
-
- ip = mon_yday[isleap(y)];
-
- for(y=11; totaldays < ip[y]; --y) {
- continue;
- }
- totaldays-=ip[y];
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld", __func__, totaldays);
-
- system_time->wMonth = y + 1;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Month: %d", __func__, system_time->wMonth);
-
- system_time->wDay = totaldays + 1;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Day: %d", __func__, system_time->wDay);
-
- return(TRUE);
-}
-
-gpointer FindFirstFile (const gunichar2 *pattern, WapiFindData *find_data)
-{
- struct _WapiHandle_find find_handle = {0};
- gpointer handle;
- gchar *utf8_pattern = NULL, *dir_part, *entry_part;
- int result;
-
- if (pattern == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: pattern is NULL", __func__);
-
- SetLastError (ERROR_PATH_NOT_FOUND);
- return(INVALID_HANDLE_VALUE);
- }
-
- utf8_pattern = mono_unicode_to_external (pattern);
- if (utf8_pattern == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return(INVALID_HANDLE_VALUE);
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: looking for [%s]", __func__, utf8_pattern);
-
- /* Figure out which bit of the pattern is the directory */
- dir_part = _wapi_dirname (utf8_pattern);
- entry_part = _wapi_basename (utf8_pattern);
-
-#if 0
- /* Don't do this check for now, it breaks if directories
- * really do have metachars in their names (see bug 58116).
- * FIXME: Figure out a better solution to keep some checks...
- */
- if (strchr (dir_part, '*') || strchr (dir_part, '?')) {
- SetLastError (ERROR_INVALID_NAME);
- g_free (dir_part);
- g_free (entry_part);
- g_free (utf8_pattern);
- return(INVALID_HANDLE_VALUE);
- }
-#endif
-
- /* The pattern can specify a directory or a set of files.
- *
- * The pattern can have wildcard characters ? and *, but only
- * in the section after the last directory delimiter. (Return
- * ERROR_INVALID_NAME if there are wildcards in earlier path
- * sections.) "*" has the usual 0-or-more chars meaning. "?"
- * means "match one character", "??" seems to mean "match one
- * or two characters", "???" seems to mean "match one, two or
- * three characters", etc. Windows will also try and match
- * the mangled "short name" of files, so 8 character patterns
- * with wildcards will show some surprising results.
- *
- * All the written documentation I can find says that '?'
- * should only match one character, and doesn't mention '??',
- * '???' etc. I'm going to assume that the strict behaviour
- * (ie '???' means three and only three characters) is the
- * correct one, because that lets me use fnmatch(3) rather
- * than mess around with regexes.
- */
-
- find_handle.namelist = NULL;
- result = _wapi_io_scandir (dir_part, entry_part,
- &find_handle.namelist);
-
- if (result == 0) {
- /* No files, which windows seems to call
- * FILE_NOT_FOUND
- */
- SetLastError (ERROR_FILE_NOT_FOUND);
- g_free (utf8_pattern);
- g_free (entry_part);
- g_free (dir_part);
- return (INVALID_HANDLE_VALUE);
- }
-
- if (result < 0) {
- _wapi_set_last_path_error_from_errno (dir_part, NULL);
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: scandir error: %s", __func__, g_strerror (errno));
- g_free (utf8_pattern);
- g_free (entry_part);
- g_free (dir_part);
- return (INVALID_HANDLE_VALUE);
- }
-
- g_free (utf8_pattern);
- g_free (entry_part);
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Got %d matches", __func__, result);
-
- find_handle.dir_part = dir_part;
- find_handle.num = result;
- find_handle.count = 0;
-
- handle = mono_w32handle_new (MONO_W32HANDLE_FIND, &find_handle);
- if (handle == INVALID_HANDLE_VALUE) {
- g_warning ("%s: error creating find handle", __func__);
- g_free (dir_part);
- g_free (entry_part);
- g_free (utf8_pattern);
- SetLastError (ERROR_GEN_FAILURE);
-
- return(INVALID_HANDLE_VALUE);
- }
-
- if (handle != INVALID_HANDLE_VALUE &&
- !FindNextFile (handle, find_data)) {
- FindClose (handle);
- SetLastError (ERROR_NO_MORE_FILES);
- handle = INVALID_HANDLE_VALUE;
- }
-
- return (handle);
-}
-
-gboolean FindNextFile (gpointer handle, WapiFindData *find_data)
-{
- struct _WapiHandle_find *find_handle;
- gboolean ok;
- struct stat buf, linkbuf;
- int result;
- gchar *filename;
- gchar *utf8_filename, *utf8_basename;
- gunichar2 *utf16_basename;
- time_t create_time;
- glong bytes;
- gboolean ret = FALSE;
-
- ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FIND,
- (gpointer *)&find_handle);
- if(ok==FALSE) {
- g_warning ("%s: error looking up find handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- mono_w32handle_lock_handle (handle);
-
-retry:
- if (find_handle->count >= find_handle->num) {
- SetLastError (ERROR_NO_MORE_FILES);
- goto cleanup;
- }
-
- /* stat next match */
-
- filename = g_build_filename (find_handle->dir_part, find_handle->namelist[find_handle->count ++], NULL);
-
- result = _wapi_stat (filename, &buf);
- if (result == -1 && errno == ENOENT) {
- /* Might be a dangling symlink */
- result = _wapi_lstat (filename, &buf);
- }
-
- if (result != 0) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: stat failed: %s", __func__, filename);
-
- g_free (filename);
- goto retry;
- }
-
-#ifndef __native_client__
- result = _wapi_lstat (filename, &linkbuf);
- if (result != 0) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: lstat failed: %s", __func__, filename);
-
- g_free (filename);
- goto retry;
- }
-#endif
-
- utf8_filename = mono_utf8_from_external (filename);
- if (utf8_filename == NULL) {
- /* We couldn't turn this filename into utf8 (eg the
- * encoding of the name wasn't convertible), so just
- * ignore it.
- */
- g_warning ("%s: Bad encoding for '%s'\nConsider using MONO_EXTERNAL_ENCODINGS\n", __func__, filename);
-
- g_free (filename);
- goto retry;
- }
- g_free (filename);
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Found [%s]", __func__, utf8_filename);
-
- /* fill data block */
-
- if (buf.st_mtime < buf.st_ctime)
- create_time = buf.st_mtime;
- else
- create_time = buf.st_ctime;
-
-#ifdef __native_client__
- find_data->dwFileAttributes = _wapi_stat_to_file_attributes (utf8_filename, &buf, NULL);
-#else
- find_data->dwFileAttributes = _wapi_stat_to_file_attributes (utf8_filename, &buf, &linkbuf);
-#endif
-
- time_t_to_filetime (create_time, &find_data->ftCreationTime);
- time_t_to_filetime (buf.st_atime, &find_data->ftLastAccessTime);
- time_t_to_filetime (buf.st_mtime, &find_data->ftLastWriteTime);
-
- if (find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- find_data->nFileSizeHigh = 0;
- find_data->nFileSizeLow = 0;
- } else {
- find_data->nFileSizeHigh = buf.st_size >> 32;
- find_data->nFileSizeLow = buf.st_size & 0xFFFFFFFF;
- }
-
- find_data->dwReserved0 = 0;
- find_data->dwReserved1 = 0;
-
- utf8_basename = _wapi_basename (utf8_filename);
- utf16_basename = g_utf8_to_utf16 (utf8_basename, -1, NULL, &bytes,
- NULL);
- if(utf16_basename==NULL) {
- g_free (utf8_basename);
- g_free (utf8_filename);
- goto retry;
- }
- ret = TRUE;
-
- /* utf16 is 2 * utf8 */
- bytes *= 2;
-
- memset (find_data->cFileName, '\0', (MAX_PATH*2));
-
- /* Truncating a utf16 string like this might leave the last
- * char incomplete
- */
- memcpy (find_data->cFileName, utf16_basename,
- bytes<(MAX_PATH*2)-2?bytes:(MAX_PATH*2)-2);
-
- find_data->cAlternateFileName [0] = 0; /* not used */
-
- g_free (utf8_basename);
- g_free (utf8_filename);
- g_free (utf16_basename);
-
-cleanup:
- mono_w32handle_unlock_handle (handle);
-
- return(ret);
-}
-
-/**
- * FindClose:
- * @wapi_handle: the find handle to close.
- *
- * Closes find handle @wapi_handle
- *
- * Return value: %TRUE on success, %FALSE otherwise.
- */
-gboolean FindClose (gpointer handle)
-{
- struct _WapiHandle_find *find_handle;
- gboolean ok;
-
- if (handle == NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FIND,
- (gpointer *)&find_handle);
- if(ok==FALSE) {
- g_warning ("%s: error looking up find handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- mono_w32handle_lock_handle (handle);
-
- g_strfreev (find_handle->namelist);
- g_free (find_handle->dir_part);
-
- mono_w32handle_unlock_handle (handle);
-
- mono_w32handle_unref (handle);
-
- return(TRUE);
-}
-
-/**
- * CreateDirectory:
- * @name: a pointer to a NULL-terminated unicode string, that names
- * the directory to be created.
- * @security: ignored for now
- *
- * Creates directory @name
- *
- * Return value: %TRUE on success, %FALSE otherwise.
- */
-gboolean CreateDirectory (const gunichar2 *name,
- WapiSecurityAttributes *security)
-{
- gchar *utf8_name;
- int result;
-
- if (name == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return(FALSE);
- }
-
- utf8_name = mono_unicode_to_external (name);
- if (utf8_name == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return FALSE;
- }
-
- result = _wapi_mkdir (utf8_name, 0777);
-
- if (result == 0) {
- g_free (utf8_name);
- return TRUE;
- }
-
- _wapi_set_last_path_error_from_errno (NULL, utf8_name);
- g_free (utf8_name);
- return FALSE;
-}
-
-/**
- * RemoveDirectory:
- * @name: a pointer to a NULL-terminated unicode string, that names
- * the directory to be removed.
- *
- * Removes directory @name
- *
- * Return value: %TRUE on success, %FALSE otherwise.
- */
-gboolean RemoveDirectory (const gunichar2 *name)
-{
- gchar *utf8_name;
- int result;
-
- if (name == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return(FALSE);
- }
-
- utf8_name = mono_unicode_to_external (name);
- if (utf8_name == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return FALSE;
- }
-
- result = _wapi_rmdir (utf8_name);
- if (result == -1) {
- _wapi_set_last_path_error_from_errno (NULL, utf8_name);
- g_free (utf8_name);
-
- return(FALSE);
- }
- g_free (utf8_name);
-
- return(TRUE);
-}
-
-/**
- * GetFileAttributes:
- * @name: a pointer to a NULL-terminated unicode filename.
- *
- * Gets the attributes for @name;
- *
- * Return value: %INVALID_FILE_ATTRIBUTES on failure
- */
-guint32 GetFileAttributes (const gunichar2 *name)
-{
- gchar *utf8_name;
- struct stat buf, linkbuf;
- int result;
- guint32 ret;
-
- if (name == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return(FALSE);
- }
-
- utf8_name = mono_unicode_to_external (name);
- if (utf8_name == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
-
- SetLastError (ERROR_INVALID_PARAMETER);
- return (INVALID_FILE_ATTRIBUTES);
- }
-
- result = _wapi_stat (utf8_name, &buf);
- if (result == -1 && errno == ENOENT) {
- /* Might be a dangling symlink... */
- result = _wapi_lstat (utf8_name, &buf);
- }
-
- if (result != 0) {
- _wapi_set_last_path_error_from_errno (NULL, utf8_name);
- g_free (utf8_name);
- return (INVALID_FILE_ATTRIBUTES);
- }
-
-#ifndef __native_client__
- result = _wapi_lstat (utf8_name, &linkbuf);
- if (result != 0) {
- _wapi_set_last_path_error_from_errno (NULL, utf8_name);
- g_free (utf8_name);
- return (INVALID_FILE_ATTRIBUTES);
- }
-#endif
-
-#ifdef __native_client__
- ret = _wapi_stat_to_file_attributes (utf8_name, &buf, NULL);
-#else
- ret = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
-#endif
-
- g_free (utf8_name);
-
- return(ret);
-}
-
-/**
- * GetFileAttributesEx:
- * @name: a pointer to a NULL-terminated unicode filename.
- * @level: must be GetFileExInfoStandard
- * @info: pointer to a WapiFileAttributesData structure
- *
- * Gets attributes, size and filetimes for @name;
- *
- * Return value: %TRUE on success, %FALSE on failure
- */
-gboolean GetFileAttributesEx (const gunichar2 *name, WapiGetFileExInfoLevels level, gpointer info)
-{
- gchar *utf8_name;
- WapiFileAttributesData *data;
-
- struct stat buf, linkbuf;
- time_t create_time;
- int result;
-
- if (level != GetFileExInfoStandard) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: info level %d not supported.", __func__,
- level);
-
- SetLastError (ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- if (name == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return(FALSE);
- }
-
- utf8_name = mono_unicode_to_external (name);
- if (utf8_name == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
-
- SetLastError (ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- result = _wapi_stat (utf8_name, &buf);
- if (result == -1 && errno == ENOENT) {
- /* Might be a dangling symlink... */
- result = _wapi_lstat (utf8_name, &buf);
- }
-
- if (result != 0) {
- _wapi_set_last_path_error_from_errno (NULL, utf8_name);
- g_free (utf8_name);
- return FALSE;
- }
-
- result = _wapi_lstat (utf8_name, &linkbuf);
- if (result != 0) {
- _wapi_set_last_path_error_from_errno (NULL, utf8_name);
- g_free (utf8_name);
- return(FALSE);
- }
-
- /* fill data block */
-
- data = (WapiFileAttributesData *)info;
-
- if (buf.st_mtime < buf.st_ctime)
- create_time = buf.st_mtime;
- else
- create_time = buf.st_ctime;
-
- data->dwFileAttributes = _wapi_stat_to_file_attributes (utf8_name,
- &buf,
- &linkbuf);
-
- g_free (utf8_name);
-
- time_t_to_filetime (create_time, &data->ftCreationTime);
- time_t_to_filetime (buf.st_atime, &data->ftLastAccessTime);
- time_t_to_filetime (buf.st_mtime, &data->ftLastWriteTime);
-
- if (data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- data->nFileSizeHigh = 0;
- data->nFileSizeLow = 0;
- }
- else {
- data->nFileSizeHigh = buf.st_size >> 32;
- data->nFileSizeLow = buf.st_size & 0xFFFFFFFF;
- }
-
- return TRUE;
-}
-
-/**
- * SetFileAttributes
- * @name: name of file
- * @attrs: attributes to set
- *
- * Changes the attributes on a named file.
- *
- * Return value: %TRUE on success, %FALSE on failure.
- */
-extern gboolean SetFileAttributes (const gunichar2 *name, guint32 attrs)
-{
- /* FIXME: think of something clever to do on unix */
- gchar *utf8_name;
- struct stat buf;
- int result;
-
- /*
- * Currently we only handle one *internal* case, with a value that is
- * not standard: 0x80000000, which means `set executable bit'
- */
-
- if (name == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return(FALSE);
- }
-
- utf8_name = mono_unicode_to_external (name);
- if (utf8_name == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return FALSE;
- }
-
- result = _wapi_stat (utf8_name, &buf);
- if (result == -1 && errno == ENOENT) {
- /* Might be a dangling symlink... */
- result = _wapi_lstat (utf8_name, &buf);
- }
-
- if (result != 0) {
- _wapi_set_last_path_error_from_errno (NULL, utf8_name);
- g_free (utf8_name);
- return FALSE;
- }
-
- /* Contrary to the documentation, ms allows NORMAL to be
- * specified along with other attributes, so dont bother to
- * catch that case here.
- */
- if (attrs & FILE_ATTRIBUTE_READONLY) {
- result = _wapi_chmod (utf8_name, buf.st_mode & ~(S_IWUSR | S_IWOTH | S_IWGRP));
- } else {
- result = _wapi_chmod (utf8_name, buf.st_mode | S_IWUSR);
- }
-
- /* Ignore the other attributes for now */
-
- if (attrs & 0x80000000){
- mode_t exec_mask = 0;
-
- if ((buf.st_mode & S_IRUSR) != 0)
- exec_mask |= S_IXUSR;
-
- if ((buf.st_mode & S_IRGRP) != 0)
- exec_mask |= S_IXGRP;
-
- if ((buf.st_mode & S_IROTH) != 0)
- exec_mask |= S_IXOTH;
-
- result = chmod (utf8_name, buf.st_mode | exec_mask);
- }
- /* Don't bother to reset executable (might need to change this
- * policy)
- */
-
- g_free (utf8_name);
-
- return(TRUE);
-}
-
-/**
- * GetCurrentDirectory
- * @length: size of the buffer
- * @buffer: pointer to buffer that recieves path
- *
- * Retrieves the current directory for the current process.
- *
- * Return value: number of characters in buffer on success, zero on failure
- */
-extern guint32 GetCurrentDirectory (guint32 length, gunichar2 *buffer)
-{
- gunichar2 *utf16_path;
- glong count;
- gsize bytes;
-
-#ifdef __native_client__
- gchar *path = g_get_current_dir ();
- if (length < strlen(path) + 1 || path == NULL)
- return 0;
- memcpy (buffer, path, strlen(path) + 1);
-#else
- if (getcwd ((char*)buffer, length) == NULL) {
- if (errno == ERANGE) { /*buffer length is not big enough */
- gchar *path = g_get_current_dir (); /*FIXME g_get_current_dir doesn't work with broken paths and calling it just to know the path length is silly*/
- if (path == NULL)
- return 0;
- utf16_path = mono_unicode_from_external (path, &bytes);
- g_free (utf16_path);
- g_free (path);
- return (bytes/2)+1;
- }
- _wapi_set_last_error_from_errno ();
- return 0;
- }
-#endif
-
- utf16_path = mono_unicode_from_external ((gchar*)buffer, &bytes);
- count = (bytes/2)+1;
- g_assert (count <= length); /*getcwd must have failed before with ERANGE*/
-
- /* Add the terminator */
- memset (buffer, '\0', bytes+2);
- memcpy (buffer, utf16_path, bytes);
-
- g_free (utf16_path);
-
- return count;
-}
-
-/**
- * SetCurrentDirectory
- * @path: path to new directory
- *
- * Changes the directory path for the current process.
- *
- * Return value: %TRUE on success, %FALSE on failure.
- */
-extern gboolean SetCurrentDirectory (const gunichar2 *path)
-{
- gchar *utf8_path;
- gboolean result;
-
- if (path == NULL) {
- SetLastError (ERROR_INVALID_PARAMETER);
- return(FALSE);
- }
-
- utf8_path = mono_unicode_to_external (path);
- if (_wapi_chdir (utf8_path) != 0) {
- _wapi_set_last_error_from_errno ();
- result = FALSE;
- }
- else
- result = TRUE;
-
- g_free (utf8_path);
- return result;
-}
-
-gboolean CreatePipe (gpointer *readpipe, gpointer *writepipe,
- WapiSecurityAttributes *security G_GNUC_UNUSED, guint32 size)
-{
- struct _WapiHandle_file pipe_read_handle = {0};
- struct _WapiHandle_file pipe_write_handle = {0};
- gpointer read_handle;
- gpointer write_handle;
- int filedes[2];
- int ret;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating pipe", __func__);
-
- ret=pipe (filedes);
- if(ret==-1) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error creating pipe: %s", __func__,
- strerror (errno));
-
- _wapi_set_last_error_from_errno ();
- return(FALSE);
- }
-
- if (filedes[0] >= mono_w32handle_fd_reserve ||
- filedes[1] >= mono_w32handle_fd_reserve) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big", __func__);
-
- SetLastError (ERROR_TOO_MANY_OPEN_FILES);
-
- close (filedes[0]);
- close (filedes[1]);
-
- return(FALSE);
- }
-
- /* filedes[0] is open for reading, filedes[1] for writing */
-
- pipe_read_handle.fd = filedes [0];
- pipe_read_handle.fileaccess = GENERIC_READ;
- read_handle = mono_w32handle_new_fd (MONO_W32HANDLE_PIPE, filedes[0],
- &pipe_read_handle);
- if (read_handle == INVALID_HANDLE_VALUE) {
- g_warning ("%s: error creating pipe read handle", __func__);
- close (filedes[0]);
- close (filedes[1]);
- SetLastError (ERROR_GEN_FAILURE);
-
- return(FALSE);
- }
-
- pipe_write_handle.fd = filedes [1];
- pipe_write_handle.fileaccess = GENERIC_WRITE;
- write_handle = mono_w32handle_new_fd (MONO_W32HANDLE_PIPE, filedes[1],
- &pipe_write_handle);
- if (write_handle == INVALID_HANDLE_VALUE) {
- g_warning ("%s: error creating pipe write handle", __func__);
- mono_w32handle_unref (read_handle);
-
- close (filedes[0]);
- close (filedes[1]);
- SetLastError (ERROR_GEN_FAILURE);
-
- return(FALSE);
- }
-
- *readpipe = read_handle;
- *writepipe = write_handle;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning pipe: read handle %p, write handle %p",
- __func__, read_handle, write_handle);
-
- return(TRUE);
-}
-
-#ifdef HAVE_GETFSSTAT
-/* Darwin has getfsstat */
-gint32 GetLogicalDriveStrings (guint32 len, gunichar2 *buf)
-{
- struct statfs *stats;
- int size, n, i;
- gunichar2 *dir;
- glong length, total = 0;
-
- n = getfsstat (NULL, 0, MNT_NOWAIT);
- if (n == -1)
- return 0;
- size = n * sizeof (struct statfs);
- stats = (struct statfs *) g_malloc (size);
- if (stats == NULL)
- return 0;
- if (getfsstat (stats, size, MNT_NOWAIT) == -1){
- g_free (stats);
- return 0;
- }
- for (i = 0; i < n; i++){
- dir = g_utf8_to_utf16 (stats [i].f_mntonname, -1, NULL, &length, NULL);
- if (total + length < len){
- memcpy (buf + total, dir, sizeof (gunichar2) * length);
- buf [total+length] = 0;
- }
- g_free (dir);
- total += length + 1;
- }
- if (total < len)
- buf [total] = 0;
- total++;
- g_free (stats);
- return total;
-}
-#else
-/* In-place octal sequence replacement */
-static void
-unescape_octal (gchar *str)
-{
- gchar *rptr;
- gchar *wptr;
-
- if (str == NULL)
- return;
-
- rptr = wptr = str;
- while (*rptr != '\0') {
- if (*rptr == '\\') {
- char c;
- rptr++;
- c = (*(rptr++) - '0') << 6;
- c += (*(rptr++) - '0') << 3;
- c += *(rptr++) - '0';
- *wptr++ = c;
- } else if (wptr != rptr) {
- *wptr++ = *rptr++;
- } else {
- rptr++; wptr++;
- }
- }
- *wptr = '\0';
-}
-static gint32 GetLogicalDriveStrings_Mtab (guint32 len, gunichar2 *buf);
-
-#if __linux__
-#define GET_LOGICAL_DRIVE_STRINGS_BUFFER 512
-#define GET_LOGICAL_DRIVE_STRINGS_MOUNTPOINT_BUFFER 512
-#define GET_LOGICAL_DRIVE_STRINGS_FSNAME_BUFFER 64
-
-typedef struct
-{
- glong total;
- guint32 buffer_index;
- guint32 mountpoint_index;
- guint32 field_number;
- guint32 allocated_size;
- guint32 fsname_index;
- guint32 fstype_index;
- gchar mountpoint [GET_LOGICAL_DRIVE_STRINGS_MOUNTPOINT_BUFFER + 1];
- gchar *mountpoint_allocated;
- gchar buffer [GET_LOGICAL_DRIVE_STRINGS_BUFFER];
- gchar fsname [GET_LOGICAL_DRIVE_STRINGS_FSNAME_BUFFER + 1];
- gchar fstype [GET_LOGICAL_DRIVE_STRINGS_FSNAME_BUFFER + 1];
- ssize_t nbytes;
- gchar delimiter;
- gboolean check_mount_source;
-} LinuxMountInfoParseState;
-
-static gboolean GetLogicalDriveStrings_Mounts (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state);
-static gboolean GetLogicalDriveStrings_MountInfo (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state);
-static void append_to_mountpoint (LinuxMountInfoParseState *state);
-static gboolean add_drive_string (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state);
-
-gint32 GetLogicalDriveStrings (guint32 len, gunichar2 *buf)
-{
- int fd;
- gint32 ret = 0;
- LinuxMountInfoParseState state;
- gboolean (*parser)(guint32, gunichar2*, LinuxMountInfoParseState*) = NULL;
-
- memset (buf, 0, len * sizeof (gunichar2));
- fd = open ("/proc/self/mountinfo", O_RDONLY);
- if (fd != -1)
- parser = GetLogicalDriveStrings_MountInfo;
- else {
- fd = open ("/proc/mounts", O_RDONLY);
- if (fd != -1)
- parser = GetLogicalDriveStrings_Mounts;
- }
-
- if (!parser) {
- ret = GetLogicalDriveStrings_Mtab (len, buf);
- goto done_and_out;
- }
-
- memset (&state, 0, sizeof (LinuxMountInfoParseState));
- state.field_number = 1;
- state.delimiter = ' ';
-
- while ((state.nbytes = read (fd, state.buffer, GET_LOGICAL_DRIVE_STRINGS_BUFFER)) > 0) {
- state.buffer_index = 0;
-
- while ((*parser)(len, buf, &state)) {
- if (state.buffer [state.buffer_index] == '\n') {
- gboolean quit = add_drive_string (len, buf, &state);
- state.field_number = 1;
- state.buffer_index++;
- if (state.mountpoint_allocated) {
- g_free (state.mountpoint_allocated);
- state.mountpoint_allocated = NULL;
- }
- if (quit) {
- ret = state.total;
- goto done_and_out;
- }
- }
- }
- };
- ret = state.total;
-
- done_and_out:
- if (fd != -1)
- close (fd);
- return ret;
-}
-
-static gboolean GetLogicalDriveStrings_Mounts (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state)
-{
- gchar *ptr;
-
- if (state->field_number == 1)
- state->check_mount_source = TRUE;
-
- while (state->buffer_index < (guint32)state->nbytes) {
- if (state->buffer [state->buffer_index] == state->delimiter) {
- state->field_number++;
- switch (state->field_number) {
- case 2:
- state->mountpoint_index = 0;
- break;
-
- case 3:
- if (state->mountpoint_allocated)
- state->mountpoint_allocated [state->mountpoint_index] = 0;
- else
- state->mountpoint [state->mountpoint_index] = 0;
- break;
-
- default:
- ptr = (gchar*)memchr (state->buffer + state->buffer_index, '\n', GET_LOGICAL_DRIVE_STRINGS_BUFFER - state->buffer_index);
- if (ptr)
- state->buffer_index = (ptr - (gchar*)state->buffer) - 1;
- else
- state->buffer_index = state->nbytes;
- return TRUE;
- }
- state->buffer_index++;
- continue;
- } else if (state->buffer [state->buffer_index] == '\n')
- return TRUE;
-
- switch (state->field_number) {
- case 1:
- if (state->check_mount_source) {
- if (state->fsname_index == 0 && state->buffer [state->buffer_index] == '/') {
- /* We can ignore the rest, it's a device
- * path */
- state->check_mount_source = FALSE;
- state->fsname [state->fsname_index++] = '/';
- break;
- }
- if (state->fsname_index < GET_LOGICAL_DRIVE_STRINGS_FSNAME_BUFFER)
- state->fsname [state->fsname_index++] = state->buffer [state->buffer_index];
- }
- break;
-
- case 2:
- append_to_mountpoint (state);
- break;
-
- case 3:
- if (state->fstype_index < GET_LOGICAL_DRIVE_STRINGS_FSNAME_BUFFER)
- state->fstype [state->fstype_index++] = state->buffer [state->buffer_index];
- break;
- }
-
- state->buffer_index++;
- }
-
- return FALSE;
-}
-
-static gboolean GetLogicalDriveStrings_MountInfo (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state)
-{
- while (state->buffer_index < (guint32)state->nbytes) {
- if (state->buffer [state->buffer_index] == state->delimiter) {
- state->field_number++;
- switch (state->field_number) {
- case 5:
- state->mountpoint_index = 0;
- break;
-
- case 6:
- if (state->mountpoint_allocated)
- state->mountpoint_allocated [state->mountpoint_index] = 0;
- else
- state->mountpoint [state->mountpoint_index] = 0;
- break;
-
- case 7:
- state->delimiter = '-';
- break;
-
- case 8:
- state->delimiter = ' ';
- break;
-
- case 10:
- state->check_mount_source = TRUE;
- break;
- }
- state->buffer_index++;
- continue;
- } else if (state->buffer [state->buffer_index] == '\n')
- return TRUE;
-
- switch (state->field_number) {
- case 5:
- append_to_mountpoint (state);
- break;
-
- case 9:
- if (state->fstype_index < GET_LOGICAL_DRIVE_STRINGS_FSNAME_BUFFER)
- state->fstype [state->fstype_index++] = state->buffer [state->buffer_index];
- break;
-
- case 10:
- if (state->check_mount_source) {
- if (state->fsname_index == 0 && state->buffer [state->buffer_index] == '/') {
- /* We can ignore the rest, it's a device
- * path */
- state->check_mount_source = FALSE;
- state->fsname [state->fsname_index++] = '/';
- break;
- }
- if (state->fsname_index < GET_LOGICAL_DRIVE_STRINGS_FSNAME_BUFFER)
- state->fsname [state->fsname_index++] = state->buffer [state->buffer_index];
- }
- break;
- }
-
- state->buffer_index++;
- }
-
- return FALSE;
-}
-
-static void
-append_to_mountpoint (LinuxMountInfoParseState *state)
-{
- gchar ch = state->buffer [state->buffer_index];
- if (state->mountpoint_allocated) {
- if (state->mountpoint_index >= state->allocated_size) {
- guint32 newsize = (state->allocated_size << 1) + 1;
- gchar *newbuf = (gchar *)g_malloc0 (newsize * sizeof (gchar));
-
- memcpy (newbuf, state->mountpoint_allocated, state->mountpoint_index);
- g_free (state->mountpoint_allocated);
- state->mountpoint_allocated = newbuf;
- state->allocated_size = newsize;
- }
- state->mountpoint_allocated [state->mountpoint_index++] = ch;
- } else {
- if (state->mountpoint_index >= GET_LOGICAL_DRIVE_STRINGS_MOUNTPOINT_BUFFER) {
- state->allocated_size = (state->mountpoint_index << 1) + 1;
- state->mountpoint_allocated = (gchar *)g_malloc0 (state->allocated_size * sizeof (gchar));
- memcpy (state->mountpoint_allocated, state->mountpoint, state->mountpoint_index);
- state->mountpoint_allocated [state->mountpoint_index++] = ch;
- } else
- state->mountpoint [state->mountpoint_index++] = ch;
- }
-}
-
-static gboolean
-add_drive_string (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state)
-{
- gboolean quit = FALSE;
- gboolean ignore_entry;
-
- if (state->fsname_index == 1 && state->fsname [0] == '/')
- ignore_entry = FALSE;
- else if (memcmp ("overlay", state->fsname, state->fsname_index) == 0 ||
- memcmp ("aufs", state->fstype, state->fstype_index) == 0) {
- /* Don't ignore overlayfs and aufs - these might be used on Docker
- * (https://bugzilla.xamarin.com/show_bug.cgi?id=31021) */
- ignore_entry = FALSE;
- } else if (state->fsname_index == 0 || memcmp ("none", state->fsname, state->fsname_index) == 0) {
- ignore_entry = TRUE;
- } else if (state->fstype_index >= 5 && memcmp ("fuse.", state->fstype, 5) == 0) {
- /* Ignore GNOME's gvfs */
- if (state->fstype_index == 21 && memcmp ("fuse.gvfs-fuse-daemon", state->fstype, state->fstype_index) == 0)
- ignore_entry = TRUE;
- else
- ignore_entry = FALSE;
- } else if (state->fstype_index == 3 && memcmp ("nfs", state->fstype, state->fstype_index) == 0)
- ignore_entry = FALSE;
- else
- ignore_entry = TRUE;
-
- if (!ignore_entry) {
- gunichar2 *dir;
- glong length;
- gchar *mountpoint = state->mountpoint_allocated ? state->mountpoint_allocated : state->mountpoint;
-
- unescape_octal (mountpoint);
- dir = g_utf8_to_utf16 (mountpoint, -1, NULL, &length, NULL);
- if (state->total + length + 1 > len) {
- quit = TRUE;
- state->total = len * 2;
- } else {
- length++;
- memcpy (buf + state->total, dir, sizeof (gunichar2) * length);
- state->total += length;
- }
- g_free (dir);
- }
- state->fsname_index = 0;
- state->fstype_index = 0;
-
- return quit;
-}
-#else
-gint32
-GetLogicalDriveStrings (guint32 len, gunichar2 *buf)
-{
- return GetLogicalDriveStrings_Mtab (len, buf);
-}
-#endif
-static gint32
-GetLogicalDriveStrings_Mtab (guint32 len, gunichar2 *buf)
-{
- FILE *fp;
- gunichar2 *ptr, *dir;
- glong length, total = 0;
- gchar buffer [512];
- gchar **splitted;
-
- memset (buf, 0, sizeof (gunichar2) * (len + 1));
- buf [0] = '/';
- buf [1] = 0;
- buf [2] = 0;
-
- /* Sigh, mntent and friends don't work well.
- * It stops on the first line that doesn't begin with a '/'.
- * (linux 2.6.5, libc 2.3.2.ds1-12) - Gonz */
- fp = fopen ("/etc/mtab", "rt");
- if (fp == NULL) {
- fp = fopen ("/etc/mnttab", "rt");
- if (fp == NULL)
- return 1;
- }
-
- ptr = buf;
- while (fgets (buffer, 512, fp) != NULL) {
- if (*buffer != '/')
- continue;
-
- splitted = g_strsplit (buffer, " ", 0);
- if (!*splitted || !*(splitted + 1)) {
- g_strfreev (splitted);
- continue;
- }
-
- unescape_octal (*(splitted + 1));
- dir = g_utf8_to_utf16 (*(splitted + 1), -1, NULL, &length, NULL);
- g_strfreev (splitted);
- if (total + length + 1 > len) {
- fclose (fp);
- g_free (dir);
- return len * 2; /* guess */
- }
-
- memcpy (ptr + total, dir, sizeof (gunichar2) * length);
- g_free (dir);
- total += length + 1;
- }
-
- fclose (fp);
- return total;
-/* Commented out, does not work with my mtab!!! - Gonz */
-#ifdef NOTENABLED /* HAVE_MNTENT_H */
-{
- FILE *fp;
- struct mntent *mnt;
- gunichar2 *ptr, *dir;
- glong len, total = 0;
-
-
- fp = setmntent ("/etc/mtab", "rt");
- if (fp == NULL) {
- fp = setmntent ("/etc/mnttab", "rt");
- if (fp == NULL)
- return;
- }
-
- ptr = buf;
- while ((mnt = getmntent (fp)) != NULL) {
- g_print ("GOT %s\n", mnt->mnt_dir);
- dir = g_utf8_to_utf16 (mnt->mnt_dir, &len, NULL, NULL, NULL);
- if (total + len + 1 > len) {
- return len * 2; /* guess */
- }
-
- memcpy (ptr + total, dir, sizeof (gunichar2) * len);
- g_free (dir);
- total += len + 1;
- }
-
- endmntent (fp);
- return total;
-}
-#endif
-}
-#endif
-
-#if defined(HAVE_STATVFS) || defined(HAVE_STATFS)
-gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, ULARGE_INTEGER *free_bytes_avail,
- ULARGE_INTEGER *total_number_of_bytes,
- ULARGE_INTEGER *total_number_of_free_bytes)
-{
-#ifdef HAVE_STATVFS
- struct statvfs fsstat;
-#elif defined(HAVE_STATFS)
- struct statfs fsstat;
-#endif
- gboolean isreadonly;
- gchar *utf8_path_name;
- int ret;
- unsigned long block_size;
-
- if (path_name == NULL) {
- utf8_path_name = g_strdup (g_get_current_dir());
- if (utf8_path_name == NULL) {
- SetLastError (ERROR_DIRECTORY);
- return(FALSE);
- }
- }
- else {
- utf8_path_name = mono_unicode_to_external (path_name);
- if (utf8_path_name == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
-
- SetLastError (ERROR_INVALID_NAME);
- return(FALSE);
- }
- }
-
- do {
-#ifdef HAVE_STATVFS
- ret = statvfs (utf8_path_name, &fsstat);
- isreadonly = ((fsstat.f_flag & ST_RDONLY) == ST_RDONLY);
- block_size = fsstat.f_frsize;
-#elif defined(HAVE_STATFS)
- ret = statfs (utf8_path_name, &fsstat);
-#if defined (MNT_RDONLY)
- isreadonly = ((fsstat.f_flags & MNT_RDONLY) == MNT_RDONLY);
-#elif defined (MS_RDONLY)
- isreadonly = ((fsstat.f_flags & MS_RDONLY) == MS_RDONLY);
-#endif
- block_size = fsstat.f_bsize;
-#endif
- } while(ret == -1 && errno == EINTR);
-
- g_free(utf8_path_name);
-
- if (ret == -1) {
- _wapi_set_last_error_from_errno ();
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: statvfs failed: %s", __func__, strerror (errno));
- return(FALSE);
- }
-
- /* total number of free bytes for non-root */
- if (free_bytes_avail != NULL) {
- if (isreadonly) {
- free_bytes_avail->QuadPart = 0;
- }
- else {
- free_bytes_avail->QuadPart = block_size * (guint64)fsstat.f_bavail;
- }
- }
-
- /* total number of bytes available for non-root */
- if (total_number_of_bytes != NULL) {
- total_number_of_bytes->QuadPart = block_size * (guint64)fsstat.f_blocks;
- }
-
- /* total number of bytes available for root */
- if (total_number_of_free_bytes != NULL) {
- if (isreadonly) {
- total_number_of_free_bytes->QuadPart = 0;
- }
- else {
- total_number_of_free_bytes->QuadPart = block_size * (guint64)fsstat.f_bfree;
- }
- }
-
- return(TRUE);
-}
-#else
-gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, ULARGE_INTEGER *free_bytes_avail,
- ULARGE_INTEGER *total_number_of_bytes,
- ULARGE_INTEGER *total_number_of_free_bytes)
-{
- if (free_bytes_avail != NULL) {
- free_bytes_avail->QuadPart = (guint64) -1;
- }
-
- if (total_number_of_bytes != NULL) {
- total_number_of_bytes->QuadPart = (guint64) -1;
- }
-
- if (total_number_of_free_bytes != NULL) {
- total_number_of_free_bytes->QuadPart = (guint64) -1;
- }
-
- return(TRUE);
-}
-#endif
-
-/*
- * General Unix support
- */
-typedef struct {
- guint32 drive_type;
-#if __linux__
- const long fstypeid;
-#endif
- const gchar* fstype;
-} _wapi_drive_type;
-
-static _wapi_drive_type _wapi_drive_types[] = {
-#if PLATFORM_MACOSX
- { DRIVE_REMOTE, "afp" },
- { DRIVE_REMOTE, "autofs" },
- { DRIVE_CDROM, "cddafs" },
- { DRIVE_CDROM, "cd9660" },
- { DRIVE_RAMDISK, "devfs" },
- { DRIVE_FIXED, "exfat" },
- { DRIVE_RAMDISK, "fdesc" },
- { DRIVE_REMOTE, "ftp" },
- { DRIVE_FIXED, "hfs" },
- { DRIVE_FIXED, "msdos" },
- { DRIVE_REMOTE, "nfs" },
- { DRIVE_FIXED, "ntfs" },
- { DRIVE_REMOTE, "smbfs" },
- { DRIVE_FIXED, "udf" },
- { DRIVE_REMOTE, "webdav" },
- { DRIVE_UNKNOWN, NULL }
-#elif __linux__
- { DRIVE_FIXED, ADFS_SUPER_MAGIC, "adfs"},
- { DRIVE_FIXED, AFFS_SUPER_MAGIC, "affs"},
- { DRIVE_REMOTE, AFS_SUPER_MAGIC, "afs"},
- { DRIVE_RAMDISK, AUTOFS_SUPER_MAGIC, "autofs"},
- { DRIVE_RAMDISK, AUTOFS_SBI_MAGIC, "autofs4"},
- { DRIVE_REMOTE, CODA_SUPER_MAGIC, "coda" },
- { DRIVE_RAMDISK, CRAMFS_MAGIC, "cramfs"},
- { DRIVE_RAMDISK, CRAMFS_MAGIC_WEND, "cramfs"},
- { DRIVE_REMOTE, CIFS_MAGIC_NUMBER, "cifs"},
- { DRIVE_RAMDISK, DEBUGFS_MAGIC, "debugfs"},
- { DRIVE_RAMDISK, SYSFS_MAGIC, "sysfs"},
- { DRIVE_RAMDISK, SECURITYFS_MAGIC, "securityfs"},
- { DRIVE_RAMDISK, SELINUX_MAGIC, "selinuxfs"},
- { DRIVE_RAMDISK, RAMFS_MAGIC, "ramfs"},
- { DRIVE_FIXED, SQUASHFS_MAGIC, "squashfs"},
- { DRIVE_FIXED, EFS_SUPER_MAGIC, "efs"},
- { DRIVE_FIXED, EXT2_SUPER_MAGIC, "ext"},
- { DRIVE_FIXED, EXT3_SUPER_MAGIC, "ext"},
- { DRIVE_FIXED, EXT4_SUPER_MAGIC, "ext"},
- { DRIVE_REMOTE, XENFS_SUPER_MAGIC, "xenfs"},
- { DRIVE_FIXED, BTRFS_SUPER_MAGIC, "btrfs"},
- { DRIVE_FIXED, HFS_SUPER_MAGIC, "hfs"},
- { DRIVE_FIXED, HFSPLUS_SUPER_MAGIC, "hfsplus"},
- { DRIVE_FIXED, HPFS_SUPER_MAGIC, "hpfs"},
- { DRIVE_RAMDISK, HUGETLBFS_MAGIC, "hugetlbfs"},
- { DRIVE_CDROM, ISOFS_SUPER_MAGIC, "iso"},
- { DRIVE_FIXED, JFFS2_SUPER_MAGIC, "jffs2"},
- { DRIVE_RAMDISK, ANON_INODE_FS_MAGIC, "anon_inode"},
- { DRIVE_FIXED, JFS_SUPER_MAGIC, "jfs"},
- { DRIVE_FIXED, MINIX_SUPER_MAGIC, "minix"},
- { DRIVE_FIXED, MINIX_SUPER_MAGIC2, "minix v2"},
- { DRIVE_FIXED, MINIX2_SUPER_MAGIC, "minix2"},
- { DRIVE_FIXED, MINIX2_SUPER_MAGIC2, "minix2 v2"},
- { DRIVE_FIXED, MINIX3_SUPER_MAGIC, "minix3"},
- { DRIVE_FIXED, MSDOS_SUPER_MAGIC, "msdos"},
- { DRIVE_REMOTE, NCP_SUPER_MAGIC, "ncp"},
- { DRIVE_REMOTE, NFS_SUPER_MAGIC, "nfs"},
- { DRIVE_FIXED, NTFS_SB_MAGIC, "ntfs"},
- { DRIVE_RAMDISK, OPENPROM_SUPER_MAGIC, "openpromfs"},
- { DRIVE_RAMDISK, PROC_SUPER_MAGIC, "proc"},
- { DRIVE_FIXED, QNX4_SUPER_MAGIC, "qnx4"},
- { DRIVE_FIXED, REISERFS_SUPER_MAGIC, "reiserfs"},
- { DRIVE_RAMDISK, ROMFS_MAGIC, "romfs"},
- { DRIVE_REMOTE, SMB_SUPER_MAGIC, "samba"},
- { DRIVE_RAMDISK, CGROUP_SUPER_MAGIC, "cgroupfs"},
- { DRIVE_RAMDISK, FUTEXFS_SUPER_MAGIC, "futexfs"},
- { DRIVE_FIXED, SYSV2_SUPER_MAGIC, "sysv2"},
- { DRIVE_FIXED, SYSV4_SUPER_MAGIC, "sysv4"},
- { DRIVE_RAMDISK, TMPFS_MAGIC, "tmpfs"},
- { DRIVE_RAMDISK, DEVPTS_SUPER_MAGIC, "devpts"},
- { DRIVE_CDROM, UDF_SUPER_MAGIC, "udf"},
- { DRIVE_FIXED, UFS_MAGIC, "ufs"},
- { DRIVE_FIXED, UFS_MAGIC_BW, "ufs"},
- { DRIVE_FIXED, UFS2_MAGIC, "ufs2"},
- { DRIVE_FIXED, UFS_CIGAM, "ufs"},
- { DRIVE_RAMDISK, USBDEVICE_SUPER_MAGIC, "usbdev"},
- { DRIVE_FIXED, XENIX_SUPER_MAGIC, "xenix"},
- { DRIVE_FIXED, XFS_SB_MAGIC, "xfs"},
- { DRIVE_RAMDISK, FUSE_SUPER_MAGIC, "fuse"},
- { DRIVE_FIXED, V9FS_MAGIC, "9p"},
- { DRIVE_REMOTE, CEPH_SUPER_MAGIC, "ceph"},
- { DRIVE_RAMDISK, CONFIGFS_MAGIC, "configfs"},
- { DRIVE_RAMDISK, ECRYPTFS_SUPER_MAGIC, "eCryptfs"},
- { DRIVE_FIXED, EXOFS_SUPER_MAGIC, "exofs"},
- { DRIVE_FIXED, VXFS_SUPER_MAGIC, "vxfs"},
- { DRIVE_FIXED, VXFS_OLT_MAGIC, "vxfs_olt"},
- { DRIVE_REMOTE, GFS2_MAGIC, "gfs2"},
- { DRIVE_FIXED, LOGFS_MAGIC_U32, "logfs"},
- { DRIVE_FIXED, OCFS2_SUPER_MAGIC, "ocfs2"},
- { DRIVE_FIXED, OMFS_MAGIC, "omfs"},
- { DRIVE_FIXED, UBIFS_SUPER_MAGIC, "ubifs"},
- { DRIVE_UNKNOWN, 0, NULL}
-#else
- { DRIVE_RAMDISK, "ramfs" },
- { DRIVE_RAMDISK, "tmpfs" },
- { DRIVE_RAMDISK, "proc" },
- { DRIVE_RAMDISK, "sysfs" },
- { DRIVE_RAMDISK, "debugfs" },
- { DRIVE_RAMDISK, "devpts" },
- { DRIVE_RAMDISK, "securityfs" },
- { DRIVE_CDROM, "iso9660" },
- { DRIVE_FIXED, "ext2" },
- { DRIVE_FIXED, "ext3" },
- { DRIVE_FIXED, "ext4" },
- { DRIVE_FIXED, "sysv" },
- { DRIVE_FIXED, "reiserfs" },
- { DRIVE_FIXED, "ufs" },
- { DRIVE_FIXED, "vfat" },
- { DRIVE_FIXED, "msdos" },
- { DRIVE_FIXED, "udf" },
- { DRIVE_FIXED, "hfs" },
- { DRIVE_FIXED, "hpfs" },
- { DRIVE_FIXED, "qnx4" },
- { DRIVE_FIXED, "ntfs" },
- { DRIVE_FIXED, "ntfs-3g" },
- { DRIVE_REMOTE, "smbfs" },
- { DRIVE_REMOTE, "fuse" },
- { DRIVE_REMOTE, "nfs" },
- { DRIVE_REMOTE, "nfs4" },
- { DRIVE_REMOTE, "cifs" },
- { DRIVE_REMOTE, "ncpfs" },
- { DRIVE_REMOTE, "coda" },
- { DRIVE_REMOTE, "afs" },
- { DRIVE_UNKNOWN, NULL }
-#endif
-};
-
-#if __linux__
-static guint32 _wapi_get_drive_type(long f_type)
-{
- _wapi_drive_type *current;
-
- current = &_wapi_drive_types[0];
- while (current->drive_type != DRIVE_UNKNOWN) {
- if (current->fstypeid == f_type)
- return current->drive_type;
- current++;
- }
-
- return DRIVE_UNKNOWN;
-}
-#else
-static guint32 _wapi_get_drive_type(const gchar* fstype)
-{
- _wapi_drive_type *current;
-
- current = &_wapi_drive_types[0];
- while (current->drive_type != DRIVE_UNKNOWN) {
- if (strcmp (current->fstype, fstype) == 0)
- break;
-
- current++;
- }
-
- return current->drive_type;
-}
-#endif
-
-#if defined (PLATFORM_MACOSX) || defined (__linux__)
-static guint32
-GetDriveTypeFromPath (const char *utf8_root_path_name)
-{
- struct statfs buf;
-
- if (statfs (utf8_root_path_name, &buf) == -1)
- return DRIVE_UNKNOWN;
-#if PLATFORM_MACOSX
- return _wapi_get_drive_type (buf.f_fstypename);
-#else
- return _wapi_get_drive_type (buf.f_type);
-#endif
-}
-#else
-static guint32
-GetDriveTypeFromPath (const gchar *utf8_root_path_name)
-{
- guint32 drive_type;
- FILE *fp;
- gchar buffer [512];
- gchar **splitted;
-
- fp = fopen ("/etc/mtab", "rt");
- if (fp == NULL) {
- fp = fopen ("/etc/mnttab", "rt");
- if (fp == NULL)
- return(DRIVE_UNKNOWN);
- }
-
- drive_type = DRIVE_NO_ROOT_DIR;
- while (fgets (buffer, 512, fp) != NULL) {
- splitted = g_strsplit (buffer, " ", 0);
- if (!*splitted || !*(splitted + 1) || !*(splitted + 2)) {
- g_strfreev (splitted);
- continue;
- }
-
- /* compare given root_path_name with the one from mtab,
- if length of utf8_root_path_name is zero it must be the root dir */
- if (strcmp (*(splitted + 1), utf8_root_path_name) == 0 ||
- (strcmp (*(splitted + 1), "/") == 0 && strlen (utf8_root_path_name) == 0)) {
- drive_type = _wapi_get_drive_type (*(splitted + 2));
- /* it is possible this path might be mounted again with
- a known type...keep looking */
- if (drive_type != DRIVE_UNKNOWN) {
- g_strfreev (splitted);
- break;
- }
- }
-
- g_strfreev (splitted);
- }
-
- fclose (fp);
- return drive_type;
-}
-#endif
-
-guint32 GetDriveType(const gunichar2 *root_path_name)
-{
- gchar *utf8_root_path_name;
- guint32 drive_type;
-
- if (root_path_name == NULL) {
- utf8_root_path_name = g_strdup (g_get_current_dir());
- if (utf8_root_path_name == NULL) {
- return(DRIVE_NO_ROOT_DIR);
- }
- }
- else {
- utf8_root_path_name = mono_unicode_to_external (root_path_name);
- if (utf8_root_path_name == NULL) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
- return(DRIVE_NO_ROOT_DIR);
- }
-
- /* strip trailing slash for compare below */
- if (g_str_has_suffix(utf8_root_path_name, "/") && utf8_root_path_name [1] != 0) {
- utf8_root_path_name[strlen(utf8_root_path_name) - 1] = 0;
- }
- }
- drive_type = GetDriveTypeFromPath (utf8_root_path_name);
- g_free (utf8_root_path_name);
-
- return (drive_type);
-}
-
-#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD) || defined(__native_client__) || defined(__FreeBSD_kernel__)
-static gchar*
-get_fstypename (gchar *utfpath)
-{
-#if defined (PLATFORM_MACOSX) || defined (__linux__)
- struct statfs stat;
-#if __linux__
- _wapi_drive_type *current;
-#endif
- if (statfs (utfpath, &stat) == -1)
- return NULL;
-#if PLATFORM_MACOSX
- return g_strdup (stat.f_fstypename);
-#else
- current = &_wapi_drive_types[0];
- while (current->drive_type != DRIVE_UNKNOWN) {
- if (stat.f_type == current->fstypeid)
- return g_strdup (current->fstype);
- current++;
- }
- return NULL;
-#endif
-#else
- return NULL;
-#endif
-}
-
-/* Linux has struct statfs which has a different layout */
-gboolean
-GetVolumeInformation (const gunichar2 *path, gunichar2 *volumename, int volumesize, int *outserial, int *maxcomp, int *fsflags, gunichar2 *fsbuffer, int fsbuffersize)
-{
- gchar *utfpath;
- gchar *fstypename;
- gboolean status = FALSE;
- glong len;
-
- // We only support getting the file system type
- if (fsbuffer == NULL)
- return 0;
-
- utfpath = mono_unicode_to_external (path);
- if ((fstypename = get_fstypename (utfpath)) != NULL){
- gunichar2 *ret = g_utf8_to_utf16 (fstypename, -1, NULL, &len, NULL);
- if (ret != NULL && len < fsbuffersize){
- memcpy (fsbuffer, ret, len * sizeof (gunichar2));
- fsbuffer [len] = 0;
- status = TRUE;
- }
- if (ret != NULL)
- g_free (ret);
- g_free (fstypename);
- }
- g_free (utfpath);
- return status;
-}
-#endif
-
-void
-_wapi_io_init (void)
-{
- mono_os_mutex_init (&stdhandle_mutex);
- mono_os_mutex_init (&file_share_mutex);
-
- mono_w32handle_register_ops (MONO_W32HANDLE_FILE, &_wapi_file_ops);
- mono_w32handle_register_ops (MONO_W32HANDLE_CONSOLE, &_wapi_console_ops);
- mono_w32handle_register_ops (MONO_W32HANDLE_FIND, &_wapi_find_ops);
- mono_w32handle_register_ops (MONO_W32HANDLE_PIPE, &_wapi_pipe_ops);
-
-/* mono_w32handle_register_capabilities (MONO_W32HANDLE_FILE, */
-/* MONO_W32HANDLE_CAP_WAIT); */
-/* mono_w32handle_register_capabilities (MONO_W32HANDLE_CONSOLE, */
-/* MONO_W32HANDLE_CAP_WAIT); */
-
- if (g_getenv ("MONO_STRICT_IO_EMULATION"))
- lock_while_writing = TRUE;
-}
-
-void
-_wapi_io_cleanup (void)
-{
- mono_os_mutex_destroy (&file_share_mutex);
-
- if (file_share_hash)
- g_hash_table_destroy (file_share_hash);
-}
+++ /dev/null
-/*
- * io.h: File, console and find handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_IO_H_
-#define _WAPI_IO_H_
-
-#include <stdlib.h>
-
-#include "mono/io-layer/wapi.h"
-
-G_BEGIN_DECLS
-
-typedef struct _WapiSecurityAttributes WapiSecurityAttributes;
-
-struct _WapiSecurityAttributes
-{
- guint32 nLength;
- gpointer lpSecurityDescriptor;
- gboolean bInheritHandle;
-};
-
-typedef struct _WapiOverlapped WapiOverlapped;
-
-struct _WapiOverlapped
-{
- guint32 Internal;
- guint32 InternalHigh;
- guint32 Offset;
- guint32 OffsetHigh;
- gpointer hEvent;
- gpointer handle1;
- gpointer handle2;
-};
-
-typedef void (*WapiOverlappedCB) (guint32 error, guint32 numbytes,
- WapiOverlapped *overlapped);
-
-#define GENERIC_READ 0x80000000
-#define GENERIC_WRITE 0x40000000
-#define GENERIC_EXECUTE 0x20000000
-#define GENERIC_ALL 0x10000000
-
-#define FILE_SHARE_READ 0x00000001
-#define FILE_SHARE_WRITE 0x00000002
-#define FILE_SHARE_DELETE 0x00000004
-
-#define CREATE_NEW 1
-#define CREATE_ALWAYS 2
-#define OPEN_EXISTING 3
-#define OPEN_ALWAYS 4
-#define TRUNCATE_EXISTING 5
-
-
-#define FILE_ATTRIBUTE_READONLY 0x00000001
-#define FILE_ATTRIBUTE_HIDDEN 0x00000002
-#define FILE_ATTRIBUTE_SYSTEM 0x00000004
-#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
-#define FILE_ATTRIBUTE_ARCHIVE 0x00000020
-#define FILE_ATTRIBUTE_ENCRYPTED 0x00000040
-#define FILE_ATTRIBUTE_NORMAL 0x00000080
-#define FILE_ATTRIBUTE_TEMPORARY 0x00000100
-#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
-#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
-#define FILE_ATTRIBUTE_COMPRESSED 0x00000800
-#define FILE_ATTRIBUTE_OFFLINE 0x00001000
-#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
-#define FILE_FLAG_OPEN_NO_RECALL 0x00100000
-#define FILE_FLAG_OPEN_REPARSE_POINT 0x00200000
-#define FILE_FLAG_POSIX_SEMANTICS 0x01000000
-#define FILE_FLAG_BACKUP_SEMANTICS 0x02000000
-#define FILE_FLAG_DELETE_ON_CLOSE 0x04000000
-#define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000
-#define FILE_FLAG_RANDOM_ACCESS 0x10000000
-#define FILE_FLAG_NO_BUFFERING 0x20000000
-#define FILE_FLAG_OVERLAPPED 0x40000000
-#define FILE_FLAG_WRITE_THROUGH 0x80000000
-
-#define REPLACEFILE_WRITE_THROUGH 0x00000001
-#define REPLACEFILE_IGNORE_MERGE_ERRORS 0x00000002
-
-#define MAX_PATH 260
-
-typedef enum {
- STD_INPUT_HANDLE=-10,
- STD_OUTPUT_HANDLE=-11,
- STD_ERROR_HANDLE=-12
-} WapiStdHandle;
-
-typedef enum {
- FILE_BEGIN=0,
- FILE_CURRENT=1,
- FILE_END=2
-} WapiSeekMethod;
-
-typedef enum {
- FILE_TYPE_UNKNOWN=0x0000,
- FILE_TYPE_DISK=0x0001,
- FILE_TYPE_CHAR=0x0002,
- FILE_TYPE_PIPE=0x0003,
- FILE_TYPE_REMOTE=0x8000
-} WapiFileType;
-
-typedef enum {
- DRIVE_UNKNOWN=0,
- DRIVE_NO_ROOT_DIR=1,
- DRIVE_REMOVABLE=2,
- DRIVE_FIXED=3,
- DRIVE_REMOTE=4,
- DRIVE_CDROM=5,
- DRIVE_RAMDISK=6
-} WapiDriveType;
-
-typedef enum {
- GetFileExInfoStandard=0x0000,
- GetFileExMaxInfoLevel=0x0001
-} WapiGetFileExInfoLevels;
-
-typedef struct
-{
- guint16 wYear;
- guint16 wMonth;
- guint16 wDayOfWeek;
- guint16 wDay;
- guint16 wHour;
- guint16 wMinute;
- guint16 wSecond;
- guint16 wMilliseconds;
-} WapiSystemTime;
-
-typedef struct {
-#if G_BYTE_ORDER == G_BIG_ENDIAN
- guint32 dwHighDateTime;
- guint32 dwLowDateTime;
-#else
- guint32 dwLowDateTime;
- guint32 dwHighDateTime;
-#endif
-} WapiFileTime;
-
-typedef struct
-{
- guint32 dwFileAttributes;
- WapiFileTime ftCreationTime;
- WapiFileTime ftLastAccessTime;
- WapiFileTime ftLastWriteTime;
- guint32 nFileSizeHigh;
- guint32 nFileSizeLow;
- guint32 dwReserved0;
- guint32 dwReserved1;
- gunichar2 cFileName [MAX_PATH];
- gunichar2 cAlternateFileName [14];
-} WapiFindData;
-
-typedef struct
-{
- guint32 dwFileAttributes;
- WapiFileTime ftCreationTime;
- WapiFileTime ftLastAccessTime;
- WapiFileTime ftLastWriteTime;
- guint32 nFileSizeHigh;
- guint32 nFileSizeLow;
-} WapiFileAttributesData;
-
-typedef union {
- struct {
- guint32 LowPart;
- guint32 HighPart;
- } u;
- guint64 QuadPart;
-} ULARGE_INTEGER;
-
-#define INVALID_SET_FILE_POINTER ((guint32)-1)
-#define INVALID_FILE_SIZE ((guint32)0xFFFFFFFF)
-#define INVALID_FILE_ATTRIBUTES ((guint32)-1)
-
-extern gpointer CreateFile(const gunichar2 *name, guint32 fileaccess,
- guint32 sharemode,
- WapiSecurityAttributes *security,
- guint32 createmode,
- guint32 attrs, gpointer tmplate);
-extern gboolean DeleteFile(const gunichar2 *name);
-extern gpointer GetStdHandle(WapiStdHandle stdhandle);
-extern gboolean ReadFile(gpointer handle, gpointer buffer, guint32 numbytes,
- guint32 *bytesread, WapiOverlapped *overlapped);
-extern gboolean WriteFile(gpointer handle, gconstpointer buffer,
- guint32 numbytes, guint32 *byteswritten,
- WapiOverlapped *overlapped);
-extern gboolean FlushFileBuffers(gpointer handle);
-extern gboolean SetEndOfFile(gpointer handle);
-extern guint32 SetFilePointer(gpointer handle, gint32 movedistance,
- gint32 *highmovedistance, guint32 method);
-extern WapiFileType GetFileType(gpointer handle);
-extern guint32 GetFileSize(gpointer handle, guint32 *highsize);
-extern gboolean GetFileTime(gpointer handle, WapiFileTime *create_time,
- WapiFileTime *last_access,
- WapiFileTime *last_write);
-extern gboolean SetFileTime(gpointer handle, const WapiFileTime *create_time,
- const WapiFileTime *last_access,
- const WapiFileTime *last_write);
-extern gboolean FileTimeToSystemTime(const WapiFileTime *file_time,
- WapiSystemTime *system_time);
-extern gpointer FindFirstFile (const gunichar2 *pattern,
- WapiFindData *find_data);
-extern gboolean FindNextFile (gpointer handle, WapiFindData *find_data);
-extern gboolean FindClose (gpointer handle);
-extern gboolean CreateDirectory (const gunichar2 *name,
- WapiSecurityAttributes *security);
-extern gboolean RemoveDirectory (const gunichar2 *name);
-extern gboolean MoveFile (const gunichar2 *name, const gunichar2 *dest_name);
-extern gboolean CopyFile (const gunichar2 *name, const gunichar2 *dest_name,
- gboolean fail_if_exists);
-extern gboolean ReplaceFile (const gunichar2 *replacedFileName, const gunichar2 *replacementFileName,
- const gunichar2 *backupFileName, guint32 replaceFlags,
- gpointer exclude, gpointer reserved);
-extern guint32 GetFileAttributes (const gunichar2 *name);
-extern gboolean GetFileAttributesEx (const gunichar2 *name,
- WapiGetFileExInfoLevels level,
- gpointer info);
-extern gboolean SetFileAttributes (const gunichar2 *name, guint32 attrs);
-extern guint32 GetCurrentDirectory (guint32 length, gunichar2 *buffer);
-extern gboolean SetCurrentDirectory (const gunichar2 *path);
-extern gboolean CreatePipe (gpointer *readpipe, gpointer *writepipe,
- WapiSecurityAttributes *security, guint32 size);
-extern gint32 GetLogicalDriveStrings (guint32 len, gunichar2 *buf);
-extern gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, ULARGE_INTEGER *free_bytes_avail,
- ULARGE_INTEGER *total_number_of_bytes,
- ULARGE_INTEGER *total_number_of_free_bytes);
-extern guint32 GetDriveType(const gunichar2 *root_path_name);
-extern gboolean LockFile (gpointer handle, guint32 offset_low,
- guint32 offset_high, guint32 length_low,
- guint32 length_high);
-extern gboolean UnlockFile (gpointer handle, guint32 offset_low,
- guint32 offset_high, guint32 length_low,
- guint32 length_high);
-extern gboolean GetVolumeInformation (const gunichar2 *path, gunichar2 *volumename, int volumesize, int *outserial, int *maxcomp, int *fsflags, gunichar2 *fsbuffer, int fsbuffersize);
-
-
-extern void _wapi_io_init (void);
-extern void _wapi_io_cleanup (void);
-
-G_END_DECLS
-
-#endif /* _WAPI_IO_H_ */
+++ /dev/null
-/*
- * io.c: File, console and find handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- * Copyright (c) 2002-2009 Novell, Inc.
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-#include <config.h>
-#include <stdio.h>
-#include <glib.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <mono/io-layer/wapi.h>
-#include <mono/io-layer/wapi-private.h>
-#include <mono/io-layer/io-private.h>
-#include <mono/io-layer/io-trace.h>
-#include <mono/utils/mono-logger-internals.h>
-#include <mono/metadata/w32handle.h>
-
-gboolean
-_wapi_lock_file_region (int fd, off_t offset, off_t length)
-{
-#if defined(__native_client__)
- printf("WARNING: locking.c: _wapi_lock_file_region(): fcntl() not available on Native Client!\n");
- // behave as below -- locks are not available
- return(TRUE);
-#else
- struct flock lock_data;
- int ret;
-
- if (offset < 0 || length < 0) {
- SetLastError (ERROR_INVALID_PARAMETER);
- return(FALSE);
- }
-
- lock_data.l_type = F_WRLCK;
- lock_data.l_whence = SEEK_SET;
- lock_data.l_start = offset;
- lock_data.l_len = length;
-
- do {
- ret = fcntl (fd, F_SETLK, &lock_data);
- } while(ret == -1 && errno == EINTR);
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fcntl returns %d", __func__, ret);
-
- if (ret == -1) {
- /*
- * if locks are not available (NFS for example),
- * ignore the error
- */
- if (errno == ENOLCK
-#ifdef EOPNOTSUPP
- || errno == EOPNOTSUPP
-#endif
-#ifdef ENOTSUP
- || errno == ENOTSUP
-#endif
- ) {
- return (TRUE);
- }
-
- SetLastError (ERROR_LOCK_VIOLATION);
- return(FALSE);
- }
-
- return(TRUE);
-#endif /* __native_client__ */
-}
-
-gboolean
-_wapi_unlock_file_region (int fd, off_t offset, off_t length)
-{
-#if defined(__native_client__)
- printf("WARNING: locking.c: _wapi_unlock_file_region(): fcntl() not available on Native Client!\n");
- return (TRUE);
-#else
- struct flock lock_data;
- int ret;
-
- lock_data.l_type = F_UNLCK;
- lock_data.l_whence = SEEK_SET;
- lock_data.l_start = offset;
- lock_data.l_len = length;
-
- do {
- ret = fcntl (fd, F_SETLK, &lock_data);
- } while(ret == -1 && errno == EINTR);
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fcntl returns %d", __func__, ret);
-
- if (ret == -1) {
- /*
- * if locks are not available (NFS for example),
- * ignore the error
- */
- if (errno == ENOLCK
-#ifdef EOPNOTSUPP
- || errno == EOPNOTSUPP
-#endif
-#ifdef ENOTSUP
- || errno == ENOTSUP
-#endif
- ) {
- return (TRUE);
- }
-
- SetLastError (ERROR_LOCK_VIOLATION);
- return(FALSE);
- }
-
- return(TRUE);
-#endif /* __native_client__ */
-}
-
-gboolean
-LockFile (gpointer handle, guint32 offset_low, guint32 offset_high,
- guint32 length_low, guint32 length_high)
-{
- struct _WapiHandle_file *file_handle;
- gboolean ok;
- off_t offset, length;
- int fd = GPOINTER_TO_UINT(handle);
-
- ok = mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
- (gpointer *)&file_handle);
- if (ok == FALSE) {
- g_warning ("%s: error looking up file handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- if (!(file_handle->fileaccess & GENERIC_READ) &&
- !(file_handle->fileaccess & GENERIC_WRITE) &&
- !(file_handle->fileaccess & GENERIC_ALL)) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
- SetLastError (ERROR_ACCESS_DENIED);
- return(FALSE);
- }
-
-#ifdef HAVE_LARGE_FILE_SUPPORT
- offset = ((gint64)offset_high << 32) | offset_low;
- length = ((gint64)length_high << 32) | length_low;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Locking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
-#else
- if (offset_high > 0 || length_high > 0) {
- SetLastError (ERROR_INVALID_PARAMETER);
- return (FALSE);
- }
- offset = offset_low;
- length = length_low;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Locking handle %p, offset %ld, length %ld", __func__,
- handle, offset, length);
-#endif
-
- return(_wapi_lock_file_region (fd, offset, length));
-}
-
-gboolean
-UnlockFile (gpointer handle, guint32 offset_low,
- guint32 offset_high, guint32 length_low,
- guint32 length_high)
-{
- struct _WapiHandle_file *file_handle;
- gboolean ok;
- off_t offset, length;
- int fd = GPOINTER_TO_UINT(handle);
-
- ok = mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
- (gpointer *)&file_handle);
- if (ok == FALSE) {
- g_warning ("%s: error looking up file handle %p", __func__,
- handle);
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- if (!(file_handle->fileaccess & GENERIC_READ) &&
- !(file_handle->fileaccess & GENERIC_WRITE) &&
- !(file_handle->fileaccess & GENERIC_ALL)) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
- SetLastError (ERROR_ACCESS_DENIED);
- return(FALSE);
- }
-
-#ifdef HAVE_LARGE_FILE_SUPPORT
- offset = ((gint64)offset_high << 32) | offset_low;
- length = ((gint64)length_high << 32) | length_low;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unlocking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
-#else
- offset = offset_low;
- length = length_low;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unlocking handle %p, offset %ld, length %ld", __func__, handle, offset, length);
-#endif
-
- return(_wapi_unlock_file_region (fd, offset, length));
-}
+++ /dev/null
-/*
- * posix.c: Posix-specific support.
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- * Copyright (c) 2002-2009 Novell, Inc.
- * Copyright 2011 Xamarin Inc
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-
-#include <config.h>
-#include <glib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <stdio.h>
-
-#include <mono/io-layer/wapi.h>
-#include <mono/io-layer/wapi-private.h>
-#include <mono/io-layer/io-private.h>
-#include <mono/io-layer/io-trace.h>
-#include <mono/utils/mono-logger-internals.h>
-#include <mono/metadata/w32handle.h>
-
-static guint32
-convert_from_flags(int flags)
-{
- guint32 fileaccess=0;
-
-#ifndef O_ACCMODE
-#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
-#endif
-
- if((flags & O_ACCMODE) == O_RDONLY) {
- fileaccess=GENERIC_READ;
- } else if ((flags & O_ACCMODE) == O_WRONLY) {
- fileaccess=GENERIC_WRITE;
- } else if ((flags & O_ACCMODE) == O_RDWR) {
- fileaccess=GENERIC_READ|GENERIC_WRITE;
- } else {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't figure out flags 0x%x", __func__, flags);
- }
-
- /* Maybe sort out create mode too */
-
- return(fileaccess);
-}
-
-
-gpointer _wapi_stdhandle_create (int fd, const gchar *name)
-{
- struct _WapiHandle_file file_handle = {0};
- gpointer handle;
- int flags;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating standard handle type %s, fd %d", __func__,
- name, fd);
-
-#if !defined(__native_client__)
- /* Check if fd is valid */
- do {
- flags=fcntl(fd, F_GETFL);
- } while (flags == -1 && errno == EINTR);
-
- if(flags==-1) {
- /* Invalid fd. Not really much point checking for EBADF
- * specifically
- */
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fcntl error on fd %d: %s", __func__, fd,
- strerror(errno));
-
- SetLastError (_wapi_get_win32_file_error (errno));
- return(INVALID_HANDLE_VALUE);
- }
- file_handle.fileaccess=convert_from_flags(flags);
-#else
- /*
- * fcntl will return -1 in nacl, as there is no real file system API.
- * Yet, standard streams are available.
- */
- file_handle.fileaccess = (fd == STDIN_FILENO) ? GENERIC_READ : GENERIC_WRITE;
-#endif
-
- file_handle.fd = fd;
- file_handle.filename = g_strdup(name);
- /* some default security attributes might be needed */
- file_handle.security_attributes=0;
-
- /* Apparently input handles can't be written to. (I don't
- * know if output or error handles can't be read from.)
- */
- if (fd == 0) {
- file_handle.fileaccess &= ~GENERIC_WRITE;
- }
-
- file_handle.sharemode=0;
- file_handle.attrs=0;
-
- handle = mono_w32handle_new_fd (MONO_W32HANDLE_CONSOLE, fd, &file_handle);
- if (handle == INVALID_HANDLE_VALUE) {
- g_warning ("%s: error creating file handle", __func__);
- SetLastError (ERROR_GEN_FAILURE);
- return(INVALID_HANDLE_VALUE);
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning handle %p", __func__, handle);
-
- return(handle);
-}
-
+++ /dev/null
-/*
- * socket-private.h: Private definitions for socket handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_SOCKET_PRIVATE_H_
-#define _WAPI_SOCKET_PRIVATE_H_
-
-#include <config.h>
-#include <glib.h>
-
-#include "wapi-private.h"
-
-struct _WapiHandle_socket
-{
- int domain;
- int type;
- int protocol;
- int saved_error;
- int still_readable;
-};
-
-void
-_wapi_socket_init (void);
-
-#endif /* _WAPI_SOCKET_PRIVATE_H_ */
+++ /dev/null
-/*
- * Special header file to be included only in selected C files.
- * We need to use the _wapi_ equivalents of the socket API when
- * working with io-layer handles. On windows we define the wrappers to use
- * the normal win32 functions.
- */
-
-#include <config.h>
-#ifdef HAVE_SYS_SELECT_H
-# include <sys/select.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-
-#ifndef HAVE_SOCKLEN_T
-#define socklen_t int
-#endif
-
-#ifdef HOST_WIN32
-#define _wapi_accept accept
-#define _wapi_bind bind
-#define _wapi_connect connect
-#define _wapi_getpeername getpeername
-#define _wapi_getsockname getsockname
-#define _wapi_getsockopt getsockopt
-#define _wapi_listen listen
-#define _wapi_recv recv
-#define _wapi_recvfrom recvfrom
-#define _wapi_send send
-#define _wapi_sendto sendto
-#define _wapi_setsockopt setsockopt
-#define _wapi_shutdown shutdown
-#define _wapi_socket WSASocket
-#define _wapi_select select
-
-/* No need to wrap FD_ZERO because it doesnt involve file
- * descriptors
-*/
-#define _wapi_FD_CLR FD_CLR
-#define _wapi_FD_ISSET FD_ISSET
-#define _wapi_FD_SET FD_SET
-
-#define _wapi_cleanup_networking() ;
-#else
-
-#define WSA_FLAG_OVERLAPPED 0x01
-
-extern guint32 _wapi_accept(guint32 handle, struct sockaddr *addr,
- socklen_t *addrlen);
-extern int _wapi_bind(guint32 handle, struct sockaddr *my_addr,
- socklen_t addrlen);
-extern int _wapi_connect(guint32 handle, const struct sockaddr *serv_addr,
- socklen_t addrlen);
-extern int _wapi_getpeername(guint32 handle, struct sockaddr *name,
- socklen_t *namelen);
-extern int _wapi_getsockname(guint32 handle, struct sockaddr *name,
- socklen_t *namelen);
-extern int _wapi_getsockopt(guint32 handle, int level, int optname,
- void *optval, socklen_t *optlen);
-extern int _wapi_listen(guint32 handle, int backlog);
-extern int _wapi_recv(guint32 handle, void *buf, size_t len, int recv_flags);
-extern int _wapi_recvfrom(guint32 handle, void *buf, size_t len,
- int recv_flags, struct sockaddr *from,
- socklen_t *fromlen);
-extern int _wapi_send(guint32 handle, const void *msg, size_t len,
- int send_flags);
-extern int _wapi_sendto(guint32 handle, const void *msg, size_t len,
- int send_flags, const struct sockaddr *to,
- socklen_t tolen);
-extern int _wapi_setsockopt(guint32 handle, int level, int optname,
- const void *optval, socklen_t optlen);
-extern int _wapi_shutdown(guint32 handle, int how);
-extern guint32 _wapi_socket(int domain, int type, int protocol, void *unused,
- guint32 unused2, guint32 flags);
-
-#ifdef HAVE_SYS_SELECT_H
-extern int _wapi_select(int nfds, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout);
-
-extern void _wapi_FD_CLR(guint32 handle, fd_set *set);
-extern int _wapi_FD_ISSET(guint32 handle, fd_set *set);
-extern void _wapi_FD_SET(guint32 handle, fd_set *set);
-#endif
-
-extern void _wapi_cleanup_networking (void);
-#endif /* HOST_WIN32 */
-
+++ /dev/null
-/*
- * sockets.c: Socket handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#include <config.h>
-
-#ifndef DISABLE_SOCKETS
-
-#include <glib.h>
-#include <pthread.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#ifdef HAVE_SYS_UIO_H
-# include <sys/uio.h>
-#endif
-#ifdef HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
-#endif
-#ifdef HAVE_SYS_FILIO_H
-#include <sys/filio.h> /* defines FIONBIO and FIONREAD */
-#endif
-#ifdef HAVE_SYS_SOCKIO_H
-#include <sys/sockio.h> /* defines SIOCATMARK */
-#endif
-#include <unistd.h>
-#include <fcntl.h>
-
-#ifndef HAVE_MSG_NOSIGNAL
-#include <signal.h>
-#endif
-
-#include <mono/io-layer/wapi.h>
-#include <mono/io-layer/wapi-private.h>
-#include <mono/io-layer/socket-private.h>
-#include <mono/io-layer/socket-wrappers.h>
-#include <mono/io-layer/io-trace.h>
-#include <mono/utils/mono-poll.h>
-#include <mono/utils/mono-once.h>
-#include <mono/utils/mono-logger-internals.h>
-#include <mono/metadata/w32handle.h>
-
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#ifdef HAVE_SYS_SENDFILE_H
-#include <sys/sendfile.h>
-#endif
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-
-static guint32 in_cleanup = 0;
-
-static void socket_close (gpointer handle, gpointer data);
-static void socket_details (gpointer data);
-static const gchar* socket_typename (void);
-static gsize socket_typesize (void);
-
-static MonoW32HandleOps _wapi_socket_ops = {
- socket_close, /* close */
- NULL, /* signal */
- NULL, /* own */
- NULL, /* is_owned */
- NULL, /* special_wait */
- NULL, /* prewait */
- socket_details, /* details */
- socket_typename, /* typename */
- socket_typesize, /* typesize */
-};
-
-void
-_wapi_socket_init (void)
-{
- mono_w32handle_register_ops (MONO_W32HANDLE_SOCKET, &_wapi_socket_ops);
-}
-
-static void socket_close (gpointer handle, gpointer data)
-{
- int ret;
- struct _WapiHandle_socket *socket_handle = (struct _WapiHandle_socket *)data;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing socket handle %p", __func__, handle);
-
- /* Shutdown the socket for reading, to interrupt any potential
- * receives that may be blocking for data. See bug 75705.
- */
- shutdown (GPOINTER_TO_UINT (handle), SHUT_RD);
-
- do {
- ret = close (GPOINTER_TO_UINT(handle));
- } while (ret == -1 && errno == EINTR &&
- !mono_thread_info_is_interrupt_state (info));
-
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: close error: %s", __func__, strerror (errno));
- errnum = errno_to_WSA (errnum, __func__);
- if (!in_cleanup)
- WSASetLastError (errnum);
- }
-
- if (!in_cleanup)
- socket_handle->saved_error = 0;
-}
-
-static void socket_details (gpointer data)
-{
- /* FIXME: do something */
-}
-
-static const gchar* socket_typename (void)
-{
- return "Socket";
-}
-
-static gsize socket_typesize (void)
-{
- return sizeof (struct _WapiHandle_socket);
-}
-
-static gboolean
-cleanup_close (gpointer handle, gpointer data, gpointer user_data)
-{
- if (mono_w32handle_get_type (handle) == MONO_W32HANDLE_SOCKET)
- mono_w32handle_force_close (handle, data);
-
- return FALSE;
-}
-
-void _wapi_cleanup_networking(void)
-{
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: cleaning up", __func__);
-
- in_cleanup = 1;
- mono_w32handle_foreach (cleanup_close, NULL);
- in_cleanup = 0;
-}
-
-void WSASetLastError(int error)
-{
- SetLastError (error);
-}
-
-int WSAGetLastError(void)
-{
- return(GetLastError ());
-}
-
-int closesocket(guint32 fd)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(0);
- }
-
- mono_w32handle_unref (handle);
- return(0);
-}
-
-guint32 _wapi_accept(guint32 fd, struct sockaddr *addr, socklen_t *addrlen)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
- gpointer new_handle;
- struct _WapiHandle_socket *socket_handle;
- struct _WapiHandle_socket new_socket_handle = {0};
- gboolean ok;
- int new_fd;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- if (addr != NULL && *addrlen < sizeof(struct sockaddr)) {
- WSASetLastError (WSAEFAULT);
- return(INVALID_SOCKET);
- }
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(INVALID_SOCKET);
- }
-
- ok = mono_w32handle_lookup (handle, MONO_W32HANDLE_SOCKET,
- (gpointer *)&socket_handle);
- if (ok == FALSE) {
- g_warning ("%s: error looking up socket handle %p",
- __func__, handle);
- WSASetLastError (WSAENOTSOCK);
- return(INVALID_SOCKET);
- }
-
- do {
- new_fd = accept (fd, addr, addrlen);
- } while (new_fd == -1 && errno == EINTR &&
- !mono_thread_info_is_interrupt_state (info));
-
- if (new_fd == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: accept error: %s", __func__, strerror(errno));
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(INVALID_SOCKET);
- }
-
- if (new_fd >= mono_w32handle_fd_reserve) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big", __func__);
-
- WSASetLastError (WSASYSCALLFAILURE);
-
- close (new_fd);
-
- return(INVALID_SOCKET);
- }
-
- new_socket_handle.domain = socket_handle->domain;
- new_socket_handle.type = socket_handle->type;
- new_socket_handle.protocol = socket_handle->protocol;
- new_socket_handle.still_readable = 1;
-
- new_handle = mono_w32handle_new_fd (MONO_W32HANDLE_SOCKET, new_fd,
- &new_socket_handle);
- if(new_handle == INVALID_HANDLE_VALUE) {
- g_warning ("%s: error creating socket handle", __func__);
- WSASetLastError (ERROR_GEN_FAILURE);
- return(INVALID_SOCKET);
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning newly accepted socket handle %p with",
- __func__, new_handle);
-
- return(new_fd);
-}
-
-int _wapi_bind(guint32 fd, struct sockaddr *my_addr, socklen_t addrlen)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
- int ret;
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(SOCKET_ERROR);
- }
-
- ret = bind (fd, my_addr, addrlen);
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: bind error: %s", __func__, strerror(errno));
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(SOCKET_ERROR);
- }
- return(ret);
-}
-
-int _wapi_connect(guint32 fd, const struct sockaddr *serv_addr,
- socklen_t addrlen)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
- struct _WapiHandle_socket *socket_handle;
- gboolean ok;
- gint errnum;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(SOCKET_ERROR);
- }
-
- if (connect (fd, serv_addr, addrlen) == -1) {
- mono_pollfd fds;
- int so_error;
- socklen_t len;
-
- errnum = errno;
-
- if (errno != EINTR) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect error: %s", __func__,
- strerror (errnum));
-
- errnum = errno_to_WSA (errnum, __func__);
- if (errnum == WSAEINPROGRESS)
- errnum = WSAEWOULDBLOCK; /* see bug #73053 */
-
- WSASetLastError (errnum);
-
- /*
- * On solaris x86 getsockopt (SO_ERROR) is not set after
- * connect () fails so we need to save this error.
- *
- * But don't do this for EWOULDBLOCK (bug 317315)
- */
- if (errnum != WSAEWOULDBLOCK) {
- ok = mono_w32handle_lookup (handle,
- MONO_W32HANDLE_SOCKET,
- (gpointer *)&socket_handle);
- if (ok == FALSE) {
- /* ECONNRESET means the socket was closed by another thread */
- /* Async close on mac raises ECONNABORTED. */
- if (errnum != WSAECONNRESET && errnum != WSAENETDOWN)
- g_warning ("%s: error looking up socket handle %p (error %d)", __func__, handle, errnum);
- } else {
- socket_handle->saved_error = errnum;
- }
- }
- return(SOCKET_ERROR);
- }
-
- fds.fd = fd;
- fds.events = MONO_POLLOUT;
- while (mono_poll (&fds, 1, -1) == -1 &&
- !mono_thread_info_is_interrupt_state (info)) {
- if (errno != EINTR) {
- errnum = errno_to_WSA (errno, __func__);
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect poll error: %s",
- __func__, strerror (errno));
-
- WSASetLastError (errnum);
- return(SOCKET_ERROR);
- }
- }
-
- len = sizeof(so_error);
- if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &so_error,
- &len) == -1) {
- errnum = errno_to_WSA (errno, __func__);
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect getsockopt error: %s",
- __func__, strerror (errno));
-
- WSASetLastError (errnum);
- return(SOCKET_ERROR);
- }
-
- if (so_error != 0) {
- errnum = errno_to_WSA (so_error, __func__);
-
- /* Need to save this socket error */
- ok = mono_w32handle_lookup (handle, MONO_W32HANDLE_SOCKET,
- (gpointer *)&socket_handle);
- if (ok == FALSE) {
- g_warning ("%s: error looking up socket handle %p", __func__, handle);
- } else {
- socket_handle->saved_error = errnum;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect getsockopt returned error: %s",
- __func__, strerror (so_error));
-
- WSASetLastError (errnum);
- return(SOCKET_ERROR);
- }
- }
-
- return(0);
-}
-
-int _wapi_getpeername(guint32 fd, struct sockaddr *name, socklen_t *namelen)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
- int ret;
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(SOCKET_ERROR);
- }
-
- ret = getpeername (fd, name, namelen);
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: getpeername error: %s", __func__,
- strerror (errno));
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(SOCKET_ERROR);
- }
-
- return(ret);
-}
-
-int _wapi_getsockname(guint32 fd, struct sockaddr *name, socklen_t *namelen)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
- int ret;
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(SOCKET_ERROR);
- }
-
- ret = getsockname (fd, name, namelen);
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: getsockname error: %s", __func__,
- strerror (errno));
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(SOCKET_ERROR);
- }
-
- return(ret);
-}
-
-int _wapi_getsockopt(guint32 fd, int level, int optname, void *optval,
- socklen_t *optlen)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
- int ret;
- struct timeval tv;
- void *tmp_val;
- struct _WapiHandle_socket *socket_handle;
- gboolean ok;
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(SOCKET_ERROR);
- }
-
- tmp_val = optval;
- if (level == SOL_SOCKET &&
- (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)) {
- tmp_val = &tv;
- *optlen = sizeof (tv);
- }
-
- ret = getsockopt (fd, level, optname, tmp_val, optlen);
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: getsockopt error: %s", __func__,
- strerror (errno));
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(SOCKET_ERROR);
- }
-
- if (level == SOL_SOCKET &&
- (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)) {
- *((int *) optval) = tv.tv_sec * 1000 + (tv.tv_usec / 1000); // milli from micro
- *optlen = sizeof (int);
- }
-
- if (optname == SO_ERROR) {
- ok = mono_w32handle_lookup (handle, MONO_W32HANDLE_SOCKET,
- (gpointer *)&socket_handle);
- if (ok == FALSE) {
- g_warning ("%s: error looking up socket handle %p",
- __func__, handle);
-
- /* can't extract the last error */
- *((int *) optval) = errno_to_WSA (*((int *)optval),
- __func__);
- } else {
- if (*((int *)optval) != 0) {
- *((int *) optval) = errno_to_WSA (*((int *)optval),
- __func__);
- socket_handle->saved_error = *((int *)optval);
- } else {
- *((int *)optval) = socket_handle->saved_error;
- }
- }
- }
-
- return(ret);
-}
-
-int _wapi_listen(guint32 fd, int backlog)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
- int ret;
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(SOCKET_ERROR);
- }
-
- ret = listen (fd, backlog);
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: listen error: %s", __func__, strerror (errno));
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(SOCKET_ERROR);
- }
-
- return(0);
-}
-
-int _wapi_recv(guint32 fd, void *buf, size_t len, int recv_flags)
-{
- return(_wapi_recvfrom (fd, buf, len, recv_flags, NULL, 0));
-}
-
-int _wapi_recvfrom(guint32 fd, void *buf, size_t len, int recv_flags,
- struct sockaddr *from, socklen_t *fromlen)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
- struct _WapiHandle_socket *socket_handle;
- gboolean ok;
- int ret;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(SOCKET_ERROR);
- }
-
- do {
- ret = recvfrom (fd, buf, len, recv_flags, from, fromlen);
- } while (ret == -1 && errno == EINTR &&
- !mono_thread_info_is_interrupt_state (info));
-
- if (ret == 0 && len > 0) {
- /* According to the Linux man page, recvfrom only
- * returns 0 when the socket has been shut down
- * cleanly. Turn this into an EINTR to simulate win32
- * behaviour of returning EINTR when a socket is
- * closed while the recvfrom is blocking (we use a
- * shutdown() in socket_close() to trigger this.) See
- * bug 75705.
- */
- /* Distinguish between the socket being shut down at
- * the local or remote ends, and reads that request 0
- * bytes to be read
- */
-
- /* If this returns FALSE, it means the socket has been
- * closed locally. If it returns TRUE, but
- * still_readable != 1 then shutdown
- * (SHUT_RD|SHUT_RDWR) has been called locally.
- */
- ok = mono_w32handle_lookup (handle, MONO_W32HANDLE_SOCKET,
- (gpointer *)&socket_handle);
- if (ok == FALSE || socket_handle->still_readable != 1) {
- ret = -1;
- errno = EINTR;
- }
- }
-
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: recv error: %s", __func__, strerror(errno));
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(SOCKET_ERROR);
- }
- return(ret);
-}
-
-static int
-_wapi_recvmsg(guint32 fd, struct msghdr *msg, int recv_flags)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
- struct _WapiHandle_socket *socket_handle;
- gboolean ok;
- int ret;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(SOCKET_ERROR);
- }
-
- do {
- ret = recvmsg (fd, msg, recv_flags);
- } while (ret == -1 && errno == EINTR &&
- !mono_thread_info_is_interrupt_state (info));
-
- if (ret == 0) {
- /* see _wapi_recvfrom */
- ok = mono_w32handle_lookup (handle, MONO_W32HANDLE_SOCKET,
- (gpointer *)&socket_handle);
- if (ok == FALSE || socket_handle->still_readable != 1) {
- ret = -1;
- errno = EINTR;
- }
- }
-
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: recvmsg error: %s", __func__, strerror(errno));
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(SOCKET_ERROR);
- }
- return(ret);
-}
-
-int _wapi_send(guint32 fd, const void *msg, size_t len, int send_flags)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
- int ret;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(SOCKET_ERROR);
- }
-
- do {
- ret = send (fd, msg, len, send_flags);
- } while (ret == -1 && errno == EINTR &&
- !mono_thread_info_is_interrupt_state (info));
-
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: send error: %s", __func__, strerror (errno));
-
-#ifdef O_NONBLOCK
- /* At least linux returns EAGAIN/EWOULDBLOCK when the timeout has been set on
- * a blocking socket. See bug #599488 */
- if (errnum == EAGAIN) {
- ret = fcntl (fd, F_GETFL, 0);
- if (ret != -1 && (ret & O_NONBLOCK) == 0)
- errnum = ETIMEDOUT;
- }
-#endif /* O_NONBLOCK */
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(SOCKET_ERROR);
- }
- return(ret);
-}
-
-int _wapi_sendto(guint32 fd, const void *msg, size_t len, int send_flags,
- const struct sockaddr *to, socklen_t tolen)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
- int ret;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(SOCKET_ERROR);
- }
-
- do {
- ret = sendto (fd, msg, len, send_flags, to, tolen);
- } while (ret == -1 && errno == EINTR &&
- !mono_thread_info_is_interrupt_state (info));
-
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: send error: %s", __func__, strerror (errno));
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(SOCKET_ERROR);
- }
- return(ret);
-}
-
-static int
-_wapi_sendmsg(guint32 fd, const struct msghdr *msg, int send_flags)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
- int ret;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(SOCKET_ERROR);
- }
-
- do {
- ret = sendmsg (fd, msg, send_flags);
- } while (ret == -1 && errno == EINTR &&
- !mono_thread_info_is_interrupt_state (info));
-
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sendmsg error: %s", __func__, strerror (errno));
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(SOCKET_ERROR);
- }
- return(ret);
-}
-
-int _wapi_setsockopt(guint32 fd, int level, int optname,
- const void *optval, socklen_t optlen)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
- int ret;
- const void *tmp_val;
-#if defined (__linux__)
- /* This has its address taken so it cannot be moved to the if block which uses it */
- int bufsize = 0;
-#endif
- struct timeval tv;
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(SOCKET_ERROR);
- }
-
- tmp_val = optval;
- if (level == SOL_SOCKET &&
- (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)) {
- int ms = *((int *) optval);
- tv.tv_sec = ms / 1000;
- tv.tv_usec = (ms % 1000) * 1000; // micro from milli
- tmp_val = &tv;
- optlen = sizeof (tv);
- }
-#if defined (__linux__)
- else if (level == SOL_SOCKET &&
- (optname == SO_SNDBUF || optname == SO_RCVBUF)) {
- /* According to socket(7) the Linux kernel doubles the
- * buffer sizes "to allow space for bookkeeping
- * overhead."
- */
- bufsize = *((int *) optval);
-
- bufsize /= 2;
- tmp_val = &bufsize;
- }
-#endif
-
- ret = setsockopt (fd, level, optname, tmp_val, optlen);
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setsockopt error: %s", __func__,
- strerror (errno));
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(SOCKET_ERROR);
- }
-
-#if defined (SO_REUSEPORT)
- /* BSD's and MacOS X multicast sockets also need SO_REUSEPORT when SO_REUSEADDR is requested. */
- if (level == SOL_SOCKET && optname == SO_REUSEADDR) {
- int type;
- socklen_t type_len = sizeof (type);
-
- if (!getsockopt (fd, level, SO_TYPE, &type, &type_len)) {
- if (type == SOCK_DGRAM || type == SOCK_STREAM)
- setsockopt (fd, level, SO_REUSEPORT, tmp_val, optlen);
- }
- }
-#endif
-
- return(ret);
-}
-
-int _wapi_shutdown(guint32 fd, int how)
-{
- struct _WapiHandle_socket *socket_handle;
- gboolean ok;
- gpointer handle = GUINT_TO_POINTER (fd);
- int ret;
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(SOCKET_ERROR);
- }
-
- if (how == SHUT_RD ||
- how == SHUT_RDWR) {
- ok = mono_w32handle_lookup (handle, MONO_W32HANDLE_SOCKET,
- (gpointer *)&socket_handle);
- if (ok == FALSE) {
- g_warning ("%s: error looking up socket handle %p",
- __func__, handle);
- WSASetLastError (WSAENOTSOCK);
- return(SOCKET_ERROR);
- }
-
- socket_handle->still_readable = 0;
- }
-
- ret = shutdown (fd, how);
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: shutdown error: %s", __func__,
- strerror (errno));
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(SOCKET_ERROR);
- }
-
- return(ret);
-}
-
-guint32 _wapi_socket(int domain, int type, int protocol, void *unused,
- guint32 unused2, guint32 unused3)
-{
- struct _WapiHandle_socket socket_handle = {0};
- gpointer handle;
- int fd;
-
- socket_handle.domain = domain;
- socket_handle.type = type;
- socket_handle.protocol = protocol;
- socket_handle.still_readable = 1;
-
- fd = socket (domain, type, protocol);
- if (fd == -1 && domain == AF_INET && type == SOCK_RAW &&
- protocol == 0) {
- /* Retry with protocol == 4 (see bug #54565) */
- // https://bugzilla.novell.com/show_bug.cgi?id=MONO54565
- socket_handle.protocol = 4;
- fd = socket (AF_INET, SOCK_RAW, 4);
- }
-
- if (fd == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: socket error: %s", __func__, strerror (errno));
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(INVALID_SOCKET);
- }
-
- if (fd >= mono_w32handle_fd_reserve) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big (%d >= %d)",
- __func__, fd, mono_w32handle_fd_reserve);
-
- WSASetLastError (WSASYSCALLFAILURE);
- close (fd);
-
- return(INVALID_SOCKET);
- }
-
- /* .net seems to set this by default for SOCK_STREAM, not for
- * SOCK_DGRAM (see bug #36322)
- * https://bugzilla.novell.com/show_bug.cgi?id=MONO36322
- *
- * It seems winsock has a rather different idea of what
- * SO_REUSEADDR means. If it's set, then a new socket can be
- * bound over an existing listening socket. There's a new
- * windows-specific option called SO_EXCLUSIVEADDRUSE but
- * using that means the socket MUST be closed properly, or a
- * denial of service can occur. Luckily for us, winsock
- * behaves as though any other system would when SO_REUSEADDR
- * is true, so we don't need to do anything else here. See
- * bug 53992.
- * https://bugzilla.novell.com/show_bug.cgi?id=MONO53992
- */
- {
- int ret, true_ = 1;
-
- ret = setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &true_,
- sizeof (true_));
- if (ret == -1) {
- int errnum = errno;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error setting SO_REUSEADDR", __func__);
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- close (fd);
-
- return(INVALID_SOCKET);
- }
- }
-
-
- handle = mono_w32handle_new_fd (MONO_W32HANDLE_SOCKET, fd, &socket_handle);
- if (handle == INVALID_HANDLE_VALUE) {
- g_warning ("%s: error creating socket handle", __func__);
- WSASetLastError (WSASYSCALLFAILURE);
- close (fd);
- return(INVALID_SOCKET);
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning socket handle %p", __func__, handle);
-
- return(fd);
-}
-
-static gboolean socket_disconnect (guint32 fd)
-{
- struct _WapiHandle_socket *socket_handle;
- gboolean ok;
- gpointer handle = GUINT_TO_POINTER (fd);
- int newsock, ret;
-
- ok = mono_w32handle_lookup (handle, MONO_W32HANDLE_SOCKET,
- (gpointer *)&socket_handle);
- if (ok == FALSE) {
- g_warning ("%s: error looking up socket handle %p", __func__,
- handle);
- WSASetLastError (WSAENOTSOCK);
- return(FALSE);
- }
-
- newsock = socket (socket_handle->domain, socket_handle->type,
- socket_handle->protocol);
- if (newsock == -1) {
- gint errnum = errno;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: socket error: %s", __func__, strerror (errno));
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(FALSE);
- }
-
- /* According to Stevens "Advanced Programming in the UNIX
- * Environment: UNIX File I/O" dup2() is atomic so there
- * should not be a race condition between the old fd being
- * closed and the new socket fd being copied over
- */
- do {
- ret = dup2 (newsock, fd);
- } while (ret == -1 && errno == EAGAIN);
-
- if (ret == -1) {
- gint errnum = errno;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: dup2 error: %s", __func__, strerror (errno));
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(FALSE);
- }
-
- close (newsock);
-
- return(TRUE);
-}
-
-static gboolean wapi_disconnectex (guint32 fd, WapiOverlapped *overlapped,
- guint32 flags, guint32 reserved)
-{
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: called on socket %d!", __func__, fd);
-
- if (reserved != 0) {
- WSASetLastError (WSAEINVAL);
- return(FALSE);
- }
-
- /* We could check the socket type here and fail unless its
- * SOCK_STREAM, SOCK_SEQPACKET or SOCK_RDM (according to msdn)
- * if we really wanted to
- */
-
- return(socket_disconnect (fd));
-}
-
-#define SF_BUFFER_SIZE 16384
-static gint
-wapi_sendfile (guint32 socket, gpointer fd, guint32 bytes_to_write, guint32 bytes_per_send, guint32 flags)
-{
- MonoThreadInfo *info = mono_thread_info_current ();
-#if defined(HAVE_SENDFILE) && (defined(__linux__) || defined(DARWIN))
- gint file = GPOINTER_TO_INT (fd);
- gint n;
- gint errnum;
- gssize res;
- struct stat statbuf;
-
- n = fstat (file, &statbuf);
- if (n == -1) {
- errnum = errno;
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
- return SOCKET_ERROR;
- }
- do {
-#ifdef __linux__
- res = sendfile (socket, file, NULL, statbuf.st_size);
-#elif defined(DARWIN)
- /* TODO: header/tail could be sent in the 5th argument */
- /* TODO: Might not send the entire file for non-blocking sockets */
- res = sendfile (file, socket, 0, &statbuf.st_size, NULL, 0);
-#endif
- } while (res != -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
- if (res == -1) {
- errnum = errno;
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
- return SOCKET_ERROR;
- }
-#else
- /* Default implementation */
- gint file = GPOINTER_TO_INT (fd);
- gchar *buffer;
- gint n;
-
- buffer = g_malloc (SF_BUFFER_SIZE);
- do {
- do {
- n = read (file, buffer, SF_BUFFER_SIZE);
- } while (n == -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
- if (n == -1)
- break;
- if (n == 0) {
- g_free (buffer);
- return 0; /* We're done reading */
- }
- do {
- n = send (socket, buffer, n, 0); /* short sends? enclose this in a loop? */
- } while (n == -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
- } while (n != -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
-
- if (n == -1) {
- gint errnum = errno;
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
- g_free (buffer);
- return SOCKET_ERROR;
- }
- g_free (buffer);
-#endif
- return 0;
-}
-
-gboolean
-TransmitFile (guint32 socket, gpointer file, guint32 bytes_to_write, guint32 bytes_per_send, WapiOverlapped *ol,
- WapiTransmitFileBuffers *buffers, guint32 flags)
-{
- gpointer sock = GUINT_TO_POINTER (socket);
- gint ret;
-
- if (mono_w32handle_get_type (sock) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return FALSE;
- }
-
- /* Write the header */
- if (buffers != NULL && buffers->Head != NULL && buffers->HeadLength > 0) {
- ret = _wapi_send (socket, buffers->Head, buffers->HeadLength, 0);
- if (ret == SOCKET_ERROR)
- return FALSE;
- }
-
- ret = wapi_sendfile (socket, file, bytes_to_write, bytes_per_send, flags);
- if (ret == SOCKET_ERROR)
- return FALSE;
-
- /* Write the tail */
- if (buffers != NULL && buffers->Tail != NULL && buffers->TailLength > 0) {
- ret = _wapi_send (socket, buffers->Tail, buffers->TailLength, 0);
- if (ret == SOCKET_ERROR)
- return FALSE;
- }
-
- if ((flags & TF_DISCONNECT) == TF_DISCONNECT)
- closesocket (socket);
-
- return TRUE;
-}
-
-static struct
-{
- WapiGuid guid;
- gpointer func;
-} extension_functions[] = {
- {WSAID_DISCONNECTEX, wapi_disconnectex},
- {WSAID_TRANSMITFILE, TransmitFile},
- {{0}, NULL},
-};
-
-int
-WSAIoctl (guint32 fd, gint32 command,
- gchar *input, gint i_len,
- gchar *output, gint o_len, glong *written,
- void *unused1, void *unused2)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
- int ret;
- gchar *buffer = NULL;
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return SOCKET_ERROR;
- }
-
- if (command == SIO_GET_EXTENSION_FUNCTION_POINTER) {
- int i = 0;
- WapiGuid *guid = (WapiGuid *)input;
-
- if (i_len < sizeof(WapiGuid)) {
- /* As far as I can tell, windows doesn't
- * actually set an error here...
- */
- WSASetLastError (WSAEINVAL);
- return(SOCKET_ERROR);
- }
-
- if (o_len < sizeof(gpointer)) {
- /* Or here... */
- WSASetLastError (WSAEINVAL);
- return(SOCKET_ERROR);
- }
-
- if (output == NULL) {
- /* Or here */
- WSASetLastError (WSAEINVAL);
- return(SOCKET_ERROR);
- }
-
- while(extension_functions[i].func != NULL) {
- if (!memcmp (guid, &extension_functions[i].guid,
- sizeof(WapiGuid))) {
- memcpy (output, &extension_functions[i].func,
- sizeof(gpointer));
- *written = sizeof(gpointer);
- return(0);
- }
-
- i++;
- }
-
- WSASetLastError (WSAEINVAL);
- return(SOCKET_ERROR);
- }
-
- if (command == SIO_KEEPALIVE_VALS) {
- uint32_t onoff;
- uint32_t keepalivetime;
- uint32_t keepaliveinterval;
-
- if (i_len < (3 * sizeof (uint32_t))) {
- WSASetLastError (WSAEINVAL);
- return SOCKET_ERROR;
- }
- memcpy (&onoff, input, sizeof (uint32_t));
- memcpy (&keepalivetime, input + sizeof (uint32_t), sizeof (uint32_t));
- memcpy (&keepaliveinterval, input + 2 * sizeof (uint32_t), sizeof (uint32_t));
- ret = setsockopt (fd, SOL_SOCKET, SO_KEEPALIVE, &onoff, sizeof (uint32_t));
- if (ret < 0) {
- gint errnum = errno;
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
- return SOCKET_ERROR;
- }
- if (onoff != 0) {
-#if defined(TCP_KEEPIDLE) && defined(TCP_KEEPINTVL)
- /* Values are in ms, but we need s */
- uint32_t rem;
-
- /* keepalivetime and keepaliveinterval are > 0 (checked in managed code) */
- rem = keepalivetime % 1000;
- keepalivetime /= 1000;
- if (keepalivetime == 0 || rem >= 500)
- keepalivetime++;
- ret = setsockopt (fd, IPPROTO_TCP, TCP_KEEPIDLE, &keepalivetime, sizeof (uint32_t));
- if (ret == 0) {
- rem = keepaliveinterval % 1000;
- keepaliveinterval /= 1000;
- if (keepaliveinterval == 0 || rem >= 500)
- keepaliveinterval++;
- ret = setsockopt (fd, IPPROTO_TCP, TCP_KEEPINTVL, &keepaliveinterval, sizeof (uint32_t));
- }
- if (ret != 0) {
- gint errnum = errno;
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
- return SOCKET_ERROR;
- }
- return 0;
-#endif
- }
- return 0;
- }
-
- if (i_len > 0) {
- buffer = (char *)g_memdup (input, i_len);
- }
-
- ret = ioctl (fd, command, buffer);
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: WSAIoctl error: %s", __func__,
- strerror (errno));
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
- g_free (buffer);
-
- return(SOCKET_ERROR);
- }
-
- if (buffer == NULL) {
- *written = 0;
- } else {
- /* We just copy the buffer to the output. Some ioctls
- * don't even output any data, but, well...
- *
- * NB windows returns WSAEFAULT if o_len is too small
- */
- i_len = (i_len > o_len) ? o_len : i_len;
-
- if (i_len > 0 && output != NULL) {
- memcpy (output, buffer, i_len);
- }
-
- g_free (buffer);
- *written = i_len;
- }
-
- return(0);
-}
-
-#ifndef PLATFORM_PORT_PROVIDES_IOCTLSOCKET
-int ioctlsocket(guint32 fd, unsigned long command, gpointer arg)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
- int ret;
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(SOCKET_ERROR);
- }
-
- switch(command){
- case FIONBIO:
-#ifdef O_NONBLOCK
- /* This works better than ioctl(...FIONBIO...)
- * on Linux (it causes connect to return
- * EINPROGRESS, but the ioctl doesn't seem to)
- */
- ret = fcntl(fd, F_GETFL, 0);
- if (ret != -1) {
- if (*(gboolean *)arg) {
- ret |= O_NONBLOCK;
- } else {
- ret &= ~O_NONBLOCK;
- }
- ret = fcntl(fd, F_SETFL, ret);
- }
- break;
-#endif /* O_NONBLOCK */
- /* Unused in Mono */
- case SIOCATMARK:
- ret = ioctl (fd, command, arg);
- break;
-
- case FIONREAD:
- {
-#if defined (PLATFORM_MACOSX)
-
- // ioctl (fd, FIONREAD, XXX) returns the size of
- // the UDP header as well on
- // Darwin.
- //
- // Use getsockopt SO_NREAD instead to get the
- // right values for TCP and UDP.
- //
- // ai_canonname can be null in some cases on darwin, where the runtime assumes it will
- // be the value of the ip buffer.
-
- socklen_t optlen = sizeof (int);
- ret = getsockopt (fd, SOL_SOCKET, SO_NREAD, arg, &optlen);
-#else
- ret = ioctl (fd, command, arg);
-#endif
- break;
- }
- default:
- WSASetLastError (WSAEINVAL);
- return(SOCKET_ERROR);
- }
-
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: ioctl error: %s", __func__, strerror (errno));
-
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(SOCKET_ERROR);
- }
-
- return(0);
-}
-
-int _wapi_select(int nfds G_GNUC_UNUSED, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout)
-{
- int ret, maxfd;
- MonoThreadInfo *info = mono_thread_info_current ();
-
- for (maxfd = FD_SETSIZE-1; maxfd >= 0; maxfd--) {
- if ((readfds && FD_ISSET (maxfd, readfds)) ||
- (writefds && FD_ISSET (maxfd, writefds)) ||
- (exceptfds && FD_ISSET (maxfd, exceptfds))) {
- break;
- }
- }
-
- if (maxfd == -1) {
- WSASetLastError (WSAEINVAL);
- return(SOCKET_ERROR);
- }
-
- do {
- ret = select(maxfd + 1, readfds, writefds, exceptfds,
- timeout);
- } while (ret == -1 && errno == EINTR &&
- !mono_thread_info_is_interrupt_state (info));
-
- if (ret == -1) {
- gint errnum = errno;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: select error: %s", __func__, strerror (errno));
- errnum = errno_to_WSA (errnum, __func__);
- WSASetLastError (errnum);
-
- return(SOCKET_ERROR);
- }
-
- return(ret);
-}
-
-void _wapi_FD_CLR(guint32 fd, fd_set *set)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
-
- if (fd >= FD_SETSIZE) {
- WSASetLastError (WSAEINVAL);
- return;
- }
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return;
- }
-
- FD_CLR (fd, set);
-}
-
-int _wapi_FD_ISSET(guint32 fd, fd_set *set)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
-
- if (fd >= FD_SETSIZE) {
- WSASetLastError (WSAEINVAL);
- return(0);
- }
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return(0);
- }
-
- return(FD_ISSET (fd, set));
-}
-
-void _wapi_FD_SET(guint32 fd, fd_set *set)
-{
- gpointer handle = GUINT_TO_POINTER (fd);
-
- if (fd >= FD_SETSIZE) {
- WSASetLastError (WSAEINVAL);
- return;
- }
-
- if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
- WSASetLastError (WSAENOTSOCK);
- return;
- }
-
- FD_SET (fd, set);
-}
-#endif
-
-static void
-wsabuf_to_msghdr (WapiWSABuf *buffers, guint32 count, struct msghdr *hdr)
-{
- guint32 i;
-
- memset (hdr, 0, sizeof (struct msghdr));
- hdr->msg_iovlen = count;
- hdr->msg_iov = g_new0 (struct iovec, count);
- for (i = 0; i < count; i++) {
- hdr->msg_iov [i].iov_base = buffers [i].buf;
- hdr->msg_iov [i].iov_len = buffers [i].len;
- }
-}
-
-static void
-msghdr_iov_free (struct msghdr *hdr)
-{
- g_free (hdr->msg_iov);
-}
-
-int WSARecv (guint32 fd, WapiWSABuf *buffers, guint32 count, guint32 *received,
- guint32 *flags, WapiOverlapped *overlapped,
- WapiOverlappedCB *complete)
-{
- int ret;
- struct msghdr hdr;
-
- g_assert (overlapped == NULL);
- g_assert (complete == NULL);
-
- wsabuf_to_msghdr (buffers, count, &hdr);
- ret = _wapi_recvmsg (fd, &hdr, *flags);
- msghdr_iov_free (&hdr);
-
- if(ret == SOCKET_ERROR) {
- return(ret);
- }
-
- *received = ret;
- *flags = hdr.msg_flags;
-
- return(0);
-}
-
-int WSASend (guint32 fd, WapiWSABuf *buffers, guint32 count, guint32 *sent,
- guint32 flags, WapiOverlapped *overlapped,
- WapiOverlappedCB *complete)
-{
- int ret;
- struct msghdr hdr;
-
- g_assert (overlapped == NULL);
- g_assert (complete == NULL);
-
- wsabuf_to_msghdr (buffers, count, &hdr);
- ret = _wapi_sendmsg (fd, &hdr, flags);
- msghdr_iov_free (&hdr);
-
- if(ret == SOCKET_ERROR)
- return ret;
-
- *sent = ret;
- return 0;
-}
-
-#endif /* ifndef DISABLE_SOCKETS */
+++ /dev/null
-/*
- * sockets.h: Socket handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_SOCKETS_H_
-#define _WAPI_SOCKETS_H_
-
-#include "mono/io-layer/wapi.h"
-
-G_BEGIN_DECLS
-
-#define WSADESCRIPTION_LEN 256
-#define WSASYS_STATUS_LEN 128
-
-typedef struct
-{
- guint16 wVersion;
- guint16 wHighVersion;
- char szDescription[WSADESCRIPTION_LEN+1];
- char szSystemStatus[WSASYS_STATUS_LEN+1];
- guint16 iMaxSockets;
- guint16 iMaxUdpDg;
- guchar *lpVendorInfo;
-} WapiWSAData;
-
-#define INVALID_SOCKET (guint32)(~0)
-#define SOCKET_ERROR -1
-
-#define WSAID_DISCONNECTEX {0x7fda2e11,0x8630,0x436f,{0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}
-#define WSAID_TRANSMITFILE {0xb5367df0,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}}
-
-typedef struct
-{
- guint32 Data1;
- guint16 Data2;
- guint16 Data3;
- guint8 Data4[8];
-} WapiGuid;
-
-typedef struct
-{
- gpointer Head;
- guint32 HeadLength;
- gpointer Tail;
- guint32 TailLength;
-} WapiTransmitFileBuffers;
-
-typedef enum {
- TF_USE_DEFAULT_WORKER = 0,
- TF_DISCONNECT = 0x01,
- TF_REUSE_SOCKET = 0x02,
- TF_WRITE_BEHIND = 0x04,
- TF_USE_SYSTEM_THREAD = 0x10,
- TF_USE_KERNEL_APC = 0x20
-} WapiTransmitFileFlags;
-
-typedef struct
-{
- guint32 len;
- gpointer buf;
-} WapiWSABuf;
-
-/* If we need to support more WSAIoctl commands then define these
- * using the bitfield flags method
- */
-#define SIO_GET_EXTENSION_FUNCTION_POINTER 0xC8000006
-#define SIO_KEEPALIVE_VALS 0x98000004
-
-typedef gboolean (*WapiDisconnectExFn)(guint32, WapiOverlapped *, guint32,
- guint32);
-typedef gboolean (*WapiTransmitFileFn)(guint32, gpointer, guint32, guint32,
- WapiOverlapped *,
- WapiTransmitFileBuffers *,
- WapiTransmitFileFlags);
-
-extern void WSASetLastError(int error);
-extern int WSAGetLastError(void);
-extern int closesocket(guint32 handle);
-
-extern int ioctlsocket(guint32 handle, unsigned long command, gpointer arg);
-extern int WSAIoctl (guint32 handle, gint32 command,
- gchar *input, gint i_len,
- gchar *output, gint o_len, glong *written,
- void *unused1, void *unused2);
-extern int WSARecv (guint32 handle, WapiWSABuf *buffers, guint32 count,
- guint32 *received, guint32 *flags,
- WapiOverlapped *overlapped, WapiOverlappedCB *complete);
-extern int WSASend (guint32 handle, WapiWSABuf *buffers, guint32 count,
- guint32 *sent, guint32 flags,
- WapiOverlapped *overlapped, WapiOverlappedCB *complete);
-
-gboolean TransmitFile (guint32 socket, gpointer file, guint32 bytes_to_write, guint32 bytes_per_send, WapiOverlapped *ol,
- WapiTransmitFileBuffers *tb, guint32 flags);
-G_END_DECLS
-#endif /* _WAPI_SOCKETS_H_ */
+++ /dev/null
-/*
- * uglify.h: Optional header to provide the nasty w32 typedefs
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_UGLIFY_H_
-#define _WAPI_UGLIFY_H_
-
-/* Include this file if you insist on using the nasty Win32 typedefs */
-
-#include <stdlib.h>
-
-#include "mono/io-layer/wapi.h"
-
-typedef const gunichar2 *LPCTSTR;
-typedef gunichar2 *LPTSTR;
-typedef const char *LPCSTR;
-typedef char *LPSTR;
-typedef guint8 BYTE;
-typedef guint8 *LPBYTE;
-typedef guint16 WORD;
-typedef guint32 DWORD;
-typedef gpointer PVOID;
-typedef gpointer LPVOID;
-typedef gboolean BOOL;
-typedef guint32 *LPDWORD;
-typedef gint32 LONG;
-typedef guint32 ULONG;
-typedef gint32 *PLONG;
-typedef guint64 LONGLONG;
-typedef gunichar2 TCHAR;
-typedef size_t SIZE_T;
-typedef guint64 ULONG64;
-typedef guint UINT;
-typedef gconstpointer LPCVOID;
-
-typedef gpointer HANDLE;
-typedef gpointer *LPHANDLE;
-typedef guint32 SOCKET;
-typedef gpointer HMODULE;
-typedef gpointer HINSTANCE;
-typedef gpointer HWND;
-typedef gpointer HKEY;
-
-typedef WapiSecurityAttributes SECURITY_ATTRIBUTES;
-typedef WapiSecurityAttributes *LPSECURITY_ATTRIBUTES;
-typedef WapiOverlapped *LPOVERLAPPED;
-typedef WapiOverlappedCB LPOVERLAPPED_COMPLETION_ROUTINE;
-typedef WapiFileTime FILETIME;
-typedef WapiFileTime *LPFILETIME;
-typedef WapiSystemTime SYSTEMTIME;
-typedef WapiSystemTime *LPSYSTEMTIME;
-typedef WapiWSAData WSADATA;
-typedef WapiWSAData *LDWSADATA;
-typedef WapiWSABuf WSABUF;
-typedef WapiWSABuf *LPWSABUF;
-typedef WapiFindData WIN32_FIND_DATA;
-typedef WapiFindData *LPWIN32_FIND_DATA;
-typedef WapiFileAttributesData WIN32_FILE_ATTRIBUTE_DATA;
-typedef WapiGetFileExInfoLevels GET_FILEEX_INFO_LEVELS;
-typedef WapiTransmitFileBuffers TRANSMIT_FILE_BUFFERS;
-typedef WapiTransmitFileBuffers *PTRANSMIT_FILE_BUFFERS;
-typedef WapiTransmitFileBuffers *LPTRANSMIT_FILE_BUFFERS;
-typedef WapiDisconnectExFn LPFN_DISCONNECTEX;
-typedef WapiTransmitFileFn LPFN_TRANSMITFILE;
-typedef WapiGuid GUID;
-typedef WapiGuid *LPGUID;
-
-#define CONST const
-#define VOID void
-
-#define IN
-#define OUT
-#define WINAPI
-
-#endif /* _WAPI_UGLIFY_H_ */
+++ /dev/null
-/*
- * wapi-private.h: internal definitions of handles and shared memory layout
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002-2006 Novell, Inc.
- */
-
-#ifndef _WAPI_PRIVATE_H_
-#define _WAPI_PRIVATE_H_
-
-#include <config.h>
-#include <glib.h>
-#include <sys/stat.h>
-
-#include <mono/io-layer/wapi.h>
-#include <mono/io-layer/io.h>
-
-#include <mono/utils/mono-os-mutex.h>
-
-/* There doesn't seem to be a defined symbol for this */
-#define _WAPI_THREAD_CURRENT (gpointer)0xFFFFFFFE
-
-extern gboolean _wapi_has_shut_down;
-
-#include <mono/io-layer/io-private.h>
-#include <mono/io-layer/socket-private.h>
-#include <mono/metadata/w32handle.h>
-
-struct _WapiHandle_shared_ref
-{
- /* This will be split 16:16 with the shared file segment in
- * the top half, when I implement space increases
- */
- guint32 offset;
-};
-
-struct _WapiFileShare
-{
-#ifdef WAPI_FILE_SHARE_PLATFORM_EXTRA_DATA
- WAPI_FILE_SHARE_PLATFORM_EXTRA_DATA
-#endif
- guint64 device;
- guint64 inode;
- pid_t opened_by_pid;
- guint32 sharemode;
- guint32 access;
- guint32 handle_refs;
- guint32 timestamp;
-};
-
-typedef struct _WapiFileShare _WapiFileShare;
-
-#endif /* _WAPI_PRIVATE_H_ */
+++ /dev/null
-/*
- * wapi-remap.h: io-layer symbol remapping support
- *
- * (C) 2014 Xamarin, Inc.
- */
-
-#ifndef __WAPI_REMAP_H__
-#define __WAPI_REMAP_H__
-
-/*
- * The windows function names used by the io-layer can collide with symbols in system and 3rd party libs, esp. on osx/ios. So remap them to
- * wapi_<funcname>.
- */
-
-#define GetLastError wapi_GetLastError
-#define SetLastError wapi_SetLastError
-#define TransmitFile wapi_TransmitFile
-#define CloseHandle wapi_CloseHandle
-#define CreateFile wapi_CreateFile
-#define DeleteFile wapi_DeleteFile
-#define GetStdHandle wapi_GetStdHandle
-#define ReadFile wapi_ReadFile
-#define WriteFile wapi_WriteFile
-#define FlushFileBuffers wapi_FlushFileBuffers
-#define SetEndOfFile wapi_SetEndOfFile
-#define SetFilePointer wapi_SetFilePointer
-#define GetFileType wapi_GetFileType
-#define GetFileSize wapi_GetFileSize
-#define GetFileTime wapi_GetFileTime
-#define SetFileTime wapi_SetFileTime
-#define FileTimeToSystemTime wapi_FileTimeToSystemTime
-#define FindFirstFile wapi_FindFirstFile
-#define FindNextFile wapi_FindNextFile
-#define FindClose wapi_FindClose
-#define CreateDirectory wapi_CreateDirectory
-#define RemoveDirectory wapi_RemoveDirectory
-#define MoveFile wapi_MoveFile
-#define CopyFile wapi_CopyFile
-#define ReplaceFile wapi_ReplaceFile
-#define GetFileAttributes wapi_GetFileAttributes
-#define GetFileAttributesEx wapi_GetFileAttributesEx
-#define SetFileAttributes wapi_SetFileAttributes
-#define GetCurrentDirectory wapi_GetCurrentDirectory
-#define SetCurrentDirectory wapi_SetCurrentDirectory
-#define CreatePipe wapi_CreatePipe
-#define GetLogicalDriveStrings wapi_GetLogicalDriveStrings
-#define GetDiskFreeSpaceEx wapi_GetDiskFreeSpaceEx
-#define GetDriveType wapi_GetDriveType
-#define LockFile wapi_LockFile
-#define UnlockFile wapi_UnlockFile
-#define GetVolumeInformation wapi_GetVolumeInformation
-#define ImpersonateLoggedOnUser wapi_ImpersonateLoggedOnUser
-#define RevertToSelf wapi_RevertToSelf
-#define WSASetLastError wapi_WSASetLastError
-#define WSAGetLastError wapi_WSAGetLastError
-#define WSAIoctl wapi_WSAIoctl
-#define WSARecv wapi_WSARecv
-#define WSASend wapi_WSASend
-#define GetSystemInfo wapi_GetSystemInfo
-
-#endif /* __WAPI_REMAP_H__ */
+++ /dev/null
-
-#include "wapi.h"
-
-#include "io-trace.h"
-#include "io.h"
-#include "socket-private.h"
-
-#include "mono/utils/mono-lazy-init.h"
-#include "mono/metadata/w32handle.h"
-
-gboolean _wapi_has_shut_down = FALSE;
-
-void
-wapi_init (void)
-{
- _wapi_io_init ();
- _wapi_socket_init ();
-}
-
-void
-wapi_cleanup (void)
-{
- g_assert (_wapi_has_shut_down == FALSE);
- _wapi_has_shut_down = TRUE;
-
- _wapi_error_cleanup ();
- _wapi_io_cleanup ();
-}
-
-/* Use this instead of getpid(), to cope with linuxthreads. It's a
- * function rather than a variable lookup because we need to get at
- * this before share_init() might have been called. */
-static mono_lazy_init_t _wapi_pid_init_lazy = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED;
-static pid_t _wapi_pid;
-
-static void
-_wapi_pid_init (void)
-{
- _wapi_pid = getpid ();
-}
-
-pid_t
-wapi_getpid (void)
-{
- mono_lazy_initialize (&_wapi_pid_init_lazy, _wapi_pid_init);
- return _wapi_pid;
-}
-
-/**
- * CloseHandle:
- * @handle: The handle to release
- *
- * Closes and invalidates @handle, releasing any resources it
- * consumes. When the last handle to a temporary or non-persistent
- * object is closed, that object can be deleted. Closing the same
- * handle twice is an error.
- *
- * Return value: %TRUE on success, %FALSE otherwise.
- */
-gboolean CloseHandle(gpointer handle)
-{
- if (handle == INVALID_HANDLE_VALUE){
- SetLastError (ERROR_INVALID_PARAMETER);
- return FALSE;
- }
- if (handle == (gpointer)0 && mono_w32handle_get_type (handle) != MONO_W32HANDLE_CONSOLE) {
- /* Problem: because we map file descriptors to the
- * same-numbered handle we can't tell the difference
- * between a bogus handle and the handle to stdin.
- * Assume that it's the console handle if that handle
- * exists...
- */
- SetLastError (ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- mono_w32handle_unref (handle);
- return TRUE;
-}
+++ /dev/null
-/*
- * wapi.h: Public include files
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_WAPI_H_
-#define _WAPI_WAPI_H_
-
-#include <glib.h>
-
-#include <sys/types.h>
-
-#include <mono/io-layer/wapi-remap.h>
-#include <mono/io-layer/io.h>
-#include <mono/io-layer/io-portability.h>
-#include <mono/io-layer/error.h>
-#include <mono/io-layer/sockets.h>
-
-G_BEGIN_DECLS
-
-#define WAIT_FAILED ((int) 0xFFFFFFFF)
-#define WAIT_OBJECT_0 ((int) 0x00000000)
-#define WAIT_ABANDONED_0 ((int) 0x00000080)
-#define WAIT_TIMEOUT ((int) 0x00000102)
-#define WAIT_IO_COMPLETION ((int) 0x000000C0)
-
-void
-wapi_init (void);
-
-void
-wapi_cleanup (void);
-
-gboolean
-CloseHandle (gpointer handle);
-
-pid_t
-wapi_getpid (void);
-
-G_END_DECLS
-
-#endif /* _WAPI_WAPI_H_ */
+++ /dev/null
-/* $OpenBSD: glob.c,v 1.26 2005/11/28 17:50:12 deraadt Exp $ */
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Guido van Rossum.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * _wapi_glob(3) -- a subset of the one defined in POSIX 1003.2.
- *
- * Optional extra services, controlled by flags not defined by POSIX:
- *
- * GLOB_MAGCHAR:
- * Set in gl_flags if pattern contained a globbing character.
- */
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <glib.h>
-#include <ctype.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "wapi_glob.h"
-
-#define EOS '\0'
-#define NOT '!'
-#define QUESTION '?'
-#define QUOTE '\\'
-#define STAR '*'
-
-#ifndef DEBUG
-
-#define M_QUOTE 0x8000
-#define M_PROTECT 0x4000
-#define M_MASK 0xffff
-#define M_ASCII 0x00ff
-
-typedef unsigned short Char;
-
-#else
-
-#define M_QUOTE 0x80
-#define M_PROTECT 0x40
-#define M_MASK 0xff
-#define M_ASCII 0x7f
-
-typedef char Char;
-
-#endif
-
-
-#define CHAR(c) ((gchar)((c)&M_ASCII))
-#define META(c) ((gchar)((c)|M_QUOTE))
-#define M_ALL META('*')
-#define M_ONE META('?')
-#define ismeta(c) (((c)&M_QUOTE) != 0)
-
-
-static int g_Ctoc(const gchar *, char *, unsigned int);
-static int glob0(GDir *dir, const gchar *, wapi_glob_t *, gboolean,
- gboolean);
-static int glob1(GDir *dir, gchar *, gchar *, wapi_glob_t *, size_t *,
- gboolean, gboolean);
-static int glob3(GDir *dir, gchar *, gchar *, wapi_glob_t *, size_t *,
- gboolean, gboolean);
-static int globextend(const gchar *, wapi_glob_t *, size_t *);
-static int match(const gchar *, gchar *, gchar *, gboolean);
-#ifdef DEBUG_ENABLED
-static void qprintf(const char *, Char *);
-#endif
-
-int
-_wapi_glob(GDir *dir, const char *pattern, int flags, wapi_glob_t *pglob)
-{
- const unsigned char *patnext;
- int c;
- gchar *bufnext, *bufend, patbuf[PATH_MAX];
-
- patnext = (unsigned char *) pattern;
- if (!(flags & WAPI_GLOB_APPEND)) {
- pglob->gl_pathc = 0;
- pglob->gl_pathv = NULL;
- pglob->gl_offs = 0;
- }
- pglob->gl_flags = flags & ~WAPI_GLOB_MAGCHAR;
-
- bufnext = patbuf;
- bufend = bufnext + PATH_MAX - 1;
-
- /* Protect the quoted characters. */
- while (bufnext < bufend && (c = *patnext++) != EOS)
- if (c == QUOTE) {
- if ((c = *patnext++) == EOS) {
- c = QUOTE;
- --patnext;
- }
- *bufnext++ = c | M_PROTECT;
- } else
- *bufnext++ = c;
-
- *bufnext = EOS;
-
- return glob0(dir, patbuf, pglob, flags & WAPI_GLOB_IGNORECASE,
- flags & WAPI_GLOB_UNIQUE);
-}
-
-/*
- * The main glob() routine: compiles the pattern (optionally processing
- * quotes), calls glob1() to do the real pattern matching, and finally
- * sorts the list (unless unsorted operation is requested). Returns 0
- * if things went well, nonzero if errors occurred. It is not an error
- * to find no matches.
- */
-static int
-glob0(GDir *dir, const gchar *pattern, wapi_glob_t *pglob, gboolean ignorecase,
- gboolean unique)
-{
- const gchar *qpatnext;
- int c, err, oldpathc;
- gchar *bufnext, patbuf[PATH_MAX];
- size_t limit = 0;
-
- qpatnext = pattern;
- oldpathc = pglob->gl_pathc;
- bufnext = patbuf;
-
- /* We don't need to check for buffer overflow any more. */
- while ((c = *qpatnext++) != EOS) {
- switch (c) {
- case QUESTION:
- pglob->gl_flags |= WAPI_GLOB_MAGCHAR;
- *bufnext++ = M_ONE;
- break;
- case STAR:
- pglob->gl_flags |= WAPI_GLOB_MAGCHAR;
- /* collapse adjacent stars to one,
- * to avoid exponential behavior
- */
- if (bufnext == patbuf || bufnext[-1] != M_ALL)
- *bufnext++ = M_ALL;
- break;
- default:
- *bufnext++ = CHAR(c);
- break;
- }
- }
- *bufnext = EOS;
-#ifdef DEBUG_ENABLED
- qprintf("glob0:", patbuf);
-#endif
-
- if ((err = glob1(dir, patbuf, patbuf+PATH_MAX-1, pglob, &limit,
- ignorecase, unique)) != 0)
- return(err);
-
- if (pglob->gl_pathc == oldpathc) {
- return(WAPI_GLOB_NOMATCH);
- }
-
- return(0);
-}
-
-static int
-glob1(GDir *dir, gchar *pattern, gchar *pattern_last, wapi_glob_t *pglob,
- size_t *limitp, gboolean ignorecase, gboolean unique)
-{
- /* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */
- if (*pattern == EOS)
- return(0);
- return(glob3(dir, pattern, pattern_last, pglob, limitp, ignorecase,
- unique));
-}
-
-static gboolean contains (wapi_glob_t *pglob, const gchar *name)
-{
- int i;
- char **pp;
-
- if (pglob->gl_pathv != NULL) {
- pp = pglob->gl_pathv + pglob->gl_offs;
- for (i = pglob->gl_pathc; i--; ++pp) {
- if (*pp) {
- if (!strcmp (*pp, name)) {
- return(TRUE);
- }
- }
- }
- }
-
- return(FALSE);
-}
-
-static int
-glob3(GDir *dir, gchar *pattern, gchar *pattern_last, wapi_glob_t *pglob,
- size_t *limitp, gboolean ignorecase, gboolean unique)
-{
- const gchar *name;
-
- /* Search directory for matching names. */
- while ((name = g_dir_read_name(dir))) {
- if (!match(name, pattern, pattern + strlen (pattern),
- ignorecase)) {
- continue;
- }
- if (!unique ||
- !contains (pglob, name)) {
- globextend (name, pglob, limitp);
- }
- }
-
- return(0);
-}
-
-
-/*
- * Extend the gl_pathv member of a wapi_glob_t structure to accommodate a new item,
- * add the new item, and update gl_pathc.
- *
- * This assumes the BSD realloc, which only copies the block when its size
- * crosses a power-of-two boundary; for v7 realloc, this would cause quadratic
- * behavior.
- *
- * Return 0 if new item added, error code if memory couldn't be allocated.
- *
- * Invariant of the wapi_glob_t structure:
- * Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and
- * gl_pathv points to (gl_offs + gl_pathc + 1) items.
- */
-static int
-globextend(const gchar *path, wapi_glob_t *pglob, size_t *limitp)
-{
- char **pathv;
- int i;
- unsigned int newsize, len;
- char *copy;
- const gchar *p;
-
- newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
- /* FIXME: Can just use realloc(). */
- pathv = (char **)(pglob->gl_pathv ? g_realloc ((char *)pglob->gl_pathv, newsize) :
- g_malloc (newsize));
- if (pathv == NULL) {
- if (pglob->gl_pathv) {
- g_free (pglob->gl_pathv);
- pglob->gl_pathv = NULL;
- }
- return(WAPI_GLOB_NOSPACE);
- }
-
- if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
- /* first time around -- clear initial gl_offs items */
- pathv += pglob->gl_offs;
- for (i = pglob->gl_offs; --i >= 0; )
- *--pathv = NULL;
- }
- pglob->gl_pathv = pathv;
-
- for (p = path; *p++;)
- ;
- len = (size_t)(p - path);
- *limitp += len;
- if ((copy = (char *)malloc(len)) != NULL) {
- if (g_Ctoc(path, copy, len)) {
- g_free (copy);
- return(WAPI_GLOB_NOSPACE);
- }
- pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
- }
- pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
-
-#if 0
- /* Broken on opensuse 11 */
- if ((pglob->gl_flags & WAPI_GLOB_LIMIT) &&
- newsize + *limitp >= ARG_MAX) {
- errno = 0;
- return(WAPI_GLOB_NOSPACE);
- }
-#endif
-
- return(copy == NULL ? WAPI_GLOB_NOSPACE : 0);
-}
-
-
-/*
- * pattern matching function for filenames. Each occurrence of the *
- * pattern causes a recursion level.
- */
-static int
-match(const gchar *name, gchar *pat, gchar *patend, gboolean ignorecase)
-{
- gchar c;
-
- while (pat < patend) {
- c = *pat++;
- switch (c & M_MASK) {
- case M_ALL:
- if (pat == patend)
- return(1);
- do {
- if (match(name, pat, patend, ignorecase))
- return(1);
- } while (*name++ != EOS);
- return(0);
- case M_ONE:
- if (*name++ == EOS)
- return(0);
- break;
- default:
- if (ignorecase) {
- if (g_ascii_tolower (*name++) != g_ascii_tolower (c))
- return(0);
- } else {
- if (*name++ != c)
- return(0);
- }
-
- break;
- }
- }
- return(*name == EOS);
-}
-
-/* Free allocated data belonging to a wapi_glob_t structure. */
-void
-_wapi_globfree(wapi_glob_t *pglob)
-{
- int i;
- char **pp;
-
- if (pglob->gl_pathv != NULL) {
- pp = pglob->gl_pathv + pglob->gl_offs;
- for (i = pglob->gl_pathc; i--; ++pp)
- if (*pp)
- g_free (*pp);
- g_free (pglob->gl_pathv);
- pglob->gl_pathv = NULL;
- }
-}
-
-static int
-g_Ctoc(const gchar *str, char *buf, unsigned int len)
-{
-
- while (len--) {
- if ((*buf++ = *str++) == EOS)
- return (0);
- }
- return (1);
-}
-
-#ifdef DEBUG_ENABLED
-static void
-qprintf(const char *str, Char *s)
-{
- Char *p;
-
- (void)printf("%s:\n", str);
- for (p = s; *p; p++)
- (void)printf("%c", CHAR(*p));
- (void)printf("\n");
- for (p = s; *p; p++)
- (void)printf("%c", *p & M_PROTECT ? '"' : ' ');
- (void)printf("\n");
- for (p = s; *p; p++)
- (void)printf("%c", ismeta(*p) ? '_' : ' ');
- (void)printf("\n");
-}
-#endif
+++ /dev/null
-/* $OpenBSD: glob.h,v 1.10 2005/12/13 00:35:22 millert Exp $ */
-/* $NetBSD: glob.h,v 1.5 1994/10/26 00:55:56 cgd Exp $ */
-
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Guido van Rossum.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)glob.h 8.1 (Berkeley) 6/2/93
- */
-
-#ifndef _WAPI_GLOB_H_
-#define _WAPI_GLOB_H_
-
-#include <glib.h>
-
-struct stat;
-typedef struct {
- int gl_pathc; /* Count of total paths so far. */
- int gl_offs; /* Reserved at beginning of gl_pathv. */
- int gl_flags; /* Copy of flags parameter to glob. */
- char **gl_pathv; /* List of paths matching pattern. */
-} wapi_glob_t;
-
-#define WAPI_GLOB_APPEND 0x0001 /* Append to output from previous call. */
-#define WAPI_GLOB_UNIQUE 0x0040 /* When appending only add items that aren't already in the list */
-#define WAPI_GLOB_NOSPACE (-1) /* Malloc call failed. */
-#define WAPI_GLOB_ABORTED (-2) /* Unignored error. */
-#define WAPI_GLOB_NOMATCH (-3) /* No match and WAPI_GLOB_NOCHECK not set. */
-#define WAPI_GLOB_NOSYS (-4) /* Function not supported. */
-
-#define WAPI_GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */
-#define WAPI_GLOB_LIMIT 0x2000 /* Limit pattern match output to ARG_MAX */
-#define WAPI_GLOB_IGNORECASE 0x4000 /* Ignore case when matching */
-#define WAPI_GLOB_ABEND WAPI_GLOB_ABORTED /* backward compatibility */
-
-G_BEGIN_DECLS
-int _wapi_glob(GDir *dir, const char *, int, wapi_glob_t *);
-void _wapi_globfree(wapi_glob_t *);
-G_END_DECLS
-
-#endif /* !_WAPI_GLOB_H_ */
console-win32.c \
console-win32-internals.h \
cominterop-win32-internals.h \
- file-io-windows.c \
- file-io-windows-internals.h \
+ w32file-win32.c \
+ w32file-win32-internals.h \
icall-windows.c \
icall-windows-internals.h \
marshal-windows.c \
w32event-win32.c \
w32process-win32.c \
w32process-win32-internals.h \
- socket-io-windows.c
+ w32socket-win32.c \
+ w32error-win32.c
platform_sources = $(win32_sources)
w32process-unix-osx.c \
w32process-unix-bsd.c \
w32process-unix-haiku.c \
- w32process-unix-default.c
+ w32process-unix-default.c \
+ w32socket-unix.c \
+ w32file-unix.c \
+ w32file-unix-glob.c \
+ w32file-unix-glob.h \
+ w32error-unix.c
platform_sources = $(unix_sources)
endif
exception.c \
exception.h \
exception-internals.h \
- file-io.c \
- file-io.h \
- file-io-internals.h \
+ w32file.c \
+ w32file.h \
+ w32file-internals.h \
filewatcher.c \
filewatcher.h \
gc-internals.h \
opcodes.c \
property-bag.h \
property-bag.c \
- socket-io.c \
- socket-io.h \
+ w32socket.c \
+ w32socket.h \
+ w32socket-internals.h \
w32process.c \
w32process.h \
w32process-internals.h \
w32handle-namespace.h \
w32handle-namespace.c \
w32handle.h \
- w32handle.c
+ w32handle.c \
+ w32error.h
# These source files have compile time dependencies on GC code
gc_dependent_sources = \
#include <mono/metadata/handle.h>
#include <mono/metadata/object-internals.h>
-MonoAppDomain *
-ves_icall_System_AppDomain_getCurDomain (void);
+MonoAppDomainHandle
+ves_icall_System_AppDomain_getCurDomain (MonoError *error);
-MonoAppDomain *
-ves_icall_System_AppDomain_getRootDomain (void);
+MonoAppDomainHandle
+ves_icall_System_AppDomain_getRootDomain (MonoError *error);
-MonoAppDomain *
-ves_icall_System_AppDomain_createDomain (MonoString *friendly_name,
- MonoAppDomainSetup *setup);
+MonoAppDomainHandle
+ves_icall_System_AppDomain_createDomain (MonoStringHandle friendly_name,
+ MonoAppDomainSetupHandle setup,
+ MonoError *error);
-MonoObject *
-ves_icall_System_AppDomain_GetData (MonoAppDomain *ad,
- MonoString *name);
+MonoObjectHandle
+ves_icall_System_AppDomain_GetData (MonoAppDomainHandle ad,
+ MonoStringHandle name,
+ MonoError* error);
MonoReflectionAssemblyHandle
ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomainHandle ad,
MonoError *error);
void
-ves_icall_System_AppDomain_SetData (MonoAppDomain *ad,
- MonoString *name,
- MonoObject *data);
+ves_icall_System_AppDomain_SetData (MonoAppDomainHandle ad,
+ MonoStringHandle name,
+ MonoObjectHandle data,
+ MonoError *error);
-MonoAppDomainSetup *
-ves_icall_System_AppDomain_getSetup (MonoAppDomain *ad);
+MonoAppDomainSetupHandle
+ves_icall_System_AppDomain_getSetup (MonoAppDomainHandle ad,
+ MonoError *error);
-MonoString *
-ves_icall_System_AppDomain_getFriendlyName (MonoAppDomain *ad);
+MonoStringHandle
+ves_icall_System_AppDomain_getFriendlyName (MonoAppDomainHandle ad,
+ MonoError *error);
MonoArrayHandle
ves_icall_System_AppDomain_GetAssemblies (MonoAppDomainHandle ad,
MonoError *error);
gboolean
-ves_icall_System_AppDomain_InternalIsFinalizingForUnload (gint32 domain_id);
+ves_icall_System_AppDomain_InternalIsFinalizingForUnload (gint32 domain_id, MonoError *error);
void
-ves_icall_System_AppDomain_InternalUnload (gint32 domain_id);
+ves_icall_System_AppDomain_InternalUnload (gint32 domain_id,
+ MonoError *error);
void
ves_icall_System_AppDomain_DoUnhandledException (MonoException *exc);
MonoArrayHandle args,
MonoError *error);
-MonoAppDomain *
-ves_icall_System_AppDomain_InternalSetDomain (MonoAppDomain *ad);
+MonoAppDomainHandle
+ves_icall_System_AppDomain_InternalSetDomain (MonoAppDomainHandle ad, MonoError *error);
-MonoAppDomain *
-ves_icall_System_AppDomain_InternalSetDomainByID (gint32 domainid);
+MonoAppDomainHandle
+ves_icall_System_AppDomain_InternalSetDomainByID (gint32 domainid, MonoError *error);
void
-ves_icall_System_AppDomain_InternalPushDomainRef (MonoAppDomain *ad);
+ves_icall_System_AppDomain_InternalPushDomainRef (MonoAppDomainHandle ad, MonoError *error);
void
-ves_icall_System_AppDomain_InternalPushDomainRefByID (gint32 domain_id);
+ves_icall_System_AppDomain_InternalPushDomainRefByID (gint32 domain_id, MonoError *error);
void
-ves_icall_System_AppDomain_InternalPopDomainRef (void);
+ves_icall_System_AppDomain_InternalPopDomainRef (MonoError *error);
MonoAppContext *
ves_icall_System_AppDomain_InternalGetContext (void);
gint32
ves_icall_System_AppDomain_GetIDFromDomain (MonoAppDomain * ad);
-MonoString *
-ves_icall_System_AppDomain_InternalGetProcessGuid (MonoString* newguid);
+MonoStringHandle
+ves_icall_System_AppDomain_InternalGetProcessGuid (MonoStringHandle newguid, MonoError *error);
MonoBoolean
ves_icall_System_CLRConfig_CheckThrowUnobservedTaskExceptions (void);
#include <mono/metadata/exception-internals.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/threadpool.h>
-#include <mono/metadata/socket-io.h>
#include <mono/metadata/tabledefs.h>
-#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mono-gc.h>
#include <mono/metadata/marshal.h>
+#include <mono/metadata/marshal-internals.h>
#include <mono/metadata/monitor.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/mono-debug-debugger.h>
#include <mono/metadata/attach.h>
-#include <mono/metadata/file-io.h>
+#include <mono/metadata/w32file.h>
#include <mono/metadata/lock-tracer.h>
#include <mono/metadata/console-io.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/reflection-internals.h>
#include <mono/metadata/abi-details.h>
+#include <mono/metadata/w32socket.h>
#include <mono/utils/mono-uri.h>
#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-path.h>
#include <mono/utils/mono-memory-model.h>
#include <mono/utils/mono-threads.h>
#include <mono/metadata/w32handle.h>
-#include <mono/io-layer/io-layer.h>
+#include <mono/metadata/w32error.h>
+#include <mono/utils/w32api.h>
#ifdef HOST_WIN32
#include <direct.h>
#endif
static void
add_assemblies_to_domain (MonoDomain *domain, MonoAssembly *ass, GHashTable *hash);
-static MonoAppDomain *
-mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetup *setup, MonoError *error);
+static MonoAppDomainHandle
+mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetupHandle setup, MonoError *error);
+
+static MonoDomain *
+mono_domain_create_appdomain_checked (char *friendly_name, char *configuration_file, MonoError *error);
+
static char *
get_shadow_assembly_location_base (MonoDomain *domain, MonoError *error);
static MonoLoadFunc load_function = NULL;
/* Lazy class loading functions */
-static GENERATE_GET_CLASS_WITH_CACHE (assembly, System.Reflection, Assembly);
+static GENERATE_GET_CLASS_WITH_CACHE (assembly, "System.Reflection", "Assembly");
+
+static GENERATE_GET_CLASS_WITH_CACHE (appdomain, "System", "AppDomain");
-static GENERATE_GET_CLASS_WITH_CACHE (appdomain, System, AppDomain);
+static MonoDomain *
+mono_domain_from_appdomain_handle (MonoAppDomainHandle appdomain);
+
+static void
+mono_error_set_appdomain_unloaded (MonoError *error)
+{
+ mono_error_set_generic_error (error, "System", "AppDomainUnloadedException", "");
+}
void
mono_install_runtime_load (MonoLoadFunc func)
MonoDomain *
mono_domain_create_appdomain (char *friendly_name, char *configuration_file)
{
+ HANDLE_FUNCTION_ENTER ();
MonoError error;
- MonoAppDomain *ad;
- MonoAppDomainSetup *setup;
- MonoClass *klass;
+ MonoDomain *domain = mono_domain_create_appdomain_checked (friendly_name, configuration_file, &error);
+ mono_error_cleanup (&error);
+ HANDLE_FUNCTION_RETURN_VAL (domain);
+}
- klass = mono_class_load_from_name (mono_defaults.corlib, "System", "AppDomainSetup");
- setup = (MonoAppDomainSetup *) mono_object_new_checked (mono_domain_get (), klass, &error);
- if (!is_ok (&error))
- goto fail;
- setup->configuration_file = configuration_file != NULL ? mono_string_new (mono_domain_get (), configuration_file) : NULL;
+/**
+ * mono_domain_create_appdomain_checked:
+ * @friendly_name: The friendly name of the appdomain to create
+ * @configuration_file: The configuration file to initialize the appdomain with
+ * @error: Set on error.
+ *
+ * Returns a MonoDomain initialized with the appdomain. On failure sets @error and returns NULL.
+ */
+MonoDomain *
+mono_domain_create_appdomain_checked (char *friendly_name, char *configuration_file, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER ();
+ mono_error_init (error);
+ MonoDomain *result = NULL;
- ad = mono_domain_create_appdomain_internal (friendly_name, setup, &error);
- if (!is_ok (&error))
- goto fail;
+ MonoClass *klass = mono_class_load_from_name (mono_defaults.corlib, "System", "AppDomainSetup");
+ MonoAppDomainSetupHandle setup = MONO_HANDLE_NEW (MonoAppDomainSetup, mono_object_new_checked (mono_domain_get (), klass, error));
+ if (!is_ok (error))
+ goto leave;
+ MonoStringHandle config_file;
+ if (configuration_file != NULL) {
+ config_file = mono_string_new_handle (mono_domain_get (), configuration_file, error);
+ if (!is_ok (error))
+ goto leave;
+ } else {
+ config_file = MONO_HANDLE_NEW (MonoString, NULL);
+ }
+ MONO_HANDLE_SET (setup, configuration_file, config_file);
- return mono_domain_from_appdomain (ad);
-fail:
- mono_error_cleanup (&error);
- return NULL;
+ MonoAppDomainHandle ad = mono_domain_create_appdomain_internal (friendly_name, setup, error);
+ if (!is_ok (error))
+ goto leave;
+
+ result = mono_domain_from_appdomain_handle (ad);
+leave:
+ HANDLE_FUNCTION_RETURN_VAL (result);
}
/**
MONO_OBJECT_SETREF (domain->setup, configuration_file, mono_string_new (domain, config_file_name));
}
-static MonoAppDomainSetup*
-copy_app_domain_setup (MonoDomain *domain, MonoAppDomainSetup *setup, MonoError *error)
+static MonoAppDomainSetupHandle
+copy_app_domain_setup (MonoDomain *domain, MonoAppDomainSetupHandle setup, MonoError *error)
{
+ HANDLE_FUNCTION_ENTER ();
MonoDomain *caller_domain;
MonoClass *ads_class;
- MonoAppDomainSetup *copy;
+ MonoAppDomainSetupHandle result = MONO_HANDLE_NEW (MonoAppDomainSetup, NULL);
mono_error_init (error);
caller_domain = mono_domain_get ();
ads_class = mono_class_load_from_name (mono_defaults.corlib, "System", "AppDomainSetup");
- copy = (MonoAppDomainSetup*)mono_object_new_checked (domain, ads_class, error);
- return_val_if_nok (error, NULL);
+ MonoAppDomainSetupHandle copy = MONO_HANDLE_NEW (MonoAppDomainSetup, mono_object_new_checked (domain, ads_class, error));
+ if (!is_ok (error))
+ goto leave;
mono_domain_set_internal (domain);
-#define XCOPY_FIELD(dst,field,src,error) \
+#define XCOPY_FIELD(dst,field,src,error) \
do { \
- MonoObject *copied_val = mono_marshal_xdomain_copy_value ((MonoObject*)(src), error); \
- return_val_if_nok (error, NULL); \
- MONO_OBJECT_SETREF ((dst),field,copied_val); \
+ MonoObjectHandle src_val = MONO_HANDLE_NEW_GET (MonoObject, (src), field); \
+ MonoObjectHandle copied_val = mono_marshal_xdomain_copy_value_handle (src_val, error); \
+ if (!is_ok (error)) \
+ goto leave; \
+ MONO_HANDLE_SET ((dst),field,copied_val); \
} while (0)
- XCOPY_FIELD (copy, application_base, setup->application_base, error);
- XCOPY_FIELD (copy, application_name, setup->application_name, error);
- XCOPY_FIELD (copy, cache_path, setup->cache_path, error);
- XCOPY_FIELD (copy, configuration_file, setup->configuration_file, error);
- XCOPY_FIELD (copy, dynamic_base, setup->dynamic_base, error);
- XCOPY_FIELD (copy, license_file, setup->license_file, error);
- XCOPY_FIELD (copy, private_bin_path, setup->private_bin_path, error);
- XCOPY_FIELD (copy, private_bin_path_probe, setup->private_bin_path_probe, error);
- XCOPY_FIELD (copy, shadow_copy_directories, setup->shadow_copy_directories, error);
- XCOPY_FIELD (copy, shadow_copy_files, setup->shadow_copy_files, error);
- copy->publisher_policy = setup->publisher_policy;
- copy->path_changed = setup->path_changed;
- copy->loader_optimization = setup->loader_optimization;
- copy->disallow_binding_redirects = setup->disallow_binding_redirects;
- copy->disallow_code_downloads = setup->disallow_code_downloads;
- XCOPY_FIELD (copy, domain_initializer_args, setup->domain_initializer_args, error);
- copy->disallow_appbase_probe = setup->disallow_appbase_probe;
- XCOPY_FIELD (copy, application_trust, setup->application_trust, error);
- XCOPY_FIELD (copy, configuration_bytes, setup->configuration_bytes, error);
- XCOPY_FIELD (copy, serialized_non_primitives, setup->serialized_non_primitives, error);
-
-#undef COPY_FIELD
+#define COPY_VAL(dst,field,type,src) \
+ do { \
+ MONO_HANDLE_SETVAL ((dst), field, type, MONO_HANDLE_GETVAL ((src),field)); \
+ } while (0)
+
+ XCOPY_FIELD (copy, application_base, setup, error);
+ XCOPY_FIELD (copy, application_name, setup, error);
+ XCOPY_FIELD (copy, cache_path, setup, error);
+ XCOPY_FIELD (copy, configuration_file, setup, error);
+ XCOPY_FIELD (copy, dynamic_base, setup, error);
+ XCOPY_FIELD (copy, license_file, setup, error);
+ XCOPY_FIELD (copy, private_bin_path, setup, error);
+ XCOPY_FIELD (copy, private_bin_path_probe, setup, error);
+ XCOPY_FIELD (copy, shadow_copy_directories, setup, error);
+ XCOPY_FIELD (copy, shadow_copy_files, setup, error);
+ COPY_VAL (copy, publisher_policy, MonoBoolean, setup);
+ COPY_VAL (copy, path_changed, MonoBoolean, setup);
+ COPY_VAL (copy, loader_optimization, int, setup);
+ COPY_VAL (copy, disallow_binding_redirects, MonoBoolean, setup);
+ COPY_VAL (copy, disallow_code_downloads, MonoBoolean, setup);
+ XCOPY_FIELD (copy, domain_initializer_args, setup, error);
+ COPY_VAL (copy, disallow_appbase_probe, MonoBoolean, setup);
+ XCOPY_FIELD (copy, application_trust, setup, error);
+ XCOPY_FIELD (copy, configuration_bytes, setup, error);
+ XCOPY_FIELD (copy, serialized_non_primitives, setup, error);
+
+#undef XCOPY_FIELD
+#undef COPY_VAL
mono_domain_set_internal (caller_domain);
- return copy;
+ MONO_HANDLE_ASSIGN (result, copy);
+leave:
+ HANDLE_FUNCTION_RETURN_REF (MonoAppDomainSetup, result);
}
-static MonoAppDomain *
-mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetup *setup, MonoError *error)
+static MonoAppDomainHandle
+mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetupHandle setup, MonoError *error)
{
+ HANDLE_FUNCTION_ENTER ();
+ MonoAppDomainHandle result = MONO_HANDLE_NEW (MonoAppDomain, NULL);
MonoClass *adclass;
- MonoAppDomain *ad;
MonoDomain *data;
- char *shadow_location;
mono_error_init (error);
/* FIXME: pin all those objects */
data = mono_domain_create();
- ad = (MonoAppDomain *) mono_object_new_checked (data, adclass, error);
- return_val_if_nok (error, NULL);
- ad->data = data;
- data->domain = ad;
+ MonoAppDomainHandle ad = MONO_HANDLE_NEW (MonoAppDomain, mono_object_new_checked (data, adclass, error));
+ if (!is_ok (error))
+ goto leave;
+ MONO_HANDLE_SETVAL (ad, data, MonoDomain*, data);
+ data->domain = MONO_HANDLE_RAW (ad);
data->friendly_name = g_strdup (friendly_name);
mono_profiler_appdomain_name (data, data->friendly_name);
- if (!setup->application_base) {
+ MonoStringHandle app_base = MONO_HANDLE_NEW_GET (MonoString, setup, application_base);
+ if (MONO_HANDLE_IS_NULL (app_base)) {
/* Inherit from the root domain since MS.NET does this */
MonoDomain *root = mono_get_root_domain ();
- if (root->setup->application_base) {
- MonoString *s = mono_string_new_utf16_checked (data, mono_string_chars (root->setup->application_base), mono_string_length (root->setup->application_base), error);
- mono_error_assert_ok (error); /* FIXME don't swallow the error */
- MONO_OBJECT_SETREF (setup, application_base, s);
+ MonoAppDomainSetupHandle root_setup = MONO_HANDLE_NEW (MonoAppDomainSetup, root->setup);
+ MonoStringHandle root_app_base = MONO_HANDLE_NEW_GET (MonoString, root_setup, application_base);
+ if (!MONO_HANDLE_IS_NULL (root_app_base)) {
+ /* N.B. new string is in the new domain */
+ uint32_t gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, root_app_base), TRUE);
+ MonoStringHandle s = mono_string_new_utf16_handle (data, mono_string_chars (MONO_HANDLE_RAW (root_app_base)), mono_string_handle_length (root_app_base), error);
+ mono_gchandle_free (gchandle);
+ if (!is_ok (error)) {
+ g_free (data->friendly_name);
+ goto leave;
+ }
+ MONO_HANDLE_SET (setup, application_base, s);
}
}
mono_context_init_checked (data, error);
- return_val_if_nok (error, NULL);
+ if (!is_ok (error))
+ goto leave;
- data->setup = copy_app_domain_setup (data, setup, error);
+ data->setup = MONO_HANDLE_RAW (copy_app_domain_setup (data, setup, error));
if (!mono_error_ok (error)) {
g_free (data->friendly_name);
- return NULL;
+ goto leave;
}
mono_domain_set_options_from_config (data);
#ifndef DISABLE_SHADOW_COPY
/*FIXME, guard this for when the debugger is not running */
- shadow_location = get_shadow_assembly_location_base (data, error);
+ char *shadow_location = get_shadow_assembly_location_base (data, error);
if (!mono_error_ok (error)) {
g_free (data->friendly_name);
- return NULL;
+ goto leave;
}
g_free (shadow_location);
create_domain_objects (data);
- return ad;
+ MONO_HANDLE_ASSIGN (result, ad);
+leave:
+ HANDLE_FUNCTION_RETURN_REF (MonoAppDomain, result);
}
/**
return TRUE;
}
-MonoObject *
-ves_icall_System_AppDomain_GetData (MonoAppDomain *ad, MonoString *name)
+MonoObjectHandle
+ves_icall_System_AppDomain_GetData (MonoAppDomainHandle ad, MonoStringHandle name, MonoError *error)
{
- MonoError error;
- MonoDomain *add;
- MonoObject *o;
- char *str;
+ mono_error_init (error);
- MONO_CHECK_ARG_NULL (name, NULL);
+ if (MONO_HANDLE_IS_NULL (name)) {
+ mono_error_set_argument_null (error, "name", "");
+ return NULL_HANDLE;
+ }
- g_assert (ad);
- add = ad->data;
+ g_assert (!MONO_HANDLE_IS_NULL (ad));
+ MonoDomain *add = MONO_HANDLE_GETVAL (ad, data);
g_assert (add);
- str = mono_string_to_utf8_checked (name, &error);
- if (mono_error_set_pending_exception (&error))
- return NULL;
+ char *str = mono_string_handle_to_utf8 (name, error);
+ return_val_if_nok (error, NULL_HANDLE);
mono_domain_lock (add);
+ MonoAppDomainSetupHandle ad_setup = MONO_HANDLE_NEW (MonoAppDomainSetup, add->setup);
+ MonoStringHandle o;
if (!strcmp (str, "APPBASE"))
- o = (MonoObject *)add->setup->application_base;
+ o = MONO_HANDLE_NEW_GET (MonoString, ad_setup, application_base);
else if (!strcmp (str, "APP_CONFIG_FILE"))
- o = (MonoObject *)add->setup->configuration_file;
+ o = MONO_HANDLE_NEW_GET (MonoString, ad_setup, configuration_file);
else if (!strcmp (str, "DYNAMIC_BASE"))
- o = (MonoObject *)add->setup->dynamic_base;
+ o = MONO_HANDLE_NEW_GET (MonoString, ad_setup, dynamic_base);
else if (!strcmp (str, "APP_NAME"))
- o = (MonoObject *)add->setup->application_name;
+ o = MONO_HANDLE_NEW_GET (MonoString, ad_setup, application_name);
else if (!strcmp (str, "CACHE_BASE"))
- o = (MonoObject *)add->setup->cache_path;
+ o = MONO_HANDLE_NEW_GET (MonoString, ad_setup, cache_path);
else if (!strcmp (str, "PRIVATE_BINPATH"))
- o = (MonoObject *)add->setup->private_bin_path;
+ o = MONO_HANDLE_NEW_GET (MonoString, ad_setup, private_bin_path);
else if (!strcmp (str, "BINPATH_PROBE_ONLY"))
- o = (MonoObject *)add->setup->private_bin_path_probe;
+ o = MONO_HANDLE_NEW_GET (MonoString, ad_setup, private_bin_path_probe);
else if (!strcmp (str, "SHADOW_COPY_DIRS"))
- o = (MonoObject *)add->setup->shadow_copy_directories;
+ o = MONO_HANDLE_NEW_GET (MonoString, ad_setup, shadow_copy_directories);
else if (!strcmp (str, "FORCE_CACHE_INSTALL"))
- o = (MonoObject *)add->setup->shadow_copy_files;
+ o = MONO_HANDLE_NEW_GET (MonoString, ad_setup, shadow_copy_files);
else
- o = (MonoObject *)mono_g_hash_table_lookup (add->env, name);
+ o = MONO_HANDLE_NEW (MonoString, mono_g_hash_table_lookup (add->env, MONO_HANDLE_RAW (name)));
mono_domain_unlock (add);
g_free (str);
- if (!o)
- return NULL;
-
- return o;
+ return MONO_HANDLE_CAST (MonoObject, o);
}
void
-ves_icall_System_AppDomain_SetData (MonoAppDomain *ad, MonoString *name, MonoObject *data)
+ves_icall_System_AppDomain_SetData (MonoAppDomainHandle ad, MonoStringHandle name, MonoObjectHandle data, MonoError *error)
{
- MonoDomain *add;
+ mono_error_init (error);
- MONO_CHECK_ARG_NULL (name,);
+ if (MONO_HANDLE_IS_NULL (name)) {
+ mono_error_set_argument_null (error, "name", "");
+ return;
+ }
- g_assert (ad);
- add = ad->data;
+ g_assert (!MONO_HANDLE_IS_NULL (ad));
+ MonoDomain *add = MONO_HANDLE_GETVAL (ad, data);
g_assert (add);
mono_domain_lock (add);
- mono_g_hash_table_insert (add->env, name, data);
+ mono_g_hash_table_insert (add->env, MONO_HANDLE_RAW (name), MONO_HANDLE_RAW (data));
mono_domain_unlock (add);
}
-MonoAppDomainSetup *
-ves_icall_System_AppDomain_getSetup (MonoAppDomain *ad)
+MonoAppDomainSetupHandle
+ves_icall_System_AppDomain_getSetup (MonoAppDomainHandle ad, MonoError *error)
{
- g_assert (ad);
- g_assert (ad->data);
+ mono_error_init (error);
+ g_assert (!MONO_HANDLE_IS_NULL (ad));
+ MonoDomain *domain = MONO_HANDLE_GETVAL (ad, data);
+ g_assert (domain);
- return ad->data->setup;
+ return MONO_HANDLE_NEW (MonoAppDomainSetup, domain->setup);
}
-MonoString *
-ves_icall_System_AppDomain_getFriendlyName (MonoAppDomain *ad)
+MonoStringHandle
+ves_icall_System_AppDomain_getFriendlyName (MonoAppDomainHandle ad, MonoError *error)
{
- g_assert (ad);
- g_assert (ad->data);
+ mono_error_init (error);
+ g_assert (!MONO_HANDLE_IS_NULL (ad));
+ MonoDomain *domain = MONO_HANDLE_GETVAL (ad, data);
+ g_assert (domain);
- return mono_string_new (ad->data, ad->data->friendly_name);
+ return mono_string_new_handle (domain, domain->friendly_name, error);
}
-MonoAppDomain *
-ves_icall_System_AppDomain_getCurDomain ()
+MonoAppDomainHandle
+ves_icall_System_AppDomain_getCurDomain (MonoError *error)
{
+ mono_error_init (error);
MonoDomain *add = mono_domain_get ();
- return add->domain;
+ return MONO_HANDLE_NEW (MonoAppDomain, add->domain);
}
-MonoAppDomain *
-ves_icall_System_AppDomain_getRootDomain ()
+MonoAppDomainHandle
+ves_icall_System_AppDomain_getRootDomain (MonoError *error)
{
+ mono_error_init (error);
MonoDomain *root = mono_get_root_domain ();
- return root->domain;
+ return MONO_HANDLE_NEW (MonoAppDomain, root->domain);
}
MonoBoolean
g_free (config_file_path);
}
-MonoAppDomain *
-ves_icall_System_AppDomain_createDomain (MonoString *friendly_name, MonoAppDomainSetup *setup)
+MonoAppDomainHandle
+ves_icall_System_AppDomain_createDomain (MonoStringHandle friendly_name, MonoAppDomainSetupHandle setup, MonoError *error)
{
- MonoError error;
- MonoAppDomain *ad = NULL;
+ mono_error_init (error);
+ MonoAppDomainHandle ad = MONO_HANDLE_NEW (MonoAppDomain, NULL);
#ifdef DISABLE_APPDOMAINS
- mono_error_init (&error);
- mono_error_set_not_supported (&error, "AppDomain creation is not supported on this runtime.");
+ mono_error_set_not_supported (error, "AppDomain creation is not supported on this runtime.");
#else
char *fname;
- fname = mono_string_to_utf8_checked (friendly_name, &error);
- if (mono_error_set_pending_exception (&error))
- return NULL;
- ad = mono_domain_create_appdomain_internal (fname, setup, &error);
-
+ fname = mono_string_handle_to_utf8 (friendly_name, error);
+ return_val_if_nok (error, ad);
+ ad = mono_domain_create_appdomain_internal (fname, setup, error);
g_free (fname);
#endif
- mono_error_set_pending_exception (&error);
return ad;
}
{
guint16 *orig, *dest;
gboolean copy_result;
+ gint32 copy_error;
strcpy (src + srclen - tail_len, extension);
strcpy (target + targetlen - tail_len, extension);
dest = g_utf8_to_utf16 (target, strlen (target), NULL, NULL, NULL);
- DeleteFile (dest);
+ mono_w32file_delete (dest);
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
- copy_result = CopyFile (orig, dest, FALSE);
-#else
- copy_result = SUCCEEDED (CopyFile2 (orig, dest, NULL));
-#endif
+ copy_result = mono_w32file_copy (orig, dest, TRUE, ©_error);
/* Fix for bug #556884 - make sure the files have the correct mode so that they can be
* overwritten when updated in their original locations. */
if (copy_result)
- copy_result = SetFileAttributes (dest, FILE_ATTRIBUTE_NORMAL);
+ copy_result = mono_w32file_set_attributes (dest, FILE_ATTRIBUTE_NORMAL);
g_free (orig);
g_free (dest);
if (!u16_ini) {
return FALSE;
}
- handle = (void **)CreateFile (u16_ini, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL, CREATE_NEW, FileAttributes_Normal, NULL);
+ handle = (void **)mono_w32file_create (u16_ini, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, CREATE_NEW, FileAttributes_Normal);
g_free (u16_ini);
if (handle == INVALID_HANDLE_VALUE) {
return FALSE;
}
full_path = mono_path_resolve_symlinks (filename);
- result = WriteFile (handle, full_path, strlen (full_path), &n, NULL);
+ result = mono_w32file_write (handle, full_path, strlen (full_path), &n);
g_free (full_path);
- CloseHandle (handle);
+ mono_w32file_close (handle);
return result;
}
char *dir_name = g_path_get_dirname (filename);
MonoDomain *domain = mono_domain_get ();
char *shadow_dir;
+ gint32 copy_error;
mono_error_init (oerror);
orig = g_utf8_to_utf16 (filename, strlen (filename), NULL, NULL, NULL);
dest = g_utf8_to_utf16 (shadow, strlen (shadow), NULL, NULL, NULL);
- DeleteFile (dest);
+ mono_w32file_delete (dest);
/* Fix for bug #17066 - make sure we can read the file. if not then don't error but rather
* let the assembly fail to load. This ensures you can do Type.GetType("NS.T, NonExistantAssembly)
* and not have it runtime error" */
- attrs = GetFileAttributes (orig);
+ attrs = mono_w32file_get_attributes (orig);
if (attrs == INVALID_FILE_ATTRIBUTES) {
g_free (shadow);
return (char *)filename;
}
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
- copy_result = CopyFile (orig, dest, FALSE);
-#else
- copy_result = SUCCEEDED (CopyFile2 (orig, dest, NULL));
-#endif
+ copy_result = mono_w32file_copy (orig, dest, TRUE, ©_error);
/* Fix for bug #556884 - make sure the files have the correct mode so that they can be
* overwritten when updated in their original locations. */
if (copy_result)
- copy_result = SetFileAttributes (dest, FILE_ATTRIBUTE_NORMAL);
+ copy_result = mono_w32file_set_attributes (dest, FILE_ATTRIBUTE_NORMAL);
g_free (dest);
g_free (orig);
g_free (shadow);
/* Fix for bug #17251 - if file not found try finding assembly by other means (it is not fatal error) */
- if (GetLastError() == ERROR_FILE_NOT_FOUND || GetLastError() == ERROR_PATH_NOT_FOUND)
+ if (mono_w32error_get_last() == ERROR_FILE_NOT_FOUND || mono_w32error_get_last() == ERROR_PATH_NOT_FOUND)
return NULL; /* file not found, shadow copy failed */
- mono_error_set_execution_engine (oerror, "Failed to create shadow copy (CopyFile).");
+ mono_error_set_execution_engine (oerror, "Failed to create shadow copy (mono_w32file_copy).");
return NULL;
}
if (!copy_result) {
g_free (shadow);
- mono_error_set_execution_engine (oerror, "Failed to create shadow copy of sibling data (CopyFile).");
+ mono_error_set_execution_engine (oerror, "Failed to create shadow copy of sibling data (mono_w32file_copy).");
return NULL;
}
#endif /* DISABLE_SHADOW_COPY */
MonoDomain *
-mono_domain_from_appdomain (MonoAppDomain *appdomain)
+mono_domain_from_appdomain (MonoAppDomain *appdomain_raw)
{
- if (appdomain == NULL)
- return NULL;
+ HANDLE_FUNCTION_ENTER ();
+ MONO_HANDLE_DCL (MonoAppDomain, appdomain);
+ MonoDomain *result = mono_domain_from_appdomain_handle (appdomain);
+ HANDLE_FUNCTION_RETURN_VAL (result);
+}
- if (mono_object_is_transparent_proxy (&appdomain->mbr.obj)) {
- MonoTransparentProxy *tp = (MonoTransparentProxy*)appdomain;
- return mono_domain_get_by_id (tp->rp->target_domain_id);
- }
-
- return appdomain->data;
+MonoDomain *
+mono_domain_from_appdomain_handle (MonoAppDomainHandle appdomain)
+{
+ HANDLE_FUNCTION_ENTER ();
+ MonoDomain *dom = NULL;
+ if (MONO_HANDLE_IS_NULL (appdomain))
+ goto leave;
+
+ if (mono_class_is_transparent_proxy (mono_handle_class (appdomain))) {
+ MonoTransparentProxyHandle tp = MONO_HANDLE_CAST (MonoTransparentProxy, appdomain);
+ MonoRealProxyHandle rp = MONO_HANDLE_NEW_GET (MonoRealProxy, tp, rp);
+
+ dom = mono_domain_get_by_id (MONO_HANDLE_GETVAL (rp, target_domain_id));
+ } else
+ dom = MONO_HANDLE_GETVAL (appdomain, data);
+
+leave:
+ HANDLE_FUNCTION_RETURN_VAL (dom);
}
+
static gboolean
try_load_from (MonoAssembly **assembly, const gchar *path1, const gchar *path2,
const gchar *path3, const gchar *path4,
}
void
-ves_icall_System_AppDomain_InternalUnload (gint32 domain_id)
+ves_icall_System_AppDomain_InternalUnload (gint32 domain_id, MonoError *error)
{
- MonoException *exc = NULL;
+ mono_error_init (error);
MonoDomain * domain = mono_domain_get_by_id (domain_id);
if (NULL == domain) {
- mono_get_exception_execution_engine ("Failed to unload domain, domain id not found");
- mono_set_pending_exception (exc);
+ mono_error_set_execution_engine (error, "Failed to unload domain, domain id not found");
return;
}
if (domain == mono_get_root_domain ()) {
- mono_set_pending_exception (mono_get_exception_cannot_unload_appdomain ("The default appdomain can not be unloaded."));
+ mono_error_set_generic_error (error, "System", "CannotUnloadAppDomainException", "The default appdomain can not be unloaded.");
return;
}
return;
#endif
+ MonoException *exc = NULL;
mono_domain_try_unload (domain, (MonoObject**)&exc);
if (exc)
- mono_set_pending_exception (exc);
+ mono_error_set_exception_instance (error, exc);
}
gboolean
-ves_icall_System_AppDomain_InternalIsFinalizingForUnload (gint32 domain_id)
+ves_icall_System_AppDomain_InternalIsFinalizingForUnload (gint32 domain_id, MonoError *error)
{
+ mono_error_init (error);
MonoDomain *domain = mono_domain_get_by_id (domain_id);
if (!domain)
return ad->data->domain_id;
}
-MonoAppDomain *
-ves_icall_System_AppDomain_InternalSetDomain (MonoAppDomain *ad)
+MonoAppDomainHandle
+ves_icall_System_AppDomain_InternalSetDomain (MonoAppDomainHandle ad, MonoError* error)
{
- MonoDomain *old_domain = mono_domain_get();
+ mono_error_init (error);
+ MonoDomain *old_domain = mono_domain_get ();
- if (!mono_domain_set (ad->data, FALSE)) {
- mono_set_pending_exception (mono_get_exception_appdomain_unloaded ());
- return NULL;
+ if (!mono_domain_set (MONO_HANDLE_GETVAL (ad, data), FALSE)) {
+ mono_error_set_appdomain_unloaded (error);
+ return MONO_HANDLE_CAST (MonoAppDomain, NULL_HANDLE);
}
- return old_domain->domain;
+ return MONO_HANDLE_NEW (MonoAppDomain, old_domain->domain);
}
-MonoAppDomain *
-ves_icall_System_AppDomain_InternalSetDomainByID (gint32 domainid)
+MonoAppDomainHandle
+ves_icall_System_AppDomain_InternalSetDomainByID (gint32 domainid, MonoError *error)
{
MonoDomain *current_domain = mono_domain_get ();
MonoDomain *domain = mono_domain_get_by_id (domainid);
if (!domain || !mono_domain_set (domain, FALSE)) {
- mono_set_pending_exception (mono_get_exception_appdomain_unloaded ());
- return NULL;
+ mono_error_set_appdomain_unloaded (error);
+ return MONO_HANDLE_CAST (MonoAppDomain, NULL_HANDLE);
}
- return current_domain->domain;
+ return MONO_HANDLE_NEW (MonoAppDomain, current_domain->domain);
}
void
-ves_icall_System_AppDomain_InternalPushDomainRef (MonoAppDomain *ad)
+ves_icall_System_AppDomain_InternalPushDomainRef (MonoAppDomainHandle ad, MonoError *error)
{
- mono_thread_push_appdomain_ref (ad->data);
+ mono_error_init (error);
+ mono_thread_push_appdomain_ref (MONO_HANDLE_GETVAL (ad, data));
}
void
-ves_icall_System_AppDomain_InternalPushDomainRefByID (gint32 domain_id)
+ves_icall_System_AppDomain_InternalPushDomainRefByID (gint32 domain_id, MonoError *error)
{
+ mono_error_init (error);
MonoDomain *domain = mono_domain_get_by_id (domain_id);
if (!domain) {
* Raise an exception to prevent the managed code from executing a pop
* later.
*/
- mono_set_pending_exception (mono_get_exception_appdomain_unloaded ());
+ mono_error_set_appdomain_unloaded (error);
return;
}
}
void
-ves_icall_System_AppDomain_InternalPopDomainRef (void)
+ves_icall_System_AppDomain_InternalPopDomainRef (MonoError *error)
{
+ mono_error_init (error);
mono_thread_pop_appdomain_ref ();
}
return old_context;
}
-MonoString *
-ves_icall_System_AppDomain_InternalGetProcessGuid (MonoString* newguid)
+MonoStringHandle
+ves_icall_System_AppDomain_InternalGetProcessGuid (MonoStringHandle newguid, MonoError *error)
{
+ mono_error_init (error);
MonoDomain* mono_root_domain = mono_get_root_domain ();
mono_domain_lock (mono_root_domain);
if (process_guid_set) {
mono_domain_unlock (mono_root_domain);
- MonoError error;
- MonoString *res = NULL;
- res = mono_string_new_utf16_checked (mono_domain_get (), process_guid, sizeof(process_guid)/2, &error);
- mono_error_set_pending_exception (&error);
- return res;
+ return mono_string_new_utf16_handle (mono_domain_get (), process_guid, sizeof(process_guid)/2, error);
}
- memcpy (process_guid, mono_string_chars(newguid), sizeof(process_guid));
+ uint32_t gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, newguid), TRUE);
+ memcpy (process_guid, mono_string_chars(MONO_HANDLE_RAW (newguid)), sizeof(process_guid));
+ mono_gchandle_free (gchandle);
process_guid_set = TRUE;
mono_domain_unlock (mono_root_domain);
return newguid;
/* Force it to be attached to avoid racing during shutdown. */
thread = mono_thread_attach_full (mono_get_root_domain (), TRUE);
- mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "Domain unloader"), TRUE, &error);
+ mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "Domain unloader"), TRUE, FALSE, &error);
if (!is_ok (&error)) {
data->failure_reason = g_strdup (mono_error_get_message (&error));
mono_error_cleanup (&error);
MONO_API mono_bool
mono_domain_is_unloading (MonoDomain *domain);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoDomain *
mono_domain_from_appdomain (MonoAppDomain *appdomain);
#include <mono/metadata/reflection-internals.h>
#include <mono/metadata/mono-endian.h>
#include <mono/metadata/mono-debug.h>
-#include <mono/io-layer/io-layer.h>
#include <mono/utils/mono-uri.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/mono-config-dirs.h>
{"System.EnterpriseServices", 0},
{"System.IdentityModel", 3},
{"System.IdentityModel.Selectors", 3},
+ {"System.IO.Compression", 2},
{"System.Management", 0},
{"System.Messaging", 0},
{"System.Net", 2},
+ {"System.Net.Http", 3},
+ {"System.Numerics.Vectors", 3},
+ {"System.Runtime.InteropServices.RuntimeInformation", 2},
{"System.Runtime.Remoting", 0},
{"System.Runtime.Serialization", 3},
+ {"System.Runtime.Serialization.Formatters", 3},
{"System.Runtime.Serialization.Formatters.Soap", 0},
{"System.Security", 0},
{"System.ServiceModel", 3},
+ {"System.ServiceModel.Duplex", 3},
+ {"System.ServiceModel.Http", 3},
+ {"System.ServiceModel.NetTcp", 3},
+ {"System.ServiceModel.Primitives", 3},
+ {"System.ServiceModel.Security", 3},
{"System.ServiceModel.Web", 2},
{"System.ServiceProcess", 0},
+ {"System.Text.Encoding.CodePages", 3},
{"System.Transactions", 0},
{"System.Web", 0},
{"System.Web.Abstractions", 2},
{"System.Windows.Forms", 0},
{"System.Xml", 0},
{"System.Xml.Linq", 2},
+ {"System.Xml.ReaderWriter", 3},
+ {"System.Xml.XPath.XmlDocument", 3},
{"WindowsBase", 3},
{"mscorlib", 0}
};
static GSList *loaded_assembly_bindings = NULL;
/* Class lazy loading functions */
-static GENERATE_TRY_GET_CLASS_WITH_CACHE (internals_visible, System.Runtime.CompilerServices, InternalsVisibleToAttribute)
+static GENERATE_TRY_GET_CLASS_WITH_CACHE (internals_visible, "System.Runtime.CompilerServices", "InternalsVisibleToAttribute")
static MonoAssembly*
mono_assembly_invoke_search_hook_internal (MonoAssemblyName *aname, MonoAssembly *requesting, gboolean refonly, gboolean postload);
static MonoAssembly*
if (strstr (aname->name, ".dll")) {
len = strlen (aname->name) - 4;
name = (gchar *)g_malloc (len + 1);
- strncpy (name, aname->name, len);
+ memcpy (name, aname->name, len);
name[len] = 0;
} else
name = g_strdup (aname->name);
if (strstr (aname->name, ".dll")) {
len = strlen (filename) - 4;
name = (gchar *)g_malloc (len + 1);
- strncpy (name, aname->name, len);
+ memcpy (name, aname->name, len);
name[len] = 0;
} else {
name = g_strdup (aname->name);
#include <sys/stat.h>
#include <sys/un.h>
#include <netinet/in.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include <inttypes.h>
#include <pwd.h>
#include <mono/utils/mono-threads.h>
#include "attach.h"
-#include <mono/io-layer/io-layer.h>
+#include <mono/utils/w32api.h>
/*
* This module enables other processes to attach to a running mono process and
printf ("attach: Connected.\n");
MonoThread *thread = mono_thread_attach (mono_get_root_domain ());
- mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "Attach receiver"), TRUE, &error);
+ mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "Attach receiver"), TRUE, FALSE, &error);
mono_error_assert_ok (&error);
/* Ask the runtime to not abort this thread */
//mono_thread_current ()->flags |= MONO_THREAD_FLAG_DONT_MANAGE;
MONO_TABLE_LOCALVARIABLE,
MONO_TABLE_LOCALCONSTANT,
MONO_TABLE_IMPORTSCOPE,
- MONO_TABLE_ASYNCMETHOD,
+ MONO_TABLE_STATEMACHINEMETHOD,
MONO_TABLE_CUSTOMDEBUGINFORMATION
#define MONO_TABLE_LAST MONO_TABLE_CUSTOMDEBUGINFORMATION
prop->value = value;
mono_property_bag_add (&class->infrequent_data, prop);
}
+
+void
+mono_class_set_is_com_object (MonoClass *klass)
+{
+#ifndef DISABLE_COM
+ mono_loader_lock ();
+ klass->is_com_object = 1;
+ mono_loader_unlock ();
+#endif
+}
* to 1, because we know the instance size now. After that we
* initialise all static fields.
*/
- /* size_inited is accessed without locks, so it needs a memory barrier */
- /* All flag bits should be written while holding the loader lock */
+
+ /* ALL BITFIELDS SHOULD BE WRITTEN WHILE HOLDING THE LOADER LOCK */
guint size_inited : 1;
guint valuetype : 1; /* derives from System.ValueType */
guint enumtype : 1; /* derives from System.Enum */
#ifdef DISABLE_COM
#define mono_class_is_com_object(klass) (FALSE)
-#define mono_class_set_is_com_object(klass) do {} while (0)
#else
#define mono_class_is_com_object(klass) ((klass)->is_com_object)
-#define mono_class_set_is_com_object(klass) do { (klass)->is_com_object = 1; } while (0)
#endif
MonoGenericContext *generic_context);
MonoMethod*
-mono_class_get_cctor (MonoClass *klass);
+mono_class_get_cctor (MonoClass *klass) MONO_LLVM_INTERNAL;
MonoMethod*
mono_class_get_finalizer (MonoClass *klass);
#define GENERATE_TRY_GET_CLASS_WITH_CACHE_DECL(shortname) \
MonoClass* mono_class_try_get_##shortname##_class (void);
-#define GENERATE_GET_CLASS_WITH_CACHE(shortname,namespace,name) \
+#define GENERATE_GET_CLASS_WITH_CACHE(shortname,name_space,name) \
MonoClass* \
mono_class_get_##shortname##_class (void) \
{ \
static MonoClass *tmp_class; \
MonoClass *klass = tmp_class; \
if (!klass) { \
- klass = mono_class_load_from_name (mono_defaults.corlib, #namespace, #name); \
+ klass = mono_class_load_from_name (mono_defaults.corlib, name_space, name); \
mono_memory_barrier (); \
tmp_class = klass; \
} \
return klass; \
}
-#define GENERATE_TRY_GET_CLASS_WITH_CACHE(shortname,namespace,name) \
+#define GENERATE_TRY_GET_CLASS_WITH_CACHE(shortname,name_space,name) \
MonoClass* \
mono_class_try_get_##shortname##_class (void) \
{ \
MonoClass *klass = (MonoClass *)tmp_class; \
mono_memory_barrier (); \
if (!inited) { \
- klass = mono_class_try_load_from_name (mono_defaults.corlib, #namespace, #name); \
+ klass = mono_class_try_load_from_name (mono_defaults.corlib, name_space, name); \
tmp_class = klass; \
mono_memory_barrier (); \
inited = TRUE; \
int
mono_method_get_vtable_index (MonoMethod *method);
+MonoMethod*
+mono_method_get_base_method (MonoMethod *method, gboolean definition, MonoError *error);
+
MonoMethod*
mono_method_search_in_array_class (MonoClass *klass, const char *name, MonoMethodSignature *sig);
void
mono_class_set_declsec_flags (MonoClass *class, guint32 value);
+void
+mono_class_set_is_com_object (MonoClass *klass);
+
/*Now that everything has been defined, let's include the inline functions */
#include <mono/metadata/class-inlines.h>
static gboolean can_access_type (MonoClass *access_klass, MonoClass *member_klass);
static MonoMethod* find_method_in_metadata (MonoClass *klass, const char *name, int param_count, int flags);
static int generic_array_methods (MonoClass *klass);
-static void setup_generic_array_ifaces (MonoClass *klass, MonoClass *iface, MonoMethod **methods, int pos);
+static void setup_generic_array_ifaces (MonoClass *klass, MonoClass *iface, MonoMethod **methods, int pos, GHashTable *cache);
static MonoMethod* mono_class_get_virtual_methods (MonoClass* klass, gpointer *iter);
static char* mono_assembly_name_from_token (MonoImage *image, guint32 type_token);
init_sizes_with_info (MonoClass *klass, MonoCachedClassInfo *cached_info)
{
if (cached_info) {
+ mono_loader_lock ();
klass->instance_size = cached_info->instance_size;
klass->sizes.class_size = cached_info->class_size;
klass->packing_size = cached_info->packing_size;
klass->has_references = cached_info->has_references;
klass->has_static_refs = cached_info->has_static_refs;
klass->no_special_static_fields = cached_info->no_special_static_fields;
+ mono_loader_unlock ();
}
else {
if (!klass->size_inited)
amethod = create_array_method (klass, "Set", sig);
methods [method_num++] = amethod;
+ GHashTable *cache = g_hash_table_new (NULL, NULL);
for (i = 0; i < klass->interface_count; i++)
- setup_generic_array_ifaces (klass, klass->interfaces [i], methods, first_generic + i * count_generic);
+ setup_generic_array_ifaces (klass, klass->interfaces [i], methods, first_generic + i * count_generic, cache);
+ g_hash_table_destroy (cache);
} else if (mono_class_has_static_metadata (klass)) {
MonoError error;
int first_idx = mono_class_get_first_method_idx (klass);
}
static void
-setup_generic_array_ifaces (MonoClass *klass, MonoClass *iface, MonoMethod **methods, int pos)
+setup_generic_array_ifaces (MonoClass *klass, MonoClass *iface, MonoMethod **methods, int pos, GHashTable *cache)
{
MonoGenericContext tmp_context;
int i;
for (i = 0; i < generic_array_method_num; i++) {
MonoError error;
MonoMethod *m = generic_array_method_info [i].array_method;
- MonoMethod *inflated;
+ MonoMethod *inflated, *helper;
inflated = mono_class_inflate_generic_method_checked (m, &tmp_context, &error);
- g_assert (mono_error_ok (&error)); /*FIXME proper error handling*/
- methods [pos++] = mono_marshal_get_generic_array_helper (klass, iface, generic_array_method_info [i].name, inflated);
+ mono_error_assert_ok (&error);
+ helper = g_hash_table_lookup (cache, inflated);
+ if (!helper) {
+ helper = mono_marshal_get_generic_array_helper (klass, generic_array_method_info [i].name, inflated);
+ g_hash_table_insert (cache, inflated, helper);
+ }
+ methods [pos ++] = helper;
}
}
}
}
- mono_image_lock (klass->image);
-
+ mono_loader_lock ();
if (!klass->has_finalize_inited) {
klass->has_finalize = has_finalize ? 1 : 0;
mono_memory_barrier ();
klass->has_finalize_inited = TRUE;
}
-
- mono_image_unlock (klass->image);
+ mono_loader_unlock ();
return klass->has_finalize;
}
mono_error_cleanup (&error);
}
}
+ mono_loader_lock ();
if (klass->parent)
mono_class_setup_parent (klass, klass->parent);
klass->cast_class = gtd->cast_class;
klass->element_class = gtd->element_class;
}
+ mono_loader_unlock ();
}
gboolean
/*A TypeBuilder can have more interfaces on tb->interfaces than on candidate->interfaces*/
if (image_is_dynamic (candidate->image) && !candidate->wastypebuilder) {
- MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)mono_class_get_ref_info (candidate);
+ MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)mono_class_get_ref_info_raw (candidate); /* FIXME use handles */
int j;
if (tb && tb->interfaces) {
for (j = mono_array_length (tb->interfaces) - 1; j >= 0; --j) {
if (klass->nested_classes_inited)
return;
- if (!klass->type_token)
+ if (!klass->type_token) {
+ mono_loader_lock ();
klass->nested_classes_inited = TRUE;
+ mono_loader_unlock ();
+ return;
+ }
i = mono_metadata_nesting_typedef (klass->image, klass->type_token, 1);
classes = NULL;
MonoType *args [1];
/* generic IList, ICollection, IEnumerable */
- interface_count = mono_defaults.generic_ireadonlylist_class ? 2 : 1;
+ interface_count = 2;
interfaces = (MonoClass **)mono_image_alloc0 (klass->image, sizeof (MonoClass*) * interface_count);
args [0] = &klass->element_class->byval_arg;
interfaces [0] = mono_class_bind_generic_parameters (
mono_defaults.generic_ilist_class, 1, args, FALSE);
- if (interface_count > 1)
- interfaces [1] = mono_class_bind_generic_parameters (
+ interfaces [1] = mono_class_bind_generic_parameters (
mono_defaults.generic_ireadonlylist_class, 1, args, FALSE);
} else if (mono_class_is_ginst (klass)) {
MonoClass *gklass = mono_class_get_generic_class (klass)->container_class;
interfaces = NULL;
}
- mono_image_lock (klass->image);
-
+ mono_loader_lock ();
if (!klass->interfaces_inited) {
klass->interface_count = interface_count;
klass->interfaces = interfaces;
klass->interfaces_inited = TRUE;
}
-
- mono_image_unlock (klass->image);
+ mono_loader_unlock ();
}
static void
MonoClass *gtd = mono_class_is_ginst (klass) ? mono_class_get_generic_type_definition (klass) : NULL;
int field_idx = field - klass->fields;
-
if (gtd) {
MonoClassField *gfield = >d->fields [field_idx];
return mono_field_get_flags (gfield);
}
/* Declare all shared lazy type lookup functions */
-GENERATE_TRY_GET_CLASS_WITH_CACHE (safehandle, System.Runtime.InteropServices, SafeHandle)
+GENERATE_TRY_GET_CLASS_WITH_CACHE (safehandle, "System.Runtime.InteropServices", "SafeHandle")
+
+/**
+ * mono_method_get_base_method:
+ * @method: a method
+ * @definition: if true, get the definition
+ * @error: set on failure
+ *
+ * Given a virtual method associated with a subclass, return the corresponding
+ * method from an ancestor. If @definition is FALSE, returns the method in the
+ * superclass of the given method. If @definition is TRUE, return the method
+ * in the ancestor class where it was first declared. The type arguments will
+ * be inflated in the ancestor classes. If the method is not associated with a
+ * class, or isn't virtual, returns the method itself. On failure returns NULL
+ * and sets @error.
+ */
+MonoMethod*
+mono_method_get_base_method (MonoMethod *method, gboolean definition, MonoError *error)
+{
+ MonoClass *klass, *parent;
+ MonoGenericContext *generic_inst = NULL;
+ MonoMethod *result = NULL;
+ int slot;
+
+ if (method->klass == NULL)
+ return method;
+
+ if (!(method->flags & METHOD_ATTRIBUTE_VIRTUAL) ||
+ MONO_CLASS_IS_INTERFACE (method->klass) ||
+ method->flags & METHOD_ATTRIBUTE_NEW_SLOT)
+ return method;
+
+ slot = mono_method_get_vtable_slot (method);
+ if (slot == -1)
+ return method;
+
+ klass = method->klass;
+ if (mono_class_is_ginst (klass)) {
+ generic_inst = mono_class_get_context (klass);
+ klass = mono_class_get_generic_class (klass)->container_class;
+ }
+
+retry:
+ if (definition) {
+ /* At the end of the loop, klass points to the eldest class that has this virtual function slot. */
+ for (parent = klass->parent; parent != NULL; parent = parent->parent) {
+ /* on entry, klass is either a plain old non-generic class and generic_inst == NULL
+ or klass is the generic container class and generic_inst is the instantiation.
+
+ when we go to the parent, if the parent is an open constructed type, we need to
+ replace the type parameters by the definitions from the generic_inst, and then take it
+ apart again into the klass and the generic_inst.
+
+ For cases like this:
+ class C<T> : B<T, int> {
+ public override void Foo () { ... }
+ }
+ class B<U,V> : A<HashMap<U,V>> {
+ public override void Foo () { ... }
+ }
+ class A<X> {
+ public virtual void Foo () { ... }
+ }
+
+ if at each iteration the parent isn't open, we can skip inflating it. if at some
+ iteration the parent isn't generic (after possible inflation), we set generic_inst to
+ NULL;
+ */
+ MonoGenericContext *parent_inst = NULL;
+ if (mono_class_is_open_constructed_type (mono_class_get_type (parent))) {
+ parent = mono_class_inflate_generic_class_checked (parent, generic_inst, error);
+ return_val_if_nok (error, NULL);
+ }
+ if (mono_class_is_ginst (parent)) {
+ parent_inst = mono_class_get_context (parent);
+ parent = mono_class_get_generic_class (parent)->container_class;
+ }
+
+ mono_class_setup_vtable (parent);
+ if (parent->vtable_size <= slot)
+ break;
+ klass = parent;
+ generic_inst = parent_inst;
+ }
+ } else {
+ klass = klass->parent;
+ if (!klass)
+ return method;
+ if (mono_class_is_open_constructed_type (mono_class_get_type (klass))) {
+ klass = mono_class_inflate_generic_class_checked (klass, generic_inst, error);
+ return_val_if_nok (error, NULL);
+
+ generic_inst = NULL;
+ }
+ if (mono_class_is_ginst (klass)) {
+ generic_inst = mono_class_get_context (klass);
+ klass = mono_class_get_generic_class (klass)->container_class;
+ }
+
+ }
+
+ if (generic_inst) {
+ klass = mono_class_inflate_generic_class_checked (klass, generic_inst, error);
+ return_val_if_nok (error, NULL);
+ }
+
+ if (klass == method->klass)
+ return method;
+
+ /*This is possible if definition == FALSE.
+ * Do it here to be really sure we don't read invalid memory.
+ */
+ if (slot >= klass->vtable_size)
+ return method;
+
+ mono_class_setup_vtable (klass);
+
+ result = klass->vtable [slot];
+ if (result == NULL) {
+ /* It is an abstract method */
+ gboolean found = FALSE;
+ gpointer iter = NULL;
+ while ((result = mono_class_get_methods (klass, &iter))) {
+ if (result->slot == slot) {
+ found = TRUE;
+ break;
+ }
+ }
+ /* found might be FALSE if we looked in an abstract class
+ * that doesn't override an abstract method of its
+ * parent:
+ * abstract class Base {
+ * public abstract void Foo ();
+ * }
+ * abstract class Derived : Base { }
+ * class Child : Derived {
+ * public override void Foo () { }
+ * }
+ *
+ * if m was Child.Foo and we ask for the base method,
+ * then we get here with klass == Derived and found == FALSE
+ */
+ /* but it shouldn't be the case that if we're looking
+ * for the definition and didn't find a result; the
+ * loop above should've taken us as far as we could
+ * go! */
+ g_assert (!(definition && !found));
+ if (!found)
+ goto retry;
+ }
+
+ g_assert (result != NULL);
+ return result;
+}
#include "mono/metadata/threads-types.h"
#include "mono/metadata/string-icalls.h"
#include "mono/metadata/attrdefs.h"
-#include "mono/metadata/gc-internals.h"
#include "mono/utils/mono-counters.h"
#include "mono/utils/strenc.h"
#include "mono/utils/atomic.h"
#include "mono/utils/mono-error.h"
#include "mono/utils/mono-error-internals.h"
-#include "mono/io-layer/io-layer.h"
#include <string.h>
#include <errno.h>
+#include <mono/utils/w32api.h>
#if defined(HOST_WIN32)
#include <oleauto.h>
#define STDCALL
#endif
-GENERATE_GET_CLASS_WITH_CACHE (interop_proxy, Mono.Interop, ComInteropProxy)
-GENERATE_GET_CLASS_WITH_CACHE (idispatch, Mono.Interop, IDispatch)
-GENERATE_GET_CLASS_WITH_CACHE (iunknown, Mono.Interop, IUnknown)
+GENERATE_GET_CLASS_WITH_CACHE (interop_proxy, "Mono.Interop", "ComInteropProxy")
+GENERATE_GET_CLASS_WITH_CACHE (idispatch, "Mono.Interop", "IDispatch")
+GENERATE_GET_CLASS_WITH_CACHE (iunknown, "Mono.Interop", "IUnknown")
-GENERATE_GET_CLASS_WITH_CACHE (com_object, System, __ComObject)
-GENERATE_GET_CLASS_WITH_CACHE (variant, System, Variant)
+GENERATE_GET_CLASS_WITH_CACHE (com_object, "System", "__ComObject")
+GENERATE_GET_CLASS_WITH_CACHE (variant, "System", "Variant")
-static GENERATE_GET_CLASS_WITH_CACHE (interface_type_attribute, System.Runtime.InteropServices, InterfaceTypeAttribute)
-static GENERATE_GET_CLASS_WITH_CACHE (guid_attribute, System.Runtime.InteropServices, GuidAttribute)
+static GENERATE_GET_CLASS_WITH_CACHE (interface_type_attribute, "System.Runtime.InteropServices", "InterfaceTypeAttribute")
+static GENERATE_GET_CLASS_WITH_CACHE (guid_attribute, "System.Runtime.InteropServices", "GuidAttribute")
/* Upon creation of a CCW, only allocate a weak handle and set the
* reference count to 0. If the unmanaged client code decides to addref and
MonoBoolean
ves_icall_System_ConsoleDriver_Isatty (HANDLE handle)
{
- return (GetFileType (handle) == FILE_TYPE_CHAR);
+ return mono_w32file_get_type (handle) == FILE_TYPE_CHAR;
}
MonoBoolean
#include <mono/metadata/threadpool.h>
#include <mono/utils/mono-signal-handler.h>
#include <mono/utils/mono-proclib.h>
-#include <mono/io-layer/io-layer.h>
+#include <mono/utils/w32api.h>
/* On solaris, curses.h must come before both termios.h and term.h */
#ifdef HAVE_CURSES_H
#include <glib.h>
#include <string.h>
-#include <mono/io-layer/io-layer.h>
#include <mono/utils/mono-path.h>
+#include "utils/w32api.h"
#include "cil-coff.h"
#include "metadata-internals.h"
#include "image.h"
#ifdef HOST_WIN32
-#include <mono/io-layer/io-layer.h>
#include <mono/utils/mono-compiler.h>
+#include <mono/utils/w32api.h>
#include "image.h"
#define STATUS_SUCCESS 0x00000000L
static gboolean type_is_reference (MonoType *type);
-static GENERATE_GET_CLASS_WITH_CACHE (custom_attribute_typed_argument, System.Reflection, CustomAttributeTypedArgument);
-static GENERATE_GET_CLASS_WITH_CACHE (custom_attribute_named_argument, System.Reflection, CustomAttributeNamedArgument);
+static GENERATE_GET_CLASS_WITH_CACHE (custom_attribute_typed_argument, "System.Reflection", "CustomAttributeTypedArgument");
+static GENERATE_GET_CLASS_WITH_CACHE (custom_attribute_named_argument, "System.Reflection", "CustomAttributeNamedArgument");
/*
* LOCKING: Acquires the loader lock.
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/cil-coff.h>
+#include <mono/utils/bsearch.h>
#include "debug-mono-ppdb.h"
g_free (info);
}
+static MonoPPDBFile*
+create_ppdb_file (MonoImage *ppdb_image)
+{
+ MonoPPDBFile *ppdb;
+
+ ppdb = g_new0 (MonoPPDBFile, 1);
+ ppdb->image = ppdb_image;
+ ppdb->doc_hash = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) doc_free);
+ ppdb->method_hash = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) g_free);
+ return ppdb;
+}
+
MonoPPDBFile*
mono_ppdb_load_file (MonoImage *image, const guint8 *raw_contents, int size)
{
guint8 pe_guid [16];
gint32 pe_age;
gint32 pe_timestamp;
- MonoPPDBFile *ppdb;
+
+ if (image->tables [MONO_TABLE_DOCUMENT].rows) {
+ /* Embedded ppdb */
+ mono_image_addref (image);
+ return create_ppdb_file (image);
+ }
if (!get_pe_debug_guid (image, pe_guid, &pe_age, &pe_timestamp))
return NULL;
return NULL;
}
- ppdb = g_new0 (MonoPPDBFile, 1);
- ppdb->image = ppdb_image;
- ppdb->doc_hash = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) doc_free);
- ppdb->method_hash = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) g_free);
-
- return ppdb;
+ return create_ppdb_file (ppdb_image);
}
void
return res;
}
+
+/*
+* We use this to pass context information to the row locator
+*/
+typedef struct {
+ int idx; /* The index that we are trying to locate */
+ int col_idx; /* The index in the row where idx may be stored */
+ MonoTableInfo *t; /* pointer to the table */
+ guint32 result;
+} locator_t;
+
+static int
+table_locator (const void *a, const void *b)
+{
+ locator_t *loc = (locator_t *)a;
+ const char *bb = (const char *)b;
+ guint32 table_index = (bb - loc->t->base) / loc->t->row_size;
+ guint32 col;
+
+ col = mono_metadata_decode_row_col(loc->t, table_index, loc->col_idx);
+
+ if (loc->idx == col) {
+ loc->result = table_index;
+ return 0;
+ }
+ if (loc->idx < col)
+ return -1;
+ else
+ return 1;
+}
+
+static gboolean
+compare_guid (guint8* guid1, guint8* guid2) {
+ for (int i = 0; i < 16; i++) {
+ if (guid1 [i] != guid2 [i])
+ return FALSE;
+ }
+ return TRUE;
+}
+
+// for parent_type see HasCustomDebugInformation table at
+// https://github.com/dotnet/corefx/blob/master/src/System.Reflection.Metadata/specs/PortablePdb-Metadata.md
+static const char*
+lookup_custom_debug_information (MonoImage* image, guint32 token, uint8_t parent_type, guint8* guid)
+{
+ MonoTableInfo *tables = image->tables;
+ MonoTableInfo *table = &tables[MONO_TABLE_CUSTOMDEBUGINFORMATION];
+ locator_t loc;
+
+ if (!table->base)
+ return 0;
+
+ loc.idx = (mono_metadata_token_index (token) << 5) | parent_type;
+ loc.col_idx = MONO_CUSTOMDEBUGINFORMATION_PARENT;
+ loc.t = table;
+
+ if (!mono_binary_search (&loc, table->base, table->rows, table->row_size, table_locator))
+ return NULL;
+ // Great we found one of possibly many CustomDebugInformations of this entity they are distinguished by KIND guid
+ // First try on this index found by binary search...(it's most likeley to be only one and binary search found the one we want)
+ if (compare_guid (guid, (guint8*)mono_metadata_guid_heap (image, mono_metadata_decode_row_col (table, loc.result, MONO_CUSTOMDEBUGINFORMATION_KIND))))
+ return mono_metadata_blob_heap (image, mono_metadata_decode_row_col (table, loc.result, MONO_CUSTOMDEBUGINFORMATION_VALUE));
+
+ // Move forward from binary found index, until parent token differs
+ for (int i = loc.result + 1; i < table->rows; i++)
+ {
+ if (mono_metadata_decode_row_col (table, i, MONO_CUSTOMDEBUGINFORMATION_PARENT) != loc.idx)
+ break;
+ if (compare_guid (guid, (guint8*)mono_metadata_guid_heap (image, mono_metadata_decode_row_col (table, i, MONO_CUSTOMDEBUGINFORMATION_KIND))))
+ return mono_metadata_blob_heap (image, mono_metadata_decode_row_col (table, i, MONO_CUSTOMDEBUGINFORMATION_VALUE));
+ }
+
+ // Move backward from binary found index, until parent token differs
+ for (int i = loc.result - 1; i >= 0; i--) {
+ if (mono_metadata_decode_row_col (table, i, MONO_CUSTOMDEBUGINFORMATION_PARENT) != loc.idx)
+ break;
+ if (compare_guid (guid, (guint8*)mono_metadata_guid_heap (image, mono_metadata_decode_row_col (table, i, MONO_CUSTOMDEBUGINFORMATION_KIND))))
+ return mono_metadata_blob_heap (image, mono_metadata_decode_row_col (table, i, MONO_CUSTOMDEBUGINFORMATION_VALUE));
+ }
+ return NULL;
+}
+
+MonoDebugMethodAsyncInfo*
+mono_ppdb_lookup_method_async_debug_info (MonoDebugMethodInfo *minfo)
+{
+ MonoMethod *method = minfo->method;
+ MonoPPDBFile *ppdb = minfo->handle->ppdb;
+ MonoImage *image = ppdb->image;
+
+ // Guid is taken from Roslyn source code:
+ // https://github.com/dotnet/roslyn/blob/1ad4b58/src/Dependencies/CodeAnalysis.Metadata/PortableCustomDebugInfoKinds.cs#L9
+ guint8 async_method_stepping_information_guid [16] = { 0xC5, 0x2A, 0xFD, 0x54, 0x25, 0xE9, 0x1A, 0x40, 0x9C, 0x2A, 0xF9, 0x4F, 0x17, 0x10, 0x72, 0xF8 };
+ char const *blob = lookup_custom_debug_information (image, method->token, 0, async_method_stepping_information_guid);
+ if (!blob)
+ return NULL;
+ int blob_len = mono_metadata_decode_blob_size (blob, &blob);
+ MonoDebugMethodAsyncInfo* res = g_new0 (MonoDebugMethodAsyncInfo, 1);
+ char const *pointer = blob;
+
+ // Format of this blob is taken from Roslyn source code:
+ // https://github.com/dotnet/roslyn/blob/1ad4b58/src/Compilers/Core/Portable/PEWriter/MetadataWriter.PortablePdb.cs#L566
+
+ pointer += 4;//catch_handler_offset
+ while (pointer - blob < blob_len) {
+ res->num_awaits++;
+ pointer += 8;//yield_offsets+resume_offsets
+ mono_metadata_decode_value (pointer, &pointer);//move_next_method_token
+ }
+ g_assert(pointer - blob == blob_len); //Check that we used all blob data
+ pointer = blob; //reset pointer after we figured num_awaits
+
+ res->yield_offsets = g_new (uint32_t, res->num_awaits);
+ res->resume_offsets = g_new (uint32_t, res->num_awaits);
+ res->move_next_method_token = g_new (uint32_t, res->num_awaits);
+
+ res->catch_handler_offset = read32 (pointer); pointer += 4;
+ for (int i = 0; i < res->num_awaits; i++) {
+ res->yield_offsets [i] = read32 (pointer); pointer += 4;
+ res->resume_offsets [i] = read32 (pointer); pointer += 4;
+ res->move_next_method_token [i] = mono_metadata_decode_value (pointer, &pointer);
+ }
+ return res;
+}
MonoDebugLocalsInfo*
mono_ppdb_lookup_locals (MonoDebugMethodInfo *minfo);
+MonoDebugMethodAsyncInfo*
+mono_ppdb_lookup_method_async_debug_info (MonoDebugMethodInfo *minfo);
+
#endif
MonoDebugCodeBlock *code_blocks;
};
+/*
+* Information about method await yield and resume offsets retrieved from a symbol file.
+*/
+struct _MonoDebugMethodAsyncInfo {
+ uint32_t catch_handler_offset;
+ int num_awaits;
+ uint32_t *yield_offsets;
+ uint32_t *resume_offsets;
+ uint32_t *move_next_method_token;
+};
+
struct _MonoDebugLineNumberEntry {
uint32_t il_offset;
uint32_t native_offset;
#include <mono/metadata/assembly.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/metadata-internals.h>
-#include <mono/metadata/gc-internals.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/mono-debug-debugger.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/w32semaphore.h>
#include <mono/metadata/w32event.h>
#include <mono/metadata/w32process.h>
+#include <mono/metadata/w32file.h>
#include <metadata/threads.h>
#include <metadata/profiler-private.h>
#include <mono/metadata/coree.h>
-#include <mono/io-layer/io-layer.h>
//#define DEBUG_DOMAIN_UNLOAD 1
#ifndef HOST_WIN32
mono_w32handle_init ();
mono_w32handle_namespace_init ();
- wapi_init ();
#endif
mono_w32mutex_init ();
mono_w32semaphore_init ();
mono_w32event_init ();
mono_w32process_init ();
+ mono_w32file_init ();
#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters_init ();
mono_coop_mutex_destroy (&appdomains_mutex);
mono_w32process_cleanup ();
-
-#ifndef HOST_WIN32
- wapi_cleanup ();
-#endif
+ mono_w32file_cleanup ();
}
void
#include <mono/metadata/object.h>
#include <mono/metadata/metadata-internals.h>
+#include <mono/metadata/object-internals.h>
typedef struct {
guint32 import_lookup_table;
mono_dynamic_images_init (void);
void
-mono_dynamic_image_register_token (MonoDynamicImage *assembly, guint32 token, MonoObject *obj);
+mono_dynamic_image_register_token (MonoDynamicImage *assembly, guint32 token, MonoObjectHandle obj);
gboolean
mono_dynamic_image_is_valid_token (MonoDynamicImage *image, guint32 token);
mono_image_unlock ((MonoImage*)image);
}
+#ifndef DISABLE_REFLECTION_INIT
+/*
+ * mono_dynamic_image_register_token:
+ *
+ * Register the TOKEN->OBJ mapping in the mapping table in ASSEMBLY. This is required for
+ * the Module.ResolveXXXToken () methods to work.
+ */
void
-mono_dynamic_image_register_token (MonoDynamicImage *assembly, guint32 token, MonoObject *obj)
+mono_dynamic_image_register_token (MonoDynamicImage *assembly, guint32 token, MonoObjectHandle obj)
{
MONO_REQ_GC_UNSAFE_MODE;
dynamic_image_lock (assembly);
- mono_g_hash_table_insert (assembly->tokens, GUINT_TO_POINTER (token), obj);
+ mono_g_hash_table_insert (assembly->tokens, GUINT_TO_POINTER (token), MONO_HANDLE_RAW (obj));
dynamic_image_unlock (assembly);
}
+#else
+void
+mono_dynamic_image_register_token (MonoDynamicImage *assembly, guint32 token, MonoObjectHandle obj)
+{
+}
+#endif
static MonoObject*
lookup_dyn_token (MonoDynamicImage *assembly, guint32 token)
gpointer result = mono_reflection_resolve_object (image, obj, handle_class, context, error);
return result;
}
-
-/*
- * mono_image_register_token:
- *
- * Register the TOKEN->OBJ mapping in the mapping table in ASSEMBLY. This is required for
- * the Module.ResolveXXXToken () methods to work.
- */
-void
-mono_image_register_token (MonoDynamicImage *assembly, guint32 token, MonoObject *obj)
-{
- MonoObject *prev;
-
- dynamic_image_lock (assembly);
- prev = (MonoObject *)mono_g_hash_table_lookup (assembly->tokens, GUINT_TO_POINTER (token));
- if (prev) {
- /* There could be multiple MethodInfo objects with the same token */
- //g_assert (prev == obj);
- } else {
- mono_g_hash_table_insert (assembly->tokens, GUINT_TO_POINTER (token), obj);
- }
- dynamic_image_unlock (assembly);
-}
-
#else /* DISABLE_REFLECTION_EMIT */
-
gpointer
mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token, gboolean valid_token, MonoClass **handle_class, MonoGenericContext *context, MonoError *error)
{
mono_error_init (error);
return NULL;
}
-
-void
-mono_image_register_token (MonoDynamicImage *assembly, guint32 token, MonoObject *obj)
-{
-}
-
#endif /* DISABLE_REFLECTION_EMIT */
#ifndef DISABLE_REFLECTION_EMIT
#include <mono/metadata/environment.h>
#include <mono/metadata/exception.h>
#include <mono/utils/mono-compiler.h>
-#include <mono/io-layer/io-layer.h>
+#include <mono/utils/w32api.h>
extern MonoString* ves_icall_System_Environment_GetOSVersionString (void);
}
void
-mono_install_unhandled_exception_hook (MonoUnhandledExceptionFunc func, gpointer user_data)
+mono_install_unhandled_exception_hook (MonoUnhandledExceptionFunc func, void *user_data)
{
unhandled_exception_hook = func;
unhandled_exception_hook_data = user_data;
#ifndef _MONO_METADATA_EXCEPTION_H_
#define _MONO_METADATA_EXCEPTION_H_
-#include <glib.h>
#include <mono/metadata/object.h>
#include <mono/metadata/image.h>
* This hook isn't expected to return.
* If no hook has been installed, the runtime will print a message before aborting.
*/
-typedef void (*MonoUnhandledExceptionFunc) (MonoObject *exc, gpointer user_data);
-MONO_API void mono_install_unhandled_exception_hook (MonoUnhandledExceptionFunc func, gpointer user_data);
+typedef void (*MonoUnhandledExceptionFunc) (MonoObject *exc, void *user_data);
+MONO_API void mono_install_unhandled_exception_hook (MonoUnhandledExceptionFunc func, void *user_data);
void mono_invoke_unhandled_exception_hook (MonoObject *exc);
MONO_END_DECLS
+++ /dev/null
-/*
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-#ifndef __MONO_FILE_IO_INTERNALS_H__
-#define __MONO_FILE_IO_INTERNALS_H__
-
-#include <config.h>
-#include <glib.h>
-#include "mono/metadata/object.h"
-#include "mono/metadata/object-internals.h"
-
-gboolean
-mono_file_io_move_file (gunichar2 *path, gunichar2 *dest, gint32 *error);
-
-gboolean
-mono_file_io_copy_file (gunichar2 *path, gunichar2 *dest, gboolean overwrite, gint32 *error);
-
-gint64
-mono_file_io_get_file_size (HANDLE handle, gint32 *error);
-
-gboolean
-mono_file_io_lock_file (HANDLE handle, gint64 position, gint64 length, gint32 *error);
-
-gboolean
-mono_file_io_replace_file (gunichar2 *destinationFileName, gunichar2 *sourceFileName,
- gunichar2 *destinationBackupFileName, guint32 flags, gint32 *error);
-
-gboolean
-mono_file_io_unlock_file (HANDLE handle, gint64 position, gint64 length, gint32 *error);
-
-HANDLE
-mono_file_io_get_console_output (void);
-
-HANDLE
-mono_file_io_get_console_error (void);
-
-HANDLE
-mono_file_io_get_console_input (void);
-
-#endif /* __MONO_FILE_IO_INTERNALS_H__ */
+++ /dev/null
-/*
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-#ifndef _MONO_METADATA_FILEIO_WINDOWS_H_
-#define _MONO_METADATA_FILEIO_WINDOWS_H_
-
-#include <config.h>
-#include <glib.h>
-
-#ifdef HOST_WIN32
-#include "mono/metadata/file-io.h"
-#include "mono/metadata/file-io-internals.h"
-#endif /* HOST_WIN32 */
-#endif /* _MONO_METADATA_FILEIO_WINDOWS_H_ */
+++ /dev/null
-/*
- * file-io-windows-uwp.c: UWP file-io support for Mono.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-#include "mono/utils/mono-compiler.h"
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#include <windows.h>
-#include "mono/metadata/file-io-windows-internals.h"
-
-gboolean
-mono_file_io_move_file (gunichar2 *path, gunichar2 *dest, gint32 *error)
-{
- gboolean result = FALSE;
- MONO_ENTER_GC_SAFE;
-
- result = MoveFileEx (path, dest, MOVEFILE_COPY_ALLOWED);
- if (result == FALSE) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return result;
-}
-
-gboolean
-mono_file_io_replace_file (gunichar2 *destinationFileName, gunichar2 *sourceFileName,
- gunichar2 *destinationBackupFileName, guint32 flags, gint32 *error)
-{
- gboolean result = FALSE;
- MONO_ENTER_GC_SAFE;
-
- result = ReplaceFile (destinationFileName, sourceFileName, destinationBackupFileName, flags, NULL, NULL);
- if (result == FALSE) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return result;
-}
-
-gboolean
-mono_file_io_copy_file (gunichar2 *path, gunichar2 *dest, gboolean overwrite, gint32 *error)
-{
- gboolean result = FALSE;
- COPYFILE2_EXTENDED_PARAMETERS copy_param = {0};
-
- copy_param.dwSize = sizeof (COPYFILE2_EXTENDED_PARAMETERS);
- copy_param.dwCopyFlags = (!overwrite) ? COPY_FILE_FAIL_IF_EXISTS : 0;
-
- MONO_ENTER_GC_SAFE;
-
- result = SUCCEEDED (CopyFile2 (path, dest, ©_param));
- if (result == FALSE) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return result;
-}
-
-gint64
-mono_file_io_get_file_size (HANDLE handle, gint32 *error)
-{
- LARGE_INTEGER length;
-
- MONO_ENTER_GC_SAFE;
-
- if (!GetFileSizeEx (handle, &length)) {
- *error=GetLastError ();
- length.QuadPart = INVALID_FILE_SIZE;
- }
-
- MONO_EXIT_GC_SAFE;
- return length.QuadPart;
-}
-
-gboolean
-mono_file_io_lock_file (HANDLE handle, gint64 position, gint64 length, gint32 *error)
-{
- gboolean result = FALSE;
- MONO_ENTER_GC_SAFE;
-
- result = LockFile (handle, position & 0xFFFFFFFF, position >> 32,
- length & 0xFFFFFFFF, length >> 32);
-
- if (result == FALSE) {
- *error = GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return result;
-}
-
-gboolean
-mono_file_io_unlock_file (HANDLE handle, gint64 position, gint64 length, gint32 *error)
-{
- gboolean result = FALSE;
- MONO_ENTER_GC_SAFE;
-
- result = UnlockFile (handle, position & 0xFFFFFFFF, position >> 32,
- length & 0xFFFFFFFF, length >> 32);
-
- if (result == FALSE) {
- *error = GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return result;
-}
-
-HANDLE
-mono_file_io_get_console_output (void)
-{
- MonoError mono_error;
- mono_error_init (&mono_error);
-
- g_unsupported_api ("GetStdHandle (STD_OUTPUT_HANDLE)");
-
- mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetStdHandle (STD_OUTPUT_HANDLE)");
- mono_error_set_pending_exception (&mono_error);
-
- SetLastError (ERROR_NOT_SUPPORTED);
-
- return INVALID_HANDLE_VALUE;
-}
-
-HANDLE
-mono_file_io_get_console_input (void)
-{
- MonoError mono_error;
- mono_error_init (&mono_error);
-
- g_unsupported_api ("GetStdHandle (STD_INPUT_HANDLE)");
-
- mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetStdHandle (STD_INPUT_HANDLE)");
- mono_error_set_pending_exception (&mono_error);
-
- SetLastError (ERROR_NOT_SUPPORTED);
-
- return INVALID_HANDLE_VALUE;
-}
-
-HANDLE
-mono_file_io_get_console_error (void)
-{
- MonoError mono_error;
- mono_error_init (&mono_error);
-
- g_unsupported_api ("GetStdHandle (STD_ERROR_HANDLE)");
-
- mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetStdHandle (STD_ERROR_HANDLE)");
- mono_error_set_pending_exception (&mono_error);
-
- SetLastError (ERROR_NOT_SUPPORTED);
-
- return INVALID_HANDLE_VALUE;
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-MONO_EMPTY_SOURCE_FILE (file_io_windows_uwp);
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
+++ /dev/null
-/*
- * file-io-windows.c: Windows File IO internal calls.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-#include <config.h>
-#include <glib.h>
-
-#if defined(HOST_WIN32)
-#include <winsock2.h>
-#include <windows.h>
-#include "mono/metadata/file-io-windows-internals.h"
-
-gunichar2
-ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar ()
-{
- return (gunichar2) ':'; /* colon */
-}
-
-gunichar2
-ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar ()
-{
- return (gunichar2) '\\'; /* backslash */
-}
-
-gunichar2
-ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar ()
-{
- return (gunichar2) '/'; /* forward slash */
-}
-
-gunichar2
-ves_icall_System_IO_MonoIO_get_PathSeparator ()
-{
- return (gunichar2) ';'; /* semicolon */
-}
-
-void ves_icall_System_IO_MonoIO_DumpHandles (void)
-{
- return;
-}
-#endif /* HOST_WIN32 */
+++ /dev/null
-/*
- * file-io.c: File IO internal calls
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- * Gonzalo Paniagua Javier (gonzalo@ximian.com)
- *
- * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
- * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
- * Copyright 2012 Xamarin Inc (http://www.xamarin.com)
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-
-#include <config.h>
-
-#include <glib.h>
-#include <string.h>
-#include <errno.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#include <mono/metadata/object.h>
-#include <mono/io-layer/io-layer.h>
-#include <mono/metadata/file-io.h>
-#include <mono/metadata/file-io-internals.h>
-#include <mono/metadata/exception.h>
-#include <mono/metadata/appdomain.h>
-#include <mono/metadata/marshal.h>
-#include <mono/utils/strenc.h>
-#include <utils/mono-io-portability.h>
-#include <mono/metadata/w32handle.h>
-
-#undef DEBUG
-
-/* conversion functions */
-
-static guint32 convert_mode(MonoFileMode mono_mode)
-{
- guint32 mode;
-
- switch(mono_mode) {
- case FileMode_CreateNew:
- mode=CREATE_NEW;
- break;
- case FileMode_Create:
- mode=CREATE_ALWAYS;
- break;
- case FileMode_Open:
- mode=OPEN_EXISTING;
- break;
- case FileMode_OpenOrCreate:
- mode=OPEN_ALWAYS;
- break;
- case FileMode_Truncate:
- mode=TRUNCATE_EXISTING;
- break;
- case FileMode_Append:
- mode=OPEN_ALWAYS;
- break;
- default:
- g_warning("System.IO.FileMode has unknown value 0x%x",
- mono_mode);
- /* Safe fallback */
- mode=OPEN_EXISTING;
- }
-
- return(mode);
-}
-
-static guint32 convert_access(MonoFileAccess mono_access)
-{
- guint32 access;
-
- switch(mono_access) {
- case FileAccess_Read:
- access=GENERIC_READ;
- break;
- case FileAccess_Write:
- access=GENERIC_WRITE;
- break;
- case FileAccess_ReadWrite:
- access=GENERIC_READ|GENERIC_WRITE;
- break;
- default:
- g_warning("System.IO.FileAccess has unknown value 0x%x",
- mono_access);
- /* Safe fallback */
- access=GENERIC_READ;
- }
-
- return(access);
-}
-
-static guint32 convert_share(MonoFileShare mono_share)
-{
- guint32 share = 0;
-
- if (mono_share & FileShare_Read) {
- share |= FILE_SHARE_READ;
- }
- if (mono_share & FileShare_Write) {
- share |= FILE_SHARE_WRITE;
- }
- if (mono_share & FileShare_Delete) {
- share |= FILE_SHARE_DELETE;
- }
-
- if (mono_share & ~(FileShare_Read|FileShare_Write|FileShare_Delete)) {
- g_warning("System.IO.FileShare has unknown value 0x%x",
- mono_share);
- /* Safe fallback */
- share=0;
- }
-
- return(share);
-}
-
-#if 0
-static guint32 convert_stdhandle(guint32 fd)
-{
- guint32 stdhandle;
-
- switch(fd) {
- case 0:
- stdhandle=STD_INPUT_HANDLE;
- break;
- case 1:
- stdhandle=STD_OUTPUT_HANDLE;
- break;
- case 2:
- stdhandle=STD_ERROR_HANDLE;
- break;
- default:
- g_warning("unknown standard file descriptor %d", fd);
- stdhandle=STD_INPUT_HANDLE;
- }
-
- return(stdhandle);
-}
-#endif
-
-static guint32 convert_seekorigin(MonoSeekOrigin origin)
-{
- guint32 w32origin;
-
- switch(origin) {
- case SeekOrigin_Begin:
- w32origin=FILE_BEGIN;
- break;
- case SeekOrigin_Current:
- w32origin=FILE_CURRENT;
- break;
- case SeekOrigin_End:
- w32origin=FILE_END;
- break;
- default:
- g_warning("System.IO.SeekOrigin has unknown value 0x%x",
- origin);
- /* Safe fallback */
- w32origin=FILE_CURRENT;
- }
-
- return(w32origin);
-}
-
-static gint64 convert_filetime (const FILETIME *filetime)
-{
- guint64 ticks = filetime->dwHighDateTime;
- ticks <<= 32;
- ticks += filetime->dwLowDateTime;
- return (gint64)ticks;
-}
-
-static void convert_win32_file_attribute_data (const WIN32_FILE_ATTRIBUTE_DATA *data, MonoIOStat *stat)
-{
- stat->attributes = data->dwFileAttributes;
- stat->creation_time = convert_filetime (&data->ftCreationTime);
- stat->last_access_time = convert_filetime (&data->ftLastAccessTime);
- stat->last_write_time = convert_filetime (&data->ftLastWriteTime);
- stat->length = ((gint64)data->nFileSizeHigh << 32) | data->nFileSizeLow;
-}
-
-/* Managed file attributes have nearly but not quite the same values
- * as the w32 equivalents.
- */
-static guint32 convert_attrs(MonoFileAttributes attrs)
-{
- if(attrs & FileAttributes_Encrypted) {
- attrs = (MonoFileAttributes)(attrs | FILE_ATTRIBUTE_ENCRYPTED);
- }
-
- return(attrs);
-}
-
-/*
- * On Win32, GetFileAttributes|Ex () seems to try opening the file,
- * which might lead to sharing violation errors, whereas FindFirstFile
- * always succeeds. These 2 wrappers resort to FindFirstFile if
- * GetFileAttributes|Ex () has failed.
- */
-static guint32
-get_file_attributes (const gunichar2 *path)
-{
- guint32 res;
- WIN32_FIND_DATA find_data;
- HANDLE find_handle;
- gint32 error;
-
- res = GetFileAttributes (path);
- if (res != -1)
- return res;
-
- error = GetLastError ();
-
- if (error != ERROR_SHARING_VIOLATION)
- return res;
-
- find_handle = FindFirstFile (path, &find_data);
-
- if (find_handle == INVALID_HANDLE_VALUE)
- return res;
-
- FindClose (find_handle);
-
- return find_data.dwFileAttributes;
-}
-
-static gboolean
-get_file_attributes_ex (const gunichar2 *path, WIN32_FILE_ATTRIBUTE_DATA *data)
-{
- gboolean res;
- WIN32_FIND_DATA find_data;
- HANDLE find_handle;
- gint32 error;
-
- res = GetFileAttributesEx (path, GetFileExInfoStandard, data);
- if (res)
- return TRUE;
-
- error = GetLastError ();
-
- if (error != ERROR_SHARING_VIOLATION)
- return FALSE;
-
- find_handle = FindFirstFile (path, &find_data);
-
- if (find_handle == INVALID_HANDLE_VALUE)
- return FALSE;
-
- FindClose (find_handle);
-
- data->dwFileAttributes = find_data.dwFileAttributes;
- data->ftCreationTime = find_data.ftCreationTime;
- data->ftLastAccessTime = find_data.ftLastAccessTime;
- data->ftLastWriteTime = find_data.ftLastWriteTime;
- data->nFileSizeHigh = find_data.nFileSizeHigh;
- data->nFileSizeLow = find_data.nFileSizeLow;
-
- return TRUE;
-}
-
-/* System.IO.MonoIO internal calls */
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_CreateDirectory (MonoString *path, gint32 *error)
-{
- gboolean ret;
- MONO_ENTER_GC_SAFE;
-
- *error=ERROR_SUCCESS;
-
- ret=CreateDirectory (mono_string_chars (path), NULL);
- if(ret==FALSE) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return(ret);
-}
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_RemoveDirectory (MonoString *path, gint32 *error)
-{
- gboolean ret;
- MONO_ENTER_GC_SAFE;
-
- *error=ERROR_SUCCESS;
-
- ret=RemoveDirectory (mono_string_chars (path));
- if(ret==FALSE) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return(ret);
-}
-
-static gchar *
-get_search_dir (const gunichar2 *pattern)
-{
- gchar *p;
- gchar *result;
-
- p = g_utf16_to_utf8 (pattern, -1, NULL, NULL, NULL);
- result = g_path_get_dirname (p);
- g_free (p);
- return result;
-}
-
-static GPtrArray *
-get_filesystem_entries (const gunichar2 *path,
- const gunichar2 *path_with_pattern,
- gint attrs, gint mask,
- gint32 *error)
-{
- int i;
- WIN32_FIND_DATA data;
- HANDLE find_handle;
- GPtrArray *names = NULL;
- gchar *utf8_path = NULL, *utf8_result, *full_name;
- gint32 attributes;
-
- mask = convert_attrs ((MonoFileAttributes)mask);
- attributes = get_file_attributes (path);
- if (attributes != -1) {
- if ((attributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
- *error = ERROR_INVALID_NAME;
- goto fail;
- }
- } else {
- *error = GetLastError ();
- goto fail;
- }
-
- find_handle = FindFirstFile (path_with_pattern, &data);
- if (find_handle == INVALID_HANDLE_VALUE) {
- gint32 find_error = GetLastError ();
-
- if (find_error == ERROR_FILE_NOT_FOUND || find_error == ERROR_NO_MORE_FILES) {
- /* No files, so just return an empty array */
- goto fail;
- }
-
- *error = find_error;
- goto fail;
- }
-
- utf8_path = get_search_dir (path_with_pattern);
- names = g_ptr_array_new ();
-
- do {
- if ((data.cFileName[0] == '.' && data.cFileName[1] == 0) ||
- (data.cFileName[0] == '.' && data.cFileName[1] == '.' && data.cFileName[2] == 0)) {
- continue;
- }
-
- if ((data.dwFileAttributes & mask) == attrs) {
- utf8_result = g_utf16_to_utf8 (data.cFileName, -1, NULL, NULL, NULL);
- if (utf8_result == NULL) {
- continue;
- }
-
- full_name = g_build_filename (utf8_path, utf8_result, NULL);
- g_ptr_array_add (names, full_name);
-
- g_free (utf8_result);
- }
- } while(FindNextFile (find_handle, &data));
-
- if (FindClose (find_handle) == FALSE) {
- *error = GetLastError ();
- goto fail;
- }
-
- g_free (utf8_path);
- return names;
-fail:
- if (names) {
- for (i = 0; i < names->len; i++)
- g_free (g_ptr_array_index (names, i));
- g_ptr_array_free (names, TRUE);
- }
- g_free (utf8_path);
- return FALSE;
-}
-
-
-MonoArray *
-ves_icall_System_IO_MonoIO_GetFileSystemEntries (MonoString *path,
- MonoString *path_with_pattern,
- gint attrs, gint mask,
- gint32 *ioerror)
-{
- MonoError error;
- MonoDomain *domain = mono_domain_get ();
- MonoArray *result;
- int i;
- GPtrArray *names;
-
- *ioerror = ERROR_SUCCESS;
-
- MONO_ENTER_GC_SAFE;
- names = get_filesystem_entries (mono_string_chars (path), mono_string_chars (path_with_pattern), attrs, mask, ioerror);
- MONO_EXIT_GC_SAFE;
-
- if (!names) {
- // If there's no array and no error, then return an empty array.
- if (*ioerror == ERROR_SUCCESS) {
- MonoArray *arr = mono_array_new_checked (domain, mono_defaults.string_class, 0, &error);
- mono_error_set_pending_exception (&error);
- return arr;
- }
- return NULL;
- }
-
- result = mono_array_new_checked (domain, mono_defaults.string_class, names->len, &error);
- if (mono_error_set_pending_exception (&error))
- goto leave;
- for (i = 0; i < names->len; i++) {
- mono_array_setref (result, i, mono_string_new (domain, (const char *)g_ptr_array_index (names, i)));
- g_free (g_ptr_array_index (names, i));
- }
-leave:
- g_ptr_array_free (names, TRUE);
- return result;
-}
-
-typedef struct {
- MonoDomain *domain;
- gchar *utf8_path;
- HANDLE find_handle;
-} IncrementalFind;
-
-static gboolean
-incremental_find_check_match (IncrementalFind *handle, WIN32_FIND_DATA *data, MonoString **result)
-{
- gchar *utf8_result;
- gchar *full_name;
-
- if ((data->cFileName[0] == '.' && data->cFileName[1] == 0) || (data->cFileName[0] == '.' && data->cFileName[1] == '.' && data->cFileName[2] == 0))
- return FALSE;
-
- utf8_result = g_utf16_to_utf8 (data->cFileName, -1, NULL, NULL, NULL);
- if (utf8_result == NULL)
- return FALSE;
-
- full_name = g_build_filename (handle->utf8_path, utf8_result, NULL);
- g_free (utf8_result);
- *result = mono_string_new (mono_domain_get (), full_name);
- g_free (full_name);
-
- return TRUE;
-}
-
-HANDLE
-ves_icall_System_IO_MonoIO_FindFirstFile (MonoString *path_with_pattern, MonoString **file_name, gint32 *file_attr, gint32 *ioerror)
-{
- HANDLE hnd;
- WIN32_FIND_DATA data;
- MonoError error;
-
- hnd = FindFirstFile (mono_string_chars (path_with_pattern), &data);
-
- if (hnd == INVALID_HANDLE_VALUE) {
- *file_name = NULL;
- *file_attr = 0;
- *ioerror = GetLastError ();
- return hnd;
- }
-
- mono_gc_wbarrier_generic_store (file_name, (MonoObject*) mono_string_from_utf16_checked (data.cFileName, &error));
- mono_error_set_pending_exception (&error);
-
- *file_attr = data.dwFileAttributes;
- *ioerror = ERROR_SUCCESS;
-
- return hnd;
-}
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_FindNextFile (HANDLE hnd, MonoString **file_name, gint32 *file_attr, gint32 *ioerror)
-{
- MonoBoolean res;
- WIN32_FIND_DATA data;
- MonoError error;
-
- res = FindNextFile (hnd, &data);
-
- if (res == FALSE) {
- *file_name = NULL;
- *file_attr = 0;
- *ioerror = GetLastError ();
- return res;
- }
-
- mono_gc_wbarrier_generic_store (file_name, (MonoObject*) mono_string_from_utf16_checked (data.cFileName, &error));
- mono_error_set_pending_exception (&error);
-
- *file_attr = data.dwFileAttributes;
- *ioerror = ERROR_SUCCESS;
-
- return res;
-}
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_FindCloseFile (HANDLE hnd)
-{
- return FindClose (hnd);
-}
-
-/* FIXME make gc suspendable */
-MonoString *
-ves_icall_System_IO_MonoIO_FindFirst (MonoString *path,
- MonoString *path_with_pattern,
- gint32 *result_attr, gint32 *ioerror,
- gpointer *handle)
-{
- MonoError error;
- WIN32_FIND_DATA data;
- HANDLE find_handle;
- IncrementalFind *ifh;
- MonoString *result;
-
- *ioerror = ERROR_SUCCESS;
-
- find_handle = FindFirstFile (mono_string_chars (path_with_pattern), &data);
-
- if (find_handle == INVALID_HANDLE_VALUE) {
- gint32 find_error = GetLastError ();
- *handle = NULL;
-
- if (find_error == ERROR_FILE_NOT_FOUND)
- return NULL;
-
- *ioerror = find_error;
- return NULL;
- }
-
- ifh = g_new (IncrementalFind, 1);
- ifh->find_handle = find_handle;
- ifh->utf8_path = mono_string_to_utf8_checked (path, &error);
- if (mono_error_set_pending_exception (&error)) {
- MONO_ENTER_GC_SAFE;
- FindClose (find_handle);
- MONO_EXIT_GC_SAFE;
- g_free (ifh);
- return NULL;
- }
- ifh->domain = mono_domain_get ();
- *handle = ifh;
-
- while (incremental_find_check_match (ifh, &data, &result) == 0){
- if (FindNextFile (find_handle, &data) == FALSE){
- int e = GetLastError ();
- if (e != ERROR_NO_MORE_FILES)
- *ioerror = e;
- return NULL;
- }
- }
- *result_attr = data.dwFileAttributes;
-
- return result;
-}
-
-/* FIXME make gc suspendable */
-MonoString *
-ves_icall_System_IO_MonoIO_FindNext (gpointer handle, gint32 *result_attr, gint32 *error)
-{
- IncrementalFind *ifh = (IncrementalFind *)handle;
- WIN32_FIND_DATA data;
- MonoString *result;
-
- *error = ERROR_SUCCESS;
- do {
- if (FindNextFile (ifh->find_handle, &data) == FALSE){
- int e = GetLastError ();
- if (e != ERROR_NO_MORE_FILES)
- *error = e;
- return NULL;
- }
- } while (incremental_find_check_match (ifh, &data, &result) == 0);
-
- *result_attr = data.dwFileAttributes;
- return result;
-}
-
-int
-ves_icall_System_IO_MonoIO_FindClose (gpointer handle)
-{
- IncrementalFind *ifh = (IncrementalFind *)handle;
- gint32 error;
-
- MONO_ENTER_GC_SAFE;
- if (FindClose (ifh->find_handle) == FALSE){
- error = GetLastError ();
- } else
- error = ERROR_SUCCESS;
- g_free (ifh->utf8_path);
- g_free (ifh);
- MONO_EXIT_GC_SAFE;
-
- return error;
-}
-
-MonoString *
-ves_icall_System_IO_MonoIO_GetCurrentDirectory (gint32 *io_error)
-{
- MonoError error;
- MonoString *result;
- gunichar2 *buf;
- int len, res_len;
-
- len = MAX_PATH + 1; /*FIXME this is too smal under most unix systems.*/
- buf = g_new (gunichar2, len);
-
- mono_error_init (&error);
- *io_error=ERROR_SUCCESS;
- result = NULL;
-
- res_len = GetCurrentDirectory (len, buf);
- if (res_len > len) { /*buf is too small.*/
- int old_res_len = res_len;
- g_free (buf);
- buf = g_new (gunichar2, res_len);
- res_len = GetCurrentDirectory (res_len, buf) == old_res_len;
- }
-
- if (res_len) {
- len = 0;
- while (buf [len])
- ++ len;
-
- result = mono_string_new_utf16_checked (mono_domain_get (), buf, len, &error);
- } else {
- *io_error=GetLastError ();
- }
-
- g_free (buf);
- mono_error_set_pending_exception (&error);
- return result;
-}
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_SetCurrentDirectory (MonoString *path,
- gint32 *error)
-{
- gboolean ret;
-
- *error=ERROR_SUCCESS;
-
- ret=SetCurrentDirectory (mono_string_chars (path));
- if(ret==FALSE) {
- *error=GetLastError ();
- }
-
- return(ret);
-}
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-gboolean
-mono_file_io_move_file (gunichar2 *path, gunichar2 *dest, gint32 *error)
-{
- gboolean result = FALSE;
- MONO_ENTER_GC_SAFE;
-
- result = MoveFile (path, dest);
- if (result == FALSE) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return result;
-}
-#endif /* HAVE_CLASSIC_WINAPI_SUPPORT */
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_MoveFile (MonoString *path, MonoString *dest, gint32 *error)
-{
- *error=ERROR_SUCCESS;
- return mono_file_io_move_file (mono_string_chars (path), mono_string_chars (dest), error);
-}
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-gboolean
-mono_file_io_replace_file (gunichar2 *destinationFileName, gunichar2 *sourceFileName,
- gunichar2 *destinationBackupFileName, guint32 flags, gint32 *error)
-{
- gboolean result = FALSE;
- MONO_ENTER_GC_SAFE;
-
- result = ReplaceFile (destinationFileName, sourceFileName, destinationBackupFileName, flags, NULL, NULL);
- if (result == FALSE) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return result;
-}
-#endif /* HAVE_CLASSIC_WINAPI_SUPPORT */
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_ReplaceFile (MonoString *sourceFileName, MonoString *destinationFileName,
- MonoString *destinationBackupFileName, MonoBoolean ignoreMetadataErrors,
- gint32 *error)
-{
- gunichar2 *utf16_sourceFileName = NULL, *utf16_destinationFileName = NULL, *utf16_destinationBackupFileName = NULL;
- guint32 replaceFlags = REPLACEFILE_WRITE_THROUGH;
-
- if (sourceFileName)
- utf16_sourceFileName = mono_string_chars (sourceFileName);
- if (destinationFileName)
- utf16_destinationFileName = mono_string_chars (destinationFileName);
- if (destinationBackupFileName)
- utf16_destinationBackupFileName = mono_string_chars (destinationBackupFileName);
-
- *error = ERROR_SUCCESS;
- if (ignoreMetadataErrors)
- replaceFlags |= REPLACEFILE_IGNORE_MERGE_ERRORS;
-
- /* FIXME: source and destination file names must not be NULL, but apparently they might be! */
- return mono_file_io_replace_file (utf16_destinationFileName, utf16_sourceFileName,
- utf16_destinationBackupFileName, replaceFlags, error);
-}
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-gboolean
-mono_file_io_copy_file (gunichar2 *path, gunichar2 *dest, gboolean overwrite, gint32 *error)
-{
- gboolean result = FALSE;
- MONO_ENTER_GC_SAFE;
-
- result = CopyFile (path, dest, !overwrite);
- if (result == FALSE) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return result;
-}
-#endif /* HAVE_CLASSIC_WINAPI_SUPPORT */
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_CopyFile (MonoString *path, MonoString *dest,
- MonoBoolean overwrite, gint32 *error)
-{
- *error=ERROR_SUCCESS;
- return mono_file_io_copy_file (mono_string_chars (path), mono_string_chars (dest), overwrite, error);
-}
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_DeleteFile (MonoString *path, gint32 *error)
-{
- gboolean ret;
- MONO_ENTER_GC_SAFE;
-
- *error=ERROR_SUCCESS;
-
- ret=DeleteFile (mono_string_chars (path));
- if(ret==FALSE) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return(ret);
-}
-
-gint32
-ves_icall_System_IO_MonoIO_GetFileAttributes (MonoString *path, gint32 *error)
-{
- gint32 ret;
- MONO_ENTER_GC_SAFE;
-
- *error=ERROR_SUCCESS;
-
- ret=get_file_attributes (mono_string_chars (path));
-
- /*
- * The definition of INVALID_FILE_ATTRIBUTES in the cygwin win32
- * headers is wrong, hence this temporary workaround.
- * See
- * http://cygwin.com/ml/cygwin/2003-09/msg01771.html
- */
- if (ret==-1) {
- /* if(ret==INVALID_FILE_ATTRIBUTES) { */
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return(ret);
-}
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_SetFileAttributes (MonoString *path, gint32 attrs,
- gint32 *error)
-{
- gboolean ret;
- MONO_ENTER_GC_SAFE;
-
- *error=ERROR_SUCCESS;
-
- ret=SetFileAttributes (mono_string_chars (path),
- convert_attrs ((MonoFileAttributes)attrs));
- if(ret==FALSE) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return(ret);
-}
-
-gint32
-ves_icall_System_IO_MonoIO_GetFileType (HANDLE handle, gint32 *error)
-{
- gboolean ret;
- MONO_ENTER_GC_SAFE;
-
- *error=ERROR_SUCCESS;
-
- ret=GetFileType (handle);
- if(ret==FILE_TYPE_UNKNOWN) {
- /* Not necessarily an error, but the caller will have
- * to decide based on the error value.
- */
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return(ret);
-}
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_GetFileStat (MonoString *path, MonoIOStat *stat,
- gint32 *error)
-{
- gboolean result;
- WIN32_FILE_ATTRIBUTE_DATA data;
- MONO_ENTER_GC_SAFE;
-
- *error=ERROR_SUCCESS;
-
- result = get_file_attributes_ex (mono_string_chars (path), &data);
-
- if (result) {
- convert_win32_file_attribute_data (&data, stat);
- } else {
- *error=GetLastError ();
- memset (stat, 0, sizeof (MonoIOStat));
- }
-
- MONO_EXIT_GC_SAFE;
- return result;
-}
-
-HANDLE
-ves_icall_System_IO_MonoIO_Open (MonoString *filename, gint32 mode,
- gint32 access_mode, gint32 share, gint32 options,
- gint32 *error)
-{
- HANDLE ret;
- int attributes, attrs;
- gunichar2 *chars;
- MONO_ENTER_GC_SAFE;
-
- chars = mono_string_chars (filename);
- *error=ERROR_SUCCESS;
-
- if (options != 0){
- if (options & FileOptions_Encrypted)
- attributes = FILE_ATTRIBUTE_ENCRYPTED;
- else
- attributes = FILE_ATTRIBUTE_NORMAL;
- if (options & FileOptions_DeleteOnClose)
- attributes |= FILE_FLAG_DELETE_ON_CLOSE;
- if (options & FileOptions_SequentialScan)
- attributes |= FILE_FLAG_SEQUENTIAL_SCAN;
- if (options & FileOptions_RandomAccess)
- attributes |= FILE_FLAG_RANDOM_ACCESS;
-
- if (options & FileOptions_Temporary)
- attributes |= FILE_ATTRIBUTE_TEMPORARY;
-
- if (options & FileOptions_WriteThrough)
- attributes |= FILE_FLAG_WRITE_THROUGH;
- } else
- attributes = FILE_ATTRIBUTE_NORMAL;
-
- /* If we're opening a directory we need to set the extra flag
- */
- attrs = get_file_attributes (chars);
- if (attrs != INVALID_FILE_ATTRIBUTES) {
- if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
- attributes |= FILE_FLAG_BACKUP_SEMANTICS;
- }
- }
-
- ret=CreateFile (chars, convert_access ((MonoFileAccess)access_mode),
- convert_share ((MonoFileShare)share), NULL, convert_mode ((MonoFileMode)mode),
- attributes, NULL);
- if(ret==INVALID_HANDLE_VALUE) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return(ret);
-}
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_Close (HANDLE handle, gint32 *error)
-{
- gboolean ret;
- MONO_ENTER_GC_SAFE;
-
- *error=ERROR_SUCCESS;
-
- ret=CloseHandle (handle);
- if(ret==FALSE) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return(ret);
-}
-
-gint32
-ves_icall_System_IO_MonoIO_Read (HANDLE handle, MonoArray *dest,
- gint32 dest_offset, gint32 count,
- gint32 *error)
-{
- guchar *buffer;
- gboolean result;
- guint32 n;
-
- *error=ERROR_SUCCESS;
-
- MONO_CHECK_ARG_NULL (dest, 0);
-
- if (dest_offset > mono_array_length (dest) - count) {
- mono_set_pending_exception (mono_get_exception_argument ("array", "array too small. numBytes/offset wrong."));
- return 0;
- }
-
- buffer = mono_array_addr (dest, guchar, dest_offset);
-
- MONO_ENTER_GC_SAFE;
- result = ReadFile (handle, buffer, count, &n, NULL);
- MONO_EXIT_GC_SAFE;
-
- if (!result) {
- *error=GetLastError ();
- return -1;
- }
-
- return (gint32)n;
-}
-
-gint32
-ves_icall_System_IO_MonoIO_Write (HANDLE handle, MonoArray *src,
- gint32 src_offset, gint32 count,
- gint32 *error)
-{
- guchar *buffer;
- gboolean result;
- guint32 n;
-
- *error=ERROR_SUCCESS;
-
- MONO_CHECK_ARG_NULL (src, 0);
-
- if (src_offset > mono_array_length (src) - count) {
- mono_set_pending_exception (mono_get_exception_argument ("array", "array too small. numBytes/offset wrong."));
- return 0;
- }
-
- buffer = mono_array_addr (src, guchar, src_offset);
- MONO_ENTER_GC_SAFE;
- result = WriteFile (handle, buffer, count, &n, NULL);
- MONO_EXIT_GC_SAFE;
-
- if (!result) {
- *error=GetLastError ();
- return -1;
- }
-
- return (gint32)n;
-}
-
-gint64
-ves_icall_System_IO_MonoIO_Seek (HANDLE handle, gint64 offset, gint32 origin,
- gint32 *error)
-{
- gint32 offset_hi;
- MONO_ENTER_GC_SAFE;
-
- *error=ERROR_SUCCESS;
-
- offset_hi = offset >> 32;
- offset = SetFilePointer (handle, (gint32) (offset & 0xFFFFFFFF), &offset_hi,
- convert_seekorigin ((MonoSeekOrigin)origin));
-
- if(offset==INVALID_SET_FILE_POINTER) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return offset | ((gint64)offset_hi << 32);
-}
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_Flush (HANDLE handle, gint32 *error)
-{
- gboolean ret;
- MONO_ENTER_GC_SAFE;
-
- *error=ERROR_SUCCESS;
-
- ret=FlushFileBuffers (handle);
- if(ret==FALSE) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return(ret);
-}
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-gint64
-mono_file_io_get_file_size (HANDLE handle, gint32 *error)
-{
- gint64 length;
- guint32 length_hi;
-
- MONO_ENTER_GC_SAFE;
-
- length = GetFileSize (handle, &length_hi);
- if(length==INVALID_FILE_SIZE) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return length | ((gint64)length_hi << 32);
-}
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
-
-gint64
-ves_icall_System_IO_MonoIO_GetLength (HANDLE handle, gint32 *error)
-{
- *error=ERROR_SUCCESS;
- return mono_file_io_get_file_size (handle, error);
-}
-
-/* FIXME make gc suspendable */
-MonoBoolean
-ves_icall_System_IO_MonoIO_SetLength (HANDLE handle, gint64 length,
- gint32 *error)
-{
- gint64 offset, offset_set;
- gint32 offset_hi;
- gint32 length_hi;
- gboolean result;
-
- *error=ERROR_SUCCESS;
-
- /* save file pointer */
-
- offset_hi = 0;
- offset = SetFilePointer (handle, 0, &offset_hi, FILE_CURRENT);
- if(offset==INVALID_SET_FILE_POINTER) {
- *error=GetLastError ();
- return(FALSE);
- }
-
- /* extend or truncate */
-
- length_hi = length >> 32;
- offset_set=SetFilePointer (handle, length & 0xFFFFFFFF, &length_hi,
- FILE_BEGIN);
- if(offset_set==INVALID_SET_FILE_POINTER) {
- *error=GetLastError ();
- return(FALSE);
- }
-
- result = SetEndOfFile (handle);
- if(result==FALSE) {
- *error=GetLastError ();
- return(FALSE);
- }
-
- /* restore file pointer */
-
- offset_set=SetFilePointer (handle, offset & 0xFFFFFFFF, &offset_hi,
- FILE_BEGIN);
- if(offset_set==INVALID_SET_FILE_POINTER) {
- *error=GetLastError ();
- return(FALSE);
- }
-
- return result;
-}
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_SetFileTime (HANDLE handle, gint64 creation_time,
- gint64 last_access_time,
- gint64 last_write_time, gint32 *error)
-{
- gboolean ret;
- const FILETIME *creation_filetime;
- const FILETIME *last_access_filetime;
- const FILETIME *last_write_filetime;
- MONO_ENTER_GC_SAFE;
-
- *error=ERROR_SUCCESS;
-
- if (creation_time < 0)
- creation_filetime = NULL;
- else
- creation_filetime = (FILETIME *)&creation_time;
-
- if (last_access_time < 0)
- last_access_filetime = NULL;
- else
- last_access_filetime = (FILETIME *)&last_access_time;
-
- if (last_write_time < 0)
- last_write_filetime = NULL;
- else
- last_write_filetime = (FILETIME *)&last_write_time;
-
- ret=SetFileTime (handle, creation_filetime, last_access_filetime, last_write_filetime);
- if(ret==FALSE) {
- *error=GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return(ret);
-}
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-HANDLE
-mono_file_io_get_console_output (void)
-{
- return GetStdHandle (STD_OUTPUT_HANDLE);
-}
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
-
-HANDLE
-ves_icall_System_IO_MonoIO_get_ConsoleOutput ()
-{
- return mono_file_io_get_console_output ();
-}
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-HANDLE
-mono_file_io_get_console_input (void)
-{
- return GetStdHandle (STD_INPUT_HANDLE);
-}
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
-
-HANDLE
-ves_icall_System_IO_MonoIO_get_ConsoleInput ()
-{
- return mono_file_io_get_console_input ();
-}
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-HANDLE
-mono_file_io_get_console_error (void)
-{
- return GetStdHandle (STD_ERROR_HANDLE);
-}
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
-
-HANDLE
-ves_icall_System_IO_MonoIO_get_ConsoleError ()
-{
- return mono_file_io_get_console_error ();
-}
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_CreatePipe (HANDLE *read_handle, HANDLE *write_handle, gint32 *error)
-{
- SECURITY_ATTRIBUTES attr;
- gboolean ret;
-
- attr.nLength=sizeof(SECURITY_ATTRIBUTES);
- attr.bInheritHandle=TRUE;
- attr.lpSecurityDescriptor=NULL;
-
- MONO_ENTER_GC_SAFE;
- ret=CreatePipe (read_handle, write_handle, &attr, 0);
- MONO_EXIT_GC_SAFE;
-
- if(ret==FALSE) {
- *error = GetLastError ();
- /* FIXME: throw an exception? */
- return(FALSE);
- }
-
- return(TRUE);
-}
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_DuplicateHandle (HANDLE source_process_handle, HANDLE source_handle,
- HANDLE target_process_handle, HANDLE *target_handle, gint32 access, gint32 inherit, gint32 options, gint32 *error)
-{
- /* This is only used on Windows */
- gboolean ret;
-
- MONO_ENTER_GC_SAFE;
-#ifdef HOST_WIN32
- ret=DuplicateHandle (source_process_handle, source_handle, target_process_handle, target_handle, access, inherit, options);
-#else
- mono_w32handle_ref (source_handle);
- *target_handle = source_handle;
- ret = TRUE;
-#endif
- MONO_EXIT_GC_SAFE;
-
- if(ret==FALSE) {
- *error = GetLastError ();
- /* FIXME: throw an exception? */
- return(FALSE);
- }
-
- return(TRUE);
-}
-
-#ifndef HOST_WIN32
-gunichar2
-ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar ()
-{
- return (gunichar2) '/'; /* forward slash */
-}
-
-gunichar2
-ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar ()
-{
- return (gunichar2) '/'; /* forward slash */
-}
-
-gunichar2
-ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar ()
-{
- if (IS_PORTABILITY_SET)
- return (gunichar2) '\\'; /* backslash */
- else
- return (gunichar2) '/'; /* forward slash */
-}
-
-gunichar2
-ves_icall_System_IO_MonoIO_get_PathSeparator ()
-{
- return (gunichar2) ':'; /* colon */
-}
-#endif /* !HOST_WIN32 */
-
-static const gunichar2
-invalid_path_chars [] = {
-#if defined (TARGET_WIN32)
- 0x0022, /* double quote, which seems allowed in MS.NET but should be rejected */
- 0x003c, /* less than */
- 0x003e, /* greater than */
- 0x007c, /* pipe */
- 0x0008,
- 0x0010,
- 0x0011,
- 0x0012,
- 0x0014,
- 0x0015,
- 0x0016,
- 0x0017,
- 0x0018,
- 0x0019,
-#endif
- 0x0000 /* null */
-};
-
-MonoArray *
-ves_icall_System_IO_MonoIO_get_InvalidPathChars ()
-{
- MonoError error;
- MonoArray *chars;
- MonoDomain *domain;
- int i, n;
-
- domain = mono_domain_get ();
- n = sizeof (invalid_path_chars) / sizeof (gunichar2);
- chars = mono_array_new_checked (domain, mono_defaults.char_class, n, &error);
- if (mono_error_set_pending_exception (&error))
- return NULL;
-
- for (i = 0; i < n; ++ i)
- mono_array_set (chars, gunichar2, i, invalid_path_chars [i]);
-
- return chars;
-}
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-gboolean
-mono_file_io_lock_file (HANDLE handle, gint64 position, gint64 length, gint32 *error)
-{
- gboolean result = FALSE;
- MONO_ENTER_GC_SAFE;
-
- result = LockFile (handle, position & 0xFFFFFFFF, position >> 32,
- length & 0xFFFFFFFF, length >> 32);
-
- if (result == FALSE) {
- *error = GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return result;
-}
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
-
-void ves_icall_System_IO_MonoIO_Lock (HANDLE handle, gint64 position,
- gint64 length, gint32 *error)
-{
- *error=ERROR_SUCCESS;
- mono_file_io_lock_file (handle, position, length, error);
-}
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-gboolean
-mono_file_io_unlock_file (HANDLE handle, gint64 position, gint64 length, gint32 *error)
-{
- gboolean result = FALSE;
- MONO_ENTER_GC_SAFE;
-
- result = UnlockFile (handle, position & 0xFFFFFFFF, position >> 32,
- length & 0xFFFFFFFF, length >> 32);
-
- if (result == FALSE) {
- *error = GetLastError ();
- }
-
- MONO_EXIT_GC_SAFE;
- return result;
-}
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
-
-void ves_icall_System_IO_MonoIO_Unlock (HANDLE handle, gint64 position,
- gint64 length, gint32 *error)
-{
- *error=ERROR_SUCCESS;
- mono_file_io_unlock_file (handle, position, length, error);
-}
-
-//Support for io-layer free mmap'd files.
-
-#if defined (TARGET_IOS) || defined (TARGET_ANDROID)
-
-gint64
-mono_filesize_from_path (MonoString *string)
-{
- MonoError error;
- struct stat buf;
- gint64 res;
- char *path = mono_string_to_utf8_checked (string, &error);
- mono_error_raise_exception (&error); /* OK to throw, external only without a good alternative */
-
- MONO_ENTER_GC_SAFE;
- if (stat (path, &buf) == -1)
- res = -1;
- else
- res = (gint64)buf.st_size;
-
- g_free (path);
-
- MONO_EXIT_GC_SAFE;
- return res;
-}
-
-gint64
-mono_filesize_from_fd (int fd)
-{
- struct stat buf;
- int res;
-
- MONO_ENTER_GC_SAFE;
- res = fstat (fd, &buf);
- MONO_EXIT_GC_SAFE;
-
- if (res == -1)
- return (gint64)-1;
-
- return (gint64)buf.st_size;
-}
-
-#endif
-
-#ifndef HOST_WIN32
-void mono_w32handle_dump (void);
-
-void ves_icall_System_IO_MonoIO_DumpHandles (void)
-{
-
- mono_w32handle_dump ();
-}
-#endif /* !HOST_WIN32 */
+++ /dev/null
-/*
- * file-io.h: File IO internal calls
- *
- * Authors:
- * Dick Porter (dick@ximian.com)
- * Dan Lewis (dihlewis@yahoo.co.uk)
- *
- * (C) 2001 Ximian, Inc.
- * Copyright 2012 Xamarin Inc (http://www.xamarin.com)
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-
-#ifndef _MONO_METADATA_FILEIO_H_
-#define _MONO_METADATA_FILEIO_H_
-
-#include <config.h>
-#include <glib.h>
-
-#include <mono/metadata/object-internals.h>
-#include <mono/utils/mono-compiler.h>
-
-G_BEGIN_DECLS
-
-/* This is a copy of System.IO.FileAccess */
-typedef enum {
- FileAccess_Read=0x01,
- FileAccess_Write=0x02,
- FileAccess_ReadWrite=FileAccess_Read|FileAccess_Write
-} MonoFileAccess;
-
-/* This is a copy of System.IO.FileMode */
-typedef enum {
- FileMode_CreateNew=1,
- FileMode_Create=2,
- FileMode_Open=3,
- FileMode_OpenOrCreate=4,
- FileMode_Truncate=5,
- FileMode_Append=6
-} MonoFileMode;
-
-/* This is a copy of System.IO.FileShare */
-typedef enum {
- FileShare_None=0x0,
- FileShare_Read=0x01,
- FileShare_Write=0x02,
- FileShare_ReadWrite=FileShare_Read|FileShare_Write,
- FileShare_Delete=0x04
-} MonoFileShare;
-
-/* This is a copy of System.IO.FileOptions */
-typedef enum {
- FileOptions_None = 0,
- FileOptions_Temporary = 1, // Internal. See note in System.IO.FileOptions
- FileOptions_Encrypted = 0x4000,
- FileOptions_DeleteOnClose = 0x4000000,
- FileOptions_SequentialScan = 0x8000000,
- FileOptions_RandomAccess = 0x10000000,
- FileOptions_Asynchronous = 0x40000000,
- FileOptions_WriteThrough = 0x80000000
-} MonoFileOptions;
-
-/* This is a copy of System.IO.SeekOrigin */
-typedef enum {
- SeekOrigin_Begin=0,
- SeekOrigin_Current=1,
- SeekOrigin_End=2
-} MonoSeekOrigin;
-
-/* This is a copy of System.IO.MonoIOStat */
-typedef struct _MonoIOStat {
- gint32 attributes;
- gint64 length;
- gint64 creation_time;
- gint64 last_access_time;
- gint64 last_write_time;
-} MonoIOStat;
-
-/* This is a copy of System.IO.FileAttributes */
-typedef enum {
- FileAttributes_ReadOnly=0x00001,
- FileAttributes_Hidden=0x00002,
- FileAttributes_System=0x00004,
- FileAttributes_Directory=0x00010,
- FileAttributes_Archive=0x00020,
- FileAttributes_Device=0x00040,
- FileAttributes_Normal=0x00080,
- FileAttributes_Temporary=0x00100,
- FileAttributes_SparseFile=0x00200,
- FileAttributes_ReparsePoint=0x00400,
- FileAttributes_Compressed=0x00800,
- FileAttributes_Offline=0x01000,
- FileAttributes_NotContentIndexed=0x02000,
- FileAttributes_Encrypted=0x04000,
- FileAttributes_MonoExecutable= (int) 0x80000000
-} MonoFileAttributes;
-/* This is not used anymore
-typedef struct _MonoFSAsyncResult {
- MonoObject obj;
- MonoObject *state;
- MonoBoolean completed;
- MonoBoolean done;
- MonoException *exc;
- MonoWaitHandle *wait_handle;
- MonoDelegate *async_callback;
- MonoBoolean completed_synch;
- MonoArray *buffer;
- gint offset;
- gint count;
- gint original_count;
- gint bytes_read;
- MonoDelegate *real_cb;
-} MonoFSAsyncResult;
-*/
-/* System.IO.MonoIO */
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_CreateDirectory (MonoString *path, gint32 *error);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_RemoveDirectory (MonoString *path, gint32 *error);
-
-MonoArray *
-ves_icall_System_IO_MonoIO_GetFileSystemEntries (MonoString *path,
- MonoString *path_with_pattern,
- gint mask, gint attrs,
- gint32 *error);
-
-extern gpointer
-ves_icall_System_IO_MonoIO_FindFirstFile (MonoString *path_with_pattern,
- MonoString **file_name,
- gint32 *file_attr,
- gint32 *ioerror);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_FindNextFile (gpointer hnd,
- MonoString **file_name,
- gint32 *file_attr,
- gint32 *ioerror);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_FindCloseFile (gpointer hnd);
-
-extern MonoString *
-ves_icall_System_IO_MonoIO_FindFirst (MonoString *path,
- MonoString *path_with_pattern,
- gint32 *result_mask,
- gint32 *error,
- gpointer *handle);
-extern MonoString *
-ves_icall_System_IO_MonoIO_FindNext (gpointer handle, gint32 *result_mask, gint32 *error);
-
-extern int
-ves_icall_System_IO_MonoIO_FindClose (gpointer handle);
-
-extern MonoString *
-ves_icall_System_IO_MonoIO_GetCurrentDirectory (gint32 *error);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_SetCurrentDirectory (MonoString *path,
- gint32 *error);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_MoveFile (MonoString *path, MonoString *dest,
- gint32 *error);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_CopyFile (MonoString *path, MonoString *dest,
- MonoBoolean overwrite, gint32 *error);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_DeleteFile (MonoString *path, gint32 *error);
-
-extern gint32
-ves_icall_System_IO_MonoIO_GetFileAttributes (MonoString *path, gint32 *error);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_SetFileAttributes (MonoString *path, gint32 attrs,
- gint32 *error);
-
-extern gint32
-ves_icall_System_IO_MonoIO_GetFileType (gpointer handle, gint32 *error);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_GetFileStat (MonoString *path, MonoIOStat *stat,
- gint32 *error);
-
-extern gpointer
-ves_icall_System_IO_MonoIO_Open (MonoString *filename, gint32 mode,
- gint32 access_mode, gint32 share, gint32 options,
- gint32 *error);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_Close (gpointer handle, gint32 *error);
-
-extern gint32
-ves_icall_System_IO_MonoIO_Read (gpointer handle, MonoArray *dest,
- gint32 dest_offset, gint32 count,
- gint32 *error);
-
-extern gint32
-ves_icall_System_IO_MonoIO_Write (gpointer handle, MonoArray *src,
- gint32 src_offset, gint32 count,
- gint32 *error);
-
-extern gint64
-ves_icall_System_IO_MonoIO_Seek (gpointer handle, gint64 offset, gint32 origin,
- gint32 *error);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_Flush (gpointer handle, gint32 *error);
-
-extern gint64
-ves_icall_System_IO_MonoIO_GetLength (gpointer handle, gint32 *error);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_SetLength (gpointer handle, gint64 length,
- gint32 *error);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_SetFileTime (gpointer handle, gint64 creation_time,
- gint64 last_access_time,
- gint64 last_write_time, gint32 *error);
-
-extern gpointer
-ves_icall_System_IO_MonoIO_get_ConsoleOutput (void);
-
-extern gpointer
-ves_icall_System_IO_MonoIO_get_ConsoleInput (void);
-
-extern gpointer
-ves_icall_System_IO_MonoIO_get_ConsoleError (void);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_CreatePipe (gpointer *read_handle, gpointer *write_handle, gint32 *error);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_DuplicateHandle (gpointer source_process_handle, gpointer source_handle,
- gpointer target_process_handle, gpointer *target_handle, gint32 access, gint32 inherit, gint32 options, gint32 *error);
-
-extern gunichar2
-ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar (void);
-
-extern gunichar2
-ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar (void);
-
-extern gunichar2
-ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar (void);
-
-extern gunichar2
-ves_icall_System_IO_MonoIO_get_PathSeparator (void);
-
-extern MonoArray *
-ves_icall_System_IO_MonoIO_get_InvalidPathChars (void);
-
-extern void ves_icall_System_IO_MonoIO_Lock (gpointer handle, gint64 position,
- gint64 length, gint32 *error);
-extern void ves_icall_System_IO_MonoIO_Unlock (gpointer handle, gint64 position,
- gint64 length, gint32 *error);
-
-extern MonoBoolean
-ves_icall_System_IO_MonoIO_ReplaceFile (MonoString *sourceFileName, MonoString *destinationFileName,
- MonoString *destinationBackupFileName, MonoBoolean ignoreMetadataErrors,
- gint32 *error);
-
-MONO_RT_EXTERNAL_ONLY
-extern gint64
-mono_filesize_from_path (MonoString *path);
-
-extern gint64
-mono_filesize_from_fd (int fd);
-
-void
-ves_icall_System_IO_MonoIO_DumpHandles (void);
-
-G_END_DECLS
-
-#endif /* _MONO_METADATA_FILEIO_H_ */
#include <mono/metadata/object.h>
-#include <mono/metadata/file-io.h>
+#include <mono/metadata/w32file.h>
#include <mono/metadata/file-mmap.h>
#include <mono/utils/atomic.h>
#include <mono/utils/mono-memory-model.h>
#include <mono/metadata/marshal.h>
#include <mono/utils/mono-dl.h>
#include <mono/utils/mono-io-portability.h>
-#include <mono/io-layer/io-layer.h>
+#include <mono/metadata/w32error.h>
#ifdef HOST_WIN32
#include <mono/metadata/object-internals.h>
#include <mono/metadata/threads-types.h>
#include <mono/sgen/gc-internal-agnostic.h>
-#include <mono/utils/gc_wrapper.h>
#define mono_domain_finalizers_lock(domain) mono_os_mutex_lock (&(domain)->finalizable_objects_hash_lock);
#define mono_domain_finalizers_unlock(domain) mono_os_mutex_unlock (&(domain)->finalizable_objects_hash_lock);
#include <mono/sgen/sgen-conf.h>
#include <mono/sgen/sgen-gc.h>
#include <mono/utils/mono-logger-internals.h>
-#include <mono/metadata/gc-internals.h>
#include <mono/metadata/marshal.h> /* for mono_delegate_free_ftnptr () */
#include <mono/metadata/attach.h>
#include <mono/metadata/console-io.h>
#include <mono/utils/atomic.h>
#include <mono/utils/mono-coop-semaphore.h>
#include <mono/utils/hazard-pointer.h>
-#include <mono/io-layer/io-layer.h>
+#include <mono/utils/w32api.h>
#ifndef HOST_WIN32
#include <pthread.h>
MonoError error;
gboolean wait = TRUE;
- mono_thread_set_name_internal (mono_thread_internal_current (), mono_string_new (mono_get_root_domain (), "Finalizer"), FALSE, &error);
+ mono_thread_set_name_internal (mono_thread_internal_current (), mono_string_new (mono_get_root_domain (), "Finalizer"), FALSE, FALSE, &error);
mono_error_assert_ok (&error);
/* Register a hazard free queue pump callback */
return MONO_HANDLE_NEW (MonoArray, mono_array_new_checked (domain, eclass, n, error));
}
+MonoArrayHandle
+mono_array_new_full_handle (MonoDomain *domain, MonoClass *array_class, uintptr_t *lengths, intptr_t *lower_bounds, MonoError *error)
+{
+ return MONO_HANDLE_NEW (MonoArray, mono_array_new_full_checked (domain, array_class, lengths, lower_bounds, error));
+}
+
#ifdef ENABLE_CHECKED_BUILD
/* Checked build helpers */
void
MonoObjectHandle
mono_gchandle_get_target_handle (uint32_t gchandle)
{
- return MONO_HANDLE_NEW (MonoObject, mono_gchandle_get_target);
+ return MONO_HANDLE_NEW (MonoObject, mono_gchandle_get_target (gchandle));
}
gpointer
mono_gc_wbarrier_generic_store (&__dest->__obj, (MonoObject*)(MONO_HANDLE_RAW(HANDLE)->FIELD)); \
} while (0)
+#define MONO_HANDLE_NEW_GET(TYPE,HANDLE,FIELD) (MONO_HANDLE_NEW(TYPE,MONO_HANDLE_RAW(HANDLE)->FIELD))
+
#define MONO_HANDLE_GETVAL(HANDLE, FIELD) (MONO_HANDLE_RAW(HANDLE)->FIELD)
/* VS doesn't support typeof :( :( :( */
//FIXME this should go somewhere else
MonoStringHandle mono_string_new_handle (MonoDomain *domain, const char *data, MonoError *error);
MonoArrayHandle mono_array_new_handle (MonoDomain *domain, MonoClass *eclass, uintptr_t n, MonoError *error);
+MonoArrayHandle
+mono_array_new_full_handle (MonoDomain *domain, MonoClass *array_class, uintptr_t *lengths, intptr_t *lower_bounds, MonoError *error);
+
uintptr_t mono_array_handle_length (MonoArrayHandle arr);
ICALL(APPDOM_23, "DoUnhandledException", ves_icall_System_AppDomain_DoUnhandledException)
HANDLES(ICALL(APPDOM_1, "ExecuteAssembly", ves_icall_System_AppDomain_ExecuteAssembly))
HANDLES(ICALL(APPDOM_2, "GetAssemblies", ves_icall_System_AppDomain_GetAssemblies))
-ICALL(APPDOM_3, "GetData", ves_icall_System_AppDomain_GetData)
+HANDLES(ICALL(APPDOM_3, "GetData", ves_icall_System_AppDomain_GetData))
ICALL(APPDOM_4, "InternalGetContext", ves_icall_System_AppDomain_InternalGetContext)
ICALL(APPDOM_5, "InternalGetDefaultContext", ves_icall_System_AppDomain_InternalGetDefaultContext)
-ICALL(APPDOM_6, "InternalGetProcessGuid", ves_icall_System_AppDomain_InternalGetProcessGuid)
-ICALL(APPDOM_7, "InternalIsFinalizingForUnload", ves_icall_System_AppDomain_InternalIsFinalizingForUnload)
-ICALL(APPDOM_8, "InternalPopDomainRef", ves_icall_System_AppDomain_InternalPopDomainRef)
-ICALL(APPDOM_9, "InternalPushDomainRef", ves_icall_System_AppDomain_InternalPushDomainRef)
-ICALL(APPDOM_10, "InternalPushDomainRefByID", ves_icall_System_AppDomain_InternalPushDomainRefByID)
+HANDLES(ICALL(APPDOM_6, "InternalGetProcessGuid", ves_icall_System_AppDomain_InternalGetProcessGuid))
+HANDLES(ICALL(APPDOM_7, "InternalIsFinalizingForUnload", ves_icall_System_AppDomain_InternalIsFinalizingForUnload))
+HANDLES(ICALL(APPDOM_8, "InternalPopDomainRef", ves_icall_System_AppDomain_InternalPopDomainRef))
+HANDLES(ICALL(APPDOM_9, "InternalPushDomainRef", ves_icall_System_AppDomain_InternalPushDomainRef))
+HANDLES(ICALL(APPDOM_10, "InternalPushDomainRefByID", ves_icall_System_AppDomain_InternalPushDomainRefByID))
ICALL(APPDOM_11, "InternalSetContext", ves_icall_System_AppDomain_InternalSetContext)
-ICALL(APPDOM_12, "InternalSetDomain", ves_icall_System_AppDomain_InternalSetDomain)
-ICALL(APPDOM_13, "InternalSetDomainByID", ves_icall_System_AppDomain_InternalSetDomainByID)
-ICALL(APPDOM_14, "InternalUnload", ves_icall_System_AppDomain_InternalUnload)
+HANDLES(ICALL(APPDOM_12, "InternalSetDomain", ves_icall_System_AppDomain_InternalSetDomain))
+HANDLES(ICALL(APPDOM_13, "InternalSetDomainByID", ves_icall_System_AppDomain_InternalSetDomainByID))
+HANDLES(ICALL(APPDOM_14, "InternalUnload", ves_icall_System_AppDomain_InternalUnload))
HANDLES(ICALL(APPDOM_15, "LoadAssembly", ves_icall_System_AppDomain_LoadAssembly))
HANDLES(ICALL(APPDOM_16, "LoadAssemblyRaw", ves_icall_System_AppDomain_LoadAssemblyRaw))
-ICALL(APPDOM_17, "SetData", ves_icall_System_AppDomain_SetData)
-ICALL(APPDOM_18, "createDomain", ves_icall_System_AppDomain_createDomain)
-ICALL(APPDOM_19, "getCurDomain", ves_icall_System_AppDomain_getCurDomain)
-ICALL(APPDOM_20, "getFriendlyName", ves_icall_System_AppDomain_getFriendlyName)
-ICALL(APPDOM_21, "getRootDomain", ves_icall_System_AppDomain_getRootDomain)
-ICALL(APPDOM_22, "getSetup", ves_icall_System_AppDomain_getSetup)
+HANDLES(ICALL(APPDOM_17, "SetData", ves_icall_System_AppDomain_SetData))
+HANDLES(ICALL(APPDOM_18, "createDomain", ves_icall_System_AppDomain_createDomain))
+HANDLES(ICALL(APPDOM_19, "getCurDomain", ves_icall_System_AppDomain_getCurDomain))
+HANDLES(ICALL(APPDOM_20, "getFriendlyName", ves_icall_System_AppDomain_getFriendlyName))
+HANDLES(ICALL(APPDOM_21, "getRootDomain", ves_icall_System_AppDomain_getRootDomain))
+HANDLES(ICALL(APPDOM_22, "getSetup", ves_icall_System_AppDomain_getSetup))
ICALL_TYPE(ARGI, "System.ArgIterator", ARGI_1)
ICALL(ARGI_1, "IntGetNextArg()", mono_ArgIterator_IntGetNextArg)
#endif
ICALL_TYPE(DYNM, "System.Reflection.Emit.DynamicMethod", DYNM_1)
-ICALL(DYNM_1, "create_dynamic_method", ves_icall_DynamicMethod_create_dynamic_method)
+HANDLES(ICALL(DYNM_1, "create_dynamic_method", ves_icall_DynamicMethod_create_dynamic_method))
ICALL_TYPE(ENUMB, "System.Reflection.Emit.EnumBuilder", ENUMB_1)
ICALL(ENUMB_1, "setup_enum_type", ves_icall_EnumBuilder_setup_enum_type)
ICALL_TYPE(MODULEB, "System.Reflection.Emit.ModuleBuilder", MODULEB_10)
ICALL(MODULEB_10, "GetRegisteredToken", ves_icall_ModuleBuilder_GetRegisteredToken)
-ICALL(MODULEB_8, "RegisterToken", ves_icall_ModuleBuilder_RegisterToken)
+HANDLES(ICALL(MODULEB_8, "RegisterToken", ves_icall_ModuleBuilder_RegisterToken))
ICALL(MODULEB_1, "WriteToFile", ves_icall_ModuleBuilder_WriteToFile)
-ICALL(MODULEB_2, "basic_init", ves_icall_ModuleBuilder_basic_init)
+HANDLES(ICALL(MODULEB_2, "basic_init", ves_icall_ModuleBuilder_basic_init))
ICALL(MODULEB_3, "build_metadata", ves_icall_ModuleBuilder_build_metadata)
-ICALL(MODULEB_5, "getMethodToken", ves_icall_ModuleBuilder_getMethodToken)
-ICALL(MODULEB_6, "getToken", ves_icall_ModuleBuilder_getToken)
-ICALL(MODULEB_7, "getUSIndex", ves_icall_ModuleBuilder_getUSIndex)
+HANDLES(ICALL(MODULEB_5, "getMethodToken", ves_icall_ModuleBuilder_getMethodToken))
+HANDLES(ICALL(MODULEB_6, "getToken", ves_icall_ModuleBuilder_getToken))
+HANDLES(ICALL(MODULEB_7, "getUSIndex", ves_icall_ModuleBuilder_getUSIndex))
ICALL(MODULEB_9, "set_wrappers_type", ves_icall_ModuleBuilder_set_wrappers_type)
ICALL_TYPE(SIGH, "System.Reflection.Emit.SignatureHelper", SIGH_1)
ICALL(SIGH_2, "get_signature_local", ves_icall_SignatureHelper_get_signature_local)
ICALL_TYPE(TYPEB, "System.Reflection.Emit.TypeBuilder", TYPEB_1)
-ICALL(TYPEB_1, "create_runtime_class", ves_icall_TypeBuilder_create_runtime_class)
+HANDLES(ICALL(TYPEB_1, "create_runtime_class", ves_icall_TypeBuilder_create_runtime_class))
ICALL_TYPE(EVENTI, "System.Reflection.EventInfo", EVENTI_1)
HANDLES(ICALL(EVENTI_1, "internal_from_handle_type", ves_icall_System_Reflection_EventInfo_internal_from_handle_type))
HANDLES(ICALL(MODULE_13, "get_MetadataToken", ves_icall_reflection_get_token))
ICALL_TYPE(MCMETH, "System.Reflection.MonoCMethod", MCMETH_1)
-ICALL(MCMETH_1, "GetGenericMethodDefinition_impl", ves_icall_MonoMethod_GetGenericMethodDefinition)
+HANDLES(ICALL(MCMETH_1, "GetGenericMethodDefinition_impl", ves_icall_MonoMethod_GetGenericMethodDefinition))
ICALL(MCMETH_2, "InternalInvoke", ves_icall_InternalInvoke)
-ICALL(MCMETH_3, "get_core_clr_security_level", ves_icall_MonoMethod_get_core_clr_security_level)
+HANDLES(ICALL(MCMETH_3, "get_core_clr_security_level", ves_icall_MonoMethod_get_core_clr_security_level))
ICALL_TYPE(MEVIN, "System.Reflection.MonoEventInfo", MEVIN_1)
ICALL(MEVIN_1, "get_event_info", ves_icall_MonoEventInfo_get_event_info)
ICALL(MFIELD_7, "get_core_clr_security_level", ves_icall_MonoField_get_core_clr_security_level)
ICALL_TYPE(MMETH, "System.Reflection.MonoMethod", MMETH_2)
-ICALL(MMETH_2, "GetGenericArguments", ves_icall_MonoMethod_GetGenericArguments)
-ICALL(MMETH_3, "GetGenericMethodDefinition_impl", ves_icall_MonoMethod_GetGenericMethodDefinition)
-ICALL(MMETH_11, "GetPInvoke", ves_icall_MonoMethod_GetPInvoke)
+HANDLES(ICALL(MMETH_2, "GetGenericArguments", ves_icall_MonoMethod_GetGenericArguments))
+HANDLES(ICALL(MMETH_3, "GetGenericMethodDefinition_impl", ves_icall_MonoMethod_GetGenericMethodDefinition))
+HANDLES(ICALL(MMETH_11, "GetPInvoke", ves_icall_MonoMethod_GetPInvoke))
ICALL(MMETH_4, "InternalInvoke", ves_icall_InternalInvoke)
-ICALL(MMETH_5, "MakeGenericMethod_impl", ves_icall_MonoMethod_MakeGenericMethod_impl)
-ICALL(MMETH_6, "get_IsGenericMethod", ves_icall_MonoMethod_get_IsGenericMethod)
-ICALL(MMETH_7, "get_IsGenericMethodDefinition", ves_icall_MonoMethod_get_IsGenericMethodDefinition)
-ICALL(MMETH_8, "get_base_method", ves_icall_MonoMethod_get_base_method)
-ICALL(MMETH_10, "get_core_clr_security_level", ves_icall_MonoMethod_get_core_clr_security_level)
-ICALL(MMETH_9, "get_name", ves_icall_MonoMethod_get_name)
+HANDLES(ICALL(MMETH_5, "MakeGenericMethod_impl", ves_icall_MonoMethod_MakeGenericMethod_impl))
+HANDLES(ICALL(MMETH_6, "get_IsGenericMethod", ves_icall_MonoMethod_get_IsGenericMethod))
+HANDLES(ICALL(MMETH_7, "get_IsGenericMethodDefinition", ves_icall_MonoMethod_get_IsGenericMethodDefinition))
+HANDLES(ICALL(MMETH_8, "get_base_method", ves_icall_MonoMethod_get_base_method))
+HANDLES(ICALL(MMETH_10, "get_core_clr_security_level", ves_icall_MonoMethod_get_core_clr_security_level))
+HANDLES(ICALL(MMETH_9, "get_name", ves_icall_MonoMethod_get_name))
ICALL_TYPE(MMETHI, "System.Reflection.MonoMethodInfo", MMETHI_4)
ICALL(MMETHI_4, "get_method_attributes", vell_icall_get_method_attributes)
HANDLES(ICALL(RT_16, "GetTypeCodeImplInternal", ves_icall_type_GetTypeCodeInternal))
HANDLES(ICALL(RT_28, "IsTypeExportedToWindowsRuntime", ves_icall_System_RuntimeType_IsTypeExportedToWindowsRuntime))
HANDLES(ICALL(RT_29, "IsWindowsRuntimeObjectType", ves_icall_System_RuntimeType_IsWindowsRuntimeObjectType))
-ICALL(RT_17, "MakeGenericType", ves_icall_RuntimeType_MakeGenericType)
+HANDLES(ICALL(RT_17, "MakeGenericType", ves_icall_RuntimeType_MakeGenericType))
HANDLES(ICALL(RT_18, "MakePointerType", ves_icall_RuntimeType_MakePointerType))
HANDLES(ICALL(RT_19, "getFullName", ves_icall_System_RuntimeType_getFullName))
HANDLES(ICALL(RT_21, "get_DeclaringMethod", ves_icall_RuntimeType_get_DeclaringMethod))
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/exception-internals.h>
-#include <mono/metadata/file-io.h>
+#include <mono/metadata/w32file.h>
#include <mono/metadata/console-io.h>
#include <mono/metadata/mono-route.h>
-#include <mono/metadata/socket-io.h>
+#include <mono/metadata/w32socket.h>
#include <mono/metadata/mono-endian.h>
#include <mono/metadata/tokentype.h>
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/w32mutex.h>
#include <mono/metadata/w32semaphore.h>
#include <mono/metadata/w32event.h>
-#include <mono/io-layer/io-layer.h>
#include <mono/utils/monobitset.h>
#include <mono/utils/mono-time.h>
#include <mono/utils/mono-proclib.h>
#include <mono/utils/bsearch.h>
#include <mono/utils/mono-os-mutex.h>
#include <mono/utils/mono-threads.h>
+#include <mono/metadata/w32error.h>
+#include <mono/utils/w32api.h>
#include "decimal-ms.h"
#include "number-ms.h"
ICALL_EXPORT MonoReflectionAssemblyHandle ves_icall_System_Reflection_Assembly_GetCallingAssembly (MonoError *error);
/* Lazy class loading functions */
-static GENERATE_GET_CLASS_WITH_CACHE (system_version, System, Version)
-static GENERATE_GET_CLASS_WITH_CACHE (assembly_name, System.Reflection, AssemblyName)
-static GENERATE_GET_CLASS_WITH_CACHE (constructor_info, System.Reflection, ConstructorInfo)
-static GENERATE_GET_CLASS_WITH_CACHE (property_info, System.Reflection, PropertyInfo)
-static GENERATE_GET_CLASS_WITH_CACHE (event_info, System.Reflection, EventInfo)
-static GENERATE_GET_CLASS_WITH_CACHE (module, System.Reflection, Module)
+static GENERATE_GET_CLASS_WITH_CACHE (system_version, "System", "Version")
+static GENERATE_GET_CLASS_WITH_CACHE (assembly_name, "System.Reflection", "AssemblyName")
+static GENERATE_GET_CLASS_WITH_CACHE (constructor_info, "System.Reflection", "ConstructorInfo")
+static GENERATE_GET_CLASS_WITH_CACHE (property_info, "System.Reflection", "PropertyInfo")
+static GENERATE_GET_CLASS_WITH_CACHE (event_info, "System.Reflection", "EventInfo")
+static GENERATE_GET_CLASS_WITH_CACHE (module, "System.Reflection", "Module")
static MonoArrayHandle
type_array_from_modifiers (MonoImage *image, MonoType *type, int optional, MonoError *error);
if (mono_class_is_ginst (klass)) {
MonoClass *generic_class = mono_class_get_generic_class (klass)->container_class;
- guint32 ref_info_handle = mono_class_get_ref_info_handle (klass);
+ guint32 ref_info_handle = mono_class_get_ref_info_handle (generic_class);
if (generic_class->wastypebuilder && ref_info_handle) {
MonoObjectHandle tb = mono_gchandle_get_target_handle (ref_info_handle);
return ret;
}
-ICALL_EXPORT MonoReflectionType*
-ves_icall_RuntimeType_MakeGenericType (MonoReflectionType *type, MonoArray *type_array)
+ICALL_EXPORT MonoReflectionTypeHandle
+ves_icall_RuntimeType_MakeGenericType (MonoReflectionTypeHandle reftype, MonoArrayHandle type_array, MonoError *error)
{
- MonoError error;
- MonoReflectionType *ret;
- MonoClass *klass;
- MonoType *geninst, **types;
- int i, count;
+ mono_error_init (error);
+ MonoDomain *domain = MONO_HANDLE_DOMAIN (reftype);
- g_assert (IS_MONOTYPE (type));
- mono_class_init_checked (mono_class_from_mono_type (type->type), &error);
- if (mono_error_set_pending_exception (&error))
- return NULL;
+ g_assert (IS_MONOTYPE_HANDLE (reftype));
+ MonoType *type = MONO_HANDLE_GETVAL (reftype, type);
+ mono_class_init_checked (mono_class_from_mono_type (type), error);
+ if (!is_ok (error))
+ return MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE);
- count = mono_array_length (type_array);
- types = g_new0 (MonoType *, count);
+ int count = mono_array_handle_length (type_array);
+ MonoType **types = g_new0 (MonoType *, count);
- for (i = 0; i < count; i++) {
- MonoReflectionType *t = (MonoReflectionType *)mono_array_get (type_array, gpointer, i);
- types [i] = t->type;
+ MonoReflectionTypeHandle t = MONO_HANDLE_NEW (MonoReflectionType, NULL);
+ for (int i = 0; i < count; i++) {
+ MONO_HANDLE_ARRAY_GETREF (t, type_array, i);
+ types [i] = MONO_HANDLE_GETVAL (t, type);
}
- geninst = mono_reflection_bind_generic_parameters (type, count, types, &error);
+ MonoType *geninst = mono_reflection_bind_generic_parameters (reftype, count, types, error);
g_free (types);
if (!geninst) {
- mono_error_set_pending_exception (&error);
- return NULL;
+ return MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE);
}
- klass = mono_class_from_mono_type (geninst);
+ MonoClass *klass = mono_class_from_mono_type (geninst);
/*we might inflate to the GTD*/
if (mono_class_is_ginst (klass) && !mono_verifier_class_is_valid_generic_instantiation (klass)) {
- mono_set_pending_exception (mono_get_exception_argument ("typeArguments", "Invalid generic arguments"));
- return NULL;
+ mono_error_set_argument (error, "typeArguments", "Invalid generic arguments");
+ return MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE);
}
- ret = mono_type_get_object_checked (mono_object_domain (type), geninst, &error);
- mono_error_set_pending_exception (&error);
-
- return ret;
+ return mono_type_get_object_handle (domain, geninst, error);
}
ICALL_EXPORT gboolean
}
ICALL_EXPORT void
-ves_icall_MonoMethod_GetPInvoke (MonoReflectionMethod *method, int* flags, MonoString** entry_point, MonoString** dll_name)
+ves_icall_MonoMethod_GetPInvoke (MonoReflectionMethodHandle ref_method, int* flags, MonoStringHandleOut entry_point, MonoStringHandleOut dll_name, MonoError *error)
{
MonoDomain *domain = mono_domain_get ();
- MonoImage *image = method->method->klass->image;
- MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)method->method;
+ MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
+ MonoImage *image = method->klass->image;
+ MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)method;
MonoTableInfo *tables = image->tables;
MonoTableInfo *im = &tables [MONO_TABLE_IMPLMAP];
MonoTableInfo *mr = &tables [MONO_TABLE_MODULEREF];
const char *import = NULL;
const char *scope = NULL;
+ mono_error_init (error);
+
if (image_is_dynamic (image)) {
MonoReflectionMethodAux *method_aux =
- (MonoReflectionMethodAux *)g_hash_table_lookup (((MonoDynamicImage*)image)->method_aux_hash, method->method);
+ (MonoReflectionMethodAux *)g_hash_table_lookup (((MonoDynamicImage*)image)->method_aux_hash, method);
if (method_aux) {
import = method_aux->dllentry;
scope = method_aux->dll;
}
if (!import || !scope) {
- mono_set_pending_exception (mono_get_exception_argument ("method", "System.Reflection.Emit method with invalid pinvoke information"));
+ mono_error_set_argument (error, "method", "System.Refleciton.Emit method with invalid pinvoke information");
return;
}
}
}
*flags = piinfo->piflags;
- *entry_point = mono_string_new (domain, import);
- *dll_name = mono_string_new (domain, scope);
+ MONO_HANDLE_ASSIGN (entry_point, mono_string_new_handle (domain, import, error));
+ return_if_nok (error);
+ MONO_HANDLE_ASSIGN (dll_name, mono_string_new_handle (domain, scope, error));
}
-ICALL_EXPORT MonoReflectionMethod *
-ves_icall_MonoMethod_GetGenericMethodDefinition (MonoReflectionMethod *method)
+ICALL_EXPORT MonoReflectionMethodHandle
+ves_icall_MonoMethod_GetGenericMethodDefinition (MonoReflectionMethodHandle ref_method, MonoError *error)
{
- MonoMethodInflated *imethod;
- MonoMethod *result;
- MonoReflectionMethod *ret = NULL;
- MonoError error;
+ mono_error_init (error);
+ MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
- if (method->method->is_generic)
- return method;
+ if (method->is_generic)
+ return ref_method;
- if (!method->method->is_inflated)
- return NULL;
+ if (!method->is_inflated)
+ return MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE);
- imethod = (MonoMethodInflated *) method->method;
+ MonoMethodInflated *imethod = (MonoMethodInflated *) method;
- result = imethod->declaring;
+ MonoMethod *result = imethod->declaring;
/* Not a generic method. */
if (!result->is_generic)
- return NULL;
+ return MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE);
- if (image_is_dynamic (method->method->klass->image)) {
- MonoDynamicImage *image = (MonoDynamicImage*)method->method->klass->image;
- MonoReflectionMethod *res;
+ if (image_is_dynamic (method->klass->image)) {
+ MonoDynamicImage *image = (MonoDynamicImage*)method->klass->image;
/*
* FIXME: Why is this stuff needed at all ? Why can't the code below work for
* the dynamic case as well ?
*/
mono_image_lock ((MonoImage*)image);
- res = (MonoReflectionMethod *)mono_g_hash_table_lookup (image->generic_def_objects, imethod);
+ MonoReflectionMethodHandle res = MONO_HANDLE_NEW (MonoReflectionMethod, mono_g_hash_table_lookup (image->generic_def_objects, imethod));
mono_image_unlock ((MonoImage*)image);
- if (res)
+ if (!MONO_HANDLE_IS_NULL (res))
return res;
}
MonoClass *klass = ((MonoMethod *) imethod)->klass;
/*Generic methods gets the context of the GTD.*/
if (mono_class_get_context (klass)) {
- result = mono_class_inflate_generic_method_full_checked (result, klass, mono_class_get_context (klass), &error);
- if (!mono_error_ok (&error))
- goto leave;
+ result = mono_class_inflate_generic_method_full_checked (result, klass, mono_class_get_context (klass), error);
+ return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE));
}
}
- ret = mono_method_get_object_checked (mono_object_domain (method), result, NULL, &error);
-leave:
- if (!mono_error_ok (&error))
- mono_error_set_pending_exception (&error);
- return ret;
+ return mono_method_get_object_handle (MONO_HANDLE_DOMAIN (ref_method), result, NULL, error);
}
ICALL_EXPORT gboolean
-ves_icall_MonoMethod_get_IsGenericMethod (MonoReflectionMethod *method)
+ves_icall_MonoMethod_get_IsGenericMethod (MonoReflectionMethodHandle ref_method, MonoError *erro)
{
- return mono_method_signature (method->method)->generic_param_count != 0;
+ MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
+ return mono_method_signature (method)->generic_param_count != 0;
}
ICALL_EXPORT gboolean
-ves_icall_MonoMethod_get_IsGenericMethodDefinition (MonoReflectionMethod *method)
+ves_icall_MonoMethod_get_IsGenericMethodDefinition (MonoReflectionMethodHandle ref_method, MonoError *Error)
{
- return method->method->is_generic;
+ MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
+ return method->is_generic;
}
-ICALL_EXPORT MonoArray*
-ves_icall_MonoMethod_GetGenericArguments (MonoReflectionMethod *method)
+static gboolean
+set_array_generic_argument_handle_inflated (MonoDomain *domain, MonoGenericInst *inst, int i, MonoArrayHandle arr, MonoError *error)
{
- MonoError error;
- MonoReflectionType *rt;
- MonoArray *res;
- MonoDomain *domain;
- int count, i;
+ HANDLE_FUNCTION_ENTER ();
+ mono_error_init (error);
+ MonoReflectionTypeHandle rt = mono_type_get_object_handle (domain, inst->type_argv [i], error);
+ if (!is_ok (error))
+ goto leave;
+ MONO_HANDLE_ARRAY_SETREF (arr, i, rt);
+leave:
+ HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
+}
+
+static gboolean
+set_array_generic_argument_handle_gparam (MonoDomain *domain, MonoGenericContainer *container, int i, MonoArrayHandle arr, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER ();
+ mono_error_init (error);
+ MonoGenericParam *param = mono_generic_container_get_param (container, i);
+ MonoClass *pklass = mono_class_from_generic_parameter_internal (param);
+ MonoReflectionTypeHandle rt = mono_type_get_object_handle (domain, &pklass->byval_arg, error);
+ if (!is_ok (error))
+ goto leave;
+ MONO_HANDLE_ARRAY_SETREF (arr, i, rt);
+leave:
+ HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
+}
- domain = mono_object_domain (method);
+ICALL_EXPORT MonoArrayHandle
+ves_icall_MonoMethod_GetGenericArguments (MonoReflectionMethodHandle ref_method, MonoError *error)
+{
+ mono_error_init (error);
+ MonoDomain *domain = MONO_HANDLE_DOMAIN (ref_method);
+ MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
- if (method->method->is_inflated) {
- MonoGenericInst *inst = mono_method_get_context (method->method)->method_inst;
+ if (method->is_inflated) {
+ MonoGenericInst *inst = mono_method_get_context (method)->method_inst;
if (inst) {
- count = inst->type_argc;
- res = mono_array_new_checked (domain, mono_defaults.systemtype_class, count, &error);
- if (mono_error_set_pending_exception (&error))
- return NULL;
-
- for (i = 0; i < count; i++) {
- rt = mono_type_get_object_checked (domain, inst->type_argv [i], &error);
- if (mono_error_set_pending_exception (&error))
- return NULL;
+ int count = inst->type_argc;
+ MonoArrayHandle res = mono_array_new_handle (domain, mono_defaults.systemtype_class, count, error);
+ return_val_if_nok (error, MONO_HANDLE_CAST (MonoArray, NULL_HANDLE));
- mono_array_setref (res, i, rt);
+ for (int i = 0; i < count; i++) {
+ if (!set_array_generic_argument_handle_inflated (domain, inst, i, res, error))
+ break;
}
-
+ return_val_if_nok (error, MONO_HANDLE_CAST (MonoArray, NULL_HANDLE));
return res;
}
}
- count = mono_method_signature (method->method)->generic_param_count;
- res = mono_array_new_checked (domain, mono_defaults.systemtype_class, count, &error);
- if (mono_error_set_pending_exception (&error))
- return NULL;
-
- for (i = 0; i < count; i++) {
- MonoGenericContainer *container = mono_method_get_generic_container (method->method);
- MonoGenericParam *param = mono_generic_container_get_param (container, i);
- MonoClass *pklass = mono_class_from_generic_parameter_internal (param);
-
- rt = mono_type_get_object_checked (domain, &pklass->byval_arg, &error);
- if (mono_error_set_pending_exception (&error))
- return NULL;
+ int count = mono_method_signature (method)->generic_param_count;
+ MonoArrayHandle res = mono_array_new_handle (domain, mono_defaults.systemtype_class, count, error);
+ return_val_if_nok (error, MONO_HANDLE_CAST (MonoArray, NULL_HANDLE));
- mono_array_setref (res, i, rt);
+ MonoGenericContainer *container = mono_method_get_generic_container (method);
+ for (int i = 0; i < count; i++) {
+ if (!set_array_generic_argument_handle_gparam (domain, container, i, res, error))
+ break;
}
-
+ return_val_if_nok (error, MONO_HANDLE_CAST (MonoArray, NULL_HANDLE));
return res;
}
}
ICALL_EXPORT int
-ves_icall_MonoMethod_get_core_clr_security_level (MonoReflectionMethod *rfield)
+ves_icall_MonoMethod_get_core_clr_security_level (MonoReflectionMethodHandle rfield, MonoError *error)
{
- MonoMethod *method = rfield->method;
+ mono_error_init (error);
+ MonoMethod *method = MONO_HANDLE_GETVAL (rfield, method);
return mono_security_core_clr_method_level (method, TRUE);
}
replace_shadow_path (mono_domain_get (), dirname, &filename);
g_free (dirname);
- image = mono_image_open (filename, &status);
+ image = mono_image_open_full (filename, &status, TRUE);
if (!image){
if (status == MONO_IMAGE_IMAGE_INVALID)
{
MonoReflectionMethod *ret = NULL;
MonoError error;
- ret = mono_method_get_object_checked (mono_domain_get (), mono_object_get_virtual_method (delegate->target, delegate->method), mono_object_class (delegate->target), &error);
+ MonoMethod *m;
+
+ m = mono_object_get_virtual_method (delegate->target, delegate->method);
+ ret = mono_method_get_object_checked (mono_domain_get (), m, m->klass, &error);
mono_error_set_pending_exception (&error);
return ret;
}
/* Suspend all managed threads since the runtime is going away */
mono_thread_suspend_all_other_threads ();
+ //FIXME shutdown is, weirdly enough, abortible in gc.c so we add this hack for now, see https://bugzilla.xamarin.com/show_bug.cgi?id=51653
+ mono_threads_begin_abort_protected_block ();
+ mono_thread_info_clear_self_interrupt ();
+
mono_runtime_quit ();
#endif
ptr = buf;
while (size > initial_size) {
- size = (guint) GetLogicalDriveStrings (initial_size, ptr);
+ size = (guint) mono_w32file_get_logical_drive (initial_size, ptr);
if (size > initial_size) {
if (ptr != buf)
g_free (ptr);
MonoError error;
gunichar2 volume_name [MAX_PATH + 1];
- if (GetVolumeInformation (mono_string_chars (path), NULL, 0, NULL, NULL, NULL, volume_name, MAX_PATH + 1) == FALSE)
+ if (mono_w32file_get_volume_information (mono_string_chars (path), NULL, 0, NULL, NULL, NULL, volume_name, MAX_PATH + 1) == FALSE)
return NULL;
MonoString *result = mono_string_from_utf16_checked (volume_name, &error);
mono_error_set_pending_exception (&error);
gint32 *error)
{
gboolean result;
- ULARGE_INTEGER wapi_free_bytes_avail;
- ULARGE_INTEGER wapi_total_number_of_bytes;
- ULARGE_INTEGER wapi_total_number_of_free_bytes;
*error = ERROR_SUCCESS;
- result = GetDiskFreeSpaceEx (mono_string_chars (path_name), &wapi_free_bytes_avail, &wapi_total_number_of_bytes,
- &wapi_total_number_of_free_bytes);
- if (result) {
- *free_bytes_avail = wapi_free_bytes_avail.QuadPart;
- *total_number_of_bytes = wapi_total_number_of_bytes.QuadPart;
- *total_number_of_free_bytes = wapi_total_number_of_free_bytes.QuadPart;
- } else {
- *free_bytes_avail = 0;
- *total_number_of_bytes = 0;
- *total_number_of_free_bytes = 0;
- *error = GetLastError ();
- }
+ result = mono_w32file_get_disk_free_space (mono_string_chars (path_name), free_bytes_avail, total_number_of_bytes, total_number_of_free_bytes);
+ if (!result)
+ *error = mono_w32error_get_last ();
return result;
}
static inline guint32
mono_icall_drive_info_get_drive_type (MonoString *root_path_name)
{
- return GetDriveType (mono_string_chars (root_path_name));
+ return mono_w32file_get_drive_type (mono_string_chars (root_path_name));
}
#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
return MONO_HANDLE_NEW (MonoObject, mono_object_new_checked (domain, klass, error));
}
-ICALL_EXPORT MonoReflectionMethod *
-ves_icall_MonoMethod_get_base_method (MonoReflectionMethod *m, gboolean definition)
+ICALL_EXPORT MonoReflectionMethodHandle
+ves_icall_MonoMethod_get_base_method (MonoReflectionMethodHandle m, gboolean definition, MonoError *error)
{
- MonoReflectionMethod *ret = NULL;
- MonoError error;
-
- MonoClass *klass, *parent;
- MonoGenericContext *generic_inst = NULL;
- MonoMethod *method = m->method;
- MonoMethod *result = NULL;
- int slot;
-
- if (method->klass == NULL)
- return m;
-
- if (!(method->flags & METHOD_ATTRIBUTE_VIRTUAL) ||
- MONO_CLASS_IS_INTERFACE (method->klass) ||
- method->flags & METHOD_ATTRIBUTE_NEW_SLOT)
- return m;
-
- slot = mono_method_get_vtable_slot (method);
- if (slot == -1)
- return m;
-
- klass = method->klass;
- if (mono_class_is_ginst (klass)) {
- generic_inst = mono_class_get_context (klass);
- klass = mono_class_get_generic_class (klass)->container_class;
- }
-
-retry:
- if (definition) {
- /* At the end of the loop, klass points to the eldest class that has this virtual function slot. */
- for (parent = klass->parent; parent != NULL; parent = parent->parent) {
- /* on entry, klass is either a plain old non-generic class and generic_inst == NULL
- or klass is the generic container class and generic_inst is the instantiation.
-
- when we go to the parent, if the parent is an open constructed type, we need to
- replace the type parameters by the definitions from the generic_inst, and then take it
- apart again into the klass and the generic_inst.
-
- For cases like this:
- class C<T> : B<T, int> {
- public override void Foo () { ... }
- }
- class B<U,V> : A<HashMap<U,V>> {
- public override void Foo () { ... }
- }
- class A<X> {
- public virtual void Foo () { ... }
- }
-
- if at each iteration the parent isn't open, we can skip inflating it. if at some
- iteration the parent isn't generic (after possible inflation), we set generic_inst to
- NULL;
- */
- MonoGenericContext *parent_inst = NULL;
- if (mono_class_is_open_constructed_type (mono_class_get_type (parent))) {
- parent = mono_class_inflate_generic_class_checked (parent, generic_inst, &error);
- if (!mono_error_ok (&error)) {
- mono_error_set_pending_exception (&error);
- return NULL;
- }
- }
- if (mono_class_is_ginst (parent)) {
- parent_inst = mono_class_get_context (parent);
- parent = mono_class_get_generic_class (parent)->container_class;
- }
-
- mono_class_setup_vtable (parent);
- if (parent->vtable_size <= slot)
- break;
- klass = parent;
- generic_inst = parent_inst;
- }
- } else {
- klass = klass->parent;
- if (!klass)
- return m;
- if (mono_class_is_open_constructed_type (mono_class_get_type (klass))) {
- klass = mono_class_inflate_generic_class_checked (klass, generic_inst, &error);
- if (!mono_error_ok (&error)) {
- mono_error_set_pending_exception (&error);
- return NULL;
- }
-
- generic_inst = NULL;
- }
- if (mono_class_is_ginst (klass)) {
- generic_inst = mono_class_get_context (klass);
- klass = mono_class_get_generic_class (klass)->container_class;
- }
-
- }
-
- if (generic_inst) {
- klass = mono_class_inflate_generic_class_checked (klass, generic_inst, &error);
- if (!mono_error_ok (&error)) {
- mono_error_set_pending_exception (&error);
- return NULL;
- }
- }
-
- if (klass == method->klass)
- return m;
+ mono_error_init (error);
+ MonoMethod *method = MONO_HANDLE_GETVAL (m, method);
- /*This is possible if definition == FALSE.
- * Do it here to be really sure we don't read invalid memory.
- */
- if (slot >= klass->vtable_size)
+ MonoMethod *base = mono_method_get_base_method (method, definition, error);
+ return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE));
+ if (base == method)
return m;
-
- mono_class_setup_vtable (klass);
-
- result = klass->vtable [slot];
- if (result == NULL) {
- /* It is an abstract method */
- gboolean found = FALSE;
- gpointer iter = NULL;
- while ((result = mono_class_get_methods (klass, &iter))) {
- if (result->slot == slot) {
- found = TRUE;
- break;
- }
- }
- /* found might be FALSE if we looked in an abstract class
- * that doesn't override an abstract method of its
- * parent:
- * abstract class Base {
- * public abstract void Foo ();
- * }
- * abstract class Derived : Base { }
- * class Child : Derived {
- * public override void Foo () { }
- * }
- *
- * if m was Child.Foo and we ask for the base method,
- * then we get here with klass == Derived and found == FALSE
- */
- /* but it shouldn't be the case that if we're looking
- * for the definition and didn't find a result; the
- * loop above should've taken us as far as we could
- * go! */
- g_assert (!(definition && !found));
- if (!found)
- goto retry;
- }
-
- g_assert (result != NULL);
-
- ret = mono_method_get_object_checked (mono_domain_get (), result, NULL, &error);
- mono_error_set_pending_exception (&error);
- return ret;
+ else
+ return mono_method_get_object_handle (mono_domain_get (), base, NULL, error);
}
-ICALL_EXPORT MonoString*
-ves_icall_MonoMethod_get_name (MonoReflectionMethod *m)
+ICALL_EXPORT MonoStringHandle
+ves_icall_MonoMethod_get_name (MonoReflectionMethodHandle m, MonoError *error)
{
- MonoMethod *method = m->method;
+ mono_error_init (error);
+ MonoMethod *method = MONO_HANDLE_GETVAL (m, method);
- MONO_OBJECT_SETREF (m, name, mono_string_new (mono_object_domain (m), method->name));
- return m->name;
+ MonoStringHandle s = mono_string_new_handle (MONO_HANDLE_DOMAIN (m), method->name, error);
+ if (!is_ok (error))
+ return NULL_HANDLE_STRING;
+ MONO_HANDLE_SET (m, name, s);
+ return s;
}
ICALL_EXPORT void
#include "loader.h"
#include "marshal.h"
#include "coree.h"
-#include <mono/io-layer/io-layer.h>
#include <mono/utils/checked-build.h>
#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-path.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#include <mono/metadata/w32error.h>
#define INVALID_ADDRESS 0xffffffff
/* They must be the same */
g_assert ((const void *) image->tables_base == (const void *) rows);
+ if (image->heap_pdb.size) {
+ /*
+ * Obtain token sizes from the pdb stream.
+ */
+ /* 24 = guid + entry point */
+ int pos = 24;
+ image->referenced_tables = read64 (image->heap_pdb.data + pos);
+ pos += 8;
+ image->referenced_table_rows = g_new0 (int, 64);
+ for (int i = 0; i < 64; ++i) {
+ if (image->referenced_tables & ((guint64)1 << i)) {
+ image->referenced_table_rows [i] = read32 (image->heap_pdb.data + pos);
+ pos += 4;
+ }
+ }
+ }
+
mono_metadata_compute_table_bases (image);
return TRUE;
}
mono_install_image_loader (&pe_loader);
}
+/*
+Ignored assemblies.
+
+There are some assemblies we need to ignore because they include an implementation that doesn't work under mono.
+Mono provides its own implementation of those assemblies so it's safe to do so.
+
+The ignored_assemblies list is generated using tools/nuget-hash-extractor and feeding the problematic nugets to it.
+
+Right now the list of nugets are the ones that provide the assemblies in $ignored_assemblies_names.
+
+This is to be removed once a proper fix is shipped through nuget.
+
+*/
+
+typedef enum {
+ SYS_RT_INTEROP_RUNTIME_INFO = 0, //System.Runtime.InteropServices.RuntimeInformation
+ SYS_GLOBALIZATION_EXT = 1, //System.Globalization.Extensions
+ SYS_IO_COMPRESSION = 2, //System.IO.Compression
+ SYS_NET_HTTP = 3, //System.Net.Http
+ SYS_TEXT_ENC_CODEPAGES = 4, //System.Text.Encoding.CodePages
+ SYS_REF_DISP_PROXY = 5, //System.Reflection.DispatchProxy
+ SYS_VALUE_TUPLE = 6, //System.ValueTuple
+} IgnoredAssemblyNames;
+
+typedef struct {
+ int hash;
+ int assembly_name;
+ const char guid [40];
+} IgnoredAssembly;
+
+const char *ignored_assemblies_names[] = {
+ "System.Runtime.InteropServices.RuntimeInformation.dll",
+ "System.Globalization.Extensions.dll",
+ "System.IO.Compression.dll",
+ "System.Net.Http.dll",
+ "System.Text.Encoding.CodePages.dll",
+ "System.Reflection.DispatchProxy.dll",
+ "System.ValueTuple.dll"
+};
+
+#define IGNORED_ASSEMBLY(HASH, NAME, GUID, VER_STR) { .hash = HASH, .assembly_name = NAME, .guid = GUID }
+
+static const IgnoredAssembly ignored_assemblies [] = {
+ IGNORED_ASSEMBLY (0x1136045D, SYS_GLOBALIZATION_EXT, "475DBF02-9F68-44F1-8FB5-C9F69F1BD2B1", "4.0.0 net46"),
+ IGNORED_ASSEMBLY (0x358C9723, SYS_GLOBALIZATION_EXT, "5FCD54F0-4B97-4259-875D-30E481F02EA2", "4.0.1 net46"),
+ IGNORED_ASSEMBLY (0x450A096A, SYS_GLOBALIZATION_EXT, "E9FCFF5B-4DE1-4BDC-9CE8-08C640FC78CC", "4.3.0 net46"),
+ IGNORED_ASSEMBLY (0x1CBD59A2, SYS_IO_COMPRESSION, "44FCA06C-A510-4B3E-BDBF-D08D697EF65A", "4.1.0 net46"),
+ IGNORED_ASSEMBLY (0x5E393C29, SYS_IO_COMPRESSION, "3A58A219-266B-47C3-8BE8-4E4F394147AB", "4.3.0 net46"),
+ IGNORED_ASSEMBLY (0x27726A90, SYS_NET_HTTP, "269B562C-CC15-4736-B1B1-68D4A43CAA98", "4.1.0 net46"),
+ IGNORED_ASSEMBLY (0x10CADA75, SYS_NET_HTTP, "EA2EC6DC-51DD-479C-BFC2-E713FB9E7E47", "4.1.1 net46"),
+ IGNORED_ASSEMBLY (0x8437178B, SYS_NET_HTTP, "C0E04D9C-70CF-48A6-A179-FBFD8CE69FD0", "4.3.0 net46"),
+ IGNORED_ASSEMBLY (0x4A15555E, SYS_REF_DISP_PROXY, "E40AFEB4-CABE-4124-8412-B46AB79C92FD", "4.0.0 net46"),
+ IGNORED_ASSEMBLY (0xD20D9783, SYS_REF_DISP_PROXY, "2A69F0AD-B86B-40F2-8E4C-5B671E47479F", "4.0.1 netstandard1.3"),
+ IGNORED_ASSEMBLY (0xA33A7E68, SYS_REF_DISP_PROXY, "D4E8D2DB-BD65-4168-99EA-D2C1BDEBF9CC", "4.3.0 netstandard1.3"),
+ IGNORED_ASSEMBLY (0x46A4A1C5, SYS_RT_INTEROP_RUNTIME_INFO, "F13660F8-9D0D-419F-BA4E-315693DD26EA", "4.0.0 net45"),
+ IGNORED_ASSEMBLY (0xD07383BB, SYS_RT_INTEROP_RUNTIME_INFO, "DD91439F-3167-478E-BD2C-BF9C036A1395", "4.3.0 net45"),
+ IGNORED_ASSEMBLY (0x911D9EC3, SYS_TEXT_ENC_CODEPAGES, "C142254F-DEB5-46A7-AE43-6F10320D1D1F", "4.0.1 net46"),
+ IGNORED_ASSEMBLY (0xFA686A38, SYS_TEXT_ENC_CODEPAGES, "FD178CD4-EF4F-44D5-9C3F-812B1E25126B", "4.3.0 net46"),
+ IGNORED_ASSEMBLY (0x75B4B041, SYS_VALUE_TUPLE, "F81A4140-A898-4E2B-B6E9-55CE78C273EC", "4.3.0 netstandard1.0"),
+};
+
+/*
+Equivalent C# code:
+ static void Main () {
+ string str = "...";
+ int h = 5381;
+ for (int i = 0; i < str.Length; ++i)
+ h = ((h << 5) + h) ^ str[i];
+
+ Console.WriteLine ("{0:X}", h);
+ }
+*/
+static int
+hash_guid (const char *str)
+{
+ int h = 5381;
+ while (*str) {
+ h = ((h << 5) + h) ^ *str;
+ ++str;
+ }
+
+ return h;
+}
+
+static gboolean
+is_problematic_image (MonoImage *image)
+{
+ int h = hash_guid (image->guid);
+
+ //TODO make this more cache effiecient.
+ // Either sort by hash and bseach or use SoA and make the linear search more cache efficient.
+ for (int i = 0; i < G_N_ELEMENTS (ignored_assemblies); ++i) {
+ if (ignored_assemblies [i].hash == h && !strcmp (image->guid, ignored_assemblies [i].guid)) {
+ const char *needle = ignored_assemblies_names [ignored_assemblies [i].assembly_name];
+ size_t needle_len = strlen (needle);
+ size_t asm_len = strlen (image->name);
+ if (asm_len > needle_len && !g_ascii_strcasecmp (image->name + (asm_len - needle_len), needle))
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
static MonoImage *
do_mono_image_load (MonoImage *image, MonoImageOpenStatus *status,
gboolean care_about_cli, gboolean care_about_pecoff)
if (!mono_image_load_cli_data (image))
goto invalid_image;
+ if (!image->ref_only && is_problematic_image (image)) {
+ mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Denying load of problematic image %s", image->name);
+ *status = MONO_IMAGE_IMAGE_INVALID;
+ goto invalid_image;
+ }
+
if (image->loader == &pe_loader && !image->metadata_only && !mono_verifier_verify_table_data (image, &errors))
goto invalid_image;
fname_utf16 = g_utf8_to_utf16 (absfname, -1, NULL, NULL, NULL);
module_handle = MonoLoadImage (fname_utf16);
if (status && module_handle == NULL)
- last_error = GetLastError ();
+ last_error = mono_w32error_get_last ();
/* mono_image_open_from_module_handle is called by _CorDllMain. */
image = g_hash_table_lookup (loaded_images, absfname);
#include <mono/metadata/assembly.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/metadata-internals.h>
-#include <mono/metadata/gc-internals.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/mono-debug-debugger.h>
#include <mono/metadata/mono-config.h>
static const RegionInfoEntry* region_info_entry_from_lcid (int lcid);
/* Lazy class loading functions */
-static GENERATE_GET_CLASS_WITH_CACHE (culture_info, System.Globalization, CultureInfo)
+static GENERATE_GET_CLASS_WITH_CACHE (culture_info, "System.Globalization", "CultureInfo")
static int
culture_lcid_locator (const void *a, const void *b)
#include <execinfo.h>
#endif
-#include <mono/io-layer/io-layer.h>
#include <mono/utils/mono-compiler.h>
#include "lock-tracer.h"
#include <glib.h>
#include <mono/metadata/object-internals.h>
+MonoObjectHandle
+mono_marshal_xdomain_copy_value_handle (MonoObjectHandle val, MonoError *error);
+
// On Windows platform implementation of bellow methods are hosted in separate source file
// masrshal-windows.c or marshal-windows-*.c. On other platforms the implementation is still keept
// in marshal.c still declared as static and in some places even inlined.
#include "mono/metadata/threads-types.h"
#include "mono/metadata/string-icalls.h"
#include "mono/metadata/attrdefs.h"
-#include "mono/metadata/gc-internals.h"
#include "mono/metadata/cominterop.h"
#include "mono/metadata/remoting.h"
#include "mono/metadata/reflection-internals.h"
mono_icall_end (MonoThreadInfo *info, HandleStackMark *stackmark, MonoError *error);
/* Lazy class loading functions */
-static GENERATE_GET_CLASS_WITH_CACHE (string_builder, System.Text, StringBuilder);
-static GENERATE_GET_CLASS_WITH_CACHE (date_time, System, DateTime);
-static GENERATE_GET_CLASS_WITH_CACHE (fixed_buffer_attribute, System.Runtime.CompilerServices, FixedBufferAttribute);
-static GENERATE_TRY_GET_CLASS_WITH_CACHE (unmanaged_function_pointer_attribute, System.Runtime.InteropServices, UnmanagedFunctionPointerAttribute);
-static GENERATE_TRY_GET_CLASS_WITH_CACHE (icustom_marshaler, System.Runtime.InteropServices, ICustomMarshaler);
+static GENERATE_GET_CLASS_WITH_CACHE (string_builder, "System.Text", "StringBuilder");
+static GENERATE_GET_CLASS_WITH_CACHE (date_time, "System", "DateTime");
+static GENERATE_GET_CLASS_WITH_CACHE (fixed_buffer_attribute, "System.Runtime.CompilerServices", "FixedBufferAttribute");
+static GENERATE_TRY_GET_CLASS_WITH_CACHE (unmanaged_function_pointer_attribute, "System.Runtime.InteropServices", "UnmanagedFunctionPointerAttribute");
+static GENERATE_TRY_GET_CLASS_WITH_CACHE (icustom_marshaler, "System.Runtime.InteropServices", "ICustomMarshaler");
/* MonoMethod pointers to SafeHandle::DangerousAddRef and ::DangerousRelease */
static MonoMethod *sh_dangerous_add_ref;
}
}
+/*
+ * mono_marshal_get_generic_array_helper:
+ *
+ * Return a wrapper which is used to implement the implicit interfaces on arrays.
+ * The wrapper routes calls to METHOD, which is one of the InternalArray_ methods in Array.
+ */
MonoMethod *
-mono_marshal_get_generic_array_helper (MonoClass *klass, MonoClass *iface, gchar *name, MonoMethod *method)
+mono_marshal_get_generic_array_helper (MonoClass *klass, gchar *name, MonoMethod *method)
{
MonoMethodSignature *sig, *csig;
MonoMethodBuilder *mb;
mono_marshal_get_array_accessor_wrapper (MonoMethod *method);
MonoMethod *
-mono_marshal_get_generic_array_helper (MonoClass *klass, MonoClass *iface,
- gchar *name, MonoMethod *method);
+mono_marshal_get_generic_array_helper (MonoClass *klass, gchar *name, MonoMethod *method);
MonoMethod *
mono_marshal_get_thunk_invoke_wrapper (MonoMethod *method);
const char *tables_base;
+ /* For PPDB files */
+ guint64 referenced_tables;
+ int *referenced_table_rows;
+
/**/
MonoTableInfo tables [MONO_TABLE_NUM];
MONO_MT_HS_IDX,
/* ResolutionScope coded index: Module, ModuleRef, AssemblytRef, TypeRef */
- MONO_MT_RS_IDX
+ MONO_MT_RS_IDX,
+
+ /* CustomDebugInformation parent encoded index */
+ MONO_MT_HASCUSTDEBUG_IDX
};
const static unsigned char TableSchemas [] = {
MONO_MT_STRING_IDX, /* Name */
MONO_MT_END,
-#define NULL_SCHEMA_OFFSET LOCALVARIABLE_SCHEMA_OFFSET + 4
+#define LOCALCONSTANT_SCHEMA_OFFSET LOCALVARIABLE_SCHEMA_OFFSET + 4
+ MONO_MT_STRING_IDX, /* Name (String heap index) */
+ MONO_MT_BLOB_IDX, /* Signature (Blob heap index, LocalConstantSig blob) */
+ MONO_MT_END,
+
+#define IMPORTSCOPE_SCHEMA_OFFSET LOCALCONSTANT_SCHEMA_OFFSET + 3
+ MONO_MT_TABLE_IDX, /* Parent (ImportScope row id or nil) */
+ MONO_MT_BLOB_IDX, /* Imports (Blob index, encoding: Imports blob) */
+ MONO_MT_END,
+
+#define ASYNCMETHOD_SCHEMA_OFFSET IMPORTSCOPE_SCHEMA_OFFSET + 3
+ MONO_MT_TABLE_IDX, /* MoveNextMethod (MethodDef row id) */
+ MONO_MT_TABLE_IDX, /* KickoffMethod (MethodDef row id) */
+ MONO_MT_END,
+
+#define CUSTOMDEBUGINFORMATION_SCHEMA_OFFSET ASYNCMETHOD_SCHEMA_OFFSET + 3
+ MONO_MT_HASCUSTDEBUG_IDX, /* Parent (HasCustomDebugInformation coded index) */
+ MONO_MT_GUID_IDX, /* Kind (Guid heap index) */
+ MONO_MT_BLOB_IDX, /* Value (Blob heap index) */
+ MONO_MT_END,
+
+#define NULL_SCHEMA_OFFSET CUSTOMDEBUGINFORMATION_SCHEMA_OFFSET + 4
MONO_MT_END
};
DOCUMENT_SCHEMA_OFFSET, /* 0x30 */
METHODBODY_SCHEMA_OFFSET,
LOCALSCOPE_SCHEMA_OFFSET,
- LOCALVARIABLE_SCHEMA_OFFSET
+ LOCALVARIABLE_SCHEMA_OFFSET,
+ LOCALCONSTANT_SCHEMA_OFFSET,
+ IMPORTSCOPE_SCHEMA_OFFSET,
+ ASYNCMETHOD_SCHEMA_OFFSET,
+ CUSTOMDEBUGINFORMATION_SCHEMA_OFFSET
};
#ifdef HAVE_ARRAY_ELEM_INIT
*/
#define rtsize(meta,s,b) (((s) < (1 << (b)) ? 2 : 4))
-#define idx_size(meta,tableidx) ((meta)->tables [(tableidx)].rows < 65536 ? 2 : 4)
+
+static inline int
+idx_size (MonoImage *meta, int tableidx)
+{
+ if (meta->referenced_tables && (meta->referenced_tables & ((guint64)1 << tableidx)))
+ return meta->referenced_table_rows [tableidx] < 65536 ? 2 : 4;
+ else
+ return meta->tables [tableidx].rows < 65536 ? 2 : 4;
+}
+
+static inline int
+get_nrows (MonoImage *meta, int tableidx)
+{
+ if (meta->referenced_tables && (meta->referenced_tables & ((guint64)1 << tableidx)))
+ return meta->referenced_table_rows [tableidx];
+ else
+ return meta->tables [tableidx].rows;
+}
/* Reference: Partition II - 23.2.6 */
/*
break;
case MONO_TABLE_GENERICPARAM:
g_assert (i == 2);
- n = MAX (meta->tables [MONO_TABLE_METHOD].rows, meta->tables [MONO_TABLE_TYPEDEF].rows);
+ n = MAX (get_nrows (meta, MONO_TABLE_METHOD), get_nrows (meta, MONO_TABLE_TYPEDEF));
/*This is a coded token for 2 tables, so takes 1 bit */
field_size = rtsize (meta, n, 16 - MONO_TYPEORMETHOD_BITS);
break;
break;
case MONO_TABLE_METHODBODY:
g_assert (i == 0);
- field_size = idx_size (meta, MONO_TABLE_DOCUMENT);
- break;
+ field_size = idx_size (meta, MONO_TABLE_DOCUMENT); break;
+ case MONO_TABLE_IMPORTSCOPE:
+ g_assert(i == 0);
+ field_size = idx_size (meta, MONO_TABLE_IMPORTSCOPE); break;
+ case MONO_TABLE_STATEMACHINEMETHOD:
+ g_assert(i == 0 || i == 1);
+ field_size = idx_size(meta, MONO_TABLE_METHOD); break;
default:
g_error ("Can't handle MONO_MT_TABLE_IDX for table %d element %d", tableindex, i);
}
* HasConstant: ParamDef, FieldDef, Property
*/
case MONO_MT_CONST_IDX:
- n = MAX (meta->tables [MONO_TABLE_PARAM].rows,
- meta->tables [MONO_TABLE_FIELD].rows);
- n = MAX (n, meta->tables [MONO_TABLE_PROPERTY].rows);
+ n = MAX (get_nrows (meta, MONO_TABLE_PARAM),
+ get_nrows (meta, MONO_TABLE_FIELD));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_PROPERTY));
/* 2 bits to encode tag */
field_size = rtsize (meta, n, 16-2);
break;
}*/
- n = MAX (meta->tables [MONO_TABLE_METHOD].rows,
- meta->tables [MONO_TABLE_FIELD].rows);
- n = MAX (n, meta->tables [MONO_TABLE_TYPEREF].rows);
- n = MAX (n, meta->tables [MONO_TABLE_TYPEDEF].rows);
- n = MAX (n, meta->tables [MONO_TABLE_PARAM].rows);
- n = MAX (n, meta->tables [MONO_TABLE_INTERFACEIMPL].rows);
- n = MAX (n, meta->tables [MONO_TABLE_MEMBERREF].rows);
- n = MAX (n, meta->tables [MONO_TABLE_MODULE].rows);
- n = MAX (n, meta->tables [MONO_TABLE_DECLSECURITY].rows);
- n = MAX (n, meta->tables [MONO_TABLE_PROPERTY].rows);
- n = MAX (n, meta->tables [MONO_TABLE_EVENT].rows);
- n = MAX (n, meta->tables [MONO_TABLE_STANDALONESIG].rows);
- n = MAX (n, meta->tables [MONO_TABLE_MODULEREF].rows);
- n = MAX (n, meta->tables [MONO_TABLE_TYPESPEC].rows);
- n = MAX (n, meta->tables [MONO_TABLE_ASSEMBLY].rows);
- n = MAX (n, meta->tables [MONO_TABLE_ASSEMBLYREF].rows);
- n = MAX (n, meta->tables [MONO_TABLE_FILE].rows);
- n = MAX (n, meta->tables [MONO_TABLE_EXPORTEDTYPE].rows);
- n = MAX (n, meta->tables [MONO_TABLE_MANIFESTRESOURCE].rows);
+ n = MAX (get_nrows (meta, MONO_TABLE_METHOD),
+ get_nrows (meta, MONO_TABLE_FIELD));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_TYPEREF));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_TYPEDEF));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_PARAM));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_INTERFACEIMPL));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_MEMBERREF));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_MODULE));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_DECLSECURITY));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_PROPERTY));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_EVENT));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_STANDALONESIG));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_MODULEREF));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_TYPESPEC));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_ASSEMBLY));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_ASSEMBLYREF));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_FILE));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_EXPORTEDTYPE));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_MANIFESTRESOURCE));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_GENERICPARAM));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_GENERICPARAMCONSTRAINT));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_METHODSPEC));
/* 5 bits to encode */
field_size = rtsize (meta, n, 16-5);
break;
+ /*
+ * HasCustomAttribute: points to any table but
+ * itself.
+ */
+
+ case MONO_MT_HASCUSTDEBUG_IDX:
+ n = MAX(get_nrows (meta, MONO_TABLE_METHOD),
+ get_nrows (meta, MONO_TABLE_FIELD));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_TYPEREF));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_TYPEDEF));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_PARAM));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_INTERFACEIMPL));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_MEMBERREF));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_MODULE));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_DECLSECURITY));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_PROPERTY));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_EVENT));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_STANDALONESIG));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_MODULEREF));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_TYPESPEC));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_ASSEMBLY));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_ASSEMBLYREF));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_FILE));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_EXPORTEDTYPE));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_MANIFESTRESOURCE));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_GENERICPARAM));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_GENERICPARAMCONSTRAINT));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_METHODSPEC));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_DOCUMENT));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_LOCALSCOPE));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_LOCALVARIABLE));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_LOCALCONSTANT));
+ n = MAX(n, get_nrows (meta, MONO_TABLE_IMPORTSCOPE));
+
+ /* 5 bits to encode */
+ field_size = rtsize(meta, n, 16 - 5);
+ break;
+
/*
* CustomAttributeType: TypeDef, TypeRef, MethodDef,
* MemberRef and String.
break;
}*/
- n = MAX (meta->tables [MONO_TABLE_TYPEREF].rows,
- meta->tables [MONO_TABLE_TYPEDEF].rows);
- n = MAX (n, meta->tables [MONO_TABLE_METHOD].rows);
- n = MAX (n, meta->tables [MONO_TABLE_MEMBERREF].rows);
+ n = MAX (get_nrows (meta, MONO_TABLE_TYPEREF),
+ get_nrows (meta, MONO_TABLE_TYPEDEF));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_METHOD));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_MEMBERREF));
/* 3 bits to encode */
field_size = rtsize (meta, n, 16-3);
* HasDeclSecurity: Typedef, MethodDef, Assembly
*/
case MONO_MT_HASDEC_IDX:
- n = MAX (meta->tables [MONO_TABLE_TYPEDEF].rows,
- meta->tables [MONO_TABLE_METHOD].rows);
- n = MAX (n, meta->tables [MONO_TABLE_ASSEMBLY].rows);
+ n = MAX (get_nrows (meta, MONO_TABLE_TYPEDEF),
+ get_nrows (meta, MONO_TABLE_METHOD));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_ASSEMBLY));
/* 2 bits to encode */
field_size = rtsize (meta, n, 16-2);
* Implementation: File, AssemblyRef, ExportedType
*/
case MONO_MT_IMPL_IDX:
- n = MAX (meta->tables [MONO_TABLE_FILE].rows,
- meta->tables [MONO_TABLE_ASSEMBLYREF].rows);
- n = MAX (n, meta->tables [MONO_TABLE_EXPORTEDTYPE].rows);
+ n = MAX (get_nrows (meta, MONO_TABLE_FILE),
+ get_nrows (meta, MONO_TABLE_ASSEMBLYREF));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_EXPORTEDTYPE));
/* 2 bits to encode tag */
field_size = rtsize (meta, n, 16-2);
* HasFieldMarshall: FieldDef, ParamDef
*/
case MONO_MT_HFM_IDX:
- n = MAX (meta->tables [MONO_TABLE_FIELD].rows,
- meta->tables [MONO_TABLE_PARAM].rows);
+ n = MAX (get_nrows (meta, MONO_TABLE_FIELD),
+ get_nrows (meta, MONO_TABLE_PARAM));
/* 1 bit used to encode tag */
field_size = rtsize (meta, n, 16-1);
* MemberForwarded: FieldDef, MethodDef
*/
case MONO_MT_MF_IDX:
- n = MAX (meta->tables [MONO_TABLE_FIELD].rows,
- meta->tables [MONO_TABLE_METHOD].rows);
+ n = MAX (get_nrows (meta, MONO_TABLE_FIELD),
+ get_nrows (meta, MONO_TABLE_METHOD));
/* 1 bit used to encode tag */
field_size = rtsize (meta, n, 16-1);
* It is TypeDef, _TypeRef_, TypeSpec, instead.
*/
case MONO_MT_TDOR_IDX:
- n = MAX (meta->tables [MONO_TABLE_TYPEDEF].rows,
- meta->tables [MONO_TABLE_TYPEREF].rows);
- n = MAX (n, meta->tables [MONO_TABLE_TYPESPEC].rows);
+ n = MAX (get_nrows (meta, MONO_TABLE_TYPEDEF),
+ get_nrows (meta, MONO_TABLE_TYPEREF));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_TYPESPEC));
/* 2 bits to encode */
field_size = rtsize (meta, n, 16-2);
* MemberRefParent: TypeDef, TypeRef, MethodDef, ModuleRef, TypeSpec, MemberRef
*/
case MONO_MT_MRP_IDX:
- n = MAX (meta->tables [MONO_TABLE_TYPEDEF].rows,
- meta->tables [MONO_TABLE_TYPEREF].rows);
- n = MAX (n, meta->tables [MONO_TABLE_METHOD].rows);
- n = MAX (n, meta->tables [MONO_TABLE_MODULEREF].rows);
- n = MAX (n, meta->tables [MONO_TABLE_TYPESPEC].rows);
+ n = MAX (get_nrows (meta, MONO_TABLE_TYPEDEF),
+ get_nrows (meta, MONO_TABLE_TYPEREF));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_METHOD));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_MODULEREF));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_TYPESPEC));
/* 3 bits to encode */
field_size = rtsize (meta, n, 16 - 3);
* MethodDefOrRef: MethodDef, MemberRef
*/
case MONO_MT_MDOR_IDX:
- n = MAX (meta->tables [MONO_TABLE_METHOD].rows,
- meta->tables [MONO_TABLE_MEMBERREF].rows);
+ n = MAX (get_nrows (meta, MONO_TABLE_METHOD),
+ get_nrows (meta, MONO_TABLE_MEMBERREF));
/* 1 bit used to encode tag */
field_size = rtsize (meta, n, 16-1);
* HasSemantics: Property, Event
*/
case MONO_MT_HS_IDX:
- n = MAX (meta->tables [MONO_TABLE_PROPERTY].rows,
- meta->tables [MONO_TABLE_EVENT].rows);
+ n = MAX (get_nrows (meta, MONO_TABLE_PROPERTY),
+ get_nrows (meta, MONO_TABLE_EVENT));
/* 1 bit used to encode tag */
field_size = rtsize (meta, n, 16-1);
* ResolutionScope: Module, ModuleRef, AssemblyRef, TypeRef
*/
case MONO_MT_RS_IDX:
- n = MAX (meta->tables [MONO_TABLE_MODULE].rows,
- meta->tables [MONO_TABLE_MODULEREF].rows);
- n = MAX (n, meta->tables [MONO_TABLE_ASSEMBLYREF].rows);
- n = MAX (n, meta->tables [MONO_TABLE_TYPEREF].rows);
+ n = MAX (get_nrows (meta, MONO_TABLE_MODULE),
+ get_nrows (meta, MONO_TABLE_MODULEREF));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_ASSEMBLYREF));
+ n = MAX (n, get_nrows (meta, MONO_TABLE_TYPEREF));
/* 2 bits used to encode tag (ECMA spec claims 3) */
field_size = rtsize (meta, n, 16 - 2);
* @rptr: the new position of the pointer
*
* This routine decompresses 32-bit values as specified in the "Blob and
- * Signature" section (22.2)
+ * Signature" section (23.2)
*
* Returns: the decoded value
*/
#include <mono/metadata/threads-types.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/threads.h>
-#include <mono/io-layer/io-layer.h>
#include <mono/metadata/object-internals.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/gc-internals.h>
#include <mono/metadata/profiler-private.h>
#include <mono/utils/mono-time.h>
#include <mono/utils/atomic.h>
+#include <mono/utils/w32api.h>
/*
* Pull the list of opcodes
/* Orphaned events left by aborted threads */
while (new_->wait_list) {
LOCK_DEBUG (g_message (G_GNUC_PRETTY_FUNCTION ": (%d): Closing orphaned event %d", mono_thread_info_get_small_id (), new_->wait_list->data));
- CloseHandle (new_->wait_list->data);
+ mono_w32event_close (new_->wait_list->data);
new_->wait_list = g_slist_remove (new_->wait_list, new_->wait_list->data);
}
}
/* This looks superfluous */
if (mono_thread_current_check_pending_interrupt ()) {
- CloseHandle (event);
+ mono_w32event_close (event);
return FALSE;
}
*/
mon->wait_list = g_slist_remove (mon->wait_list, event);
}
- CloseHandle (event);
+ mono_w32event_close (event);
return success;
}
-/*
- * This is a private header file.
- * The API in here is undocumented and may only be used by the JIT to
- * communicate with the debugger.
- */
-
#ifndef __MONO_DEBUG_DEBUGGER_H__
#define __MONO_DEBUG_DEBUGGER_H__
MONO_API void
mono_debug_free_locals (MonoDebugLocalsInfo *info);
+void
+mono_debug_free_method_async_debug_info (MonoDebugMethodAsyncInfo *info);
+
#endif /* __MONO_DEBUG_DEBUGGER_H__ */
g_free (info);
}
+/*
+* mono_debug_lookup_method_async_debug_info:
+*
+* Return information about the async stepping information of method.
+* The result should be freed using mono_debug_free_async_debug_info ().
+*/
+MonoDebugMethodAsyncInfo*
+mono_debug_lookup_method_async_debug_info (MonoMethod *method)
+{
+ MonoDebugMethodInfo *minfo;
+ MonoDebugMethodAsyncInfo *res = NULL;
+
+ if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
+ return NULL;
+
+ mono_debugger_lock ();
+ minfo = mono_debug_lookup_method_internal (method);
+ if (!minfo || !minfo->handle) {
+ mono_debugger_unlock ();
+ return NULL;
+ }
+
+ if (minfo->handle->ppdb)
+ res = mono_ppdb_lookup_method_async_debug_info (minfo);
+
+ mono_debugger_unlock ();
+
+ return res;
+}
+
+/*
+ * mono_debug_free_method_async_debug_info:
+ *
+ * Free all the data allocated by mono_debug_lookup_method_async_debug_info ().
+ */
+void
+mono_debug_free_method_async_debug_info (MonoDebugMethodAsyncInfo *info)
+{
+ if (info->num_awaits) {
+ g_free (info->yield_offsets);
+ g_free (info->resume_offsets);
+ g_free (info->move_next_method_token);
+ }
+ g_free (info);
+}
+
/**
* mono_debug_free_source_location:
* @location: A `MonoDebugSourceLocation'.
typedef struct _MonoDebugMethodInfo MonoDebugMethodInfo;
typedef struct _MonoDebugLocalsInfo MonoDebugLocalsInfo;
+typedef struct _MonoDebugMethodAsyncInfo MonoDebugMethodAsyncInfo;
typedef struct _MonoDebugSourceLocation MonoDebugSourceLocation;
typedef struct _MonoDebugList MonoDebugList;
MONO_API MonoDebugLocalsInfo*
mono_debug_lookup_locals (MonoMethod *method);
+MonoDebugMethodAsyncInfo*
+mono_debug_lookup_method_async_debug_info (MonoMethod *method);
+
MonoDebugSourceLocation *
mono_debug_method_lookup_location (MonoDebugMethodInfo *minfo, int il_offset);
#include "utils/mono-networkinterfaces.h"
#include "utils/mono-error-internals.h"
#include "utils/atomic.h"
-#include <mono/io-layer/io-layer.h>
/* map of CounterSample.cs */
struct _MonoCounterSample {
#include <mono/metadata/object-internals.h>
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/security.h>
-#include <mono/io-layer/io-layer.h>
#include <mono/utils/strenc.h>
#ifndef HOST_WIN32
/* Safely access System.AppDomain from native code */
TYPED_HANDLE_DECL (MonoAppDomain);
+/* Safely access System.AppDomainSetup from native code. (struct is in domain-internals.h) */
+TYPED_HANDLE_DECL (MonoAppDomainSetup);
+
typedef struct _MonoStringBuilder MonoStringBuilder;
struct _MonoStringBuilder {
int _serialized_principal_version;
gpointer appdomain_refs;
/* This is modified using atomic ops, so keep it a gint32 */
- gint32 interruption_requested;
+ gint32 __interruption_requested;
MonoCoopMutex *synch_cs;
MonoBoolean threadpool_thread;
MonoBoolean thread_interrupt_requested;
gpointer interrupt_on_stop;
gsize flags;
gpointer thread_pinning_ref;
- gsize abort_protected_block_count;
+ gsize __abort_protected_block_count;
gint32 priority;
GPtrArray *owned_mutexes;
MonoOSEvent *suspended;
gint32 self_suspended; // TRUE | FALSE
+
+ gsize thread_state;
/*
* These fields are used to avoid having to increment corlib versions
* when a new field is added to this structure.
* Please synchronize any changes with InternalThread in Thread.cs, i.e. add the
* same field there.
*/
- gsize unused1;
gsize unused2;
/* This is used only to check that we are in sync between the representation
guint32 call_conv;
} MonoReflectionArrayMethod;
+/* Safely access System.Reflection.Emit.MonoArrayMethod from native code */
+TYPED_HANDLE_DECL (MonoReflectionArrayMethod);
+
typedef struct {
MonoArray *data;
MonoString *name;
typedef struct {
MonoReflectionType type;
MonoReflectionType *element_type;
- int rank;
+ gint32 rank;
} MonoReflectionArrayType;
+/* Safely access System.Reflection.Emit.ArrayType (in DerivedTypes.cs) from native code */
+TYPED_HANDLE_DECL (MonoReflectionArrayType);
+
typedef struct {
MonoReflectionType type;
MonoReflectionType *element_type;
} MonoReflectionDerivedType;
+/* Safely access System.Reflection.Emit.SymbolType and subclasses (in DerivedTypes.cs) from native code */
+TYPED_HANDLE_DECL (MonoReflectionDerivedType);
+
typedef struct {
MonoReflectionType type;
MonoReflectionTypeBuilder *tbuilder;
guint32 attrs;
} MonoReflectionGenericParam;
+/* Safely access System.Reflection.Emit.GenericTypeParameterBuilder from native code */
+TYPED_HANDLE_DECL (MonoReflectionGenericParam);
+
typedef struct {
MonoReflectionType type;
MonoReflectionTypeBuilder *tb;
} MonoReflectionEnumBuilder;
+/* Safely access System.Reflection.Emit.EnumBuilder from native code */
+TYPED_HANDLE_DECL (MonoReflectionEnumBuilder);
+
typedef struct _MonoReflectionGenericClass MonoReflectionGenericClass;
struct _MonoReflectionGenericClass {
MonoReflectionType type;
MonoArray *type_arguments;
};
+/* Safely access System.Reflection.Emit.TypeBuilderInstantiation from native code */
+TYPED_HANDLE_DECL (MonoReflectionGenericClass);
+
typedef struct {
MonoObject obj;
MonoString *name;
MonoReflectionType *owner;
} MonoReflectionDynamicMethod;
+/* Safely access System.Reflection.Emit.DynamicMethod from native code */
+TYPED_HANDLE_DECL (MonoReflectionDynamicMethod);
+
typedef struct {
MonoObject object;
MonoReflectionModuleBuilder *module;
MonoArray *modopts;
} MonoReflectionSigHelper;
+/* Safely access System.Reflection.Emit.SignatureHelper from native code */
+TYPED_HANDLE_DECL (MonoReflectionSigHelper);
+
typedef struct {
MonoObject object;
MonoBoolean visible;
} CattrNamedArg;
gboolean mono_image_create_pefile (MonoReflectionModuleBuilder *module, gpointer file, MonoError *error);
-guint32 mono_image_insert_string (MonoReflectionModuleBuilder *module, MonoString *str);
-guint32 mono_image_create_token (MonoDynamicImage *assembly, MonoObject *obj, gboolean create_methodspec, gboolean register_token, MonoError *error);
-guint32 mono_image_create_method_token (MonoDynamicImage *assembly, MonoObject *obj, MonoArray *opt_param_types, MonoError *error);
-void mono_image_register_token (MonoDynamicImage *assembly, guint32 token, MonoObject *obj);
+guint32 mono_image_insert_string (MonoReflectionModuleBuilderHandle module, MonoStringHandle str, MonoError *error);
+guint32 mono_image_create_token (MonoDynamicImage *assembly, MonoObjectHandle obj, gboolean create_methodspec, gboolean register_token, MonoError *error);
void mono_dynamic_image_free (MonoDynamicImage *image);
void mono_dynamic_image_free_image (MonoDynamicImage *image);
void mono_dynamic_image_release_gc_roots (MonoDynamicImage *image);
MonoClass*
mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, gboolean is_dynamic);
MonoType*
-mono_reflection_bind_generic_parameters (MonoReflectionType *type, int type_argc, MonoType **types, MonoError *error);
+mono_reflection_bind_generic_parameters (MonoReflectionTypeHandle type, int type_argc, MonoType **types, MonoError *error);
void
mono_reflection_generic_class_initialize (MonoReflectionGenericClass *type, MonoArray *fields);
void
mono_release_type_locks (MonoInternalThread *thread);
+int
+mono_string_handle_length (MonoStringHandle s);
+
char *
mono_string_handle_to_utf8 (MonoStringHandle s, MonoError *error);
mono_string_to_utf8_mp (MonoMemPool *mp, MonoString *s, MonoError *error);
char *
-mono_string_to_utf8_image (MonoImage *image, MonoString *s, MonoError *error);
+mono_string_to_utf8_image (MonoImage *image, MonoStringHandle s, MonoError *error);
-MonoArray*
-mono_array_clone_in_domain (MonoDomain *domain, MonoArray *array, MonoError *error);
+MonoArrayHandle
+mono_array_clone_in_domain (MonoDomain *domain, MonoArrayHandle array, MonoError *error);
MonoArray*
mono_array_clone_checked (MonoArray *array, MonoError *error);
MonoObject *
mono_get_object_from_blob (MonoDomain *domain, MonoType *type, const char *blob, MonoError *error);
-gpointer
+MonoObjectHandle
mono_class_get_ref_info (MonoClass *klass);
+gboolean
+mono_class_has_ref_info (MonoClass *klass);
+
+MonoObject*
+mono_class_get_ref_info_raw (MonoClass *klass);
+
void
-mono_class_set_ref_info (MonoClass *klass, gpointer obj);
+mono_class_set_ref_info (MonoClass *klass, MonoObjectHandle obj);
void
mono_class_free_ref_info (MonoClass *klass);
MonoString *
mono_string_new_utf16_checked (MonoDomain *domain, const guint16 *text, gint32 len, MonoError *error);
+MonoStringHandle
+mono_string_new_utf16_handle (MonoDomain *domain, const guint16 *text, gint32 len, MonoError *error);
+
MonoString *
mono_string_from_utf16_checked (mono_unichar2 *data, MonoError *error);
int
mono_runtime_try_exec_main (MonoMethod *method, MonoArray *args, MonoObject **exc);
-MonoReflectionMethod*
-ves_icall_MonoMethod_MakeGenericMethod_impl (MonoReflectionMethod *rmethod, MonoArray *types);
+MonoReflectionMethodHandle
+ves_icall_MonoMethod_MakeGenericMethod_impl (MonoReflectionMethodHandle rmethod, MonoArrayHandle types, MonoError *error);
gint32
-ves_icall_ModuleBuilder_getToken (MonoReflectionModuleBuilder *mb, MonoObject *obj, gboolean create_open_instance);
+ves_icall_ModuleBuilder_getToken (MonoReflectionModuleBuilderHandle mb, MonoObjectHandle obj, gboolean create_open_instance, MonoError *error);
gint32
-ves_icall_ModuleBuilder_getMethodToken (MonoReflectionModuleBuilder *mb,
- MonoReflectionMethod *method,
- MonoArray *opt_param_types);
+ves_icall_ModuleBuilder_getMethodToken (MonoReflectionModuleBuilderHandle mb,
+ MonoReflectionMethodHandle method,
+ MonoArrayHandle opt_param_types,
+ MonoError *error);
void
ves_icall_ModuleBuilder_WriteToFile (MonoReflectionModuleBuilder *mb, gpointer file);
ves_icall_ModuleBuilder_build_metadata (MonoReflectionModuleBuilder *mb);
void
-ves_icall_ModuleBuilder_RegisterToken (MonoReflectionModuleBuilder *mb, MonoObject *obj, guint32 token);
+ves_icall_ModuleBuilder_RegisterToken (MonoReflectionModuleBuilderHandle mb, MonoObjectHandle obj, guint32 token, MonoError *error);
MonoObject*
ves_icall_ModuleBuilder_GetRegisteredToken (MonoReflectionModuleBuilder *mb, guint32 token);
ves_icall_CustomAttributeBuilder_GetBlob (MonoReflectionAssembly *assembly, MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *propValues, MonoArray *fields, MonoArray* fieldValues);
void
-ves_icall_DynamicMethod_create_dynamic_method (MonoReflectionDynamicMethod *mb);
+ves_icall_DynamicMethod_create_dynamic_method (MonoReflectionDynamicMethodHandle mb, MonoError *error);
-MonoReflectionType*
-ves_icall_TypeBuilder_create_runtime_class (MonoReflectionTypeBuilder *tb);
+MonoReflectionTypeHandle
+ves_icall_TypeBuilder_create_runtime_class (MonoReflectionTypeBuilderHandle tb, MonoError *error);
void
ves_icall_EnumBuilder_setup_enum_type (MonoReflectionType *enumtype,
MonoReflectionType *t);
void
-ves_icall_ModuleBuilder_basic_init (MonoReflectionModuleBuilder *moduleb);
+ves_icall_ModuleBuilder_basic_init (MonoReflectionModuleBuilderHandle moduleb, MonoError *error);
guint32
-ves_icall_ModuleBuilder_getUSIndex (MonoReflectionModuleBuilder *module, MonoString *str);
+ves_icall_ModuleBuilder_getUSIndex (MonoReflectionModuleBuilderHandle module, MonoStringHandle str, MonoError *error);
void
ves_icall_ModuleBuilder_set_wrappers_type (MonoReflectionModuleBuilder *moduleb, MonoReflectionType *type);
#include <mono/metadata/assembly.h>
#include <mono/metadata/marshal.h>
#include "mono/metadata/debug-helpers.h"
-#include "mono/metadata/marshal.h"
#include <mono/metadata/threads.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/environment.h>
#include "mono/metadata/profiler-private.h"
#include "mono/metadata/security-manager.h"
#include "mono/metadata/mono-debug-debugger.h"
-#include <mono/metadata/gc-internals.h>
#include <mono/metadata/verify-internals.h>
#include <mono/metadata/reflection-internals.h>
#include <mono/metadata/w32event.h>
#include <mono/utils/mono-threads.h>
#include <mono/utils/mono-threads-coop.h>
#include "cominterop.h"
-#include <mono/io-layer/io-layer.h>
+#include <mono/utils/w32api.h>
static void
get_default_field_value (MonoDomain* domain, MonoClassField *field, void *value, MonoError *error);
static char *
mono_string_to_utf8_internal (MonoMemPool *mp, MonoImage *image, MonoString *s, gboolean ignore_error, MonoError *error);
+static void
+array_full_copy_unchecked_size (MonoArray *src, MonoArray *dest, MonoClass *klass, uintptr_t size);
+
static MonoMethod*
class_get_virtual_method (MonoClass *klass, MonoMethod *method, gboolean is_proxy, MonoError *error);
/* Class lazy loading functions */
-static GENERATE_GET_CLASS_WITH_CACHE (pointer, System.Reflection, Pointer)
-static GENERATE_GET_CLASS_WITH_CACHE (remoting_services, System.Runtime.Remoting, RemotingServices)
-static GENERATE_GET_CLASS_WITH_CACHE (unhandled_exception_event_args, System, UnhandledExceptionEventArgs)
-static GENERATE_GET_CLASS_WITH_CACHE (sta_thread_attribute, System, STAThreadAttribute)
-static GENERATE_GET_CLASS_WITH_CACHE (activation_services, System.Runtime.Remoting.Activation, ActivationServices)
+static GENERATE_GET_CLASS_WITH_CACHE (pointer, "System.Reflection", "Pointer")
+static GENERATE_GET_CLASS_WITH_CACHE (remoting_services, "System.Runtime.Remoting", "RemotingServices")
+static GENERATE_GET_CLASS_WITH_CACHE (unhandled_exception_event_args, "System", "UnhandledExceptionEventArgs")
+static GENERATE_GET_CLASS_WITH_CACHE (sta_thread_attribute, "System", "STAThreadAttribute")
+static GENERATE_GET_CLASS_WITH_CACHE (activation_services, "System.Runtime.Remoting.Activation", "ActivationServices")
#define ldstr_lock() mono_os_mutex_lock (&ldstr_section)
MonoNativeThreadId initializing_tid;
guint32 waiting_count;
gboolean done;
- MonoCoopMutex initialization_section;
+ MonoCoopMutex mutex;
+ /* condvar used to wait for 'done' becoming TRUE */
+ MonoCoopCond cond;
} TypeInitializationLock;
/* for locking access to type_initialization_hash and blocked_thread_hash */
{
MONO_REQ_GC_NEUTRAL_MODE;
- mono_coop_mutex_lock (&lock->initialization_section);
+ mono_coop_mutex_lock (&lock->mutex);
}
static void
mono_type_init_unlock (TypeInitializationLock *lock)
{
- mono_coop_mutex_unlock (&lock->initialization_section);
+ mono_coop_mutex_unlock (&lock->mutex);
}
/* from vtable to lock */
mono_error_assert_ok (&error);
}
+/*
+ * Returns TRUE if the lock was freed.
+ * LOCKING: Caller should hold type_initialization_lock.
+ */
+static gboolean
+unref_type_lock (TypeInitializationLock *lock)
+{
+ --lock->waiting_count;
+ if (lock->waiting_count == 0) {
+ mono_coop_mutex_destroy (&lock->mutex);
+ mono_coop_cond_destroy (&lock->cond);
+ g_free (lock);
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
/**
* mono_runtime_class_init_full:
* @vtable that neeeds to be initialized
tid = mono_native_thread_id_get ();
+ /*
+ * Due some preprocessing inside a global lock. If we are the first thread
+ * trying to initialize this class, create a separate lock+cond var, and
+ * acquire it before leaving the global lock. The other threads will wait
+ * on this cond var.
+ */
+
mono_type_initialization_lock ();
/* double check... */
if (vtable->initialized) {
return FALSE;
}
}
- lock = (TypeInitializationLock *)g_malloc (sizeof (TypeInitializationLock));
- mono_coop_mutex_init_recursive (&lock->initialization_section);
+ lock = (TypeInitializationLock *)g_malloc0 (sizeof (TypeInitializationLock));
+ mono_coop_mutex_init_recursive (&lock->mutex);
+ mono_coop_cond_init (&lock->cond);
lock->initializing_tid = tid;
lock->waiting_count = 1;
lock->done = FALSE;
gpointer blocked;
TypeInitializationLock *pending_lock;
- if (mono_native_thread_id_equals (lock->initializing_tid, tid) || lock->done) {
+ if (mono_native_thread_id_equals (lock->initializing_tid, tid)) {
mono_type_initialization_unlock ();
return TRUE;
}
if (do_initialization) {
MonoException *exc = NULL;
+ /* We are holding the per-vtable lock, do the actual initialization */
+
mono_threads_begin_abort_protected_block ();
mono_runtime_try_invoke (method, NULL, NULL, (MonoObject**) &exc, error);
- mono_threads_end_abort_protected_block ();
+ gboolean got_pending_interrupt = mono_threads_end_abort_protected_block ();
//exception extracted, error will be set to the right value later
if (exc == NULL && !mono_error_ok (error))//invoking failed but exc was not set
if (last_domain)
mono_domain_set (last_domain, TRUE);
+ /* Signal to the other threads that we are done */
lock->done = TRUE;
+ mono_coop_cond_broadcast (&lock->cond);
+
mono_type_init_unlock (lock);
+
+ //This can happen if the cctor self-aborts
if (exc && mono_object_class (exc) == mono_defaults.threadabortexception_class)
pending_tae = exc;
+
//TAEs are blocked around .cctors, they must escape as soon as no cctor is left to run.
- if (!pending_tae && mono_get_eh_callbacks ()->mono_above_abort_threshold ())
+ if (!pending_tae && got_pending_interrupt)
pending_tae = mono_thread_try_resume_interruption ();
} else {
/* this just blocks until the initializing thread is done */
mono_type_init_lock (lock);
+ while (!lock->done)
+ mono_coop_cond_wait (&lock->cond, &lock->mutex);
mono_type_init_unlock (lock);
}
+ /* Do cleanup and setting vtable->initialized inside the global lock again */
mono_type_initialization_lock ();
- if (!mono_native_thread_id_equals (lock->initializing_tid, tid))
+ if (!do_initialization)
g_hash_table_remove (blocked_thread_hash, GUINT_TO_POINTER (tid));
- --lock->waiting_count;
- if (lock->waiting_count == 0) {
- mono_coop_mutex_destroy (&lock->initialization_section);
+ gboolean deleted = unref_type_lock (lock);
+ if (deleted)
g_hash_table_remove (type_initialization_hash, vtable);
- g_free (lock);
- }
- mono_memory_barrier ();
- if (!vtable->init_failed)
+ /* Have to set this here since we check it inside the global lock */
+ if (do_initialization && !vtable->init_failed)
vtable->initialized = 1;
mono_type_initialization_unlock ();
* and get_type_init_exception_for_class () needs to be aware of this.
*/
vtable->init_failed = 1;
+ mono_coop_cond_broadcast (&lock->cond);
mono_type_init_unlock (lock);
- --lock->waiting_count;
- if (lock->waiting_count == 0) {
- mono_coop_mutex_destroy (&lock->initialization_section);
- g_free (lock);
+ gboolean deleted = unref_type_lock (lock);
+ if (deleted)
return TRUE;
- }
}
return FALSE;
}
size = mono_array_length (src);
g_assert (size == mono_array_length (dest));
size *= mono_array_element_size (klass);
+
+ array_full_copy_unchecked_size (src, dest, klass, size);
+}
+
+static void
+array_full_copy_unchecked_size (MonoArray *src, MonoArray *dest, MonoClass *klass, uintptr_t size)
+{
#ifdef HAVE_SGEN_GC
if (klass->element_class->valuetype) {
if (klass->element_class->has_references)
* This routine returns a copy of the array that is hosted on the
* specified MonoDomain. On failure returns NULL and sets @error.
*/
-MonoArray*
-mono_array_clone_in_domain (MonoDomain *domain, MonoArray *array, MonoError *error)
+MonoArrayHandle
+mono_array_clone_in_domain (MonoDomain *domain, MonoArrayHandle array_handle, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;
- MonoArray *o;
- uintptr_t size, i;
- uintptr_t *sizes;
- MonoClass *klass = array->obj.vtable->klass;
+ MonoArrayHandle result = MONO_HANDLE_NEW (MonoArray, NULL);
+ uintptr_t size = 0;
+ MonoClass *klass = mono_handle_class (array_handle);
mono_error_init (error);
- if (array->bounds == NULL) {
- size = mono_array_length (array);
- o = mono_array_new_full_checked (domain, klass, &size, NULL, error);
- return_val_if_nok (error, NULL);
-
- size *= mono_array_element_size (klass);
-#ifdef HAVE_SGEN_GC
- if (klass->element_class->valuetype) {
- if (klass->element_class->has_references)
- mono_value_copy_array (o, 0, mono_array_addr_with_size_fast (array, 0, 0), mono_array_length (array));
- else
- mono_gc_memmove_atomic (&o->vector, &array->vector, size);
- } else {
- mono_array_memcpy_refs (o, 0, array, 0, mono_array_length (array));
- }
-#else
- mono_gc_memmove_atomic (&o->vector, &array->vector, size);
-#endif
- return o;
- }
+ /* Pin source array here - if bounds is non-NULL, it's a pointer into the object data */
+ uint32_t src_handle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, array_handle), TRUE);
- sizes = (uintptr_t *)alloca (klass->rank * sizeof(intptr_t) * 2);
- size = mono_array_element_size (klass);
- for (i = 0; i < klass->rank; ++i) {
- sizes [i] = array->bounds [i].length;
- size *= array->bounds [i].length;
- sizes [i + klass->rank] = array->bounds [i].lower_bound;
- }
- o = mono_array_new_full_checked (domain, klass, sizes, (intptr_t*)sizes + klass->rank, error);
- return_val_if_nok (error, NULL);
-#ifdef HAVE_SGEN_GC
- if (klass->element_class->valuetype) {
- if (klass->element_class->has_references)
- mono_value_copy_array (o, 0, mono_array_addr_with_size_fast (array, 0, 0), mono_array_length (array));
- else
- mono_gc_memmove_atomic (&o->vector, &array->vector, size);
+ MonoArrayBounds *array_bounds = MONO_HANDLE_GETVAL (array_handle, bounds);
+ MonoArrayHandle o;
+ if (array_bounds == NULL) {
+ size = mono_array_handle_length (array_handle);
+ o = mono_array_new_full_handle (domain, klass, &size, NULL, error);
+ if (!is_ok (error))
+ goto leave;
+ size *= mono_array_element_size (klass);
} else {
- mono_array_memcpy_refs (o, 0, array, 0, mono_array_length (array));
+ uintptr_t *sizes = (uintptr_t *)alloca (klass->rank * sizeof (uintptr_t));
+ intptr_t *lower_bounds = (intptr_t *)alloca (klass->rank * sizeof (intptr_t));
+ size = mono_array_element_size (klass);
+ for (int i = 0; i < klass->rank; ++i) {
+ sizes [i] = array_bounds [i].length;
+ size *= array_bounds [i].length;
+ lower_bounds [i] = array_bounds [i].lower_bound;
+ }
+ o = mono_array_new_full_handle (domain, klass, sizes, lower_bounds, error);
+ if (!is_ok (error))
+ goto leave;
}
-#else
- mono_gc_memmove_atomic (&o->vector, &array->vector, size);
-#endif
- return o;
+ uint32_t dst_handle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, o), TRUE);
+ array_full_copy_unchecked_size (MONO_HANDLE_RAW (array_handle), MONO_HANDLE_RAW (o), klass, size);
+ mono_gchandle_free (dst_handle);
+
+ MONO_HANDLE_ASSIGN (result, o);
+
+leave:
+ mono_gchandle_free (src_handle);
+ return result;
}
/**
* failure returns NULL and sets @error.
*/
MonoArray*
-mono_array_clone_checked (MonoArray *array, MonoError *error)
+mono_array_clone_checked (MonoArray *array_raw, MonoError *error)
{
-
MONO_REQ_GC_UNSAFE_MODE;
- return mono_array_clone_in_domain (((MonoObject *)array)->vtable->domain, array, error);
+ HANDLE_FUNCTION_ENTER ();
+ /* FIXME: callers of mono_array_clone_checked should use handles */
+ mono_error_init (error);
+ MONO_HANDLE_DCL (MonoArray, array);
+ MonoArrayHandle result = mono_array_clone_in_domain (MONO_HANDLE_DOMAIN (array), array, error);
+ HANDLE_FUNCTION_RETURN_OBJ (result);
}
/* helper macros to check for overflow when calculating the size of arrays */
return s;
}
+/**
+ * mono_string_new_utf16_handle:
+ * @text: a pointer to an utf16 string
+ * @len: the length of the string
+ * @error: written on error.
+ *
+ * Returns: A newly created string object which contains @text.
+ * On error, returns NULL and sets @error.
+ */
+MonoStringHandle
+mono_string_new_utf16_handle (MonoDomain *domain, const guint16 *text, gint32 len, MonoError *error)
+{
+ return MONO_HANDLE_NEW (MonoString, mono_string_new_utf16_checked (domain, text, len, error));
+}
+
/**
* mono_string_new_utf32:
* @text: a pointer to an utf32 string
* Same as mono_string_to_utf8, but allocate the string from the image mempool.
*/
char *
-mono_string_to_utf8_image (MonoImage *image, MonoString *s, MonoError *error)
+mono_string_to_utf8_image (MonoImage *image, MonoStringHandle s, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;
- return mono_string_to_utf8_internal (NULL, image, s, FALSE, error);
+ return mono_string_to_utf8_internal (NULL, image, MONO_HANDLE_RAW (s), FALSE, error); /* FIXME pin the string */
}
/**
return s->length;
}
+/**
+ * mono_string_handle_length:
+ * @s: MonoString
+ *
+ * Returns the lenght in characters of the string
+ */
+int
+mono_string_handle_length (MonoStringHandle s)
+{
+ MONO_REQ_GC_UNSAFE_MODE;
+
+ return MONO_HANDLE_GETVAL (s, length);
+}
+
+
/**
* mono_array_length:
* @array: a MonoArray*
typedef void (*MonoMainThreadFunc) (void* user_data);
#define MONO_OBJECT_SETREF(obj,fieldname,value) do { \
- g_assert (sizeof((obj)->fieldname) == sizeof (gpointer*)); \
mono_gc_wbarrier_set_field ((MonoObject*)(obj), &((obj)->fieldname), (MonoObject*)value); \
/*(obj)->fieldname = (value);*/ \
} while (0)
#include "mono/metadata/domain-internals.h"
#include "mono/metadata/gc-internals.h"
#include "mono/metadata/mono-config-dirs.h"
-#include "mono/io-layer/io-layer.h"
#include "mono/utils/mono-dl.h"
#include <mono/utils/mono-logger-internals.h>
#include <string.h>
}
#define CACHE_OBJECT(t,p,o,k) ((t) (cache_object (domain, (k), (p), (o))))
+#define CACHE_OBJECT_HANDLE(t,p,o,k) ((t) (cache_object_handle (domain, (k), (p), (o))))
static inline MonoObjectHandle
check_object_handle (MonoDomain* domain, MonoClass *klass, gpointer item)
#include <mono/utils/mono-error.h>
gboolean
-mono_reflection_is_usertype (MonoReflectionType *ref);
+mono_reflection_is_usertype (MonoReflectionTypeHandle ref);
MonoReflectionType*
mono_reflection_type_resolve_user_types (MonoReflectionType *type, MonoError *error);
+MonoType *
+mono_reflection_type_handle_mono_type (MonoReflectionTypeHandle ref_type, MonoError *error);
+
MonoType*
mono_reflection_get_type_checked (MonoImage *rootimage, MonoImage* image, MonoTypeNameParse *info, mono_bool ignorecase, mono_bool *type_resolve, MonoError *error);
static MonoType* mono_reflection_get_type_with_rootimage (MonoImage *rootimage, MonoImage* image, MonoTypeNameParse *info, gboolean ignorecase, gboolean *type_resolve, MonoError *error);
/* Class lazy loading functions */
-static GENERATE_GET_CLASS_WITH_CACHE (mono_assembly, System.Reflection, MonoAssembly)
-static GENERATE_GET_CLASS_WITH_CACHE (mono_module, System.Reflection, MonoModule)
-static GENERATE_GET_CLASS_WITH_CACHE (mono_method, System.Reflection, MonoMethod);
-static GENERATE_GET_CLASS_WITH_CACHE (mono_cmethod, System.Reflection, MonoCMethod);
-static GENERATE_GET_CLASS_WITH_CACHE (mono_field, System.Reflection, MonoField);
-static GENERATE_GET_CLASS_WITH_CACHE (mono_event, System.Reflection, MonoEvent);
-static GENERATE_GET_CLASS_WITH_CACHE (mono_property, System.Reflection, MonoProperty);
-static GENERATE_GET_CLASS_WITH_CACHE (mono_parameter_info, System.Reflection, MonoParameterInfo);
-static GENERATE_GET_CLASS_WITH_CACHE (missing, System.Reflection, Missing);
-static GENERATE_GET_CLASS_WITH_CACHE (method_body, System.Reflection, MethodBody);
-static GENERATE_GET_CLASS_WITH_CACHE (local_variable_info, System.Reflection, LocalVariableInfo);
-static GENERATE_GET_CLASS_WITH_CACHE (exception_handling_clause, System.Reflection, ExceptionHandlingClause);
-static GENERATE_GET_CLASS_WITH_CACHE (type_builder, System.Reflection.Emit, TypeBuilder);
-static GENERATE_GET_CLASS_WITH_CACHE (dbnull, System, DBNull);
+static GENERATE_GET_CLASS_WITH_CACHE (mono_assembly, "System.Reflection", "MonoAssembly")
+static GENERATE_GET_CLASS_WITH_CACHE (mono_module, "System.Reflection", "MonoModule")
+static GENERATE_GET_CLASS_WITH_CACHE (mono_method, "System.Reflection", "MonoMethod");
+static GENERATE_GET_CLASS_WITH_CACHE (mono_cmethod, "System.Reflection", "MonoCMethod");
+static GENERATE_GET_CLASS_WITH_CACHE (mono_field, "System.Reflection", "MonoField");
+static GENERATE_GET_CLASS_WITH_CACHE (mono_event, "System.Reflection", "MonoEvent");
+static GENERATE_GET_CLASS_WITH_CACHE (mono_property, "System.Reflection", "MonoProperty");
+static GENERATE_GET_CLASS_WITH_CACHE (mono_parameter_info, "System.Reflection", "MonoParameterInfo");
+static GENERATE_GET_CLASS_WITH_CACHE (missing, "System.Reflection", "Missing");
+static GENERATE_GET_CLASS_WITH_CACHE (method_body, "System.Reflection", "MethodBody");
+static GENERATE_GET_CLASS_WITH_CACHE (local_variable_info, "System.Reflection", "LocalVariableInfo");
+static GENERATE_GET_CLASS_WITH_CACHE (exception_handling_clause, "System.Reflection", "ExceptionHandlingClause");
+static GENERATE_GET_CLASS_WITH_CACHE (type_builder, "System.Reflection.Emit", "TypeBuilder");
+static GENERATE_GET_CLASS_WITH_CACHE (dbnull, "System", "DBNull");
static int class_ref_info_handle_count;
*
* Return the type builder/generic param builder corresponding to KLASS, if it exists.
*/
-gpointer
+MonoObjectHandle
mono_class_get_ref_info (MonoClass *klass)
{
MONO_REQ_GC_UNSAFE_MODE;
guint32 ref_info_handle = mono_class_get_ref_info_handle (klass);
+ if (ref_info_handle == 0)
+ return MONO_HANDLE_NEW (MonoObject, NULL);
+ else
+ return mono_gchandle_get_target_handle (ref_info_handle);
+}
+
+gboolean
+mono_class_has_ref_info (MonoClass *klass)
+{
+ MONO_REQ_GC_UNSAFE_MODE;
+ return 0 != mono_class_get_ref_info_handle (klass);
+}
+
+MonoObject*
+mono_class_get_ref_info_raw (MonoClass *klass)
+{
+ /* FIXME callers of mono_class_get_ref_info_raw should use handles */
+ MONO_REQ_GC_UNSAFE_MODE;
+ guint32 ref_info_handle = mono_class_get_ref_info_handle (klass);
+
if (ref_info_handle == 0)
return NULL;
else
}
void
-mono_class_set_ref_info (MonoClass *klass, gpointer obj)
+mono_class_set_ref_info (MonoClass *klass, MonoObjectHandle obj)
{
MONO_REQ_GC_UNSAFE_MODE;
- guint32 candidate = mono_gchandle_new ((MonoObject*)obj, FALSE);
+ guint32 candidate = mono_gchandle_from_handle (obj, FALSE);
guint32 handle = mono_class_set_ref_info_handle (klass, candidate);
++class_ref_info_handle_count;
return NULL;
}
- if (mono_class_get_ref_info (klass) && !klass->wastypebuilder && !type->byref) {
+ if (mono_class_has_ref_info (klass) && !klass->wastypebuilder && !type->byref) {
mono_domain_unlock (domain);
mono_loader_unlock ();
- return (MonoReflectionType *)mono_class_get_ref_info (klass);
+ return (MonoReflectionType *)mono_class_get_ref_info_raw (klass); /* FIXME use handles */
}
/* This is stored in vtables/JITted code so it has to be pinned */
res = (MonoReflectionType *)mono_object_new_pinned (domain, mono_defaults.runtimetype_class, error);
if (info->type_arguments) {
MonoType **type_args = g_new0 (MonoType *, info->type_arguments->len);
- MonoReflectionType *the_type;
+ MonoReflectionTypeHandle the_type;
MonoType *instance;
int i;
}
}
- the_type = mono_type_get_object_checked (mono_domain_get (), &klass->byval_arg, error);
- if (!the_type)
+ the_type = mono_type_get_object_handle (mono_domain_get (), &klass->byval_arg, error);
+ if (!is_ok (error) || MONO_HANDLE_IS_NULL (the_type))
return NULL;
instance = mono_reflection_bind_generic_parameters (
gboolean
-mono_reflection_is_usertype (MonoReflectionType *ref)
+mono_reflection_is_usertype (MonoReflectionTypeHandle ref)
{
- MonoClass *klass = mono_object_class (ref);
+ MonoClass *klass = mono_handle_class (ref);
return klass->image != mono_defaults.corlib || strcmp ("TypeDelegator", klass->name) == 0;
}
* Returns the MonoType* for the resulting type instantiation. On failure returns NULL and sets @error.
*/
MonoType*
-mono_reflection_bind_generic_parameters (MonoReflectionType *type, int type_argc, MonoType **types, MonoError *error)
+mono_reflection_bind_generic_parameters (MonoReflectionTypeHandle reftype, int type_argc, MonoType **types, MonoError *error)
{
- MonoClass *klass;
gboolean is_dynamic = FALSE;
MonoClass *geninst;
mono_loader_lock ();
- if (mono_is_sre_type_builder (mono_object_class (type))) {
+ MonoClass *klass = mono_handle_class (reftype);
+ if (mono_is_sre_type_builder (klass)) {
is_dynamic = TRUE;
- } else if (mono_is_sre_generic_instance (mono_object_class (type))) {
+ } else if (mono_is_sre_generic_instance (klass)) {
/* Does this ever make sense? what does instantiating a generic instance even mean? */
g_assert_not_reached ();
- MonoReflectionGenericClass *rgi = (MonoReflectionGenericClass *) type;
- MonoReflectionType *gtd = rgi->generic_type;
+ MonoReflectionGenericClassHandle rgi = MONO_HANDLE_CAST (MonoReflectionGenericClass, reftype);
+ MonoReflectionTypeHandle gtd = MONO_HANDLE_NEW_GET (MonoReflectionType, rgi, generic_type);
- if (mono_is_sre_type_builder (mono_object_class (gtd)))
+ if (mono_is_sre_type_builder (mono_handle_class (gtd)))
is_dynamic = TRUE;
}
- MonoType *t = mono_reflection_type_get_handle (type, error);
+ MonoType *t = mono_reflection_type_handle_mono_type (reftype, error);
if (!is_ok (error)) {
mono_loader_unlock ();
return NULL;
return mono_generic_class_get_class (gclass);
}
-static MonoReflectionMethod*
-reflection_bind_generic_method_parameters (MonoReflectionMethod *rmethod, MonoArray *types, MonoError *error)
+static MonoGenericInst*
+generic_inst_from_type_array_handle (MonoArrayHandle types, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER ();
+ mono_error_init (error);
+ MonoGenericInst *ginst = NULL;
+ int count = mono_array_handle_length (types);
+ MonoType **type_argv = g_new0 (MonoType *, count);
+ MonoReflectionTypeHandle garg = MONO_HANDLE_NEW (MonoReflectionType, NULL);
+ for (int i = 0; i < count; i++) {
+ MONO_HANDLE_ARRAY_GETREF (garg, types, i);
+ type_argv [i] = mono_reflection_type_handle_mono_type (garg, error);
+ if (!is_ok (error))
+ goto leave;
+
+ }
+ ginst = mono_metadata_get_generic_inst (count, type_argv);
+leave:
+ g_free (type_argv);
+ HANDLE_FUNCTION_RETURN_VAL (ginst);
+}
+
+static MonoMethod*
+reflection_bind_generic_method_parameters (MonoMethod *method, MonoArrayHandle types, MonoError *error)
{
MonoClass *klass;
- MonoMethod *method, *inflated;
- MonoMethodInflated *imethod;
+ MonoMethod *inflated;
MonoGenericContext tmp_context;
- MonoGenericInst *ginst;
- MonoType **type_argv;
- int count, i;
mono_error_init (error);
- g_assert (strcmp (rmethod->object.vtable->klass->name, "MethodBuilder"));
-
- method = rmethod->method;
-
klass = method->klass;
if (method->is_inflated)
method = ((MonoMethodInflated *) method)->declaring;
- count = mono_method_signature (method)->generic_param_count;
- if (count != mono_array_length (types))
+ int count = mono_method_signature (method)->generic_param_count;
+ if (count != mono_array_handle_length (types)) {
+ mono_error_set_argument (error, "typeArguments", "Incorrect number of generic arguments");
return NULL;
-
- type_argv = g_new0 (MonoType *, count);
- for (i = 0; i < count; i++) {
- MonoReflectionType *garg = (MonoReflectionType *)mono_array_get (types, gpointer, i);
- type_argv [i] = mono_reflection_type_get_handle (garg, error);
- if (!is_ok (error)) {
- g_free (type_argv);
- return NULL;
- }
}
- ginst = mono_metadata_get_generic_inst (count, type_argv);
- g_free (type_argv);
+
+ MonoGenericInst *ginst = generic_inst_from_type_array_handle (types, error);
+ return_val_if_nok (error, NULL);
tmp_context.class_inst = mono_class_is_ginst (klass) ? mono_class_get_generic_class (klass)->context.class_inst : NULL;
tmp_context.method_inst = ginst;
inflated = mono_class_inflate_generic_method_checked (method, &tmp_context, error);
mono_error_assert_ok (error);
- imethod = (MonoMethodInflated *) inflated;
+
+ if (!mono_verifier_is_method_valid_generic_instantiation (inflated)) {
+ mono_error_set_argument (error, "typeArguments", "Invalid generic arguments");
+ return NULL;
+ }
+
+ return inflated;
+}
+
+MonoReflectionMethodHandle
+ves_icall_MonoMethod_MakeGenericMethod_impl (MonoReflectionMethodHandle rmethod, MonoArrayHandle types, MonoError *error)
+{
+ mono_error_init (error);
+ g_assert (0 != strcmp (mono_handle_class (rmethod)->name, "MethodBuilder"));
+
+ MonoMethod *method = MONO_HANDLE_GETVAL (rmethod, method);
+ MonoMethod *imethod = reflection_bind_generic_method_parameters (method, types, error);
+ return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE));
/*FIXME but I think this is no longer necessary*/
if (image_is_dynamic (method->klass->image)) {
* to the reflection objects representing their generic definitions.
*/
mono_image_lock ((MonoImage*)image);
- mono_g_hash_table_insert (image->generic_def_objects, imethod, rmethod);
+ mono_g_hash_table_insert (image->generic_def_objects, imethod, MONO_HANDLE_RAW (rmethod));
mono_image_unlock ((MonoImage*)image);
}
- if (!mono_verifier_is_method_valid_generic_instantiation (inflated)) {
- mono_error_set_argument (error, "typeArguments", "Invalid generic arguments");
- return NULL;
- }
-
- return mono_method_get_object_checked (mono_object_domain (rmethod), inflated, NULL, error);
-}
-
-MonoReflectionMethod*
-ves_icall_MonoMethod_MakeGenericMethod_impl (MonoReflectionMethod *rmethod, MonoArray *types)
-{
- MonoError error;
- MonoReflectionMethod *result = reflection_bind_generic_method_parameters (rmethod, types, &error);
- mono_error_set_pending_exception (&error);
- return result;
+ return mono_method_get_object_handle (MONO_HANDLE_DOMAIN (rmethod), imethod, NULL, error);
}
* The result of mono_type_get_object_checked () might be a System.MonoType but we
* need a TypeBuilder so use mono_class_get_ref_info (klass).
*/
- g_assert (mono_class_get_ref_info (klass));
- g_assert (!strcmp (((MonoObject*)(mono_class_get_ref_info (klass)))->vtable->klass->name, "TypeBuilder"));
+ g_assert (mono_class_has_ref_info (klass));
+ g_assert (!strcmp (mono_object_class (mono_class_get_ref_info_raw (klass))->name, "TypeBuilder")); /* FIXME use handles */
params [0] = mono_type_get_object_checked (mono_domain_get (), &oklass->byval_arg, error);
return_val_if_nok (error, FALSE);
MonoError inner_error;
- res = mono_runtime_try_invoke (method, (MonoObject*)(mono_class_get_ref_info (klass)), params, &exc, &inner_error);
+ res = mono_runtime_try_invoke (method, mono_class_get_ref_info_raw (klass), params, &exc, &inner_error); /* FIXME use handles */
if (exc || !is_ok (&inner_error)) {
mono_error_cleanup (&inner_error);
#include "config.h"
+#include "mono/metadata/handle.h"
#include "mono/metadata/remoting.h"
#include "mono/metadata/marshal.h"
+#include "mono/metadata/marshal-internals.h"
#include "mono/metadata/abi-details.h"
#include "mono/metadata/cominterop.h"
#include "mono/metadata/tabledefs.h"
type_from_handle (MonoType *handle);
/* Class lazy loading functions */
-static GENERATE_GET_CLASS_WITH_CACHE (remoting_services, System.Runtime.Remoting, RemotingServices)
-static GENERATE_GET_CLASS_WITH_CACHE (call_context, System.Runtime.Remoting.Messaging, CallContext)
-static GENERATE_GET_CLASS_WITH_CACHE (context, System.Runtime.Remoting.Contexts, Context)
+static GENERATE_GET_CLASS_WITH_CACHE (remoting_services, "System.Runtime.Remoting", "RemotingServices")
+static GENERATE_GET_CLASS_WITH_CACHE (call_context, "System.Runtime.Remoting.Messaging", "CallContext")
+static GENERATE_GET_CLASS_WITH_CACHE (context, "System.Runtime.Remoting.Contexts", "Context")
static mono_mutex_t remoting_mutex;
static gboolean remoting_mutex_inited;
return MONO_MARSHAL_SERIALIZE;
}
-/* mono_marshal_xdomain_copy_value
- * Makes a copy of "val" suitable for the current domain.
+/* Replace the given array element by a copy in the current domain */
+static gboolean
+xdomain_copy_array_element_inplace (MonoArrayHandle arr, int i, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER ();
+ mono_error_init (error);
+ MonoObjectHandle item = MONO_HANDLE_NEW (MonoObject, NULL);
+ MONO_HANDLE_ARRAY_GETREF (item, arr, i);
+
+ MonoObjectHandle item_copy = mono_marshal_xdomain_copy_value_handle (item, error);
+ if (!is_ok (error))
+ goto leave;
+ MONO_HANDLE_ARRAY_SETREF (arr, i, item_copy);
+leave:
+ HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
+}
+
+/**
+ * mono_marshal_xdomain_copy_value_handle:
+ * @val: The value to copy.
+ * @error: set on failure.
+ *
+ * Makes a copy of @val suitable for the current domain.
+ * On failure returns NULL and sets @error.
*/
-MonoObject *
-mono_marshal_xdomain_copy_value (MonoObject *val, MonoError *error)
+MonoObjectHandle
+mono_marshal_xdomain_copy_value_handle (MonoObjectHandle val, MonoError *error)
{
mono_error_init (error);
- MonoDomain *domain;
- if (val == NULL) return NULL;
+ MonoObjectHandle result = MONO_HANDLE_NEW (MonoObject, NULL);
+ if (MONO_HANDLE_IS_NULL (val))
+ goto leave;
- domain = mono_domain_get ();
+ MonoDomain *domain = mono_domain_get ();
- switch (mono_object_class (val)->byval_arg.type) {
+ MonoClass *klass = mono_handle_class (val);
+
+ switch (klass->byval_arg.type) {
case MONO_TYPE_VOID:
g_assert_not_reached ();
break;
case MONO_TYPE_U8:
case MONO_TYPE_R4:
case MONO_TYPE_R8: {
- MonoObject *res = mono_value_box_checked (domain, mono_object_class (val), ((char*)val) + sizeof(MonoObject), error);
- return res;
-
+ uint32_t gchandle = mono_gchandle_from_handle (val, TRUE);
+ MonoObjectHandle res = MONO_HANDLE_NEW (MonoObject, mono_value_box_checked (domain, klass, ((char*)val) + sizeof(MonoObject), error)); /* FIXME use handles in mono_value_box_checked */
+ mono_gchandle_free (gchandle);
+ if (!is_ok (error))
+ goto leave;
+ MONO_HANDLE_ASSIGN (result, res);
+ break;
}
case MONO_TYPE_STRING: {
- MonoString *str = (MonoString *) val;
- MonoObject *res = NULL;
- res = (MonoObject *) mono_string_new_utf16_checked (domain, mono_string_chars (str), mono_string_length (str), error);
- return res;
+ MonoStringHandle str = MONO_HANDLE_CAST (MonoString, val);
+ uint32_t gchandle = mono_gchandle_from_handle (val, TRUE);
+ MonoStringHandle res = mono_string_new_utf16_handle (domain, mono_string_chars (MONO_HANDLE_RAW (str)), mono_string_handle_length (str), error);
+ mono_gchandle_free (gchandle);
+ if (!is_ok (error))
+ goto leave;
+ MONO_HANDLE_ASSIGN (result, res);
+ break;
}
case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY: {
- MonoArray *acopy;
- MonoXDomainMarshalType mt = mono_get_xdomain_marshal_type (&(mono_object_class (val)->element_class->byval_arg));
- if (mt == MONO_MARSHAL_SERIALIZE) return NULL;
- acopy = mono_array_clone_in_domain (domain, (MonoArray *) val, error);
- return_val_if_nok (error, NULL);
+ MonoArrayHandle arr = MONO_HANDLE_CAST (MonoArray, val);
+ MonoXDomainMarshalType mt = mono_get_xdomain_marshal_type (&klass->element_class->byval_arg);
+ if (mt == MONO_MARSHAL_SERIALIZE)
+ goto leave;
+ MonoArrayHandle acopy = mono_array_clone_in_domain (domain, arr, error);
+ if (!is_ok (error))
+ goto leave;
if (mt == MONO_MARSHAL_COPY) {
- int i, len = mono_array_length (acopy);
+ int i, len = mono_array_handle_length (acopy);
for (i = 0; i < len; i++) {
- MonoObject *item = (MonoObject *)mono_array_get (acopy, gpointer, i);
- MonoObject *item_copy = mono_marshal_xdomain_copy_value (item, error);
- return_val_if_nok (error, NULL);
- mono_array_setref (acopy, i, item_copy);
+ if (!xdomain_copy_array_element_inplace (acopy, i, error))
+ goto leave;
}
}
- return (MonoObject *) acopy;
+ MONO_HANDLE_ASSIGN (result, acopy);
+ break;
}
default:
break;
}
- return NULL;
+leave:
+ return result;
+}
+
+/* mono_marshal_xdomain_copy_value
+ * Makes a copy of "val" suitable for the current domain.
+ */
+MonoObject*
+mono_marshal_xdomain_copy_value (MonoObject* val_raw, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER ();
+ /* FIXME callers of mono_marshal_xdomain_copy_value should use handles */
+ MONO_HANDLE_DCL (MonoObject, val);
+ MonoObjectHandle result = mono_marshal_xdomain_copy_value_handle (val, error);
+ HANDLE_FUNCTION_RETURN_OBJ (result);
}
/* mono_marshal_xdomain_copy_value
MONO_LOCALVARIABLE_SIZE
};
+enum {
+ MONO_CUSTOMDEBUGINFORMATION_PARENT,
+ MONO_CUSTOMDEBUGINFORMATION_KIND,
+ MONO_CUSTOMDEBUGINFORMATION_VALUE,
+ MONO_CUSTOMDEBUGINFORMATION_SIZE
+};
+
/*
* Coded Tokens
* The _BITS entry is for the bits used in the token.
#ifndef DISABLE_SECURITY
/* Class lazy loading functions */
-static GENERATE_GET_CLASS_WITH_CACHE (security_critical, System.Security, SecurityCriticalAttribute)
-static GENERATE_GET_CLASS_WITH_CACHE (security_safe_critical, System.Security, SecuritySafeCriticalAttribute)
+static GENERATE_GET_CLASS_WITH_CACHE (security_critical, "System.Security", "SecurityCriticalAttribute")
+static GENERATE_GET_CLASS_WITH_CACHE (security_safe_critical, "System.Security", "SecuritySafeCriticalAttribute")
static MonoClass*
security_critical_attribute (void)
#include "security-manager.h"
/* Class lazy loading functions */
-static GENERATE_GET_CLASS_WITH_CACHE (security_manager, System.Security, SecurityManager)
-static GENERATE_TRY_GET_CLASS_WITH_CACHE (execution_context, System.Threading, ExecutionContext)
+static GENERATE_GET_CLASS_WITH_CACHE (security_manager, "System.Security", "SecurityManager")
+static GENERATE_TRY_GET_CLASS_WITH_CACHE (execution_context, "System.Threading", "ExecutionContext")
static MonoSecurityMode mono_security_mode = MONO_SECURITY_MODE_NONE;
#define SGEN_CLIENT_OBJECT_HEADER_SIZE (sizeof (GCObject))
#define SGEN_CLIENT_MINIMUM_OBJECT_SIZE SGEN_CLIENT_OBJECT_HEADER_SIZE
-static mword /*__attribute__((noinline)) not sure if this hint is a good idea*/
+static mword /*__attribute__ ((__noinline__)) not sure if this hint is a good idea*/
sgen_client_slow_object_get_size (GCVTable vtable, GCObject* o)
{
MonoClass *klass = ((MonoVTable*)vtable)->klass;
#include "utils/mono-memory-model.h"
#include "utils/mono-logger-internals.h"
#include "utils/mono-threads-coop.h"
-#include "sgen/sgen-thread-pool.h"
#include "utils/mono-threads.h"
#include "metadata/w32handle.h"
#define ARRAY_OBJ_INDEX(ptr,array,elem_size) (((char*)(ptr) - ((char*)(array) + G_STRUCT_OFFSET (MonoArray, vector))) / (elem_size))
gboolean
-sgen_client_cardtable_scan_object (GCObject *obj, mword block_obj_size, guint8 *cards, ScanCopyContext ctx)
+sgen_client_cardtable_scan_object (GCObject *obj, guint8 *cards, ScanCopyContext ctx)
{
MonoVTable *vt = SGEN_LOAD_VTABLE (obj);
MonoClass *klass = vt->klass;
int
mono_gc_pthread_create (pthread_t *new_thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
{
- return pthread_create (new_thread, attr, start_routine, arg);
+ int res;
+
+ mono_threads_join_lock ();
+ res = pthread_create (new_thread, attr, start_routine, arg);
+ mono_threads_join_unlock ();
+
+ return res;
}
#endif
/* Once we remove the old suspend code, we should move sgen to directly access the state in MonoThread */
info->client_info.stack_start = (gpointer) ((char*)MONO_CONTEXT_GET_SP (&info->client_info.ctx) - REDZONE_SIZE);
- /* altstack signal handler, sgen can't handle them, mono-threads should have handled this. */
- if (!info->client_info.stack_start
- || info->client_info.stack_start < info->client_info.stack_start_limit
+ if (info->client_info.stack_start < info->client_info.stack_start_limit
|| info->client_info.stack_start >= info->client_info.stack_end) {
- g_error ("BAD STACK: stack_start = %p, stack_start_limit = %p, stack_end = %p",
- info->client_info.stack_start, info->client_info.stack_start_limit, info->client_info.stack_end);
+ /*
+ * Thread context is in unhandled state, most likely because it is
+ * dying. We don't scan it.
+ * FIXME We should probably rework and check the valid flag instead.
+ */
+ info->client_info.stack_start = NULL;
}
stopped_ip = (gpointer) (MONO_CONTEXT_GET_IP (&info->client_info.ctx));
+++ /dev/null
-/*
-* socket-io-windows-internals.h: Windows specific socket code.
-*
-* Copyright 2016 Microsoft
-* Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#ifndef __MONO_METADATA_SOCKET_IO_WINDOWS_INTERNALS_H__
-#define __MONO_METADATA_SOCKET_IO_WINDOWS_INTERNALS_H__
-
-#include <config.h>
-#include <glib.h>
-#include <mono/io-layer/io-layer.h>
-
-SOCKET alertable_accept (SOCKET s, struct sockaddr *addr, int *addrlen, gboolean blocking);
-int alertable_connect (SOCKET s, const struct sockaddr *name, int namelen, gboolean blocking);
-int alertable_recv (SOCKET s, char *buf, int len, int flags, gboolean blocking);
-int alertable_recvfrom (SOCKET s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen, gboolean blocking);
-int alertable_WSARecv (SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, gboolean blocking);
-int alertable_send (SOCKET s, char *buf, int len, int flags, gboolean blocking);
-int alertable_sendto (SOCKET s, const char *buf, int len, int flags, const struct sockaddr *to, int tolen, gboolean blocking);
-int alertable_WSASend (SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd, DWORD lpFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, gboolean blocking);
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
-BOOL alertable_TransmitFile (SOCKET hSocket, HANDLE hFile, DWORD nNumberOfBytesToWrite, DWORD nNumberOfBytesPerSend, LPOVERLAPPED lpOverlapped, LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, DWORD dwReserved, gboolean blocking);
-#endif
-
-#endif // __MONO_METADATA_SOCKET_IO_WINDOWS_INTERNALS_H__
+++ /dev/null
-/*
-* socket-io-windows.c: Windows specific socket code.
-*
-* Copyright 2016 Microsoft
-* Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-
-#include "mono/metadata/socket-io-windows-internals.h"
-
-#define LOGDEBUG(...)
-
-static gboolean set_blocking (SOCKET sock, gboolean block)
-{
- u_long non_block = block ? 0 : 1;
- return ioctlsocket (sock, FIONBIO, &non_block) != SOCKET_ERROR;
-}
-
-static DWORD get_socket_timeout (SOCKET sock, int optname)
-{
- DWORD timeout = 0;
- int optlen = sizeof (DWORD);
- if (getsockopt (sock, SOL_SOCKET, optname, (char *)&timeout, &optlen) == SOCKET_ERROR) {
- WSASetLastError (0);
- return WSA_INFINITE;
- }
- if (timeout == 0)
- timeout = WSA_INFINITE; // 0 means infinite
- return timeout;
-}
-
-/*
-* Performs an alertable wait for the specified event (FD_ACCEPT_BIT,
-* FD_CONNECT_BIT, FD_READ_BIT, FD_WRITE_BIT) on the specified socket.
-* Returns TRUE if the event is fired without errors. Calls WSASetLastError()
-* with WSAEINTR and returns FALSE if the thread is alerted. If the event is
-* fired but with an error WSASetLastError() is called to set the error and the
-* function returns FALSE.
-*/
-static gboolean alertable_socket_wait (SOCKET sock, int event_bit)
-{
- static char *EVENT_NAMES[] = { "FD_READ", "FD_WRITE", NULL /*FD_OOB*/, "FD_ACCEPT", "FD_CONNECT", "FD_CLOSE" };
- gboolean success = FALSE;
- int error = -1;
- DWORD timeout = WSA_INFINITE;
- if (event_bit == FD_READ_BIT || event_bit == FD_WRITE_BIT) {
- timeout = get_socket_timeout (sock, event_bit == FD_READ_BIT ? SO_RCVTIMEO : SO_SNDTIMEO);
- }
- WSASetLastError (0);
- WSAEVENT event = WSACreateEvent ();
- if (event != WSA_INVALID_EVENT) {
- if (WSAEventSelect (sock, event, (1 << event_bit) | FD_CLOSE) != SOCKET_ERROR) {
- LOGDEBUG (g_message ("%06d - Calling WSAWaitForMultipleEvents () on socket %d", GetCurrentThreadId (), sock));
- DWORD ret = WSAWaitForMultipleEvents (1, &event, TRUE, timeout, TRUE);
- if (ret == WSA_WAIT_IO_COMPLETION) {
- LOGDEBUG (g_message ("%06d - WSAWaitForMultipleEvents () returned WSA_WAIT_IO_COMPLETION for socket %d", GetCurrentThreadId (), sock));
- error = WSAEINTR;
- } else if (ret == WSA_WAIT_TIMEOUT) {
- error = WSAETIMEDOUT;
- } else {
- g_assert (ret == WSA_WAIT_EVENT_0);
- WSANETWORKEVENTS ne = { 0 };
- if (WSAEnumNetworkEvents (sock, event, &ne) != SOCKET_ERROR) {
- if (ne.lNetworkEvents & (1 << event_bit) && ne.iErrorCode[event_bit]) {
- LOGDEBUG (g_message ("%06d - %s error %d on socket %d", GetCurrentThreadId (), EVENT_NAMES[event_bit], ne.iErrorCode[event_bit], sock));
- error = ne.iErrorCode[event_bit];
- } else if (ne.lNetworkEvents & FD_CLOSE_BIT && ne.iErrorCode[FD_CLOSE_BIT]) {
- LOGDEBUG (g_message ("%06d - FD_CLOSE error %d on socket %d", GetCurrentThreadId (), ne.iErrorCode[FD_CLOSE_BIT], sock));
- error = ne.iErrorCode[FD_CLOSE_BIT];
- } else {
- LOGDEBUG (g_message ("%06d - WSAEnumNetworkEvents () finished successfully on socket %d", GetCurrentThreadId (), sock));
- success = TRUE;
- error = 0;
- }
- }
- }
- WSAEventSelect (sock, NULL, 0);
- }
- WSACloseEvent (event);
- }
- if (error != -1) {
- WSASetLastError (error);
- }
- return success;
-}
-
-#define ALERTABLE_SOCKET_CALL(event_bit, blocking, repeat, ret, op, sock, ...) \
- LOGDEBUG (g_message ("%06d - Performing %s " #op " () on socket %d", GetCurrentThreadId (), blocking ? "blocking" : "non-blocking", sock)); \
- if (blocking) { \
- if (set_blocking(sock, FALSE)) { \
- while (-1 == (int) (ret = op (sock, __VA_ARGS__))) { \
- int _error = WSAGetLastError ();\
- if (_error != WSAEWOULDBLOCK && _error != WSA_IO_PENDING) \
- break; \
- if (!alertable_socket_wait (sock, event_bit) || !repeat) \
- break; \
- } \
- int _saved_error = WSAGetLastError (); \
- set_blocking (sock, TRUE); \
- WSASetLastError (_saved_error); \
- } \
- } else { \
- ret = op (sock, __VA_ARGS__); \
- } \
- int _saved_error = WSAGetLastError (); \
- LOGDEBUG (g_message ("%06d - Finished %s " #op " () on socket %d (ret = %d, WSAGetLastError() = %d)", GetCurrentThreadId (), \
- blocking ? "blocking" : "non-blocking", sock, ret, _saved_error)); \
- WSASetLastError (_saved_error);
-
-SOCKET alertable_accept (SOCKET s, struct sockaddr *addr, int *addrlen, gboolean blocking)
-{
- SOCKET newsock = INVALID_SOCKET;
- ALERTABLE_SOCKET_CALL (FD_ACCEPT_BIT, blocking, TRUE, newsock, accept, s, addr, addrlen);
- return newsock;
-}
-
-int alertable_connect (SOCKET s, const struct sockaddr *name, int namelen, gboolean blocking)
-{
- int ret = SOCKET_ERROR;
- ALERTABLE_SOCKET_CALL (FD_CONNECT_BIT, blocking, FALSE, ret, connect, s, name, namelen);
- ret = WSAGetLastError () != 0 ? SOCKET_ERROR : 0;
- return ret;
-}
-
-int alertable_recv (SOCKET s, char *buf, int len, int flags, gboolean blocking)
-{
- int ret = SOCKET_ERROR;
- ALERTABLE_SOCKET_CALL (FD_READ_BIT, blocking, TRUE, ret, recv, s, buf, len, flags);
- return ret;
-}
-
-int alertable_recvfrom (SOCKET s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen, gboolean blocking)
-{
- int ret = SOCKET_ERROR;
- ALERTABLE_SOCKET_CALL (FD_READ_BIT, blocking, TRUE, ret, recvfrom, s, buf, len, flags, from, fromlen);
- return ret;
-}
-
-int alertable_WSARecv (SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, gboolean blocking)
-{
- int ret = SOCKET_ERROR;
- ALERTABLE_SOCKET_CALL (FD_READ_BIT, blocking, TRUE, ret, WSARecv, s, lpBuffers, dwBufferCount, lpNumberOfBytesRecvd, lpFlags, lpOverlapped, lpCompletionRoutine);
- return ret;
-}
-
-int alertable_send (SOCKET s, char *buf, int len, int flags, gboolean blocking)
-{
- int ret = SOCKET_ERROR;
- ALERTABLE_SOCKET_CALL (FD_WRITE_BIT, blocking, FALSE, ret, send, s, buf, len, flags);
- return ret;
-}
-
-int alertable_sendto (SOCKET s, const char *buf, int len, int flags, const struct sockaddr *to, int tolen, gboolean blocking)
-{
- int ret = SOCKET_ERROR;
- ALERTABLE_SOCKET_CALL (FD_WRITE_BIT, blocking, FALSE, ret, sendto, s, buf, len, flags, to, tolen);
- return ret;
-}
-
-int alertable_WSASend (SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd, DWORD lpFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, gboolean blocking)
-{
- int ret = SOCKET_ERROR;
- ALERTABLE_SOCKET_CALL (FD_WRITE_BIT, blocking, FALSE, ret, WSASend, s, lpBuffers, dwBufferCount, lpNumberOfBytesRecvd, lpFlags, lpOverlapped, lpCompletionRoutine);
- return ret;
-}
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
-BOOL alertable_TransmitFile (SOCKET hSocket, HANDLE hFile, DWORD nNumberOfBytesToWrite, DWORD nNumberOfBytesPerSend, LPOVERLAPPED lpOverlapped, LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, DWORD dwReserved, gboolean blocking)
-{
- LOGDEBUG (g_message ("%06d - Performing %s TransmitFile () on socket %d", GetCurrentThreadId (), blocking ? "blocking" : "non-blocking", hSocket));
-
- int error = 0;
- if (blocking) {
- g_assert (lpOverlapped == NULL);
- OVERLAPPED overlapped = { 0 };
- overlapped.hEvent = WSACreateEvent ();
- if (overlapped.hEvent == WSA_INVALID_EVENT)
- return FALSE;
- if (!TransmitFile (hSocket, hFile, nNumberOfBytesToWrite, nNumberOfBytesPerSend, &overlapped, lpTransmitBuffers, dwReserved)) {
- error = WSAGetLastError ();
- if (error == WSA_IO_PENDING) {
- error = 0;
- // NOTE: .NET's Socket.SendFile() doesn't honor the Socket's SendTimeout so we shouldn't either
- DWORD ret = WaitForSingleObjectEx (overlapped.hEvent, INFINITE, TRUE);
- if (ret == WAIT_IO_COMPLETION) {
- LOGDEBUG (g_message ("%06d - WaitForSingleObjectEx () returned WSA_WAIT_IO_COMPLETION for socket %d", GetCurrentThreadId (), hSocket));
- error = WSAEINTR;
- } else if (ret == WAIT_TIMEOUT) {
- error = WSAETIMEDOUT;
- } else if (ret != WAIT_OBJECT_0) {
- error = GetLastError ();
- }
- }
- }
- WSACloseEvent (overlapped.hEvent);
- } else {
- if (!TransmitFile (hSocket, hFile, nNumberOfBytesToWrite, nNumberOfBytesPerSend, lpOverlapped, lpTransmitBuffers, dwReserved)) {
- error = WSAGetLastError ();
- }
- }
-
- LOGDEBUG (g_message ("%06d - Finished %s TransmitFile () on socket %d (ret = %d, WSAGetLastError() = %d)", GetCurrentThreadId (), \
- blocking ? "blocking" : "non-blocking", hSocket, error == 0, error));
- WSASetLastError (error);
-
- return error == 0;
-}
-#endif /* #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
+++ /dev/null
-/*
- * socket-io.c: Socket IO internal calls
- *
- * Authors:
- * Dick Porter (dick@ximian.com)
- * Gonzalo Paniagua Javier (gonzalo@ximian.com)
- *
- * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
- * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
- *
- * This file has been re-licensed under the MIT License:
- * http://opensource.org/licenses/MIT
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-
-#include <config.h>
-
-#ifndef DISABLE_SOCKETS
-
-#if defined(__APPLE__) || defined(__FreeBSD__)
-#define __APPLE_USE_RFC_3542
-#endif
-
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-#ifdef HOST_WIN32
-#include <ws2tcpip.h>
-#else
-#include <sys/socket.h>
-#ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-#include <arpa/inet.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <errno.h>
-
-#include <sys/types.h>
-
-#include <mono/metadata/object.h>
-#include <mono/io-layer/io-layer.h>
-#include <mono/metadata/socket-io.h>
-#include <mono/metadata/exception.h>
-#include <mono/metadata/assembly.h>
-#include <mono/metadata/appdomain.h>
-#include <mono/metadata/file-io.h>
-#include <mono/metadata/threads.h>
-#include <mono/metadata/threads-types.h>
-#include <mono/metadata/threadpool-io.h>
-#include <mono/utils/mono-poll.h>
-/* FIXME change this code to not mess so much with the internals */
-#include <mono/metadata/class-internals.h>
-#include <mono/metadata/domain-internals.h>
-#include <mono/utils/mono-threads.h>
-#include <mono/utils/mono-memory-model.h>
-#include <mono/utils/networking.h>
-#include <mono/metadata/w32handle.h>
-
-#include <time.h>
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-#ifdef HAVE_NET_IF_H
-#include <net/if.h>
-#endif
-
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-#ifdef HAVE_SYS_FILIO_H
-#include <sys/filio.h> /* defines FIONBIO and FIONREAD */
-#endif
-#ifdef HAVE_SYS_SOCKIO_H
-#include <sys/sockio.h> /* defines SIOCATMARK */
-#endif
-#ifdef HAVE_SYS_UN_H
-#include <sys/un.h>
-#endif
-
-#ifdef HAVE_GETIFADDRS
-// <net/if.h> must be included before <ifaddrs.h>
-#include <ifaddrs.h>
-#endif
-
-#if defined(_MSC_VER) && G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
-#include <MSWSock.h>
-#endif
-
-#include "mono/io-layer/socket-wrappers.h"
-#ifdef HOST_WIN32
-#include "mono/metadata/socket-io-windows-internals.h"
-#endif
-
-#define LOGDEBUG(...)
-/* define LOGDEBUG(...) g_message(__VA_ARGS__) */
-
-static void
-abort_syscall (gpointer data)
-{
- mono_thread_info_abort_socket_syscall_for_close ((MonoNativeThreadId) (gsize) data);
-}
-
-static gint32
-convert_family (MonoAddressFamily mono_family)
-{
- switch (mono_family) {
- case AddressFamily_Unknown:
- case AddressFamily_ImpLink:
- case AddressFamily_Pup:
- case AddressFamily_Chaos:
- case AddressFamily_Iso:
- case AddressFamily_Ecma:
- case AddressFamily_DataKit:
- case AddressFamily_Ccitt:
- case AddressFamily_DataLink:
- case AddressFamily_Lat:
- case AddressFamily_HyperChannel:
- case AddressFamily_NetBios:
- case AddressFamily_VoiceView:
- case AddressFamily_FireFox:
- case AddressFamily_Banyan:
- case AddressFamily_Atm:
- case AddressFamily_Cluster:
- case AddressFamily_Ieee12844:
- case AddressFamily_NetworkDesigners:
- g_warning ("System.Net.Sockets.AddressFamily has unsupported value 0x%x", mono_family);
- return -1;
- case AddressFamily_Unspecified:
- return AF_UNSPEC;
- case AddressFamily_Unix:
- return AF_UNIX;
- case AddressFamily_InterNetwork:
- return AF_INET;
- case AddressFamily_AppleTalk:
- return AF_APPLETALK;
- case AddressFamily_InterNetworkV6:
- return AF_INET6;
- case AddressFamily_DecNet:
-#ifdef AF_DECnet
- return AF_DECnet;
-#else
- return -1;
-#endif
- case AddressFamily_Ipx:
-#ifdef AF_IPX
- return AF_IPX;
-#else
- return -1;
-#endif
- case AddressFamily_Sna:
-#ifdef AF_SNA
- return AF_SNA;
-#else
- return -1;
-#endif
- case AddressFamily_Irda:
-#ifdef AF_IRDA
- return AF_IRDA;
-#else
- return -1;
-#endif
- default:
- g_warning ("System.Net.Sockets.AddressFamily has unknown value 0x%x", mono_family);
- return -1;
- }
-}
-
-static MonoAddressFamily
-convert_to_mono_family (guint16 af_family)
-{
- switch (af_family) {
- case AF_UNSPEC:
- return AddressFamily_Unspecified;
- case AF_UNIX:
- return AddressFamily_Unix;
- case AF_INET:
- return AddressFamily_InterNetwork;
-#ifdef AF_IPX
- case AF_IPX:
- return AddressFamily_Ipx;
-#endif
-#ifdef AF_SNA
- case AF_SNA:
- return AddressFamily_Sna;
-#endif
-#ifdef AF_DECnet
- case AF_DECnet:
- return AddressFamily_DecNet;
-#endif
- case AF_APPLETALK:
- return AddressFamily_AppleTalk;
- case AF_INET6:
- return AddressFamily_InterNetworkV6;
-#ifdef AF_IRDA
- case AF_IRDA:
- return AddressFamily_Irda;
-#endif
- default:
- g_warning ("unknown address family 0x%x", af_family);
- return AddressFamily_Unknown;
- }
-}
-
-static gint32
-convert_type (MonoSocketType mono_type)
-{
- switch (mono_type) {
- case SocketType_Stream:
- return SOCK_STREAM;
- case SocketType_Dgram:
- return SOCK_DGRAM;
- case SocketType_Raw:
- return SOCK_RAW;
- case SocketType_Rdm:
-#ifdef SOCK_RDM
- return SOCK_RDM;
-#else
- return -1;
-#endif
- case SocketType_Seqpacket:
- return SOCK_SEQPACKET;
- case SocketType_Unknown:
- g_warning ("System.Net.Sockets.SocketType has unsupported value 0x%x", mono_type);
- return -1;
- default:
- g_warning ("System.Net.Sockets.SocketType has unknown value 0x%x", mono_type);
- return -1;
- }
-}
-
-static gint32
-convert_proto (MonoProtocolType mono_proto)
-{
- switch (mono_proto) {
- case ProtocolType_IP:
- case ProtocolType_IPv6:
- case ProtocolType_Icmp:
- case ProtocolType_Igmp:
- case ProtocolType_Ggp:
- case ProtocolType_Tcp:
- case ProtocolType_Pup:
- case ProtocolType_Udp:
- case ProtocolType_Idp:
- /* These protocols are known (on my system at least) */
- return mono_proto;
- case ProtocolType_ND:
- case ProtocolType_Raw:
- case ProtocolType_Ipx:
- case ProtocolType_Spx:
- case ProtocolType_SpxII:
- case ProtocolType_Unknown:
- /* These protocols arent */
- g_warning ("System.Net.Sockets.ProtocolType has unsupported value 0x%x", mono_proto);
- return -1;
- default:
- return -1;
- }
-}
-
-/* Convert MonoSocketFlags */
-static gint32
-convert_socketflags (gint32 sflags)
-{
- gint32 flags = 0;
-
- if (!sflags)
- /* SocketFlags.None */
- return 0;
-
- if (sflags & ~(SocketFlags_OutOfBand | SocketFlags_MaxIOVectorLength | SocketFlags_Peek |
- SocketFlags_DontRoute | SocketFlags_Partial))
- /* Contains invalid flag values */
- return -1;
-
- if (sflags & SocketFlags_OutOfBand)
- flags |= MSG_OOB;
- if (sflags & SocketFlags_Peek)
- flags |= MSG_PEEK;
- if (sflags & SocketFlags_DontRoute)
- flags |= MSG_DONTROUTE;
-
- /* Ignore Partial - see bug 349688. Don't return -1, because
- * according to the comment in that bug ms runtime doesn't for
- * UDP sockets (this means we will silently ignore it for TCP
- * too)
- */
-#ifdef MSG_MORE
- if (sflags & SocketFlags_Partial)
- flags |= MSG_MORE;
-#endif
-#if 0
- /* Don't do anything for MaxIOVectorLength */
- if (sflags & SocketFlags_MaxIOVectorLength)
- return -1;
-#endif
- return flags;
-}
-
-/*
- * Returns:
- * 0 on success (mapped mono_level and mono_name to system_level and system_name
- * -1 on error
- * -2 on non-fatal error (ie, must ignore)
- */
-static gint32
-convert_sockopt_level_and_name (MonoSocketOptionLevel mono_level, MonoSocketOptionName mono_name, int *system_level, int *system_name)
-{
- switch (mono_level) {
- case SocketOptionLevel_Socket:
- *system_level = SOL_SOCKET;
-
- switch (mono_name) {
- case SocketOptionName_DontLinger:
- /* This is SO_LINGER, because the setsockopt
- * internal call maps DontLinger to SO_LINGER
- * with l_onoff=0
- */
- *system_name = SO_LINGER;
- break;
- case SocketOptionName_Debug:
- *system_name = SO_DEBUG;
- break;
-#ifdef SO_ACCEPTCONN
- case SocketOptionName_AcceptConnection:
- *system_name = SO_ACCEPTCONN;
- break;
-#endif
- case SocketOptionName_ReuseAddress:
- *system_name = SO_REUSEADDR;
- break;
- case SocketOptionName_KeepAlive:
- *system_name = SO_KEEPALIVE;
- break;
- case SocketOptionName_DontRoute:
- *system_name = SO_DONTROUTE;
- break;
- case SocketOptionName_Broadcast:
- *system_name = SO_BROADCAST;
- break;
- case SocketOptionName_Linger:
- *system_name = SO_LINGER;
- break;
- case SocketOptionName_OutOfBandInline:
- *system_name = SO_OOBINLINE;
- break;
- case SocketOptionName_SendBuffer:
- *system_name = SO_SNDBUF;
- break;
- case SocketOptionName_ReceiveBuffer:
- *system_name = SO_RCVBUF;
- break;
- case SocketOptionName_SendLowWater:
- *system_name = SO_SNDLOWAT;
- break;
- case SocketOptionName_ReceiveLowWater:
- *system_name = SO_RCVLOWAT;
- break;
- case SocketOptionName_SendTimeout:
- *system_name = SO_SNDTIMEO;
- break;
- case SocketOptionName_ReceiveTimeout:
- *system_name = SO_RCVTIMEO;
- break;
- case SocketOptionName_Error:
- *system_name = SO_ERROR;
- break;
- case SocketOptionName_Type:
- *system_name = SO_TYPE;
- break;
-#ifdef SO_PEERCRED
- case SocketOptionName_PeerCred:
- *system_name = SO_PEERCRED;
- break;
-#endif
- case SocketOptionName_ExclusiveAddressUse:
-#ifdef SO_EXCLUSIVEADDRUSE
- *system_name = SO_EXCLUSIVEADDRUSE;
- break;
-#endif
- case SocketOptionName_UseLoopback:
-#ifdef SO_USELOOPBACK
- *system_name = SO_USELOOPBACK;
- break;
-#endif
- case SocketOptionName_MaxConnections:
-#ifdef SO_MAXCONN
- *system_name = SO_MAXCONN;
- break;
-#elif defined(SOMAXCONN)
- *system_name = SOMAXCONN;
- break;
-#endif
- default:
- g_warning ("System.Net.Sockets.SocketOptionName 0x%x is not supported at Socket level", mono_name);
- return -1;
- }
- break;
-
- case SocketOptionLevel_IP:
- *system_level = mono_networking_get_ip_protocol ();
-
- switch (mono_name) {
- case SocketOptionName_IPOptions:
- *system_name = IP_OPTIONS;
- break;
-#ifdef IP_HDRINCL
- case SocketOptionName_HeaderIncluded:
- *system_name = IP_HDRINCL;
- break;
-#endif
-#ifdef IP_TOS
- case SocketOptionName_TypeOfService:
- *system_name = IP_TOS;
- break;
-#endif
-#ifdef IP_TTL
- case SocketOptionName_IpTimeToLive:
- *system_name = IP_TTL;
- break;
-#endif
- case SocketOptionName_MulticastInterface:
- *system_name = IP_MULTICAST_IF;
- break;
- case SocketOptionName_MulticastTimeToLive:
- *system_name = IP_MULTICAST_TTL;
- break;
- case SocketOptionName_MulticastLoopback:
- *system_name = IP_MULTICAST_LOOP;
- break;
- case SocketOptionName_AddMembership:
- *system_name = IP_ADD_MEMBERSHIP;
- break;
- case SocketOptionName_DropMembership:
- *system_name = IP_DROP_MEMBERSHIP;
- break;
-#ifdef HAVE_IP_PKTINFO
- case SocketOptionName_PacketInformation:
- *system_name = IP_PKTINFO;
- break;
-#endif /* HAVE_IP_PKTINFO */
-
- case SocketOptionName_DontFragment:
-#ifdef HAVE_IP_DONTFRAGMENT
- *system_name = IP_DONTFRAGMENT;
- break;
-#elif defined HAVE_IP_MTU_DISCOVER
- /* Not quite the same */
- *system_name = IP_MTU_DISCOVER;
- break;
-#else
- /* If the flag is not available on this system, we can ignore this error */
- return -2;
-#endif /* HAVE_IP_DONTFRAGMENT */
- case SocketOptionName_AddSourceMembership:
- case SocketOptionName_DropSourceMembership:
- case SocketOptionName_BlockSource:
- case SocketOptionName_UnblockSource:
- /* Can't figure out how to map these, so fall
- * through
- */
- default:
- g_warning ("System.Net.Sockets.SocketOptionName 0x%x is not supported at IP level", mono_name);
- return -1;
- }
- break;
-
- case SocketOptionLevel_IPv6:
- *system_level = mono_networking_get_ipv6_protocol ();
-
- switch (mono_name) {
- case SocketOptionName_IpTimeToLive:
- case SocketOptionName_HopLimit:
- *system_name = IPV6_UNICAST_HOPS;
- break;
- case SocketOptionName_MulticastInterface:
- *system_name = IPV6_MULTICAST_IF;
- break;
- case SocketOptionName_MulticastTimeToLive:
- *system_name = IPV6_MULTICAST_HOPS;
- break;
- case SocketOptionName_MulticastLoopback:
- *system_name = IPV6_MULTICAST_LOOP;
- break;
- case SocketOptionName_AddMembership:
- *system_name = IPV6_JOIN_GROUP;
- break;
- case SocketOptionName_DropMembership:
- *system_name = IPV6_LEAVE_GROUP;
- break;
- case SocketOptionName_IPv6Only:
-#ifdef IPV6_V6ONLY
- *system_name = IPV6_V6ONLY;
-#else
- return -1;
-#endif
- break;
- case SocketOptionName_PacketInformation:
-#ifdef HAVE_IPV6_PKTINFO
- *system_name = IPV6_PKTINFO;
-#endif
- break;
- case SocketOptionName_HeaderIncluded:
- case SocketOptionName_IPOptions:
- case SocketOptionName_TypeOfService:
- case SocketOptionName_DontFragment:
- case SocketOptionName_AddSourceMembership:
- case SocketOptionName_DropSourceMembership:
- case SocketOptionName_BlockSource:
- case SocketOptionName_UnblockSource:
- /* Can't figure out how to map these, so fall
- * through
- */
- default:
- g_warning ("System.Net.Sockets.SocketOptionName 0x%x is not supported at IPv6 level", mono_name);
- return -1;
- }
- break; /* SocketOptionLevel_IPv6 */
-
- case SocketOptionLevel_Tcp:
- *system_level = mono_networking_get_tcp_protocol ();
-
- switch (mono_name) {
- case SocketOptionName_NoDelay:
- *system_name = TCP_NODELAY;
- break;
-#if 0
- /* The documentation is talking complete
- * bollocks here: rfc-1222 is titled
- * 'Advancing the NSFNET Routing Architecture'
- * and doesn't mention either of the words
- * "expedite" or "urgent".
- */
- case SocketOptionName_BsdUrgent:
- case SocketOptionName_Expedited:
-#endif
- default:
- g_warning ("System.Net.Sockets.SocketOptionName 0x%x is not supported at TCP level", mono_name);
- return -1;
- }
- break;
-
- case SocketOptionLevel_Udp:
- g_warning ("System.Net.Sockets.SocketOptionLevel has unsupported value 0x%x", mono_level);
-
- switch(mono_name) {
- case SocketOptionName_NoChecksum:
- case SocketOptionName_ChecksumCoverage:
- default:
- g_warning ("System.Net.Sockets.SocketOptionName 0x%x is not supported at UDP level", mono_name);
- return -1;
- }
- return -1;
- break;
-
- default:
- g_warning ("System.Net.Sockets.SocketOptionLevel has unknown value 0x%x", mono_level);
- return -1;
- }
-
- return 0;
-}
-
-static MonoImage*
-get_socket_assembly (void)
-{
- MonoDomain *domain = mono_domain_get ();
-
- if (domain->socket_assembly == NULL) {
- MonoImage *socket_assembly;
-
- socket_assembly = mono_image_loaded ("System");
- if (!socket_assembly) {
- MonoAssembly *sa = mono_assembly_open ("System.dll", NULL);
-
- if (!sa) {
- g_assert_not_reached ();
- } else {
- socket_assembly = mono_assembly_get_image (sa);
- }
- }
- mono_atomic_store_release (&domain->socket_assembly, socket_assembly);
- }
-
- return domain->socket_assembly;
-}
-
-gpointer
-ves_icall_System_Net_Sockets_Socket_Socket_internal (MonoObject *this_obj, gint32 family, gint32 type, gint32 proto, gint32 *werror)
-{
- SOCKET sock;
- gint32 sock_family;
- gint32 sock_proto;
- gint32 sock_type;
-
- *werror = 0;
-
- sock_family = convert_family ((MonoAddressFamily)family);
- if (sock_family == -1) {
- *werror = WSAEAFNOSUPPORT;
- return NULL;
- }
-
- sock_proto = convert_proto ((MonoProtocolType)proto);
- if (sock_proto == -1) {
- *werror = WSAEPROTONOSUPPORT;
- return NULL;
- }
-
- sock_type = convert_type ((MonoSocketType)type);
- if (sock_type == -1) {
- *werror = WSAESOCKTNOSUPPORT;
- return NULL;
- }
-
- sock = _wapi_socket (sock_family, sock_type, sock_proto,
- NULL, 0, WSA_FLAG_OVERLAPPED);
-
- if (sock == INVALID_SOCKET) {
- *werror = WSAGetLastError ();
- return NULL;
- }
-
- return GUINT_TO_POINTER (sock);
-}
-
-/* FIXME: the SOCKET parameter (here and in other functions in this
- * file) is really an IntPtr which needs to be converted to a guint32.
- */
-void
-ves_icall_System_Net_Sockets_Socket_Close_internal (SOCKET sock, gint32 *werror)
-{
- LOGDEBUG (g_message ("%s: closing 0x%x", __func__, sock));
-
- *werror = 0;
-
- /* Clear any pending work item from this socket if the underlying
- * polling system does not notify when the socket is closed */
- mono_threadpool_io_remove_socket (GPOINTER_TO_INT (sock));
-
- MONO_ENTER_GC_SAFE;
- closesocket (sock);
- MONO_EXIT_GC_SAFE;
-}
-
-gint32
-ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal (void)
-{
- LOGDEBUG (g_message("%s: returning %d", __func__, WSAGetLastError ()));
-
- return WSAGetLastError ();
-}
-
-gint32
-ves_icall_System_Net_Sockets_Socket_Available_internal (SOCKET sock, gint32 *werror)
-{
- int ret;
- int amount;
-
- *werror = 0;
-
- /* FIXME: this might require amount to be unsigned long. */
- ret = ioctlsocket (sock, FIONREAD, &amount);
- if (ret == SOCKET_ERROR) {
- *werror = WSAGetLastError ();
- return 0;
- }
-
- return amount;
-}
-
-void
-ves_icall_System_Net_Sockets_Socket_Blocking_internal (SOCKET sock, gboolean block, gint32 *werror)
-{
- int ret;
-
- *werror = 0;
-
- /*
- * block == TRUE/FALSE means we will block/not block.
- * But the ioctlsocket call takes TRUE/FALSE for non-block/block
- */
- block = !block;
-
- ret = ioctlsocket (sock, FIONBIO, (gulong *)&block);
- if (ret == SOCKET_ERROR)
- *werror = WSAGetLastError ();
-}
-
-gpointer
-ves_icall_System_Net_Sockets_Socket_Accept_internal (SOCKET sock, gint32 *werror, gboolean blocking)
-{
- gboolean interrupted;
- SOCKET newsock;
-
- *werror = 0;
-
- mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
- if (interrupted) {
- *werror = WSAEINTR;
- return NULL;
- }
-
- MONO_ENTER_GC_SAFE;
-
-#ifdef HOST_WIN32
- {
- MonoInternalThread *curthread = mono_thread_internal_current ();
- curthread->interrupt_on_stop = (gpointer)TRUE;
- newsock = alertable_accept (sock, NULL, 0, blocking);
- curthread->interrupt_on_stop = (gpointer)FALSE;
- }
-#else
- newsock = _wapi_accept (sock, NULL, 0);
-#endif
-
- MONO_EXIT_GC_SAFE;
-
- if (newsock == INVALID_SOCKET)
- *werror = WSAGetLastError ();
-
- mono_thread_info_uninstall_interrupt (&interrupted);
- if (interrupted)
- *werror = WSAEINTR;
-
- if (*werror)
- return NULL;
-
- return GUINT_TO_POINTER (newsock);
-}
-
-void
-ves_icall_System_Net_Sockets_Socket_Listen_internal(SOCKET sock, guint32 backlog, gint32 *werror)
-{
- int ret;
-
- *werror = 0;
-
- MONO_ENTER_GC_SAFE;
-
- ret = _wapi_listen (sock, backlog);
-
- MONO_EXIT_GC_SAFE;
-
- if (ret == SOCKET_ERROR)
- *werror = WSAGetLastError ();
-}
-
-// Check whether it's ::ffff::0:0.
-static gboolean
-is_ipv4_mapped_any (const struct in6_addr *addr)
-{
- int i;
-
- for (i = 0; i < 10; i++) {
- if (addr->s6_addr [i])
- return FALSE;
- }
- if ((addr->s6_addr [10] != 0xff) || (addr->s6_addr [11] != 0xff))
- return FALSE;
- for (i = 12; i < 16; i++) {
- if (addr->s6_addr [i])
- return FALSE;
- }
- return TRUE;
-}
-
-static MonoObject*
-create_object_from_sockaddr (struct sockaddr *saddr, int sa_size, gint32 *werror, MonoError *error)
-{
- MonoDomain *domain = mono_domain_get ();
- MonoObject *sockaddr_obj;
- MonoArray *data;
- MonoAddressFamily family;
-
- mono_error_init (error);
-
- /* Build a System.Net.SocketAddress object instance */
- if (!domain->sockaddr_class)
- domain->sockaddr_class = mono_class_load_from_name (get_socket_assembly (), "System.Net", "SocketAddress");
- sockaddr_obj = mono_object_new_checked (domain, domain->sockaddr_class, error);
- return_val_if_nok (error, NULL);
-
- /* Locate the SocketAddress data buffer in the object */
- if (!domain->sockaddr_data_field) {
- domain->sockaddr_data_field = mono_class_get_field_from_name (domain->sockaddr_class, "m_Buffer");
- g_assert (domain->sockaddr_data_field);
- }
-
- /* Locate the SocketAddress data buffer length in the object */
- if (!domain->sockaddr_data_length_field) {
- domain->sockaddr_data_length_field = mono_class_get_field_from_name (domain->sockaddr_class, "m_Size");
- g_assert (domain->sockaddr_data_length_field);
- }
-
- /* May be the +2 here is too conservative, as sa_len returns
- * the length of the entire sockaddr_in/in6, including
- * sizeof (unsigned short) of the family */
- /* We can't really avoid the +2 as all code below depends on this size - INCLUDING unix domain sockets.*/
- data = mono_array_new_cached (domain, mono_get_byte_class (), sa_size + 2, error);
- return_val_if_nok (error, NULL);
-
- /* The data buffer is laid out as follows:
- * bytes 0 and 1 are the address family
- * bytes 2 and 3 are the port info
- * the rest is the address info
- */
-
- family = convert_to_mono_family (saddr->sa_family);
- if (family == AddressFamily_Unknown) {
- *werror = WSAEAFNOSUPPORT;
- return NULL;
- }
-
- mono_array_set (data, guint8, 0, family & 0x0FF);
- mono_array_set (data, guint8, 1, (family >> 8) & 0x0FF);
-
- if (saddr->sa_family == AF_INET) {
- struct sockaddr_in *sa_in = (struct sockaddr_in *)saddr;
- guint16 port = ntohs (sa_in->sin_port);
- guint32 address = ntohl (sa_in->sin_addr.s_addr);
- int buffer_size = 8;
-
- if (sa_size < buffer_size) {
- mono_error_set_exception_instance (error, mono_exception_from_name (mono_get_corlib (), "System", "SystemException"));
- return NULL;
- }
-
- mono_array_set (data, guint8, 2, (port>>8) & 0xff);
- mono_array_set (data, guint8, 3, (port) & 0xff);
- mono_array_set (data, guint8, 4, (address>>24) & 0xff);
- mono_array_set (data, guint8, 5, (address>>16) & 0xff);
- mono_array_set (data, guint8, 6, (address>>8) & 0xff);
- mono_array_set (data, guint8, 7, (address) & 0xff);
-
- mono_field_set_value (sockaddr_obj, domain->sockaddr_data_field, data);
- mono_field_set_value (sockaddr_obj, domain->sockaddr_data_length_field, &buffer_size);
-
- return sockaddr_obj;
- } else if (saddr->sa_family == AF_INET6) {
- struct sockaddr_in6 *sa_in = (struct sockaddr_in6 *)saddr;
- int i;
- int buffer_size = 28;
-
- guint16 port = ntohs (sa_in->sin6_port);
-
- if (sa_size < buffer_size) {
- mono_error_set_exception_instance (error, mono_exception_from_name (mono_get_corlib (), "System", "SystemException"));
- return NULL;
- }
-
- mono_array_set (data, guint8, 2, (port>>8) & 0xff);
- mono_array_set (data, guint8, 3, (port) & 0xff);
-
- if (is_ipv4_mapped_any (&sa_in->sin6_addr)) {
- // Map ::ffff:0:0 to :: (bug #5502)
- for (i = 0; i < 16; i++)
- mono_array_set (data, guint8, 8 + i, 0);
- } else {
- for (i = 0; i < 16; i++) {
- mono_array_set (data, guint8, 8 + i,
- sa_in->sin6_addr.s6_addr [i]);
- }
- }
-
- mono_array_set (data, guint8, 24, sa_in->sin6_scope_id & 0xff);
- mono_array_set (data, guint8, 25,
- (sa_in->sin6_scope_id >> 8) & 0xff);
- mono_array_set (data, guint8, 26,
- (sa_in->sin6_scope_id >> 16) & 0xff);
- mono_array_set (data, guint8, 27,
- (sa_in->sin6_scope_id >> 24) & 0xff);
-
- mono_field_set_value (sockaddr_obj, domain->sockaddr_data_field, data);
- mono_field_set_value (sockaddr_obj, domain->sockaddr_data_length_field, &buffer_size);
-
- return sockaddr_obj;
- }
-#ifdef HAVE_SYS_UN_H
- else if (saddr->sa_family == AF_UNIX) {
- int i;
- int buffer_size = sa_size + 2;
-
- for (i = 0; i < sa_size; i++)
- mono_array_set (data, guint8, i + 2, saddr->sa_data [i]);
-
- mono_field_set_value (sockaddr_obj, domain->sockaddr_data_field, data);
- mono_field_set_value (sockaddr_obj, domain->sockaddr_data_length_field, &buffer_size);
-
- return sockaddr_obj;
- }
-#endif
- else {
- *werror = WSAEAFNOSUPPORT;
- return NULL;
- }
-}
-
-static int
-get_sockaddr_size (int family)
-{
- int size;
-
- size = 0;
- if (family == AF_INET) {
- size = sizeof (struct sockaddr_in);
- } else if (family == AF_INET6) {
- size = sizeof (struct sockaddr_in6);
- }
-#ifdef HAVE_SYS_UN_H
- else if (family == AF_UNIX) {
- size = sizeof (struct sockaddr_un);
- }
-#endif
- return size;
-}
-
-MonoObject*
-ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal (SOCKET sock, gint32 af, gint32 *werror)
-{
- gchar *sa;
- socklen_t salen;
- int ret;
- MonoObject *result;
- MonoError error;
-
- *werror = 0;
-
- salen = get_sockaddr_size (convert_family ((MonoAddressFamily)af));
- if (salen == 0) {
- *werror = WSAEAFNOSUPPORT;
- return NULL;
- }
- sa = (salen <= 128) ? (gchar *)alloca (salen) : (gchar *)g_malloc0 (salen);
-
- MONO_ENTER_GC_SAFE;
-
- ret = _wapi_getsockname (sock, (struct sockaddr *)sa, &salen);
-
- MONO_EXIT_GC_SAFE;
-
- if (ret == SOCKET_ERROR) {
- *werror = WSAGetLastError ();
- if (salen > 128)
- g_free (sa);
- return NULL;
- }
-
- LOGDEBUG (g_message("%s: bound to %s port %d", __func__, inet_ntoa (((struct sockaddr_in *)&sa)->sin_addr), ntohs (((struct sockaddr_in *)&sa)->sin_port)));
-
- result = create_object_from_sockaddr ((struct sockaddr *)sa, salen, werror, &error);
- if (salen > 128)
- g_free (sa);
- if (!mono_error_ok (&error))
- mono_error_set_pending_exception (&error);
- return result;
-}
-
-MonoObject*
-ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal (SOCKET sock, gint32 af, gint32 *werror)
-{
- gchar *sa;
- socklen_t salen;
- int ret;
- MonoObject *result;
- MonoError error;
-
- *werror = 0;
-
- salen = get_sockaddr_size (convert_family ((MonoAddressFamily)af));
- if (salen == 0) {
- *werror = WSAEAFNOSUPPORT;
- return NULL;
- }
- sa = (salen <= 128) ? (gchar *)alloca (salen) : (gchar *)g_malloc0 (salen);
- /* Note: linux returns just 2 for AF_UNIX. Always. */
-
- MONO_ENTER_GC_SAFE;
-
- ret = _wapi_getpeername (sock, (struct sockaddr *)sa, &salen);
-
- MONO_EXIT_GC_SAFE;
-
- if (ret == SOCKET_ERROR) {
- *werror = WSAGetLastError ();
- if (salen > 128)
- g_free (sa);
- return NULL;
- }
-
- LOGDEBUG (g_message("%s: connected to %s port %d", __func__, inet_ntoa (((struct sockaddr_in *)&sa)->sin_addr), ntohs (((struct sockaddr_in *)&sa)->sin_port)));
-
- result = create_object_from_sockaddr ((struct sockaddr *)sa, salen, werror, &error);
- if (salen > 128)
- g_free (sa);
- if (!mono_error_ok (&error))
- mono_error_set_pending_exception (&error);
- return result;
-}
-
-static struct sockaddr*
-create_sockaddr_from_object (MonoObject *saddr_obj, socklen_t *sa_size, gint32 *werror, MonoError *error)
-{
- MonoDomain *domain = mono_domain_get ();
- MonoArray *data;
- gint32 family;
- int len;
-
- mono_error_init (error);
-
- if (!domain->sockaddr_class)
- domain->sockaddr_class = mono_class_load_from_name (get_socket_assembly (), "System.Net", "SocketAddress");
-
- /* Locate the SocketAddress data buffer in the object */
- if (!domain->sockaddr_data_field) {
- domain->sockaddr_data_field = mono_class_get_field_from_name (domain->sockaddr_class, "m_Buffer");
- g_assert (domain->sockaddr_data_field);
- }
-
- /* Locate the SocketAddress data buffer length in the object */
- if (!domain->sockaddr_data_length_field) {
- domain->sockaddr_data_length_field = mono_class_get_field_from_name (domain->sockaddr_class, "m_Size");
- g_assert (domain->sockaddr_data_length_field);
- }
-
- data = *(MonoArray **)(((char *)saddr_obj) + domain->sockaddr_data_field->offset);
-
- /* The data buffer is laid out as follows:
- * byte 0 is the address family low byte
- * byte 1 is the address family high byte
- * INET:
- * bytes 2 and 3 are the port info
- * the rest is the address info
- * UNIX:
- * the rest is the file name
- */
- len = *(int *)(((char *)saddr_obj) + domain->sockaddr_data_length_field->offset);
- g_assert (len >= 2);
-
- family = convert_family ((MonoAddressFamily)(mono_array_get (data, guint8, 0) + (mono_array_get (data, guint8, 1) << 8)));
- if (family == AF_INET) {
- struct sockaddr_in *sa;
- guint16 port;
- guint32 address;
-
- if (len < 8) {
- mono_error_set_exception_instance (error, mono_exception_from_name (mono_get_corlib (), "System", "SystemException"));
- return NULL;
- }
-
- sa = g_new0 (struct sockaddr_in, 1);
- port = (mono_array_get (data, guint8, 2) << 8) +
- mono_array_get (data, guint8, 3);
- address = (mono_array_get (data, guint8, 4) << 24) +
- (mono_array_get (data, guint8, 5) << 16 ) +
- (mono_array_get (data, guint8, 6) << 8) +
- mono_array_get (data, guint8, 7);
-
- sa->sin_family = family;
- sa->sin_addr.s_addr = htonl (address);
- sa->sin_port = htons (port);
-
- *sa_size = sizeof (struct sockaddr_in);
- return (struct sockaddr *)sa;
- } else if (family == AF_INET6) {
- struct sockaddr_in6 *sa;
- int i;
- guint16 port;
- guint32 scopeid;
-
- if (len < 28) {
- mono_error_set_exception_instance (error, mono_exception_from_name (mono_get_corlib (), "System", "SystemException"));
- return NULL;
- }
-
- sa = g_new0 (struct sockaddr_in6, 1);
- port = mono_array_get (data, guint8, 3) +
- (mono_array_get (data, guint8, 2) << 8);
- scopeid = mono_array_get (data, guint8, 24) +
- (mono_array_get (data, guint8, 25) << 8) +
- (mono_array_get (data, guint8, 26) << 16) +
- (mono_array_get (data, guint8, 27) << 24);
-
- sa->sin6_family = family;
- sa->sin6_port = htons (port);
- sa->sin6_scope_id = scopeid;
-
- for (i = 0; i < 16; i++)
- sa->sin6_addr.s6_addr [i] = mono_array_get (data, guint8, 8 + i);
-
- *sa_size = sizeof (struct sockaddr_in6);
- return (struct sockaddr *)sa;
- }
-#ifdef HAVE_SYS_UN_H
- else if (family == AF_UNIX) {
- struct sockaddr_un *sock_un;
- int i;
-
- /* Need a byte for the '\0' terminator/prefix, and the first
- * two bytes hold the SocketAddress family
- */
- if (len - 2 >= sizeof (sock_un->sun_path)) {
- mono_error_set_exception_instance (error, mono_get_exception_index_out_of_range ());
- return NULL;
- }
-
- sock_un = g_new0 (struct sockaddr_un, 1);
-
- sock_un->sun_family = family;
- for (i = 0; i < len - 2; i++)
- sock_un->sun_path [i] = mono_array_get (data, guint8, i + 2);
-
- *sa_size = len;
- return (struct sockaddr *)sock_un;
- }
-#endif
- else {
- *werror = WSAEAFNOSUPPORT;
- return 0;
- }
-}
-
-void
-ves_icall_System_Net_Sockets_Socket_Bind_internal (SOCKET sock, MonoObject *sockaddr, gint32 *werror)
-{
- MonoError error;
- struct sockaddr *sa;
- socklen_t sa_size;
- int ret;
-
- *werror = 0;
-
- sa = create_sockaddr_from_object (sockaddr, &sa_size, werror, &error);
- if (*werror != 0)
- return;
- if (!mono_error_ok (&error)) {
- mono_error_set_pending_exception (&error);
- return;
- }
-
- LOGDEBUG (g_message("%s: binding to %s port %d", __func__, inet_ntoa (((struct sockaddr_in *)sa)->sin_addr), ntohs (((struct sockaddr_in *)sa)->sin_port)));
-
- ret = _wapi_bind (sock, sa, sa_size);
-
- if (ret == SOCKET_ERROR)
- *werror = WSAGetLastError ();
-
- g_free (sa);
-}
-
-enum {
- SelectModeRead,
- SelectModeWrite,
- SelectModeError
-};
-
-MonoBoolean
-ves_icall_System_Net_Sockets_Socket_Poll_internal (SOCKET sock, gint mode,
- gint timeout, gint32 *werror)
-{
- MonoInternalThread *thread = mono_thread_internal_current ();
- mono_pollfd *pfds;
- int ret;
- gboolean interrupted;
- time_t start;
-
- *werror = 0;
-
- pfds = g_new0 (mono_pollfd, 1);
- pfds->fd = GPOINTER_TO_INT (sock);
-
- switch (mode) {
- case SelectModeRead:
- pfds->events = MONO_POLLIN;
- break;
- case SelectModeWrite:
- pfds->events = MONO_POLLOUT;
- break;
- default:
- pfds->events = MONO_POLLERR | MONO_POLLHUP | MONO_POLLNVAL;
- break;
- }
-
- timeout = (timeout >= 0) ? (timeout / 1000) : -1;
- start = time (NULL);
-
- do {
- mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
- if (interrupted) {
- g_free (pfds);
- *werror = WSAEINTR;
- return FALSE;
- }
-
- MONO_ENTER_GC_SAFE;
-
- ret = mono_poll (pfds, 1, timeout);
-
- MONO_EXIT_GC_SAFE;
-
- mono_thread_info_uninstall_interrupt (&interrupted);
- if (interrupted) {
- g_free (pfds);
- *werror = WSAEINTR;
- return FALSE;
- }
-
- if (timeout > 0 && ret < 0) {
- int err = errno;
- int sec = time (NULL) - start;
-
- timeout -= sec * 1000;
- if (timeout < 0) {
- timeout = 0;
- }
-
- errno = err;
- }
-
- if (ret == -1 && errno == EINTR) {
- if (mono_thread_test_state (thread, (MonoThreadState)(ThreadState_AbortRequested | ThreadState_StopRequested))) {
- g_free (pfds);
- return FALSE;
- }
-
- /* Suspend requested? */
- mono_thread_interruption_checkpoint ();
-
- errno = EINTR;
- }
- } while (ret == -1 && errno == EINTR);
-
- if (ret == -1) {
-#ifdef HOST_WIN32
- *werror = (errno > 0 && errno < WSABASEERR) ? errno + WSABASEERR : errno;
-#else
- *werror = errno_to_WSA (errno, __func__);
-#endif
- g_free (pfds);
- return FALSE;
- }
-
- g_free (pfds);
- return ret != 0;
-}
-
-void
-ves_icall_System_Net_Sockets_Socket_Connect_internal (SOCKET sock, MonoObject *sockaddr, gint32 *werror, gboolean blocking)
-{
- MonoError error;
- struct sockaddr *sa;
- socklen_t sa_size;
- int ret;
- gboolean interrupted;
-
- *werror = 0;
-
- sa = create_sockaddr_from_object (sockaddr, &sa_size, werror, &error);
- if (*werror != 0)
- return;
- if (!mono_error_ok (&error)) {
- mono_error_set_pending_exception (&error);
- return;
- }
-
- LOGDEBUG (g_message("%s: connecting to %s port %d", __func__, inet_ntoa (((struct sockaddr_in *)sa)->sin_addr), ntohs (((struct sockaddr_in *)sa)->sin_port)));
-
- mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
- if (interrupted) {
- *werror = WSAEINTR;
- return;
- }
-
- MONO_ENTER_GC_SAFE;
-
-#ifdef HOST_WIN32
- ret = alertable_connect (sock, sa, sa_size, blocking);
-#else
- ret = _wapi_connect (sock, sa, sa_size);
-#endif
-
- MONO_EXIT_GC_SAFE;
-
- if (ret == SOCKET_ERROR)
- *werror = WSAGetLastError ();
-
- mono_thread_info_uninstall_interrupt (&interrupted);
- if (interrupted)
- *werror = WSAEINTR;
-
- g_free (sa);
-}
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
-/* These #defines from mswsock.h from wine. Defining them here allows
- * us to build this file on a mingw box that doesn't know the magic
- * numbers, but still run on a newer windows box that does.
- */
-#ifndef WSAID_DISCONNECTEX
-#define WSAID_DISCONNECTEX {0x7fda2e11,0x8630,0x436f,{0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}
-typedef BOOL (WINAPI *LPFN_DISCONNECTEX)(SOCKET, LPOVERLAPPED, DWORD, DWORD);
-#endif
-
-#ifndef WSAID_TRANSMITFILE
-#define WSAID_TRANSMITFILE {0xb5367df0,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}}
-typedef BOOL (WINAPI *LPFN_TRANSMITFILE)(SOCKET, HANDLE, DWORD, DWORD, LPOVERLAPPED, LPTRANSMIT_FILE_BUFFERS, DWORD);
-#endif
-
-void
-ves_icall_System_Net_Sockets_Socket_Disconnect_internal (SOCKET sock, MonoBoolean reuse, gint32 *werror)
-{
- int ret;
- glong output_bytes = 0;
- GUID disco_guid = WSAID_DISCONNECTEX;
- GUID trans_guid = WSAID_TRANSMITFILE;
- LPFN_DISCONNECTEX _wapi_disconnectex = NULL;
- LPFN_TRANSMITFILE _wapi_transmitfile = NULL;
- gboolean interrupted;
-
- *werror = 0;
-
- LOGDEBUG (g_message("%s: disconnecting from socket %p (reuse %d)", __func__, sock, reuse));
-
- MONO_ENTER_GC_SAFE;
-
- /* I _think_ the extension function pointers need to be looked
- * up for each socket. FIXME: check the best way to store
- * pointers to functions in managed objects that still works
- * on 64bit platforms.
- */
- ret = WSAIoctl (sock, SIO_GET_EXTENSION_FUNCTION_POINTER, (gchar *)&disco_guid, sizeof (GUID),
- (gchar *)&_wapi_disconnectex, sizeof (void *), &output_bytes, NULL, NULL);
-
- MONO_EXIT_GC_SAFE;
-
- if (ret != 0) {
- /* make sure that WSAIoctl didn't put crap in the
- * output pointer
- */
- _wapi_disconnectex = NULL;
-
- MONO_ENTER_GC_SAFE;
-
- /*
- * Use the SIO_GET_EXTENSION_FUNCTION_POINTER to
- * determine the address of the disconnect method without
- * taking a hard dependency on a single provider
- *
- * For an explanation of why this is done, you can read
- * the article at http://www.codeproject.com/internet/jbsocketserver3.asp
- */
- ret = WSAIoctl (sock, SIO_GET_EXTENSION_FUNCTION_POINTER, (gchar *)&trans_guid, sizeof(GUID),
- (gchar *)&_wapi_transmitfile, sizeof(void *), &output_bytes, NULL, NULL);
-
- MONO_EXIT_GC_SAFE;
-
- if (ret != 0)
- _wapi_transmitfile = NULL;
- }
-
- mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
- if (interrupted) {
- *werror = WSAEINTR;
- return;
- }
-
- MONO_ENTER_GC_SAFE;
-
- if (_wapi_disconnectex != NULL) {
- if (!_wapi_disconnectex (sock, NULL, reuse ? TF_REUSE_SOCKET : 0, 0))
- *werror = WSAGetLastError ();
- } else if (_wapi_transmitfile != NULL) {
- if (!_wapi_transmitfile (sock, NULL, 0, 0, NULL, NULL, TF_DISCONNECT | (reuse ? TF_REUSE_SOCKET : 0)))
- *werror = WSAGetLastError ();
- } else {
- *werror = ERROR_NOT_SUPPORTED;
- }
-
- MONO_EXIT_GC_SAFE;
-
- mono_thread_info_uninstall_interrupt (&interrupted);
- if (interrupted)
- *werror = WSAEINTR;
-}
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
-
-gint32
-ves_icall_System_Net_Sockets_Socket_Receive_internal (SOCKET sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, gint32 *werror, gboolean blocking)
-{
- int ret;
- guchar *buf;
- gint32 alen;
- int recvflags = 0;
- gboolean interrupted;
- MonoInternalThread* curthread G_GNUC_UNUSED = mono_thread_internal_current ();
-
- *werror = 0;
-
- alen = mono_array_length (buffer);
- if (offset > alen - count)
- return 0;
-
- buf = mono_array_addr (buffer, guchar, offset);
-
- recvflags = convert_socketflags (flags);
- if (recvflags == -1) {
- *werror = WSAEOPNOTSUPP;
- return 0;
- }
-
- mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
- if (interrupted)
- return 0;
-
- MONO_ENTER_GC_SAFE;
-
-#ifdef HOST_WIN32
- {
- curthread->interrupt_on_stop = (gpointer)TRUE;
- ret = alertable_recv (sock, buf, count, recvflags, blocking);
- curthread->interrupt_on_stop = (gpointer)FALSE;
- }
-#else
- ret = _wapi_recv (sock, buf, count, recvflags);
-#endif
-
- MONO_EXIT_GC_SAFE;
-
- if (ret == SOCKET_ERROR)
- *werror = WSAGetLastError ();
-
- mono_thread_info_uninstall_interrupt (&interrupted);
- if (interrupted)
- *werror = WSAEINTR;
-
- if (*werror)
- return 0;
-
- return ret;
-}
-
-gint32
-ves_icall_System_Net_Sockets_Socket_Receive_array_internal (SOCKET sock, MonoArray *buffers, gint32 flags, gint32 *werror, gboolean blocking)
-{
- int ret, count;
- gboolean interrupted;
- DWORD recv;
- WSABUF *wsabufs;
- DWORD recvflags = 0;
-
- *werror = 0;
-
- wsabufs = mono_array_addr (buffers, WSABUF, 0);
- count = mono_array_length (buffers);
-
- recvflags = convert_socketflags (flags);
- if (recvflags == -1) {
- *werror = WSAEOPNOTSUPP;
- return 0;
- }
-
- mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
- if (interrupted) {
- *werror = WSAEINTR;
- return 0;
- }
-
- MONO_ENTER_GC_SAFE;
-
-#ifdef HOST_WIN32
- ret = alertable_WSARecv (sock, wsabufs, count, &recv, &recvflags, NULL, NULL, blocking);
-#else
- ret = WSARecv (sock, wsabufs, count, &recv, &recvflags, NULL, NULL);
-#endif
-
- MONO_EXIT_GC_SAFE;
-
- if (ret == SOCKET_ERROR)
- *werror = WSAGetLastError ();
-
- mono_thread_info_uninstall_interrupt (&interrupted);
- if (interrupted)
- *werror = WSAEINTR;
-
- if (*werror)
- return 0;
-
- return recv;
-}
-
-gint32
-ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (SOCKET sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, MonoObject **sockaddr, gint32 *werror, gboolean blocking)
-{
- MonoError error;
- int ret;
- guchar *buf;
- gint32 alen;
- int recvflags = 0;
- struct sockaddr *sa;
- socklen_t sa_size;
- gboolean interrupted;
-
- *werror = 0;
-
- alen = mono_array_length (buffer);
- if (offset > alen - count)
- return 0;
-
- sa = create_sockaddr_from_object (*sockaddr, &sa_size, werror, &error);
- if (*werror != 0)
- return 0;
- if (!mono_error_ok (&error)) {
- mono_error_set_pending_exception (&error);
- return 0;
- }
-
- buf = mono_array_addr (buffer, guchar, offset);
-
- recvflags = convert_socketflags (flags);
- if (recvflags == -1) {
- *werror = WSAEOPNOTSUPP;
- return 0;
- }
-
- mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
- if (interrupted) {
- g_free (sa);
- *werror = WSAEINTR;
- return 0;
- }
-
- MONO_ENTER_GC_SAFE;
-
-#ifdef HOST_WIN32
- ret = alertable_recvfrom (sock, buf, count, recvflags, sa, &sa_size, blocking);
-#else
- ret = _wapi_recvfrom (sock, buf, count, recvflags, sa, &sa_size);
-#endif
-
- MONO_EXIT_GC_SAFE;
-
- if (ret == SOCKET_ERROR)
- *werror = WSAGetLastError ();
-
- mono_thread_info_uninstall_interrupt (&interrupted);
-
- if (interrupted)
- *werror = WSAEINTR;
-
- if (*werror) {
- g_free(sa);
- return 0;
- }
-
- /* If we didn't get a socket size, then we're probably a
- * connected connection-oriented socket and the stack hasn't
- * returned the remote address. All we can do is return null.
- */
- if (sa_size) {
- *sockaddr = create_object_from_sockaddr (sa, sa_size, werror, &error);
- if (!mono_error_ok (&error)) {
- mono_error_set_pending_exception (&error);
- g_free (sa);
- return 0;
- }
- } else {
- *sockaddr = NULL;
- }
-
- g_free (sa);
-
- return ret;
-}
-
-gint32
-ves_icall_System_Net_Sockets_Socket_Send_internal (SOCKET sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, gint32 *werror, gboolean blocking)
-{
- int ret;
- guchar *buf;
- gint32 alen;
- int sendflags = 0;
- gboolean interrupted;
-
- *werror = 0;
-
- alen = mono_array_length (buffer);
- if (offset > alen - count)
- return 0;
-
- LOGDEBUG (g_message("%s: alen: %d", __func__, alen));
-
- buf = mono_array_addr (buffer, guchar, offset);
-
- LOGDEBUG (g_message("%s: Sending %d bytes", __func__, count));
-
- sendflags = convert_socketflags (flags);
- if (sendflags == -1) {
- *werror = WSAEOPNOTSUPP;
- return 0;
- }
-
- mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
- if (interrupted) {
- *werror = WSAEINTR;
- return 0;
- }
-
- MONO_ENTER_GC_SAFE;
-
-#ifdef HOST_WIN32
- ret = alertable_send (sock, buf, count, sendflags, blocking);
-#else
- ret = _wapi_send (sock, buf, count, sendflags);
-#endif
-
- MONO_EXIT_GC_SAFE;
-
- if (ret == SOCKET_ERROR)
- *werror = WSAGetLastError ();
-
- mono_thread_info_uninstall_interrupt (&interrupted);
- if (interrupted)
- *werror = WSAEINTR;
-
- if (*werror)
- return 0;
-
- return ret;
-}
-
-gint32
-ves_icall_System_Net_Sockets_Socket_Send_array_internal (SOCKET sock, MonoArray *buffers, gint32 flags, gint32 *werror, gboolean blocking)
-{
- int ret, count;
- DWORD sent;
- WSABUF *wsabufs;
- DWORD sendflags = 0;
- gboolean interrupted;
-
- *werror = 0;
-
- wsabufs = mono_array_addr (buffers, WSABUF, 0);
- count = mono_array_length (buffers);
-
- sendflags = convert_socketflags (flags);
- if (sendflags == -1) {
- *werror = WSAEOPNOTSUPP;
- return 0;
- }
-
- mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
- if (interrupted) {
- *werror = WSAEINTR;
- return 0;
- }
-
- MONO_ENTER_GC_SAFE;
-
-#ifdef HOST_WIN32
- ret = alertable_WSASend (sock, wsabufs, count, &sent, sendflags, NULL, NULL, blocking);
-#else
- ret = WSASend (sock, wsabufs, count, &sent, sendflags, NULL, NULL);
-#endif
-
- MONO_EXIT_GC_SAFE;
-
- if (ret == SOCKET_ERROR)
- *werror = WSAGetLastError ();
-
- mono_thread_info_uninstall_interrupt (&interrupted);
- if (interrupted)
- *werror = WSAEINTR;
-
- if (*werror)
- return 0;
-
- return sent;
-}
-
-gint32
-ves_icall_System_Net_Sockets_Socket_SendTo_internal (SOCKET sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, MonoObject *sockaddr, gint32 *werror, gboolean blocking)
-{
- MonoError error;
- int ret;
- guchar *buf;
- gint32 alen;
- int sendflags = 0;
- struct sockaddr *sa;
- socklen_t sa_size;
- gboolean interrupted;
-
- *werror = 0;
-
- alen = mono_array_length (buffer);
- if (offset > alen - count) {
- return 0;
- }
-
- sa = create_sockaddr_from_object(sockaddr, &sa_size, werror, &error);
- if (*werror != 0)
- return 0;
- if (!mono_error_ok (&error)) {
- mono_error_set_pending_exception (&error);
- return 0;
- }
-
- LOGDEBUG (g_message ("%s: alen: %d", __func__, alen));
-
- buf = mono_array_addr (buffer, guchar, offset);
-
- LOGDEBUG (g_message("%s: Sending %d bytes", __func__, count));
-
- sendflags = convert_socketflags (flags);
- if (sendflags == -1) {
- g_free (sa);
- *werror = WSAEOPNOTSUPP;
- return 0;
- }
-
- mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
- if (interrupted) {
- g_free (sa);
- *werror = WSAEINTR;
- return 0;
- }
-
- MONO_ENTER_GC_SAFE;
-
-#ifdef HOST_WIN32
- ret = alertable_sendto (sock, buf, count, sendflags, sa, sa_size, blocking);
-#else
- ret = _wapi_sendto (sock, buf, count, sendflags, sa, sa_size);
-#endif
-
- MONO_EXIT_GC_SAFE;
-
- if (ret == SOCKET_ERROR)
- *werror = WSAGetLastError ();
-
- mono_thread_info_uninstall_interrupt (&interrupted);
- if (interrupted)
- *werror = WSAEINTR;
-
- g_free(sa);
-
- if (*werror)
- return 0;
-
- return ret;
-}
-
-static SOCKET
-Socket_to_SOCKET (MonoObject *sockobj)
-{
- MonoSafeHandle *safe_handle;
- MonoClassField *field;
-
- field = mono_class_get_field_from_name (sockobj->vtable->klass, "m_Handle");
- safe_handle = ((MonoSafeHandle *)(*(gpointer *)(((char *)sockobj) + field->offset)));
-
- if (safe_handle == NULL)
- return -1;
-
- return (SOCKET)safe_handle->handle;
-}
-
-#define POLL_ERRORS (MONO_POLLERR | MONO_POLLHUP | MONO_POLLNVAL)
-
-void
-ves_icall_System_Net_Sockets_Socket_Select_internal (MonoArray **sockets, gint32 timeout, gint32 *werror)
-{
- MonoError error;
- MonoInternalThread *thread = mono_thread_internal_current ();
- MonoObject *obj;
- mono_pollfd *pfds;
- int nfds, idx;
- int ret;
- int i, count;
- int mode;
- MonoClass *sock_arr_class;
- MonoArray *socks;
- time_t start;
- uintptr_t socks_size;
- gboolean interrupted;
-
- *werror = 0;
-
- /* *sockets -> READ, null, WRITE, null, ERROR, null */
- count = mono_array_length (*sockets);
- nfds = count - 3; /* NULL separators */
- pfds = g_new0 (mono_pollfd, nfds);
- mode = idx = 0;
- for (i = 0; i < count; i++) {
- obj = mono_array_get (*sockets, MonoObject *, i);
- if (obj == NULL) {
- mode++;
- continue;
- }
-
- if (idx >= nfds) {
- /* The socket array was bogus */
- g_free (pfds);
- *werror = WSAEFAULT;
- return;
- }
-
- pfds [idx].fd = Socket_to_SOCKET (obj);
- pfds [idx].events = (mode == 0) ? MONO_POLLIN : (mode == 1) ? MONO_POLLOUT : POLL_ERRORS;
- idx++;
- }
-
- timeout = (timeout >= 0) ? (timeout / 1000) : -1;
- start = time (NULL);
- do {
- mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
- if (interrupted) {
- g_free (pfds);
- *werror = WSAEINTR;
- return;
- }
-
- MONO_ENTER_GC_SAFE;
-
- ret = mono_poll (pfds, nfds, timeout);
-
- MONO_EXIT_GC_SAFE;
-
- mono_thread_info_uninstall_interrupt (&interrupted);
- if (interrupted) {
- g_free (pfds);
- *werror = WSAEINTR;
- return;
- }
-
- if (timeout > 0 && ret < 0) {
- int err = errno;
- int sec = time (NULL) - start;
-
- timeout -= sec * 1000;
- if (timeout < 0)
- timeout = 0;
- errno = err;
- }
-
- if (ret == -1 && errno == EINTR) {
- if (mono_thread_test_state (thread, (MonoThreadState)(ThreadState_AbortRequested | ThreadState_StopRequested))) {
- g_free (pfds);
- *sockets = NULL;
- return;
- }
-
- /* Suspend requested? */
- mono_thread_interruption_checkpoint ();
-
- errno = EINTR;
- }
- } while (ret == -1 && errno == EINTR);
-
- if (ret == -1) {
-#ifdef HOST_WIN32
- *werror = (errno > 0 && errno < WSABASEERR) ? errno + WSABASEERR : errno;
-#else
- *werror = errno_to_WSA (errno, __func__);
-#endif
- g_free (pfds);
- return;
- }
-
- if (ret == 0) {
- g_free (pfds);
- *sockets = NULL;
- return;
- }
-
- sock_arr_class = ((MonoObject *)*sockets)->vtable->klass;
- socks_size = ((uintptr_t)ret) + 3; /* space for the NULL delimiters */
- socks = mono_array_new_full_checked (mono_domain_get (), sock_arr_class, &socks_size, NULL, &error);
- if (!mono_error_ok (&error)) {
- mono_error_set_pending_exception (&error);
- g_free (pfds);
- return;
- }
-
- mode = idx = 0;
- for (i = 0; i < count && ret > 0; i++) {
- mono_pollfd *pfd;
-
- obj = mono_array_get (*sockets, MonoObject *, i);
- if (obj == NULL) {
- mode++;
- idx++;
- continue;
- }
-
- pfd = &pfds [i - mode];
- if (pfd->revents == 0)
- continue;
-
- ret--;
- if (mode == 0 && (pfd->revents & (MONO_POLLIN | POLL_ERRORS)) != 0) {
- mono_array_setref (socks, idx++, obj);
- } else if (mode == 1 && (pfd->revents & (MONO_POLLOUT | POLL_ERRORS)) != 0) {
- mono_array_setref (socks, idx++, obj);
- } else if ((pfd->revents & POLL_ERRORS) != 0) {
- mono_array_setref (socks, idx++, obj);
- }
- }
-
- *sockets = socks;
- g_free (pfds);
-}
-
-static MonoObject*
-int_to_object (MonoDomain *domain, int val, MonoError *error)
-{
- return mono_value_box_checked (domain, mono_get_int32_class (), &val, error);
-}
-
-void
-ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal (SOCKET sock, gint32 level, gint32 name, MonoObject **obj_val, gint32 *werror)
-{
- int system_level = 0;
- int system_name = 0;
- int ret;
- int val = 0;
- socklen_t valsize = sizeof (val);
- struct linger linger;
- socklen_t lingersize = sizeof (linger);
- int time_ms = 0;
- socklen_t time_ms_size = sizeof (time_ms);
-#ifdef SO_PEERCRED
-# if defined(__OpenBSD__)
- struct sockpeercred cred;
-# else
- struct ucred cred;
-# endif
- socklen_t credsize = sizeof (cred);
-#endif
- MonoError error;
- MonoDomain *domain = mono_domain_get ();
- MonoObject *obj;
- MonoClass *obj_class;
- MonoClassField *field;
-
- *werror = 0;
-
-#if !defined(SO_EXCLUSIVEADDRUSE) && defined(SO_REUSEADDR)
- if (level == SocketOptionLevel_Socket && name == SocketOptionName_ExclusiveAddressUse) {
- system_level = SOL_SOCKET;
- system_name = SO_REUSEADDR;
- ret = 0;
- } else
-#endif
- {
- ret = convert_sockopt_level_and_name ((MonoSocketOptionLevel)level, (MonoSocketOptionName)name, &system_level, &system_name);
- }
-
- if (ret == -1) {
- *werror = WSAENOPROTOOPT;
- return;
- }
- if (ret == -2) {
- *obj_val = int_to_object (domain, 0, &error);
- mono_error_set_pending_exception (&error);
- return;
- }
-
- MONO_ENTER_GC_SAFE;
-
- /* No need to deal with MulticastOption names here, because
- * you cant getsockopt AddMembership or DropMembership (the
- * int getsockopt will error, causing an exception)
- */
- switch (name) {
- case SocketOptionName_Linger:
- case SocketOptionName_DontLinger:
- ret = _wapi_getsockopt (sock, system_level, system_name, &linger, &lingersize);
- break;
-
- case SocketOptionName_SendTimeout:
- case SocketOptionName_ReceiveTimeout:
- ret = _wapi_getsockopt (sock, system_level, system_name, (char *)&time_ms, &time_ms_size);
- break;
-
-#ifdef SO_PEERCRED
- case SocketOptionName_PeerCred:
- ret = _wapi_getsockopt (sock, system_level, system_name, &cred, &credsize);
- break;
-#endif
-
- default:
- ret = _wapi_getsockopt (sock, system_level, system_name, &val, &valsize);
- }
-
- MONO_EXIT_GC_SAFE;
-
- if (ret == SOCKET_ERROR) {
- *werror = WSAGetLastError ();
- return;
- }
-
- switch (name) {
- case SocketOptionName_Linger:
- /* build a System.Net.Sockets.LingerOption */
- obj_class = mono_class_load_from_name (get_socket_assembly (),
- "System.Net.Sockets",
- "LingerOption");
- obj = mono_object_new_checked (domain, obj_class, &error);
- if (!mono_error_ok (&error)) {
- mono_error_set_pending_exception (&error);
- return;
- }
-
- /* Locate and set the fields "bool enabled" and "int
- * lingerTime"
- */
- field = mono_class_get_field_from_name(obj_class, "enabled");
- *(guint8 *)(((char *)obj)+field->offset) = linger.l_onoff;
-
- field = mono_class_get_field_from_name(obj_class, "lingerTime");
- *(guint32 *)(((char *)obj)+field->offset)=linger.l_linger;
- break;
- case SocketOptionName_DontLinger:
- /* construct a bool int in val - true if linger is off */
- obj = int_to_object (domain, !linger.l_onoff, &error);
- mono_error_set_pending_exception (&error);
- break;
- case SocketOptionName_SendTimeout:
- case SocketOptionName_ReceiveTimeout:
- obj = int_to_object (domain, time_ms, &error);
- mono_error_set_pending_exception (&error);
- break;
-
-#ifdef SO_PEERCRED
- case SocketOptionName_PeerCred: {
- /*
- * build a Mono.Posix.PeerCred+PeerCredData if
- * possible
- */
- static MonoImage *mono_posix_image = NULL;
- MonoPeerCredData *cred_data;
-
- if (mono_posix_image == NULL) {
- mono_posix_image = mono_image_loaded ("Mono.Posix");
- if (!mono_posix_image) {
- MonoAssembly *sa = mono_assembly_open ("Mono.Posix.dll", NULL);
- if (!sa) {
- *werror = WSAENOPROTOOPT;
- return;
- } else {
- mono_posix_image = mono_assembly_get_image (sa);
- }
- }
- }
-
- obj_class = mono_class_load_from_name (mono_posix_image,
- "Mono.Posix",
- "PeerCredData");
- obj = mono_object_new_checked (domain, obj_class, &error);
- if (!mono_error_ok (&error)) {
- mono_error_set_pending_exception (&error);
- return;
- }
- cred_data = (MonoPeerCredData *)obj;
- cred_data->pid = cred.pid;
- cred_data->uid = cred.uid;
- cred_data->gid = cred.gid;
- break;
- }
-#endif
-
- default:
-#if !defined(SO_EXCLUSIVEADDRUSE) && defined(SO_REUSEADDR)
- if (level == SocketOptionLevel_Socket && name == SocketOptionName_ExclusiveAddressUse)
- val = val ? 0 : 1;
-#endif
- obj = int_to_object (domain, val, &error);
- mono_error_set_pending_exception (&error);
- }
-
- *obj_val = obj;
-}
-
-void
-ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal (SOCKET sock, gint32 level, gint32 name, MonoArray **byte_val, gint32 *werror)
-{
- int system_level = 0;
- int system_name = 0;
- int ret;
- guchar *buf;
- socklen_t valsize;
-
- *werror = 0;
-
- ret = convert_sockopt_level_and_name((MonoSocketOptionLevel)level, (MonoSocketOptionName)name, &system_level,
- &system_name);
- if (ret == -1) {
- *werror = WSAENOPROTOOPT;
- return;
- }
- if (ret == -2)
- return;
-
- valsize = mono_array_length (*byte_val);
- buf = mono_array_addr (*byte_val, guchar, 0);
-
- MONO_ENTER_GC_SAFE;
-
- ret = _wapi_getsockopt (sock, system_level, system_name, buf, &valsize);
-
- MONO_EXIT_GC_SAFE;
-
- if (ret == SOCKET_ERROR)
- *werror = WSAGetLastError ();
-}
-
-#if defined(HAVE_STRUCT_IP_MREQN) || defined(HAVE_STRUCT_IP_MREQ)
-static struct in_addr
-ipaddress_to_struct_in_addr (MonoObject *ipaddr)
-{
- struct in_addr inaddr;
- MonoClassField *field;
-
- field = mono_class_get_field_from_name (ipaddr->vtable->klass, "m_Address");
-
- /* No idea why .net uses a 64bit type to hold a 32bit value...
- *
- * Internal value of IPAddess is in little-endian order
- */
- inaddr.s_addr = GUINT_FROM_LE ((guint32)*(guint64 *)(((char *)ipaddr) + field->offset));
-
- return inaddr;
-}
-
-static struct in6_addr
-ipaddress_to_struct_in6_addr (MonoObject *ipaddr)
-{
- struct in6_addr in6addr;
- MonoClassField *field;
- MonoArray *data;
- int i;
-
- field = mono_class_get_field_from_name (ipaddr->vtable->klass, "m_Numbers");
- g_assert (field);
- data = *(MonoArray **)(((char *)ipaddr) + field->offset);
-
- for (i = 0; i < 8; i++) {
- const guint16 s = GUINT16_TO_BE (mono_array_get (data, guint16, i));
-
-/* Solaris/MacOS have only the 8 bit version. */
-#ifndef s6_addr16
- in6addr.s6_addr[2 * i + 1] = (s >> 8) & 0xff;
- in6addr.s6_addr[2 * i] = s & 0xff;
-#else
- in6addr.s6_addr16[i] = s;
-#endif
- }
- return in6addr;
-}
-#endif
-
-#if defined(__APPLE__) || defined(__FreeBSD__)
-
-static int
-get_local_interface_id (int family)
-{
-#if !defined(HAVE_GETIFADDRS) || !defined(HAVE_IF_NAMETOINDEX)
- return 0;
-#else
- struct ifaddrs *ifap = NULL, *ptr;
- int idx = 0;
-
- if (getifaddrs (&ifap))
- return 0;
-
- for (ptr = ifap; ptr; ptr = ptr->ifa_next) {
- if (!ptr->ifa_addr || !ptr->ifa_name)
- continue;
- if (ptr->ifa_addr->sa_family != family)
- continue;
- if ((ptr->ifa_flags & IFF_LOOPBACK) != 0)
- continue;
- if ((ptr->ifa_flags & IFF_MULTICAST) == 0)
- continue;
-
- idx = if_nametoindex (ptr->ifa_name);
- break;
- }
-
- freeifaddrs (ifap);
- return idx;
-#endif
-}
-
-#endif /* defined(__APPLE__) || defined(__FreeBSD__) */
-
-void
-ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (SOCKET sock, gint32 level, gint32 name, MonoObject *obj_val, MonoArray *byte_val, gint32 int_val, gint32 *werror)
-{
- struct linger linger;
- int system_level = 0;
- int system_name = 0;
- int ret;
- int sol_ip;
- int sol_ipv6;
-
- *werror = 0;
-
- sol_ipv6 = mono_networking_get_ipv6_protocol ();
- sol_ip = mono_networking_get_ip_protocol ();
-
- ret = convert_sockopt_level_and_name ((MonoSocketOptionLevel)level, (MonoSocketOptionName)name, &system_level,
- &system_name);
-
-#if !defined(SO_EXCLUSIVEADDRUSE) && defined(SO_REUSEADDR)
- if (level == SocketOptionLevel_Socket && name == SocketOptionName_ExclusiveAddressUse) {
- system_name = SO_REUSEADDR;
- int_val = int_val ? 0 : 1;
- ret = 0;
- }
-#endif
-
- if (ret == -1) {
- *werror = WSAENOPROTOOPT;
- return;
- }
- if (ret == -2)
- return;
-
- /* Only one of obj_val, byte_val or int_val has data */
- if (obj_val) {
- MonoClassField *field;
- int valsize;
-
- switch (name) {
- case SocketOptionName_Linger:
- /* Dig out "bool enabled" and "int lingerTime"
- * fields
- */
- field = mono_class_get_field_from_name (obj_val->vtable->klass, "enabled");
- linger.l_onoff = *(guint8 *)(((char *)obj_val) + field->offset);
- field = mono_class_get_field_from_name (obj_val->vtable->klass, "lingerTime");
- linger.l_linger = *(guint32 *)(((char *)obj_val) + field->offset);
-
- valsize = sizeof (linger);
- ret = _wapi_setsockopt (sock, system_level,
- system_name, &linger, valsize);
- break;
- case SocketOptionName_AddMembership:
- case SocketOptionName_DropMembership:
-#if defined(HAVE_STRUCT_IP_MREQN) || defined(HAVE_STRUCT_IP_MREQ)
- {
- MonoObject *address = NULL;
-
- if (system_level == sol_ipv6) {
- struct ipv6_mreq mreq6;
-
- /*
- * Get group address
- */
- field = mono_class_get_field_from_name (obj_val->vtable->klass, "m_Group");
- g_assert (field);
- address = *(MonoObject **)(((char *)obj_val) + field->offset);
-
- if (address)
- mreq6.ipv6mr_multiaddr = ipaddress_to_struct_in6_addr (address);
-
- field = mono_class_get_field_from_name (obj_val->vtable->klass, "m_Interface");
- mreq6.ipv6mr_interface = *(guint64 *)(((char *)obj_val) + field->offset);
-
-#if defined(__APPLE__) || defined(__FreeBSD__)
- /*
- * Bug #5504:
- *
- * Mac OS Lion doesn't allow ipv6mr_interface = 0.
- *
- * Tests on Windows and Linux show that the multicast group is only
- * joined on one NIC when interface = 0, so we simply use the interface
- * id from the first non-loopback interface (this is also what
- * Dns.GetHostName (string.Empty) would return).
- */
- if (!mreq6.ipv6mr_interface)
- mreq6.ipv6mr_interface = get_local_interface_id (AF_INET6);
-#endif
-
- ret = _wapi_setsockopt (sock, system_level,
- system_name, &mreq6,
- sizeof (mreq6));
- } else if (system_level == sol_ip) {
-#ifdef HAVE_STRUCT_IP_MREQN
- struct ip_mreqn mreq = {{0}};
-#else
- struct ip_mreq mreq = {{0}};
-#endif /* HAVE_STRUCT_IP_MREQN */
-
- /*
- * pain! MulticastOption holds two IPAddress
- * members, so I have to dig the value out of
- * those :-(
- */
- field = mono_class_get_field_from_name (obj_val->vtable->klass, "group");
- address = *(MonoObject **)(((char *)obj_val) + field->offset);
-
- /* address might not be defined and if so, set the address to ADDR_ANY.
- */
- if (address)
- mreq.imr_multiaddr = ipaddress_to_struct_in_addr (address);
-
- field = mono_class_get_field_from_name (obj_val->vtable->klass, "localAddress");
- address = *(MonoObject **)(((char *)obj_val) + field->offset);
-
-#ifdef HAVE_STRUCT_IP_MREQN
- if (address)
- mreq.imr_address = ipaddress_to_struct_in_addr (address);
-
- field = mono_class_get_field_from_name (obj_val->vtable->klass, "ifIndex");
- mreq.imr_ifindex = *(gint32 *)(((char *)obj_val) + field->offset);
-#else
- if (address)
- mreq.imr_interface = ipaddress_to_struct_in_addr (address);
-#endif /* HAVE_STRUCT_IP_MREQN */
-
- ret = _wapi_setsockopt (sock, system_level,
- system_name, &mreq,
- sizeof (mreq));
- }
- break;
- }
-#endif /* HAVE_STRUCT_IP_MREQN || HAVE_STRUCT_IP_MREQ */
- default:
- /* Cause an exception to be thrown */
- *werror = WSAEINVAL;
- return;
- }
- } else if (byte_val!=NULL) {
- int valsize = mono_array_length (byte_val);
- guchar *buf = mono_array_addr (byte_val, guchar, 0);
-
- switch(name) {
- case SocketOptionName_DontLinger:
- if (valsize == 1) {
- linger.l_onoff = (*buf) ? 0 : 1;
- linger.l_linger = 0;
- ret = _wapi_setsockopt (sock, system_level, system_name, &linger, sizeof (linger));
- } else {
- *werror = WSAEINVAL;
- }
- break;
- default:
- ret = _wapi_setsockopt (sock, system_level, system_name, buf, valsize);
- break;
- }
- } else {
- /* ReceiveTimeout/SendTimeout get here */
- switch (name) {
- case SocketOptionName_DontLinger:
- linger.l_onoff = !int_val;
- linger.l_linger = 0;
- ret = _wapi_setsockopt (sock, system_level, system_name, &linger, sizeof (linger));
- break;
- case SocketOptionName_MulticastInterface:
-#ifndef HOST_WIN32
-#ifdef HAVE_STRUCT_IP_MREQN
- int_val = GUINT32_FROM_BE (int_val);
- if ((int_val & 0xff000000) == 0) {
- /* int_val is interface index */
- struct ip_mreqn mreq = {{0}};
- mreq.imr_ifindex = int_val;
- ret = _wapi_setsockopt (sock, system_level, system_name, (char *) &mreq, sizeof (mreq));
- break;
- }
- int_val = GUINT32_TO_BE (int_val);
-#endif /* HAVE_STRUCT_IP_MREQN */
-#endif /* HOST_WIN32 */
- /* int_val is in_addr */
- ret = _wapi_setsockopt (sock, system_level, system_name, (char *) &int_val, sizeof (int_val));
- break;
- case SocketOptionName_DontFragment:
-#ifdef HAVE_IP_MTU_DISCOVER
- /* Fiddle with the value slightly if we're
- * turning DF on
- */
- if (int_val == 1)
- int_val = IP_PMTUDISC_DO;
- /* Fall through */
-#endif
-
- default:
- ret = _wapi_setsockopt (sock, system_level, system_name, (char *) &int_val, sizeof (int_val));
- }
- }
-
- if (ret == SOCKET_ERROR)
- *werror = WSAGetLastError ();
-}
-
-void
-ves_icall_System_Net_Sockets_Socket_Shutdown_internal (SOCKET sock, gint32 how, gint32 *werror)
-{
- int ret;
- gboolean interrupted;
-
- *werror = 0;
-
- mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
- if (interrupted) {
- *werror = WSAEINTR;
- return;
- }
-
- MONO_ENTER_GC_SAFE;
-
- /* Currently, the values for how (recv=0, send=1, both=2) match the BSD API */
- ret = _wapi_shutdown (sock, how);
-
- MONO_EXIT_GC_SAFE;
-
- if (ret == SOCKET_ERROR)
- *werror = WSAGetLastError ();
-
- mono_thread_info_uninstall_interrupt (&interrupted);
- if (interrupted) {
- *werror = WSAEINTR;
- }
-
-}
-
-gint
-ves_icall_System_Net_Sockets_Socket_IOControl_internal (SOCKET sock, gint32 code, MonoArray *input, MonoArray *output, gint32 *werror)
-{
- glong output_bytes = 0;
- gchar *i_buffer, *o_buffer;
- gint i_len, o_len;
- gint ret;
-
- *werror = 0;
-
- if ((guint32)code == FIONBIO)
- /* Invalid command. Must use Socket.Blocking */
- return -1;
-
- if (input == NULL) {
- i_buffer = NULL;
- i_len = 0;
- } else {
- i_buffer = mono_array_addr (input, gchar, 0);
- i_len = mono_array_length (input);
- }
-
- if (output == NULL) {
- o_buffer = NULL;
- o_len = 0;
- } else {
- o_buffer = mono_array_addr (output, gchar, 0);
- o_len = mono_array_length (output);
- }
-
- MONO_ENTER_GC_SAFE;
-
- ret = WSAIoctl (sock, code, i_buffer, i_len, o_buffer, o_len, &output_bytes, NULL, NULL);
-
- MONO_EXIT_GC_SAFE;
-
- if (ret == SOCKET_ERROR) {
- *werror = WSAGetLastError ();
- return -1;
- }
-
- return (gint)output_bytes;
-}
-
-static gboolean
-addrinfo_to_IPHostEntry (MonoAddressInfo *info, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gboolean add_local_ips, MonoError *error)
-{
- gint32 count, i;
- MonoAddressEntry *ai = NULL;
- struct in_addr *local_in = NULL;
- int nlocal_in = 0;
- struct in6_addr *local_in6 = NULL;
- int nlocal_in6 = 0;
- int addr_index;
- MonoDomain *domain = mono_domain_get ();
-
- mono_error_init (error);
- addr_index = 0;
- *h_aliases = mono_array_new_checked (domain, mono_get_string_class (), 0, error);
- return_val_if_nok (error, FALSE);
- if (add_local_ips) {
- local_in = (struct in_addr *) mono_get_local_interfaces (AF_INET, &nlocal_in);
- local_in6 = (struct in6_addr *) mono_get_local_interfaces (AF_INET6, &nlocal_in6);
- if (nlocal_in || nlocal_in6) {
- char addr [INET6_ADDRSTRLEN];
- *h_addr_list = mono_array_new_checked (domain, mono_get_string_class (), nlocal_in + nlocal_in6, error);
- if (!is_ok (error))
- goto leave;
-
- if (nlocal_in) {
- MonoString *addr_string;
- int i;
-
- for (i = 0; i < nlocal_in; i++) {
- MonoAddress maddr;
- mono_address_init (&maddr, AF_INET, &local_in [i]);
- if (mono_networking_addr_to_str (&maddr, addr, sizeof (addr))) {
- addr_string = mono_string_new (domain, addr);
- mono_array_setref (*h_addr_list, addr_index, addr_string);
- addr_index++;
- }
- }
- }
-
- if (nlocal_in6) {
- MonoString *addr_string;
- int i;
-
- for (i = 0; i < nlocal_in6; i++) {
- MonoAddress maddr;
- mono_address_init (&maddr, AF_INET6, &local_in6 [i]);
- if (mono_networking_addr_to_str (&maddr, addr, sizeof (addr))) {
- addr_string = mono_string_new (domain, addr);
- mono_array_setref (*h_addr_list, addr_index, addr_string);
- addr_index++;
- }
- }
- }
-
- leave:
- g_free (local_in);
- g_free (local_in6);
- if (info)
- mono_free_address_info (info);
- return is_ok (error);;
- }
-
- g_free (local_in);
- g_free (local_in6);
- }
-
- for (count = 0, ai = info->entries; ai != NULL; ai = ai->next) {
- if (ai->family != AF_INET && ai->family != AF_INET6)
- continue;
- count++;
- }
-
- *h_addr_list = mono_array_new_checked (domain, mono_get_string_class (), count, error);
- if (!is_ok (error))
- goto leave2;
-
- for (ai = info->entries, i = 0; ai != NULL; ai = ai->next) {
- MonoAddress maddr;
- MonoString *addr_string;
- char buffer [INET6_ADDRSTRLEN]; /* Max. size for IPv6 */
-
- if ((ai->family != PF_INET) && (ai->family != PF_INET6))
- continue;
-
- mono_address_init (&maddr, ai->family, &ai->address);
- if (mono_networking_addr_to_str (&maddr, buffer, sizeof (buffer)))
- addr_string = mono_string_new (domain, buffer);
- else
- addr_string = mono_string_new (domain, "");
-
- mono_array_setref (*h_addr_list, addr_index, addr_string);
-
- if (!i) {
- i++;
- if (ai->canonical_name != NULL) {
- *h_name = mono_string_new (domain, ai->canonical_name);
- } else {
- *h_name = mono_string_new (domain, buffer);
- }
- }
-
- addr_index++;
- }
-
-leave2:
- if (info)
- mono_free_address_info (info);
-
- return is_ok (error);
-}
-
-MonoBoolean
-ves_icall_System_Net_Dns_GetHostByName_internal (MonoString *host, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gint32 hint)
-{
- MonoError error;
- gboolean add_local_ips = FALSE, add_info_ok = TRUE;
- gchar this_hostname [256];
- MonoAddressInfo *info = NULL;
-
- char *hostname = mono_string_to_utf8_checked (host, &error);
- if (mono_error_set_pending_exception (&error))
- return FALSE;
-
- if (*hostname == '\0') {
- add_local_ips = TRUE;
- *h_name = host;
- }
-
- if (!add_local_ips && gethostname (this_hostname, sizeof (this_hostname)) != -1) {
- if (!strcmp (hostname, this_hostname)) {
- add_local_ips = TRUE;
- *h_name = host;
- }
- }
-
-#ifdef HOST_WIN32
- // Win32 APIs already returns local interface addresses for empty hostname ("")
- // so we never want to add them manually.
- add_local_ips = FALSE;
- if (mono_get_address_info(hostname, 0, MONO_HINT_CANONICAL_NAME | hint, &info))
- add_info_ok = FALSE;
-#else
- if (*hostname && mono_get_address_info (hostname, 0, MONO_HINT_CANONICAL_NAME | hint, &info))
- add_info_ok = FALSE;
-#endif
-
- g_free(hostname);
-
- if (add_info_ok) {
- MonoBoolean result = addrinfo_to_IPHostEntry (info, h_name, h_aliases, h_addr_list, add_local_ips, &error);
- mono_error_set_pending_exception (&error);
- return result;
- }
- return FALSE;
-}
-
-MonoBoolean
-ves_icall_System_Net_Dns_GetHostByAddr_internal (MonoString *addr, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gint32 hint)
-{
- char *address;
- struct sockaddr_in saddr;
- struct sockaddr_in6 saddr6;
- MonoAddressInfo *info = NULL;
- MonoError error;
- gint32 family;
- gchar hostname [NI_MAXHOST] = { 0 };
- gboolean ret;
-
- address = mono_string_to_utf8_checked (addr, &error);
- if (mono_error_set_pending_exception (&error))
- return FALSE;
-
- if (inet_pton (AF_INET, address, &saddr.sin_addr ) == 1) {
- family = AF_INET;
- saddr.sin_family = AF_INET;
- } else if (inet_pton (AF_INET6, address, &saddr6.sin6_addr) == 1) {
- family = AF_INET6;
- saddr6.sin6_family = AF_INET6;
- } else {
- g_free (address);
- return FALSE;
- }
-
- g_free (address);
-
- MONO_ENTER_GC_SAFE;
-
- switch (family) {
- case AF_INET: {
-#if HAVE_SOCKADDR_IN_SIN_LEN
- saddr.sin_len = sizeof (saddr);
-#endif
- ret = getnameinfo ((struct sockaddr*)&saddr, sizeof (saddr), hostname, sizeof (hostname), NULL, 0, 0) == 0;
- break;
- }
- case AF_INET6: {
-#if HAVE_SOCKADDR_IN6_SIN_LEN
- saddr6.sin6_len = sizeof (saddr6);
-#endif
- ret = getnameinfo ((struct sockaddr*)&saddr6, sizeof (saddr6), hostname, sizeof (hostname), NULL, 0, 0) == 0;
- break;
- }
- default:
- g_assert_not_reached ();
- }
-
- MONO_EXIT_GC_SAFE;
-
- if (!ret)
- return FALSE;
-
- if (mono_get_address_info (hostname, 0, hint | MONO_HINT_CANONICAL_NAME | MONO_HINT_CONFIGURED_ONLY, &info) != 0)
- return FALSE;
-
- MonoBoolean result = addrinfo_to_IPHostEntry (info, h_name, h_aliases, h_addr_list, FALSE, &error);
- mono_error_set_pending_exception (&error);
- return result;
-}
-
-MonoBoolean
-ves_icall_System_Net_Dns_GetHostName_internal (MonoString **h_name)
-{
- gchar hostname [NI_MAXHOST] = { 0 };
- int ret;
-
- ret = gethostname (hostname, sizeof (hostname));
- if (ret == -1)
- return FALSE;
-
- *h_name = mono_string_new (mono_domain_get (), hostname);
-
- return TRUE;
-}
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
-gboolean
-ves_icall_System_Net_Sockets_Socket_SendFile_internal (SOCKET sock, MonoString *filename, MonoArray *pre_buffer, MonoArray *post_buffer, gint flags, gint32 *werror, gboolean blocking)
-{
- HANDLE file;
- gboolean ret;
- gboolean interrupted;
- TRANSMIT_FILE_BUFFERS buffers;
-
- if (filename == NULL)
- return FALSE;
-
- /* FIXME: replace file by a proper fd that we can call open and close on, as they are interruptible */
-
- file = ves_icall_System_IO_MonoIO_Open (filename, FileMode_Open, FileAccess_Read, FileShare_Read, 0, werror);
-
- if (file == INVALID_HANDLE_VALUE) {
- SetLastError (*werror);
- return FALSE;
- }
-
- memset (&buffers, 0, sizeof (buffers));
- if (pre_buffer != NULL) {
- buffers.Head = mono_array_addr (pre_buffer, guchar, 0);
- buffers.HeadLength = mono_array_length (pre_buffer);
- }
- if (post_buffer != NULL) {
- buffers.Tail = mono_array_addr (post_buffer, guchar, 0);
- buffers.TailLength = mono_array_length (post_buffer);
- }
-
- mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
- if (interrupted) {
- CloseHandle (file);
- SetLastError (WSAEINTR);
- return FALSE;
- }
-
- MONO_ENTER_GC_SAFE;
-
-#ifdef HOST_WIN32
- ret = alertable_TransmitFile (sock, file, 0, 0, NULL, &buffers, flags, blocking);
-#else
- ret = TransmitFile (sock, file, 0, 0, NULL, &buffers, flags);
-#endif
-
- MONO_EXIT_GC_SAFE;
-
- if (!ret)
- *werror = WSAGetLastError ();
-
- mono_thread_info_uninstall_interrupt (&interrupted);
- if (interrupted) {
- CloseHandle (file);
- *werror = WSAEINTR;
- return FALSE;
- }
-
- MONO_ENTER_GC_SAFE;
-
- CloseHandle (file);
-
- MONO_EXIT_GC_SAFE;
-
- if (*werror)
- return FALSE;
-
- return ret;
-}
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
-
-gboolean
-ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto)
-{
-#if defined (SO_REUSEPORT) || defined (HOST_WIN32)
- return TRUE;
-#else
-#ifdef __linux__
- /* Linux always supports double binding for UDP, even on older kernels. */
- if (proto == ProtocolType_Udp)
- return TRUE;
-#endif
- return FALSE;
-#endif
-}
-
-void
-mono_network_init (void)
-{
- mono_networking_init ();
-}
-
-void
-mono_network_cleanup (void)
-{
- _wapi_cleanup_networking ();
- mono_networking_shutdown ();
-}
-
-void
-icall_cancel_blocking_socket_operation (MonoThread *thread)
-{
- MonoInternalThread *internal;
-
- internal = thread->internal_thread;
- g_assert (internal);
-
- mono_thread_info_abort_socket_syscall_for_close (MONO_UINT_TO_NATIVE_THREAD_ID (internal->tid));
-}
-
-#endif /* #ifndef DISABLE_SOCKETS */
+++ /dev/null
-/*
- * socket-io.h: Socket IO internal calls
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2001 Ximian, Inc.
- */
-
-#ifndef _MONO_METADATA_SOCKET_H_
-#define _MONO_METADATA_SOCKET_H_
-
-#include <config.h>
-#include <glib.h>
-
-#include <mono/metadata/object-internals.h>
-#include <mono/io-layer/io-layer.h>
-
-/* This is a copy of System.Net.Sockets.SocketType */
-typedef enum {
- SocketType_Stream=1,
- SocketType_Dgram=2,
- SocketType_Raw=3,
- SocketType_Rdm=4,
- SocketType_Seqpacket=5,
- SocketType_Unknown=-1
-} MonoSocketType;
-
-/* This is a copy of System.Net.Sockets.AddressFamily */
-typedef enum {
- AddressFamily_Unknown=-1,
- AddressFamily_Unspecified=0,
- AddressFamily_Unix=1,
- AddressFamily_InterNetwork=2,
- AddressFamily_ImpLink=3,
- AddressFamily_Pup=4,
- AddressFamily_Chaos=5,
- AddressFamily_NS=6,
- AddressFamily_Ipx=6,
- AddressFamily_Iso=7,
- AddressFamily_Osi=7,
- AddressFamily_Ecma=8,
- AddressFamily_DataKit=9,
- AddressFamily_Ccitt=10,
- AddressFamily_Sna=11,
- AddressFamily_DecNet=12,
- AddressFamily_DataLink=13,
- AddressFamily_Lat=14,
- AddressFamily_HyperChannel=15,
- AddressFamily_AppleTalk=16,
- AddressFamily_NetBios=17,
- AddressFamily_VoiceView=18,
- AddressFamily_FireFox=19,
- AddressFamily_Banyan=21,
- AddressFamily_Atm=22,
- AddressFamily_InterNetworkV6=23,
- AddressFamily_Cluster=24,
- AddressFamily_Ieee12844=25,
- AddressFamily_Irda=26,
- AddressFamily_NetworkDesigners=28
-} MonoAddressFamily;
-
-/* This is a copy of System.Net.Sockets.ProtocolType */
-typedef enum {
- ProtocolType_IP=0,
- ProtocolType_Icmp=1,
- ProtocolType_Igmp=2,
- ProtocolType_Ggp=3,
- ProtocolType_Tcp=6,
- ProtocolType_Pup=12,
- ProtocolType_Udp=17,
- ProtocolType_Idp=22,
- ProtocolType_IPv6=41,
- ProtocolType_ND=77,
- ProtocolType_Raw=255,
- ProtocolType_Unspecified=0,
- ProtocolType_Ipx=1000,
- ProtocolType_Spx=1256,
- ProtocolType_SpxII=1257,
- ProtocolType_Unknown=-1
-} MonoProtocolType;
-
-/* This is a copy of System.Net.Sockets.SocketOptionLevel */
-typedef enum {
- SocketOptionLevel_Socket=65535,
- SocketOptionLevel_IP=0,
- SocketOptionLevel_IPv6=41,
- SocketOptionLevel_Tcp=6,
- SocketOptionLevel_Udp=17
-} MonoSocketOptionLevel;
-
-/* This is a copy of System.Net.Sockets.SocketOptionName */
-typedef enum {
- SocketOptionName_Debug=1,
- SocketOptionName_AcceptConnection=2,
- SocketOptionName_ReuseAddress=4,
- SocketOptionName_KeepAlive=8,
- SocketOptionName_DontRoute=16,
- SocketOptionName_IPProtectionLevel = 23,
- SocketOptionName_IPv6Only = 27,
- SocketOptionName_Broadcast=32,
- SocketOptionName_UseLoopback=64,
- SocketOptionName_Linger=128,
- SocketOptionName_OutOfBandInline=256,
- SocketOptionName_DontLinger= -129,
- SocketOptionName_ExclusiveAddressUse= -5,
- SocketOptionName_SendBuffer= 4097,
- SocketOptionName_ReceiveBuffer=4098,
- SocketOptionName_SendLowWater=4099,
- SocketOptionName_ReceiveLowWater=4100,
- SocketOptionName_SendTimeout=4101,
- SocketOptionName_ReceiveTimeout=4102,
- SocketOptionName_Error=4103,
- SocketOptionName_Type=4104,
- SocketOptionName_MaxConnections=2147483647,
- SocketOptionName_IPOptions=1,
- SocketOptionName_HeaderIncluded=2,
- SocketOptionName_TypeOfService=3,
- SocketOptionName_IpTimeToLive=4,
- SocketOptionName_MulticastInterface=9,
- SocketOptionName_MulticastTimeToLive=10,
- SocketOptionName_MulticastLoopback=11,
- SocketOptionName_AddMembership=12,
- SocketOptionName_DropMembership=13,
- SocketOptionName_DontFragment=14,
- SocketOptionName_AddSourceMembership=15,
- SocketOptionName_DropSourceMembership=16,
- SocketOptionName_BlockSource=17,
- SocketOptionName_UnblockSource=18,
- SocketOptionName_PacketInformation=19,
- SocketOptionName_NoDelay=1,
- SocketOptionName_BsdUrgent=2,
- SocketOptionName_Expedited=2,
- SocketOptionName_NoChecksum=1,
- SocketOptionName_ChecksumCoverage=20,
- SocketOptionName_HopLimit=21,
-
- /* This is Mono-specific, keep it in sync with
- * Mono.Posix/PeerCred.cs
- */
- SocketOptionName_PeerCred=10001
-} MonoSocketOptionName;
-
-/* This is a copy of System.Net.Sockets.SocketFlags */
-typedef enum {
- SocketFlags_None = 0x0000,
- SocketFlags_OutOfBand = 0x0001,
- SocketFlags_MaxIOVectorLength = 0x0010,
- SocketFlags_Peek = 0x0002,
- SocketFlags_DontRoute = 0x0004,
- SocketFlags_Partial = 0x8000
-} MonoSocketFlags;
-
-typedef struct
-{
- MonoObject obj;
- gint pid;
- gint uid;
- gint gid;
-} MonoPeerCredData;
-
-extern gpointer ves_icall_System_Net_Sockets_Socket_Socket_internal(MonoObject *this_obj, gint32 family, gint32 type, gint32 proto, gint32 *error);
-extern void ves_icall_System_Net_Sockets_Socket_Close_internal(SOCKET sock, gint32 *error);
-extern gint32 ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal(void);
-extern gint32 ves_icall_System_Net_Sockets_Socket_Available_internal(SOCKET sock, gint32 *error);
-extern void ves_icall_System_Net_Sockets_Socket_Blocking_internal(SOCKET sock, gboolean block, gint32 *error);
-extern gpointer ves_icall_System_Net_Sockets_Socket_Accept_internal(SOCKET sock, gint32 *error, gboolean blocking);
-extern void ves_icall_System_Net_Sockets_Socket_Listen_internal(SOCKET sock, guint32 backlog, gint32 *error);
-extern MonoObject *ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal(SOCKET sock, gint32 af, gint32 *error);
-extern MonoObject *ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal(SOCKET sock, gint32 af, gint32 *error);
-extern void ves_icall_System_Net_Sockets_Socket_Bind_internal(SOCKET sock, MonoObject *sockaddr, gint32 *error);
-extern void ves_icall_System_Net_Sockets_Socket_Connect_internal(SOCKET sock, MonoObject *sockaddr, gint32 *error, gboolean blocking);
-extern gint32 ves_icall_System_Net_Sockets_Socket_Receive_internal(SOCKET sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, gint32 *error, gboolean blocking);
-extern gint32 ves_icall_System_Net_Sockets_Socket_Receive_array_internal(SOCKET sock, MonoArray *buffers, gint32 flags, gint32 *error, gboolean blocking);
-extern gint32 ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal(SOCKET sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, MonoObject **sockaddr, gint32 *error, gboolean blocking);
-extern gint32 ves_icall_System_Net_Sockets_Socket_Send_internal(SOCKET sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, gint32 *error, gboolean blocking);
-extern gint32 ves_icall_System_Net_Sockets_Socket_Send_array_internal(SOCKET sock, MonoArray *buffers, gint32 flags, gint32 *error, gboolean blocking);
-extern gint32 ves_icall_System_Net_Sockets_Socket_SendTo_internal(SOCKET sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, MonoObject *sockaddr, gint32 *error, gboolean blocking);
-extern void ves_icall_System_Net_Sockets_Socket_Select_internal(MonoArray **sockets, gint32 timeout, gint32 *error);
-extern void ves_icall_System_Net_Sockets_Socket_Shutdown_internal(SOCKET sock, gint32 how, gint32 *error);
-extern void ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal(SOCKET sock, gint32 level, gint32 name, MonoObject **obj_val, gint32 *error);
-extern void ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal(SOCKET sock, gint32 level, gint32 name, MonoArray **byte_val, gint32 *error);
-extern void ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal(SOCKET sock, gint32 level, gint32 name, MonoObject *obj_val, MonoArray *byte_val, gint32 int_val, gint32 *error);
-extern int ves_icall_System_Net_Sockets_Socket_IOControl_internal (SOCKET sock, gint32 code, MonoArray *input, MonoArray *output, gint32 *error);
-extern MonoBoolean ves_icall_System_Net_Dns_GetHostByName_internal(MonoString *host, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gint32 hint);
-extern MonoBoolean ves_icall_System_Net_Dns_GetHostByAddr_internal(MonoString *addr, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gint32 hint);
-extern MonoBoolean ves_icall_System_Net_Dns_GetHostName_internal(MonoString **h_name);
-extern MonoBoolean ves_icall_System_Net_Sockets_Socket_Poll_internal (SOCKET sock, gint mode, gint timeout, gint32 *error);
-extern void ves_icall_System_Net_Sockets_Socket_Disconnect_internal(SOCKET sock, MonoBoolean reuse, gint32 *error);
-extern gboolean ves_icall_System_Net_Sockets_Socket_SendFile_internal (SOCKET sock, MonoString *filename, MonoArray *pre_buffer, MonoArray *post_buffer, gint flags, gint32 *error, gboolean blocking);
-void icall_cancel_blocking_socket_operation (MonoThread *thread);
-extern gboolean ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto);
-
-extern void mono_network_init(void);
-extern void mono_network_cleanup(void);
-
-#endif /* _MONO_METADATA_SOCKET_H_ */
#include "mono/metadata/dynamic-image-internals.h"
#include "mono/metadata/dynamic-stream-internals.h"
#include "mono/metadata/object-internals.h"
+#include "mono/metadata/reflection-internals.h"
#include "mono/metadata/sre-internals.h"
#include "mono/metadata/tabledefs.h"
#include "mono/metadata/tokentype.h"
static void encode_type (MonoDynamicImage *assembly, MonoType *type, SigBuffer *buf);
static guint32 mono_image_typedef_or_ref (MonoDynamicImage *assembly, MonoType *type);
-#define mono_type_array_get_and_resolve(array, index, error) mono_reflection_type_get_handle ((MonoReflectionType*)mono_array_get (array, gpointer, index), error)
-
static guint32
mono_image_add_stream_data (MonoDynamicStream *stream, const char *data, guint32 len)
{
}
static void
-encode_reflection_type (MonoDynamicImage *assembly, MonoReflectionType *type, SigBuffer *buf, MonoError *error)
+encode_reflection_type (MonoDynamicImage *assembly, MonoReflectionTypeHandle type, SigBuffer *buf, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;
return;
}
- MonoType *t = mono_reflection_type_get_handle (type, error);
+ MonoType *t = mono_reflection_type_handle_mono_type (type, error);
return_if_nok (error);
encode_type (assembly, t, buf);
}
static void
-encode_custom_modifiers (MonoDynamicImage *assembly, MonoArray *modreq, MonoArray *modopt, SigBuffer *buf, MonoError *error)
+encode_reflection_type_raw (MonoDynamicImage *assembly, MonoReflectionType* type_raw, SigBuffer *buf, MonoError *error)
{
+ HANDLE_FUNCTION_ENTER (); /* FIXME callers of encode_reflection_type_raw should use handles */
+ mono_error_init (error);
+ MONO_HANDLE_DCL (MonoReflectionType, type);
+ encode_reflection_type (assembly, type, buf, error);
+ HANDLE_FUNCTION_RETURN ();
+}
+
+
+static void
+encode_custom_modifiers (MonoDynamicImage *assembly, MonoArrayHandle modreq, MonoArrayHandle modopt, SigBuffer *buf, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER ();
MONO_REQ_GC_UNSAFE_MODE;
int i;
mono_error_init (error);
- if (modreq) {
- for (i = 0; i < mono_array_length (modreq); ++i) {
+ if (!MONO_HANDLE_IS_NULL (modreq)) {
+ for (i = 0; i < mono_array_handle_length (modreq); ++i) {
MonoType *mod = mono_type_array_get_and_resolve (modreq, i, error);
- return_if_nok (error);
+ if (!is_ok (error))
+ goto leave;
sigbuffer_add_byte (buf, MONO_TYPE_CMOD_REQD);
sigbuffer_add_value (buf, mono_image_typedef_or_ref (assembly, mod));
}
}
- if (modopt) {
- for (i = 0; i < mono_array_length (modopt); ++i) {
+ if (!MONO_HANDLE_IS_NULL (modopt)) {
+ for (i = 0; i < mono_array_handle_length (modopt); ++i) {
MonoType *mod = mono_type_array_get_and_resolve (modopt, i, error);
- return_if_nok (error);
+ if (!is_ok (error))
+ goto leave;
sigbuffer_add_byte (buf, MONO_TYPE_CMOD_OPT);
sigbuffer_add_value (buf, mono_image_typedef_or_ref (assembly, mod));
}
}
+leave:
+ HANDLE_FUNCTION_RETURN ();
+}
+
+static void
+encode_custom_modifiers_raw (MonoDynamicImage *assembly, MonoArray *modreq_raw, MonoArray *modopt_raw, SigBuffer *buf, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER (); /* FIXME callers of encode_custom_modifiers_raw should use handles */
+ mono_error_init (error);
+ MONO_HANDLE_DCL (MonoArray, modreq);
+ MONO_HANDLE_DCL (MonoArray, modopt);
+ encode_custom_modifiers (assembly, modreq, modopt, buf, error);
+ HANDLE_FUNCTION_RETURN ();
}
+
#ifndef DISABLE_REFLECTION_EMIT
guint32
mono_dynimage_encode_method_signature (MonoDynamicImage *assembly, MonoMethodSignature *sig)
if (ngparams)
sigbuffer_add_value (&buf, ngparams);
sigbuffer_add_value (&buf, nparams + notypes);
- encode_custom_modifiers (assembly, mb->return_modreq, mb->return_modopt, &buf, error);
+ encode_custom_modifiers_raw (assembly, mb->return_modreq, mb->return_modopt, &buf, error);
if (!is_ok (error))
goto leave;
- encode_reflection_type (assembly, mb->rtype, &buf, error);
+ encode_reflection_type_raw (assembly, mb->rtype, &buf, error);
if (!is_ok (error))
goto leave;
for (i = 0; i < nparams; ++i) {
modreq = mono_array_get (mb->param_modreq, MonoArray*, i);
if (mb->param_modopt && (i < mono_array_length (mb->param_modopt)))
modopt = mono_array_get (mb->param_modopt, MonoArray*, i);
- encode_custom_modifiers (assembly, modreq, modopt, &buf, error);
+ encode_custom_modifiers_raw (assembly, modreq, modopt, &buf, error);
if (!is_ok (error))
goto leave;
pt = mono_array_get (mb->parameters, MonoReflectionType*, i);
- encode_reflection_type (assembly, pt, &buf, error);
+ encode_reflection_type_raw (assembly, pt, &buf, error);
if (!is_ok (error))
goto leave;
}
MonoReflectionType *pt;
pt = mono_array_get (mb->opt_types, MonoReflectionType*, i);
- encode_reflection_type (assembly, pt, &buf, error);
+ encode_reflection_type_raw (assembly, pt, &buf, error);
if (!is_ok (error))
goto leave;
}
if (lb->is_pinned)
sigbuffer_add_value (&buf, MONO_TYPE_PINNED);
- encode_reflection_type (assembly, (MonoReflectionType*)lb->type, &buf, error);
+ encode_reflection_type_raw (assembly, (MonoReflectionType*)lb->type, &buf, error);
if (!is_ok (error)) {
sigbuffer_free (&buf);
return 0;
sigbuffer_init (&buf, 32);
sigbuffer_add_value (&buf, 0x06);
- encode_custom_modifiers (assembly, fb->modreq, fb->modopt, &buf, error);
+ encode_custom_modifiers_raw (assembly, fb->modreq, fb->modopt, &buf, error);
if (!is_ok (error))
goto fail;
/* encode custom attributes before the type */
return token;
klass = mono_class_from_mono_type (type);
+ MonoReflectionTypeBuilderHandle tb = MONO_HANDLE_CAST (MonoReflectionTypeBuilder, mono_class_get_ref_info (klass));
/*
* If it's in the same module and not a generic type parameter:
*/
if ((klass->image == &assembly->image) && (type->type != MONO_TYPE_VAR) &&
(type->type != MONO_TYPE_MVAR)) {
- MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)mono_class_get_ref_info (klass);
- token = MONO_TYPEDEFORREF_TYPEDEF | (tb->table_idx << MONO_TYPEDEFORREF_BITS);
- mono_dynamic_image_register_token (assembly, token, (MonoObject *)mono_class_get_ref_info (klass));
+ token = MONO_TYPEDEFORREF_TYPEDEF | (MONO_HANDLE_GETVAL (tb, table_idx) << MONO_TYPEDEFORREF_BITS);
+ mono_dynamic_image_register_token (assembly, token, MONO_HANDLE_CAST (MonoObject, tb));
return token;
}
token = MONO_TYPEDEFORREF_TYPEREF | (table->next_idx << MONO_TYPEDEFORREF_BITS); /* typeref */
g_hash_table_insert (assembly->typeref, type, GUINT_TO_POINTER(token));
table->next_idx ++;
- mono_dynamic_image_register_token (assembly, token, (MonoObject *)mono_class_get_ref_info (klass));
+ mono_dynamic_image_register_token (assembly, token, MONO_HANDLE_CAST (MonoObject, tb));
return token;
}
}
#ifndef DISABLE_REFLECTION_EMIT
+static gboolean
+encode_sighelper_arg (MonoDynamicImage *assembly, int i, MonoArrayHandle helper_arguments, MonoArrayHandle helper_modreqs, MonoArrayHandle helper_modopts, SigBuffer* buf, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER();
+ mono_error_init (error);
+ MonoArrayHandle modreqs = MONO_HANDLE_NEW (MonoArray, NULL);
+ MonoArrayHandle modopts = MONO_HANDLE_NEW (MonoArray, NULL);
+
+ if (!MONO_HANDLE_IS_NULL (helper_modreqs) && (i < mono_array_handle_length (helper_modreqs)))
+ MONO_HANDLE_ARRAY_GETREF (modreqs, helper_modreqs, i);
+ if (!MONO_HANDLE_IS_NULL (helper_modopts) && (i < mono_array_handle_length (helper_modopts)))
+ MONO_HANDLE_ARRAY_GETREF (modopts, helper_modopts, i);
+
+ encode_custom_modifiers (assembly, modreqs, modopts, buf, error);
+ if (!is_ok (error))
+ goto leave;
+ MonoReflectionTypeHandle pt = MONO_HANDLE_NEW (MonoReflectionType, NULL);
+ MONO_HANDLE_ARRAY_GETREF (pt, helper_arguments, i);
+ encode_reflection_type (assembly, pt, buf, error);
+ if (!is_ok (error))
+ goto leave;
+leave:
+ HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
+}
+
guint32
-mono_dynimage_encode_reflection_sighelper (MonoDynamicImage *assembly, MonoReflectionSigHelper *helper, MonoError *error)
+mono_dynimage_encode_reflection_sighelper (MonoDynamicImage *assembly, MonoReflectionSigHelperHandle helper, MonoError *error)
{
SigBuffer buf;
guint32 nargs;
return 0;
/* FIXME: this means SignatureHelper.SignatureHelpType.HELPER_METHOD */
- g_assert (helper->type == 2);
+ g_assert (MONO_HANDLE_GETVAL (helper, type) == 2);
- if (helper->arguments)
- nargs = mono_array_length (helper->arguments);
+ MonoArrayHandle arguments = MONO_HANDLE_NEW_GET (MonoArray, helper, arguments);
+ if (!MONO_HANDLE_IS_NULL (arguments))
+ nargs = mono_array_handle_length (arguments);
else
nargs = 0;
/* Encode calling convention */
/* Change Any to Standard */
- if ((helper->call_conv & 0x03) == 0x03)
- helper->call_conv = 0x01;
+ if ((MONO_HANDLE_GETVAL (helper, call_conv) & 0x03) == 0x03)
+ MONO_HANDLE_SETVAL (helper, call_conv, guint32, 0x01);
/* explicit_this implies has_this */
- if (helper->call_conv & 0x40)
- helper->call_conv &= 0x20;
+ if (MONO_HANDLE_GETVAL (helper, call_conv) & 0x40)
+ MONO_HANDLE_SETVAL (helper, call_conv, guint32, MONO_HANDLE_GETVAL (helper, call_conv) & 0x20);
- if (helper->call_conv == 0) { /* Unmanaged */
- idx = helper->unmanaged_call_conv - 1;
+ if (MONO_HANDLE_GETVAL (helper, call_conv) == 0) { /* Unmanaged */
+ idx = MONO_HANDLE_GETVAL (helper, unmanaged_call_conv) - 1;
} else {
/* Managed */
- idx = helper->call_conv & 0x60; /* has_this + explicit_this */
- if (helper->call_conv & 0x02) /* varargs */
+ idx = MONO_HANDLE_GETVAL (helper, call_conv) & 0x60; /* has_this + explicit_this */
+ if (MONO_HANDLE_GETVAL (helper, call_conv) & 0x02) /* varargs */
idx += 0x05;
}
sigbuffer_add_byte (&buf, idx);
sigbuffer_add_value (&buf, nargs);
- encode_reflection_type (assembly, helper->return_type, &buf, error);
+ encode_reflection_type (assembly, MONO_HANDLE_NEW_GET (MonoReflectionType, helper, return_type), &buf, error);
if (!is_ok (error))
goto fail;
+ MonoArrayHandle modreqs = MONO_HANDLE_NEW_GET (MonoArray, helper, modreqs);
+ MonoArrayHandle modopts = MONO_HANDLE_NEW_GET (MonoArray, helper, modopts);
for (i = 0; i < nargs; ++i) {
- MonoArray *modreqs = NULL;
- MonoArray *modopts = NULL;
- MonoReflectionType *pt;
-
- if (helper->modreqs && (i < mono_array_length (helper->modreqs)))
- modreqs = mono_array_get (helper->modreqs, MonoArray*, i);
- if (helper->modopts && (i < mono_array_length (helper->modopts)))
- modopts = mono_array_get (helper->modopts, MonoArray*, i);
-
- encode_custom_modifiers (assembly, modreqs, modopts, &buf, error);
- if (!is_ok (error))
- goto fail;
- pt = mono_array_get (helper->arguments, MonoReflectionType*, i);
- encode_reflection_type (assembly, pt, &buf, error);
- if (!is_ok (error))
+ if (!encode_sighelper_arg (assembly, i, arguments, modreqs, modopts, &buf, error))
goto fail;
}
idx = sigbuffer_add_to_blob_cached (assembly, &buf);
}
#else /* DISABLE_REFLECTION_EMIT */
guint32
-mono_dynimage_encode_reflection_sighelper (MonoDynamicImage *assembly, MonoReflectionSigHelper *helper, MonoError *error)
+mono_dynimage_encode_reflection_sighelper (MonoDynamicImage *assembly, MonoReflectionSigHelperHandle helper, MonoError *error)
{
g_assert_not_reached ();
return 0;
if (assembly != NULL){
for (i = 0; i < na; ++i) {
MonoReflectionType *type = mono_array_get (sig->arguments, MonoReflectionType*, i);
- encode_reflection_type (assembly, type, &buf, error);
+ encode_reflection_type_raw (assembly, type, &buf, error);
if (!is_ok (error)) goto fail;
}
}
sigbuffer_add_value (&buf, 0x06);
for (i = 0; i < na; ++i) {
MonoReflectionType *type = mono_array_get (sig->arguments, MonoReflectionType*, i);
- encode_reflection_type (assembly, type, &buf, error);
+ encode_reflection_type_raw (assembly, type, &buf, error);
if (!is_ok (error))
goto fail;
}
sigbuffer_add_byte (&buf, 0x08);
sigbuffer_add_value (&buf, nparams);
if (mb) {
- encode_reflection_type (assembly, (MonoReflectionType*)mb->rtype, &buf, error);
+ encode_reflection_type_raw (assembly, (MonoReflectionType*)mb->rtype, &buf, error);
if (!is_ok (error))
goto fail;
for (i = 0; i < nparams; ++i) {
MonoReflectionType *pt = mono_array_get (mb->parameters, MonoReflectionType*, i);
- encode_reflection_type (assembly, pt, &buf, error);
+ encode_reflection_type_raw (assembly, pt, &buf, error);
if (!is_ok (error))
goto fail;
}
} else if (smb && smb->parameters) {
/* the property type is the last param */
- encode_reflection_type (assembly, mono_array_get (smb->parameters, MonoReflectionType*, nparams), &buf, error);
+ encode_reflection_type_raw (assembly, mono_array_get (smb->parameters, MonoReflectionType*, nparams), &buf, error);
if (!is_ok (error))
goto fail;
for (i = 0; i < nparams; ++i) {
MonoReflectionType *pt = mono_array_get (smb->parameters, MonoReflectionType*, i);
- encode_reflection_type (assembly, pt, &buf, error);
+ encode_reflection_type_raw (assembly, pt, &buf, error);
if (!is_ok (error))
goto fail;
}
} else {
- encode_reflection_type (assembly, (MonoReflectionType*)fb->type, &buf, error);
+ encode_reflection_type_raw (assembly, (MonoReflectionType*)fb->type, &buf, error);
if (!is_ok (error))
goto fail;
}
/* for PInvoke */
int charset, extra_flags, native_cc;
MonoString *dll, *dllentry;
-} ReflectionMethodBuilder;
+} ReflectionMethodBuilder; /* FIXME raw pointers to managed objects */
void
mono_reflection_emit_init (void);
gpointer
mono_reflection_resolve_object (MonoImage *image, MonoObject *obj, MonoClass **handle_class, MonoGenericContext *context, MonoError *error);
+MonoType* mono_type_array_get_and_resolve (MonoArrayHandle array, int idx, MonoError* error);
+
void
mono_sre_array_method_free (ArrayMethod *am);
mono_dynimage_encode_typedef_or_ref_full (MonoDynamicImage *assembly, MonoType *type, gboolean try_typespec);
guint32
-mono_dynimage_encode_reflection_sighelper (MonoDynamicImage *assembly, MonoReflectionSigHelper *helper,
+mono_dynimage_encode_reflection_sighelper (MonoDynamicImage *assembly, MonoReflectionSigHelperHandle helper,
MonoError *error);
/* sre-encode, without DISABLE_REFLECTION_EMIT_SAVE (o.w. g_assert_not_reached ()) */
#include "mono/metadata/security-manager.h"
#include "mono/metadata/tabledefs.h"
#include "mono/metadata/tokentype.h"
+#include "mono/metadata/w32file.h"
+#include "mono/metadata/w32error.h"
#include "mono/utils/checked-build.h"
#include "mono/utils/mono-digest.h"
#include "mono/utils/mono-error-internals.h"
-
-#include "mono/io-layer/io-layer.h"
+#include "mono/utils/w32api.h"
#define TEXT_OFFSET 512
#define CLI_H_SIZE 136
return idx;
}
+static guint32
+image_create_token_raw (MonoDynamicImage *assembly, MonoObject* obj_raw, gboolean create_methodspec, gboolean register_token, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER (); /* FIXME callers of image_create_token_raw should use handles */
+ mono_error_init (error);
+ MONO_HANDLE_DCL (MonoObject, obj);
+ guint32 result = mono_image_create_token (assembly, obj, create_methodspec, register_token, error);
+ HANDLE_FUNCTION_RETURN_VAL (result);
+}
+
+
/*
* idx is the table index of the object
* type is one of MONO_CUSTOM_ATTR_*
for (i = 0; i < count; ++i) {
cattr = (MonoReflectionCustomAttr*)mono_array_get (cattrs, gpointer, i);
values [MONO_CUSTOM_ATTR_PARENT] = idx;
- token = mono_image_create_token (assembly, (MonoObject*)cattr->ctor, FALSE, FALSE, error);
+ token = image_create_token_raw (assembly, (MonoObject*)cattr->ctor, FALSE, FALSE, error); /* FIXME use handles */
if (!mono_error_ok (error)) goto fail;
type = mono_metadata_token_index (token);
type <<= MONO_CUSTOM_ATTR_TYPE_BITS;
values [MONO_METHODIMPL_CLASS] = tb->table_idx;
values [MONO_METHODIMPL_BODY] = MONO_METHODDEFORREF_METHODDEF | (mb->table_idx << MONO_METHODDEFORREF_BITS);
- tok = mono_image_create_token (assembly, (MonoObject*)m, FALSE, FALSE, error);
+ tok = image_create_token_raw (assembly, (MonoObject*)m, FALSE, FALSE, error); /* FIXME use handles */
return_val_if_nok (error, FALSE);
switch (mono_metadata_token_table (tok)) {
g_assert_not_reached ();
} else if (!strcmp (iltoken->member->vtable->klass->name, "RuntimeType")) {
MonoClass *k = mono_class_from_mono_type (((MonoReflectionType*)iltoken->member)->type);
- MonoObject *obj = mono_class_get_ref_info (k);
+ MonoObject *obj = mono_class_get_ref_info_raw (k); /* FIXME use handles */
g_assert (obj);
- g_assert (!strcmp (obj->vtable->klass->name, "TypeBuilder"));
+ g_assert (!strcmp (mono_object_class (obj)->name, "TypeBuilder"));
tb = (MonoReflectionTypeBuilder*)obj;
idx = tb->table_idx;
} else {
checked_write_file (HANDLE f, gconstpointer buffer, guint32 numbytes)
{
guint32 dummy;
- if (!WriteFile (f, buffer, numbytes, &dummy, NULL))
- g_error ("WriteFile returned %d\n", GetLastError ());
+ if (!mono_w32file_write (f, buffer, numbytes, &dummy))
+ g_error ("mono_w32file_write returned %d\n", mono_w32error_get_last ());
}
/*
if (!assembly->sections [i].size)
continue;
- if (SetFilePointer (file, assembly->sections [i].offset, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
- g_error ("SetFilePointer returned %d\n", GetLastError ());
+ if (mono_w32file_seek (file, assembly->sections [i].offset, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
+ g_error ("mono_w32file_seek returned %d\n", mono_w32error_get_last ());
switch (i) {
case MONO_SECTION_TEXT:
}
/* check that the file is properly padded */
- if (SetFilePointer (file, file_offset, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
- g_error ("SetFilePointer returned %d\n", GetLastError ());
- if (! SetEndOfFile (file))
- g_error ("SetEndOfFile returned %d\n", GetLastError ());
+ if (mono_w32file_seek (file, file_offset, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
+ g_error ("mono_w32file_seek returned %d\n", mono_w32error_get_last ());
+ if (! mono_w32file_truncate (file))
+ g_error ("mono_w32file_truncate returned %d\n", mono_w32error_get_last ());
mono_dynamic_stream_reset (&assembly->code);
mono_dynamic_stream_reset (&assembly->us);
#include "mono/metadata/tokentype.h"
#include "mono/utils/checked-build.h"
#include "mono/utils/mono-digest.h"
-#include "mono/io-layer/io-layer.h"
+#include "mono/utils/w32api.h"
-static GENERATE_GET_CLASS_WITH_CACHE (marshal_as_attribute, System.Runtime.InteropServices, MarshalAsAttribute);
-static GENERATE_GET_CLASS_WITH_CACHE (module_builder, System.Reflection.Emit, ModuleBuilder);
+static GENERATE_GET_CLASS_WITH_CACHE (marshal_as_attribute, "System.Runtime.InteropServices", "MarshalAsAttribute");
+static GENERATE_GET_CLASS_WITH_CACHE (module_builder, "System.Reflection.Emit", "ModuleBuilder");
+
+static char* string_to_utf8_image_raw (MonoImage *image, MonoString *s, MonoError *error);
#ifndef DISABLE_REFLECTION_EMIT
static guint32 mono_image_get_methodref_token (MonoDynamicImage *assembly, MonoMethod *method, gboolean create_typespec);
-static guint32 mono_image_get_sighelper_token (MonoDynamicImage *assembly, MonoReflectionSigHelper *helper, MonoError *error);
+static guint32 mono_image_get_sighelper_token (MonoDynamicImage *assembly, MonoReflectionSigHelperHandle helper, MonoError *error);
static gboolean ensure_runtime_vtable (MonoClass *klass, MonoError *error);
static void reflection_methodbuilder_from_dynamic_method (ReflectionMethodBuilder *rmb, MonoReflectionDynamicMethod *mb);
-static gboolean reflection_setup_internal_class (MonoReflectionTypeBuilder *tb, MonoError *error);
-static gboolean reflection_create_generic_class (MonoReflectionTypeBuilder *tb, MonoError *error);
+static gboolean reflection_setup_internal_class (MonoReflectionTypeBuilderHandle tb, MonoError *error);
+static gboolean reflection_create_generic_class (MonoReflectionTypeBuilderHandle tb, MonoError *error);
static gpointer register_assembly (MonoDomain *domain, MonoReflectionAssembly *res, MonoAssembly *assembly);
#endif
static char* type_get_qualified_name (MonoType *type, MonoAssembly *ass);
-static MonoReflectionType *mono_reflection_type_get_underlying_system_type (MonoReflectionType* t, MonoError *error);
+static MonoReflectionTypeHandle mono_reflection_type_get_underlying_system_type (MonoReflectionTypeHandle t, MonoError *error);
static gboolean is_sre_array (MonoClass *klass);
static gboolean is_sre_byref (MonoClass *klass);
static gboolean is_sre_pointer (MonoClass *klass);
static guint32 mono_image_get_methodspec_token (MonoDynamicImage *assembly, MonoMethod *method);
static guint32 mono_image_get_inflated_method_token (MonoDynamicImage *assembly, MonoMethod *m);
+static guint32 mono_image_create_method_token (MonoDynamicImage *assembly, MonoObjectHandle obj, MonoArrayHandle opt_param_types, MonoError *error);
-#define mono_type_array_get_and_resolve(array, index, error) mono_reflection_type_get_handle ((MonoReflectionType*)mono_array_get (array, gpointer, index), error)
-static void mono_image_module_basic_init (MonoReflectionModuleBuilder *module);
+#ifndef DISABLE_REFLECTION_EMIT
+static MonoType* mono_type_array_get_and_resolve_raw (MonoArray* array, int idx, MonoError* error);
+#endif
+
+static gboolean mono_image_module_basic_init (MonoReflectionModuleBuilderHandle module, MonoError *error);
void
mono_reflection_emit_init (void)
mono_dynamic_images_init ();
}
+char*
+string_to_utf8_image_raw (MonoImage *image, MonoString *s_raw, MonoError *error)
+{
+ /* FIXME all callers to string_to_utf8_image_raw should use handles */
+ HANDLE_FUNCTION_ENTER ();
+ char* result = NULL;
+ mono_error_init (error);
+ MONO_HANDLE_DCL (MonoString, s);
+ result = mono_string_to_utf8_image (image, s, error);
+ HANDLE_FUNCTION_RETURN_VAL (result);
+}
+
static char*
type_get_fully_qualified_name (MonoType *type)
{
#ifndef DISABLE_REFLECTION_EMIT
static guint32
-mono_image_get_fieldref_token (MonoDynamicImage *assembly, MonoObject *f, MonoClassField *field)
+mono_image_get_fieldref_token (MonoDynamicImage *assembly, MonoObjectHandle f, MonoClassField *field)
{
MonoType *type;
guint32 token;
g_assert (field);
g_assert (field->parent);
- token = GPOINTER_TO_UINT (mono_g_hash_table_lookup (assembly->handleref_managed, f));
+ token = GPOINTER_TO_UINT (mono_g_hash_table_lookup (assembly->handleref_managed, MONO_HANDLE_RAW (f)));
if (token)
return token;
token = mono_image_get_memberref_token (assembly, &field->parent->byval_arg,
mono_field_get_name (field),
mono_dynimage_encode_fieldref_signature (assembly, field->parent->image, type));
- mono_g_hash_table_insert (assembly->handleref_managed, f, GUINT_TO_POINTER(token));
+ mono_g_hash_table_insert (assembly->handleref_managed, MONO_HANDLE_RAW (f), GUINT_TO_POINTER(token));
return token;
}
}
static guint32
-mono_image_get_sighelper_token (MonoDynamicImage *assembly, MonoReflectionSigHelper *helper, MonoError *error)
+mono_image_get_sighelper_token (MonoDynamicImage *assembly, MonoReflectionSigHelperHandle helper, MonoError *error)
{
guint32 idx;
MonoDynamicTable *table;
#ifndef DISABLE_REFLECTION_EMIT
static guint32
-mono_image_get_array_token (MonoDynamicImage *assembly, MonoReflectionArrayMethod *m, MonoError *error)
+mono_image_get_array_token (MonoDynamicImage *assembly, MonoReflectionArrayMethodHandle m, MonoError *error)
{
- guint32 nparams, i;
- GList *tmp;
+ MonoMethodSignature *sig = NULL;
char *name = NULL;
- MonoMethodSignature *sig;
- ArrayMethod *am = NULL;
- MonoType *mtype;
mono_error_init (error);
- nparams = mono_array_length (m->parameters);
+ MonoArrayHandle parameters = MONO_HANDLE_NEW_GET (MonoArray, m, parameters);
+ guint32 nparams = mono_array_handle_length (parameters);
sig = (MonoMethodSignature *)g_malloc0 (MONO_SIZEOF_METHOD_SIGNATURE + sizeof (MonoType*) * nparams);
sig->hasthis = 1;
sig->sentinelpos = -1;
- sig->call_convention = reflection_cc_to_file (m->call_conv);
+ sig->call_convention = reflection_cc_to_file (MONO_HANDLE_GETVAL (m, call_conv));
sig->param_count = nparams;
- if (m->ret) {
- sig->ret = mono_reflection_type_get_handle (m->ret, error);
+ MonoReflectionTypeHandle ret = MONO_HANDLE_NEW_GET (MonoReflectionType, m, ret);
+ if (!MONO_HANDLE_IS_NULL (ret)) {
+ sig->ret = mono_reflection_type_handle_mono_type (ret, error);
if (!is_ok (error))
goto fail;
} else
sig->ret = &mono_defaults.void_class->byval_arg;
- mtype = mono_reflection_type_get_handle (m->parent, error);
+ MonoReflectionTypeHandle parent = MONO_HANDLE_NEW_GET (MonoReflectionType, m, parent);
+ MonoType *mtype = mono_reflection_type_handle_mono_type (parent, error);
if (!is_ok (error))
goto fail;
- for (i = 0; i < nparams; ++i) {
- sig->params [i] = mono_type_array_get_and_resolve (m->parameters, i, error);
+ for (int i = 0; i < nparams; ++i) {
+ sig->params [i] = mono_type_array_get_and_resolve (parameters, i, error);
if (!is_ok (error))
goto fail;
}
- name = mono_string_to_utf8_checked (m->name, error);
+ MonoStringHandle mname = MONO_HANDLE_NEW_GET (MonoString, m, name);
+ name = mono_string_handle_to_utf8 (mname, error);
if (!is_ok (error))
goto fail;
- for (tmp = assembly->array_methods; tmp; tmp = tmp->next) {
+
+ ArrayMethod *am = NULL;
+ for (GList *tmp = assembly->array_methods; tmp; tmp = tmp->next) {
am = (ArrayMethod *)tmp->data;
if (strcmp (name, am->name) == 0 &&
mono_metadata_type_equal (am->parent, mtype) &&
mono_metadata_signature_equal (am->sig, sig)) {
g_free (name);
g_free (sig);
- m->table_idx = am->token & 0xffffff;
+ MONO_HANDLE_SETVAL (m, table_idx, guint32, am->token & 0xffffff);
return am->token;
}
}
am->token = mono_image_get_memberref_token (assembly, am->parent, name,
mono_dynimage_encode_method_signature (assembly, sig));
assembly->array_methods = g_list_prepend (assembly->array_methods, am);
- m->table_idx = am->token & 0xffffff;
+ MONO_HANDLE_SETVAL (m, table_idx, guint32, am->token & 0xffffff);
return am->token;
fail:
- g_free (am);
g_free (name);
g_free (sig);
return 0;
* Insert @str into the user string stream of @module.
*/
guint32
-mono_image_insert_string (MonoReflectionModuleBuilder *module, MonoString *str)
+mono_image_insert_string (MonoReflectionModuleBuilderHandle ref_module, MonoStringHandle str, MonoError *error)
{
- MonoDynamicImage *assembly;
+ HANDLE_FUNCTION_ENTER ();
guint32 idx;
char buf [16];
char *b = buf;
-
- if (!module->dynamic_image)
- mono_image_module_basic_init (module);
+ guint32 token = 0;
+
+ MonoDynamicImage *assembly = MONO_HANDLE_GETVAL (ref_module, dynamic_image);
+ if (!assembly) {
+ if (!mono_image_module_basic_init (ref_module, error))
+ goto leave;
+
+ assembly = MONO_HANDLE_GETVAL (ref_module, dynamic_image);
+ }
+ g_assert (assembly != NULL);
- assembly = module->dynamic_image;
-
if (assembly->save) {
- mono_metadata_encode_value (1 | (str->length * 2), b, &b);
+ int32_t length = mono_string_length (MONO_HANDLE_RAW (str));
+ mono_metadata_encode_value (1 | (length * 2), b, &b);
idx = mono_image_add_stream_data (&assembly->us, buf, b-buf);
+ /* pinned */
+ uint32_t gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, str), TRUE);
+ const char *p = (const char*)mono_string_chars (MONO_HANDLE_RAW (str));
#if G_BYTE_ORDER != G_LITTLE_ENDIAN
{
- char *swapped = g_malloc (2 * mono_string_length (str));
- const char *p = (const char*)mono_string_chars (str);
+ char *swapped = g_malloc (2 * length);
- swap_with_size (swapped, p, 2, mono_string_length (str));
- mono_image_add_stream_data (&assembly->us, swapped, str->length * 2);
+ swap_with_size (swapped, p, 2, length);
+ mono_image_add_stream_data (&assembly->us, swapped, length * 2);
g_free (swapped);
}
#else
- mono_image_add_stream_data (&assembly->us, (const char*)mono_string_chars (str), str->length * 2);
+ mono_image_add_stream_data (&assembly->us, p, length * 2);
#endif
+ mono_gchandle_free (gchandle);
mono_image_add_stream_data (&assembly->us, "", 1);
} else {
idx = assembly->us.index ++;
}
- mono_dynamic_image_register_token (assembly, MONO_TOKEN_STRING | idx, (MonoObject*)str);
+ token = MONO_TOKEN_STRING | idx;
+ mono_dynamic_image_register_token (assembly, token, MONO_HANDLE_CAST (MonoObject, str));
- return MONO_TOKEN_STRING | idx;
+leave:
+ HANDLE_FUNCTION_RETURN_VAL (token);
}
-guint32
-mono_image_create_method_token (MonoDynamicImage *assembly, MonoObject *obj, MonoArray *opt_param_types, MonoError *error)
+static guint32
+create_method_token (MonoDynamicImage *assembly, MonoMethod *method, MonoArrayHandle opt_param_types, MonoError *error)
{
- MonoClass *klass;
- guint32 token = 0;
- MonoMethodSignature *sig;
+ guint32 sig_token, parent;
- mono_error_init (error);
-
- klass = obj->vtable->klass;
- if (strcmp (klass->name, "MonoMethod") == 0 || strcmp (klass->name, "MonoCMethod") == 0) {
- MonoMethod *method = ((MonoReflectionMethod *)obj)->method;
- MonoMethodSignature *old;
- guint32 sig_token, parent;
- int nargs, i;
- g_assert (opt_param_types && (mono_method_signature (method)->sentinelpos >= 0));
+ int nargs = mono_array_handle_length (opt_param_types);
+ MonoMethodSignature *old = mono_method_signature (method);
+ MonoMethodSignature *sig = mono_metadata_signature_alloc ( &assembly->image, old->param_count + nargs);
- nargs = mono_array_length (opt_param_types);
- old = mono_method_signature (method);
- sig = mono_metadata_signature_alloc ( &assembly->image, old->param_count + nargs);
-
- sig->hasthis = old->hasthis;
- sig->explicit_this = old->explicit_this;
- sig->call_convention = old->call_convention;
- sig->generic_param_count = old->generic_param_count;
- sig->param_count = old->param_count + nargs;
- sig->sentinelpos = old->param_count;
- sig->ret = old->ret;
-
- for (i = 0; i < old->param_count; i++)
- sig->params [i] = old->params [i];
-
- for (i = 0; i < nargs; i++) {
- MonoReflectionType *rt = mono_array_get (opt_param_types, MonoReflectionType *, i);
- sig->params [old->param_count + i] = mono_reflection_type_get_handle (rt, error);
- if (!is_ok (error)) goto fail;
- }
+ sig->hasthis = old->hasthis;
+ sig->explicit_this = old->explicit_this;
+ sig->call_convention = old->call_convention;
+ sig->generic_param_count = old->generic_param_count;
+ sig->param_count = old->param_count + nargs;
+ sig->sentinelpos = old->param_count;
+ sig->ret = old->ret;
- parent = mono_image_typedef_or_ref (assembly, &method->klass->byval_arg);
- g_assert ((parent & MONO_TYPEDEFORREF_MASK) == MONO_MEMBERREF_PARENT_TYPEREF);
- parent >>= MONO_TYPEDEFORREF_BITS;
+ for (int i = 0; i < old->param_count; i++)
+ sig->params [i] = old->params [i];
- parent <<= MONO_MEMBERREF_PARENT_BITS;
- parent |= MONO_MEMBERREF_PARENT_TYPEREF;
+ MonoReflectionTypeHandle rt = MONO_HANDLE_NEW (MonoReflectionType, NULL);
+ for (int i = 0; i < nargs; i++) {
+ MONO_HANDLE_ARRAY_GETREF (rt, opt_param_types, i);
+ sig->params [old->param_count + i] = mono_reflection_type_handle_mono_type (rt, error);
+ if (!is_ok (error)) goto fail;
+ }
- sig_token = mono_dynimage_encode_method_signature (assembly, sig);
- token = mono_image_get_varargs_method_token (assembly, parent, method->name, sig_token);
- } else if (strcmp (klass->name, "MethodBuilder") == 0) {
- MonoReflectionMethodBuilder *mb = (MonoReflectionMethodBuilder *)obj;
- ReflectionMethodBuilder rmb;
- guint32 parent, sig_token;
- int nopt_args, nparams, ngparams, i;
+ parent = mono_image_typedef_or_ref (assembly, &method->klass->byval_arg);
+ g_assert ((parent & MONO_TYPEDEFORREF_MASK) == MONO_MEMBERREF_PARENT_TYPEREF);
+ parent >>= MONO_TYPEDEFORREF_BITS;
- if (!mono_reflection_methodbuilder_from_method_builder (&rmb, mb, error))
- goto fail;
-
- rmb.opt_types = opt_param_types;
- nopt_args = mono_array_length (opt_param_types);
-
- nparams = rmb.parameters ? mono_array_length (rmb.parameters): 0;
- ngparams = rmb.generic_params ? mono_array_length (rmb.generic_params): 0;
- sig = mono_metadata_signature_alloc (&assembly->image, nparams + nopt_args);
-
- sig->hasthis = !(rmb.attrs & METHOD_ATTRIBUTE_STATIC);
- sig->explicit_this = (rmb.call_conv & 0x40) == 0x40;
- sig->call_convention = rmb.call_conv;
- sig->generic_param_count = ngparams;
- sig->param_count = nparams + nopt_args;
- sig->sentinelpos = nparams;
- sig->ret = mono_reflection_type_get_handle (rmb.rtype, error);
- if (!is_ok (error)) goto fail;
+ parent <<= MONO_MEMBERREF_PARENT_BITS;
+ parent |= MONO_MEMBERREF_PARENT_TYPEREF;
- for (i = 0; i < nparams; i++) {
- MonoReflectionType *rt = mono_array_get (rmb.parameters, MonoReflectionType *, i);
- sig->params [i] = mono_reflection_type_get_handle (rt, error);
- if (!is_ok (error)) goto fail;
- }
+ sig_token = mono_dynimage_encode_method_signature (assembly, sig);
+ guint32 token = mono_image_get_varargs_method_token (assembly, parent, method->name, sig_token);
+ g_hash_table_insert (assembly->vararg_aux_hash, GUINT_TO_POINTER (token), sig);
+ return token;
+fail:
+ return 0;
+}
- for (i = 0; i < nopt_args; i++) {
- MonoReflectionType *rt = mono_array_get (opt_param_types, MonoReflectionType *, i);
- sig->params [nparams + i] = mono_reflection_type_get_handle (rt, error);
- if (!is_ok (error)) goto fail;
- }
+guint32
+mono_image_create_method_token (MonoDynamicImage *assembly, MonoObjectHandle obj, MonoArrayHandle opt_param_types, MonoError *error)
+{
+ guint32 token = 0;
- // FIXME: This doesn't work, we don't use 'sig' for anything
- // The token fixup doesn't work either
- g_assert_not_reached ();
+ mono_error_init (error);
- sig_token = mono_dynimage_encode_method_builder_signature (assembly, &rmb, error);
+ MonoClass *klass = mono_handle_class (obj);
+ if (strcmp (klass->name, "MonoMethod") == 0 || strcmp (klass->name, "MonoCMethod") == 0) {
+ MonoReflectionMethodHandle ref_method = MONO_HANDLE_CAST (MonoReflectionMethod, obj);
+ MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
+ g_assert (!MONO_HANDLE_IS_NULL (opt_param_types) && (mono_method_signature (method)->sentinelpos >= 0));
+ token = create_method_token (assembly, method, opt_param_types, error);
if (!is_ok (error))
goto fail;
-
- parent = mono_image_create_token (assembly, obj, TRUE, TRUE, error);
- if (!mono_error_ok (error))
- goto fail;
- g_assert (mono_metadata_token_table (parent) == MONO_TABLE_METHOD);
-
- parent = mono_metadata_token_index (parent) << MONO_MEMBERREF_PARENT_BITS;
- parent |= MONO_MEMBERREF_PARENT_METHODDEF;
-
- char *name = mono_string_to_utf8_checked (rmb.name, error);
- if (!is_ok (error)) goto fail;
- token = mono_image_get_varargs_method_token (
- assembly, parent, name, sig_token);
- g_free (name);
+ } else if (strcmp (klass->name, "MethodBuilder") == 0) {
+ g_assert_not_reached ();
} else {
g_error ("requested method token for %s\n", klass->name);
}
- g_hash_table_insert (assembly->vararg_aux_hash, GUINT_TO_POINTER (token), sig);
mono_dynamic_image_register_token (assembly, token, obj);
return token;
fail:
* entry.
*/
guint32
-mono_image_create_token (MonoDynamicImage *assembly, MonoObject *obj,
+mono_image_create_token (MonoDynamicImage *assembly, MonoObjectHandle obj,
gboolean create_open_instance, gboolean register_token,
MonoError *error)
{
- MonoClass *klass;
guint32 token = 0;
mono_error_init (error);
- klass = obj->vtable->klass;
+ MonoClass *klass = mono_handle_class (obj);
/* Check for user defined reflection objects */
/* TypeDelegator is the only corlib type which doesn't look like a MonoReflectionType */
}
if (strcmp (klass->name, "RuntimeType") == 0) {
- MonoType *type = mono_reflection_type_get_handle ((MonoReflectionType *)obj, error);
+ MonoType *type = mono_reflection_type_handle_mono_type (MONO_HANDLE_CAST (MonoReflectionType, obj), error);
return_val_if_nok (error, 0);
MonoClass *mc = mono_class_from_mono_type (type);
token = mono_metadata_token_from_dor (
mono_dynimage_encode_typedef_or_ref_full (assembly, type, !mono_class_is_gtd (mc) || create_open_instance));
} else if (strcmp (klass->name, "MonoCMethod") == 0 ||
strcmp (klass->name, "MonoMethod") == 0) {
- MonoReflectionMethod *m = (MonoReflectionMethod *)obj;
- if (m->method->is_inflated) {
+ MonoReflectionMethodHandle m = MONO_HANDLE_CAST (MonoReflectionMethod, obj);
+ MonoMethod *method = MONO_HANDLE_GETVAL (m, method);
+ if (method->is_inflated) {
if (create_open_instance)
- token = mono_image_get_methodspec_token (assembly, m->method);
+ token = mono_image_get_methodspec_token (assembly, method);
else
- token = mono_image_get_inflated_method_token (assembly, m->method);
- } else if ((m->method->klass->image == &assembly->image) &&
- !mono_class_is_ginst (m->method->klass)) {
+ token = mono_image_get_inflated_method_token (assembly, method);
+ } else if ((method->klass->image == &assembly->image) &&
+ !mono_class_is_ginst (method->klass)) {
static guint32 method_table_idx = 0xffffff;
- if (m->method->klass->wastypebuilder) {
+ if (method->klass->wastypebuilder) {
/* we use the same token as the one that was assigned
* to the Methodbuilder.
* FIXME: do the equivalent for Fields.
*/
- token = m->method->token;
+ token = method->token;
} else {
/*
* Each token should have a unique index, but the indexes are
token = MONO_TOKEN_METHOD_DEF | method_table_idx;
}
} else {
- token = mono_image_get_methodref_token (assembly, m->method, create_open_instance);
+ token = mono_image_get_methodref_token (assembly, method, create_open_instance);
}
/*g_print ("got token 0x%08x for %s\n", token, m->method->name);*/
} else if (strcmp (klass->name, "MonoField") == 0) {
- MonoReflectionField *f = (MonoReflectionField *)obj;
- if ((f->field->parent->image == &assembly->image) && !is_field_on_inst (f->field)) {
+ MonoReflectionFieldHandle f = MONO_HANDLE_CAST (MonoReflectionField, obj);
+ MonoClassField *field = MONO_HANDLE_GETVAL (f, field);
+ if ((field->parent->image == &assembly->image) && !is_field_on_inst (field)) {
static guint32 field_table_idx = 0xffffff;
field_table_idx --;
token = MONO_TOKEN_FIELD_DEF | field_table_idx;
} else {
- token = mono_image_get_fieldref_token (assembly, (MonoObject*)f, f->field);
+ token = mono_image_get_fieldref_token (assembly, obj, field);
}
/*g_print ("got token 0x%08x for %s\n", token, f->field->name);*/
} else if (strcmp (klass->name, "MonoArrayMethod") == 0) {
- MonoReflectionArrayMethod *m = (MonoReflectionArrayMethod *)obj;
+ MonoReflectionArrayMethodHandle m = MONO_HANDLE_CAST (MonoReflectionArrayMethod, obj);
token = mono_image_get_array_token (assembly, m, error);
return_val_if_nok (error, 0);
} else if (strcmp (klass->name, "SignatureHelper") == 0) {
- MonoReflectionSigHelper *s = (MonoReflectionSigHelper*)obj;
+ MonoReflectionSigHelperHandle s = MONO_HANDLE_CAST (MonoReflectionSigHelper, obj);
token = MONO_TOKEN_SIGNATURE | mono_image_get_sighelper_token (assembly, s, error);
return_val_if_nok (error, 0);
} else if (strcmp (klass->name, "EnumBuilder") == 0) {
- MonoType *type = mono_reflection_type_get_handle ((MonoReflectionType *)obj, error);
+ MonoType *type = mono_reflection_type_handle_mono_type (MONO_HANDLE_CAST (MonoReflectionType, obj), error);
return_val_if_nok (error, 0);
token = mono_metadata_token_from_dor (
mono_image_typedef_or_ref (assembly, type));
}
if (register_token)
- mono_image_register_token (assembly, token, obj);
+ mono_dynamic_image_register_token (assembly, token, obj);
return token;
}
return CACHE_OBJECT (MonoReflectionAssembly *, assembly, &res->object, NULL);
}
-static gpointer
-register_module (MonoDomain *domain, MonoReflectionModuleBuilder *res, MonoDynamicImage *module)
+static MonoReflectionModuleBuilderHandle
+register_module (MonoDomain *domain, MonoReflectionModuleBuilderHandle res, MonoDynamicImage *module)
{
- return CACHE_OBJECT (MonoReflectionModuleBuilder *, module, &res->module.obj, NULL);
+ return CACHE_OBJECT_HANDLE (MonoReflectionModuleBuilderHandle, module, MONO_HANDLE_CAST (MonoObject, res), NULL);
}
static gboolean
-image_module_basic_init (MonoReflectionModuleBuilder *moduleb, MonoError *error)
+image_module_basic_init (MonoReflectionModuleBuilderHandle moduleb, MonoError *error)
{
- MonoDynamicImage *image = moduleb->dynamic_image;
- MonoReflectionAssemblyBuilder *ab = moduleb->assemblyb;
mono_error_init (error);
+ MonoDomain *domain = MONO_HANDLE_DOMAIN (moduleb);
+ MonoDynamicImage *image = MONO_HANDLE_GETVAL (moduleb, dynamic_image);
+ MonoReflectionAssemblyBuilderHandle ab = MONO_HANDLE_NEW (MonoReflectionAssemblyBuilder, NULL);
+ MONO_HANDLE_GET (ab, moduleb, assemblyb);
if (!image) {
- int module_count;
- MonoImage **new_modules;
- MonoImage *ass;
- char *name, *fqname;
/*
* FIXME: we already created an image in mono_reflection_dynimage_basic_init (), but
* we don't know which module it belongs to, since that is only
* determined at assembly save time.
*/
/*image = (MonoDynamicImage*)ab->dynamic_assembly->assembly.image; */
- name = mono_string_to_utf8_checked (ab->name, error);
+ MonoStringHandle abname = MONO_HANDLE_NEW_GET (MonoString, ab, name);
+ char *name = mono_string_handle_to_utf8 (abname, error);
return_val_if_nok (error, FALSE);
- fqname = mono_string_to_utf8_checked (moduleb->module.fqname, error);
+ MonoStringHandle modfqname = MONO_HANDLE_NEW_GET (MonoString, MONO_HANDLE_CAST (MonoReflectionModule, moduleb), fqname);
+ char *fqname = mono_string_handle_to_utf8 (modfqname, error);
if (!is_ok (error)) {
g_free (name);
return FALSE;
}
- image = mono_dynamic_image_create (ab->dynamic_assembly, name, fqname);
+ MonoDynamicAssembly *dynamic_assembly = MONO_HANDLE_GETVAL (ab, dynamic_assembly);
+ image = mono_dynamic_image_create (dynamic_assembly, name, fqname);
- moduleb->module.image = &image->image;
- moduleb->dynamic_image = image;
- register_module (mono_object_domain (moduleb), moduleb, image);
+ MONO_HANDLE_SETVAL (MONO_HANDLE_CAST (MonoReflectionModule, moduleb), image, MonoImage*, &image->image);
+ MONO_HANDLE_SETVAL (moduleb, dynamic_image, MonoDynamicImage*, image);
+ register_module (domain, moduleb, image);
/* register the module with the assembly */
- ass = ab->dynamic_assembly->assembly.image;
- module_count = ass->module_count;
- new_modules = g_new0 (MonoImage *, module_count + 1);
+ MonoImage *ass = dynamic_assembly->assembly.image;
+ int module_count = ass->module_count;
+ MonoImage **new_modules = g_new0 (MonoImage *, module_count + 1);
if (ass->modules)
memcpy (new_modules, ass->modules, module_count * sizeof (MonoImage *));
return TRUE;
}
-static void
-mono_image_module_basic_init (MonoReflectionModuleBuilder *moduleb)
+static gboolean
+mono_image_module_basic_init (MonoReflectionModuleBuilderHandle moduleb, MonoError *error)
{
- MonoError error;
- (void) image_module_basic_init (moduleb, &error);
- mono_error_set_pending_exception (&error);
+ mono_error_init (error);
+ return image_module_basic_init (moduleb, error);
}
#endif
} while (0) \
+MonoType*
+mono_type_array_get_and_resolve (MonoArrayHandle array, int idx, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER();
+ mono_error_init (error);
+ MonoReflectionTypeHandle t = MONO_HANDLE_NEW (MonoReflectionType, NULL);
+ MONO_HANDLE_ARRAY_GETREF (t, array, idx);
+ MonoType *result = mono_reflection_type_handle_mono_type (t, error);
+ HANDLE_FUNCTION_RETURN_VAL (result);
+}
+
#ifndef DISABLE_REFLECTION_EMIT
static gboolean
check_corlib_type_cached (klass, "System.Reflection.Emit", "ConstructorOnTypeBuilderInst");
}
-static MonoReflectionType*
-mono_reflection_type_get_underlying_system_type (MonoReflectionType* t, MonoError *error)
+static MonoReflectionTypeHandle
+mono_reflection_type_get_underlying_system_type (MonoReflectionTypeHandle t, MonoError *error)
{
static MonoMethod *method_get_underlying_system_type = NULL;
- MonoReflectionType *rt;
- MonoMethod *usertype_method;
+ HANDLE_FUNCTION_ENTER ();
mono_error_init (error);
if (!method_get_underlying_system_type)
method_get_underlying_system_type = mono_class_get_method_from_name (mono_defaults.systemtype_class, "get_UnderlyingSystemType", 0);
- usertype_method = mono_object_get_virtual_method ((MonoObject *) t, method_get_underlying_system_type);
+ MonoReflectionTypeHandle rt = MONO_HANDLE_NEW (MonoReflectionType, NULL);
- rt = (MonoReflectionType *) mono_runtime_invoke_checked (usertype_method, t, NULL, error);
+ MonoMethod *usertype_method = mono_object_handle_get_virtual_method (MONO_HANDLE_CAST (MonoObject, t), method_get_underlying_system_type, error);
+ if (!is_ok (error))
+ goto leave;
- return rt;
+ MONO_HANDLE_ASSIGN (rt, MONO_HANDLE_NEW (MonoReflectionType, mono_runtime_invoke_checked (usertype_method, MONO_HANDLE_RAW (t), NULL, error)));
+
+leave:
+ HANDLE_FUNCTION_RETURN_REF (MonoReflectionType, rt);
}
MonoType*
-mono_reflection_type_get_handle (MonoReflectionType* ref, MonoError *error)
+mono_reflection_type_get_handle (MonoReflectionType* ref_raw, MonoError *error)
{
- MonoClass *klass;
+ HANDLE_FUNCTION_ENTER ();
mono_error_init (error);
+ MONO_HANDLE_DCL (MonoReflectionType, ref);
+ MonoType *result = mono_reflection_type_handle_mono_type (ref, error);
+ HANDLE_FUNCTION_RETURN_VAL (result);
+}
+
+static MonoType*
+reflection_instance_handle_mono_type (MonoReflectionGenericClassHandle ref_gclass, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER ();
+ MonoType *result = NULL;
+ MonoType **types = NULL;
+
+ MonoArrayHandle typeargs = MONO_HANDLE_NEW_GET (MonoArray, ref_gclass, type_arguments);
+ int count = mono_array_handle_length (typeargs);
+ types = g_new0 (MonoType*, count);
+ MonoReflectionTypeHandle t = MONO_HANDLE_NEW (MonoReflectionType, NULL);
+ for (int i = 0; i < count; ++i) {
+ MONO_HANDLE_ARRAY_GETREF (t, typeargs, i);
+ types [i] = mono_reflection_type_handle_mono_type (t, error);
+ if (!types[i] || !is_ok (error)) {
+ goto leave;
+ }
+ }
+ /* Need to resolve the generic_type in order for it to create its generic context. */
+ MonoReflectionTypeHandle ref_gtd = MONO_HANDLE_NEW_GET (MonoReflectionType, ref_gclass, generic_type);
+ MonoType *gtd = mono_reflection_type_handle_mono_type (ref_gtd, error);
+ if (!is_ok (error)) {
+ goto leave;
+ }
+ MonoClass *gtd_klass = mono_class_from_mono_type (gtd);
+ if (is_sre_type_builder (mono_handle_class (ref_gtd))) {
+ reflection_create_generic_class (MONO_HANDLE_CAST (MonoReflectionTypeBuilder, ref_gtd), error);
+ if (!is_ok (error)) {
+ goto leave;
+ }
+ }
+ g_assert (count == 0 || mono_class_is_gtd (gtd_klass));
+ result = mono_reflection_bind_generic_parameters (ref_gtd, count, types, error);
+ if (!is_ok (error))
+ goto leave;
+ g_assert (result);
+ MONO_HANDLE_SETVAL (MONO_HANDLE_CAST (MonoReflectionType, ref_gclass), type, MonoType*, result);
+leave:
+ g_free (types);
+ HANDLE_FUNCTION_RETURN_VAL (result);
+}
+
+static MonoType*
+reflection_param_handle_mono_type (MonoReflectionGenericParamHandle ref_gparam, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER ();
+ mono_error_init (error);
+ MonoType *result = NULL;
- if (!ref)
- return NULL;
- if (ref->type)
- return ref->type;
+
+ MonoReflectionTypeBuilderHandle ref_tbuilder = MONO_HANDLE_NEW_GET (MonoReflectionTypeBuilder, ref_gparam, tbuilder);
+ MonoReflectionModuleBuilderHandle ref_module = MONO_HANDLE_NEW_GET (MonoReflectionModuleBuilder, ref_tbuilder, module);
+ MonoDynamicImage *dynamic_image = MONO_HANDLE_GETVAL (ref_module, dynamic_image);
+ MonoImage *image = &dynamic_image->image;
+
+ MonoGenericParamFull *param = mono_image_new0 (image, MonoGenericParamFull, 1);
+
+ MonoStringHandle ref_name = MONO_HANDLE_NEW_GET (MonoString, ref_gparam, name);
+ param->info.name = mono_string_to_utf8_image (image, ref_name, error);
+ mono_error_assert_ok (error);
+ param->param.num = MONO_HANDLE_GETVAL (ref_gparam, index);
+
+ MonoReflectionMethodBuilderHandle ref_mbuilder = MONO_HANDLE_NEW_GET (MonoReflectionMethodBuilder, ref_gparam, mbuilder);
+ if (!MONO_HANDLE_IS_NULL (ref_mbuilder)) {
+ MonoGenericContainer *generic_container = MONO_HANDLE_GETVAL (ref_mbuilder, generic_container);
+ if (!generic_container) {
+ generic_container = (MonoGenericContainer *)mono_image_alloc0 (image, sizeof (MonoGenericContainer));
+ generic_container->is_method = TRUE;
+ /*
+ * Cannot set owner.method, since the MonoMethod is not created yet.
+ * Set the image field instead, so type_in_image () works.
+ */
+ generic_container->is_anonymous = TRUE;
+ generic_container->owner.image = image;
+ MONO_HANDLE_SETVAL (ref_mbuilder, generic_container, MonoGenericContainer*, generic_container);
+ }
+ param->param.owner = generic_container;
+ } else {
+ MonoType *type = mono_reflection_type_handle_mono_type (MONO_HANDLE_CAST (MonoReflectionType, ref_tbuilder), error);
+ if (!is_ok (error))
+ goto leave;
+ MonoClass *owner = mono_class_from_mono_type (type);
+ g_assert (mono_class_is_gtd (owner));
+ param->param.owner = mono_class_get_generic_container (owner);
+ }
+
+ MonoClass *pklass = mono_class_from_generic_parameter_internal ((MonoGenericParam *) param);
+
+ result = &pklass->byval_arg;
+
+ mono_class_set_ref_info (pklass, MONO_HANDLE_CAST (MonoObject, ref_gparam));
+ mono_image_append_class_to_reflection_info_set (pklass);
+
+ MONO_HANDLE_SETVAL (MONO_HANDLE_CAST (MonoReflectionType, ref_gparam), type, MonoType*, result);
+
+leave:
+ HANDLE_FUNCTION_RETURN_VAL (result);
+}
+
+static MonoType*
+mono_type_array_get_and_resolve_raw (MonoArray* array_raw, int idx, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER(); /* FIXME callers of mono_type_array_get_and_resolve_raw should use handles */
+ mono_error_init (error);
+ MONO_HANDLE_DCL (MonoArray, array);
+ MonoType *result = mono_type_array_get_and_resolve (array, idx, error);
+ HANDLE_FUNCTION_RETURN_VAL (result);
+}
+
+MonoType*
+mono_reflection_type_handle_mono_type (MonoReflectionTypeHandle ref, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER ();
+ mono_error_init (error);
+
+ MonoType* result = NULL;
+
+ g_assert (ref);
+ if (MONO_HANDLE_IS_NULL (ref))
+ goto leave;
+ MonoType *t = MONO_HANDLE_GETVAL (ref, type);
+ if (t) {
+ result = t;
+ goto leave;
+ }
if (mono_reflection_is_usertype (ref)) {
- ref = mono_reflection_type_get_underlying_system_type (ref, error);
- if (ref == NULL || mono_reflection_is_usertype (ref) || !is_ok (error))
- return NULL;
- if (ref->type)
- return ref->type;
+ MONO_HANDLE_ASSIGN (ref, mono_reflection_type_get_underlying_system_type (ref, error));
+ if (!is_ok (error) || MONO_HANDLE_IS_NULL (ref) || mono_reflection_is_usertype (ref))
+ goto leave;
+ t = MONO_HANDLE_GETVAL (ref, type);
+ if (t) {
+ result = t;
+ goto leave;
+ }
}
- klass = mono_object_class (ref);
+ MonoClass *klass = mono_handle_class (ref);
if (is_sre_array (klass)) {
- MonoType *res;
- MonoReflectionArrayType *sre_array = (MonoReflectionArrayType*)ref;
- MonoType *base = mono_reflection_type_get_handle (sre_array->element_type, error);
- return_val_if_nok (error, NULL);
+ MonoReflectionArrayTypeHandle sre_array = MONO_HANDLE_CAST (MonoReflectionArrayType, ref);
+ MonoReflectionTypeHandle ref_element = MONO_HANDLE_NEW_GET (MonoReflectionType, sre_array, element_type);
+ MonoType *base = mono_reflection_type_handle_mono_type (ref_element, error);
+ if (!is_ok (error))
+ goto leave;
g_assert (base);
- if (sre_array->rank == 0) //single dimentional array
- res = &mono_array_class_get (mono_class_from_mono_type (base), 1)->byval_arg;
+ gint32 rank = MONO_HANDLE_GETVAL (sre_array, rank);
+ if (rank == 0) //single dimentional array
+ result = &mono_array_class_get (mono_class_from_mono_type (base), 1)->byval_arg;
else
- res = &mono_bounded_array_class_get (mono_class_from_mono_type (base), sre_array->rank, TRUE)->byval_arg;
- sre_array->type.type = res;
- return res;
+ result = &mono_bounded_array_class_get (mono_class_from_mono_type (base), rank, TRUE)->byval_arg;
+ MONO_HANDLE_SETVAL (ref, type, MonoType*, result);
} else if (is_sre_byref (klass)) {
- MonoType *res;
- MonoReflectionDerivedType *sre_byref = (MonoReflectionDerivedType*)ref;
- MonoType *base = mono_reflection_type_get_handle (sre_byref->element_type, error);
- return_val_if_nok (error, NULL);
+ MonoReflectionDerivedTypeHandle sre_byref = MONO_HANDLE_CAST (MonoReflectionDerivedType, ref);
+ MonoReflectionTypeHandle ref_element = MONO_HANDLE_NEW_GET (MonoReflectionType, sre_byref, element_type);
+ MonoType *base = mono_reflection_type_handle_mono_type (ref_element, error);
+ if (!is_ok (error))
+ goto leave;
g_assert (base);
- res = &mono_class_from_mono_type (base)->this_arg;
- sre_byref->type.type = res;
- return res;
+ result = &mono_class_from_mono_type (base)->this_arg;
+ MONO_HANDLE_SETVAL (ref, type, MonoType*, result);
} else if (is_sre_pointer (klass)) {
- MonoType *res;
- MonoReflectionDerivedType *sre_pointer = (MonoReflectionDerivedType*)ref;
- MonoType *base = mono_reflection_type_get_handle (sre_pointer->element_type, error);
- return_val_if_nok (error, NULL);
+ MonoReflectionDerivedTypeHandle sre_pointer = MONO_HANDLE_CAST (MonoReflectionDerivedType, ref);
+ MonoReflectionTypeHandle ref_element = MONO_HANDLE_NEW_GET (MonoReflectionType, sre_pointer, element_type);
+ MonoType *base = mono_reflection_type_handle_mono_type (ref_element, error);
+ if (!is_ok (error))
+ goto leave;
g_assert (base);
- res = &mono_ptr_class_get (base)->byval_arg;
- sre_pointer->type.type = res;
- return res;
+ result = &mono_ptr_class_get (base)->byval_arg;
+ MONO_HANDLE_SETVAL (ref, type, MonoType*, result);
} else if (is_sre_generic_instance (klass)) {
- MonoType *res, **types;
- MonoReflectionGenericClass *gclass = (MonoReflectionGenericClass*)ref;
- int i, count;
-
- count = mono_array_length (gclass->type_arguments);
- types = g_new0 (MonoType*, count);
- for (i = 0; i < count; ++i) {
- MonoReflectionType *t = (MonoReflectionType *)mono_array_get (gclass->type_arguments, gpointer, i);
- types [i] = mono_reflection_type_get_handle (t, error);
- if (!types[i] || !is_ok (error)) {
- g_free (types);
- return NULL;
- }
- }
- /* Need to resolve the generic_type in order for it to create its generic context. */
- MonoType *gtd = mono_reflection_type_get_handle (gclass->generic_type, error);
- if (!is_ok (error)) {
- g_free (types);
- return NULL;
- }
- MonoClass *gtd_klass = mono_class_from_mono_type (gtd);
- if (is_sre_type_builder (mono_object_class (gclass->generic_type))) {
- reflection_create_generic_class ((MonoReflectionTypeBuilder*)gclass->generic_type, error);
- if (!is_ok (error)) {
- g_free (types);
- return NULL;
- }
- }
- g_assert (count == 0 || mono_class_is_gtd (gtd_klass));
- res = mono_reflection_bind_generic_parameters (gclass->generic_type, count, types, error);
- g_free (types);
- g_assert (res);
- gclass->type.type = res;
- return res;
+ result = reflection_instance_handle_mono_type (MONO_HANDLE_CAST (MonoReflectionGenericClass, ref), error);
} else if (is_sre_gparam_builder (klass)) {
- MonoReflectionGenericParam *gparam = (MonoReflectionGenericParam *)ref;
- MonoGenericParamFull *param;
- MonoImage *image;
- MonoClass *pklass;
-
- image = &gparam->tbuilder->module->dynamic_image->image;
-
- param = mono_image_new0 (image, MonoGenericParamFull, 1);
-
- param->info.name = mono_string_to_utf8_image (image, gparam->name, error);
- mono_error_assert_ok (error);
- param->param.num = gparam->index;
-
- if (gparam->mbuilder) {
- if (!gparam->mbuilder->generic_container) {
- gparam->mbuilder->generic_container = (MonoGenericContainer *)mono_image_alloc0 (image, sizeof (MonoGenericContainer));
- gparam->mbuilder->generic_container->is_method = TRUE;
- /*
- * Cannot set owner.method, since the MonoMethod is not created yet.
- * Set the image field instead, so type_in_image () works.
- */
- gparam->mbuilder->generic_container->is_anonymous = TRUE;
- gparam->mbuilder->generic_container->owner.image = image;
- }
- param->param.owner = gparam->mbuilder->generic_container;
- } else if (gparam->tbuilder) {
- MonoType *type = mono_reflection_type_get_handle ((MonoReflectionType*)(gparam->tbuilder), error);
- mono_error_assert_ok (error);
- MonoClass *owner = mono_class_from_mono_type (type);
- g_assert (mono_class_is_gtd (owner));
- param->param.owner = mono_class_get_generic_container (owner);
- }
-
- pklass = mono_class_from_generic_parameter_internal ((MonoGenericParam *) param);
-
- gparam->type.type = &pklass->byval_arg;
-
- mono_class_set_ref_info (pklass, gparam);
- mono_image_append_class_to_reflection_info_set (pklass);
-
- return &pklass->byval_arg;
+ result = reflection_param_handle_mono_type (MONO_HANDLE_CAST (MonoReflectionGenericParam, ref), error);
} else if (is_sre_enum_builder (klass)) {
- MonoReflectionEnumBuilder *ebuilder = (MonoReflectionEnumBuilder *)ref;
+ MonoReflectionEnumBuilderHandle ref_ebuilder = MONO_HANDLE_CAST (MonoReflectionEnumBuilder, ref);
- return mono_reflection_type_get_handle ((MonoReflectionType*)ebuilder->tb, error);
+ MonoReflectionTypeHandle ref_tb = MONO_HANDLE_NEW_GET (MonoReflectionType, ref_ebuilder, tb);
+ result = mono_reflection_type_handle_mono_type (ref_tb, error);
} else if (is_sre_type_builder (klass)) {
- MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder*)ref;
+ MonoReflectionTypeBuilderHandle ref_tb = MONO_HANDLE_CAST (MonoReflectionTypeBuilder, ref);
/* This happens when a finished type references an unfinished one. Have to create the minimal type */
- reflection_setup_internal_class (tb, error);
+ reflection_setup_internal_class (ref_tb, error);
mono_error_assert_ok (error);
- g_assert (ref->type);
- return ref->type;
+ result = MONO_HANDLE_GETVAL (ref, type);
+ } else {
+ g_error ("Cannot handle corlib user type %s", mono_type_full_name (&mono_object_class(ref)->byval_arg));
}
-
- g_error ("Cannot handle corlib user type %s", mono_type_full_name (&mono_object_class(ref)->byval_arg));
- return NULL;
+leave:
+ HANDLE_FUNCTION_RETURN_VAL (result);
}
/**
* LOCKING: Assumes the loader lock is held.
*/
static MonoMethodSignature*
-parameters_to_signature (MonoImage *image, MonoArray *parameters, MonoError *error) {
+parameters_to_signature (MonoImage *image, MonoArrayHandle parameters, MonoError *error) {
MonoMethodSignature *sig;
int count, i;
mono_error_init (error);
- count = parameters? mono_array_length (parameters): 0;
+ count = MONO_HANDLE_IS_NULL (parameters) ? 0 : mono_array_handle_length (parameters);
sig = (MonoMethodSignature *)mono_image_g_malloc0 (image, MONO_SIZEOF_METHOD_SIGNATURE + sizeof (MonoType*) * count);
sig->param_count = count;
* LOCKING: Assumes the loader lock is held.
*/
static MonoMethodSignature*
-ctor_builder_to_signature (MonoImage *image, MonoReflectionCtorBuilder *ctor, MonoError *error) {
+ctor_builder_to_signature (MonoImage *image, MonoReflectionCtorBuilderHandle ctor, MonoError *error) {
MonoMethodSignature *sig;
mono_error_init (error);
- sig = parameters_to_signature (image, ctor->parameters, error);
+ sig = parameters_to_signature (image, MONO_HANDLE_NEW_GET (MonoArray, ctor, parameters), error);
return_val_if_nok (error, NULL);
- sig->hasthis = ctor->attrs & METHOD_ATTRIBUTE_STATIC? 0: 1;
+ sig->hasthis = MONO_HANDLE_GETVAL (ctor, attrs) & METHOD_ATTRIBUTE_STATIC? 0: 1;
sig->ret = &mono_defaults.void_class->byval_arg;
return sig;
}
+static MonoMethodSignature*
+ctor_builder_to_signature_raw (MonoImage *image, MonoReflectionCtorBuilder* ctor_raw, MonoError *error) {
+ HANDLE_FUNCTION_ENTER();
+ MONO_HANDLE_DCL (MonoReflectionCtorBuilder, ctor);
+ MonoMethodSignature *sig = ctor_builder_to_signature (image, ctor, error);
+ HANDLE_FUNCTION_RETURN_VAL (sig);
+}
/**
* LOCKING: Assumes the loader lock is held.
*/
static MonoMethodSignature*
-method_builder_to_signature (MonoImage *image, MonoReflectionMethodBuilder *method, MonoError *error) {
+method_builder_to_signature (MonoImage *image, MonoReflectionMethodBuilderHandle method, MonoError *error) {
MonoMethodSignature *sig;
mono_error_init (error);
- sig = parameters_to_signature (image, method->parameters, error);
+ sig = parameters_to_signature (image, MONO_HANDLE_NEW_GET(MonoArray, method, parameters), error);
return_val_if_nok (error, NULL);
- sig->hasthis = method->attrs & METHOD_ATTRIBUTE_STATIC? 0: 1;
- if (method->rtype) {
- sig->ret = mono_reflection_type_get_handle ((MonoReflectionType*)method->rtype, error);
+ sig->hasthis = MONO_HANDLE_GETVAL (method, attrs) & METHOD_ATTRIBUTE_STATIC? 0: 1;
+ MonoReflectionTypeHandle rtype = MONO_HANDLE_NEW_GET (MonoReflectionType, method, rtype);
+ if (!MONO_HANDLE_IS_NULL (rtype)) {
+ sig->ret = mono_reflection_type_handle_mono_type (rtype, error);
if (!is_ok (error)) {
image_g_free (image, sig);
return NULL;
} else {
sig->ret = &mono_defaults.void_class->byval_arg;
}
- sig->generic_param_count = method->generic_params ? mono_array_length (method->generic_params) : 0;
+ MonoArrayHandle generic_params = MONO_HANDLE_NEW_GET (MonoArray, method, generic_params);
+ sig->generic_param_count = MONO_HANDLE_IS_NULL (generic_params) ? 0 : mono_array_handle_length (generic_params);
return sig;
}
static MonoMethodSignature*
-dynamic_method_to_signature (MonoReflectionDynamicMethod *method, MonoError *error) {
- MonoMethodSignature *sig;
+dynamic_method_to_signature (MonoReflectionDynamicMethodHandle method, MonoError *error) {
+ HANDLE_FUNCTION_ENTER ();
+ MonoMethodSignature *sig = NULL;
mono_error_init (error);
- sig = parameters_to_signature (NULL, method->parameters, error);
- return_val_if_nok (error, NULL);
- sig->hasthis = method->attrs & METHOD_ATTRIBUTE_STATIC? 0: 1;
- if (method->rtype) {
- sig->ret = mono_reflection_type_get_handle (method->rtype, error);
+ sig = parameters_to_signature (NULL, MONO_HANDLE_NEW_GET (MonoArray, method, parameters), error);
+ if (!is_ok (error))
+ goto leave;
+ sig->hasthis = MONO_HANDLE_GETVAL (method, attrs) & METHOD_ATTRIBUTE_STATIC? 0: 1;
+ MonoReflectionTypeHandle rtype = MONO_HANDLE_NEW_GET (MonoReflectionType, method, rtype);
+ if (!MONO_HANDLE_IS_NULL (rtype)) {
+ sig->ret = mono_reflection_type_handle_mono_type (rtype, error);
if (!is_ok (error)) {
g_free (sig);
- return NULL;
+ sig = NULL;
+ goto leave;
}
} else {
sig->ret = &mono_defaults.void_class->byval_arg;
}
sig->generic_param_count = 0;
- return sig;
+leave:
+ HANDLE_FUNCTION_RETURN_VAL (sig);
}
static void
if (strcmp (ctor->vtable->klass->name, "MonoCMethod")) {
/* sig is freed later so allocate it in the heap */
- sig = ctor_builder_to_signature (NULL, (MonoReflectionCtorBuilder*)ctor, error);
+ sig = ctor_builder_to_signature_raw (NULL, (MonoReflectionCtorBuilder*)ctor, error); /* FIXME use handles */
if (!is_ok (error)) {
g_free (sig);
return NULL;
* Returns TRUE on success. On failure, returns FALSE and sets @error.
*/
static gboolean
-reflection_setup_internal_class (MonoReflectionTypeBuilder *tb, MonoError *error)
+reflection_setup_internal_class (MonoReflectionTypeBuilderHandle ref_tb, MonoError *error)
{
- MonoClass *klass, *parent;
-
+ HANDLE_FUNCTION_ENTER ();
mono_error_init (error);
mono_loader_lock ();
- if (tb->parent) {
- MonoType *parent_type = mono_reflection_type_get_handle ((MonoReflectionType*)tb->parent, error);
- if (!is_ok (error)) {
- mono_loader_unlock ();
- return FALSE;
- }
+ MonoReflectionTypeHandle ref_parent = MONO_HANDLE_NEW_GET (MonoReflectionType, ref_tb, parent);
+ MonoClass *parent = NULL;
+ if (!MONO_HANDLE_IS_NULL (ref_parent)) {
+ MonoType *parent_type = mono_reflection_type_handle_mono_type (ref_parent, error);
+ if (!is_ok (error))
+ goto leave;
/* check so we can compile corlib correctly */
- if (strcmp (mono_object_class (tb->parent)->name, "TypeBuilder") == 0) {
+ if (strcmp (mono_handle_class (ref_parent)->name, "TypeBuilder") == 0) {
/* mono_class_setup_mono_type () guaranteess type->data.klass is valid */
parent = parent_type->data.klass;
} else {
parent = mono_class_from_mono_type (parent_type);
}
- } else {
- parent = NULL;
}
/* the type has already being created: it means we just have to change the parent */
- if (tb->type.type) {
- klass = mono_class_from_mono_type (tb->type.type);
+ MonoType *type = MONO_HANDLE_GETVAL (MONO_HANDLE_CAST (MonoReflectionType, ref_tb), type);
+ if (type != NULL) {
+ MonoClass *klass = mono_class_from_mono_type (type);
klass->parent = NULL;
/* fool mono_class_setup_parent */
klass->supertypes = NULL;
mono_class_setup_parent (klass, parent);
mono_class_setup_mono_type (klass);
- mono_loader_unlock ();
- return TRUE;
+ goto leave;
}
+ MonoReflectionModuleBuilderHandle ref_module = MONO_HANDLE_NEW_GET (MonoReflectionModuleBuilder, ref_tb, module);
+ MonoDynamicImage *dynamic_image = MONO_HANDLE_GETVAL (ref_module, dynamic_image);
+
+ MonoStringHandle ref_name = MONO_HANDLE_NEW_GET (MonoString, ref_tb, name);
+ MonoStringHandle ref_nspace = MONO_HANDLE_NEW_GET (MonoString, ref_tb, nspace);
+
+ guint32 table_idx = MONO_HANDLE_GETVAL (ref_tb, table_idx);
/*
* The size calculation here warrants some explaining.
* reflection_setup_internal_class is called too early, well before we know whether the type will be a GTD or DEF,
* meaning we need to alloc enough space to morth a def into a gtd.
*/
- klass = (MonoClass *)mono_image_alloc0 (&tb->module->dynamic_image->image, MAX (sizeof (MonoClassDef), sizeof (MonoClassGtd)));
+ MonoClass *klass = (MonoClass *)mono_image_alloc0 (&dynamic_image->image, MAX (sizeof (MonoClassDef), sizeof (MonoClassGtd)));
klass->class_kind = MONO_CLASS_DEF;
- klass->image = &tb->module->dynamic_image->image;
+ klass->image = &dynamic_image->image;
klass->inited = 1; /* we lie to the runtime */
- klass->name = mono_string_to_utf8_image (klass->image, tb->name, error);
+ klass->name = mono_string_to_utf8_image (klass->image, ref_name, error);
if (!is_ok (error))
- goto failure;
- klass->name_space = mono_string_to_utf8_image (klass->image, tb->nspace, error);
+ goto leave;
+ klass->name_space = mono_string_to_utf8_image (klass->image, ref_nspace, error);
if (!is_ok (error))
- goto failure;
- klass->type_token = MONO_TOKEN_TYPE_DEF | tb->table_idx;
- mono_class_set_flags (klass, tb->attrs);
+ goto leave;
+ klass->type_token = MONO_TOKEN_TYPE_DEF | table_idx;
+ mono_class_set_flags (klass, MONO_HANDLE_GETVAL (ref_tb, attrs));
mono_profiler_class_event (klass, MONO_PROFILE_START_LOAD);
klass->element_class = klass;
- if (mono_class_get_ref_info (klass) == NULL) {
- mono_class_set_ref_info (klass, tb);
+ g_assert (!mono_class_has_ref_info (klass));
+ mono_class_set_ref_info (klass, MONO_HANDLE_CAST (MonoObject, ref_tb));
- /* Put into cache so mono_class_get_checked () will find it.
- Skip nested types as those should not be available on the global scope. */
- if (!tb->nesting_type)
- mono_image_add_to_name_cache (klass->image, klass->name_space, klass->name, tb->table_idx);
+ MonoReflectionTypeHandle ref_nesting_type = MONO_HANDLE_NEW_GET (MonoReflectionType, ref_tb, nesting_type);
+ /* Put into cache so mono_class_get_checked () will find it.
+ Skip nested types as those should not be available on the global scope. */
+ if (MONO_HANDLE_IS_NULL (ref_nesting_type))
+ mono_image_add_to_name_cache (klass->image, klass->name_space, klass->name, table_idx);
- /*
- We must register all types as we cannot rely on the name_cache hashtable since we find the class
- by performing a mono_class_get which does the full resolution.
+ /*
+ We must register all types as we cannot rely on the name_cache hashtable since we find the class
+ by performing a mono_class_get which does the full resolution.
- Working around this semantics would require us to write a lot of code for no clear advantage.
- */
- mono_image_append_class_to_reflection_info_set (klass);
- } else {
- g_assert (mono_class_get_ref_info (klass) == tb);
- }
+ Working around this semantics would require us to write a lot of code for no clear advantage.
+ */
+ mono_image_append_class_to_reflection_info_set (klass);
- mono_dynamic_image_register_token (tb->module->dynamic_image, MONO_TOKEN_TYPE_DEF | tb->table_idx, (MonoObject*)tb);
+ mono_dynamic_image_register_token (dynamic_image, MONO_TOKEN_TYPE_DEF | table_idx, MONO_HANDLE_CAST (MonoObject, ref_tb));
if (parent != NULL) {
mono_class_setup_parent (klass, parent);
* FIXME: handle interfaces.
*/
- tb->type.type = &klass->byval_arg;
+ MonoReflectionTypeHandle ref_tb_type = MONO_HANDLE_CAST (MonoReflectionType, ref_tb);
+ MONO_HANDLE_SETVAL (ref_tb_type, type, MonoType*, &klass->byval_arg);
- if (tb->nesting_type) {
- reflection_setup_internal_class ((MonoReflectionTypeBuilder*)tb->nesting_type, error);
- g_assert (tb->nesting_type->type);
- MonoType *nesting_type = mono_reflection_type_get_handle (tb->nesting_type, error);
- if (!is_ok (error)) goto failure;
+ if (!MONO_HANDLE_IS_NULL (ref_nesting_type)) {
+ if (!reflection_setup_internal_class (MONO_HANDLE_CAST (MonoReflectionTypeBuilder, ref_nesting_type), error))
+ goto leave;
+
+ MonoType *nesting_type = mono_reflection_type_handle_mono_type (ref_nesting_type, error);
+ if (!is_ok (error))
+ goto leave;
klass->nested_in = mono_class_from_mono_type (nesting_type);
}
mono_profiler_class_loaded (klass, MONO_PROFILE_OK);
+leave:
mono_loader_unlock ();
- return TRUE;
-
-failure:
- mono_loader_unlock ();
- return FALSE;
+ HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
/**
* On success returns TRUE, on failure returns FALSE and sets @error.
*/
static gboolean
-reflection_create_generic_class (MonoReflectionTypeBuilder *tb, MonoError *error)
+reflection_create_generic_class (MonoReflectionTypeBuilderHandle ref_tb, MonoError *error)
{
- MonoClass *klass;
- int count, i;
+ HANDLE_FUNCTION_ENTER ();
mono_error_init (error);
- reflection_setup_internal_class (tb, error);
- return_val_if_nok (error, FALSE);
+ reflection_setup_internal_class (ref_tb, error);
+ if (!is_ok (error))
+ goto leave;
- klass = mono_class_from_mono_type (tb->type.type);
+ MonoType *type = MONO_HANDLE_GETVAL (MONO_HANDLE_CAST (MonoReflectionType, ref_tb), type);
+ MonoClass *klass = mono_class_from_mono_type (type);
- count = tb->generic_params ? mono_array_length (tb->generic_params) : 0;
+ MonoArrayHandle generic_params = MONO_HANDLE_NEW_GET (MonoArray, ref_tb, generic_params);
+ int count = MONO_HANDLE_IS_NULL (generic_params) ? 0 : mono_array_handle_length (generic_params);
if (count == 0)
- return TRUE;
+ goto leave;
if (mono_class_try_get_generic_container (klass) != NULL)
- return TRUE; /* already setup */
+ goto leave; /* already setup */
MonoGenericContainer *generic_container = (MonoGenericContainer *)mono_image_alloc0 (klass->image, sizeof (MonoGenericContainer));
mono_class_set_generic_container (klass, generic_container);
- for (i = 0; i < count; i++) {
- MonoReflectionGenericParam *gparam = (MonoReflectionGenericParam *)mono_array_get (tb->generic_params, gpointer, i);
- MonoType *param_type = mono_reflection_type_get_handle ((MonoReflectionType*)gparam, error);
- return_val_if_nok (error, FALSE);
+ MonoReflectionGenericParamHandle ref_gparam = MONO_HANDLE_NEW (MonoReflectionGenericParam, NULL);
+ for (int i = 0; i < count; i++) {
+ MONO_HANDLE_ARRAY_GETREF (ref_gparam, generic_params, i);
+ MonoType *param_type = mono_reflection_type_handle_mono_type (MONO_HANDLE_CAST (MonoReflectionType, ref_gparam), error);
+ if (!is_ok (error))
+ goto leave;
MonoGenericParamFull *param = (MonoGenericParamFull *) param_type->data.generic_param;
generic_container->type_params [i] = *param;
/*Make sure we are a diferent type instance */
generic_container->type_params [i].param.owner = generic_container;
generic_container->type_params [i].info.pklass = NULL;
- generic_container->type_params [i].info.flags = gparam->attrs;
+ generic_container->type_params [i].info.flags = MONO_HANDLE_GETVAL (ref_gparam, attrs);
g_assert (generic_container->type_params [i].param.owner);
}
generic_container->context.class_inst = mono_get_shared_generic_inst (generic_container);
- return TRUE;
+leave:
+ HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
static MonoMarshalSpec*
method_aux = image_g_new0 (image, MonoReflectionMethodAux, 1);
- method_aux->dllentry = rmb->dllentry ? mono_string_to_utf8_image (image, rmb->dllentry, error) : image_strdup (image, m->name);
+ method_aux->dllentry = rmb->dllentry ? string_to_utf8_image_raw (image, rmb->dllentry, error) : image_strdup (image, m->name);
mono_error_assert_ok (error);
- method_aux->dll = mono_string_to_utf8_image (image, rmb->dll, error);
+ method_aux->dll = string_to_utf8_image_raw (image, rmb->dll, error);
mono_error_assert_ok (error);
((MonoMethodPInvoke*)m)->piflags = (rmb->native_cc << 8) | (rmb->charset ? (rmb->charset - 1) * 2 : 0) | rmb->extra_flags;
}
if (pb->name) {
- method_aux->param_names [i] = mono_string_to_utf8_image (image, pb->name, error);
+ method_aux->param_names [i] = string_to_utf8_image_raw (image, pb->name, error);
mono_error_assert_ok (error);
}
if (pb->cattrs) {
return NULL;
g_assert (klass->image != NULL);
- sig = ctor_builder_to_signature (klass->image, mb, error);
+ sig = ctor_builder_to_signature_raw (klass->image, mb, error); /* FIXME use handles */
mono_loader_unlock ();
return_val_if_nok (error, NULL);
}
static MonoMethod*
-methodbuilder_to_mono_method (MonoClass *klass, MonoReflectionMethodBuilder* mb, MonoError *error)
+methodbuilder_to_mono_method (MonoClass *klass, MonoReflectionMethodBuilderHandle ref_mb, MonoError *error)
{
ReflectionMethodBuilder rmb;
MonoMethodSignature *sig;
mono_loader_lock ();
+ MonoReflectionMethodBuilder *mb = MONO_HANDLE_RAW (ref_mb); /* FIXME use handles */
if (!mono_reflection_methodbuilder_from_method_builder (&rmb, mb, error))
return NULL;
g_assert (klass->image != NULL);
- sig = method_builder_to_signature (klass->image, mb, error);
+ sig = method_builder_to_signature (klass->image, ref_mb, error);
mono_loader_unlock ();
return_val_if_nok (error, NULL);
- mb->mhandle = reflection_methodbuilder_to_mono_method (klass, &rmb, sig, error);
+ MonoMethod *method = reflection_methodbuilder_to_mono_method (klass, &rmb, sig, error);
return_val_if_nok (error, NULL);
- mono_save_custom_attrs (klass->image, mb->mhandle, mb->cattrs);
+ MONO_HANDLE_SETVAL (ref_mb, mhandle, MonoMethod*, method);
+ mono_save_custom_attrs (klass->image, method, mb->cattrs);
if (!((MonoDynamicImage*)(MonoDynamicImage*)klass->image)->save)
/* ilgen is no longer needed */
mb->ilgen = NULL;
- return mb->mhandle;
+ return method;
+}
+
+static MonoMethod*
+methodbuilder_to_mono_method_raw (MonoClass *klass, MonoReflectionMethodBuilder* mb_raw, MonoError *error)
+{
+ HANDLE_FUNCTION_ENTER (); /* FIXME change callers of methodbuilder_to_mono_method_raw to use handles */
+ mono_error_init (error);
+ MONO_HANDLE_DCL (MonoReflectionMethodBuilder, mb);
+ MonoMethod *result = methodbuilder_to_mono_method (klass, mb, error);
+ HANDLE_FUNCTION_RETURN_VAL (result);
}
+
#endif
#ifndef DISABLE_REFLECTION_EMIT
static gboolean
ensure_runtime_vtable (MonoClass *klass, MonoError *error)
{
- MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)mono_class_get_ref_info (klass);
+ MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)mono_class_get_ref_info_raw (klass); /* FIXME use handles */
int i, num, j;
mono_error_init (error);
num = tb->num_methods;
j = i;
for (i = 0; i < num; ++i) {
- MonoMethod *meth = methodbuilder_to_mono_method (klass, mono_array_get (tb->methods, MonoReflectionMethodBuilder*, i), error);
+ MonoMethod *meth = methodbuilder_to_mono_method_raw (klass, mono_array_get (tb->methods, MonoReflectionMethodBuilder*, i), error); /* FIXME use handles */
if (!meth)
return FALSE;
klass->methods [j++] = meth;
klass->interface_count = mono_array_length (tb->interfaces);
klass->interfaces = (MonoClass **)mono_image_alloc (klass->image, sizeof (MonoClass*) * klass->interface_count);
for (i = 0; i < klass->interface_count; ++i) {
- MonoType *iface = mono_type_array_get_and_resolve (tb->interfaces, i, error);
+ MonoType *iface = mono_type_array_get_and_resolve_raw (tb->interfaces, i, error); /* FIXME use handles */
return_val_if_nok (error, FALSE);
klass->interfaces [i] = mono_class_from_mono_type (iface);
if (!ensure_runtime_vtable (klass->interfaces [i], error))
g_assert (image_is_dynamic (klass->image));
- if (!mono_class_get_ref_info (klass))
+ if (!mono_class_has_ref_info (klass))
return;
- g_assert (strcmp (((MonoObject*)mono_class_get_ref_info (klass))->vtable->klass->name, "TypeBuilder") == 0);
-
- tb = (MonoReflectionTypeBuilder*)mono_class_get_ref_info (klass);
+ tb = (MonoReflectionTypeBuilder*)mono_class_get_ref_info_raw (klass); /* FIXME use handles */
+ g_assert (strcmp (mono_object_class (tb)->name, "TypeBuilder") == 0);
onum = 0;
if (tb->methods) {
static void
typebuilder_setup_fields (MonoClass *klass, MonoError *error)
{
- MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)mono_class_get_ref_info (klass);
+ MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)mono_class_get_ref_info_raw (klass); /* FIXME use handles */
MonoReflectionFieldBuilder *fb;
MonoClassField *field;
MonoFieldDefaultValue *def_values;
fb = (MonoReflectionFieldBuilder *)mono_array_get (tb->fields, gpointer, i);
field = &klass->fields [i];
field->parent = klass;
- field->name = mono_string_to_utf8_image (image, fb->name, error);
+ field->name = string_to_utf8_image_raw (image, fb->name, error); /* FIXME use handles */
if (!mono_error_ok (error))
return;
if (fb->attrs) {
static void
typebuilder_setup_properties (MonoClass *klass, MonoError *error)
{
- MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)mono_class_get_ref_info (klass);
+ MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)mono_class_get_ref_info_raw (klass); /* FIXME use handles */
MonoReflectionPropertyBuilder *pb;
MonoImage *image = klass->image;
MonoProperty *properties;
pb = mono_array_get (tb->properties, MonoReflectionPropertyBuilder*, i);
properties [i].parent = klass;
properties [i].attrs = pb->attrs;
- properties [i].name = mono_string_to_utf8_image (image, pb->name, error);
+ properties [i].name = string_to_utf8_image_raw (image, pb->name, error); /* FIXME use handles */
if (!mono_error_ok (error))
return;
if (pb->get_method)
static void
typebuilder_setup_events (MonoClass *klass, MonoError *error)
{
- MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)mono_class_get_ref_info (klass);
+ MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)mono_class_get_ref_info_raw (klass); /* FIXME use handles */
MonoReflectionEventBuilder *eb;
MonoImage *image = klass->image;
MonoEvent *events;
eb = mono_array_get (tb->events, MonoReflectionEventBuilder*, i);
events [i].parent = klass;
events [i].attrs = eb->attrs;
- events [i].name = mono_string_to_utf8_image (image, eb->name, error);
+ events [i].name = string_to_utf8_image_raw (image, eb->name, error); /* FIXME use handles */
if (!mono_error_ok (error))
return;
if (eb->add_method)
return FALSE;
}
-MonoReflectionType*
-ves_icall_TypeBuilder_create_runtime_class (MonoReflectionTypeBuilder *tb)
+MonoReflectionTypeHandle
+ves_icall_TypeBuilder_create_runtime_class (MonoReflectionTypeBuilderHandle ref_tb, MonoError *error)
{
- MonoError error;
- MonoClass *klass;
- MonoDomain* domain;
- MonoReflectionType* res;
- int i;
-
- mono_error_init (&error);
+ mono_error_init (error);
- reflection_create_generic_class (tb, &error);
- mono_error_assert_ok (&error);
+ reflection_create_generic_class (ref_tb, error);
+ mono_error_assert_ok (error);
- domain = mono_object_domain (tb);
- klass = mono_class_from_mono_type (tb->type.type);
+ MonoDomain *domain = MONO_HANDLE_DOMAIN (ref_tb);
+ MonoType *type = MONO_HANDLE_GETVAL (MONO_HANDLE_CAST (MonoReflectionType, ref_tb), type);
+ MonoClass *klass = mono_class_from_mono_type (type);
- mono_save_custom_attrs (klass->image, klass, tb->cattrs);
+ MonoArrayHandle cattrs = MONO_HANDLE_NEW_GET (MonoArray, ref_tb, cattrs);
+ mono_save_custom_attrs (klass->image, klass, MONO_HANDLE_RAW (cattrs)); /* FIXME use handles */
/*
* we need to lock the domain because the lock will be taken inside
mono_domain_unlock (domain);
mono_loader_unlock ();
- res = mono_type_get_object_checked (mono_object_domain (tb), &klass->byval_arg, &error);
- mono_error_set_pending_exception (&error);
-
- return res;
+ return mono_type_get_object_handle (domain, &klass->byval_arg, error);
}
/*
* Fields to set in klass:
* the various flags: delegate/unicode/contextbound etc.
*/
- mono_class_set_flags (klass, tb->attrs);
+ mono_class_set_flags (klass, MONO_HANDLE_GETVAL (ref_tb, attrs));
klass->has_cctor = 1;
mono_class_setup_parent (klass, klass->parent);
/* enums are done right away */
if (!klass->enumtype)
- if (!ensure_runtime_vtable (klass, &error))
+ if (!ensure_runtime_vtable (klass, error))
goto failure;
- if (tb->subtypes) {
+ MonoArrayHandle nested_types = MONO_HANDLE_NEW_GET (MonoArray, ref_tb, subtypes);
+ if (!MONO_HANDLE_IS_NULL (nested_types)) {
GList *nested = NULL;
- for (i = 0; i < mono_array_length (tb->subtypes); ++i) {
- MonoReflectionTypeBuilder *subtb = mono_array_get (tb->subtypes, MonoReflectionTypeBuilder*, i);
-
- if (!subtb->type.type) {
- reflection_setup_internal_class (subtb, &error);
- mono_error_assert_ok (&error);
+ int num_nested = mono_array_handle_length (nested_types);
+ MonoReflectionTypeHandle nested_tb = MONO_HANDLE_NEW (MonoReflectionType, NULL);
+ for (int i = 0; i < num_nested; ++i) {
+ MONO_HANDLE_ARRAY_GETREF (nested_tb, nested_types, i);
+
+ if (MONO_HANDLE_GETVAL (nested_tb, type) == NULL) {
+ reflection_setup_internal_class (MONO_HANDLE_CAST (MonoReflectionTypeBuilder, nested_tb), error);
+ mono_error_assert_ok (error);
}
- MonoType *subtype = mono_reflection_type_get_handle ((MonoReflectionType*)subtb, &error);
- if (!is_ok (&error)) goto failure;
+ MonoType *subtype = mono_reflection_type_handle_mono_type (nested_tb, error);
+ if (!is_ok (error)) goto failure;
nested = g_list_prepend_image (klass->image, nested, mono_class_from_mono_type (subtype));
}
mono_class_set_nested_classes_property (klass, nested);
klass->nested_classes_inited = TRUE;
- typebuilder_setup_fields (klass, &error);
- if (!mono_error_ok (&error))
+ typebuilder_setup_fields (klass, error);
+ if (!is_ok (error))
goto failure;
- typebuilder_setup_properties (klass, &error);
- if (!mono_error_ok (&error))
+ typebuilder_setup_properties (klass, error);
+ if (!is_ok (error))
goto failure;
- typebuilder_setup_events (klass, &error);
- if (!mono_error_ok (&error))
+ typebuilder_setup_events (klass, error);
+ if (!is_ok (error))
goto failure;
klass->wastypebuilder = TRUE;
- if (tb->generic_params) {
- for (i = 0; i < mono_array_length (tb->generic_params); i++) {
- MonoReflectionGenericParam *gparam = (MonoReflectionGenericParam *)mono_array_get (tb->generic_params, gpointer, i);
- MonoType *param_type = mono_reflection_type_get_handle ((MonoReflectionType*)gparam, &error);
+ MonoArrayHandle generic_params = MONO_HANDLE_NEW_GET (MonoArray, ref_tb, generic_params);
+ if (!MONO_HANDLE_IS_NULL (generic_params)) {
+ int num_params = mono_array_handle_length (generic_params);
+ MonoReflectionTypeHandle ref_gparam = MONO_HANDLE_NEW (MonoReflectionType, NULL);
+ for (int i = 0; i < num_params; i++) {
+ MONO_HANDLE_ARRAY_GETREF (ref_gparam, generic_params, i);
+ MonoType *param_type = mono_reflection_type_handle_mono_type (ref_gparam, error);
+ if (!is_ok (error))
+ goto failure;
MonoClass *gklass = mono_class_from_mono_type (param_type);
gklass->wastypebuilder = TRUE;
if (domain->type_hash && mono_class_is_gtd (klass)) {
struct remove_instantiations_user_data data;
data.klass = klass;
- data.error = &error;
- mono_error_assert_ok (&error);
+ data.error = error;
+ mono_error_assert_ok (error);
mono_g_hash_table_foreach_remove (domain->type_hash, remove_instantiations_of_and_ensure_contents, &data);
- if (!is_ok (&error))
+ if (!is_ok (error))
goto failure;
}
if (klass->enumtype && !mono_class_is_valid_enum (klass)) {
mono_class_set_type_load_failure (klass, "Not a valid enumeration");
- mono_error_set_type_load_class (&error, klass, "Not a valid enumeration");
+ mono_error_set_type_load_class (error, klass, "Not a valid enumeration");
goto failure_unlocked;
}
- res = mono_type_get_object_checked (mono_object_domain (tb), &klass->byval_arg, &error);
- if (!is_ok (&error))
+ MonoReflectionTypeHandle res = mono_type_get_object_handle (domain, &klass->byval_arg, error);
+ if (!is_ok (error))
goto failure_unlocked;
- g_assert (res != (MonoReflectionType*)tb);
-
return res;
failure:
- mono_class_set_type_load_failure (klass, "TypeBuilder could not create runtime class due to: %s", mono_error_get_message (&error));
+ mono_class_set_type_load_failure (klass, "TypeBuilder could not create runtime class due to: %s", mono_error_get_message (error));
klass->wastypebuilder = TRUE;
mono_domain_unlock (domain);
mono_loader_unlock ();
failure_unlocked:
- mono_error_set_pending_exception (&error);
return NULL;
}
}
static gboolean
-reflection_create_dynamic_method (MonoReflectionDynamicMethod *mb, MonoError *error)
+reflection_create_dynamic_method (MonoReflectionDynamicMethodHandle ref_mb, MonoError *error)
{
MonoReferenceQueue *queue;
MonoMethod *handle;
mono_loader_unlock ();
}
- sig = dynamic_method_to_signature (mb, error);
+ sig = dynamic_method_to_signature (ref_mb, error);
return_val_if_nok (error, FALSE);
+ MonoReflectionDynamicMethod *mb = MONO_HANDLE_RAW (ref_mb); /* FIXME convert reflection_create_dynamic_method to use handles */
reflection_methodbuilder_from_dynamic_method (&rmb, mb);
/*
}
void
-ves_icall_DynamicMethod_create_dynamic_method (MonoReflectionDynamicMethod *mb)
+ves_icall_DynamicMethod_create_dynamic_method (MonoReflectionDynamicMethodHandle mb, MonoError *error)
{
- MonoError error;
- (void) reflection_create_dynamic_method (mb, &error);
- mono_error_set_pending_exception (&error);
+ (void) reflection_create_dynamic_method (mb, error);
}
#endif /* DISABLE_REFLECTION_EMIT */
{
mono_error_init (error);
- if (image_is_dynamic (klass->image) && !klass->wastypebuilder && mono_class_get_ref_info (klass)) {
- MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)mono_class_get_ref_info (klass);
+ if (image_is_dynamic (klass->image) && !klass->wastypebuilder && mono_class_has_ref_info (klass)) {
+ MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)mono_class_get_ref_info_raw (klass); /* FIXME use handles */
mono_domain_try_type_resolve_checked (mono_domain_get (), NULL, (MonoObject*)tb, error);
return_if_nok (error);
/* TODO: Copy type ? */
sig->ret = helper->return_type->type;
for (i = 0; i < nargs; ++i) {
- sig->params [i] = mono_type_array_get_and_resolve (helper->arguments, i, error);
+ sig->params [i] = mono_type_array_get_and_resolve_raw (helper->arguments, i, error); /* FIXME use handles */
if (!is_ok (error)) {
image_g_free (image, sig);
return NULL;
g_error ("This mono runtime was configured with --enable-minimal=reflection_emit, so System.Reflection.Emit is not supported.");
}
-static void
-mono_image_module_basic_init (MonoReflectionModuleBuilder *moduleb)
+static gboolean
+mono_image_module_basic_init (MonoReflectionModuleBuilderHandle moduleb, MonoError *error)
{
g_assert_not_reached ();
+ return FALSE;
}
guint32
-mono_image_insert_string (MonoReflectionModuleBuilder *module, MonoString *str)
+mono_image_insert_string (MonoReflectionModuleBuilderHandle module, MonoStringHandle str, MonoError *error)
{
g_assert_not_reached ();
return 0;
}
guint32
-mono_image_create_method_token (MonoDynamicImage *assembly, MonoObject *obj, MonoArray *opt_param_types, MonoError *error)
+mono_image_create_method_token (MonoDynamicImage *assembly, MonoObjectHandle obj, MonoArrayHandle opt_param_types, MonoError *error)
{
g_assert_not_reached ();
return 0;
}
guint32
-mono_image_create_token (MonoDynamicImage *assembly, MonoObject *obj,
+mono_image_create_token (MonoDynamicImage *assembly, MonoObjectHandle obj,
gboolean create_open_instance, gboolean register_token, MonoError *error)
{
g_assert_not_reached ();
*num_overrides = 0;
}
-MonoReflectionType*
-ves_icall_TypeBuilder_create_runtime_class (MonoReflectionTypeBuilder *tb)
+MonoReflectionTypeHandle
+ves_icall_TypeBuilder_create_runtime_class (MonoReflectionTypeBuilderHandle tb, MonoError *error)
{
g_assert_not_reached ();
return NULL;
}
void
-ves_icall_DynamicMethod_create_dynamic_method (MonoReflectionDynamicMethod *mb)
+ves_icall_DynamicMethod_create_dynamic_method (MonoReflectionDynamicMethodHandle mb, MonoError *error)
{
+ mono_error_init (error);
}
MonoType*
return ref->type;
}
+MonoType*
+mono_reflection_type_handle_mono_type (MonoReflectionTypeHandle ref, MonoError *error)
+{
+ mono_error_init (error);
+ if (MONO_HANDLE_IS_NULL (ref))
+ return NULL;
+ return MONO_HANDLE_GETVAL (ref, type);
+}
+
+
#endif /* DISABLE_REFLECTION_EMIT */
void
}
gint32
-ves_icall_ModuleBuilder_getToken (MonoReflectionModuleBuilder *mb, MonoObject *obj, gboolean create_open_instance)
+ves_icall_ModuleBuilder_getToken (MonoReflectionModuleBuilderHandle mb, MonoObjectHandle obj, gboolean create_open_instance, MonoError *error)
{
- MONO_CHECK_ARG_NULL (obj, 0);
-
- MonoError error;
- gint32 result = mono_image_create_token (mb->dynamic_image, obj, create_open_instance, TRUE, &error);
- mono_error_set_pending_exception (&error);
- return result;
+ mono_error_init (error);
+ if (MONO_HANDLE_IS_NULL (obj)) {
+ mono_error_set_argument_null (error, "obj", "");
+ return 0;
+ }
+ return mono_image_create_token (MONO_HANDLE_GETVAL (mb, dynamic_image), obj, create_open_instance, TRUE, error);
}
gint32
-ves_icall_ModuleBuilder_getMethodToken (MonoReflectionModuleBuilder *mb,
- MonoReflectionMethod *method,
- MonoArray *opt_param_types)
+ves_icall_ModuleBuilder_getMethodToken (MonoReflectionModuleBuilderHandle mb,
+ MonoReflectionMethodHandle method,
+ MonoArrayHandle opt_param_types,
+ MonoError *error)
{
- MONO_CHECK_ARG_NULL (method, 0);
+ mono_error_init (error);
+ if (MONO_HANDLE_IS_NULL (method)) {
+ mono_error_set_argument_null (error, "method", "");
+ return 0;
+ }
- MonoError error;
- gint32 result = mono_image_create_method_token (
- mb->dynamic_image, (MonoObject *) method, opt_param_types, &error);
- mono_error_set_pending_exception (&error);
- return result;
+ return mono_image_create_method_token (MONO_HANDLE_GETVAL (mb, dynamic_image), MONO_HANDLE_CAST (MonoObject, method), opt_param_types, error);
}
void
}
void
-ves_icall_ModuleBuilder_RegisterToken (MonoReflectionModuleBuilder *mb, MonoObject *obj, guint32 token)
+ves_icall_ModuleBuilder_RegisterToken (MonoReflectionModuleBuilderHandle mb, MonoObjectHandle obj, guint32 token, MonoError *error)
{
- mono_image_register_token (mb->dynamic_image, token, obj);
+ mono_error_init (error);
+ mono_dynamic_image_register_token (MONO_HANDLE_GETVAL (mb, dynamic_image), token, obj);
}
MonoObject*
}
void
-ves_icall_ModuleBuilder_basic_init (MonoReflectionModuleBuilder *moduleb)
+ves_icall_ModuleBuilder_basic_init (MonoReflectionModuleBuilderHandle moduleb, MonoError *error)
{
- mono_image_module_basic_init (moduleb);
+ mono_error_init (error);
+ mono_image_module_basic_init (moduleb, error);
}
guint32
-ves_icall_ModuleBuilder_getUSIndex (MonoReflectionModuleBuilder *module, MonoString *str)
+ves_icall_ModuleBuilder_getUSIndex (MonoReflectionModuleBuilderHandle module, MonoStringHandle str, MonoError *error)
{
- return mono_image_insert_string (module, str);
+ return mono_image_insert_string (module, str, error);
}
void
#include <mono/utils/mono-threads.h>
#include <mono/utils/mono-lazy-init.h>
#include <mono/utils/mono-logger-internals.h>
+#include <mono/utils/w32api.h>
typedef struct {
gboolean (*init) (gint wakeup_pipe_fd);
#include <glib.h>
#include <mono/metadata/object-internals.h>
-#include <mono/metadata/socket-io.h>
typedef struct _MonoIOSelectorJob MonoIOSelectorJob;
#include <mono/utils/mono-time.h>
#include <mono/utils/mono-rand.h>
#include <mono/utils/refcount.h>
+#include <mono/utils/w32api.h>
#define CPU_USAGE_LOW 80
#define CPU_USAGE_HIGH 95
/* unpark all worker->parked_threads */
mono_coop_cond_broadcast (&worker->parked_threads_cond);
+#if 0
for (;;) {
ThreadPoolWorkerCounter counter;
mono_coop_cond_wait (&worker->threads_exit_cond, &worker->threads_lock);
}
+#endif
mono_coop_mutex_unlock (&worker->threads_lock);
worker_thread (gpointer data)
{
MonoThreadPoolWorker *worker;
- MonoError error;
MonoInternalThread *thread;
ThreadPoolWorkerCounter counter;
g_ptr_array_add (worker->threads, thread);
mono_coop_mutex_unlock (&worker->threads_lock);
- mono_thread_set_name_internal (thread, mono_string_new (mono_get_root_domain (), "Threadpool worker"), FALSE, &error);
- mono_error_assert_ok (&error);
-
while (!mono_runtime_is_shutting_down ()) {
ThreadPoolWorkItem work_item;
mono_coop_mutex_destroy (&threadpool->threads_lock);
mono_coop_cond_destroy (&threadpool->threads_exit_cond);
- g_free (threadpool);
+ /* We cannot free the threadpool, because there is a race
+ * on shutdown where a managed thread may request a new
+ * threadpool thread, but we already destroyed the
+ * threadpool. So to avoid a use-after-free, we simply do
+ * not free the threadpool, as we won't be able to access
+ * the threadpool anyway because the ref count will be 0 */
+ // g_free (threadpool);
}
static void
mono_coop_mutex_unlock (&threadpool->threads_lock);
+#if 0
/* give a chance to the other threads to exit */
mono_thread_info_yield ();
}
mono_coop_mutex_unlock (&threadpool->threads_lock);
+#endif
mono_threadpool_worker_cleanup (threadpool->worker);
domains_unlock ();
+ mono_thread_set_name_internal (thread, mono_string_new (mono_get_root_domain (), "Threadpool worker"), FALSE, TRUE, &error);
+ mono_error_assert_ok (&error);
+
mono_thread_clr_state (thread, (MonoThreadState)~ThreadState_Background);
if (!mono_thread_test_state (thread , ThreadState_Background))
ves_icall_System_Threading_Thread_SetState (thread, ThreadState_Background);
g_assert(wait_event);
MonoWaitHandle *wait_handle = mono_wait_handle_new (mono_object_domain (ares), wait_event, error);
if (!is_ok (error)) {
- CloseHandle (wait_event);
+ mono_w32event_close (wait_event);
return NULL;
}
MONO_OBJECT_SETREF (ares, handle, (MonoObject*) wait_handle);
if (mono_domain_is_unloading (domain))
return FALSE;
+ if (!mono_refcount_tryinc (threadpool)) {
+ /* threadpool has been destroyed, we are shutting down */
+ return FALSE;
+ }
+
domains_lock ();
/* synchronize with mono_threadpool_remove_domain_jobs */
if (mono_domain_is_unloading (domain)) {
domains_unlock ();
+ mono_refcount_dec (threadpool);
return FALSE;
}
domains_unlock ();
COUNTER_ATOMIC (threadpool, counter, {
- if (counter._.starting == 16)
+ if (counter._.starting == 16) {
+ mono_refcount_dec (threadpool);
return TRUE;
+ }
counter._.starting ++;
});
- mono_refcount_inc (threadpool);
-
mono_threadpool_worker_enqueue (threadpool->worker, worker_callback, NULL);
return TRUE;
#define SPECIAL_STATIC_THREAD 1
#define SPECIAL_STATIC_CONTEXT 2
-#ifdef HOST_WIN32
-typedef SECURITY_ATTRIBUTES WapiSecurityAttributes;
-#endif
-
typedef struct _MonoInternalThread MonoInternalThread;
typedef void (*MonoThreadCleanupFunc) (MonoNativeThreadId tid);
MONO_API MonoException* mono_thread_get_undeniable_exception (void);
-void mono_thread_set_name_internal (MonoInternalThread *this_obj, MonoString *name, gboolean permanent, MonoError *error);
+void mono_thread_set_name_internal (MonoInternalThread *this_obj, MonoString *name, gboolean permanent, gboolean reset, MonoError *error);
void mono_thread_suspend_all_other_threads (void);
gboolean mono_threads_abort_appdomain_threads (MonoDomain *domain, int timeout);
mono_threads_detach_coop (gpointer cookie, gpointer *dummy);
void mono_threads_begin_abort_protected_block (void);
-void mono_threads_end_abort_protected_block (void);
+gboolean mono_threads_end_abort_protected_block (void);
MonoException* mono_thread_try_resume_interruption (void);
gboolean
#include <mono/metadata/gc-internals.h>
#include <mono/metadata/marshal.h>
#include <mono/metadata/runtime.h>
-#include <mono/io-layer/io-layer.h>
#include <mono/metadata/object-internals.h>
#include <mono/metadata/mono-debug-debugger.h>
#include <mono/utils/monobitset.h>
#include <mono/utils/mono-tls.h>
#include <mono/utils/atomic.h>
#include <mono/utils/mono-memory-model.h>
-#include <mono/utils/mono-threads-coop.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/os-event.h>
#include <mono/utils/mono-threads-debug.h>
#include <mono/metadata/w32event.h>
#include <mono/metadata/w32mutex.h>
-#include <mono/metadata/gc-internals.h>
#include <mono/metadata/reflection-internals.h>
#include <mono/metadata/abi-details.h>
+#include <mono/metadata/w32error.h>
+#include <mono/utils/w32api.h>
#ifdef HAVE_SIGNAL_H
#include <signal.h>
static gint32 managed_thread_id_counter = 0;
/* Class lazy loading functions */
-static GENERATE_GET_CLASS_WITH_CACHE (appdomain_unloaded_exception, System, AppDomainUnloadedException)
+static GENERATE_GET_CLASS_WITH_CACHE (appdomain_unloaded_exception, "System", "AppDomainUnloadedException")
static void
mono_threads_lock (void)
return InterlockedIncrement (&managed_thread_id_counter);
}
+enum {
+ INTERRUPT_REQUESTED_BIT = 0x1,
+ INTERRUPT_REQUEST_DEFERRED_BIT = 0x2,
+ ABORT_PROT_BLOCK_SHIFT = 2,
+ ABORT_PROT_BLOCK_BITS = 8,
+ ABORT_PROT_BLOCK_MASK = (((1 << ABORT_PROT_BLOCK_BITS) - 1) << ABORT_PROT_BLOCK_SHIFT)
+};
+
+static int
+mono_thread_get_abort_prot_block_count (MonoInternalThread *thread)
+{
+ gsize state = thread->thread_state;
+ return (state & ABORT_PROT_BLOCK_MASK) >> ABORT_PROT_BLOCK_SHIFT;
+}
+
+static void
+verify_thread_state (gsize state)
+{
+ //can't have both INTERRUPT_REQUESTED_BIT and INTERRUPT_REQUEST_DEFERRED_BIT set at the same time
+ g_assert ((state & (INTERRUPT_REQUESTED_BIT | INTERRUPT_REQUEST_DEFERRED_BIT)) != (INTERRUPT_REQUESTED_BIT | INTERRUPT_REQUEST_DEFERRED_BIT));
+
+ //XXX This would be nice to be true, but can happen due to self-aborts (and possibly set-pending-exception)
+ //if prot_count > 0, INTERRUPT_REQUESTED_BIT must never be set
+ // int prot_count = (state & ABORT_PROT_BLOCK_MASK) >> ABORT_PROT_BLOCK_SHIFT;
+ // g_assert (!(prot_count > 0 && (state & INTERRUPT_REQUESTED_BIT)));
+}
+
+void
+mono_threads_begin_abort_protected_block (void)
+{
+ MonoInternalThread *thread = mono_thread_internal_current ();
+ gsize old_state, new_state;
+ do {
+ old_state = thread->thread_state;
+ verify_thread_state (old_state);
+
+ int new_val = ((old_state & ABORT_PROT_BLOCK_MASK) >> ABORT_PROT_BLOCK_SHIFT) + 1;
+
+ new_state = 0;
+ if (old_state & (INTERRUPT_REQUESTED_BIT | INTERRUPT_REQUEST_DEFERRED_BIT)) {
+ if (old_state & INTERRUPT_REQUESTED_BIT)
+ printf ("begin prot happy as it demoted interrupt to deferred interrupt\n");
+ new_state |= INTERRUPT_REQUEST_DEFERRED_BIT;
+ }
+
+ //bounds check abort_prot_count
+ g_assert (new_val > 0);
+ g_assert (new_val < (1 << ABORT_PROT_BLOCK_BITS));
+ new_state |= new_val << ABORT_PROT_BLOCK_SHIFT;
+
+ } while (InterlockedCompareExchangePointer ((volatile gpointer)&thread->thread_state, (gpointer)new_state, (gpointer)old_state) != (gpointer)old_state);
+}
+
+gboolean
+mono_threads_end_abort_protected_block (void)
+{
+ MonoInternalThread *thread = mono_thread_internal_current ();
+ gsize old_state, new_state;
+ do {
+ old_state = thread->thread_state;
+ verify_thread_state (old_state);
+
+ int new_val = ((old_state & ABORT_PROT_BLOCK_MASK) >> ABORT_PROT_BLOCK_SHIFT) - 1;
+ new_state = 0;
+
+ if ((old_state & INTERRUPT_REQUEST_DEFERRED_BIT) && new_val == 0) {
+ printf ("end abort on alert, promoted deferred to pront interrupt\n");
+ new_state |= INTERRUPT_REQUESTED_BIT;
+ }
+
+ //bounds check abort_prot_count
+ g_assert (new_val >= 0);
+ g_assert (new_val < (1 << ABORT_PROT_BLOCK_BITS));
+ new_state |= new_val << ABORT_PROT_BLOCK_SHIFT;
+
+ } while (InterlockedCompareExchangePointer ((volatile gpointer)&thread->thread_state, (gpointer)new_state, (gpointer)old_state) != (gpointer)old_state);
+ return (new_state & INTERRUPT_REQUESTED_BIT) == INTERRUPT_REQUESTED_BIT;
+}
+
+
+//Don't use this function, use inc/dec below
+static void
+mono_thread_abort_prot_block_count_add (MonoInternalThread *thread, int val)
+{
+ gsize old_state, new_state;
+ do {
+ old_state = thread->thread_state;
+ verify_thread_state (old_state);
+
+ int new_val = val + ((old_state & ABORT_PROT_BLOCK_MASK) >> ABORT_PROT_BLOCK_SHIFT);
+ //bounds check abort_prot_count
+ g_assert (new_val >= 0);
+ g_assert (new_val < (1 << ABORT_PROT_BLOCK_BITS));
+ new_state = (old_state & ~ABORT_PROT_BLOCK_MASK) | (new_val << ABORT_PROT_BLOCK_SHIFT);
+
+ } while (InterlockedCompareExchangePointer ((volatile gpointer)&thread->thread_state, (gpointer)new_state, (gpointer)old_state) != (gpointer)old_state);
+}
+
+static void
+mono_thread_inc_abort_prot_block_count (MonoInternalThread *thread)
+{
+ mono_thread_abort_prot_block_count_add (thread, 1);
+}
+
+static void
+mono_thread_dec_abort_prot_block_count (MonoInternalThread *thread)
+{
+ mono_thread_abort_prot_block_count_add (thread, -1);
+}
+
+static gboolean
+mono_thread_get_interruption_requested (MonoInternalThread *thread)
+{
+ gsize state = thread->thread_state;
+ return (state & INTERRUPT_REQUESTED_BIT) == INTERRUPT_REQUESTED_BIT;
+}
+
+/* Returns TRUE is there was a state change */
+static gboolean
+mono_thread_clear_interruption_requested (MonoInternalThread *thread)
+{
+ gsize old_state, new_state;
+ do {
+ old_state = thread->thread_state;
+ verify_thread_state (old_state);
+
+ //Already cleared
+ if (!(old_state & (INTERRUPT_REQUESTED_BIT | INTERRUPT_REQUEST_DEFERRED_BIT)))
+ return FALSE;
+ new_state = old_state & ~(INTERRUPT_REQUESTED_BIT | INTERRUPT_REQUEST_DEFERRED_BIT);
+ } while (InterlockedCompareExchangePointer ((volatile gpointer)&thread->thread_state, (gpointer)new_state, (gpointer)old_state) != (gpointer)old_state);
+ return TRUE;
+}
+
+/* Returns TRUE is there was a state change */
+static gboolean
+mono_thread_set_interruption_requested (MonoInternalThread *thread)
+{
+ //always force when the current thread is doing it to itself.
+ gboolean force_interrupt = thread == mono_thread_internal_current ();
+ gsize old_state, new_state;
+ do {
+ old_state = thread->thread_state;
+ verify_thread_state (old_state);
+
+ int prot_count = ((old_state & ABORT_PROT_BLOCK_MASK) >> ABORT_PROT_BLOCK_SHIFT);
+ //Already set
+ if (old_state & (INTERRUPT_REQUESTED_BIT | INTERRUPT_REQUEST_DEFERRED_BIT))
+ return FALSE;
+
+ //If there's an outstanding prot block, we queue it
+ if (prot_count && !force_interrupt) {
+ printf ("set interrupt unhappy, as it's only putting a deferred req %d\n", force_interrupt);
+ new_state = old_state | INTERRUPT_REQUEST_DEFERRED_BIT;
+ } else
+ new_state = old_state | INTERRUPT_REQUESTED_BIT;
+ } while (InterlockedCompareExchangePointer ((volatile gpointer)&thread->thread_state, (gpointer)new_state, (gpointer)old_state) != (gpointer)old_state);
+
+ return (new_state & INTERRUPT_REQUESTED_BIT) == INTERRUPT_REQUESTED_BIT;
+}
+
static inline MonoNativeThreadId
thread_get_tid (MonoInternalThread *thread)
{
param.sched_priority = 0;
break;
default:
- g_error ("%s: unknown policy %d", __func__, policy);
+ g_warning ("%s: unknown policy %d", __func__, policy);
+ return;
}
}
mono_threads_lock ();
mono_g_hash_table_remove (threads_starting_up, thread);
mono_threads_unlock ();
- mono_error_set_execution_engine (error, "Couldn't create thread. Error 0x%x", GetLastError());
+ mono_error_set_execution_engine (error, "Couldn't create thread. Error 0x%x", mono_w32error_get_last());
/* ref is not going to be decremented in start_wrapper_internal */
InterlockedDecrement (&start_info->ref);
ret = FALSE;
Leaving the counter unbalanced will cause a performance degradation since all threads
will now keep checking their local flags all the time.
*/
- if (InterlockedExchange (&thread->interruption_requested, 0) != 0)
+ if (mono_thread_clear_interruption_requested (thread))
InterlockedDecrement (&thread_interruption_requested);
mono_threads_lock ();
}
void
-mono_thread_set_name_internal (MonoInternalThread *this_obj, MonoString *name, gboolean permanent, MonoError *error)
+mono_thread_set_name_internal (MonoInternalThread *this_obj, MonoString *name, gboolean permanent, gboolean reset, MonoError *error)
{
LOCK_THREAD (this_obj);
mono_error_init (error);
- if ((this_obj->flags & MONO_THREAD_FLAG_NAME_SET)) {
+ if (reset) {
+ this_obj->flags &= ~MONO_THREAD_FLAG_NAME_SET;
+ } else if (this_obj->flags & MONO_THREAD_FLAG_NAME_SET) {
UNLOCK_THREAD (this_obj);
mono_error_set_invalid_operation (error, "Thread.Name can only be set once.");
this_obj->name_len = 0;
}
if (name) {
- this_obj->name = g_new (gunichar2, mono_string_length (name));
- memcpy (this_obj->name, mono_string_chars (name), mono_string_length (name) * 2);
+ this_obj->name = g_memdup (mono_string_chars (name), mono_string_length (name) * sizeof (gunichar2));
this_obj->name_len = mono_string_length (name);
if (permanent)
ves_icall_System_Threading_Thread_SetName_internal (MonoInternalThread *this_obj, MonoString *name)
{
MonoError error;
- mono_thread_set_name_internal (this_obj, name, TRUE, &error);
+ mono_thread_set_name_internal (this_obj, name, TRUE, FALSE, &error);
mono_error_set_pending_exception (&error);
}
LOCK_THREAD (thread);
/* MonoThread::interruption_requested can only be changed with atomics */
- if (InterlockedCompareExchange (&thread->interruption_requested, FALSE, TRUE)) {
+ if (mono_thread_clear_interruption_requested (thread)) {
/* this will consume pending APC calls */
#ifdef HOST_WIN32
WaitForSingleObjectEx (GetCurrentThread(), 0, TRUE);
thread->state & ThreadState_Background)
ExitThread (1);
#endif
- if (InterlockedCompareExchange (&thread->interruption_requested, 1, 0) == 1)
+ if (!mono_thread_set_interruption_requested (thread))
return NULL;
InterlockedIncrement (&thread_interruption_requested);
if (!still_aborting)
return FALSE;
- if (InterlockedCompareExchange (&thread->interruption_requested, 1, 0) == 1)
+ if (!mono_thread_set_interruption_requested (thread))
return NULL;
InterlockedIncrement (&thread_interruption_requested);
MonoInternalThread *thread = mono_thread_internal_current ();
/* The thread may already be stopping */
if (thread != NULL)
- return (thread->interruption_requested);
+ return mono_thread_get_interruption_requested (thread);
}
return FALSE;
}
/* The thread may already be stopping */
if (!thread)
return NULL;
- if (!thread->interruption_requested)
+ if (!mono_thread_get_interruption_requested (thread))
return NULL;
if (!bypass_abort_protection && is_running_protected_wrapper ())
return NULL;
The target thread is running at least one protected block, which must not be interrupted, so we give up.
The protected block code will give them a chance when appropriate.
*/
- if (thread->abort_protected_block_count)
+ if (mono_thread_get_abort_prot_block_count (thread) > 0)
return MonoResumeThread;
/*someone is already interrupting it*/
- if (InterlockedCompareExchange (&thread->interruption_requested, 1, 0) == 1)
+ if (!mono_thread_set_interruption_requested (thread))
return MonoResumeThread;
InterlockedIncrement (&thread_interruption_requested);
return KeepSuspended;
}
} else {
- if (InterlockedCompareExchange (&thread->interruption_requested, 1, 0) == 0)
+ if (mono_thread_set_interruption_requested (thread))
InterlockedIncrement (&thread_interruption_requested);
if (data->interrupt)
data->interrupt_token = mono_thread_info_prepare_interrupt ((MonoThreadInfo *)thread->thread_info);
if (thread != pthread_self ()) {
MONO_ENTER_GC_SAFE;
/* This shouldn't block */
+ mono_threads_join_lock ();
mono_native_thread_join (thread);
+ mono_threads_join_unlock ();
MONO_EXIT_GC_SAFE;
}
} else {
}
}
-void
-mono_threads_begin_abort_protected_block (void)
-{
- MonoInternalThread *thread;
-
- thread = mono_thread_internal_current ();
- ++thread->abort_protected_block_count;
- mono_memory_barrier ();
-}
-
-void
-mono_threads_end_abort_protected_block (void)
-{
- MonoInternalThread *thread;
-
- thread = mono_thread_internal_current ();
-
- mono_memory_barrier ();
- --thread->abort_protected_block_count;
-}
-
MonoException*
mono_thread_try_resume_interruption (void)
{
MonoInternalThread *thread;
thread = mono_thread_internal_current ();
- if (thread->abort_protected_block_count || mono_get_eh_callbacks ()->mono_current_thread_has_handle_block_guard ())
+ if (!mono_get_eh_callbacks ()->mono_above_abort_threshold ())
+ return NULL;
+ if (mono_thread_get_abort_prot_block_count (thread) > 0 || mono_get_eh_callbacks ()->mono_current_thread_has_handle_block_guard ())
return NULL;
return mono_thread_resume_interruption ();
return FALSE;
}
- if (thread->abort_protected_block_count || mono_get_eh_callbacks ()->mono_current_thread_has_handle_block_guard ()) {
+ if (mono_thread_get_abort_prot_block_count (thread) || mono_get_eh_callbacks ()->mono_current_thread_has_handle_block_guard ()) {
UNLOCK_THREAD (thread);
return FALSE;
}
#include <mono/metadata/tokentype.h>
#include <mono/metadata/mono-basic-block.h>
#include <mono/metadata/attrdefs.h>
-#include <mono/metadata/class-internals.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/monobitset.h>
#include <string.h>
code->stack->stype |= BOXED_MASK;
}
/* Class lazy loading functions */
-static GENERATE_GET_CLASS_WITH_CACHE (ienumerable, System.Collections.Generic, IEnumerable`1)
-static GENERATE_GET_CLASS_WITH_CACHE (icollection, System.Collections.Generic, ICollection`1)
-static GENERATE_GET_CLASS_WITH_CACHE (ireadonly_list, System.Collections.Generic, IReadOnlyList`1)
-static GENERATE_GET_CLASS_WITH_CACHE (ireadonly_collection, System.Collections.Generic, IReadOnlyCollection`1)
+static GENERATE_GET_CLASS_WITH_CACHE (ienumerable, "System.Collections.Generic", "IEnumerable`1")
+static GENERATE_GET_CLASS_WITH_CACHE (icollection, "System.Collections.Generic", "ICollection`1")
+static GENERATE_GET_CLASS_WITH_CACHE (ireadonly_list, "System.Collections.Generic", "IReadOnlyList`1")
+static GENERATE_GET_CLASS_WITH_CACHE (ireadonly_collection, "System.Collections.Generic", "IReadOnlyCollection`1")
static MonoClass*
--- /dev/null
+
+#include "w32error.h"
+
+#include "utils/mono-lazy-init.h"
+
+static mono_lazy_init_t error_key_once = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED;
+
+static pthread_key_t error_key;
+
+static void
+error_key_init (void)
+{
+ gint ret;
+ ret = pthread_key_create (&error_key, NULL);
+ g_assert (ret == 0);
+}
+
+guint32
+mono_w32error_get_last (void)
+{
+ mono_lazy_initialize (&error_key_once, error_key_init);
+ return GPOINTER_TO_UINT (pthread_getspecific (error_key));
+}
+
+void
+mono_w32error_set_last (guint32 error)
+{
+ gint ret;
+ mono_lazy_initialize (&error_key_once, error_key_init);
+ ret = pthread_setspecific (error_key, GUINT_TO_POINTER (error));
+ g_assert (ret == 0);
+}
+
+guint32
+mono_w32error_unix_to_win32 (guint32 error)
+{
+ /* mapping ideas borrowed from wine. they may need some work */
+
+ switch (error) {
+ case EACCES:
+ case EPERM:
+ case EROFS: return ERROR_ACCESS_DENIED;
+ case EAGAIN: return ERROR_SHARING_VIOLATION;
+ case EBUSY: return ERROR_LOCK_VIOLATION;
+ case EEXIST: return ERROR_FILE_EXISTS;
+ case EINVAL:
+ case ESPIPE: return ERROR_SEEK;
+ case EISDIR: return ERROR_CANNOT_MAKE;
+ case ENFILE:
+ case EMFILE: return ERROR_TOO_MANY_OPEN_FILES;
+ case ENOENT:
+ case ENOTDIR: return ERROR_FILE_NOT_FOUND;
+ case ENOSPC: return ERROR_HANDLE_DISK_FULL;
+ case ENOTEMPTY: return ERROR_DIR_NOT_EMPTY;
+ case ENOEXEC: return ERROR_BAD_FORMAT;
+ case ENAMETOOLONG: return ERROR_FILENAME_EXCED_RANGE;
+#ifdef EINPROGRESS
+ case EINPROGRESS: return ERROR_IO_PENDING;
+#endif
+ case ENOSYS: return ERROR_NOT_SUPPORTED;
+ case EBADF: return ERROR_INVALID_HANDLE;
+ case EIO: return ERROR_INVALID_HANDLE;
+ case EINTR: return ERROR_IO_PENDING; /* best match I could find */
+ case EPIPE: return ERROR_WRITE_FAULT;
+ default:
+ g_error ("%s: unknown error (%d) \"%s\"", error, g_strerror (error));
+ }
+}
--- /dev/null
+
+#include <windows.h>
+
+#include "w32error.h"
+
+guint32
+mono_w32error_get_last (void)
+{
+ return GetLastError ();
+}
+
+void
+mono_w32error_set_last (guint32 error)
+{
+ SetLastError (error);
+}
+
+guint32
+mono_w32error_unix_to_win32 (guint32 error)
+{
+ g_assert_not_reached ();
+}
--- /dev/null
+
+#ifndef _MONO_METADATA_W32ERROR_H_
+#define _MONO_METADATA_W32ERROR_H_
+
+#include <config.h>
+#include <glib.h>
+
+#if !defined(HOST_WIN32)
+
+#define ERROR_SUCCESS 0
+#define ERROR_FILE_NOT_FOUND 2
+#define ERROR_PATH_NOT_FOUND 3
+#define ERROR_TOO_MANY_OPEN_FILES 4
+#define ERROR_ACCESS_DENIED 5
+#define ERROR_INVALID_HANDLE 6
+#define ERROR_NOT_ENOUGH_MEMORY 8
+#define ERROR_BAD_FORMAT 11
+#define ERROR_INVALID_ACCESS 12
+#define ERROR_INVALID_DATA 13
+#define ERROR_OUTOFMEMORY 14
+#define ERROR_NOT_SAME_DEVICE 17
+#define ERROR_NO_MORE_FILES 18
+#define ERROR_BAD_LENGTH 24
+#define ERROR_SEEK 25
+#define ERROR_WRITE_FAULT 29
+#define ERROR_GEN_FAILURE 31
+#define ERROR_SHARING_VIOLATION 32
+#define ERROR_LOCK_VIOLATION 33
+#define ERROR_HANDLE_DISK_FULL 39
+#define ERROR_NOT_SUPPORTED 50
+#define ERROR_FILE_EXISTS 80
+#define ERROR_CANNOT_MAKE 82
+#define ERROR_INVALID_PARAMETER 87
+#define ERROR_INVALID_NAME 123
+#define ERROR_PROC_NOT_FOUND 127
+#define ERROR_DIR_NOT_EMPTY 145
+#define ERROR_ALREADY_EXISTS 183
+#define ERROR_BAD_EXE_FORMAT 193
+#define ERROR_FILENAME_EXCED_RANGE 206
+#define ERROR_DIRECTORY 267
+#define ERROR_IO_PENDING 997
+#define ERROR_ENCRYPTION_FAILED 6000
+#define WSAEINTR 10004
+#define WSAEBADF 10009
+#define WSAEACCES 10013
+#define WSAEFAULT 10014
+#define WSAEINVAL 10022
+#define WSAEMFILE 10024
+#define WSAEWOULDBLOCK 10035
+#define WSAEINPROGRESS 10036
+#define WSAEALREADY 10037
+#define WSAENOTSOCK 10038
+#define WSAEDESTADDRREQ 10039
+#define WSAEMSGSIZE 10040
+#define WSAENOPROTOOPT 10042
+#define WSAEPROTONOSUPPORT 10043
+#define WSAESOCKTNOSUPPORT 10044
+#define WSAEOPNOTSUPP 10045
+#define WSAEAFNOSUPPORT 10047
+#define WSAEADDRINUSE 10048
+#define WSAEADDRNOTAVAIL 10049
+#define WSAENETDOWN 10050
+#define WSAENETUNREACH 10051
+#define WSAECONNRESET 10054
+#define WSAENOBUFS 10055
+#define WSAEISCONN 10056
+#define WSAENOTCONN 10057
+#define WSAESHUTDOWN 10058
+#define WSAETIMEDOUT 10060
+#define WSAECONNREFUSED 10061
+#define WSAEHOSTDOWN 10064
+#define WSAEHOSTUNREACH 10065
+#define WSASYSCALLFAILURE 10107
+
+#endif
+
+guint32
+mono_w32error_get_last (void);
+
+void
+mono_w32error_set_last (guint32 error);
+
+guint32
+mono_w32error_unix_to_win32 (guint32 error);
+
+#endif /* _MONO_METADATA_W32ERROR_H_ */
#include "w32event.h"
+#include "w32error.h"
#include "w32handle-namespace.h"
-#include "mono/io-layer/io-layer.h"
#include "mono/utils/mono-logger-internals.h"
#include "mono/metadata/w32handle.h"
+#define MAX_PATH 260
+
typedef struct {
gboolean manual;
guint32 set_count;
return handle;
}
+gboolean
+mono_w32event_close (gpointer handle)
+{
+ return mono_w32handle_close (handle);
+}
+
void
mono_w32event_set (gpointer handle)
{
if (handle == INVALID_HANDLE_VALUE) {
g_warning ("%s: error creating %s handle",
__func__, mono_w32handle_get_typename (type));
- SetLastError (ERROR_GEN_FAILURE);
+ mono_w32error_set_last (ERROR_GEN_FAILURE);
return NULL;
}
/* w32 seems to guarantee that opening named objects can't race each other */
mono_w32handle_namespace_lock ();
- utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
+ glong utf8_len = 0;
+ utf8_name = g_utf16_to_utf8 (name, -1, NULL, &utf8_len, NULL);
handle = mono_w32handle_namespace_search_handle (MONO_W32HANDLE_NAMEDEVENT, utf8_name);
if (handle == INVALID_HANDLE_VALUE) {
/* The name has already been used for a different object. */
handle = NULL;
- SetLastError (ERROR_INVALID_HANDLE);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
} else if (handle) {
/* Not an error, but this is how the caller is informed that the event wasn't freshly created */
- SetLastError (ERROR_ALREADY_EXISTS);
+ mono_w32error_set_last (ERROR_ALREADY_EXISTS);
/* mono_w32handle_namespace_search_handle already adds a ref to the handle */
} else {
/* A new named event */
MonoW32HandleNamedEvent namedevent_handle;
- strncpy (&namedevent_handle.sharedns.name [0], utf8_name, MAX_PATH);
- namedevent_handle.sharedns.name [MAX_PATH] = '\0';
+ size_t len = utf8_len < MAX_PATH ? utf8_len : MAX_PATH;
+ memcpy (&namedevent_handle.sharedns.name [0], utf8_name, len);
+ namedevent_handle.sharedns.name [len] = '\0';
handle = event_handle_create ((MonoW32HandleEvent*) &namedevent_handle, MONO_W32HANDLE_NAMEDEVENT, manual, initial);
}
/* Need to blow away any old errors here, because code tests
* for ERROR_ALREADY_EXISTS on success (!) to see if an event
* was freshly created */
- SetLastError (ERROR_SUCCESS);
+ mono_w32error_set_last (ERROR_SUCCESS);
event = name ? namedevent_create (manual, initial, mono_string_chars (name)) : event_create (manual, initial);
- *error = GetLastError ();
+ *error = mono_w32error_get_last ();
return event;
}
MonoW32HandleEvent *event_handle;
if (handle == NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
return(FALSE);
}
case MONO_W32HANDLE_NAMEDEVENT:
break;
default:
- SetLastError (ERROR_INVALID_HANDLE);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
return FALSE;
}
MonoW32HandleType type;
MonoW32HandleEvent *event_handle;
- SetLastError (ERROR_SUCCESS);
+ mono_w32error_set_last (ERROR_SUCCESS);
if (handle == NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
return(FALSE);
}
case MONO_W32HANDLE_NAMEDEVENT:
break;
default:
- SetLastError (ERROR_INVALID_HANDLE);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
return FALSE;
}
void
ves_icall_System_Threading_Events_CloseEvent_internal (gpointer handle)
{
- CloseHandle (handle);
+ mono_w32handle_close (handle);
}
gpointer
return CreateEvent (NULL, manual, initial, NULL);
}
+gboolean
+mono_w32event_close (gpointer handle)
+{
+ return CloseHandle (handle);
+}
+
void
mono_w32event_set (gpointer handle)
{
gpointer
mono_w32event_create (gboolean manual, gboolean initial);
+gboolean
+mono_w32event_close (gpointer handle);
+
void
mono_w32event_set (gpointer handle);
--- /dev/null
+/*
+ * Copyright 2016 Microsoft
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+#ifndef _MONO_METADATA_W32FILE_INTERNALS_H_
+#define _MONO_METADATA_W32FILE_INTERNALS_H_
+
+#include <config.h>
+#include <glib.h>
+
+#endif /* _MONO_METADATA_W32FILE_INTERNALS_H_ */
--- /dev/null
+/* $OpenBSD: glob.c,v 1.26 2005/11/28 17:50:12 deraadt Exp $ */
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Guido van Rossum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * mono_w32file_unix_glob(3) -- a subset of the one defined in POSIX 1003.2.
+ *
+ * Optional extra services, controlled by flags not defined by POSIX:
+ *
+ * GLOB_MAGCHAR:
+ * Set in gl_flags if pattern contained a globbing character.
+ */
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <glib.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "w32file-unix-glob.h"
+
+#define EOS '\0'
+#define NOT '!'
+#define QUESTION '?'
+#define QUOTE '\\'
+#define STAR '*'
+
+#ifndef DEBUG
+
+#define M_QUOTE 0x8000
+#define M_PROTECT 0x4000
+#define M_MASK 0xffff
+#define M_ASCII 0x00ff
+
+typedef unsigned short Char;
+
+#else
+
+#define M_QUOTE 0x80
+#define M_PROTECT 0x40
+#define M_MASK 0xff
+#define M_ASCII 0x7f
+
+typedef char Char;
+
+#endif
+
+
+#define CHAR(c) ((gchar)((c)&M_ASCII))
+#define META(c) ((gchar)((c)|M_QUOTE))
+#define M_ALL META('*')
+#define M_ONE META('?')
+#define ismeta(c) (((c)&M_QUOTE) != 0)
+
+
+static int
+g_Ctoc(const gchar *, char *, unsigned int);
+
+static int
+glob0(GDir *dir, const gchar *, mono_w32file_unix_glob_t *, gboolean, gboolean);
+static int
+glob1(GDir *dir, gchar *, gchar *, mono_w32file_unix_glob_t *, size_t *, gboolean, gboolean);
+
+static int
+glob3(GDir *dir, gchar *, gchar *, mono_w32file_unix_glob_t *, size_t *, gboolean, gboolean);
+
+static int
+globextend(const gchar *, mono_w32file_unix_glob_t *, size_t *);
+
+static int
+match(const gchar *, gchar *, gchar *, gboolean);
+
+#ifdef DEBUG_ENABLED
+static void qprintf(const char *, Char *);
+#endif
+
+int
+mono_w32file_unix_glob(GDir *dir, const char *pattern, int flags, mono_w32file_unix_glob_t *pglob)
+{
+ const unsigned char *patnext;
+ int c;
+ gchar *bufnext, *bufend, patbuf[PATH_MAX];
+
+ patnext = (unsigned char *) pattern;
+ if (!(flags & W32FILE_UNIX_GLOB_APPEND)) {
+ pglob->gl_pathc = 0;
+ pglob->gl_pathv = NULL;
+ pglob->gl_offs = 0;
+ }
+ pglob->gl_flags = flags & ~W32FILE_UNIX_GLOB_MAGCHAR;
+
+ bufnext = patbuf;
+ bufend = bufnext + PATH_MAX - 1;
+
+ /* Protect the quoted characters. */
+ while (bufnext < bufend && (c = *patnext++) != EOS)
+ if (c == QUOTE) {
+ if ((c = *patnext++) == EOS) {
+ c = QUOTE;
+ --patnext;
+ }
+ *bufnext++ = c | M_PROTECT;
+ } else
+ *bufnext++ = c;
+
+ *bufnext = EOS;
+
+ return glob0(dir, patbuf, pglob, flags & W32FILE_UNIX_GLOB_IGNORECASE,
+ flags & W32FILE_UNIX_GLOB_UNIQUE);
+}
+
+/*
+ * The main glob() routine: compiles the pattern (optionally processing
+ * quotes), calls glob1() to do the real pattern matching, and finally
+ * sorts the list (unless unsorted operation is requested). Returns 0
+ * if things went well, nonzero if errors occurred. It is not an error
+ * to find no matches.
+ */
+static int
+glob0(GDir *dir, const gchar *pattern, mono_w32file_unix_glob_t *pglob, gboolean ignorecase,
+ gboolean unique)
+{
+ const gchar *qpatnext;
+ int c, err, oldpathc;
+ gchar *bufnext, patbuf[PATH_MAX];
+ size_t limit = 0;
+
+ qpatnext = pattern;
+ oldpathc = pglob->gl_pathc;
+ bufnext = patbuf;
+
+ /* We don't need to check for buffer overflow any more. */
+ while ((c = *qpatnext++) != EOS) {
+ switch (c) {
+ case QUESTION:
+ pglob->gl_flags |= W32FILE_UNIX_GLOB_MAGCHAR;
+ *bufnext++ = M_ONE;
+ break;
+ case STAR:
+ pglob->gl_flags |= W32FILE_UNIX_GLOB_MAGCHAR;
+ /* collapse adjacent stars to one,
+ * to avoid exponential behavior
+ */
+ if (bufnext == patbuf || bufnext[-1] != M_ALL)
+ *bufnext++ = M_ALL;
+ break;
+ default:
+ *bufnext++ = CHAR(c);
+ break;
+ }
+ }
+ *bufnext = EOS;
+#ifdef DEBUG_ENABLED
+ qprintf("glob0:", patbuf);
+#endif
+
+ if ((err = glob1(dir, patbuf, patbuf+PATH_MAX-1, pglob, &limit,
+ ignorecase, unique)) != 0)
+ return(err);
+
+ if (pglob->gl_pathc == oldpathc) {
+ return(W32FILE_UNIX_GLOB_NOMATCH);
+ }
+
+ return(0);
+}
+
+static int
+glob1(GDir *dir, gchar *pattern, gchar *pattern_last, mono_w32file_unix_glob_t *pglob,
+ size_t *limitp, gboolean ignorecase, gboolean unique)
+{
+ /* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */
+ if (*pattern == EOS)
+ return(0);
+ return(glob3(dir, pattern, pattern_last, pglob, limitp, ignorecase,
+ unique));
+}
+
+static gboolean contains (mono_w32file_unix_glob_t *pglob, const gchar *name)
+{
+ int i;
+ char **pp;
+
+ if (pglob->gl_pathv != NULL) {
+ pp = pglob->gl_pathv + pglob->gl_offs;
+ for (i = pglob->gl_pathc; i--; ++pp) {
+ if (*pp) {
+ if (!strcmp (*pp, name)) {
+ return(TRUE);
+ }
+ }
+ }
+ }
+
+ return(FALSE);
+}
+
+static int
+glob3(GDir *dir, gchar *pattern, gchar *pattern_last, mono_w32file_unix_glob_t *pglob,
+ size_t *limitp, gboolean ignorecase, gboolean unique)
+{
+ const gchar *name;
+
+ /* Search directory for matching names. */
+ while ((name = g_dir_read_name(dir))) {
+ if (!match(name, pattern, pattern + strlen (pattern),
+ ignorecase)) {
+ continue;
+ }
+ if (!unique ||
+ !contains (pglob, name)) {
+ globextend (name, pglob, limitp);
+ }
+ }
+
+ return(0);
+}
+
+
+/*
+ * Extend the gl_pathv member of a mono_w32file_unix_glob_t structure to accommodate a new item,
+ * add the new item, and update gl_pathc.
+ *
+ * This assumes the BSD realloc, which only copies the block when its size
+ * crosses a power-of-two boundary; for v7 realloc, this would cause quadratic
+ * behavior.
+ *
+ * Return 0 if new item added, error code if memory couldn't be allocated.
+ *
+ * Invariant of the mono_w32file_unix_glob_t structure:
+ * Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and
+ * gl_pathv points to (gl_offs + gl_pathc + 1) items.
+ */
+static int
+globextend(const gchar *path, mono_w32file_unix_glob_t *pglob, size_t *limitp)
+{
+ char **pathv;
+ int i;
+ unsigned int newsize, len;
+ char *copy;
+ const gchar *p;
+
+ newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
+ /* FIXME: Can just use realloc(). */
+ pathv = (char **)(pglob->gl_pathv ? g_realloc ((char *)pglob->gl_pathv, newsize) :
+ g_malloc (newsize));
+ if (pathv == NULL) {
+ if (pglob->gl_pathv) {
+ g_free (pglob->gl_pathv);
+ pglob->gl_pathv = NULL;
+ }
+ return(W32FILE_UNIX_GLOB_NOSPACE);
+ }
+
+ if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
+ /* first time around -- clear initial gl_offs items */
+ pathv += pglob->gl_offs;
+ for (i = pglob->gl_offs; --i >= 0; )
+ *--pathv = NULL;
+ }
+ pglob->gl_pathv = pathv;
+
+ for (p = path; *p++;)
+ ;
+ len = (size_t)(p - path);
+ *limitp += len;
+ if ((copy = (char *)malloc(len)) != NULL) {
+ if (g_Ctoc(path, copy, len)) {
+ g_free (copy);
+ return(W32FILE_UNIX_GLOB_NOSPACE);
+ }
+ pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
+ }
+ pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
+
+#if 0
+ /* Broken on opensuse 11 */
+ if ((pglob->gl_flags & W32FILE_UNIX_GLOB_LIMIT) &&
+ newsize + *limitp >= ARG_MAX) {
+ errno = 0;
+ return(W32FILE_UNIX_GLOB_NOSPACE);
+ }
+#endif
+
+ return(copy == NULL ? W32FILE_UNIX_GLOB_NOSPACE : 0);
+}
+
+
+/*
+ * pattern matching function for filenames. Each occurrence of the *
+ * pattern causes a recursion level.
+ */
+static int
+match(const gchar *name, gchar *pat, gchar *patend, gboolean ignorecase)
+{
+ gchar c;
+
+ while (pat < patend) {
+ c = *pat++;
+ switch (c & M_MASK) {
+ case M_ALL:
+ if (pat == patend)
+ return(1);
+ do {
+ if (match(name, pat, patend, ignorecase))
+ return(1);
+ } while (*name++ != EOS);
+ return(0);
+ case M_ONE:
+ if (*name++ == EOS)
+ return(0);
+ break;
+ default:
+ if (ignorecase) {
+ if (g_ascii_tolower (*name++) != g_ascii_tolower (c))
+ return(0);
+ } else {
+ if (*name++ != c)
+ return(0);
+ }
+
+ break;
+ }
+ }
+ return(*name == EOS);
+}
+
+/* Free allocated data belonging to a mono_w32file_unix_glob_t structure. */
+void
+mono_w32file_unix_globfree(mono_w32file_unix_glob_t *pglob)
+{
+ int i;
+ char **pp;
+
+ if (pglob->gl_pathv != NULL) {
+ pp = pglob->gl_pathv + pglob->gl_offs;
+ for (i = pglob->gl_pathc; i--; ++pp)
+ if (*pp)
+ g_free (*pp);
+ g_free (pglob->gl_pathv);
+ pglob->gl_pathv = NULL;
+ }
+}
+
+static int
+g_Ctoc(const gchar *str, char *buf, unsigned int len)
+{
+
+ while (len--) {
+ if ((*buf++ = *str++) == EOS)
+ return (0);
+ }
+ return (1);
+}
+
+#ifdef DEBUG_ENABLED
+static void
+qprintf(const char *str, Char *s)
+{
+ Char *p;
+
+ (void)printf("%s:\n", str);
+ for (p = s; *p; p++)
+ (void)printf("%c", CHAR(*p));
+ (void)printf("\n");
+ for (p = s; *p; p++)
+ (void)printf("%c", *p & M_PROTECT ? '"' : ' ');
+ (void)printf("\n");
+ for (p = s; *p; p++)
+ (void)printf("%c", ismeta(*p) ? '_' : ' ');
+ (void)printf("\n");
+}
+#endif
--- /dev/null
+/* $OpenBSD: glob.h,v 1.10 2005/12/13 00:35:22 millert Exp $ */
+/* $NetBSD: glob.h,v 1.5 1994/10/26 00:55:56 cgd Exp $ */
+
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Guido van Rossum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)glob.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef __MONO_METADATA_W32FILE_UNIX_GLOB_H__
+#define __MONO_METADATA_W32FILE_UNIX_GLOB_H__
+
+#include <glib.h>
+
+struct stat;
+typedef struct {
+ int gl_pathc; /* Count of total paths so far. */
+ int gl_offs; /* Reserved at beginning of gl_pathv. */
+ int gl_flags; /* Copy of flags parameter to glob. */
+ char **gl_pathv; /* List of paths matching pattern. */
+} mono_w32file_unix_glob_t;
+
+#define W32FILE_UNIX_GLOB_APPEND 0x0001 /* Append to output from previous call. */
+#define W32FILE_UNIX_GLOB_UNIQUE 0x0040 /* When appending only add items that aren't already in the list */
+#define W32FILE_UNIX_GLOB_NOSPACE (-1) /* Malloc call failed. */
+#define W32FILE_UNIX_GLOB_ABORTED (-2) /* Unignored error. */
+#define W32FILE_UNIX_GLOB_NOMATCH (-3) /* No match and W32FILE_UNIX_GLOB_NOCHECK not set. */
+#define W32FILE_UNIX_GLOB_NOSYS (-4) /* Function not supported. */
+
+#define W32FILE_UNIX_GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */
+#define W32FILE_UNIX_GLOB_LIMIT 0x2000 /* Limit pattern match output to ARG_MAX */
+#define W32FILE_UNIX_GLOB_IGNORECASE 0x4000 /* Ignore case when matching */
+#define W32FILE_UNIX_GLOB_ABEND W32FILE_UNIX_GLOB_ABORTED /* backward compatibility */
+
+G_BEGIN_DECLS
+
+int
+mono_w32file_unix_glob (GDir *dir, const char *, int, mono_w32file_unix_glob_t *);
+
+void
+mono_w32file_unix_globfree (mono_w32file_unix_glob_t *);
+
+G_END_DECLS
+
+#endif /* !__MONO_METADATA_W32FILE_UNIX_GLOB_H__ */
--- /dev/null
+
+#include <config.h>
+#include <glib.h>
+
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+#ifdef HAVE_SYS_STATVFS_H
+#include <sys/statvfs.h>
+#endif
+#if defined(HAVE_SYS_STATFS_H)
+#include <sys/statfs.h>
+#endif
+#if defined(HAVE_SYS_PARAM_H) && defined(HAVE_SYS_MOUNT_H)
+#include <sys/param.h>
+#include <sys/mount.h>
+#endif
+#include <sys/types.h>
+#include <stdio.h>
+#include <utime.h>
+#ifdef __linux__
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#include <mono/utils/linux_magic.h>
+#endif
+#include <sys/time.h>
+#ifdef HAVE_DIRENT_H
+# include <dirent.h>
+#endif
+
+#include "w32file.h"
+#include "w32file-internals.h"
+
+#include "w32file-unix-glob.h"
+#include "w32handle.h"
+#include "w32error.h"
+#include "utils/mono-io-portability.h"
+#include "utils/mono-logger-internals.h"
+#include "utils/mono-os-mutex.h"
+#include "utils/mono-threads.h"
+#include "utils/mono-threads-api.h"
+#include "utils/strenc.h"
+
+typedef struct {
+ guint64 device;
+ guint64 inode;
+ guint32 sharemode;
+ guint32 access;
+ guint32 handle_refs;
+ guint32 timestamp;
+} FileShare;
+
+/* Currently used for both FILE, CONSOLE and PIPE handle types.
+ * This may have to change in future. */
+typedef struct {
+ gchar *filename;
+ FileShare *share_info; /* Pointer into shared mem */
+ gint fd;
+ guint32 security_attributes;
+ guint32 fileaccess;
+ guint32 sharemode;
+ guint32 attrs;
+} MonoW32HandleFile;
+
+typedef struct {
+ gchar **namelist;
+ gchar *dir_part;
+ gint num;
+ gsize count;
+} MonoW32HandleFind;
+
+/*
+ * If SHM is disabled, this will point to a hash of FileShare structures, otherwise
+ * it will be NULL. We use this instead of _wapi_fileshare_layout to avoid allocating a
+ * 4MB array.
+ */
+static GHashTable *file_share_table;
+static mono_mutex_t file_share_mutex;
+
+static void
+time_t_to_filetime (time_t timeval, FILETIME *filetime)
+{
+ guint64 ticks;
+
+ ticks = ((guint64)timeval * 10000000) + 116444736000000000ULL;
+ filetime->dwLowDateTime = ticks & 0xFFFFFFFF;
+ filetime->dwHighDateTime = ticks >> 32;
+}
+
+static void
+file_share_release (FileShare *share_info)
+{
+ /* Prevent new entries racing with us */
+ mono_os_mutex_lock (&file_share_mutex);
+
+ g_assert (share_info->handle_refs > 0);
+ share_info->handle_refs -= 1;
+
+ if (share_info->handle_refs == 0)
+ g_hash_table_remove (file_share_table, share_info);
+
+ mono_os_mutex_unlock (&file_share_mutex);
+}
+
+static gint
+file_share_equal (gconstpointer ka, gconstpointer kb)
+{
+ const FileShare *s1 = (const FileShare *)ka;
+ const FileShare *s2 = (const FileShare *)kb;
+
+ return (s1->device == s2->device && s1->inode == s2->inode) ? 1 : 0;
+}
+
+static guint
+file_share_hash (gconstpointer data)
+{
+ const FileShare *s = (const FileShare *)data;
+
+ return s->inode;
+}
+
+static gboolean
+file_share_get (guint64 device, guint64 inode, guint32 new_sharemode, guint32 new_access,
+ guint32 *old_sharemode, guint32 *old_access, FileShare **share_info)
+{
+ FileShare *file_share;
+ gboolean exists = FALSE;
+
+ /* Prevent new entries racing with us */
+ mono_os_mutex_lock (&file_share_mutex);
+
+ FileShare tmp;
+
+ /*
+ * Instead of allocating a 4MB array, we use a hash table to keep track of this
+ * info. This is needed even if SHM is disabled, to track sharing inside
+ * the current process.
+ */
+ if (!file_share_table)
+ file_share_table = g_hash_table_new_full (file_share_hash, file_share_equal, NULL, g_free);
+
+ tmp.device = device;
+ tmp.inode = inode;
+
+ file_share = (FileShare *)g_hash_table_lookup (file_share_table, &tmp);
+ if (file_share) {
+ *old_sharemode = file_share->sharemode;
+ *old_access = file_share->access;
+ *share_info = file_share;
+
+ g_assert (file_share->handle_refs > 0);
+ file_share->handle_refs += 1;
+
+ exists = TRUE;
+ } else {
+ file_share = g_new0 (FileShare, 1);
+
+ file_share->device = device;
+ file_share->inode = inode;
+ file_share->sharemode = new_sharemode;
+ file_share->access = new_access;
+ file_share->handle_refs = 1;
+ *share_info = file_share;
+
+ g_hash_table_insert (file_share_table, file_share, file_share);
+ }
+
+ mono_os_mutex_unlock (&file_share_mutex);
+
+ return(exists);
+}
+
+static gint
+_wapi_open (const gchar *pathname, gint flags, mode_t mode)
+{
+ gint fd;
+ gchar *located_filename;
+
+ if (flags & O_CREAT) {
+ located_filename = mono_portability_find_file (pathname, FALSE);
+ if (located_filename == NULL) {
+ fd = open (pathname, flags, mode);
+ } else {
+ fd = open (located_filename, flags, mode);
+ g_free (located_filename);
+ }
+ } else {
+ fd = open (pathname, flags, mode);
+ if (fd == -1 && (errno == ENOENT || errno == ENOTDIR) && IS_PORTABILITY_SET) {
+ gint saved_errno = errno;
+ located_filename = mono_portability_find_file (pathname, TRUE);
+
+ if (located_filename == NULL) {
+ errno = saved_errno;
+ return -1;
+ }
+
+ fd = open (located_filename, flags, mode);
+ g_free (located_filename);
+ }
+ }
+
+ return(fd);
+}
+
+static gint
+_wapi_access (const gchar *pathname, gint mode)
+{
+ gint ret;
+
+ ret = access (pathname, mode);
+ if (ret == -1 && (errno == ENOENT || errno == ENOTDIR) && IS_PORTABILITY_SET) {
+ gint saved_errno = errno;
+ gchar *located_filename = mono_portability_find_file (pathname, TRUE);
+
+ if (located_filename == NULL) {
+ errno = saved_errno;
+ return -1;
+ }
+
+ ret = access (located_filename, mode);
+ g_free (located_filename);
+ }
+
+ return ret;
+}
+
+static gint
+_wapi_chmod (const gchar *pathname, mode_t mode)
+{
+ gint ret;
+
+ ret = chmod (pathname, mode);
+ if (ret == -1 && (errno == ENOENT || errno == ENOTDIR) && IS_PORTABILITY_SET) {
+ gint saved_errno = errno;
+ gchar *located_filename = mono_portability_find_file (pathname, TRUE);
+
+ if (located_filename == NULL) {
+ errno = saved_errno;
+ return -1;
+ }
+
+ ret = chmod (located_filename, mode);
+ g_free (located_filename);
+ }
+
+ return ret;
+}
+
+static gint
+_wapi_utime (const gchar *filename, const struct utimbuf *buf)
+{
+ gint ret;
+
+ ret = utime (filename, buf);
+ if (ret == -1 && errno == ENOENT && IS_PORTABILITY_SET) {
+ gint saved_errno = errno;
+ gchar *located_filename = mono_portability_find_file (filename, TRUE);
+
+ if (located_filename == NULL) {
+ errno = saved_errno;
+ return -1;
+ }
+
+ ret = utime (located_filename, buf);
+ g_free (located_filename);
+ }
+
+ return ret;
+}
+
+static gint
+_wapi_unlink (const gchar *pathname)
+{
+ gint ret;
+
+ ret = unlink (pathname);
+ if (ret == -1 && (errno == ENOENT || errno == ENOTDIR || errno == EISDIR) && IS_PORTABILITY_SET) {
+ gint saved_errno = errno;
+ gchar *located_filename = mono_portability_find_file (pathname, TRUE);
+
+ if (located_filename == NULL) {
+ errno = saved_errno;
+ return -1;
+ }
+
+ ret = unlink (located_filename);
+ g_free (located_filename);
+ }
+
+ return ret;
+}
+
+static gint
+_wapi_rename (const gchar *oldpath, const gchar *newpath)
+{
+ gint ret;
+ gchar *located_newpath = mono_portability_find_file (newpath, FALSE);
+
+ if (located_newpath == NULL) {
+ ret = rename (oldpath, newpath);
+ } else {
+ ret = rename (oldpath, located_newpath);
+
+ if (ret == -1 && (errno == EISDIR || errno == ENAMETOOLONG || errno == ENOENT || errno == ENOTDIR || errno == EXDEV) && IS_PORTABILITY_SET) {
+ gint saved_errno = errno;
+ gchar *located_oldpath = mono_portability_find_file (oldpath, TRUE);
+
+ if (located_oldpath == NULL) {
+ g_free (located_oldpath);
+ g_free (located_newpath);
+
+ errno = saved_errno;
+ return -1;
+ }
+
+ ret = rename (located_oldpath, located_newpath);
+ g_free (located_oldpath);
+ }
+ g_free (located_newpath);
+ }
+
+ return ret;
+}
+
+static gint
+_wapi_stat (const gchar *path, struct stat *buf)
+{
+ gint ret;
+
+ ret = stat (path, buf);
+ if (ret == -1 && (errno == ENOENT || errno == ENOTDIR) && IS_PORTABILITY_SET) {
+ gint saved_errno = errno;
+ gchar *located_filename = mono_portability_find_file (path, TRUE);
+
+ if (located_filename == NULL) {
+ errno = saved_errno;
+ return -1;
+ }
+
+ ret = stat (located_filename, buf);
+ g_free (located_filename);
+ }
+
+ return ret;
+}
+
+static gint
+_wapi_lstat (const gchar *path, struct stat *buf)
+{
+ gint ret;
+
+ ret = lstat (path, buf);
+ if (ret == -1 && (errno == ENOENT || errno == ENOTDIR) && IS_PORTABILITY_SET) {
+ gint saved_errno = errno;
+ gchar *located_filename = mono_portability_find_file (path, TRUE);
+
+ if (located_filename == NULL) {
+ errno = saved_errno;
+ return -1;
+ }
+
+ ret = lstat (located_filename, buf);
+ g_free (located_filename);
+ }
+
+ return ret;
+}
+
+static gint
+_wapi_mkdir (const gchar *pathname, mode_t mode)
+{
+ gint ret;
+ gchar *located_filename = mono_portability_find_file (pathname, FALSE);
+
+ if (located_filename == NULL) {
+ ret = mkdir (pathname, mode);
+ } else {
+ ret = mkdir (located_filename, mode);
+ g_free (located_filename);
+ }
+
+ return ret;
+}
+
+static gint
+_wapi_rmdir (const gchar *pathname)
+{
+ gint ret;
+
+ ret = rmdir (pathname);
+ if (ret == -1 && (errno == ENOENT || errno == ENOTDIR || errno == ENAMETOOLONG) && IS_PORTABILITY_SET) {
+ gint saved_errno = errno;
+ gchar *located_filename = mono_portability_find_file (pathname, TRUE);
+
+ if (located_filename == NULL) {
+ errno = saved_errno;
+ return -1;
+ }
+
+ ret = rmdir (located_filename);
+ g_free (located_filename);
+ }
+
+ return ret;
+}
+
+static gint
+_wapi_chdir (const gchar *path)
+{
+ gint ret;
+
+ ret = chdir (path);
+ if (ret == -1 && (errno == ENOENT || errno == ENOTDIR || errno == ENAMETOOLONG) && IS_PORTABILITY_SET) {
+ gint saved_errno = errno;
+ gchar *located_filename = mono_portability_find_file (path, TRUE);
+
+ if (located_filename == NULL) {
+ errno = saved_errno;
+ return -1;
+ }
+
+ ret = chdir (located_filename);
+ g_free (located_filename);
+ }
+
+ return ret;
+}
+
+static gchar*
+_wapi_basename (const gchar *filename)
+{
+ gchar *new_filename = g_strdup (filename), *ret;
+
+ if (IS_PORTABILITY_SET) {
+ g_strdelimit (new_filename, "\\", '/');
+ }
+
+ if (IS_PORTABILITY_DRIVE && g_ascii_isalpha (new_filename[0]) && (new_filename[1] == ':')) {
+ gint len = strlen (new_filename);
+
+ g_memmove (new_filename, new_filename + 2, len - 2);
+ new_filename[len - 2] = '\0';
+ }
+
+ ret = g_path_get_basename (new_filename);
+ g_free (new_filename);
+
+ return ret;
+}
+
+static gchar*
+_wapi_dirname (const gchar *filename)
+{
+ gchar *new_filename = g_strdup (filename), *ret;
+
+ if (IS_PORTABILITY_SET) {
+ g_strdelimit (new_filename, "\\", '/');
+ }
+
+ if (IS_PORTABILITY_DRIVE && g_ascii_isalpha (new_filename[0]) && (new_filename[1] == ':')) {
+ gint len = strlen (new_filename);
+
+ g_memmove (new_filename, new_filename + 2, len - 2);
+ new_filename[len - 2] = '\0';
+ }
+
+ ret = g_path_get_dirname (new_filename);
+ g_free (new_filename);
+
+ return ret;
+}
+
+static GDir*
+_wapi_g_dir_open (const gchar *path, guint flags, GError **error)
+{
+ GDir *ret;
+
+ ret = g_dir_open (path, flags, error);
+ if (ret == NULL && ((*error)->code == G_FILE_ERROR_NOENT || (*error)->code == G_FILE_ERROR_NOTDIR || (*error)->code == G_FILE_ERROR_NAMETOOLONG) && IS_PORTABILITY_SET) {
+ gchar *located_filename = mono_portability_find_file (path, TRUE);
+ GError *tmp_error = NULL;
+
+ if (located_filename == NULL) {
+ return(NULL);
+ }
+
+ ret = g_dir_open (located_filename, flags, &tmp_error);
+ g_free (located_filename);
+ if (tmp_error == NULL) {
+ g_clear_error (error);
+ }
+ }
+
+ return ret;
+}
+
+static gint
+get_errno_from_g_file_error (gint error)
+{
+ switch (error) {
+#ifdef EACCESS
+ case G_FILE_ERROR_ACCES: return EACCES;
+#endif
+#ifdef ENAMETOOLONG
+ case G_FILE_ERROR_NAMETOOLONG: return ENAMETOOLONG;
+#endif
+#ifdef ENOENT
+ case G_FILE_ERROR_NOENT: return ENOENT;
+#endif
+#ifdef ENOTDIR
+ case G_FILE_ERROR_NOTDIR: return ENOTDIR;
+#endif
+#ifdef ENXIO
+ case G_FILE_ERROR_NXIO: return ENXIO;
+#endif
+#ifdef ENODEV
+ case G_FILE_ERROR_NODEV: return ENODEV;
+#endif
+#ifdef EROFS
+ case G_FILE_ERROR_ROFS: return EROFS;
+#endif
+#ifdef ETXTBSY
+ case G_FILE_ERROR_TXTBSY: return ETXTBSY;
+#endif
+#ifdef EFAULT
+ case G_FILE_ERROR_FAULT: return EFAULT;
+#endif
+#ifdef ELOOP
+ case G_FILE_ERROR_LOOP: return ELOOP;
+#endif
+#ifdef ENOSPC
+ case G_FILE_ERROR_NOSPC: return ENOSPC;
+#endif
+#ifdef ENOMEM
+ case G_FILE_ERROR_NOMEM: return ENOMEM;
+#endif
+#ifdef EMFILE
+ case G_FILE_ERROR_MFILE: return EMFILE;
+#endif
+#ifdef ENFILE
+ case G_FILE_ERROR_NFILE: return ENFILE;
+#endif
+#ifdef EBADF
+ case G_FILE_ERROR_BADF: return EBADF;
+#endif
+#ifdef EINVAL
+ case G_FILE_ERROR_INVAL: return EINVAL;
+#endif
+#ifdef EPIPE
+ case G_FILE_ERROR_PIPE: return EPIPE;
+#endif
+#ifdef EAGAIN
+ case G_FILE_ERROR_AGAIN: return EAGAIN;
+#endif
+#ifdef EINTR
+ case G_FILE_ERROR_INTR: return EINTR;
+#endif
+#ifdef EWIO
+ case G_FILE_ERROR_IO: return EIO;
+#endif
+#ifdef EPERM
+ case G_FILE_ERROR_PERM: return EPERM;
+#endif
+ case G_FILE_ERROR_FAILED: return ERROR_INVALID_PARAMETER;
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static gint
+file_compare (gconstpointer a, gconstpointer b)
+{
+ gchar *astr = *(gchar **) a;
+ gchar *bstr = *(gchar **) b;
+
+ return strcmp (astr, bstr);
+}
+
+/* scandir using glib */
+static gint
+_wapi_io_scandir (const gchar *dirname, const gchar *pattern, gchar ***namelist)
+{
+ GError *error = NULL;
+ GDir *dir;
+ GPtrArray *names;
+ gint result;
+ mono_w32file_unix_glob_t glob_buf;
+ gint flags = 0, i;
+
+ dir = _wapi_g_dir_open (dirname, 0, &error);
+ if (dir == NULL) {
+ /* g_dir_open returns ENOENT on directories on which we don't
+ * have read/x permission */
+ gint errnum = get_errno_from_g_file_error (error->code);
+ g_error_free (error);
+ if (errnum == ENOENT &&
+ !_wapi_access (dirname, F_OK) &&
+ _wapi_access (dirname, R_OK|X_OK)) {
+ errnum = EACCES;
+ }
+
+ errno = errnum;
+ return -1;
+ }
+
+ if (IS_PORTABILITY_CASE) {
+ flags = W32FILE_UNIX_GLOB_IGNORECASE;
+ }
+
+ result = mono_w32file_unix_glob (dir, pattern, flags, &glob_buf);
+ if (g_str_has_suffix (pattern, ".*")) {
+ /* Special-case the patterns ending in '.*', as
+ * windows also matches entries with no extension with
+ * this pattern.
+ *
+ * TODO: should this be a MONO_IOMAP option?
+ */
+ gchar *pattern2 = g_strndup (pattern, strlen (pattern) - 2);
+ gint result2;
+
+ g_dir_rewind (dir);
+ result2 = mono_w32file_unix_glob (dir, pattern2, flags | W32FILE_UNIX_GLOB_APPEND | W32FILE_UNIX_GLOB_UNIQUE, &glob_buf);
+
+ g_free (pattern2);
+
+ if (result != 0) {
+ result = result2;
+ }
+ }
+
+ g_dir_close (dir);
+ if (glob_buf.gl_pathc == 0) {
+ return(0);
+ } else if (result != 0) {
+ return -1;
+ }
+
+ names = g_ptr_array_new ();
+ for (i = 0; i < glob_buf.gl_pathc; i++) {
+ g_ptr_array_add (names, g_strdup (glob_buf.gl_pathv[i]));
+ }
+
+ mono_w32file_unix_globfree (&glob_buf);
+
+ result = names->len;
+ if (result > 0) {
+ g_ptr_array_sort (names, file_compare);
+ g_ptr_array_set_size (names, result + 1);
+
+ *namelist = (gchar **) g_ptr_array_free (names, FALSE);
+ } else {
+ g_ptr_array_free (names, TRUE);
+ }
+
+ return result;
+}
+
+static gboolean
+_wapi_lock_file_region (gint fd, off_t offset, off_t length)
+{
+#if defined(__native_client__)
+ printf("WARNING: %s: fcntl() not available on Native Client!\n", __func__);
+ // behave as below -- locks are not available
+ return TRUE;
+#else
+ struct flock lock_data;
+ gint ret;
+
+ if (offset < 0 || length < 0) {
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ lock_data.l_type = F_WRLCK;
+ lock_data.l_whence = SEEK_SET;
+ lock_data.l_start = offset;
+ lock_data.l_len = length;
+
+ do {
+ ret = fcntl (fd, F_SETLK, &lock_data);
+ } while(ret == -1 && errno == EINTR);
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fcntl returns %d", __func__, ret);
+
+ if (ret == -1) {
+ /*
+ * if locks are not available (NFS for example),
+ * ignore the error
+ */
+ if (errno == ENOLCK
+#ifdef EOPNOTSUPP
+ || errno == EOPNOTSUPP
+#endif
+#ifdef ENOTSUP
+ || errno == ENOTSUP
+#endif
+ ) {
+ return TRUE;
+ }
+
+ mono_w32error_set_last (ERROR_LOCK_VIOLATION);
+ return FALSE;
+ }
+
+ return TRUE;
+#endif /* __native_client__ */
+}
+
+static gboolean
+_wapi_unlock_file_region (gint fd, off_t offset, off_t length)
+{
+#if defined(__native_client__)
+ printf("WARNING: %s: fcntl() not available on Native Client!\n", __func__);
+ return TRUE;
+#else
+ struct flock lock_data;
+ gint ret;
+
+ lock_data.l_type = F_UNLCK;
+ lock_data.l_whence = SEEK_SET;
+ lock_data.l_start = offset;
+ lock_data.l_len = length;
+
+ do {
+ ret = fcntl (fd, F_SETLK, &lock_data);
+ } while(ret == -1 && errno == EINTR);
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fcntl returns %d", __func__, ret);
+
+ if (ret == -1) {
+ /*
+ * if locks are not available (NFS for example),
+ * ignore the error
+ */
+ if (errno == ENOLCK
+#ifdef EOPNOTSUPP
+ || errno == EOPNOTSUPP
+#endif
+#ifdef ENOTSUP
+ || errno == ENOTSUP
+#endif
+ ) {
+ return TRUE;
+ }
+
+ mono_w32error_set_last (ERROR_LOCK_VIOLATION);
+ return FALSE;
+ }
+
+ return TRUE;
+#endif /* __native_client__ */
+}
+
+static void file_close (gpointer handle, gpointer data);
+static void file_details (gpointer data);
+static const gchar* file_typename (void);
+static gsize file_typesize (void);
+static gint file_getfiletype(void);
+static gboolean file_read(gpointer handle, gpointer buffer, guint32 numbytes, guint32 *bytesread);
+static gboolean file_write(gpointer handle, gconstpointer buffer, guint32 numbytes, guint32 *byteswritten);
+static gboolean file_flush(gpointer handle);
+static guint32 file_seek(gpointer handle, gint32 movedistance,
+ gint32 *highmovedistance, gint method);
+static gboolean file_setendoffile(gpointer handle);
+static guint32 file_getfilesize(gpointer handle, guint32 *highsize);
+static gboolean file_getfiletime(gpointer handle, FILETIME *create_time,
+ FILETIME *access_time,
+ FILETIME *write_time);
+static gboolean file_setfiletime(gpointer handle,
+ const FILETIME *create_time,
+ const FILETIME *access_time,
+ const FILETIME *write_time);
+static guint32 GetDriveTypeFromPath (const gchar *utf8_root_path_name);
+
+/* File handle is only signalled for overlapped IO */
+static MonoW32HandleOps _wapi_file_ops = {
+ file_close, /* close */
+ NULL, /* signal */
+ NULL, /* own */
+ NULL, /* is_owned */
+ NULL, /* special_wait */
+ NULL, /* prewait */
+ file_details, /* details */
+ file_typename, /* typename */
+ file_typesize, /* typesize */
+};
+
+static void console_close (gpointer handle, gpointer data);
+static void console_details (gpointer data);
+static const gchar* console_typename (void);
+static gsize console_typesize (void);
+static gint console_getfiletype(void);
+static gboolean console_read(gpointer handle, gpointer buffer, guint32 numbytes, guint32 *bytesread);
+static gboolean console_write(gpointer handle, gconstpointer buffer, guint32 numbytes, guint32 *byteswritten);
+
+/* Console is mostly the same as file, except it can block waiting for
+ * input or output
+ */
+static MonoW32HandleOps _wapi_console_ops = {
+ console_close, /* close */
+ NULL, /* signal */
+ NULL, /* own */
+ NULL, /* is_owned */
+ NULL, /* special_wait */
+ NULL, /* prewait */
+ console_details, /* details */
+ console_typename, /* typename */
+ console_typesize, /* typesize */
+};
+
+static const gchar* find_typename (void);
+static gsize find_typesize (void);
+
+static MonoW32HandleOps _wapi_find_ops = {
+ NULL, /* close */
+ NULL, /* signal */
+ NULL, /* own */
+ NULL, /* is_owned */
+ NULL, /* special_wait */
+ NULL, /* prewait */
+ NULL, /* details */
+ find_typename, /* typename */
+ find_typesize, /* typesize */
+};
+
+static void pipe_close (gpointer handle, gpointer data);
+static void pipe_details (gpointer data);
+static const gchar* pipe_typename (void);
+static gsize pipe_typesize (void);
+static gint pipe_getfiletype (void);
+static gboolean pipe_read (gpointer handle, gpointer buffer, guint32 numbytes, guint32 *bytesread);
+static gboolean pipe_write (gpointer handle, gconstpointer buffer, guint32 numbytes, guint32 *byteswritten);
+
+/* Pipe handles
+ */
+static MonoW32HandleOps _wapi_pipe_ops = {
+ pipe_close, /* close */
+ NULL, /* signal */
+ NULL, /* own */
+ NULL, /* is_owned */
+ NULL, /* special_wait */
+ NULL, /* prewait */
+ pipe_details, /* details */
+ pipe_typename, /* typename */
+ pipe_typesize, /* typesize */
+};
+
+static const struct {
+ /* File, console and pipe handles */
+ gint (*getfiletype)(void);
+
+ /* File, console and pipe handles */
+ gboolean (*readfile)(gpointer handle, gpointer buffer, guint32 numbytes, guint32 *bytesread);
+ gboolean (*writefile)(gpointer handle, gconstpointer buffer, guint32 numbytes, guint32 *byteswritten);
+ gboolean (*flushfile)(gpointer handle);
+
+ /* File handles */
+ guint32 (*seek)(gpointer handle, gint32 movedistance,
+ gint32 *highmovedistance, gint method);
+ gboolean (*setendoffile)(gpointer handle);
+ guint32 (*getfilesize)(gpointer handle, guint32 *highsize);
+ gboolean (*getfiletime)(gpointer handle, FILETIME *create_time,
+ FILETIME *access_time,
+ FILETIME *write_time);
+ gboolean (*setfiletime)(gpointer handle,
+ const FILETIME *create_time,
+ const FILETIME *access_time,
+ const FILETIME *write_time);
+} io_ops[MONO_W32HANDLE_COUNT]={
+ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+ /* file */
+ {file_getfiletype,
+ file_read, file_write,
+ file_flush, file_seek,
+ file_setendoffile,
+ file_getfilesize,
+ file_getfiletime,
+ file_setfiletime},
+ /* console */
+ {console_getfiletype,
+ console_read,
+ console_write,
+ NULL, NULL, NULL, NULL, NULL, NULL},
+ /* thread */
+ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+ /* sem */
+ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+ /* mutex */
+ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+ /* event */
+ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+ /* socket (will need at least read and write) */
+ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+ /* find */
+ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+ /* process */
+ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+ /* pipe */
+ {pipe_getfiletype,
+ pipe_read,
+ pipe_write,
+ NULL, NULL, NULL, NULL, NULL, NULL},
+};
+
+static gboolean lock_while_writing = FALSE;
+
+/* Some utility functions.
+ */
+
+/*
+ * Check if a file is writable by the current user.
+ *
+ * This is is a best effort kind of thing. It assumes a reasonable sane set
+ * of permissions by the underlying OS.
+ *
+ * We generally assume that basic unix permission bits are authoritative. Which might not
+ * be the case under systems with extended permissions systems (posix ACLs, SELinux, OSX/iOS sandboxing, etc)
+ *
+ * The choice of access as the fallback is due to the expected lower overhead compared to trying to open the file.
+ *
+ * The only expected problem with using access are for root, setuid or setgid programs as access is not consistent
+ * under those situations. It's to be expected that this should not happen in practice as those bits are very dangerous
+ * and should not be used with a dynamic runtime.
+ */
+static gboolean
+is_file_writable (struct stat *st, const gchar *path)
+{
+#if __APPLE__
+ // OS X Finder "locked" or `ls -lO` "uchg".
+ // This only covers one of several cases where an OS X file could be unwritable through special flags.
+ if (st->st_flags & (UF_IMMUTABLE|SF_IMMUTABLE))
+ return 0;
+#endif
+
+ /* Is it globally writable? */
+ if (st->st_mode & S_IWOTH)
+ return 1;
+
+ /* Am I the owner? */
+ if ((st->st_uid == geteuid ()) && (st->st_mode & S_IWUSR))
+ return 1;
+
+ /* Am I in the same group? */
+ if ((st->st_gid == getegid ()) && (st->st_mode & S_IWGRP))
+ return 1;
+
+ /* Fallback to using access(2). It's not ideal as it might not take into consideration euid/egid
+ * but it's the only sane option we have on unix.
+ */
+ return access (path, W_OK) == 0;
+}
+
+
+static guint32 _wapi_stat_to_file_attributes (const gchar *pathname,
+ struct stat *buf,
+ struct stat *lbuf)
+{
+ guint32 attrs = 0;
+ gchar *filename;
+
+ /* FIXME: this could definitely be better, but there seems to
+ * be no pattern to the attributes that are set
+ */
+
+ /* Sockets (0140000) != Directory (040000) + Regular file (0100000) */
+ if (S_ISSOCK (buf->st_mode))
+ buf->st_mode &= ~S_IFSOCK; /* don't consider socket protection */
+
+ filename = _wapi_basename (pathname);
+
+ if (S_ISDIR (buf->st_mode)) {
+ attrs = FILE_ATTRIBUTE_DIRECTORY;
+ if (!is_file_writable (buf, pathname)) {
+ attrs |= FILE_ATTRIBUTE_READONLY;
+ }
+ if (filename[0] == '.') {
+ attrs |= FILE_ATTRIBUTE_HIDDEN;
+ }
+ } else {
+ if (!is_file_writable (buf, pathname)) {
+ attrs = FILE_ATTRIBUTE_READONLY;
+
+ if (filename[0] == '.') {
+ attrs |= FILE_ATTRIBUTE_HIDDEN;
+ }
+ } else if (filename[0] == '.') {
+ attrs = FILE_ATTRIBUTE_HIDDEN;
+ } else {
+ attrs = FILE_ATTRIBUTE_NORMAL;
+ }
+ }
+
+ if (lbuf != NULL) {
+ if (S_ISLNK (lbuf->st_mode)) {
+ attrs |= FILE_ATTRIBUTE_REPARSE_POINT;
+ }
+ }
+
+ g_free (filename);
+
+ return attrs;
+}
+
+static void
+_wapi_set_last_error_from_errno (void)
+{
+ mono_w32error_set_last (mono_w32error_unix_to_win32 (errno));
+}
+
+static void _wapi_set_last_path_error_from_errno (const gchar *dir,
+ const gchar *path)
+{
+ if (errno == ENOENT) {
+ /* Check the path - if it's a missing directory then
+ * we need to set PATH_NOT_FOUND not FILE_NOT_FOUND
+ */
+ gchar *dirname;
+
+
+ if (dir == NULL) {
+ dirname = _wapi_dirname (path);
+ } else {
+ dirname = g_strdup (dir);
+ }
+
+ if (_wapi_access (dirname, F_OK) == 0) {
+ mono_w32error_set_last (ERROR_FILE_NOT_FOUND);
+ } else {
+ mono_w32error_set_last (ERROR_PATH_NOT_FOUND);
+ }
+
+ g_free (dirname);
+ } else {
+ _wapi_set_last_error_from_errno ();
+ }
+}
+
+/* Handle ops.
+ */
+static void file_close (gpointer handle, gpointer data)
+{
+ MonoW32HandleFile *file_handle = (MonoW32HandleFile *)data;
+ gint fd = file_handle->fd;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing file handle %p [%s]", __func__, handle,
+ file_handle->filename);
+
+ if (file_handle->attrs & FILE_FLAG_DELETE_ON_CLOSE)
+ _wapi_unlink (file_handle->filename);
+
+ g_free (file_handle->filename);
+
+ if (file_handle->share_info)
+ file_share_release (file_handle->share_info);
+
+ close (fd);
+}
+
+static void file_details (gpointer data)
+{
+ MonoW32HandleFile *file = (MonoW32HandleFile *)data;
+
+ g_print ("[%20s] acc: %c%c%c, shr: %c%c%c, attrs: %5u",
+ file->filename,
+ file->fileaccess&GENERIC_READ?'R':'.',
+ file->fileaccess&GENERIC_WRITE?'W':'.',
+ file->fileaccess&GENERIC_EXECUTE?'X':'.',
+ file->sharemode&FILE_SHARE_READ?'R':'.',
+ file->sharemode&FILE_SHARE_WRITE?'W':'.',
+ file->sharemode&FILE_SHARE_DELETE?'D':'.',
+ file->attrs);
+}
+
+static const gchar* file_typename (void)
+{
+ return "File";
+}
+
+static gsize file_typesize (void)
+{
+ return sizeof (MonoW32HandleFile);
+}
+
+static gint file_getfiletype(void)
+{
+ return(FILE_TYPE_DISK);
+}
+
+static gboolean
+file_read(gpointer handle, gpointer buffer, guint32 numbytes, guint32 *bytesread)
+{
+ MonoW32HandleFile *file_handle;
+ gboolean ok;
+ gint fd, ret;
+ MonoThreadInfo *info = mono_thread_info_current ();
+
+ ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
+ (gpointer *)&file_handle);
+ if(ok==FALSE) {
+ g_warning ("%s: error looking up file handle %p", __func__,
+ handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ fd = file_handle->fd;
+ if(bytesread!=NULL) {
+ *bytesread=0;
+ }
+
+ if(!(file_handle->fileaccess & GENERIC_READ) &&
+ !(file_handle->fileaccess & GENERIC_ALL)) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
+ __func__, handle, file_handle->fileaccess);
+
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
+ return(FALSE);
+ }
+
+ do {
+ ret = read (fd, buffer, numbytes);
+ } while (ret == -1 && errno == EINTR &&
+ !mono_thread_info_is_interrupt_state (info));
+
+ if(ret==-1) {
+ gint err = errno;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read of handle %p error: %s", __func__,
+ handle, strerror(err));
+ mono_w32error_set_last (mono_w32error_unix_to_win32 (err));
+ return(FALSE);
+ }
+
+ if (bytesread != NULL) {
+ *bytesread = ret;
+ }
+
+ return(TRUE);
+}
+
+static gboolean
+file_write(gpointer handle, gconstpointer buffer, guint32 numbytes, guint32 *byteswritten)
+{
+ MonoW32HandleFile *file_handle;
+ gboolean ok;
+ gint ret, fd;
+ off_t current_pos = 0;
+ MonoThreadInfo *info = mono_thread_info_current ();
+
+ ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
+ (gpointer *)&file_handle);
+ if(ok==FALSE) {
+ g_warning ("%s: error looking up file handle %p", __func__,
+ handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ fd = file_handle->fd;
+
+ if(byteswritten!=NULL) {
+ *byteswritten=0;
+ }
+
+ if(!(file_handle->fileaccess & GENERIC_WRITE) &&
+ !(file_handle->fileaccess & GENERIC_ALL)) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
+ return(FALSE);
+ }
+
+ if (lock_while_writing) {
+ /* Need to lock the region we're about to write to,
+ * because we only do advisory locking on POSIX
+ * systems
+ */
+ current_pos = lseek (fd, (off_t)0, SEEK_CUR);
+ if (current_pos == -1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p lseek failed: %s", __func__,
+ handle, strerror (errno));
+ _wapi_set_last_error_from_errno ();
+ return(FALSE);
+ }
+
+ if (_wapi_lock_file_region (fd, current_pos,
+ numbytes) == FALSE) {
+ /* The error has already been set */
+ return(FALSE);
+ }
+ }
+
+ do {
+ ret = write (fd, buffer, numbytes);
+ } while (ret == -1 && errno == EINTR &&
+ !mono_thread_info_is_interrupt_state (info));
+
+ if (lock_while_writing) {
+ _wapi_unlock_file_region (fd, current_pos, numbytes);
+ }
+
+ if (ret == -1) {
+ if (errno == EINTR) {
+ ret = 0;
+ } else {
+ _wapi_set_last_error_from_errno ();
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write of handle %p error: %s",
+ __func__, handle, strerror(errno));
+
+ return(FALSE);
+ }
+ }
+ if (byteswritten != NULL) {
+ *byteswritten = ret;
+ }
+ return(TRUE);
+}
+
+static gboolean file_flush(gpointer handle)
+{
+ MonoW32HandleFile *file_handle;
+ gboolean ok;
+ gint ret, fd;
+
+ ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
+ (gpointer *)&file_handle);
+ if(ok==FALSE) {
+ g_warning ("%s: error looking up file handle %p", __func__,
+ handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ fd = file_handle->fd;
+
+ if(!(file_handle->fileaccess & GENERIC_WRITE) &&
+ !(file_handle->fileaccess & GENERIC_ALL)) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
+ return(FALSE);
+ }
+
+ ret=fsync(fd);
+ if (ret==-1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fsync of handle %p error: %s", __func__, handle,
+ strerror(errno));
+
+ _wapi_set_last_error_from_errno ();
+ return(FALSE);
+ }
+
+ return(TRUE);
+}
+
+static guint32 file_seek(gpointer handle, gint32 movedistance,
+ gint32 *highmovedistance, gint method)
+{
+ MonoW32HandleFile *file_handle;
+ gboolean ok;
+ gint64 offset, newpos;
+ gint whence, fd;
+ guint32 ret;
+
+ ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
+ (gpointer *)&file_handle);
+ if(ok==FALSE) {
+ g_warning ("%s: error looking up file handle %p", __func__,
+ handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(INVALID_SET_FILE_POINTER);
+ }
+
+ fd = file_handle->fd;
+
+ if(!(file_handle->fileaccess & GENERIC_READ) &&
+ !(file_handle->fileaccess & GENERIC_WRITE) &&
+ !(file_handle->fileaccess & GENERIC_ALL)) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
+ return(INVALID_SET_FILE_POINTER);
+ }
+
+ switch(method) {
+ case FILE_BEGIN:
+ whence=SEEK_SET;
+ break;
+ case FILE_CURRENT:
+ whence=SEEK_CUR;
+ break;
+ case FILE_END:
+ whence=SEEK_END;
+ break;
+ default:
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: invalid seek type %d", __func__, method);
+
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return(INVALID_SET_FILE_POINTER);
+ }
+
+#ifdef HAVE_LARGE_FILE_SUPPORT
+ if(highmovedistance==NULL) {
+ offset=movedistance;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setting offset to %lld (low %d)", __func__,
+ offset, movedistance);
+ } else {
+ offset=((gint64) *highmovedistance << 32) | (guint32)movedistance;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setting offset to %lld 0x%llx (high %d 0x%x, low %d 0x%x)", __func__, offset, offset, *highmovedistance, *highmovedistance, movedistance, movedistance);
+ }
+#else
+ offset=movedistance;
+#endif
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: moving handle %p by %lld bytes from %d", __func__,
+ handle, (long long)offset, whence);
+
+#ifdef PLATFORM_ANDROID
+ /* bionic doesn't support -D_FILE_OFFSET_BITS=64 */
+ newpos=lseek64(fd, offset, whence);
+#else
+ newpos=lseek(fd, offset, whence);
+#endif
+ if(newpos==-1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: lseek on handle %p returned error %s",
+ __func__, handle, strerror(errno));
+
+ _wapi_set_last_error_from_errno ();
+ return(INVALID_SET_FILE_POINTER);
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: lseek returns %lld", __func__, newpos);
+
+#ifdef HAVE_LARGE_FILE_SUPPORT
+ ret=newpos & 0xFFFFFFFF;
+ if(highmovedistance!=NULL) {
+ *highmovedistance=newpos>>32;
+ }
+#else
+ ret=newpos;
+ if(highmovedistance!=NULL) {
+ /* Accurate, but potentially dodgy :-) */
+ *highmovedistance=0;
+ }
+#endif
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: move of handle %p returning %d/%d", __func__,
+ handle, ret, highmovedistance==NULL?0:*highmovedistance);
+
+ return(ret);
+}
+
+static gboolean file_setendoffile(gpointer handle)
+{
+ MonoW32HandleFile *file_handle;
+ gboolean ok;
+ struct stat statbuf;
+ off_t pos;
+ gint ret, fd;
+ MonoThreadInfo *info = mono_thread_info_current ();
+
+ ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
+ (gpointer *)&file_handle);
+ if(ok==FALSE) {
+ g_warning ("%s: error looking up file handle %p", __func__,
+ handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+ fd = file_handle->fd;
+
+ if(!(file_handle->fileaccess & GENERIC_WRITE) &&
+ !(file_handle->fileaccess & GENERIC_ALL)) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
+ return(FALSE);
+ }
+
+ /* Find the current file position, and the file length. If
+ * the file position is greater than the length, write to
+ * extend the file with a hole. If the file position is less
+ * than the length, truncate the file.
+ */
+
+ ret=fstat(fd, &statbuf);
+ if(ret==-1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__,
+ handle, strerror(errno));
+
+ _wapi_set_last_error_from_errno ();
+ return(FALSE);
+ }
+
+ pos=lseek(fd, (off_t)0, SEEK_CUR);
+ if(pos==-1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p lseek failed: %s", __func__,
+ handle, strerror(errno));
+
+ _wapi_set_last_error_from_errno ();
+ return(FALSE);
+ }
+
+#ifdef FTRUNCATE_DOESNT_EXTEND
+ off_t size = statbuf.st_size;
+ /* I haven't bothered to write the configure.ac stuff for this
+ * because I don't know if any platform needs it. I'm leaving
+ * this code just in case though
+ */
+ if(pos>size) {
+ /* Extend the file. Use write() here, because some
+ * manuals say that ftruncate() behaviour is undefined
+ * when the file needs extending. The POSIX spec says
+ * that on XSI-conformant systems it extends, so if
+ * every system we care about conforms, then we can
+ * drop this write.
+ */
+ do {
+ ret = write (fd, "", 1);
+ } while (ret == -1 && errno == EINTR &&
+ !mono_thread_info_is_interrupt_state (info));
+
+ if(ret==-1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p extend write failed: %s", __func__, handle, strerror(errno));
+
+ _wapi_set_last_error_from_errno ();
+ return(FALSE);
+ }
+
+ /* And put the file position back after the write */
+ ret = lseek (fd, pos, SEEK_SET);
+ if (ret == -1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p second lseek failed: %s",
+ __func__, handle, strerror(errno));
+
+ _wapi_set_last_error_from_errno ();
+ return(FALSE);
+ }
+ }
+#endif
+
+/* Native Client has no ftruncate function, even in standalone sel_ldr. */
+#ifndef __native_client__
+ /* always truncate, because the extend write() adds an extra
+ * byte to the end of the file
+ */
+ do {
+ ret=ftruncate(fd, pos);
+ }
+ while (ret==-1 && errno==EINTR && !mono_thread_info_is_interrupt_state (info));
+ if(ret==-1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p ftruncate failed: %s", __func__,
+ handle, strerror(errno));
+
+ _wapi_set_last_error_from_errno ();
+ return(FALSE);
+ }
+#endif
+
+ return(TRUE);
+}
+
+static guint32 file_getfilesize(gpointer handle, guint32 *highsize)
+{
+ MonoW32HandleFile *file_handle;
+ gboolean ok;
+ struct stat statbuf;
+ guint32 size;
+ gint ret;
+ gint fd;
+
+ ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
+ (gpointer *)&file_handle);
+ if(ok==FALSE) {
+ g_warning ("%s: error looking up file handle %p", __func__,
+ handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(INVALID_FILE_SIZE);
+ }
+ fd = file_handle->fd;
+
+ if(!(file_handle->fileaccess & GENERIC_READ) &&
+ !(file_handle->fileaccess & GENERIC_WRITE) &&
+ !(file_handle->fileaccess & GENERIC_ALL)) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
+ return(INVALID_FILE_SIZE);
+ }
+
+ /* If the file has a size with the low bits 0xFFFFFFFF the
+ * caller can't tell if this is an error, so clear the error
+ * value
+ */
+ mono_w32error_set_last (ERROR_SUCCESS);
+
+ ret = fstat(fd, &statbuf);
+ if (ret == -1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__,
+ handle, strerror(errno));
+
+ _wapi_set_last_error_from_errno ();
+ return(INVALID_FILE_SIZE);
+ }
+
+ /* fstat indicates block devices as zero-length, so go a different path */
+#ifdef BLKGETSIZE64
+ if (S_ISBLK(statbuf.st_mode)) {
+ guint64 bigsize;
+ if (ioctl(fd, BLKGETSIZE64, &bigsize) < 0) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p ioctl BLKGETSIZE64 failed: %s",
+ __func__, handle, strerror(errno));
+
+ _wapi_set_last_error_from_errno ();
+ return(INVALID_FILE_SIZE);
+ }
+
+ size = bigsize & 0xFFFFFFFF;
+ if (highsize != NULL) {
+ *highsize = bigsize>>32;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning block device size %d/%d",
+ __func__, size, *highsize);
+
+ return(size);
+ }
+#endif
+
+#ifdef HAVE_LARGE_FILE_SUPPORT
+ size = statbuf.st_size & 0xFFFFFFFF;
+ if (highsize != NULL) {
+ *highsize = statbuf.st_size>>32;
+ }
+#else
+ if (highsize != NULL) {
+ /* Accurate, but potentially dodgy :-) */
+ *highsize = 0;
+ }
+ size = statbuf.st_size;
+#endif
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning size %d/%d", __func__, size, *highsize);
+
+ return(size);
+}
+
+static gboolean file_getfiletime(gpointer handle, FILETIME *create_time,
+ FILETIME *access_time,
+ FILETIME *write_time)
+{
+ MonoW32HandleFile *file_handle;
+ gboolean ok;
+ struct stat statbuf;
+ guint64 create_ticks, access_ticks, write_ticks;
+ gint ret, fd;
+
+ ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
+ (gpointer *)&file_handle);
+ if(ok==FALSE) {
+ g_warning ("%s: error looking up file handle %p", __func__,
+ handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+ fd = file_handle->fd;
+
+ if(!(file_handle->fileaccess & GENERIC_READ) &&
+ !(file_handle->fileaccess & GENERIC_ALL)) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
+ __func__, handle, file_handle->fileaccess);
+
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
+ return(FALSE);
+ }
+
+ ret=fstat(fd, &statbuf);
+ if(ret==-1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__, handle,
+ strerror(errno));
+
+ _wapi_set_last_error_from_errno ();
+ return(FALSE);
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: atime: %ld ctime: %ld mtime: %ld", __func__,
+ statbuf.st_atime, statbuf.st_ctime,
+ statbuf.st_mtime);
+
+ /* Try and guess a meaningful create time by using the older
+ * of atime or ctime
+ */
+ /* The magic constant comes from msdn documentation
+ * "Converting a time_t Value to a File Time"
+ */
+ if(statbuf.st_atime < statbuf.st_ctime) {
+ create_ticks=((guint64)statbuf.st_atime*10000000)
+ + 116444736000000000ULL;
+ } else {
+ create_ticks=((guint64)statbuf.st_ctime*10000000)
+ + 116444736000000000ULL;
+ }
+
+ access_ticks=((guint64)statbuf.st_atime*10000000)+116444736000000000ULL;
+ write_ticks=((guint64)statbuf.st_mtime*10000000)+116444736000000000ULL;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: aticks: %llu cticks: %llu wticks: %llu", __func__,
+ access_ticks, create_ticks, write_ticks);
+
+ if(create_time!=NULL) {
+ create_time->dwLowDateTime = create_ticks & 0xFFFFFFFF;
+ create_time->dwHighDateTime = create_ticks >> 32;
+ }
+
+ if(access_time!=NULL) {
+ access_time->dwLowDateTime = access_ticks & 0xFFFFFFFF;
+ access_time->dwHighDateTime = access_ticks >> 32;
+ }
+
+ if(write_time!=NULL) {
+ write_time->dwLowDateTime = write_ticks & 0xFFFFFFFF;
+ write_time->dwHighDateTime = write_ticks >> 32;
+ }
+
+ return(TRUE);
+}
+
+static gboolean file_setfiletime(gpointer handle,
+ const FILETIME *create_time G_GNUC_UNUSED,
+ const FILETIME *access_time,
+ const FILETIME *write_time)
+{
+ MonoW32HandleFile *file_handle;
+ gboolean ok;
+ struct utimbuf utbuf;
+ struct stat statbuf;
+ guint64 access_ticks, write_ticks;
+ gint ret, fd;
+
+ ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE,
+ (gpointer *)&file_handle);
+ if(ok==FALSE) {
+ g_warning ("%s: error looking up file handle %p", __func__,
+ handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+ fd = file_handle->fd;
+
+ if(!(file_handle->fileaccess & GENERIC_WRITE) &&
+ !(file_handle->fileaccess & GENERIC_ALL)) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
+ return(FALSE);
+ }
+
+ if(file_handle->filename == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p unknown filename", __func__, handle);
+
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ /* Get the current times, so we can put the same times back in
+ * the event that one of the FileTime structs is NULL
+ */
+ ret=fstat (fd, &statbuf);
+ if(ret==-1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__, handle,
+ strerror(errno));
+
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return(FALSE);
+ }
+
+ if(access_time!=NULL) {
+ access_ticks=((guint64)access_time->dwHighDateTime << 32) +
+ access_time->dwLowDateTime;
+ /* This is (time_t)0. We can actually go to INT_MIN,
+ * but this will do for now.
+ */
+ if (access_ticks < 116444736000000000ULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt to set access time too early",
+ __func__);
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return(FALSE);
+ }
+
+ if (sizeof (utbuf.actime) == 4 && ((access_ticks - 116444736000000000ULL) / 10000000) > INT_MAX) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt to set write time that is too big for a 32bits time_t",
+ __func__);
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return(FALSE);
+ }
+
+ utbuf.actime=(access_ticks - 116444736000000000ULL) / 10000000;
+ } else {
+ utbuf.actime=statbuf.st_atime;
+ }
+
+ if(write_time!=NULL) {
+ write_ticks=((guint64)write_time->dwHighDateTime << 32) +
+ write_time->dwLowDateTime;
+ /* This is (time_t)0. We can actually go to INT_MIN,
+ * but this will do for now.
+ */
+ if (write_ticks < 116444736000000000ULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt to set write time too early",
+ __func__);
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return(FALSE);
+ }
+ if (sizeof (utbuf.modtime) == 4 && ((write_ticks - 116444736000000000ULL) / 10000000) > INT_MAX) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt to set write time that is too big for a 32bits time_t",
+ __func__);
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return(FALSE);
+ }
+
+ utbuf.modtime=(write_ticks - 116444736000000000ULL) / 10000000;
+ } else {
+ utbuf.modtime=statbuf.st_mtime;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setting handle %p access %ld write %ld", __func__,
+ handle, utbuf.actime, utbuf.modtime);
+
+ ret = _wapi_utime (file_handle->filename, &utbuf);
+ if (ret == -1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p [%s] utime failed: %s", __func__,
+ handle, file_handle->filename, strerror(errno));
+
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return(FALSE);
+ }
+
+ return(TRUE);
+}
+
+static void console_close (gpointer handle, gpointer data)
+{
+ MonoW32HandleFile *console_handle = (MonoW32HandleFile *)data;
+ gint fd = console_handle->fd;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing console handle %p", __func__, handle);
+
+ g_free (console_handle->filename);
+
+ if (fd > 2) {
+ if (console_handle->share_info)
+ file_share_release (console_handle->share_info);
+ close (fd);
+ }
+}
+
+static void console_details (gpointer data)
+{
+ file_details (data);
+}
+
+static const gchar* console_typename (void)
+{
+ return "Console";
+}
+
+static gsize console_typesize (void)
+{
+ return sizeof (MonoW32HandleFile);
+}
+
+static gint console_getfiletype(void)
+{
+ return(FILE_TYPE_CHAR);
+}
+
+static gboolean
+console_read(gpointer handle, gpointer buffer, guint32 numbytes, guint32 *bytesread)
+{
+ MonoW32HandleFile *console_handle;
+ gboolean ok;
+ gint ret, fd;
+ MonoThreadInfo *info = mono_thread_info_current ();
+
+ ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_CONSOLE,
+ (gpointer *)&console_handle);
+ if(ok==FALSE) {
+ g_warning ("%s: error looking up console handle %p", __func__,
+ handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+ fd = console_handle->fd;
+
+ if(bytesread!=NULL) {
+ *bytesread=0;
+ }
+
+ if(!(console_handle->fileaccess & GENERIC_READ) &&
+ !(console_handle->fileaccess & GENERIC_ALL)) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
+ __func__, handle, console_handle->fileaccess);
+
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
+ return(FALSE);
+ }
+
+ do {
+ ret=read(fd, buffer, numbytes);
+ } while (ret==-1 && errno==EINTR && !mono_thread_info_is_interrupt_state (info));
+
+ if(ret==-1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read of handle %p error: %s", __func__, handle,
+ strerror(errno));
+
+ _wapi_set_last_error_from_errno ();
+ return(FALSE);
+ }
+
+ if(bytesread!=NULL) {
+ *bytesread=ret;
+ }
+
+ return(TRUE);
+}
+
+static gboolean
+console_write(gpointer handle, gconstpointer buffer, guint32 numbytes, guint32 *byteswritten)
+{
+ MonoW32HandleFile *console_handle;
+ gboolean ok;
+ gint ret, fd;
+ MonoThreadInfo *info = mono_thread_info_current ();
+
+ ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_CONSOLE,
+ (gpointer *)&console_handle);
+ if(ok==FALSE) {
+ g_warning ("%s: error looking up console handle %p", __func__,
+ handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+ fd = console_handle->fd;
+
+ if(byteswritten!=NULL) {
+ *byteswritten=0;
+ }
+
+ if(!(console_handle->fileaccess & GENERIC_WRITE) &&
+ !(console_handle->fileaccess & GENERIC_ALL)) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, console_handle->fileaccess);
+
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
+ return(FALSE);
+ }
+
+ do {
+ ret = write(fd, buffer, numbytes);
+ } while (ret == -1 && errno == EINTR &&
+ !mono_thread_info_is_interrupt_state (info));
+
+ if (ret == -1) {
+ if (errno == EINTR) {
+ ret = 0;
+ } else {
+ _wapi_set_last_error_from_errno ();
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write of handle %p error: %s",
+ __func__, handle, strerror(errno));
+
+ return(FALSE);
+ }
+ }
+ if(byteswritten!=NULL) {
+ *byteswritten=ret;
+ }
+
+ return(TRUE);
+}
+
+static const gchar* find_typename (void)
+{
+ return "Find";
+}
+
+static gsize find_typesize (void)
+{
+ return sizeof (MonoW32HandleFind);
+}
+
+static void pipe_close (gpointer handle, gpointer data)
+{
+ MonoW32HandleFile *pipe_handle = (MonoW32HandleFile*)data;
+ gint fd = pipe_handle->fd;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing pipe handle %p fd %d", __func__, handle, fd);
+
+ /* No filename with pipe handles */
+
+ if (pipe_handle->share_info)
+ file_share_release (pipe_handle->share_info);
+
+ close (fd);
+}
+
+static void pipe_details (gpointer data)
+{
+ file_details (data);
+}
+
+static const gchar* pipe_typename (void)
+{
+ return "Pipe";
+}
+
+static gsize pipe_typesize (void)
+{
+ return sizeof (MonoW32HandleFile);
+}
+
+static gint pipe_getfiletype(void)
+{
+ return(FILE_TYPE_PIPE);
+}
+
+static gboolean
+pipe_read (gpointer handle, gpointer buffer, guint32 numbytes, guint32 *bytesread)
+{
+ MonoW32HandleFile *pipe_handle;
+ gboolean ok;
+ gint ret, fd;
+ MonoThreadInfo *info = mono_thread_info_current ();
+
+ ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_PIPE,
+ (gpointer *)&pipe_handle);
+ if(ok==FALSE) {
+ g_warning ("%s: error looking up pipe handle %p", __func__,
+ handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+ fd = pipe_handle->fd;
+
+ if(bytesread!=NULL) {
+ *bytesread=0;
+ }
+
+ if(!(pipe_handle->fileaccess & GENERIC_READ) &&
+ !(pipe_handle->fileaccess & GENERIC_ALL)) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
+ __func__, handle, pipe_handle->fileaccess);
+
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
+ return(FALSE);
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: reading up to %d bytes from pipe %p", __func__,
+ numbytes, handle);
+
+ do {
+ ret=read(fd, buffer, numbytes);
+ } while (ret==-1 && errno==EINTR && !mono_thread_info_is_interrupt_state (info));
+
+ if (ret == -1) {
+ if (errno == EINTR) {
+ ret = 0;
+ } else {
+ _wapi_set_last_error_from_errno ();
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read of handle %p error: %s", __func__,
+ handle, strerror(errno));
+
+ return(FALSE);
+ }
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read %d bytes from pipe %p", __func__, ret, handle);
+
+ if(bytesread!=NULL) {
+ *bytesread=ret;
+ }
+
+ return(TRUE);
+}
+
+static gboolean
+pipe_write(gpointer handle, gconstpointer buffer, guint32 numbytes, guint32 *byteswritten)
+{
+ MonoW32HandleFile *pipe_handle;
+ gboolean ok;
+ gint ret, fd;
+ MonoThreadInfo *info = mono_thread_info_current ();
+
+ ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_PIPE,
+ (gpointer *)&pipe_handle);
+ if(ok==FALSE) {
+ g_warning ("%s: error looking up pipe handle %p", __func__,
+ handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+ fd = pipe_handle->fd;
+
+ if(byteswritten!=NULL) {
+ *byteswritten=0;
+ }
+
+ if(!(pipe_handle->fileaccess & GENERIC_WRITE) &&
+ !(pipe_handle->fileaccess & GENERIC_ALL)) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, pipe_handle->fileaccess);
+
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
+ return(FALSE);
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: writing up to %d bytes to pipe %p", __func__, numbytes,
+ handle);
+
+ do {
+ ret = write (fd, buffer, numbytes);
+ } while (ret == -1 && errno == EINTR &&
+ !mono_thread_info_is_interrupt_state (info));
+
+ if (ret == -1) {
+ if (errno == EINTR) {
+ ret = 0;
+ } else {
+ _wapi_set_last_error_from_errno ();
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write of handle %p error: %s", __func__,
+ handle, strerror(errno));
+
+ return(FALSE);
+ }
+ }
+ if(byteswritten!=NULL) {
+ *byteswritten=ret;
+ }
+
+ return(TRUE);
+}
+
+static gint convert_flags(guint32 fileaccess, guint32 createmode)
+{
+ gint flags=0;
+
+ switch(fileaccess) {
+ case GENERIC_READ:
+ flags=O_RDONLY;
+ break;
+ case GENERIC_WRITE:
+ flags=O_WRONLY;
+ break;
+ case GENERIC_READ|GENERIC_WRITE:
+ flags=O_RDWR;
+ break;
+ default:
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unknown access type 0x%x", __func__,
+ fileaccess);
+ break;
+ }
+
+ switch(createmode) {
+ case CREATE_NEW:
+ flags|=O_CREAT|O_EXCL;
+ break;
+ case CREATE_ALWAYS:
+ flags|=O_CREAT|O_TRUNC;
+ break;
+ case OPEN_EXISTING:
+ break;
+ case OPEN_ALWAYS:
+ flags|=O_CREAT;
+ break;
+ case TRUNCATE_EXISTING:
+ flags|=O_TRUNC;
+ break;
+ default:
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unknown create mode 0x%x", __func__,
+ createmode);
+ break;
+ }
+
+ return(flags);
+}
+
+#if 0 /* unused */
+static mode_t convert_perms(guint32 sharemode)
+{
+ mode_t perms=0600;
+
+ if(sharemode&FILE_SHARE_READ) {
+ perms|=044;
+ }
+ if(sharemode&FILE_SHARE_WRITE) {
+ perms|=022;
+ }
+
+ return(perms);
+}
+#endif
+
+static gboolean share_allows_open (struct stat *statbuf, guint32 sharemode,
+ guint32 fileaccess,
+ FileShare **share_info)
+{
+ gboolean file_already_shared;
+ guint32 file_existing_share, file_existing_access;
+
+ file_already_shared = file_share_get (statbuf->st_dev, statbuf->st_ino, sharemode, fileaccess, &file_existing_share, &file_existing_access, share_info);
+
+ if (file_already_shared) {
+ /* The reference to this share info was incremented
+ * when we looked it up, so be careful to put it back
+ * if we conclude we can't use this file.
+ */
+ if (file_existing_share == 0) {
+ /* Quick and easy, no possibility to share */
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing = NONE", __func__, fileaccess);
+
+ file_share_release (*share_info);
+
+ return(FALSE);
+ }
+
+ if (((file_existing_share == FILE_SHARE_READ) &&
+ (fileaccess != GENERIC_READ)) ||
+ ((file_existing_share == FILE_SHARE_WRITE) &&
+ (fileaccess != GENERIC_WRITE))) {
+ /* New access mode doesn't match up */
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing: 0x%x", __func__, fileaccess, file_existing_share);
+
+ file_share_release (*share_info);
+
+ return(FALSE);
+ }
+
+ if (((file_existing_access & GENERIC_READ) &&
+ !(sharemode & FILE_SHARE_READ)) ||
+ ((file_existing_access & GENERIC_WRITE) &&
+ !(sharemode & FILE_SHARE_WRITE))) {
+ /* New share mode doesn't match up */
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Access mode prevents open: requested share: 0x%x, file has access: 0x%x", __func__, sharemode, file_existing_access);
+
+ file_share_release (*share_info);
+
+ return(FALSE);
+ }
+ } else {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: New file!", __func__);
+ }
+
+ return(TRUE);
+}
+
+
+static gboolean
+share_allows_delete (struct stat *statbuf, FileShare **share_info)
+{
+ gboolean file_already_shared;
+ guint32 file_existing_share, file_existing_access;
+
+ file_already_shared = file_share_get (statbuf->st_dev, statbuf->st_ino, FILE_SHARE_DELETE, GENERIC_READ, &file_existing_share, &file_existing_access, share_info);
+
+ if (file_already_shared) {
+ /* The reference to this share info was incremented
+ * when we looked it up, so be careful to put it back
+ * if we conclude we can't use this file.
+ */
+ if (file_existing_share == 0) {
+ /* Quick and easy, no possibility to share */
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing = NONE", __func__, (*share_info)->access);
+
+ file_share_release (*share_info);
+
+ return(FALSE);
+ }
+
+ if (!(file_existing_share & FILE_SHARE_DELETE)) {
+ /* New access mode doesn't match up */
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing: 0x%x", __func__, (*share_info)->access, file_existing_share);
+
+ file_share_release (*share_info);
+
+ return(FALSE);
+ }
+ } else {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: New file!", __func__);
+ }
+
+ return(TRUE);
+}
+
+gpointer
+mono_w32file_create(const gunichar2 *name, guint32 fileaccess, guint32 sharemode, guint32 createmode, guint32 attrs)
+{
+ MonoW32HandleFile file_handle = {0};
+ gpointer handle;
+ gint flags=convert_flags(fileaccess, createmode);
+ /*mode_t perms=convert_perms(sharemode);*/
+ /* we don't use sharemode, because that relates to sharing of
+ * the file when the file is open and is already handled by
+ * other code, perms instead are the on-disk permissions and
+ * this is a sane default.
+ */
+ mode_t perms=0666;
+ gchar *filename;
+ gint fd, ret;
+ MonoW32HandleType handle_type;
+ struct stat statbuf;
+
+ if (attrs & FILE_ATTRIBUTE_TEMPORARY)
+ perms = 0600;
+
+ if (attrs & FILE_ATTRIBUTE_ENCRYPTED){
+ mono_w32error_set_last (ERROR_ENCRYPTION_FAILED);
+ return INVALID_HANDLE_VALUE;
+ }
+
+ if (name == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return(INVALID_HANDLE_VALUE);
+ }
+
+ filename = mono_unicode_to_external (name);
+ if (filename == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return(INVALID_HANDLE_VALUE);
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening %s with share 0x%x and access 0x%x", __func__,
+ filename, sharemode, fileaccess);
+
+ fd = _wapi_open (filename, flags, perms);
+
+ /* If we were trying to open a directory with write permissions
+ * (e.g. O_WRONLY or O_RDWR), this call will fail with
+ * EISDIR. However, this is a bit bogus because calls to
+ * manipulate the directory (e.g. mono_w32file_set_times) will still work on
+ * the directory because they use other API calls
+ * (e.g. utime()). Hence, if we failed with the EISDIR error, try
+ * to open the directory again without write permission.
+ */
+ if (fd == -1 && errno == EISDIR)
+ {
+ /* Try again but don't try to make it writable */
+ fd = _wapi_open (filename, flags & ~(O_RDWR|O_WRONLY), perms);
+ }
+
+ if (fd == -1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error opening file %s: %s", __func__, filename,
+ strerror(errno));
+ _wapi_set_last_path_error_from_errno (NULL, filename);
+ g_free (filename);
+
+ return(INVALID_HANDLE_VALUE);
+ }
+
+ if (fd >= mono_w32handle_fd_reserve) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big", __func__);
+
+ mono_w32error_set_last (ERROR_TOO_MANY_OPEN_FILES);
+
+ close (fd);
+ g_free (filename);
+
+ return(INVALID_HANDLE_VALUE);
+ }
+
+ ret = fstat (fd, &statbuf);
+ if (ret == -1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fstat error of file %s: %s", __func__,
+ filename, strerror (errno));
+ _wapi_set_last_error_from_errno ();
+ g_free (filename);
+ close (fd);
+
+ return(INVALID_HANDLE_VALUE);
+ }
+#ifdef __native_client__
+ /* Workaround: Native Client currently returns the same fake inode
+ * for all files, so do a simple hash on the filename so we don't
+ * use the same share info for each file.
+ */
+ statbuf.st_ino = g_str_hash(filename);
+#endif
+
+ if (share_allows_open (&statbuf, sharemode, fileaccess,
+ &file_handle.share_info) == FALSE) {
+ mono_w32error_set_last (ERROR_SHARING_VIOLATION);
+ g_free (filename);
+ close (fd);
+
+ return (INVALID_HANDLE_VALUE);
+ }
+ if (file_handle.share_info == NULL) {
+ /* No space, so no more files can be opened */
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: No space in the share table", __func__);
+
+ mono_w32error_set_last (ERROR_TOO_MANY_OPEN_FILES);
+ close (fd);
+ g_free (filename);
+
+ return(INVALID_HANDLE_VALUE);
+ }
+
+ file_handle.filename = filename;
+
+ file_handle.fd = fd;
+ file_handle.fileaccess=fileaccess;
+ file_handle.sharemode=sharemode;
+ file_handle.attrs=attrs;
+
+#ifdef HAVE_POSIX_FADVISE
+ if (attrs & FILE_FLAG_SEQUENTIAL_SCAN)
+ posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL);
+ if (attrs & FILE_FLAG_RANDOM_ACCESS)
+ posix_fadvise (fd, 0, 0, POSIX_FADV_RANDOM);
+#endif
+
+#ifdef F_RDAHEAD
+ if (attrs & FILE_FLAG_SEQUENTIAL_SCAN)
+ fcntl(fd, F_RDAHEAD, 1);
+#endif
+
+#ifndef S_ISFIFO
+#define S_ISFIFO(m) ((m & S_IFIFO) != 0)
+#endif
+ if (S_ISFIFO (statbuf.st_mode)) {
+ handle_type = MONO_W32HANDLE_PIPE;
+ /* maintain invariant that pipes have no filename */
+ file_handle.filename = NULL;
+ g_free (filename);
+ filename = NULL;
+ } else if (S_ISCHR (statbuf.st_mode)) {
+ handle_type = MONO_W32HANDLE_CONSOLE;
+ } else {
+ handle_type = MONO_W32HANDLE_FILE;
+ }
+
+ handle = mono_w32handle_new_fd (handle_type, fd, &file_handle);
+ if (handle == INVALID_HANDLE_VALUE) {
+ g_warning ("%s: error creating file handle", __func__);
+ g_free (filename);
+ close (fd);
+
+ mono_w32error_set_last (ERROR_GEN_FAILURE);
+ return(INVALID_HANDLE_VALUE);
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning handle %p", __func__, handle);
+
+ return(handle);
+}
+
+gboolean
+mono_w32file_close (gpointer handle)
+{
+ return mono_w32handle_close (handle);
+}
+
+gboolean mono_w32file_delete(const gunichar2 *name)
+{
+ gchar *filename;
+ gint retval;
+ gboolean ret = FALSE;
+ guint32 attrs;
+#if 0
+ struct stat statbuf;
+ FileShare *shareinfo;
+#endif
+
+ if(name==NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return(FALSE);
+ }
+
+ filename=mono_unicode_to_external(name);
+ if(filename==NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return(FALSE);
+ }
+
+ attrs = mono_w32file_get_attributes (name);
+ if (attrs == INVALID_FILE_ATTRIBUTES) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: file attributes error", __func__);
+ /* Error set by mono_w32file_get_attributes() */
+ g_free (filename);
+ return(FALSE);
+ }
+
+#if 0
+ /* Check to make sure sharing allows us to open the file for
+ * writing. See bug 323389.
+ *
+ * Do the checks that don't need an open file descriptor, for
+ * simplicity's sake. If we really have to do the full checks
+ * then we can implement that later.
+ */
+ if (_wapi_stat (filename, &statbuf) < 0) {
+ _wapi_set_last_path_error_from_errno (NULL, filename);
+ g_free (filename);
+ return(FALSE);
+ }
+
+ if (share_allows_open (&statbuf, 0, GENERIC_WRITE,
+ &shareinfo) == FALSE) {
+ mono_w32error_set_last (ERROR_SHARING_VIOLATION);
+ g_free (filename);
+ return FALSE;
+ }
+ if (shareinfo)
+ file_share_release (shareinfo);
+#endif
+
+ retval = _wapi_unlink (filename);
+
+ if (retval == -1) {
+ _wapi_set_last_path_error_from_errno (NULL, filename);
+ } else {
+ ret = TRUE;
+ }
+
+ g_free(filename);
+
+ return(ret);
+}
+
+static gboolean
+MoveFile (gunichar2 *name, gunichar2 *dest_name)
+{
+ gchar *utf8_name, *utf8_dest_name;
+ gint result, errno_copy;
+ struct stat stat_src, stat_dest;
+ gboolean ret = FALSE;
+ FileShare *shareinfo;
+
+ if(name==NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return(FALSE);
+ }
+
+ utf8_name = mono_unicode_to_external (name);
+ if (utf8_name == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return FALSE;
+ }
+
+ if(dest_name==NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
+
+ g_free (utf8_name);
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return(FALSE);
+ }
+
+ utf8_dest_name = mono_unicode_to_external (dest_name);
+ if (utf8_dest_name == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
+
+ g_free (utf8_name);
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return FALSE;
+ }
+
+ /*
+ * In C# land we check for the existence of src, but not for dest.
+ * We check it here and return the failure if dest exists and is not
+ * the same file as src.
+ */
+ if (_wapi_stat (utf8_name, &stat_src) < 0) {
+ if (errno != ENOENT || _wapi_lstat (utf8_name, &stat_src) < 0) {
+ _wapi_set_last_path_error_from_errno (NULL, utf8_name);
+ g_free (utf8_name);
+ g_free (utf8_dest_name);
+ return FALSE;
+ }
+ }
+
+ if (!_wapi_stat (utf8_dest_name, &stat_dest)) {
+ if (stat_dest.st_dev != stat_src.st_dev ||
+ stat_dest.st_ino != stat_src.st_ino) {
+ g_free (utf8_name);
+ g_free (utf8_dest_name);
+ mono_w32error_set_last (ERROR_ALREADY_EXISTS);
+ return FALSE;
+ }
+ }
+
+ /* Check to make that we have delete sharing permission.
+ * See https://bugzilla.xamarin.com/show_bug.cgi?id=17009
+ *
+ * Do the checks that don't need an open file descriptor, for
+ * simplicity's sake. If we really have to do the full checks
+ * then we can implement that later.
+ */
+ if (share_allows_delete (&stat_src, &shareinfo) == FALSE) {
+ mono_w32error_set_last (ERROR_SHARING_VIOLATION);
+ return FALSE;
+ }
+ if (shareinfo)
+ file_share_release (shareinfo);
+
+ result = _wapi_rename (utf8_name, utf8_dest_name);
+ errno_copy = errno;
+
+ if (result == -1) {
+ switch(errno_copy) {
+ case EEXIST:
+ mono_w32error_set_last (ERROR_ALREADY_EXISTS);
+ break;
+
+ case EXDEV:
+ /* Ignore here, it is dealt with below */
+ break;
+
+ case ENOENT:
+ /* We already know src exists. Must be dest that doesn't exist. */
+ _wapi_set_last_path_error_from_errno (NULL, utf8_dest_name);
+ break;
+
+ default:
+ _wapi_set_last_error_from_errno ();
+ }
+ }
+
+ g_free (utf8_name);
+ g_free (utf8_dest_name);
+
+ if (result != 0 && errno_copy == EXDEV) {
+ gint32 copy_error;
+
+ if (S_ISDIR (stat_src.st_mode)) {
+ mono_w32error_set_last (ERROR_NOT_SAME_DEVICE);
+ return FALSE;
+ }
+ /* Try a copy to the new location, and delete the source */
+ if (!mono_w32file_copy (name, dest_name, FALSE, ©_error)) {
+ /* mono_w32file_copy will set the error */
+ return(FALSE);
+ }
+
+ return(mono_w32file_delete (name));
+ }
+
+ if (result == 0) {
+ ret = TRUE;
+ }
+
+ return(ret);
+}
+
+static gboolean
+write_file (gint src_fd, gint dest_fd, struct stat *st_src, gboolean report_errors)
+{
+ gint remain, n;
+ gchar *buf, *wbuf;
+ gint buf_size = st_src->st_blksize;
+ MonoThreadInfo *info = mono_thread_info_current ();
+
+ buf_size = buf_size < 8192 ? 8192 : (buf_size > 65536 ? 65536 : buf_size);
+ buf = (gchar *) g_malloc (buf_size);
+
+ for (;;) {
+ remain = read (src_fd, buf, buf_size);
+ if (remain < 0) {
+ if (errno == EINTR && !mono_thread_info_is_interrupt_state (info))
+ continue;
+
+ if (report_errors)
+ _wapi_set_last_error_from_errno ();
+
+ g_free (buf);
+ return FALSE;
+ }
+ if (remain == 0) {
+ break;
+ }
+
+ wbuf = buf;
+ while (remain > 0) {
+ if ((n = write (dest_fd, wbuf, remain)) < 0) {
+ if (errno == EINTR && !mono_thread_info_is_interrupt_state (info))
+ continue;
+
+ if (report_errors)
+ _wapi_set_last_error_from_errno ();
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write failed.", __func__);
+ g_free (buf);
+ return FALSE;
+ }
+
+ remain -= n;
+ wbuf += n;
+ }
+ }
+
+ g_free (buf);
+ return TRUE ;
+}
+
+static gboolean
+CopyFile (const gunichar2 *name, const gunichar2 *dest_name, gboolean fail_if_exists)
+{
+ gchar *utf8_src, *utf8_dest;
+ gint src_fd, dest_fd;
+ struct stat st, dest_st;
+ struct utimbuf dest_time;
+ gboolean ret = TRUE;
+ gint ret_utime;
+
+ if(name==NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return(FALSE);
+ }
+
+ utf8_src = mono_unicode_to_external (name);
+ if (utf8_src == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion of source returned NULL",
+ __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return(FALSE);
+ }
+
+ if(dest_name==NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: dest is NULL", __func__);
+
+ g_free (utf8_src);
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return(FALSE);
+ }
+
+ utf8_dest = mono_unicode_to_external (dest_name);
+ if (utf8_dest == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion of dest returned NULL",
+ __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+
+ g_free (utf8_src);
+
+ return(FALSE);
+ }
+
+ src_fd = _wapi_open (utf8_src, O_RDONLY, 0);
+ if (src_fd < 0) {
+ _wapi_set_last_path_error_from_errno (NULL, utf8_src);
+
+ g_free (utf8_src);
+ g_free (utf8_dest);
+
+ return(FALSE);
+ }
+
+ if (fstat (src_fd, &st) < 0) {
+ _wapi_set_last_error_from_errno ();
+
+ g_free (utf8_src);
+ g_free (utf8_dest);
+ close (src_fd);
+
+ return(FALSE);
+ }
+
+ /* Before trying to open/create the dest, we need to report a 'file busy'
+ * error if src and dest are actually the same file. We do the check here to take
+ * advantage of the IOMAP capability */
+ if (!_wapi_stat (utf8_dest, &dest_st) && st.st_dev == dest_st.st_dev &&
+ st.st_ino == dest_st.st_ino) {
+
+ g_free (utf8_src);
+ g_free (utf8_dest);
+ close (src_fd);
+
+ mono_w32error_set_last (ERROR_SHARING_VIOLATION);
+ return (FALSE);
+ }
+
+ if (fail_if_exists) {
+ dest_fd = _wapi_open (utf8_dest, O_WRONLY | O_CREAT | O_EXCL, st.st_mode);
+ } else {
+ /* FIXME: it kinda sucks that this code path potentially scans
+ * the directory twice due to the weird mono_w32error_set_last()
+ * behavior. */
+ dest_fd = _wapi_open (utf8_dest, O_WRONLY | O_TRUNC, st.st_mode);
+ if (dest_fd < 0) {
+ /* The file does not exist, try creating it */
+ dest_fd = _wapi_open (utf8_dest, O_WRONLY | O_CREAT | O_TRUNC, st.st_mode);
+ } else {
+ /* Apparently this error is set if we
+ * overwrite the dest file
+ */
+ mono_w32error_set_last (ERROR_ALREADY_EXISTS);
+ }
+ }
+ if (dest_fd < 0) {
+ _wapi_set_last_error_from_errno ();
+
+ g_free (utf8_src);
+ g_free (utf8_dest);
+ close (src_fd);
+
+ return(FALSE);
+ }
+
+ if (!write_file (src_fd, dest_fd, &st, TRUE))
+ ret = FALSE;
+
+ close (src_fd);
+ close (dest_fd);
+
+ dest_time.modtime = st.st_mtime;
+ dest_time.actime = st.st_atime;
+ ret_utime = utime (utf8_dest, &dest_time);
+ if (ret_utime == -1)
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: file [%s] utime failed: %s", __func__, utf8_dest, strerror(errno));
+
+ g_free (utf8_src);
+ g_free (utf8_dest);
+
+ return ret;
+}
+
+static gchar*
+convert_arg_to_utf8 (const gunichar2 *arg, const gchar *arg_name)
+{
+ gchar *utf8_ret;
+
+ if (arg == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %s is NULL", __func__, arg_name);
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return NULL;
+ }
+
+ utf8_ret = mono_unicode_to_external (arg);
+ if (utf8_ret == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion of %s returned NULL",
+ __func__, arg_name);
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ return utf8_ret;
+}
+
+static gboolean
+ReplaceFile (const gunichar2 *replacedFileName, const gunichar2 *replacementFileName, const gunichar2 *backupFileName, guint32 replaceFlags, gpointer exclude, gpointer reserved)
+{
+ gint result, backup_fd = -1,replaced_fd = -1;
+ gchar *utf8_replacedFileName, *utf8_replacementFileName = NULL, *utf8_backupFileName = NULL;
+ struct stat stBackup;
+ gboolean ret = FALSE;
+
+ if (!(utf8_replacedFileName = convert_arg_to_utf8 (replacedFileName, "replacedFileName")))
+ return FALSE;
+ if (!(utf8_replacementFileName = convert_arg_to_utf8 (replacementFileName, "replacementFileName")))
+ goto replace_cleanup;
+ if (backupFileName != NULL) {
+ if (!(utf8_backupFileName = convert_arg_to_utf8 (backupFileName, "backupFileName")))
+ goto replace_cleanup;
+ }
+
+ if (utf8_backupFileName) {
+ // Open the backup file for read so we can restore the file if an error occurs.
+ backup_fd = _wapi_open (utf8_backupFileName, O_RDONLY, 0);
+ result = _wapi_rename (utf8_replacedFileName, utf8_backupFileName);
+ if (result == -1)
+ goto replace_cleanup;
+ }
+
+ result = _wapi_rename (utf8_replacementFileName, utf8_replacedFileName);
+ if (result == -1) {
+ _wapi_set_last_path_error_from_errno (NULL, utf8_replacementFileName);
+ _wapi_rename (utf8_backupFileName, utf8_replacedFileName);
+ if (backup_fd != -1 && !fstat (backup_fd, &stBackup)) {
+ replaced_fd = _wapi_open (utf8_backupFileName, O_WRONLY | O_CREAT | O_TRUNC,
+ stBackup.st_mode);
+
+ if (replaced_fd == -1)
+ goto replace_cleanup;
+
+ write_file (backup_fd, replaced_fd, &stBackup, FALSE);
+ }
+
+ goto replace_cleanup;
+ }
+
+ ret = TRUE;
+
+replace_cleanup:
+ g_free (utf8_replacedFileName);
+ g_free (utf8_replacementFileName);
+ g_free (utf8_backupFileName);
+ if (backup_fd != -1)
+ close (backup_fd);
+ if (replaced_fd != -1)
+ close (replaced_fd);
+ return ret;
+}
+
+static mono_mutex_t stdhandle_mutex;
+
+static gpointer
+_wapi_stdhandle_create (gint fd, const gchar *name)
+{
+ gpointer handle;
+ gint flags;
+ MonoW32HandleFile file_handle = {0};
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating standard handle type %s, fd %d", __func__, name, fd);
+
+#if !defined(__native_client__)
+ /* Check if fd is valid */
+ do {
+ flags = fcntl(fd, F_GETFL);
+ } while (flags == -1 && errno == EINTR);
+
+ if (flags == -1) {
+ /* Invalid fd. Not really much point checking for EBADF
+ * specifically
+ */
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fcntl error on fd %d: %s", __func__, fd, strerror(errno));
+
+ mono_w32error_set_last (mono_w32error_unix_to_win32 (errno));
+ return INVALID_HANDLE_VALUE;
+ }
+
+ switch (flags & (O_RDONLY|O_WRONLY|O_RDWR)) {
+ case O_RDONLY:
+ file_handle.fileaccess = GENERIC_READ;
+ break;
+ case O_WRONLY:
+ file_handle.fileaccess = GENERIC_WRITE;
+ break;
+ case O_RDWR:
+ file_handle.fileaccess = GENERIC_READ | GENERIC_WRITE;
+ break;
+ default:
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't figure out flags 0x%x", __func__, flags);
+ file_handle.fileaccess = 0;
+ break;
+ }
+#else
+ /*
+ * fcntl will return -1 in nacl, as there is no real file system API.
+ * Yet, standard streams are available.
+ */
+ file_handle.fileaccess = (fd == STDIN_FILENO) ? GENERIC_READ : GENERIC_WRITE;
+#endif
+
+ file_handle.fd = fd;
+ file_handle.filename = g_strdup(name);
+ /* some default security attributes might be needed */
+ file_handle.security_attributes = 0;
+
+ /* Apparently input handles can't be written to. (I don't
+ * know if output or error handles can't be read from.)
+ */
+ if (fd == 0)
+ file_handle.fileaccess &= ~GENERIC_WRITE;
+
+ file_handle.sharemode = 0;
+ file_handle.attrs = 0;
+
+ handle = mono_w32handle_new_fd (MONO_W32HANDLE_CONSOLE, fd, &file_handle);
+ if (handle == INVALID_HANDLE_VALUE) {
+ g_warning ("%s: error creating file handle", __func__);
+ mono_w32error_set_last (ERROR_GEN_FAILURE);
+ return INVALID_HANDLE_VALUE;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning handle %p", __func__, handle);
+
+ return handle;
+}
+
+enum {
+ STD_INPUT_HANDLE = -10,
+ STD_OUTPUT_HANDLE = -11,
+ STD_ERROR_HANDLE = -12,
+};
+
+static gpointer
+mono_w32file_get_std_handle (gint stdhandle)
+{
+ MonoW32HandleFile *file_handle;
+ gpointer handle;
+ gint fd;
+ const gchar *name;
+ gboolean ok;
+
+ switch(stdhandle) {
+ case STD_INPUT_HANDLE:
+ fd = 0;
+ name = "<stdin>";
+ break;
+
+ case STD_OUTPUT_HANDLE:
+ fd = 1;
+ name = "<stdout>";
+ break;
+
+ case STD_ERROR_HANDLE:
+ fd = 2;
+ name = "<stderr>";
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+
+ handle = GINT_TO_POINTER (fd);
+
+ mono_os_mutex_lock (&stdhandle_mutex);
+
+ ok = mono_w32handle_lookup (handle, MONO_W32HANDLE_CONSOLE,
+ (gpointer *)&file_handle);
+ if (ok == FALSE) {
+ /* Need to create this console handle */
+ handle = _wapi_stdhandle_create (fd, name);
+
+ if (handle == INVALID_HANDLE_VALUE) {
+ mono_w32error_set_last (ERROR_NO_MORE_FILES);
+ goto done;
+ }
+ } else {
+ /* Add a reference to this handle */
+ mono_w32handle_ref (handle);
+ }
+
+ done:
+ mono_os_mutex_unlock (&stdhandle_mutex);
+
+ return(handle);
+}
+
+gboolean
+mono_w32file_read (gpointer handle, gpointer buffer, guint32 numbytes, guint32 *bytesread)
+{
+ MonoW32HandleType type;
+
+ type = mono_w32handle_get_type (handle);
+
+ if(io_ops[type].readfile==NULL) {
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ return(io_ops[type].readfile (handle, buffer, numbytes, bytesread));
+}
+
+gboolean
+mono_w32file_write (gpointer handle, gconstpointer buffer, guint32 numbytes, guint32 *byteswritten)
+{
+ MonoW32HandleType type;
+
+ type = mono_w32handle_get_type (handle);
+
+ if(io_ops[type].writefile==NULL) {
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ return(io_ops[type].writefile (handle, buffer, numbytes, byteswritten));
+}
+
+gboolean
+mono_w32file_flush (gpointer handle)
+{
+ MonoW32HandleType type;
+
+ type = mono_w32handle_get_type (handle);
+
+ if(io_ops[type].flushfile==NULL) {
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ return(io_ops[type].flushfile (handle));
+}
+
+gboolean
+mono_w32file_truncate (gpointer handle)
+{
+ MonoW32HandleType type;
+
+ type = mono_w32handle_get_type (handle);
+
+ if (io_ops[type].setendoffile == NULL) {
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ return(io_ops[type].setendoffile (handle));
+}
+
+guint32
+mono_w32file_seek (gpointer handle, gint32 movedistance, gint32 *highmovedistance, guint32 method)
+{
+ MonoW32HandleType type;
+
+ type = mono_w32handle_get_type (handle);
+
+ if (io_ops[type].seek == NULL) {
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(INVALID_SET_FILE_POINTER);
+ }
+
+ return(io_ops[type].seek (handle, movedistance, highmovedistance,
+ method));
+}
+
+gint
+mono_w32file_get_type(gpointer handle)
+{
+ MonoW32HandleType type;
+
+ type = mono_w32handle_get_type (handle);
+
+ if (io_ops[type].getfiletype == NULL) {
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FILE_TYPE_UNKNOWN);
+ }
+
+ return(io_ops[type].getfiletype ());
+}
+
+static guint32
+GetFileSize(gpointer handle, guint32 *highsize)
+{
+ MonoW32HandleType type;
+
+ type = mono_w32handle_get_type (handle);
+
+ if (io_ops[type].getfilesize == NULL) {
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(INVALID_FILE_SIZE);
+ }
+
+ return(io_ops[type].getfilesize (handle, highsize));
+}
+
+gboolean
+mono_w32file_get_times(gpointer handle, FILETIME *create_time, FILETIME *access_time, FILETIME *write_time)
+{
+ MonoW32HandleType type;
+
+ type = mono_w32handle_get_type (handle);
+
+ if (io_ops[type].getfiletime == NULL) {
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ return(io_ops[type].getfiletime (handle, create_time, access_time,
+ write_time));
+}
+
+gboolean
+mono_w32file_set_times(gpointer handle, const FILETIME *create_time, const FILETIME *access_time, const FILETIME *write_time)
+{
+ MonoW32HandleType type;
+
+ type = mono_w32handle_get_type (handle);
+
+ if (io_ops[type].setfiletime == NULL) {
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ return(io_ops[type].setfiletime (handle, create_time, access_time,
+ write_time));
+}
+
+/* A tick is a 100-nanosecond interval. File time epoch is Midnight,
+ * January 1 1601 GMT
+ */
+
+#define TICKS_PER_MILLISECOND 10000L
+#define TICKS_PER_SECOND 10000000L
+#define TICKS_PER_MINUTE 600000000L
+#define TICKS_PER_HOUR 36000000000LL
+#define TICKS_PER_DAY 864000000000LL
+
+#define isleap(y) ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
+
+static const guint16 mon_yday[2][13]={
+ {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
+ {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366},
+};
+
+gboolean
+mono_w32file_filetime_to_systemtime(const FILETIME *file_time, SYSTEMTIME *system_time)
+{
+ gint64 file_ticks, totaldays, rem, y;
+ const guint16 *ip;
+
+ if(system_time==NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: system_time NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return(FALSE);
+ }
+
+ file_ticks=((gint64)file_time->dwHighDateTime << 32) +
+ file_time->dwLowDateTime;
+
+ /* Really compares if file_ticks>=0x8000000000000000
+ * (LLONG_MAX+1) but we're working with a signed value for the
+ * year and day calculation to work later
+ */
+ if(file_ticks<0) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: file_time too big", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return(FALSE);
+ }
+
+ totaldays=(file_ticks / TICKS_PER_DAY);
+ rem = file_ticks % TICKS_PER_DAY;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld rem: %lld", __func__, totaldays, rem);
+
+ system_time->wHour=rem/TICKS_PER_HOUR;
+ rem %= TICKS_PER_HOUR;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hour: %d rem: %lld", __func__, system_time->wHour, rem);
+
+ system_time->wMinute = rem / TICKS_PER_MINUTE;
+ rem %= TICKS_PER_MINUTE;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Minute: %d rem: %lld", __func__, system_time->wMinute,
+ rem);
+
+ system_time->wSecond = rem / TICKS_PER_SECOND;
+ rem %= TICKS_PER_SECOND;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Second: %d rem: %lld", __func__, system_time->wSecond,
+ rem);
+
+ system_time->wMilliseconds = rem / TICKS_PER_MILLISECOND;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Milliseconds: %d", __func__,
+ system_time->wMilliseconds);
+
+ /* January 1, 1601 was a Monday, according to Emacs calendar */
+ system_time->wDayOfWeek = ((1 + totaldays) % 7) + 1;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Day of week: %d", __func__, system_time->wDayOfWeek);
+
+ /* This algorithm to find year and month given days from epoch
+ * from glibc
+ */
+ y=1601;
+
+#define DIV(a, b) ((a) / (b) - ((a) % (b) < 0))
+#define LEAPS_THRU_END_OF(y) (DIV(y, 4) - DIV (y, 100) + DIV (y, 400))
+
+ while(totaldays < 0 || totaldays >= (isleap(y)?366:365)) {
+ /* Guess a corrected year, assuming 365 days per year */
+ gint64 yg = y + totaldays / 365 - (totaldays % 365 < 0);
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld yg: %lld y: %lld", __func__,
+ totaldays, yg,
+ y);
+ g_message("%s: LEAPS(yg): %lld LEAPS(y): %lld", __func__,
+ LEAPS_THRU_END_OF(yg-1), LEAPS_THRU_END_OF(y-1));
+
+ /* Adjust days and y to match the guessed year. */
+ totaldays -= ((yg - y) * 365
+ + LEAPS_THRU_END_OF (yg - 1)
+ - LEAPS_THRU_END_OF (y - 1));
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld", __func__, totaldays);
+ y = yg;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: y: %lld", __func__, y);
+ }
+
+ system_time->wYear = y;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Year: %d", __func__, system_time->wYear);
+
+ ip = mon_yday[isleap(y)];
+
+ for(y=11; totaldays < ip[y]; --y) {
+ continue;
+ }
+ totaldays-=ip[y];
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld", __func__, totaldays);
+
+ system_time->wMonth = y + 1;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Month: %d", __func__, system_time->wMonth);
+
+ system_time->wDay = totaldays + 1;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Day: %d", __func__, system_time->wDay);
+
+ return(TRUE);
+}
+
+gpointer
+mono_w32file_find_first (const gunichar2 *pattern, WIN32_FIND_DATA *find_data)
+{
+ MonoW32HandleFind find_handle = {0};
+ gpointer handle;
+ gchar *utf8_pattern = NULL, *dir_part, *entry_part;
+ gint result;
+
+ if (pattern == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: pattern is NULL", __func__);
+
+ mono_w32error_set_last (ERROR_PATH_NOT_FOUND);
+ return(INVALID_HANDLE_VALUE);
+ }
+
+ utf8_pattern = mono_unicode_to_external (pattern);
+ if (utf8_pattern == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return(INVALID_HANDLE_VALUE);
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: looking for [%s]", __func__, utf8_pattern);
+
+ /* Figure out which bit of the pattern is the directory */
+ dir_part = _wapi_dirname (utf8_pattern);
+ entry_part = _wapi_basename (utf8_pattern);
+
+#if 0
+ /* Don't do this check for now, it breaks if directories
+ * really do have metachars in their names (see bug 58116).
+ * FIXME: Figure out a better solution to keep some checks...
+ */
+ if (strchr (dir_part, '*') || strchr (dir_part, '?')) {
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ g_free (dir_part);
+ g_free (entry_part);
+ g_free (utf8_pattern);
+ return(INVALID_HANDLE_VALUE);
+ }
+#endif
+
+ /* The pattern can specify a directory or a set of files.
+ *
+ * The pattern can have wildcard characters ? and *, but only
+ * in the section after the last directory delimiter. (Return
+ * ERROR_INVALID_NAME if there are wildcards in earlier path
+ * sections.) "*" has the usual 0-or-more chars meaning. "?"
+ * means "match one character", "??" seems to mean "match one
+ * or two characters", "???" seems to mean "match one, two or
+ * three characters", etc. Windows will also try and match
+ * the mangled "short name" of files, so 8 character patterns
+ * with wildcards will show some surprising results.
+ *
+ * All the written documentation I can find says that '?'
+ * should only match one character, and doesn't mention '??',
+ * '???' etc. I'm going to assume that the strict behaviour
+ * (ie '???' means three and only three characters) is the
+ * correct one, because that lets me use fnmatch(3) rather
+ * than mess around with regexes.
+ */
+
+ find_handle.namelist = NULL;
+ result = _wapi_io_scandir (dir_part, entry_part,
+ &find_handle.namelist);
+
+ if (result == 0) {
+ /* No files, which windows seems to call
+ * FILE_NOT_FOUND
+ */
+ mono_w32error_set_last (ERROR_FILE_NOT_FOUND);
+ g_free (utf8_pattern);
+ g_free (entry_part);
+ g_free (dir_part);
+ return (INVALID_HANDLE_VALUE);
+ }
+
+ if (result < 0) {
+ _wapi_set_last_path_error_from_errno (dir_part, NULL);
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: scandir error: %s", __func__, g_strerror (errno));
+ g_free (utf8_pattern);
+ g_free (entry_part);
+ g_free (dir_part);
+ return (INVALID_HANDLE_VALUE);
+ }
+
+ g_free (utf8_pattern);
+ g_free (entry_part);
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Got %d matches", __func__, result);
+
+ find_handle.dir_part = dir_part;
+ find_handle.num = result;
+ find_handle.count = 0;
+
+ handle = mono_w32handle_new (MONO_W32HANDLE_FIND, &find_handle);
+ if (handle == INVALID_HANDLE_VALUE) {
+ g_warning ("%s: error creating find handle", __func__);
+ g_free (dir_part);
+ g_free (entry_part);
+ g_free (utf8_pattern);
+ mono_w32error_set_last (ERROR_GEN_FAILURE);
+
+ return(INVALID_HANDLE_VALUE);
+ }
+
+ if (handle != INVALID_HANDLE_VALUE &&
+ !mono_w32file_find_next (handle, find_data)) {
+ mono_w32file_find_close (handle);
+ mono_w32error_set_last (ERROR_NO_MORE_FILES);
+ handle = INVALID_HANDLE_VALUE;
+ }
+
+ return (handle);
+}
+
+gboolean
+mono_w32file_find_next (gpointer handle, WIN32_FIND_DATA *find_data)
+{
+ MonoW32HandleFind *find_handle;
+ gboolean ok;
+ struct stat buf, linkbuf;
+ gint result;
+ gchar *filename;
+ gchar *utf8_filename, *utf8_basename;
+ gunichar2 *utf16_basename;
+ time_t create_time;
+ glong bytes;
+ gboolean ret = FALSE;
+
+ ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FIND,
+ (gpointer *)&find_handle);
+ if(ok==FALSE) {
+ g_warning ("%s: error looking up find handle %p", __func__,
+ handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ mono_w32handle_lock_handle (handle);
+
+retry:
+ if (find_handle->count >= find_handle->num) {
+ mono_w32error_set_last (ERROR_NO_MORE_FILES);
+ goto cleanup;
+ }
+
+ /* stat next match */
+
+ filename = g_build_filename (find_handle->dir_part, find_handle->namelist[find_handle->count ++], NULL);
+
+ result = _wapi_stat (filename, &buf);
+ if (result == -1 && errno == ENOENT) {
+ /* Might be a dangling symlink */
+ result = _wapi_lstat (filename, &buf);
+ }
+
+ if (result != 0) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: stat failed: %s", __func__, filename);
+
+ g_free (filename);
+ goto retry;
+ }
+
+#ifndef __native_client__
+ result = _wapi_lstat (filename, &linkbuf);
+ if (result != 0) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: lstat failed: %s", __func__, filename);
+
+ g_free (filename);
+ goto retry;
+ }
+#endif
+
+ utf8_filename = mono_utf8_from_external (filename);
+ if (utf8_filename == NULL) {
+ /* We couldn't turn this filename into utf8 (eg the
+ * encoding of the name wasn't convertible), so just
+ * ignore it.
+ */
+ g_warning ("%s: Bad encoding for '%s'\nConsider using MONO_EXTERNAL_ENCODINGS\n", __func__, filename);
+
+ g_free (filename);
+ goto retry;
+ }
+ g_free (filename);
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Found [%s]", __func__, utf8_filename);
+
+ /* fill data block */
+
+ if (buf.st_mtime < buf.st_ctime)
+ create_time = buf.st_mtime;
+ else
+ create_time = buf.st_ctime;
+
+#ifdef __native_client__
+ find_data->dwFileAttributes = _wapi_stat_to_file_attributes (utf8_filename, &buf, NULL);
+#else
+ find_data->dwFileAttributes = _wapi_stat_to_file_attributes (utf8_filename, &buf, &linkbuf);
+#endif
+
+ time_t_to_filetime (create_time, &find_data->ftCreationTime);
+ time_t_to_filetime (buf.st_atime, &find_data->ftLastAccessTime);
+ time_t_to_filetime (buf.st_mtime, &find_data->ftLastWriteTime);
+
+ if (find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ find_data->nFileSizeHigh = 0;
+ find_data->nFileSizeLow = 0;
+ } else {
+ find_data->nFileSizeHigh = buf.st_size >> 32;
+ find_data->nFileSizeLow = buf.st_size & 0xFFFFFFFF;
+ }
+
+ find_data->dwReserved0 = 0;
+ find_data->dwReserved1 = 0;
+
+ utf8_basename = _wapi_basename (utf8_filename);
+ utf16_basename = g_utf8_to_utf16 (utf8_basename, -1, NULL, &bytes,
+ NULL);
+ if(utf16_basename==NULL) {
+ g_free (utf8_basename);
+ g_free (utf8_filename);
+ goto retry;
+ }
+ ret = TRUE;
+
+ /* utf16 is 2 * utf8 */
+ bytes *= 2;
+
+ memset (find_data->cFileName, '\0', (MAX_PATH*2));
+
+ /* Truncating a utf16 string like this might leave the last
+ * gchar incomplete
+ */
+ memcpy (find_data->cFileName, utf16_basename,
+ bytes<(MAX_PATH*2)-2?bytes:(MAX_PATH*2)-2);
+
+ find_data->cAlternateFileName [0] = 0; /* not used */
+
+ g_free (utf8_basename);
+ g_free (utf8_filename);
+ g_free (utf16_basename);
+
+cleanup:
+ mono_w32handle_unlock_handle (handle);
+
+ return(ret);
+}
+
+gboolean
+mono_w32file_find_close (gpointer handle)
+{
+ MonoW32HandleFind *find_handle;
+ gboolean ok;
+
+ if (handle == NULL) {
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FIND,
+ (gpointer *)&find_handle);
+ if(ok==FALSE) {
+ g_warning ("%s: error looking up find handle %p", __func__,
+ handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ mono_w32handle_lock_handle (handle);
+
+ g_strfreev (find_handle->namelist);
+ g_free (find_handle->dir_part);
+
+ mono_w32handle_unlock_handle (handle);
+
+ mono_w32handle_unref (handle);
+
+ return(TRUE);
+}
+
+gboolean
+mono_w32file_create_directory (const gunichar2 *name)
+{
+ gchar *utf8_name;
+ gint result;
+
+ if (name == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return(FALSE);
+ }
+
+ utf8_name = mono_unicode_to_external (name);
+ if (utf8_name == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return FALSE;
+ }
+
+ result = _wapi_mkdir (utf8_name, 0777);
+
+ if (result == 0) {
+ g_free (utf8_name);
+ return TRUE;
+ }
+
+ _wapi_set_last_path_error_from_errno (NULL, utf8_name);
+ g_free (utf8_name);
+ return FALSE;
+}
+
+gboolean
+mono_w32file_remove_directory (const gunichar2 *name)
+{
+ gchar *utf8_name;
+ gint result;
+
+ if (name == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return(FALSE);
+ }
+
+ utf8_name = mono_unicode_to_external (name);
+ if (utf8_name == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return FALSE;
+ }
+
+ result = _wapi_rmdir (utf8_name);
+ if (result == -1) {
+ _wapi_set_last_path_error_from_errno (NULL, utf8_name);
+ g_free (utf8_name);
+
+ return(FALSE);
+ }
+ g_free (utf8_name);
+
+ return(TRUE);
+}
+
+guint32
+mono_w32file_get_attributes (const gunichar2 *name)
+{
+ gchar *utf8_name;
+ struct stat buf, linkbuf;
+ gint result;
+ guint32 ret;
+
+ if (name == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return(FALSE);
+ }
+
+ utf8_name = mono_unicode_to_external (name);
+ if (utf8_name == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return (INVALID_FILE_ATTRIBUTES);
+ }
+
+ result = _wapi_stat (utf8_name, &buf);
+ if (result == -1 && errno == ENOENT) {
+ /* Might be a dangling symlink... */
+ result = _wapi_lstat (utf8_name, &buf);
+ }
+
+ if (result != 0) {
+ _wapi_set_last_path_error_from_errno (NULL, utf8_name);
+ g_free (utf8_name);
+ return (INVALID_FILE_ATTRIBUTES);
+ }
+
+#ifndef __native_client__
+ result = _wapi_lstat (utf8_name, &linkbuf);
+ if (result != 0) {
+ _wapi_set_last_path_error_from_errno (NULL, utf8_name);
+ g_free (utf8_name);
+ return (INVALID_FILE_ATTRIBUTES);
+ }
+#endif
+
+#ifdef __native_client__
+ ret = _wapi_stat_to_file_attributes (utf8_name, &buf, NULL);
+#else
+ ret = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
+#endif
+
+ g_free (utf8_name);
+
+ return(ret);
+}
+
+gboolean
+mono_w32file_get_attributes_ex (const gunichar2 *name, MonoIOStat *stat)
+{
+ gchar *utf8_name;
+
+ struct stat buf, linkbuf;
+ gint result;
+
+ if (name == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return(FALSE);
+ }
+
+ utf8_name = mono_unicode_to_external (name);
+ if (utf8_name == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ result = _wapi_stat (utf8_name, &buf);
+ if (result == -1 && errno == ENOENT) {
+ /* Might be a dangling symlink... */
+ result = _wapi_lstat (utf8_name, &buf);
+ }
+
+ if (result != 0) {
+ _wapi_set_last_path_error_from_errno (NULL, utf8_name);
+ g_free (utf8_name);
+ return FALSE;
+ }
+
+ result = _wapi_lstat (utf8_name, &linkbuf);
+ if (result != 0) {
+ _wapi_set_last_path_error_from_errno (NULL, utf8_name);
+ g_free (utf8_name);
+ return(FALSE);
+ }
+
+ /* fill stat block */
+
+ stat->attributes = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
+ stat->creation_time = (((guint64) (buf.st_mtime < buf.st_ctime ? buf.st_mtime : buf.st_ctime)) * 10 * 1000 * 1000) + 116444736000000000ULL;
+ stat->last_access_time = (((guint64) (buf.st_atime)) * 10 * 1000 * 1000) + 116444736000000000ULL;
+ stat->last_write_time = (((guint64) (buf.st_mtime)) * 10 * 1000 * 1000) + 116444736000000000ULL;
+ stat->length = (stat->attributes & FILE_ATTRIBUTE_DIRECTORY) ? 0 : buf.st_size;
+
+ g_free (utf8_name);
+ return TRUE;
+}
+
+gboolean
+mono_w32file_set_attributes (const gunichar2 *name, guint32 attrs)
+{
+ /* FIXME: think of something clever to do on unix */
+ gchar *utf8_name;
+ struct stat buf;
+ gint result;
+
+ /*
+ * Currently we only handle one *internal* case, with a value that is
+ * not standard: 0x80000000, which means `set executable bit'
+ */
+
+ if (name == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return(FALSE);
+ }
+
+ utf8_name = mono_unicode_to_external (name);
+ if (utf8_name == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return FALSE;
+ }
+
+ result = _wapi_stat (utf8_name, &buf);
+ if (result == -1 && errno == ENOENT) {
+ /* Might be a dangling symlink... */
+ result = _wapi_lstat (utf8_name, &buf);
+ }
+
+ if (result != 0) {
+ _wapi_set_last_path_error_from_errno (NULL, utf8_name);
+ g_free (utf8_name);
+ return FALSE;
+ }
+
+ /* Contrary to the documentation, ms allows NORMAL to be
+ * specified along with other attributes, so dont bother to
+ * catch that case here.
+ */
+ if (attrs & FILE_ATTRIBUTE_READONLY) {
+ result = _wapi_chmod (utf8_name, buf.st_mode & ~(S_IWUSR | S_IWOTH | S_IWGRP));
+ } else {
+ result = _wapi_chmod (utf8_name, buf.st_mode | S_IWUSR);
+ }
+
+ /* Ignore the other attributes for now */
+
+ if (attrs & 0x80000000){
+ mode_t exec_mask = 0;
+
+ if ((buf.st_mode & S_IRUSR) != 0)
+ exec_mask |= S_IXUSR;
+
+ if ((buf.st_mode & S_IRGRP) != 0)
+ exec_mask |= S_IXGRP;
+
+ if ((buf.st_mode & S_IROTH) != 0)
+ exec_mask |= S_IXOTH;
+
+ result = chmod (utf8_name, buf.st_mode | exec_mask);
+ }
+ /* Don't bother to reset executable (might need to change this
+ * policy)
+ */
+
+ g_free (utf8_name);
+
+ return(TRUE);
+}
+
+guint32
+mono_w32file_get_cwd (guint32 length, gunichar2 *buffer)
+{
+ gunichar2 *utf16_path;
+ glong count;
+ gsize bytes;
+
+#ifdef __native_client__
+ gchar *path = g_get_current_dir ();
+ if (length < strlen(path) + 1 || path == NULL)
+ return 0;
+ memcpy (buffer, path, strlen(path) + 1);
+#else
+ if (getcwd ((gchar*)buffer, length) == NULL) {
+ if (errno == ERANGE) { /*buffer length is not big enough */
+ gchar *path = g_get_current_dir (); /*FIXME g_get_current_dir doesn't work with broken paths and calling it just to know the path length is silly*/
+ if (path == NULL)
+ return 0;
+ utf16_path = mono_unicode_from_external (path, &bytes);
+ g_free (utf16_path);
+ g_free (path);
+ return (bytes/2)+1;
+ }
+ _wapi_set_last_error_from_errno ();
+ return 0;
+ }
+#endif
+
+ utf16_path = mono_unicode_from_external ((gchar*)buffer, &bytes);
+ count = (bytes/2)+1;
+ g_assert (count <= length); /*getcwd must have failed before with ERANGE*/
+
+ /* Add the terminator */
+ memset (buffer, '\0', bytes+2);
+ memcpy (buffer, utf16_path, bytes);
+
+ g_free (utf16_path);
+
+ return count;
+}
+
+gboolean
+mono_w32file_set_cwd (const gunichar2 *path)
+{
+ gchar *utf8_path;
+ gboolean result;
+
+ if (path == NULL) {
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return(FALSE);
+ }
+
+ utf8_path = mono_unicode_to_external (path);
+ if (_wapi_chdir (utf8_path) != 0) {
+ _wapi_set_last_error_from_errno ();
+ result = FALSE;
+ }
+ else
+ result = TRUE;
+
+ g_free (utf8_path);
+ return result;
+}
+
+gboolean
+mono_w32file_create_pipe (gpointer *readpipe, gpointer *writepipe, guint32 size)
+{
+ MonoW32HandleFile pipe_read_handle = {0};
+ MonoW32HandleFile pipe_write_handle = {0};
+ gpointer read_handle;
+ gpointer write_handle;
+ gint filedes[2];
+ gint ret;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating pipe", __func__);
+
+ ret=pipe (filedes);
+ if(ret==-1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error creating pipe: %s", __func__,
+ strerror (errno));
+
+ _wapi_set_last_error_from_errno ();
+ return(FALSE);
+ }
+
+ if (filedes[0] >= mono_w32handle_fd_reserve ||
+ filedes[1] >= mono_w32handle_fd_reserve) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big", __func__);
+
+ mono_w32error_set_last (ERROR_TOO_MANY_OPEN_FILES);
+
+ close (filedes[0]);
+ close (filedes[1]);
+
+ return(FALSE);
+ }
+
+ /* filedes[0] is open for reading, filedes[1] for writing */
+
+ pipe_read_handle.fd = filedes [0];
+ pipe_read_handle.fileaccess = GENERIC_READ;
+ read_handle = mono_w32handle_new_fd (MONO_W32HANDLE_PIPE, filedes[0],
+ &pipe_read_handle);
+ if (read_handle == INVALID_HANDLE_VALUE) {
+ g_warning ("%s: error creating pipe read handle", __func__);
+ close (filedes[0]);
+ close (filedes[1]);
+ mono_w32error_set_last (ERROR_GEN_FAILURE);
+
+ return(FALSE);
+ }
+
+ pipe_write_handle.fd = filedes [1];
+ pipe_write_handle.fileaccess = GENERIC_WRITE;
+ write_handle = mono_w32handle_new_fd (MONO_W32HANDLE_PIPE, filedes[1],
+ &pipe_write_handle);
+ if (write_handle == INVALID_HANDLE_VALUE) {
+ g_warning ("%s: error creating pipe write handle", __func__);
+ mono_w32handle_unref (read_handle);
+
+ close (filedes[0]);
+ close (filedes[1]);
+ mono_w32error_set_last (ERROR_GEN_FAILURE);
+
+ return(FALSE);
+ }
+
+ *readpipe = read_handle;
+ *writepipe = write_handle;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning pipe: read handle %p, write handle %p",
+ __func__, read_handle, write_handle);
+
+ return(TRUE);
+}
+
+#ifdef HAVE_GETFSSTAT
+/* Darwin has getfsstat */
+gint32
+mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf)
+{
+ struct statfs *stats;
+ gint size, n, i;
+ gunichar2 *dir;
+ glong length, total = 0;
+
+ n = getfsstat (NULL, 0, MNT_NOWAIT);
+ if (n == -1)
+ return 0;
+ size = n * sizeof (struct statfs);
+ stats = (struct statfs *) g_malloc (size);
+ if (stats == NULL)
+ return 0;
+ if (getfsstat (stats, size, MNT_NOWAIT) == -1){
+ g_free (stats);
+ return 0;
+ }
+ for (i = 0; i < n; i++){
+ dir = g_utf8_to_utf16 (stats [i].f_mntonname, -1, NULL, &length, NULL);
+ if (total + length < len){
+ memcpy (buf + total, dir, sizeof (gunichar2) * length);
+ buf [total+length] = 0;
+ }
+ g_free (dir);
+ total += length + 1;
+ }
+ if (total < len)
+ buf [total] = 0;
+ total++;
+ g_free (stats);
+ return total;
+}
+#else
+/* In-place octal sequence replacement */
+static void
+unescape_octal (gchar *str)
+{
+ gchar *rptr;
+ gchar *wptr;
+
+ if (str == NULL)
+ return;
+
+ rptr = wptr = str;
+ while (*rptr != '\0') {
+ if (*rptr == '\\') {
+ gchar c;
+ rptr++;
+ c = (*(rptr++) - '0') << 6;
+ c += (*(rptr++) - '0') << 3;
+ c += *(rptr++) - '0';
+ *wptr++ = c;
+ } else if (wptr != rptr) {
+ *wptr++ = *rptr++;
+ } else {
+ rptr++; wptr++;
+ }
+ }
+ *wptr = '\0';
+}
+static gint32 GetLogicalDriveStrings_Mtab (guint32 len, gunichar2 *buf);
+
+#if __linux__
+#define GET_LOGICAL_DRIVE_STRINGS_BUFFER 512
+#define GET_LOGICAL_DRIVE_STRINGS_MOUNTPOINT_BUFFER 512
+#define GET_LOGICAL_DRIVE_STRINGS_FSNAME_BUFFER 64
+
+typedef struct
+{
+ glong total;
+ guint32 buffer_index;
+ guint32 mountpoint_index;
+ guint32 field_number;
+ guint32 allocated_size;
+ guint32 fsname_index;
+ guint32 fstype_index;
+ gchar mountpoint [GET_LOGICAL_DRIVE_STRINGS_MOUNTPOINT_BUFFER + 1];
+ gchar *mountpoint_allocated;
+ gchar buffer [GET_LOGICAL_DRIVE_STRINGS_BUFFER];
+ gchar fsname [GET_LOGICAL_DRIVE_STRINGS_FSNAME_BUFFER + 1];
+ gchar fstype [GET_LOGICAL_DRIVE_STRINGS_FSNAME_BUFFER + 1];
+ ssize_t nbytes;
+ gchar delimiter;
+ gboolean check_mount_source;
+} LinuxMountInfoParseState;
+
+static gboolean GetLogicalDriveStrings_Mounts (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state);
+static gboolean GetLogicalDriveStrings_MountInfo (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state);
+static void append_to_mountpoint (LinuxMountInfoParseState *state);
+static gboolean add_drive_string (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state);
+
+gint32
+mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf)
+{
+ gint fd;
+ gint32 ret = 0;
+ LinuxMountInfoParseState state;
+ gboolean (*parser)(guint32, gunichar2*, LinuxMountInfoParseState*) = NULL;
+
+ memset (buf, 0, len * sizeof (gunichar2));
+ fd = open ("/proc/self/mountinfo", O_RDONLY);
+ if (fd != -1)
+ parser = GetLogicalDriveStrings_MountInfo;
+ else {
+ fd = open ("/proc/mounts", O_RDONLY);
+ if (fd != -1)
+ parser = GetLogicalDriveStrings_Mounts;
+ }
+
+ if (!parser) {
+ ret = GetLogicalDriveStrings_Mtab (len, buf);
+ goto done_and_out;
+ }
+
+ memset (&state, 0, sizeof (LinuxMountInfoParseState));
+ state.field_number = 1;
+ state.delimiter = ' ';
+
+ while ((state.nbytes = read (fd, state.buffer, GET_LOGICAL_DRIVE_STRINGS_BUFFER)) > 0) {
+ state.buffer_index = 0;
+
+ while ((*parser)(len, buf, &state)) {
+ if (state.buffer [state.buffer_index] == '\n') {
+ gboolean quit = add_drive_string (len, buf, &state);
+ state.field_number = 1;
+ state.buffer_index++;
+ if (state.mountpoint_allocated) {
+ g_free (state.mountpoint_allocated);
+ state.mountpoint_allocated = NULL;
+ }
+ if (quit) {
+ ret = state.total;
+ goto done_and_out;
+ }
+ }
+ }
+ };
+ ret = state.total;
+
+ done_and_out:
+ if (fd != -1)
+ close (fd);
+ return ret;
+}
+
+static gboolean GetLogicalDriveStrings_Mounts (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state)
+{
+ gchar *ptr;
+
+ if (state->field_number == 1)
+ state->check_mount_source = TRUE;
+
+ while (state->buffer_index < (guint32)state->nbytes) {
+ if (state->buffer [state->buffer_index] == state->delimiter) {
+ state->field_number++;
+ switch (state->field_number) {
+ case 2:
+ state->mountpoint_index = 0;
+ break;
+
+ case 3:
+ if (state->mountpoint_allocated)
+ state->mountpoint_allocated [state->mountpoint_index] = 0;
+ else
+ state->mountpoint [state->mountpoint_index] = 0;
+ break;
+
+ default:
+ ptr = (gchar*)memchr (state->buffer + state->buffer_index, '\n', GET_LOGICAL_DRIVE_STRINGS_BUFFER - state->buffer_index);
+ if (ptr)
+ state->buffer_index = (ptr - (gchar*)state->buffer) - 1;
+ else
+ state->buffer_index = state->nbytes;
+ return TRUE;
+ }
+ state->buffer_index++;
+ continue;
+ } else if (state->buffer [state->buffer_index] == '\n')
+ return TRUE;
+
+ switch (state->field_number) {
+ case 1:
+ if (state->check_mount_source) {
+ if (state->fsname_index == 0 && state->buffer [state->buffer_index] == '/') {
+ /* We can ignore the rest, it's a device
+ * path */
+ state->check_mount_source = FALSE;
+ state->fsname [state->fsname_index++] = '/';
+ break;
+ }
+ if (state->fsname_index < GET_LOGICAL_DRIVE_STRINGS_FSNAME_BUFFER)
+ state->fsname [state->fsname_index++] = state->buffer [state->buffer_index];
+ }
+ break;
+
+ case 2:
+ append_to_mountpoint (state);
+ break;
+
+ case 3:
+ if (state->fstype_index < GET_LOGICAL_DRIVE_STRINGS_FSNAME_BUFFER)
+ state->fstype [state->fstype_index++] = state->buffer [state->buffer_index];
+ break;
+ }
+
+ state->buffer_index++;
+ }
+
+ return FALSE;
+}
+
+static gboolean GetLogicalDriveStrings_MountInfo (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state)
+{
+ while (state->buffer_index < (guint32)state->nbytes) {
+ if (state->buffer [state->buffer_index] == state->delimiter) {
+ state->field_number++;
+ switch (state->field_number) {
+ case 5:
+ state->mountpoint_index = 0;
+ break;
+
+ case 6:
+ if (state->mountpoint_allocated)
+ state->mountpoint_allocated [state->mountpoint_index] = 0;
+ else
+ state->mountpoint [state->mountpoint_index] = 0;
+ break;
+
+ case 7:
+ state->delimiter = '-';
+ break;
+
+ case 8:
+ state->delimiter = ' ';
+ break;
+
+ case 10:
+ state->check_mount_source = TRUE;
+ break;
+ }
+ state->buffer_index++;
+ continue;
+ } else if (state->buffer [state->buffer_index] == '\n')
+ return TRUE;
+
+ switch (state->field_number) {
+ case 5:
+ append_to_mountpoint (state);
+ break;
+
+ case 9:
+ if (state->fstype_index < GET_LOGICAL_DRIVE_STRINGS_FSNAME_BUFFER)
+ state->fstype [state->fstype_index++] = state->buffer [state->buffer_index];
+ break;
+
+ case 10:
+ if (state->check_mount_source) {
+ if (state->fsname_index == 0 && state->buffer [state->buffer_index] == '/') {
+ /* We can ignore the rest, it's a device
+ * path */
+ state->check_mount_source = FALSE;
+ state->fsname [state->fsname_index++] = '/';
+ break;
+ }
+ if (state->fsname_index < GET_LOGICAL_DRIVE_STRINGS_FSNAME_BUFFER)
+ state->fsname [state->fsname_index++] = state->buffer [state->buffer_index];
+ }
+ break;
+ }
+
+ state->buffer_index++;
+ }
+
+ return FALSE;
+}
+
+static void
+append_to_mountpoint (LinuxMountInfoParseState *state)
+{
+ gchar ch = state->buffer [state->buffer_index];
+ if (state->mountpoint_allocated) {
+ if (state->mountpoint_index >= state->allocated_size) {
+ guint32 newsize = (state->allocated_size << 1) + 1;
+ gchar *newbuf = (gchar *)g_malloc0 (newsize * sizeof (gchar));
+
+ memcpy (newbuf, state->mountpoint_allocated, state->mountpoint_index);
+ g_free (state->mountpoint_allocated);
+ state->mountpoint_allocated = newbuf;
+ state->allocated_size = newsize;
+ }
+ state->mountpoint_allocated [state->mountpoint_index++] = ch;
+ } else {
+ if (state->mountpoint_index >= GET_LOGICAL_DRIVE_STRINGS_MOUNTPOINT_BUFFER) {
+ state->allocated_size = (state->mountpoint_index << 1) + 1;
+ state->mountpoint_allocated = (gchar *)g_malloc0 (state->allocated_size * sizeof (gchar));
+ memcpy (state->mountpoint_allocated, state->mountpoint, state->mountpoint_index);
+ state->mountpoint_allocated [state->mountpoint_index++] = ch;
+ } else
+ state->mountpoint [state->mountpoint_index++] = ch;
+ }
+}
+
+static gboolean
+add_drive_string (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state)
+{
+ gboolean quit = FALSE;
+ gboolean ignore_entry;
+
+ if (state->fsname_index == 1 && state->fsname [0] == '/')
+ ignore_entry = FALSE;
+ else if (memcmp ("overlay", state->fsname, state->fsname_index) == 0 ||
+ memcmp ("aufs", state->fstype, state->fstype_index) == 0) {
+ /* Don't ignore overlayfs and aufs - these might be used on Docker
+ * (https://bugzilla.xamarin.com/show_bug.cgi?id=31021) */
+ ignore_entry = FALSE;
+ } else if (state->fsname_index == 0 || memcmp ("none", state->fsname, state->fsname_index) == 0) {
+ ignore_entry = TRUE;
+ } else if (state->fstype_index >= 5 && memcmp ("fuse.", state->fstype, 5) == 0) {
+ /* Ignore GNOME's gvfs */
+ if (state->fstype_index == 21 && memcmp ("fuse.gvfs-fuse-daemon", state->fstype, state->fstype_index) == 0)
+ ignore_entry = TRUE;
+ else
+ ignore_entry = FALSE;
+ } else if (state->fstype_index == 3 && memcmp ("nfs", state->fstype, state->fstype_index) == 0)
+ ignore_entry = FALSE;
+ else
+ ignore_entry = TRUE;
+
+ if (!ignore_entry) {
+ gunichar2 *dir;
+ glong length;
+ gchar *mountpoint = state->mountpoint_allocated ? state->mountpoint_allocated : state->mountpoint;
+
+ unescape_octal (mountpoint);
+ dir = g_utf8_to_utf16 (mountpoint, -1, NULL, &length, NULL);
+ if (state->total + length + 1 > len) {
+ quit = TRUE;
+ state->total = len * 2;
+ } else {
+ length++;
+ memcpy (buf + state->total, dir, sizeof (gunichar2) * length);
+ state->total += length;
+ }
+ g_free (dir);
+ }
+ state->fsname_index = 0;
+ state->fstype_index = 0;
+
+ return quit;
+}
+#else
+gint32
+mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf)
+{
+ return GetLogicalDriveStrings_Mtab (len, buf);
+}
+#endif
+static gint32
+GetLogicalDriveStrings_Mtab (guint32 len, gunichar2 *buf)
+{
+ FILE *fp;
+ gunichar2 *ptr, *dir;
+ glong length, total = 0;
+ gchar buffer [512];
+ gchar **splitted;
+
+ memset (buf, 0, sizeof (gunichar2) * (len + 1));
+ buf [0] = '/';
+ buf [1] = 0;
+ buf [2] = 0;
+
+ /* Sigh, mntent and friends don't work well.
+ * It stops on the first line that doesn't begin with a '/'.
+ * (linux 2.6.5, libc 2.3.2.ds1-12) - Gonz */
+ fp = fopen ("/etc/mtab", "rt");
+ if (fp == NULL) {
+ fp = fopen ("/etc/mnttab", "rt");
+ if (fp == NULL)
+ return 1;
+ }
+
+ ptr = buf;
+ while (fgets (buffer, 512, fp) != NULL) {
+ if (*buffer != '/')
+ continue;
+
+ splitted = g_strsplit (buffer, " ", 0);
+ if (!*splitted || !*(splitted + 1)) {
+ g_strfreev (splitted);
+ continue;
+ }
+
+ unescape_octal (*(splitted + 1));
+ dir = g_utf8_to_utf16 (*(splitted + 1), -1, NULL, &length, NULL);
+ g_strfreev (splitted);
+ if (total + length + 1 > len) {
+ fclose (fp);
+ g_free (dir);
+ return len * 2; /* guess */
+ }
+
+ memcpy (ptr + total, dir, sizeof (gunichar2) * length);
+ g_free (dir);
+ total += length + 1;
+ }
+
+ fclose (fp);
+ return total;
+/* Commented out, does not work with my mtab!!! - Gonz */
+#ifdef NOTENABLED /* HAVE_MNTENT_H */
+{
+ FILE *fp;
+ struct mntent *mnt;
+ gunichar2 *ptr, *dir;
+ glong len, total = 0;
+
+
+ fp = setmntent ("/etc/mtab", "rt");
+ if (fp == NULL) {
+ fp = setmntent ("/etc/mnttab", "rt");
+ if (fp == NULL)
+ return;
+ }
+
+ ptr = buf;
+ while ((mnt = getmntent (fp)) != NULL) {
+ g_print ("GOT %s\n", mnt->mnt_dir);
+ dir = g_utf8_to_utf16 (mnt->mnt_dir, &len, NULL, NULL, NULL);
+ if (total + len + 1 > len) {
+ return len * 2; /* guess */
+ }
+
+ memcpy (ptr + total, dir, sizeof (gunichar2) * len);
+ g_free (dir);
+ total += len + 1;
+ }
+
+ endmntent (fp);
+ return total;
+}
+#endif
+}
+#endif
+
+#if defined(HAVE_STATVFS) || defined(HAVE_STATFS)
+gboolean
+mono_w32file_get_disk_free_space (const gunichar2 *path_name, guint64 *free_bytes_avail, guint64 *total_number_of_bytes, guint64 *total_number_of_free_bytes)
+{
+#ifdef HAVE_STATVFS
+ struct statvfs fsstat;
+#elif defined(HAVE_STATFS)
+ struct statfs fsstat;
+#endif
+ gboolean isreadonly;
+ gchar *utf8_path_name;
+ gint ret;
+ unsigned long block_size;
+
+ if (path_name == NULL) {
+ utf8_path_name = g_strdup (g_get_current_dir());
+ if (utf8_path_name == NULL) {
+ mono_w32error_set_last (ERROR_DIRECTORY);
+ return(FALSE);
+ }
+ }
+ else {
+ utf8_path_name = mono_unicode_to_external (path_name);
+ if (utf8_path_name == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
+
+ mono_w32error_set_last (ERROR_INVALID_NAME);
+ return(FALSE);
+ }
+ }
+
+ do {
+#ifdef HAVE_STATVFS
+ ret = statvfs (utf8_path_name, &fsstat);
+ isreadonly = ((fsstat.f_flag & ST_RDONLY) == ST_RDONLY);
+ block_size = fsstat.f_frsize;
+#elif defined(HAVE_STATFS)
+ ret = statfs (utf8_path_name, &fsstat);
+#if defined (MNT_RDONLY)
+ isreadonly = ((fsstat.f_flags & MNT_RDONLY) == MNT_RDONLY);
+#elif defined (MS_RDONLY)
+ isreadonly = ((fsstat.f_flags & MS_RDONLY) == MS_RDONLY);
+#endif
+ block_size = fsstat.f_bsize;
+#endif
+ } while(ret == -1 && errno == EINTR);
+
+ g_free(utf8_path_name);
+
+ if (ret == -1) {
+ _wapi_set_last_error_from_errno ();
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: statvfs failed: %s", __func__, strerror (errno));
+ return(FALSE);
+ }
+
+ /* total number of free bytes for non-root */
+ if (free_bytes_avail != NULL) {
+ if (isreadonly) {
+ *free_bytes_avail = 0;
+ }
+ else {
+ *free_bytes_avail = block_size * (guint64)fsstat.f_bavail;
+ }
+ }
+
+ /* total number of bytes available for non-root */
+ if (total_number_of_bytes != NULL) {
+ *total_number_of_bytes = block_size * (guint64)fsstat.f_blocks;
+ }
+
+ /* total number of bytes available for root */
+ if (total_number_of_free_bytes != NULL) {
+ if (isreadonly) {
+ *total_number_of_free_bytes = 0;
+ }
+ else {
+ *total_number_of_free_bytes = block_size * (guint64)fsstat.f_bfree;
+ }
+ }
+
+ return(TRUE);
+}
+#else
+gboolean
+mono_w32file_get_disk_free_space (const gunichar2 *path_name, guint64 *free_bytes_avail, guint64 *total_number_of_bytes, guint64 *total_number_of_free_bytes)
+{
+ if (free_bytes_avail != NULL) {
+ *free_bytes_avail = (guint64) -1;
+ }
+
+ if (total_number_of_bytes != NULL) {
+ *total_number_of_bytes = (guint64) -1;
+ }
+
+ if (total_number_of_free_bytes != NULL) {
+ *total_number_of_free_bytes = (guint64) -1;
+ }
+
+ return(TRUE);
+}
+#endif
+
+/*
+ * General Unix support
+ */
+typedef struct {
+ guint32 drive_type;
+#if __linux__
+ const long fstypeid;
+#endif
+ const gchar* fstype;
+} _wapi_drive_type;
+
+static _wapi_drive_type _wapi_drive_types[] = {
+#if PLATFORM_MACOSX
+ { DRIVE_REMOTE, "afp" },
+ { DRIVE_REMOTE, "autofs" },
+ { DRIVE_CDROM, "cddafs" },
+ { DRIVE_CDROM, "cd9660" },
+ { DRIVE_RAMDISK, "devfs" },
+ { DRIVE_FIXED, "exfat" },
+ { DRIVE_RAMDISK, "fdesc" },
+ { DRIVE_REMOTE, "ftp" },
+ { DRIVE_FIXED, "hfs" },
+ { DRIVE_FIXED, "msdos" },
+ { DRIVE_REMOTE, "nfs" },
+ { DRIVE_FIXED, "ntfs" },
+ { DRIVE_REMOTE, "smbfs" },
+ { DRIVE_FIXED, "udf" },
+ { DRIVE_REMOTE, "webdav" },
+ { DRIVE_UNKNOWN, NULL }
+#elif __linux__
+ { DRIVE_FIXED, ADFS_SUPER_MAGIC, "adfs"},
+ { DRIVE_FIXED, AFFS_SUPER_MAGIC, "affs"},
+ { DRIVE_REMOTE, AFS_SUPER_MAGIC, "afs"},
+ { DRIVE_RAMDISK, AUTOFS_SUPER_MAGIC, "autofs"},
+ { DRIVE_RAMDISK, AUTOFS_SBI_MAGIC, "autofs4"},
+ { DRIVE_REMOTE, CODA_SUPER_MAGIC, "coda" },
+ { DRIVE_RAMDISK, CRAMFS_MAGIC, "cramfs"},
+ { DRIVE_RAMDISK, CRAMFS_MAGIC_WEND, "cramfs"},
+ { DRIVE_REMOTE, CIFS_MAGIC_NUMBER, "cifs"},
+ { DRIVE_RAMDISK, DEBUGFS_MAGIC, "debugfs"},
+ { DRIVE_RAMDISK, SYSFS_MAGIC, "sysfs"},
+ { DRIVE_RAMDISK, SECURITYFS_MAGIC, "securityfs"},
+ { DRIVE_RAMDISK, SELINUX_MAGIC, "selinuxfs"},
+ { DRIVE_RAMDISK, RAMFS_MAGIC, "ramfs"},
+ { DRIVE_FIXED, SQUASHFS_MAGIC, "squashfs"},
+ { DRIVE_FIXED, EFS_SUPER_MAGIC, "efs"},
+ { DRIVE_FIXED, EXT2_SUPER_MAGIC, "ext"},
+ { DRIVE_FIXED, EXT3_SUPER_MAGIC, "ext"},
+ { DRIVE_FIXED, EXT4_SUPER_MAGIC, "ext"},
+ { DRIVE_REMOTE, XENFS_SUPER_MAGIC, "xenfs"},
+ { DRIVE_FIXED, BTRFS_SUPER_MAGIC, "btrfs"},
+ { DRIVE_FIXED, HFS_SUPER_MAGIC, "hfs"},
+ { DRIVE_FIXED, HFSPLUS_SUPER_MAGIC, "hfsplus"},
+ { DRIVE_FIXED, HPFS_SUPER_MAGIC, "hpfs"},
+ { DRIVE_RAMDISK, HUGETLBFS_MAGIC, "hugetlbfs"},
+ { DRIVE_CDROM, ISOFS_SUPER_MAGIC, "iso"},
+ { DRIVE_FIXED, JFFS2_SUPER_MAGIC, "jffs2"},
+ { DRIVE_RAMDISK, ANON_INODE_FS_MAGIC, "anon_inode"},
+ { DRIVE_FIXED, JFS_SUPER_MAGIC, "jfs"},
+ { DRIVE_FIXED, MINIX_SUPER_MAGIC, "minix"},
+ { DRIVE_FIXED, MINIX_SUPER_MAGIC2, "minix v2"},
+ { DRIVE_FIXED, MINIX2_SUPER_MAGIC, "minix2"},
+ { DRIVE_FIXED, MINIX2_SUPER_MAGIC2, "minix2 v2"},
+ { DRIVE_FIXED, MINIX3_SUPER_MAGIC, "minix3"},
+ { DRIVE_FIXED, MSDOS_SUPER_MAGIC, "msdos"},
+ { DRIVE_REMOTE, NCP_SUPER_MAGIC, "ncp"},
+ { DRIVE_REMOTE, NFS_SUPER_MAGIC, "nfs"},
+ { DRIVE_FIXED, NTFS_SB_MAGIC, "ntfs"},
+ { DRIVE_RAMDISK, OPENPROM_SUPER_MAGIC, "openpromfs"},
+ { DRIVE_RAMDISK, PROC_SUPER_MAGIC, "proc"},
+ { DRIVE_FIXED, QNX4_SUPER_MAGIC, "qnx4"},
+ { DRIVE_FIXED, REISERFS_SUPER_MAGIC, "reiserfs"},
+ { DRIVE_RAMDISK, ROMFS_MAGIC, "romfs"},
+ { DRIVE_REMOTE, SMB_SUPER_MAGIC, "samba"},
+ { DRIVE_RAMDISK, CGROUP_SUPER_MAGIC, "cgroupfs"},
+ { DRIVE_RAMDISK, FUTEXFS_SUPER_MAGIC, "futexfs"},
+ { DRIVE_FIXED, SYSV2_SUPER_MAGIC, "sysv2"},
+ { DRIVE_FIXED, SYSV4_SUPER_MAGIC, "sysv4"},
+ { DRIVE_RAMDISK, TMPFS_MAGIC, "tmpfs"},
+ { DRIVE_RAMDISK, DEVPTS_SUPER_MAGIC, "devpts"},
+ { DRIVE_CDROM, UDF_SUPER_MAGIC, "udf"},
+ { DRIVE_FIXED, UFS_MAGIC, "ufs"},
+ { DRIVE_FIXED, UFS_MAGIC_BW, "ufs"},
+ { DRIVE_FIXED, UFS2_MAGIC, "ufs2"},
+ { DRIVE_FIXED, UFS_CIGAM, "ufs"},
+ { DRIVE_RAMDISK, USBDEVICE_SUPER_MAGIC, "usbdev"},
+ { DRIVE_FIXED, XENIX_SUPER_MAGIC, "xenix"},
+ { DRIVE_FIXED, XFS_SB_MAGIC, "xfs"},
+ { DRIVE_RAMDISK, FUSE_SUPER_MAGIC, "fuse"},
+ { DRIVE_FIXED, V9FS_MAGIC, "9p"},
+ { DRIVE_REMOTE, CEPH_SUPER_MAGIC, "ceph"},
+ { DRIVE_RAMDISK, CONFIGFS_MAGIC, "configfs"},
+ { DRIVE_RAMDISK, ECRYPTFS_SUPER_MAGIC, "eCryptfs"},
+ { DRIVE_FIXED, EXOFS_SUPER_MAGIC, "exofs"},
+ { DRIVE_FIXED, VXFS_SUPER_MAGIC, "vxfs"},
+ { DRIVE_FIXED, VXFS_OLT_MAGIC, "vxfs_olt"},
+ { DRIVE_REMOTE, GFS2_MAGIC, "gfs2"},
+ { DRIVE_FIXED, LOGFS_MAGIC_U32, "logfs"},
+ { DRIVE_FIXED, OCFS2_SUPER_MAGIC, "ocfs2"},
+ { DRIVE_FIXED, OMFS_MAGIC, "omfs"},
+ { DRIVE_FIXED, UBIFS_SUPER_MAGIC, "ubifs"},
+ { DRIVE_UNKNOWN, 0, NULL}
+#else
+ { DRIVE_RAMDISK, "ramfs" },
+ { DRIVE_RAMDISK, "tmpfs" },
+ { DRIVE_RAMDISK, "proc" },
+ { DRIVE_RAMDISK, "sysfs" },
+ { DRIVE_RAMDISK, "debugfs" },
+ { DRIVE_RAMDISK, "devpts" },
+ { DRIVE_RAMDISK, "securityfs" },
+ { DRIVE_CDROM, "iso9660" },
+ { DRIVE_FIXED, "ext2" },
+ { DRIVE_FIXED, "ext3" },
+ { DRIVE_FIXED, "ext4" },
+ { DRIVE_FIXED, "sysv" },
+ { DRIVE_FIXED, "reiserfs" },
+ { DRIVE_FIXED, "ufs" },
+ { DRIVE_FIXED, "vfat" },
+ { DRIVE_FIXED, "msdos" },
+ { DRIVE_FIXED, "udf" },
+ { DRIVE_FIXED, "hfs" },
+ { DRIVE_FIXED, "hpfs" },
+ { DRIVE_FIXED, "qnx4" },
+ { DRIVE_FIXED, "ntfs" },
+ { DRIVE_FIXED, "ntfs-3g" },
+ { DRIVE_REMOTE, "smbfs" },
+ { DRIVE_REMOTE, "fuse" },
+ { DRIVE_REMOTE, "nfs" },
+ { DRIVE_REMOTE, "nfs4" },
+ { DRIVE_REMOTE, "cifs" },
+ { DRIVE_REMOTE, "ncpfs" },
+ { DRIVE_REMOTE, "coda" },
+ { DRIVE_REMOTE, "afs" },
+ { DRIVE_UNKNOWN, NULL }
+#endif
+};
+
+#if __linux__
+static guint32 _wapi_get_drive_type(long f_type)
+{
+ _wapi_drive_type *current;
+
+ current = &_wapi_drive_types[0];
+ while (current->drive_type != DRIVE_UNKNOWN) {
+ if (current->fstypeid == f_type)
+ return current->drive_type;
+ current++;
+ }
+
+ return DRIVE_UNKNOWN;
+}
+#else
+static guint32 _wapi_get_drive_type(const gchar* fstype)
+{
+ _wapi_drive_type *current;
+
+ current = &_wapi_drive_types[0];
+ while (current->drive_type != DRIVE_UNKNOWN) {
+ if (strcmp (current->fstype, fstype) == 0)
+ break;
+
+ current++;
+ }
+
+ return current->drive_type;
+}
+#endif
+
+#if defined (PLATFORM_MACOSX) || defined (__linux__)
+static guint32
+GetDriveTypeFromPath (const gchar *utf8_root_path_name)
+{
+ struct statfs buf;
+
+ if (statfs (utf8_root_path_name, &buf) == -1)
+ return DRIVE_UNKNOWN;
+#if PLATFORM_MACOSX
+ return _wapi_get_drive_type (buf.f_fstypename);
+#else
+ return _wapi_get_drive_type (buf.f_type);
+#endif
+}
+#else
+static guint32
+GetDriveTypeFromPath (const gchar *utf8_root_path_name)
+{
+ guint32 drive_type;
+ FILE *fp;
+ gchar buffer [512];
+ gchar **splitted;
+
+ fp = fopen ("/etc/mtab", "rt");
+ if (fp == NULL) {
+ fp = fopen ("/etc/mnttab", "rt");
+ if (fp == NULL)
+ return(DRIVE_UNKNOWN);
+ }
+
+ drive_type = DRIVE_NO_ROOT_DIR;
+ while (fgets (buffer, 512, fp) != NULL) {
+ splitted = g_strsplit (buffer, " ", 0);
+ if (!*splitted || !*(splitted + 1) || !*(splitted + 2)) {
+ g_strfreev (splitted);
+ continue;
+ }
+
+ /* compare given root_path_name with the one from mtab,
+ if length of utf8_root_path_name is zero it must be the root dir */
+ if (strcmp (*(splitted + 1), utf8_root_path_name) == 0 ||
+ (strcmp (*(splitted + 1), "/") == 0 && strlen (utf8_root_path_name) == 0)) {
+ drive_type = _wapi_get_drive_type (*(splitted + 2));
+ /* it is possible this path might be mounted again with
+ a known type...keep looking */
+ if (drive_type != DRIVE_UNKNOWN) {
+ g_strfreev (splitted);
+ break;
+ }
+ }
+
+ g_strfreev (splitted);
+ }
+
+ fclose (fp);
+ return drive_type;
+}
+#endif
+
+guint32
+mono_w32file_get_drive_type(const gunichar2 *root_path_name)
+{
+ gchar *utf8_root_path_name;
+ guint32 drive_type;
+
+ if (root_path_name == NULL) {
+ utf8_root_path_name = g_strdup (g_get_current_dir());
+ if (utf8_root_path_name == NULL) {
+ return(DRIVE_NO_ROOT_DIR);
+ }
+ }
+ else {
+ utf8_root_path_name = mono_unicode_to_external (root_path_name);
+ if (utf8_root_path_name == NULL) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
+ return(DRIVE_NO_ROOT_DIR);
+ }
+
+ /* strip trailing slash for compare below */
+ if (g_str_has_suffix(utf8_root_path_name, "/") && utf8_root_path_name [1] != 0) {
+ utf8_root_path_name[strlen(utf8_root_path_name) - 1] = 0;
+ }
+ }
+ drive_type = GetDriveTypeFromPath (utf8_root_path_name);
+ g_free (utf8_root_path_name);
+
+ return (drive_type);
+}
+
+#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD) || defined(__native_client__) || defined(__FreeBSD_kernel__)
+static gchar*
+get_fstypename (gchar *utfpath)
+{
+#if defined (PLATFORM_MACOSX) || defined (__linux__)
+ struct statfs stat;
+#if __linux__
+ _wapi_drive_type *current;
+#endif
+ if (statfs (utfpath, &stat) == -1)
+ return NULL;
+#if PLATFORM_MACOSX
+ return g_strdup (stat.f_fstypename);
+#else
+ current = &_wapi_drive_types[0];
+ while (current->drive_type != DRIVE_UNKNOWN) {
+ if (stat.f_type == current->fstypeid)
+ return g_strdup (current->fstype);
+ current++;
+ }
+ return NULL;
+#endif
+#else
+ return NULL;
+#endif
+}
+
+/* Linux has struct statfs which has a different layout */
+gboolean
+mono_w32file_get_volume_information (const gunichar2 *path, gunichar2 *volumename, gint volumesize, gint *outserial, gint *maxcomp, gint *fsflags, gunichar2 *fsbuffer, gint fsbuffersize)
+{
+ gchar *utfpath;
+ gchar *fstypename;
+ gboolean status = FALSE;
+ glong len;
+
+ // We only support getting the file system type
+ if (fsbuffer == NULL)
+ return 0;
+
+ utfpath = mono_unicode_to_external (path);
+ if ((fstypename = get_fstypename (utfpath)) != NULL){
+ gunichar2 *ret = g_utf8_to_utf16 (fstypename, -1, NULL, &len, NULL);
+ if (ret != NULL && len < fsbuffersize){
+ memcpy (fsbuffer, ret, len * sizeof (gunichar2));
+ fsbuffer [len] = 0;
+ status = TRUE;
+ }
+ if (ret != NULL)
+ g_free (ret);
+ g_free (fstypename);
+ }
+ g_free (utfpath);
+ return status;
+}
+#endif
+
+static gboolean
+LockFile (gpointer handle, guint32 offset_low, guint32 offset_high, guint32 length_low, guint32 length_high)
+{
+ MonoW32HandleFile *file_handle;
+ off_t offset, length;
+
+ if (!mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE, (gpointer *)&file_handle)) {
+ g_warning ("%s: error looking up file handle %p", __func__, handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ if (!(file_handle->fileaccess & GENERIC_READ) && !(file_handle->fileaccess & GENERIC_WRITE) && !(file_handle->fileaccess & GENERIC_ALL)) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
+ return FALSE;
+ }
+
+#ifdef HAVE_LARGE_FILE_SUPPORT
+ offset = ((gint64)offset_high << 32) | offset_low;
+ length = ((gint64)length_high << 32) | length_low;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Locking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
+#else
+ if (offset_high > 0 || length_high > 0) {
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+ offset = offset_low;
+ length = length_low;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Locking handle %p, offset %ld, length %ld", __func__, handle, offset, length);
+#endif
+
+ return _wapi_lock_file_region (GPOINTER_TO_UINT(handle), offset, length);
+}
+
+static gboolean
+UnlockFile (gpointer handle, guint32 offset_low, guint32 offset_high, guint32 length_low, guint32 length_high)
+{
+ MonoW32HandleFile *file_handle;
+ off_t offset, length;
+
+ if (!mono_w32handle_lookup (handle, MONO_W32HANDLE_FILE, (gpointer *)&file_handle)) {
+ g_warning ("%s: error looking up file handle %p", __func__, handle);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ if (!(file_handle->fileaccess & GENERIC_READ) && !(file_handle->fileaccess & GENERIC_WRITE) && !(file_handle->fileaccess & GENERIC_ALL)) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
+ return FALSE;
+ }
+
+#ifdef HAVE_LARGE_FILE_SUPPORT
+ offset = ((gint64)offset_high << 32) | offset_low;
+ length = ((gint64)length_high << 32) | length_low;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unlocking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
+#else
+ offset = offset_low;
+ length = length_low;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unlocking handle %p, offset %ld, length %ld", __func__, handle, offset, length);
+#endif
+
+ return _wapi_unlock_file_region (GPOINTER_TO_UINT(handle), offset, length);
+}
+
+void
+mono_w32file_init (void)
+{
+ mono_os_mutex_init (&stdhandle_mutex);
+ mono_os_mutex_init (&file_share_mutex);
+
+ mono_w32handle_register_ops (MONO_W32HANDLE_FILE, &_wapi_file_ops);
+ mono_w32handle_register_ops (MONO_W32HANDLE_CONSOLE, &_wapi_console_ops);
+ mono_w32handle_register_ops (MONO_W32HANDLE_FIND, &_wapi_find_ops);
+ mono_w32handle_register_ops (MONO_W32HANDLE_PIPE, &_wapi_pipe_ops);
+
+/* mono_w32handle_register_capabilities (MONO_W32HANDLE_FILE, */
+/* MONO_W32HANDLE_CAP_WAIT); */
+/* mono_w32handle_register_capabilities (MONO_W32HANDLE_CONSOLE, */
+/* MONO_W32HANDLE_CAP_WAIT); */
+
+ if (g_getenv ("MONO_STRICT_IO_EMULATION"))
+ lock_while_writing = TRUE;
+}
+
+void
+mono_w32file_cleanup (void)
+{
+ mono_os_mutex_destroy (&file_share_mutex);
+
+ if (file_share_table)
+ g_hash_table_destroy (file_share_table);
+}
+
+gboolean
+mono_w32file_move (gunichar2 *path, gunichar2 *dest, gint32 *error)
+{
+ gboolean result;
+
+ MONO_ENTER_GC_SAFE;
+
+ result = MoveFile (path, dest);
+ if (!result)
+ *error = mono_w32error_get_last ();
+
+ MONO_EXIT_GC_SAFE;
+
+ return result;
+}
+
+gboolean
+mono_w32file_copy (gunichar2 *path, gunichar2 *dest, gboolean overwrite, gint32 *error)
+{
+ gboolean result;
+
+ MONO_ENTER_GC_SAFE;
+
+ result = CopyFile (path, dest, !overwrite);
+ if (!result)
+ *error = mono_w32error_get_last ();
+
+ MONO_EXIT_GC_SAFE;
+
+ return result;
+}
+
+gboolean
+mono_w32file_replace (gunichar2 *destinationFileName, gunichar2 *sourceFileName, gunichar2 *destinationBackupFileName, guint32 flags, gint32 *error)
+{
+ gboolean result;
+
+ MONO_ENTER_GC_SAFE;
+
+ result = ReplaceFile (destinationFileName, sourceFileName, destinationBackupFileName, flags, NULL, NULL);
+ if (!result)
+ *error = mono_w32error_get_last ();
+
+ MONO_EXIT_GC_SAFE;
+
+ return result;
+}
+
+gint64
+mono_w32file_get_file_size (gpointer handle, gint32 *error)
+{
+ gint64 length;
+ guint32 length_hi;
+
+ MONO_ENTER_GC_SAFE;
+
+ length = GetFileSize (handle, &length_hi);
+ if(length==INVALID_FILE_SIZE) {
+ *error=mono_w32error_get_last ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+
+ return length | ((gint64)length_hi << 32);
+}
+
+gboolean
+mono_w32file_lock (gpointer handle, gint64 position, gint64 length, gint32 *error)
+{
+ gboolean result;
+
+ MONO_ENTER_GC_SAFE;
+
+ result = LockFile (handle, position & 0xFFFFFFFF, position >> 32, length & 0xFFFFFFFF, length >> 32);
+ if (!result)
+ *error = mono_w32error_get_last ();
+
+ MONO_EXIT_GC_SAFE;
+
+ return result;
+}
+
+gboolean
+mono_w32file_unlock (gpointer handle, gint64 position, gint64 length, gint32 *error)
+{
+ gboolean result;
+
+ MONO_ENTER_GC_SAFE;
+
+ result = UnlockFile (handle, position & 0xFFFFFFFF, position >> 32, length & 0xFFFFFFFF, length >> 32);
+ if (!result)
+ *error = mono_w32error_get_last ();
+
+ MONO_EXIT_GC_SAFE;
+
+ return result;
+}
+
+gpointer
+mono_w32file_get_console_input (void)
+{
+ gpointer handle;
+
+ MONO_ENTER_GC_SAFE;
+ handle = mono_w32file_get_std_handle (STD_INPUT_HANDLE);
+ MONO_EXIT_GC_SAFE;
+
+ return handle;
+}
+
+gpointer
+mono_w32file_get_console_output (void)
+{
+ gpointer handle;
+
+ MONO_ENTER_GC_SAFE;
+ handle = mono_w32file_get_std_handle (STD_OUTPUT_HANDLE);
+ MONO_EXIT_GC_SAFE;
+
+ return handle;
+}
+
+gpointer
+mono_w32file_get_console_error (void)
+{
+ gpointer handle;
+
+ MONO_ENTER_GC_SAFE;
+ handle = mono_w32file_get_std_handle (STD_ERROR_HANDLE);
+ MONO_EXIT_GC_SAFE;
+
+ return handle;
+}
--- /dev/null
+/*
+ * Copyright 2016 Microsoft
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+#ifndef _MONO_METADATA_W32FILE_WIN32_INTERNALS_H_
+#define _MONO_METADATA_W32FILE_WIN32_INTERNALS_H_
+
+#include <config.h>
+#include <glib.h>
+
+#ifdef HOST_WIN32
+#include "mono/metadata/w32file.h"
+#include "mono/metadata/w32file-internals.h"
+#endif /* HOST_WIN32 */
+#endif /* _MONO_METADATA_W32FILE_WIN32_INTERNALS_H_ */
--- /dev/null
+/*
+ * w32file-win32-uwp.c: UWP w32file support for Mono.
+ *
+ * Copyright 2016 Microsoft
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+*/
+#include <config.h>
+#include <glib.h>
+#include "mono/utils/mono-compiler.h"
+
+#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#include <windows.h>
+#include "mono/metadata/w32file-win32-internals.h"
+
+gboolean
+mono_w32file_move (gunichar2 *path, gunichar2 *dest, gint32 *error)
+{
+ gboolean result = FALSE;
+ MONO_ENTER_GC_SAFE;
+
+ result = MoveFileEx (path, dest, MOVEFILE_COPY_ALLOWED);
+ if (result == FALSE) {
+ *error=GetLastError ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return result;
+}
+
+gboolean
+mono_w32file_replace (gunichar2 *destinationFileName, gunichar2 *sourceFileName,
+ gunichar2 *destinationBackupFileName, guint32 flags, gint32 *error)
+{
+ gboolean result = FALSE;
+ MONO_ENTER_GC_SAFE;
+
+ result = ReplaceFile (destinationFileName, sourceFileName, destinationBackupFileName, flags, NULL, NULL);
+ if (result == FALSE) {
+ *error=GetLastError ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return result;
+}
+
+gboolean
+mono_w32file_copy (gunichar2 *path, gunichar2 *dest, gboolean overwrite, gint32 *error)
+{
+ gboolean result = FALSE;
+ COPYFILE2_EXTENDED_PARAMETERS copy_param = {0};
+
+ copy_param.dwSize = sizeof (COPYFILE2_EXTENDED_PARAMETERS);
+ copy_param.dwCopyFlags = (!overwrite) ? COPY_FILE_FAIL_IF_EXISTS : 0;
+
+ MONO_ENTER_GC_SAFE;
+
+ result = SUCCEEDED (CopyFile2 (path, dest, ©_param));
+ if (result == FALSE) {
+ *error=GetLastError ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return result;
+}
+
+gint64
+mono_w32file_get_file_size (HANDLE handle, gint32 *error)
+{
+ LARGE_INTEGER length;
+
+ MONO_ENTER_GC_SAFE;
+
+ if (!GetFileSizeEx (handle, &length)) {
+ *error=GetLastError ();
+ length.QuadPart = INVALID_FILE_SIZE;
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return length.QuadPart;
+}
+
+gboolean
+mono_w32file_lock (HANDLE handle, gint64 position, gint64 length, gint32 *error)
+{
+ gboolean result = FALSE;
+ MONO_ENTER_GC_SAFE;
+
+ result = LockFile (handle, position & 0xFFFFFFFF, position >> 32,
+ length & 0xFFFFFFFF, length >> 32);
+
+ if (result == FALSE) {
+ *error = GetLastError ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return result;
+}
+
+gboolean
+mono_w32file_unlock (HANDLE handle, gint64 position, gint64 length, gint32 *error)
+{
+ gboolean result = FALSE;
+ MONO_ENTER_GC_SAFE;
+
+ result = UnlockFile (handle, position & 0xFFFFFFFF, position >> 32,
+ length & 0xFFFFFFFF, length >> 32);
+
+ if (result == FALSE) {
+ *error = GetLastError ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return result;
+}
+
+HANDLE
+mono_w32file_get_console_output (void)
+{
+ MonoError mono_error;
+ mono_error_init (&mono_error);
+
+ g_unsupported_api ("GetStdHandle (STD_OUTPUT_HANDLE)");
+
+ mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetStdHandle (STD_OUTPUT_HANDLE)");
+ mono_error_set_pending_exception (&mono_error);
+
+ SetLastError (ERROR_NOT_SUPPORTED);
+
+ return INVALID_HANDLE_VALUE;
+}
+
+HANDLE
+mono_w32file_get_console_input (void)
+{
+ MonoError mono_error;
+ mono_error_init (&mono_error);
+
+ g_unsupported_api ("GetStdHandle (STD_INPUT_HANDLE)");
+
+ mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetStdHandle (STD_INPUT_HANDLE)");
+ mono_error_set_pending_exception (&mono_error);
+
+ SetLastError (ERROR_NOT_SUPPORTED);
+
+ return INVALID_HANDLE_VALUE;
+}
+
+HANDLE
+mono_w32file_get_console_error (void)
+{
+ MonoError mono_error;
+ mono_error_init (&mono_error);
+
+ g_unsupported_api ("GetStdHandle (STD_ERROR_HANDLE)");
+
+ mono_error_set_not_supported (&mono_error, G_UNSUPPORTED_API, "GetStdHandle (STD_ERROR_HANDLE)");
+ mono_error_set_pending_exception (&mono_error);
+
+ SetLastError (ERROR_NOT_SUPPORTED);
+
+ return INVALID_HANDLE_VALUE;
+}
+
+#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
+
+MONO_EMPTY_SOURCE_FILE (file_io_windows_uwp);
+#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
--- /dev/null
+/*
+ * w32file-win32.c: Windows File IO internal calls.
+ *
+ * Copyright 2016 Microsoft
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+#include <config.h>
+#include <glib.h>
+
+#include <winsock2.h>
+#include <windows.h>
+#include "mono/metadata/w32file-win32-internals.h"
+
+void
+mono_w32file_init (void)
+{
+}
+
+void
+mono_w32file_cleanup (void)
+{
+}
+
+gunichar2
+ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar ()
+{
+ return (gunichar2) ':'; /* colon */
+}
+
+gunichar2
+ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar ()
+{
+ return (gunichar2) '\\'; /* backslash */
+}
+
+gunichar2
+ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar ()
+{
+ return (gunichar2) '/'; /* forward slash */
+}
+
+gunichar2
+ves_icall_System_IO_MonoIO_get_PathSeparator ()
+{
+ return (gunichar2) ';'; /* semicolon */
+}
+
+void ves_icall_System_IO_MonoIO_DumpHandles (void)
+{
+ return;
+}
+
+gpointer
+mono_w32file_create(const gunichar2 *name, guint32 fileaccess, guint32 sharemode, guint32 createmode, guint32 attrs)
+{
+ return CreateFile (name, fileaccess, sharemode, NULL, createmode, attrs, NULL);
+}
+
+gboolean
+mono_w32file_close (gpointer handle)
+{
+ return CloseHandle (handle);
+}
+
+gboolean
+mono_w32file_delete (const gunichar2 *name)
+{
+ return DeleteFile (name);
+}
+
+gboolean
+mono_w32file_read(gpointer handle, gpointer buffer, guint32 numbytes, guint32 *bytesread)
+{
+ return ReadFile (handle, buffer, numbytes, bytesread, NULL);
+}
+
+gboolean
+mono_w32file_write (gpointer handle, gconstpointer buffer, guint32 numbytes, guint32 *byteswritten)
+{
+ return WriteFile (handle, buffer, numbytes, byteswritten, NULL);
+}
+
+gboolean
+mono_w32file_flush (gpointer handle)
+{
+ return FlushFileBuffers (handle);
+}
+
+gboolean
+mono_w32file_truncate (gpointer handle)
+{
+ return SetEndOfFile (handle);
+}
+
+guint32
+mono_w32file_seek (gpointer handle, gint32 movedistance, gint32 *highmovedistance, guint32 method)
+{
+ return SetFilePointer (handle, movedistance, highmovedistance, method);
+}
+
+gint
+mono_w32file_get_type (gpointer handle)
+{
+ return GetFileType (handle);
+}
+
+gboolean
+mono_w32file_get_times (gpointer handle, FILETIME *create_time, FILETIME *access_time, FILETIME *write_time)
+{
+ return GetFileTime (handle, create_time, access_time, write_time);
+}
+
+gboolean
+mono_w32file_set_times (gpointer handle, const FILETIME *create_time, const FILETIME *access_time, const FILETIME *write_time)
+{
+ return SetFileTime (handle, create_time, access_time, write_time);
+}
+
+gboolean
+mono_w32file_filetime_to_systemtime (const FILETIME *file_time, SYSTEMTIME *system_time)
+{
+ return FileTimeToSystemTime (file_time, system_time);
+}
+
+gpointer
+mono_w32file_find_first (const gunichar2 *pattern, WIN32_FIND_DATA *find_data)
+{
+ return FindFirstFile (pattern, find_data);
+}
+
+gboolean
+mono_w32file_find_next (gpointer handle, WIN32_FIND_DATA *find_data)
+{
+ return FindNextFile (handle, find_data);
+}
+
+gboolean
+mono_w32file_find_close (gpointer handle)
+{
+ return FindClose (handle);
+}
+
+gboolean
+mono_w32file_create_directory (const gunichar2 *name)
+{
+ return CreateDirectory (name, NULL);
+}
+
+gboolean
+mono_w32file_remove_directory (const gunichar2 *name)
+{
+ return RemoveDirectory (name);
+}
+
+guint32
+mono_w32file_get_attributes (const gunichar2 *name)
+{
+ return GetFileAttributes (name);
+}
+
+gboolean
+mono_w32file_get_attributes_ex (const gunichar2 *name, MonoIOStat *stat)
+{
+ gboolean result;
+ WIN32_FILE_ATTRIBUTE_DATA data;
+
+ result = GetFileAttributesEx (name, GetFileExInfoStandard, &data);
+ if (result) {
+ stat->attributes = data.dwFileAttributes;
+ stat->creation_time = (gint64) ((((guint64) data.ftCreationTime.dwHighDateTime) << 32) + data.ftCreationTime.dwLowDateTime);
+ stat->last_access_time = (gint64) ((((guint64) data.ftLastAccessTime.dwHighDateTime) << 32) + data.ftLastAccessTime.dwLowDateTime);
+ stat->last_write_time = (gint64) ((((guint64) data.ftLastWriteTime.dwHighDateTime) << 32) + data.ftLastWriteTime.dwLowDateTime);
+ stat->length = ((gint64)data.nFileSizeHigh << 32) | data.nFileSizeLow;
+ }
+
+ return result;
+}
+
+gboolean
+mono_w32file_set_attributes (const gunichar2 *name, guint32 attrs)
+{
+ return SetFileAttributes (name, attrs);
+}
+
+guint32
+mono_w32file_get_cwd (guint32 length, gunichar2 *buffer)
+{
+ return GetCurrentDirectory (length, buffer);
+}
+
+gboolean
+mono_w32file_set_cwd (const gunichar2 *path)
+{
+ return SetCurrentDirectory (path);
+}
+
+gboolean
+mono_w32file_create_pipe (gpointer *readpipe, gpointer *writepipe, guint32 size)
+{
+ SECURITY_ATTRIBUTES attr;
+ attr.nLength = sizeof(SECURITY_ATTRIBUTES);
+ attr.bInheritHandle = TRUE;
+ attr.lpSecurityDescriptor = NULL;
+ return CreatePipe (readpipe, writepipe, &attr, size);
+}
+
+gboolean
+mono_w32file_get_disk_free_space (const gunichar2 *path_name, guint64 *free_bytes_avail, guint64 *total_number_of_bytes, guint64 *total_number_of_free_bytes)
+{
+ gboolean result;
+ ULARGE_INTEGER *wapi_free_bytes_avail;
+ ULARGE_INTEGER *wapi_total_number_of_bytes;
+ ULARGE_INTEGER *wapi_total_number_of_free_bytes;
+
+ result = GetDiskFreeSpaceEx (path_name, wapi_free_bytes_avail, wapi_total_number_of_bytes, wapi_total_number_of_free_bytes);
+ if (result) {
+ if (free_bytes_avail)
+ *free_bytes_avail = wapi_free_bytes_avail->QuadPart;
+ if (total_number_of_bytes)
+ *total_number_of_bytes = wapi_total_number_of_bytes->QuadPart;
+ if (total_number_of_free_bytes)
+ *total_number_of_free_bytes = wapi_total_number_of_free_bytes->QuadPart;
+ }
+
+ return result;
+}
+
+gboolean
+mono_w32file_get_volume_information (const gunichar2 *path, gunichar2 *volumename, gint volumesize, gint *outserial, gint *maxcomp, gint *fsflags, gunichar2 *fsbuffer, gint fsbuffersize)
+{
+ return GetVolumeInformation (path, volumename, volumesize, outserial, maxcomp, fsflags, fsbuffer, fsbuffersize);
+}
+
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+
+gboolean
+mono_w32file_move (gunichar2 *path, gunichar2 *dest, gint32 *error)
+{
+ gboolean result;
+
+ MONO_ENTER_GC_SAFE;
+
+ result = MoveFile (path, dest);
+ if (!result)
+ *error = GetLastError ();
+
+ MONO_EXIT_GC_SAFE;
+
+ return result;
+}
+
+gboolean
+mono_w32file_replace (gunichar2 *destinationFileName, gunichar2 *sourceFileName, gunichar2 *destinationBackupFileName, guint32 flags, gint32 *error)
+{
+ gboolean result;
+
+ MONO_ENTER_GC_SAFE;
+
+ result = ReplaceFile (destinationFileName, sourceFileName, destinationBackupFileName, flags, NULL, NULL);
+ if (!result)
+ *error = GetLastError ();
+
+ MONO_EXIT_GC_SAFE;
+
+ return result;
+}
+
+gboolean
+mono_w32file_copy (gunichar2 *path, gunichar2 *dest, gboolean overwrite, gint32 *error)
+{
+ gboolean result;
+
+ MONO_ENTER_GC_SAFE;
+
+ result = CopyFile (path, dest, !overwrite);
+ if (!result)
+ *error = GetLastError ();
+
+ MONO_EXIT_GC_SAFE;
+
+ return result;
+}
+
+gboolean
+mono_w32file_lock (gpointer handle, gint64 position, gint64 length, gint32 *error)
+{
+ gboolean result;
+
+ MONO_ENTER_GC_SAFE;
+
+ result = LockFile (handle, position & 0xFFFFFFFF, position >> 32, length & 0xFFFFFFFF, length >> 32);
+ if (!result)
+ *error = GetLastError ();
+
+ MONO_EXIT_GC_SAFE;
+
+ return result;
+}
+
+gboolean
+mono_w32file_unlock (gpointer handle, gint64 position, gint64 length, gint32 *error)
+{
+ gboolean result;
+
+ MONO_ENTER_GC_SAFE;
+
+ result = UnlockFile (handle, position & 0xFFFFFFFF, position >> 32, length & 0xFFFFFFFF, length >> 32);
+ if (!result)
+ *error = GetLastError ();
+
+ MONO_EXIT_GC_SAFE;
+
+ return result;
+}
+
+HANDLE
+mono_w32file_get_console_input (void)
+{
+ return GetStdHandle (STD_INPUT_HANDLE);
+}
+
+HANDLE
+mono_w32file_get_console_output (void)
+{
+ return GetStdHandle (STD_OUTPUT_HANDLE);
+}
+
+HANDLE
+mono_w32file_get_console_error (void)
+{
+ return GetStdHandle (STD_ERROR_HANDLE);
+}
+
+gint64
+mono_w32file_get_file_size (gpointer handle, gint32 *error)
+{
+ gint64 length;
+ guint32 length_hi;
+
+ MONO_ENTER_GC_SAFE;
+
+ length = GetFileSize (handle, &length_hi);
+ if(length==INVALID_FILE_SIZE) {
+ *error=GetLastError ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+
+ return length | ((gint64)length_hi << 32);
+}
+
+guint32
+mono_w32file_get_drive_type (const gunichar2 *root_path_name)
+{
+ return GetDriveType (root_path_name);
+}
+
+gint32
+mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf)
+{
+ return GetLogicalDriveStrings (len, buf);
+}
+
+#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
--- /dev/null
+/*
+ * w32file.c: File IO internal calls
+ *
+ * Author:
+ * Dick Porter (dick@ximian.com)
+ * Gonzalo Paniagua Javier (gonzalo@ximian.com)
+ *
+ * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
+ * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
+ * Copyright 2012 Xamarin Inc (http://www.xamarin.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#include <config.h>
+
+#include <glib.h>
+#include <string.h>
+#include <errno.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#include <mono/metadata/object.h>
+#include <mono/metadata/w32file.h>
+#include <mono/metadata/w32error.h>
+#include <mono/metadata/w32file-internals.h>
+#include <mono/metadata/exception.h>
+#include <mono/metadata/appdomain.h>
+#include <mono/metadata/marshal.h>
+#include <mono/utils/strenc.h>
+#include <utils/mono-io-portability.h>
+#include <mono/metadata/w32handle.h>
+#include <mono/utils/w32api.h>
+
+#undef DEBUG
+
+/* conversion functions */
+
+static guint32 convert_mode(MonoFileMode mono_mode)
+{
+ guint32 mode;
+
+ switch(mono_mode) {
+ case FileMode_CreateNew:
+ mode=CREATE_NEW;
+ break;
+ case FileMode_Create:
+ mode=CREATE_ALWAYS;
+ break;
+ case FileMode_Open:
+ mode=OPEN_EXISTING;
+ break;
+ case FileMode_OpenOrCreate:
+ mode=OPEN_ALWAYS;
+ break;
+ case FileMode_Truncate:
+ mode=TRUNCATE_EXISTING;
+ break;
+ case FileMode_Append:
+ mode=OPEN_ALWAYS;
+ break;
+ default:
+ g_warning("System.IO.FileMode has unknown value 0x%x",
+ mono_mode);
+ /* Safe fallback */
+ mode=OPEN_EXISTING;
+ }
+
+ return(mode);
+}
+
+static guint32 convert_access(MonoFileAccess mono_access)
+{
+ guint32 access;
+
+ switch(mono_access) {
+ case FileAccess_Read:
+ access=GENERIC_READ;
+ break;
+ case FileAccess_Write:
+ access=GENERIC_WRITE;
+ break;
+ case FileAccess_ReadWrite:
+ access=GENERIC_READ|GENERIC_WRITE;
+ break;
+ default:
+ g_warning("System.IO.FileAccess has unknown value 0x%x",
+ mono_access);
+ /* Safe fallback */
+ access=GENERIC_READ;
+ }
+
+ return(access);
+}
+
+static guint32 convert_share(MonoFileShare mono_share)
+{
+ guint32 share = 0;
+
+ if (mono_share & FileShare_Read) {
+ share |= FILE_SHARE_READ;
+ }
+ if (mono_share & FileShare_Write) {
+ share |= FILE_SHARE_WRITE;
+ }
+ if (mono_share & FileShare_Delete) {
+ share |= FILE_SHARE_DELETE;
+ }
+
+ if (mono_share & ~(FileShare_Read|FileShare_Write|FileShare_Delete)) {
+ g_warning("System.IO.FileShare has unknown value 0x%x",
+ mono_share);
+ /* Safe fallback */
+ share=0;
+ }
+
+ return(share);
+}
+
+#if 0
+static guint32 convert_stdhandle(guint32 fd)
+{
+ guint32 stdhandle;
+
+ switch(fd) {
+ case 0:
+ stdhandle=STD_INPUT_HANDLE;
+ break;
+ case 1:
+ stdhandle=STD_OUTPUT_HANDLE;
+ break;
+ case 2:
+ stdhandle=STD_ERROR_HANDLE;
+ break;
+ default:
+ g_warning("unknown standard file descriptor %d", fd);
+ stdhandle=STD_INPUT_HANDLE;
+ }
+
+ return(stdhandle);
+}
+#endif
+
+static guint32 convert_seekorigin(MonoSeekOrigin origin)
+{
+ guint32 w32origin;
+
+ switch(origin) {
+ case SeekOrigin_Begin:
+ w32origin=FILE_BEGIN;
+ break;
+ case SeekOrigin_Current:
+ w32origin=FILE_CURRENT;
+ break;
+ case SeekOrigin_End:
+ w32origin=FILE_END;
+ break;
+ default:
+ g_warning("System.IO.SeekOrigin has unknown value 0x%x",
+ origin);
+ /* Safe fallback */
+ w32origin=FILE_CURRENT;
+ }
+
+ return(w32origin);
+}
+
+static gint64 convert_filetime (const FILETIME *filetime)
+{
+ return (gint64) ((((guint64) filetime->dwHighDateTime) << 32) + filetime->dwLowDateTime);
+}
+
+/* Managed file attributes have nearly but not quite the same values
+ * as the w32 equivalents.
+ */
+static guint32 convert_attrs(MonoFileAttributes attrs)
+{
+ if(attrs & FileAttributes_Encrypted) {
+ attrs = (MonoFileAttributes)(attrs | FILE_ATTRIBUTE_ENCRYPTED);
+ }
+
+ return(attrs);
+}
+
+/*
+ * On Win32, mono_w32file_get_attributes|_ex () seems to try opening the file,
+ * which might lead to sharing violation errors, whereas mono_w32file_find_first
+ * always succeeds. These 2 wrappers resort to mono_w32file_find_first if
+ * mono_w32file_get_attributes|_ex () has failed.
+ */
+static guint32
+get_file_attributes (const gunichar2 *path)
+{
+ guint32 res;
+ WIN32_FIND_DATA find_data;
+ HANDLE find_handle;
+ gint32 error;
+
+ res = mono_w32file_get_attributes (path);
+ if (res != -1)
+ return res;
+
+ error = mono_w32error_get_last ();
+
+ if (error != ERROR_SHARING_VIOLATION)
+ return res;
+
+ find_handle = mono_w32file_find_first (path, &find_data);
+
+ if (find_handle == INVALID_HANDLE_VALUE)
+ return res;
+
+ mono_w32file_find_close (find_handle);
+
+ return find_data.dwFileAttributes;
+}
+
+static gboolean
+get_file_attributes_ex (const gunichar2 *path, MonoIOStat *stat)
+{
+ gboolean res;
+ WIN32_FIND_DATA find_data;
+ HANDLE find_handle;
+ gint32 error;
+
+ res = mono_w32file_get_attributes_ex (path, stat);
+ if (res)
+ return TRUE;
+
+ error = mono_w32error_get_last ();
+ if (error != ERROR_SHARING_VIOLATION)
+ return FALSE;
+
+ find_handle = mono_w32file_find_first (path, &find_data);
+
+ if (find_handle == INVALID_HANDLE_VALUE)
+ return FALSE;
+
+ mono_w32file_find_close (find_handle);
+
+ stat->attributes = find_data.dwFileAttributes;
+ stat->creation_time = convert_filetime (&find_data.ftCreationTime);
+ stat->last_access_time = convert_filetime (&find_data.ftLastAccessTime);
+ stat->last_write_time = convert_filetime (&find_data.ftLastWriteTime);
+ stat->length = ((gint64)find_data.nFileSizeHigh << 32) | find_data.nFileSizeLow;
+ return TRUE;
+}
+
+/* System.IO.MonoIO internal calls */
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_CreateDirectory (MonoString *path, gint32 *error)
+{
+ gboolean ret;
+ MONO_ENTER_GC_SAFE;
+
+ *error=ERROR_SUCCESS;
+
+ ret=mono_w32file_create_directory (mono_string_chars (path));
+ if(ret==FALSE) {
+ *error=mono_w32error_get_last ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return(ret);
+}
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_RemoveDirectory (MonoString *path, gint32 *error)
+{
+ gboolean ret;
+ MONO_ENTER_GC_SAFE;
+
+ *error=ERROR_SUCCESS;
+
+ ret=mono_w32file_remove_directory (mono_string_chars (path));
+ if(ret==FALSE) {
+ *error=mono_w32error_get_last ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return(ret);
+}
+
+static gchar *
+get_search_dir (const gunichar2 *pattern)
+{
+ gchar *p;
+ gchar *result;
+
+ p = g_utf16_to_utf8 (pattern, -1, NULL, NULL, NULL);
+ result = g_path_get_dirname (p);
+ g_free (p);
+ return result;
+}
+
+static GPtrArray *
+get_filesystem_entries (const gunichar2 *path,
+ const gunichar2 *path_with_pattern,
+ gint attrs, gint mask,
+ gint32 *error)
+{
+ int i;
+ WIN32_FIND_DATA data;
+ HANDLE find_handle;
+ GPtrArray *names = NULL;
+ gchar *utf8_path = NULL, *utf8_result, *full_name;
+ gint32 attributes;
+
+ mask = convert_attrs ((MonoFileAttributes)mask);
+ attributes = get_file_attributes (path);
+ if (attributes != -1) {
+ if ((attributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
+ *error = ERROR_INVALID_NAME;
+ goto fail;
+ }
+ } else {
+ *error = mono_w32error_get_last ();
+ goto fail;
+ }
+
+ find_handle = mono_w32file_find_first (path_with_pattern, &data);
+ if (find_handle == INVALID_HANDLE_VALUE) {
+ gint32 find_error = mono_w32error_get_last ();
+
+ if (find_error == ERROR_FILE_NOT_FOUND || find_error == ERROR_NO_MORE_FILES) {
+ /* No files, so just return an empty array */
+ goto fail;
+ }
+
+ *error = find_error;
+ goto fail;
+ }
+
+ utf8_path = get_search_dir (path_with_pattern);
+ names = g_ptr_array_new ();
+
+ do {
+ if ((data.cFileName[0] == '.' && data.cFileName[1] == 0) ||
+ (data.cFileName[0] == '.' && data.cFileName[1] == '.' && data.cFileName[2] == 0)) {
+ continue;
+ }
+
+ if ((data.dwFileAttributes & mask) == attrs) {
+ utf8_result = g_utf16_to_utf8 (data.cFileName, -1, NULL, NULL, NULL);
+ if (utf8_result == NULL) {
+ continue;
+ }
+
+ full_name = g_build_filename (utf8_path, utf8_result, NULL);
+ g_ptr_array_add (names, full_name);
+
+ g_free (utf8_result);
+ }
+ } while(mono_w32file_find_next (find_handle, &data));
+
+ if (mono_w32file_find_close (find_handle) == FALSE) {
+ *error = mono_w32error_get_last ();
+ goto fail;
+ }
+
+ g_free (utf8_path);
+ return names;
+fail:
+ if (names) {
+ for (i = 0; i < names->len; i++)
+ g_free (g_ptr_array_index (names, i));
+ g_ptr_array_free (names, TRUE);
+ }
+ g_free (utf8_path);
+ return FALSE;
+}
+
+
+MonoArray *
+ves_icall_System_IO_MonoIO_GetFileSystemEntries (MonoString *path,
+ MonoString *path_with_pattern,
+ gint attrs, gint mask,
+ gint32 *ioerror)
+{
+ MonoError error;
+ MonoDomain *domain = mono_domain_get ();
+ MonoArray *result;
+ int i;
+ GPtrArray *names;
+
+ *ioerror = ERROR_SUCCESS;
+
+ MONO_ENTER_GC_SAFE;
+ names = get_filesystem_entries (mono_string_chars (path), mono_string_chars (path_with_pattern), attrs, mask, ioerror);
+ MONO_EXIT_GC_SAFE;
+
+ if (!names) {
+ // If there's no array and no error, then return an empty array.
+ if (*ioerror == ERROR_SUCCESS) {
+ MonoArray *arr = mono_array_new_checked (domain, mono_defaults.string_class, 0, &error);
+ mono_error_set_pending_exception (&error);
+ return arr;
+ }
+ return NULL;
+ }
+
+ result = mono_array_new_checked (domain, mono_defaults.string_class, names->len, &error);
+ if (mono_error_set_pending_exception (&error))
+ goto leave;
+ for (i = 0; i < names->len; i++) {
+ mono_array_setref (result, i, mono_string_new (domain, (const char *)g_ptr_array_index (names, i)));
+ g_free (g_ptr_array_index (names, i));
+ }
+leave:
+ g_ptr_array_free (names, TRUE);
+ return result;
+}
+
+typedef struct {
+ MonoDomain *domain;
+ gchar *utf8_path;
+ HANDLE find_handle;
+} IncrementalFind;
+
+static gboolean
+incremental_find_check_match (IncrementalFind *handle, WIN32_FIND_DATA *data, MonoString **result)
+{
+ gchar *utf8_result;
+ gchar *full_name;
+
+ if ((data->cFileName[0] == '.' && data->cFileName[1] == 0) || (data->cFileName[0] == '.' && data->cFileName[1] == '.' && data->cFileName[2] == 0))
+ return FALSE;
+
+ utf8_result = g_utf16_to_utf8 (data->cFileName, -1, NULL, NULL, NULL);
+ if (utf8_result == NULL)
+ return FALSE;
+
+ full_name = g_build_filename (handle->utf8_path, utf8_result, NULL);
+ g_free (utf8_result);
+ *result = mono_string_new (mono_domain_get (), full_name);
+ g_free (full_name);
+
+ return TRUE;
+}
+
+HANDLE
+ves_icall_System_IO_MonoIO_FindFirstFile (MonoString *path_with_pattern, MonoString **file_name, gint32 *file_attr, gint32 *ioerror)
+{
+ HANDLE hnd;
+ WIN32_FIND_DATA data;
+ MonoError error;
+
+ hnd = mono_w32file_find_first (mono_string_chars (path_with_pattern), &data);
+
+ if (hnd == INVALID_HANDLE_VALUE) {
+ *file_name = NULL;
+ *file_attr = 0;
+ *ioerror = mono_w32error_get_last ();
+ return hnd;
+ }
+
+ mono_gc_wbarrier_generic_store (file_name, (MonoObject*) mono_string_from_utf16_checked (data.cFileName, &error));
+ mono_error_set_pending_exception (&error);
+
+ *file_attr = data.dwFileAttributes;
+ *ioerror = ERROR_SUCCESS;
+
+ return hnd;
+}
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_FindNextFile (HANDLE hnd, MonoString **file_name, gint32 *file_attr, gint32 *ioerror)
+{
+ MonoBoolean res;
+ WIN32_FIND_DATA data;
+ MonoError error;
+
+ res = mono_w32file_find_next (hnd, &data);
+
+ if (res == FALSE) {
+ *file_name = NULL;
+ *file_attr = 0;
+ *ioerror = mono_w32error_get_last ();
+ return res;
+ }
+
+ mono_gc_wbarrier_generic_store (file_name, (MonoObject*) mono_string_from_utf16_checked (data.cFileName, &error));
+ mono_error_set_pending_exception (&error);
+
+ *file_attr = data.dwFileAttributes;
+ *ioerror = ERROR_SUCCESS;
+
+ return res;
+}
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_FindCloseFile (HANDLE hnd)
+{
+ return mono_w32file_find_close (hnd);
+}
+
+/* FIXME make gc suspendable */
+MonoString *
+ves_icall_System_IO_MonoIO_FindFirst (MonoString *path,
+ MonoString *path_with_pattern,
+ gint32 *result_attr, gint32 *ioerror,
+ gpointer *handle)
+{
+ MonoError error;
+ WIN32_FIND_DATA data;
+ HANDLE find_handle;
+ IncrementalFind *ifh;
+ MonoString *result;
+
+ *ioerror = ERROR_SUCCESS;
+
+ find_handle = mono_w32file_find_first (mono_string_chars (path_with_pattern), &data);
+
+ if (find_handle == INVALID_HANDLE_VALUE) {
+ gint32 find_error = mono_w32error_get_last ();
+ *handle = NULL;
+
+ if (find_error == ERROR_FILE_NOT_FOUND)
+ return NULL;
+
+ *ioerror = find_error;
+ return NULL;
+ }
+
+ ifh = g_new (IncrementalFind, 1);
+ ifh->find_handle = find_handle;
+ ifh->utf8_path = mono_string_to_utf8_checked (path, &error);
+ if (mono_error_set_pending_exception (&error)) {
+ MONO_ENTER_GC_SAFE;
+ mono_w32file_find_close (find_handle);
+ MONO_EXIT_GC_SAFE;
+ g_free (ifh);
+ return NULL;
+ }
+ ifh->domain = mono_domain_get ();
+ *handle = ifh;
+
+ while (incremental_find_check_match (ifh, &data, &result) == 0){
+ if (mono_w32file_find_next (find_handle, &data) == FALSE){
+ int e = mono_w32error_get_last ();
+ if (e != ERROR_NO_MORE_FILES)
+ *ioerror = e;
+ return NULL;
+ }
+ }
+ *result_attr = data.dwFileAttributes;
+
+ return result;
+}
+
+/* FIXME make gc suspendable */
+MonoString *
+ves_icall_System_IO_MonoIO_FindNext (gpointer handle, gint32 *result_attr, gint32 *error)
+{
+ IncrementalFind *ifh = (IncrementalFind *)handle;
+ WIN32_FIND_DATA data;
+ MonoString *result;
+
+ *error = ERROR_SUCCESS;
+ do {
+ if (mono_w32file_find_next (ifh->find_handle, &data) == FALSE){
+ int e = mono_w32error_get_last ();
+ if (e != ERROR_NO_MORE_FILES)
+ *error = e;
+ return NULL;
+ }
+ } while (incremental_find_check_match (ifh, &data, &result) == 0);
+
+ *result_attr = data.dwFileAttributes;
+ return result;
+}
+
+int
+ves_icall_System_IO_MonoIO_FindClose (gpointer handle)
+{
+ IncrementalFind *ifh = (IncrementalFind *)handle;
+ gint32 error;
+
+ MONO_ENTER_GC_SAFE;
+ if (mono_w32file_find_close (ifh->find_handle) == FALSE){
+ error = mono_w32error_get_last ();
+ } else
+ error = ERROR_SUCCESS;
+ g_free (ifh->utf8_path);
+ g_free (ifh);
+ MONO_EXIT_GC_SAFE;
+
+ return error;
+}
+
+MonoString *
+ves_icall_System_IO_MonoIO_GetCurrentDirectory (gint32 *io_error)
+{
+ MonoError error;
+ MonoString *result;
+ gunichar2 *buf;
+ int len, res_len;
+
+ len = MAX_PATH + 1; /*FIXME this is too smal under most unix systems.*/
+ buf = g_new (gunichar2, len);
+
+ mono_error_init (&error);
+ *io_error=ERROR_SUCCESS;
+ result = NULL;
+
+ res_len = mono_w32file_get_cwd (len, buf);
+ if (res_len > len) { /*buf is too small.*/
+ int old_res_len = res_len;
+ g_free (buf);
+ buf = g_new (gunichar2, res_len);
+ res_len = mono_w32file_get_cwd (res_len, buf) == old_res_len;
+ }
+
+ if (res_len) {
+ len = 0;
+ while (buf [len])
+ ++ len;
+
+ result = mono_string_new_utf16_checked (mono_domain_get (), buf, len, &error);
+ } else {
+ *io_error=mono_w32error_get_last ();
+ }
+
+ g_free (buf);
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_SetCurrentDirectory (MonoString *path,
+ gint32 *error)
+{
+ gboolean ret;
+
+ *error=ERROR_SUCCESS;
+
+ ret=mono_w32file_set_cwd (mono_string_chars (path));
+ if(ret==FALSE) {
+ *error=mono_w32error_get_last ();
+ }
+
+ return(ret);
+}
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_MoveFile (MonoString *path, MonoString *dest, gint32 *error)
+{
+ *error=ERROR_SUCCESS;
+ return mono_w32file_move (mono_string_chars (path), mono_string_chars (dest), error);
+}
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_ReplaceFile (MonoString *sourceFileName, MonoString *destinationFileName,
+ MonoString *destinationBackupFileName, MonoBoolean ignoreMetadataErrors,
+ gint32 *error)
+{
+ gunichar2 *utf16_sourceFileName = NULL, *utf16_destinationFileName = NULL, *utf16_destinationBackupFileName = NULL;
+ guint32 replaceFlags = REPLACEFILE_WRITE_THROUGH;
+
+ if (sourceFileName)
+ utf16_sourceFileName = mono_string_chars (sourceFileName);
+ if (destinationFileName)
+ utf16_destinationFileName = mono_string_chars (destinationFileName);
+ if (destinationBackupFileName)
+ utf16_destinationBackupFileName = mono_string_chars (destinationBackupFileName);
+
+ *error = ERROR_SUCCESS;
+ if (ignoreMetadataErrors)
+ replaceFlags |= REPLACEFILE_IGNORE_MERGE_ERRORS;
+
+ /* FIXME: source and destination file names must not be NULL, but apparently they might be! */
+ return mono_w32file_replace (utf16_destinationFileName, utf16_sourceFileName,
+ utf16_destinationBackupFileName, replaceFlags, error);
+}
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_CopyFile (MonoString *path, MonoString *dest,
+ MonoBoolean overwrite, gint32 *error)
+{
+ *error=ERROR_SUCCESS;
+ return mono_w32file_copy (mono_string_chars (path), mono_string_chars (dest), overwrite, error);
+}
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_DeleteFile (MonoString *path, gint32 *error)
+{
+ gboolean ret;
+ MONO_ENTER_GC_SAFE;
+
+ *error=ERROR_SUCCESS;
+
+ ret=mono_w32file_delete (mono_string_chars (path));
+ if(ret==FALSE) {
+ *error=mono_w32error_get_last ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return(ret);
+}
+
+gint32
+ves_icall_System_IO_MonoIO_GetFileAttributes (MonoString *path, gint32 *error)
+{
+ gint32 ret;
+ MONO_ENTER_GC_SAFE;
+
+ *error=ERROR_SUCCESS;
+
+ ret=get_file_attributes (mono_string_chars (path));
+
+ /*
+ * The definition of INVALID_FILE_ATTRIBUTES in the cygwin win32
+ * headers is wrong, hence this temporary workaround.
+ * See
+ * http://cygwin.com/ml/cygwin/2003-09/msg01771.html
+ */
+ if (ret==-1) {
+ /* if(ret==INVALID_FILE_ATTRIBUTES) { */
+ *error=mono_w32error_get_last ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return(ret);
+}
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_SetFileAttributes (MonoString *path, gint32 attrs,
+ gint32 *error)
+{
+ gboolean ret;
+ MONO_ENTER_GC_SAFE;
+
+ *error=ERROR_SUCCESS;
+
+ ret=mono_w32file_set_attributes (mono_string_chars (path),
+ convert_attrs ((MonoFileAttributes)attrs));
+ if(ret==FALSE) {
+ *error=mono_w32error_get_last ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return(ret);
+}
+
+gint32
+ves_icall_System_IO_MonoIO_GetFileType (HANDLE handle, gint32 *error)
+{
+ gboolean ret;
+ MONO_ENTER_GC_SAFE;
+
+ *error=ERROR_SUCCESS;
+
+ ret=mono_w32file_get_type (handle);
+ if(ret==FILE_TYPE_UNKNOWN) {
+ /* Not necessarily an error, but the caller will have
+ * to decide based on the error value.
+ */
+ *error=mono_w32error_get_last ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return(ret);
+}
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_GetFileStat (MonoString *path, MonoIOStat *stat, gint32 *error)
+{
+ gboolean result;
+ MONO_ENTER_GC_SAFE;
+
+ *error=ERROR_SUCCESS;
+
+ result = get_file_attributes_ex (mono_string_chars (path), stat);
+
+ if (!result) {
+ *error=mono_w32error_get_last ();
+ memset (stat, 0, sizeof (MonoIOStat));
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return result;
+}
+
+HANDLE
+ves_icall_System_IO_MonoIO_Open (MonoString *filename, gint32 mode,
+ gint32 access_mode, gint32 share, gint32 options,
+ gint32 *error)
+{
+ HANDLE ret;
+ int attributes, attrs;
+ gunichar2 *chars;
+ MONO_ENTER_GC_SAFE;
+
+ chars = mono_string_chars (filename);
+ *error=ERROR_SUCCESS;
+
+ if (options != 0){
+ if (options & FileOptions_Encrypted)
+ attributes = FILE_ATTRIBUTE_ENCRYPTED;
+ else
+ attributes = FILE_ATTRIBUTE_NORMAL;
+ if (options & FileOptions_DeleteOnClose)
+ attributes |= FILE_FLAG_DELETE_ON_CLOSE;
+ if (options & FileOptions_SequentialScan)
+ attributes |= FILE_FLAG_SEQUENTIAL_SCAN;
+ if (options & FileOptions_RandomAccess)
+ attributes |= FILE_FLAG_RANDOM_ACCESS;
+
+ if (options & FileOptions_Temporary)
+ attributes |= FILE_ATTRIBUTE_TEMPORARY;
+
+ if (options & FileOptions_WriteThrough)
+ attributes |= FILE_FLAG_WRITE_THROUGH;
+ } else
+ attributes = FILE_ATTRIBUTE_NORMAL;
+
+ /* If we're opening a directory we need to set the extra flag
+ */
+ attrs = get_file_attributes (chars);
+ if (attrs != INVALID_FILE_ATTRIBUTES) {
+ if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
+ attributes |= FILE_FLAG_BACKUP_SEMANTICS;
+ }
+ }
+
+ ret=mono_w32file_create (chars, convert_access ((MonoFileAccess)access_mode), convert_share ((MonoFileShare)share), convert_mode ((MonoFileMode)mode), attributes);
+ if(ret==INVALID_HANDLE_VALUE) {
+ *error=mono_w32error_get_last ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return(ret);
+}
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_Close (HANDLE handle, gint32 *error)
+{
+ gboolean ret;
+ MONO_ENTER_GC_SAFE;
+
+ *error=ERROR_SUCCESS;
+
+ ret=mono_w32file_close (handle);
+ if(ret==FALSE) {
+ *error=mono_w32error_get_last ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return(ret);
+}
+
+gint32
+ves_icall_System_IO_MonoIO_Read (HANDLE handle, MonoArray *dest,
+ gint32 dest_offset, gint32 count,
+ gint32 *error)
+{
+ guchar *buffer;
+ gboolean result;
+ guint32 n;
+
+ *error=ERROR_SUCCESS;
+
+ MONO_CHECK_ARG_NULL (dest, 0);
+
+ if (dest_offset > mono_array_length (dest) - count) {
+ mono_set_pending_exception (mono_get_exception_argument ("array", "array too small. numBytes/offset wrong."));
+ return 0;
+ }
+
+ buffer = mono_array_addr (dest, guchar, dest_offset);
+
+ MONO_ENTER_GC_SAFE;
+ result = mono_w32file_read (handle, buffer, count, &n);
+ MONO_EXIT_GC_SAFE;
+
+ if (!result) {
+ *error=mono_w32error_get_last ();
+ return -1;
+ }
+
+ return (gint32)n;
+}
+
+gint32
+ves_icall_System_IO_MonoIO_Write (HANDLE handle, MonoArray *src,
+ gint32 src_offset, gint32 count,
+ gint32 *error)
+{
+ guchar *buffer;
+ gboolean result;
+ guint32 n;
+
+ *error=ERROR_SUCCESS;
+
+ MONO_CHECK_ARG_NULL (src, 0);
+
+ if (src_offset > mono_array_length (src) - count) {
+ mono_set_pending_exception (mono_get_exception_argument ("array", "array too small. numBytes/offset wrong."));
+ return 0;
+ }
+
+ buffer = mono_array_addr (src, guchar, src_offset);
+ MONO_ENTER_GC_SAFE;
+ result = mono_w32file_write (handle, buffer, count, &n);
+ MONO_EXIT_GC_SAFE;
+
+ if (!result) {
+ *error=mono_w32error_get_last ();
+ return -1;
+ }
+
+ return (gint32)n;
+}
+
+gint64
+ves_icall_System_IO_MonoIO_Seek (HANDLE handle, gint64 offset, gint32 origin,
+ gint32 *error)
+{
+ gint32 offset_hi;
+ MONO_ENTER_GC_SAFE;
+
+ *error=ERROR_SUCCESS;
+
+ offset_hi = offset >> 32;
+ offset = mono_w32file_seek (handle, (gint32) (offset & 0xFFFFFFFF), &offset_hi,
+ convert_seekorigin ((MonoSeekOrigin)origin));
+
+ if(offset==INVALID_SET_FILE_POINTER) {
+ *error=mono_w32error_get_last ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return offset | ((gint64)offset_hi << 32);
+}
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_Flush (HANDLE handle, gint32 *error)
+{
+ gboolean ret;
+ MONO_ENTER_GC_SAFE;
+
+ *error=ERROR_SUCCESS;
+
+ ret=mono_w32file_flush (handle);
+ if(ret==FALSE) {
+ *error=mono_w32error_get_last ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return(ret);
+}
+
+gint64
+ves_icall_System_IO_MonoIO_GetLength (HANDLE handle, gint32 *error)
+{
+ *error=ERROR_SUCCESS;
+ return mono_w32file_get_file_size (handle, error);
+}
+
+/* FIXME make gc suspendable */
+MonoBoolean
+ves_icall_System_IO_MonoIO_SetLength (HANDLE handle, gint64 length,
+ gint32 *error)
+{
+ gint64 offset, offset_set;
+ gint32 offset_hi;
+ gint32 length_hi;
+ gboolean result;
+
+ *error=ERROR_SUCCESS;
+
+ /* save file pointer */
+
+ offset_hi = 0;
+ offset = mono_w32file_seek (handle, 0, &offset_hi, FILE_CURRENT);
+ if(offset==INVALID_SET_FILE_POINTER) {
+ *error=mono_w32error_get_last ();
+ return(FALSE);
+ }
+
+ /* extend or truncate */
+
+ length_hi = length >> 32;
+ offset_set=mono_w32file_seek (handle, length & 0xFFFFFFFF, &length_hi,
+ FILE_BEGIN);
+ if(offset_set==INVALID_SET_FILE_POINTER) {
+ *error=mono_w32error_get_last ();
+ return(FALSE);
+ }
+
+ result = mono_w32file_truncate (handle);
+ if(result==FALSE) {
+ *error=mono_w32error_get_last ();
+ return(FALSE);
+ }
+
+ /* restore file pointer */
+
+ offset_set=mono_w32file_seek (handle, offset & 0xFFFFFFFF, &offset_hi,
+ FILE_BEGIN);
+ if(offset_set==INVALID_SET_FILE_POINTER) {
+ *error=mono_w32error_get_last ();
+ return(FALSE);
+ }
+
+ return result;
+}
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_SetFileTime (HANDLE handle, gint64 creation_time,
+ gint64 last_access_time,
+ gint64 last_write_time, gint32 *error)
+{
+ gboolean ret;
+ const FILETIME *creation_filetime;
+ const FILETIME *access_filetime;
+ const FILETIME *write_filetime;
+ MONO_ENTER_GC_SAFE;
+
+ *error=ERROR_SUCCESS;
+
+ if (creation_time < 0)
+ creation_filetime = NULL;
+ else
+ creation_filetime = (FILETIME *)&creation_time;
+
+ if (last_access_time < 0)
+ access_filetime = NULL;
+ else
+ access_filetime = (FILETIME *)&last_access_time;
+
+ if (last_write_time < 0)
+ write_filetime = NULL;
+ else
+ write_filetime = (FILETIME *)&last_write_time;
+
+ ret=mono_w32file_set_times (handle, creation_filetime, access_filetime, write_filetime);
+ if(ret==FALSE) {
+ *error=mono_w32error_get_last ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+ return(ret);
+}
+
+HANDLE
+ves_icall_System_IO_MonoIO_get_ConsoleOutput ()
+{
+ return mono_w32file_get_console_output ();
+}
+
+HANDLE
+ves_icall_System_IO_MonoIO_get_ConsoleInput ()
+{
+ return mono_w32file_get_console_input ();
+}
+
+HANDLE
+ves_icall_System_IO_MonoIO_get_ConsoleError ()
+{
+ return mono_w32file_get_console_error ();
+}
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_CreatePipe (HANDLE *read_handle, HANDLE *write_handle, gint32 *error)
+{
+ gboolean ret;
+
+ MONO_ENTER_GC_SAFE;
+ ret=mono_w32file_create_pipe (read_handle, write_handle, 0);
+ MONO_EXIT_GC_SAFE;
+
+ if(ret==FALSE) {
+ *error = mono_w32error_get_last ();
+ /* FIXME: throw an exception? */
+ return(FALSE);
+ }
+
+ return(TRUE);
+}
+
+MonoBoolean
+ves_icall_System_IO_MonoIO_DuplicateHandle (HANDLE source_process_handle, HANDLE source_handle,
+ HANDLE target_process_handle, HANDLE *target_handle, gint32 access, gint32 inherit, gint32 options, gint32 *error)
+{
+ /* This is only used on Windows */
+ gboolean ret;
+
+ MONO_ENTER_GC_SAFE;
+#ifdef HOST_WIN32
+ ret=DuplicateHandle (source_process_handle, source_handle, target_process_handle, target_handle, access, inherit, options);
+#else
+ mono_w32handle_ref (source_handle);
+ *target_handle = source_handle;
+ ret = TRUE;
+#endif
+ MONO_EXIT_GC_SAFE;
+
+ if(ret==FALSE) {
+ *error = mono_w32error_get_last ();
+ /* FIXME: throw an exception? */
+ return(FALSE);
+ }
+
+ return(TRUE);
+}
+
+#ifndef HOST_WIN32
+gunichar2
+ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar ()
+{
+ return (gunichar2) '/'; /* forward slash */
+}
+
+gunichar2
+ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar ()
+{
+ return (gunichar2) '/'; /* forward slash */
+}
+
+gunichar2
+ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar ()
+{
+ if (IS_PORTABILITY_SET)
+ return (gunichar2) '\\'; /* backslash */
+ else
+ return (gunichar2) '/'; /* forward slash */
+}
+
+gunichar2
+ves_icall_System_IO_MonoIO_get_PathSeparator ()
+{
+ return (gunichar2) ':'; /* colon */
+}
+#endif /* !HOST_WIN32 */
+
+static const gunichar2
+invalid_path_chars [] = {
+#if defined (TARGET_WIN32)
+ 0x0022, /* double quote, which seems allowed in MS.NET but should be rejected */
+ 0x003c, /* less than */
+ 0x003e, /* greater than */
+ 0x007c, /* pipe */
+ 0x0008,
+ 0x0010,
+ 0x0011,
+ 0x0012,
+ 0x0014,
+ 0x0015,
+ 0x0016,
+ 0x0017,
+ 0x0018,
+ 0x0019,
+#endif
+ 0x0000 /* null */
+};
+
+MonoArray *
+ves_icall_System_IO_MonoIO_get_InvalidPathChars ()
+{
+ MonoError error;
+ MonoArray *chars;
+ MonoDomain *domain;
+ int i, n;
+
+ domain = mono_domain_get ();
+ n = sizeof (invalid_path_chars) / sizeof (gunichar2);
+ chars = mono_array_new_checked (domain, mono_defaults.char_class, n, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+
+ for (i = 0; i < n; ++ i)
+ mono_array_set (chars, gunichar2, i, invalid_path_chars [i]);
+
+ return chars;
+}
+
+void ves_icall_System_IO_MonoIO_Lock (HANDLE handle, gint64 position,
+ gint64 length, gint32 *error)
+{
+ *error=ERROR_SUCCESS;
+ mono_w32file_lock (handle, position, length, error);
+}
+
+void ves_icall_System_IO_MonoIO_Unlock (HANDLE handle, gint64 position,
+ gint64 length, gint32 *error)
+{
+ *error=ERROR_SUCCESS;
+ mono_w32file_unlock (handle, position, length, error);
+}
+
+//Support for io-layer free mmap'd files.
+
+#if defined (TARGET_IOS) || defined (TARGET_ANDROID)
+
+gint64
+mono_filesize_from_path (MonoString *string)
+{
+ MonoError error;
+ struct stat buf;
+ gint64 res;
+ char *path = mono_string_to_utf8_checked (string, &error);
+ mono_error_raise_exception (&error); /* OK to throw, external only without a good alternative */
+
+ MONO_ENTER_GC_SAFE;
+ if (stat (path, &buf) == -1)
+ res = -1;
+ else
+ res = (gint64)buf.st_size;
+
+ g_free (path);
+
+ MONO_EXIT_GC_SAFE;
+ return res;
+}
+
+gint64
+mono_filesize_from_fd (int fd)
+{
+ struct stat buf;
+ int res;
+
+ MONO_ENTER_GC_SAFE;
+ res = fstat (fd, &buf);
+ MONO_EXIT_GC_SAFE;
+
+ if (res == -1)
+ return (gint64)-1;
+
+ return (gint64)buf.st_size;
+}
+
+#endif
+
+#ifndef HOST_WIN32
+void mono_w32handle_dump (void);
+
+void ves_icall_System_IO_MonoIO_DumpHandles (void)
+{
+ mono_w32handle_dump ();
+}
+#endif /* !HOST_WIN32 */
--- /dev/null
+/*
+ * w32file.h: File IO internal calls
+ *
+ * Authors:
+ * Dick Porter (dick@ximian.com)
+ * Dan Lewis (dihlewis@yahoo.co.uk)
+ *
+ * (C) 2001 Ximian, Inc.
+ * Copyright 2012 Xamarin Inc (http://www.xamarin.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#ifndef _MONO_METADATA_W32FILE_H_
+#define _MONO_METADATA_W32FILE_H_
+
+#include <config.h>
+#include <glib.h>
+
+#include <mono/metadata/object-internals.h>
+#include <mono/utils/mono-compiler.h>
+
+G_BEGIN_DECLS
+
+/* This is a copy of System.IO.FileAccess */
+typedef enum {
+ FileAccess_Read=0x01,
+ FileAccess_Write=0x02,
+ FileAccess_ReadWrite=FileAccess_Read|FileAccess_Write
+} MonoFileAccess;
+
+/* This is a copy of System.IO.FileMode */
+typedef enum {
+ FileMode_CreateNew=1,
+ FileMode_Create=2,
+ FileMode_Open=3,
+ FileMode_OpenOrCreate=4,
+ FileMode_Truncate=5,
+ FileMode_Append=6
+} MonoFileMode;
+
+/* This is a copy of System.IO.FileShare */
+typedef enum {
+ FileShare_None=0x0,
+ FileShare_Read=0x01,
+ FileShare_Write=0x02,
+ FileShare_ReadWrite=FileShare_Read|FileShare_Write,
+ FileShare_Delete=0x04
+} MonoFileShare;
+
+/* This is a copy of System.IO.FileOptions */
+typedef enum {
+ FileOptions_None = 0,
+ FileOptions_Temporary = 1, // Internal. See note in System.IO.FileOptions
+ FileOptions_Encrypted = 0x4000,
+ FileOptions_DeleteOnClose = 0x4000000,
+ FileOptions_SequentialScan = 0x8000000,
+ FileOptions_RandomAccess = 0x10000000,
+ FileOptions_Asynchronous = 0x40000000,
+ FileOptions_WriteThrough = 0x80000000
+} MonoFileOptions;
+
+/* This is a copy of System.IO.SeekOrigin */
+typedef enum {
+ SeekOrigin_Begin=0,
+ SeekOrigin_Current=1,
+ SeekOrigin_End=2
+} MonoSeekOrigin;
+
+/* This is a copy of System.IO.MonoIOStat */
+typedef struct _MonoIOStat {
+ gint32 attributes;
+ gint64 length;
+ gint64 creation_time;
+ gint64 last_access_time;
+ gint64 last_write_time;
+} MonoIOStat;
+
+/* This is a copy of System.IO.FileAttributes */
+typedef enum {
+ FileAttributes_ReadOnly=0x00001,
+ FileAttributes_Hidden=0x00002,
+ FileAttributes_System=0x00004,
+ FileAttributes_Directory=0x00010,
+ FileAttributes_Archive=0x00020,
+ FileAttributes_Device=0x00040,
+ FileAttributes_Normal=0x00080,
+ FileAttributes_Temporary=0x00100,
+ FileAttributes_SparseFile=0x00200,
+ FileAttributes_ReparsePoint=0x00400,
+ FileAttributes_Compressed=0x00800,
+ FileAttributes_Offline=0x01000,
+ FileAttributes_NotContentIndexed=0x02000,
+ FileAttributes_Encrypted=0x04000,
+ FileAttributes_MonoExecutable= (int) 0x80000000
+} MonoFileAttributes;
+/* This is not used anymore
+typedef struct _MonoFSAsyncResult {
+ MonoObject obj;
+ MonoObject *state;
+ MonoBoolean completed;
+ MonoBoolean done;
+ MonoException *exc;
+ MonoWaitHandle *wait_handle;
+ MonoDelegate *async_callback;
+ MonoBoolean completed_synch;
+ MonoArray *buffer;
+ gint offset;
+ gint count;
+ gint original_count;
+ gint bytes_read;
+ MonoDelegate *real_cb;
+} MonoFSAsyncResult;
+*/
+/* System.IO.MonoIO */
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_CreateDirectory (MonoString *path, gint32 *error);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_RemoveDirectory (MonoString *path, gint32 *error);
+
+MonoArray *
+ves_icall_System_IO_MonoIO_GetFileSystemEntries (MonoString *path,
+ MonoString *path_with_pattern,
+ gint mask, gint attrs,
+ gint32 *error);
+
+extern gpointer
+ves_icall_System_IO_MonoIO_FindFirstFile (MonoString *path_with_pattern,
+ MonoString **file_name,
+ gint32 *file_attr,
+ gint32 *ioerror);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_FindNextFile (gpointer hnd,
+ MonoString **file_name,
+ gint32 *file_attr,
+ gint32 *ioerror);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_FindCloseFile (gpointer hnd);
+
+extern MonoString *
+ves_icall_System_IO_MonoIO_FindFirst (MonoString *path,
+ MonoString *path_with_pattern,
+ gint32 *result_mask,
+ gint32 *error,
+ gpointer *handle);
+extern MonoString *
+ves_icall_System_IO_MonoIO_FindNext (gpointer handle, gint32 *result_mask, gint32 *error);
+
+extern int
+ves_icall_System_IO_MonoIO_FindClose (gpointer handle);
+
+extern MonoString *
+ves_icall_System_IO_MonoIO_GetCurrentDirectory (gint32 *error);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_SetCurrentDirectory (MonoString *path,
+ gint32 *error);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_MoveFile (MonoString *path, MonoString *dest,
+ gint32 *error);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_CopyFile (MonoString *path, MonoString *dest,
+ MonoBoolean overwrite, gint32 *error);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_DeleteFile (MonoString *path, gint32 *error);
+
+extern gint32
+ves_icall_System_IO_MonoIO_GetFileAttributes (MonoString *path, gint32 *error);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_SetFileAttributes (MonoString *path, gint32 attrs,
+ gint32 *error);
+
+extern gint32
+ves_icall_System_IO_MonoIO_GetFileType (gpointer handle, gint32 *error);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_GetFileStat (MonoString *path, MonoIOStat *stat,
+ gint32 *error);
+
+extern gpointer
+ves_icall_System_IO_MonoIO_Open (MonoString *filename, gint32 mode,
+ gint32 access_mode, gint32 share, gint32 options,
+ gint32 *error);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_Close (gpointer handle, gint32 *error);
+
+extern gint32
+ves_icall_System_IO_MonoIO_Read (gpointer handle, MonoArray *dest,
+ gint32 dest_offset, gint32 count,
+ gint32 *error);
+
+extern gint32
+ves_icall_System_IO_MonoIO_Write (gpointer handle, MonoArray *src,
+ gint32 src_offset, gint32 count,
+ gint32 *error);
+
+extern gint64
+ves_icall_System_IO_MonoIO_Seek (gpointer handle, gint64 offset, gint32 origin,
+ gint32 *error);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_Flush (gpointer handle, gint32 *error);
+
+extern gint64
+ves_icall_System_IO_MonoIO_GetLength (gpointer handle, gint32 *error);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_SetLength (gpointer handle, gint64 length,
+ gint32 *error);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_SetFileTime (gpointer handle, gint64 creation_time,
+ gint64 last_access_time,
+ gint64 last_write_time, gint32 *error);
+
+extern gpointer
+ves_icall_System_IO_MonoIO_get_ConsoleOutput (void);
+
+extern gpointer
+ves_icall_System_IO_MonoIO_get_ConsoleInput (void);
+
+extern gpointer
+ves_icall_System_IO_MonoIO_get_ConsoleError (void);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_CreatePipe (gpointer *read_handle, gpointer *write_handle, gint32 *error);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_DuplicateHandle (gpointer source_process_handle, gpointer source_handle,
+ gpointer target_process_handle, gpointer *target_handle, gint32 access, gint32 inherit, gint32 options, gint32 *error);
+
+extern gunichar2
+ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar (void);
+
+extern gunichar2
+ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar (void);
+
+extern gunichar2
+ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar (void);
+
+extern gunichar2
+ves_icall_System_IO_MonoIO_get_PathSeparator (void);
+
+extern MonoArray *
+ves_icall_System_IO_MonoIO_get_InvalidPathChars (void);
+
+extern void ves_icall_System_IO_MonoIO_Lock (gpointer handle, gint64 position,
+ gint64 length, gint32 *error);
+extern void ves_icall_System_IO_MonoIO_Unlock (gpointer handle, gint64 position,
+ gint64 length, gint32 *error);
+
+extern MonoBoolean
+ves_icall_System_IO_MonoIO_ReplaceFile (MonoString *sourceFileName, MonoString *destinationFileName,
+ MonoString *destinationBackupFileName, MonoBoolean ignoreMetadataErrors,
+ gint32 *error);
+
+#if defined (TARGET_IOS) || defined (TARGET_ANDROID)
+
+MONO_RT_EXTERNAL_ONLY
+extern gint64
+mono_filesize_from_path (MonoString *path);
+
+extern gint64
+mono_filesize_from_fd (int fd);
+
+#endif
+
+void
+ves_icall_System_IO_MonoIO_DumpHandles (void);
+
+#if !defined(HOST_WIN32)
+
+#define GENERIC_READ 0x80000000
+#define GENERIC_WRITE 0x40000000
+#define GENERIC_EXECUTE 0x20000000
+#define GENERIC_ALL 0x10000000
+
+#define FILE_SHARE_READ 0x00000001
+#define FILE_SHARE_WRITE 0x00000002
+#define FILE_SHARE_DELETE 0x00000004
+
+#define CREATE_NEW 1
+#define CREATE_ALWAYS 2
+#define OPEN_EXISTING 3
+#define OPEN_ALWAYS 4
+#define TRUNCATE_EXISTING 5
+
+#define FILE_ATTRIBUTE_READONLY 0x00000001
+#define FILE_ATTRIBUTE_HIDDEN 0x00000002
+#define FILE_ATTRIBUTE_SYSTEM 0x00000004
+#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
+#define FILE_ATTRIBUTE_ARCHIVE 0x00000020
+#define FILE_ATTRIBUTE_ENCRYPTED 0x00000040
+#define FILE_ATTRIBUTE_NORMAL 0x00000080
+#define FILE_ATTRIBUTE_TEMPORARY 0x00000100
+#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
+#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
+#define FILE_ATTRIBUTE_COMPRESSED 0x00000800
+#define FILE_ATTRIBUTE_OFFLINE 0x00001000
+#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
+#define FILE_FLAG_OPEN_NO_RECALL 0x00100000
+#define FILE_FLAG_OPEN_REPARSE_POINT 0x00200000
+#define FILE_FLAG_POSIX_SEMANTICS 0x01000000
+#define FILE_FLAG_BACKUP_SEMANTICS 0x02000000
+#define FILE_FLAG_DELETE_ON_CLOSE 0x04000000
+#define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000
+#define FILE_FLAG_RANDOM_ACCESS 0x10000000
+#define FILE_FLAG_NO_BUFFERING 0x20000000
+#define FILE_FLAG_OVERLAPPED 0x40000000
+#define FILE_FLAG_WRITE_THROUGH 0x80000000
+
+#define REPLACEFILE_WRITE_THROUGH 0x00000001
+#define REPLACEFILE_IGNORE_MERGE_ERRORS 0x00000002
+
+#define MAX_PATH 260
+
+#define INVALID_SET_FILE_POINTER ((guint32) 0xFFFFFFFF)
+#define INVALID_FILE_SIZE ((guint32) 0xFFFFFFFF)
+#define INVALID_FILE_ATTRIBUTES ((guint32) 0xFFFFFFFF)
+
+#define FILE_TYPE_UNKNOWN 0x0000
+#define FILE_TYPE_DISK 0x0001
+#define FILE_TYPE_CHAR 0x0002
+#define FILE_TYPE_PIPE 0x0003
+#define FILE_TYPE_REMOTE 0x8000
+
+#define FILE_BEGIN 0
+#define FILE_CURRENT 1
+#define FILE_END 2
+
+#define DRIVE_UNKNOWN 0
+#define DRIVE_NO_ROOT_DIR 1
+#define DRIVE_REMOVABLE 2
+#define DRIVE_FIXED 3
+#define DRIVE_REMOTE 4
+#define DRIVE_CDROM 5
+#define DRIVE_RAMDISK 6
+
+typedef struct {
+ guint16 wYear;
+ guint16 wMonth;
+ guint16 wDayOfWeek;
+ guint16 wDay;
+ guint16 wHour;
+ guint16 wMinute;
+ guint16 wSecond;
+ guint16 wMilliseconds;
+} SYSTEMTIME;
+
+typedef struct {
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+ guint32 dwHighDateTime;
+ guint32 dwLowDateTime;
+#else
+ guint32 dwLowDateTime;
+ guint32 dwHighDateTime;
+#endif
+} FILETIME;
+
+typedef struct {
+ guint32 dwFileAttributes;
+ FILETIME ftCreationTime;
+ FILETIME ftLastAccessTime;
+ FILETIME ftLastWriteTime;
+ guint32 nFileSizeHigh;
+ guint32 nFileSizeLow;
+ guint32 dwReserved0;
+ guint32 dwReserved1;
+ gunichar2 cFileName [MAX_PATH];
+ gunichar2 cAlternateFileName [14];
+} WIN32_FIND_DATA;
+
+#endif /* !defined(HOST_WIN32) */
+
+void
+mono_w32file_init (void);
+
+void
+mono_w32file_cleanup (void);
+
+gpointer
+mono_w32file_create(const gunichar2 *name, guint32 fileaccess, guint32 sharemode, guint32 createmode, guint32 attrs);
+
+gboolean
+mono_w32file_close (gpointer handle);
+
+gboolean
+mono_w32file_delete (const gunichar2 *name);
+
+gboolean
+mono_w32file_read (gpointer handle, gpointer buffer, guint32 numbytes, guint32 *bytesread);
+
+gboolean
+mono_w32file_write (gpointer handle, gconstpointer buffer, guint32 numbytes, guint32 *byteswritten);
+
+gboolean
+mono_w32file_flush (gpointer handle);
+
+gboolean
+mono_w32file_truncate (gpointer handle);
+
+guint32
+mono_w32file_seek (gpointer handle, gint32 movedistance, gint32 *highmovedistance, guint32 method);
+
+gboolean
+mono_w32file_move (gunichar2 *path, gunichar2 *dest, gint32 *error);
+
+gboolean
+mono_w32file_copy (gunichar2 *path, gunichar2 *dest, gboolean overwrite, gint32 *error);
+
+gboolean
+mono_w32file_lock (gpointer handle, gint64 position, gint64 length, gint32 *error);
+
+gboolean
+mono_w32file_replace (gunichar2 *destinationFileName, gunichar2 *sourceFileName, gunichar2 *destinationBackupFileName, guint32 flags, gint32 *error);
+
+gboolean
+mono_w32file_unlock (gpointer handle, gint64 position, gint64 length, gint32 *error);
+
+gpointer
+mono_w32file_get_console_output (void);
+
+gpointer
+mono_w32file_get_console_error (void);
+
+gpointer
+mono_w32file_get_console_input (void);
+
+gint64
+mono_w32file_get_file_size (gpointer handle, gint32 *error);
+
+gint
+mono_w32file_get_type (gpointer handle);
+
+gboolean
+mono_w32file_get_times (gpointer handle, FILETIME *create_time, FILETIME *access_time, FILETIME *write_time);
+
+gboolean
+mono_w32file_set_times (gpointer handle, const FILETIME *create_time, const FILETIME *access_time, const FILETIME *write_time);
+
+gboolean
+mono_w32file_filetime_to_systemtime (const FILETIME *file_time, SYSTEMTIME *system_time);
+
+gpointer
+mono_w32file_find_first (const gunichar2 *pattern, WIN32_FIND_DATA *find_data);
+
+gboolean
+mono_w32file_find_next (gpointer handle, WIN32_FIND_DATA *find_data);
+
+gboolean
+mono_w32file_find_close (gpointer handle);
+
+gboolean
+mono_w32file_create_directory (const gunichar2 *name);
+
+gboolean
+mono_w32file_remove_directory (const gunichar2 *name);
+
+guint32
+mono_w32file_get_attributes (const gunichar2 *name);
+
+gboolean
+mono_w32file_get_attributes_ex (const gunichar2 *name, MonoIOStat *stat);
+
+gboolean
+mono_w32file_set_attributes (const gunichar2 *name, guint32 attrs);
+
+guint32
+mono_w32file_get_cwd (guint32 length, gunichar2 *buffer);
+
+gboolean
+mono_w32file_set_cwd (const gunichar2 *path);
+
+gboolean
+mono_w32file_create_pipe (gpointer *readpipe, gpointer *writepipe, guint32 size);
+
+gint32
+mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf);
+
+gboolean
+mono_w32file_get_disk_free_space (const gunichar2 *path_name, guint64 *free_bytes_avail, guint64 *total_number_of_bytes, guint64 *total_number_of_free_bytes);
+
+guint32
+mono_w32file_get_drive_type (const gunichar2 *root_path_name);
+
+gboolean
+mono_w32file_get_volume_information (const gunichar2 *path, gunichar2 *volumename, gint volumesize, gint *outserial, gint *maxcomp, gint *fsflags, gunichar2 *fsbuffer, gint fsbuffersize);
+
+G_END_DECLS
+
+#endif /* _MONO_METADATA_W32FILE_H_ */
#include "w32mutex.h"
#include "w32semaphore.h"
#include "w32event.h"
-#include "mono/io-layer/io-layer.h"
#include "mono/utils/mono-logger-internals.h"
#include "mono/utils/mono-coop-mutex.h"
mono_w32handle_unref (handle);
}
-/*
- * wapi_init:
- *
- * Initialize the io-layer.
- */
void
mono_w32handle_init (void)
{
return(GUINT_TO_POINTER(fd));
}
+gboolean
+mono_w32handle_close (gpointer handle)
+{
+ if (handle == INVALID_HANDLE_VALUE)
+ return FALSE;
+ if (handle == (gpointer) 0 && mono_w32handle_get_type (handle) != MONO_W32HANDLE_CONSOLE) {
+ /* Problem: because we map file descriptors to the
+ * same-numbered handle we can't tell the difference
+ * between a bogus handle and the handle to stdin.
+ * Assume that it's the console handle if that handle
+ * exists... */
+ return FALSE;
+ }
+
+ mono_w32handle_unref (handle);
+ return TRUE;
+}
+
gboolean
mono_w32handle_lookup (gpointer handle, MonoW32HandleType type,
gpointer *handle_specific)
gpointer
mono_w32handle_new_fd (MonoW32HandleType type, int fd, gpointer handle_specific);
+gboolean
+mono_w32handle_close (gpointer handle);
+
MonoW32HandleType
mono_w32handle_get_type (gpointer handle);
#include <pthread.h>
+#include "w32error.h"
#include "w32handle-namespace.h"
-#include "mono/io-layer/io-layer.h"
#include "mono/metadata/object-internals.h"
#include "mono/utils/mono-logger-internals.h"
#include "mono/utils/mono-threads.h"
#include "mono/metadata/w32handle.h"
+#define MAX_PATH 260
+
typedef struct {
MonoNativeThreadId tid;
guint32 recursion;
if (handle == INVALID_HANDLE_VALUE) {
g_warning ("%s: error creating %s handle",
__func__, mono_w32handle_get_typename (type));
- SetLastError (ERROR_GEN_FAILURE);
+ mono_w32error_set_last (ERROR_GEN_FAILURE);
return NULL;
}
/* w32 seems to guarantee that opening named objects can't race each other */
mono_w32handle_namespace_lock ();
- utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
+ glong utf8_len = 0;
+ utf8_name = g_utf16_to_utf8 (name, -1, NULL, &utf8_len, NULL);
handle = mono_w32handle_namespace_search_handle (MONO_W32HANDLE_NAMEDMUTEX, utf8_name);
if (handle == INVALID_HANDLE_VALUE) {
/* The name has already been used for a different object. */
handle = NULL;
- SetLastError (ERROR_INVALID_HANDLE);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
} else if (handle) {
/* Not an error, but this is how the caller is informed that the mutex wasn't freshly created */
- SetLastError (ERROR_ALREADY_EXISTS);
+ mono_w32error_set_last (ERROR_ALREADY_EXISTS);
/* mono_w32handle_namespace_search_handle already adds a ref to the handle */
} else {
/* A new named mutex */
MonoW32HandleNamedMutex namedmutex_handle;
- strncpy (&namedmutex_handle.sharedns.name [0], utf8_name, MAX_PATH);
- namedmutex_handle.sharedns.name [MAX_PATH] = '\0';
+ size_t len = utf8_len < MAX_PATH ? utf8_len : MAX_PATH;
+ memcpy (&namedmutex_handle.sharedns.name [0], utf8_name, len);
+ namedmutex_handle.sharedns.name [len] = '\0';
handle = mutex_handle_create ((MonoW32HandleMutex*) &namedmutex_handle, MONO_W32HANDLE_NAMEDMUTEX, owned);
}
/* Need to blow away any old errors here, because code tests
* for ERROR_ALREADY_EXISTS on success (!) to see if a mutex
* was freshly created */
- SetLastError (ERROR_SUCCESS);
+ mono_w32error_set_last (ERROR_SUCCESS);
if (!name) {
mutex = mutex_create (owned);
} else {
mutex = namedmutex_create (owned, mono_string_chars (name));
- if (GetLastError () == ERROR_ALREADY_EXISTS)
+ if (mono_w32error_get_last () == ERROR_ALREADY_EXISTS)
*created = FALSE;
}
gboolean ret;
if (handle == NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
return FALSE;
}
case MONO_W32HANDLE_NAMEDMUTEX:
break;
default:
- SetLastError (ERROR_INVALID_HANDLE);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
return FALSE;
}
gint mib [6];
gsize size;
struct kinfo_proc *pi;
- gchar *ret;
+ gchar *ret = NULL;
#if defined(__FreeBSD__)
mib [0] = CTL_KERN;
#include <mono/metadata/w32process.h>
#include <mono/metadata/w32process-internals.h>
#include <mono/metadata/w32process-unix-internals.h>
+#include <mono/metadata/w32error.h>
#include <mono/metadata/class.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/object.h>
#include <mono/metadata/metadata.h>
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/exception.h>
-#include <mono/io-layer/io-layer.h>
#include <mono/metadata/w32handle.h>
+#include <mono/metadata/w32file.h>
#include <mono/utils/mono-membar.h>
#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/strenc.h>
#include <mono/utils/mono-time.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/strenc.h>
+#include <mono/utils/mono-io-portability.h>
+#include <mono/utils/w32api.h>
#ifndef MAXPATHLEN
#define MAXPATHLEN 242
static Process *processes;
static mono_mutex_t processes_mutex;
+static pid_t current_pid;
static gpointer current_process;
static const gunichar2 utf16_space_bytes [2] = { 0x20, 0 };
mono_w32handle_register_capabilities (MONO_W32HANDLE_PROCESS,
(MonoW32HandleCapability)(MONO_W32HANDLE_CAP_WAIT | MONO_W32HANDLE_CAP_SPECIAL_WAIT));
+ current_pid = getpid ();
+
memset (&process_handle, 0, sizeof (process_handle));
- process_handle.pid = wapi_getpid ();
+ process_handle.pid = current_pid;
process_set_defaults (&process_handle);
process_set_name (&process_handle);
res = mono_w32handle_lookup (handle, MONO_W32HANDLE_PROCESS, (gpointer*) &process_handle);
if (!res) {
- SetLastError (ERROR_INVALID_HANDLE);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
return 0;
}
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find pid %d", __func__, pid);
- SetLastError (ERROR_PROC_NOT_FOUND);
+ mono_w32error_set_last (ERROR_PROC_NOT_FOUND);
return NULL;
}
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL",
__func__);
- SetLastError (ERROR_PATH_NOT_FOUND);
+ mono_w32error_set_last (ERROR_PATH_NOT_FOUND);
goto free_strings;
}
if (args == NULL) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
- SetLastError (ERROR_PATH_NOT_FOUND);
+ mono_w32error_set_last (ERROR_PATH_NOT_FOUND);
goto free_strings;
}
}
if (dir == NULL) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
- SetLastError (ERROR_PATH_NOT_FOUND);
+ mono_w32error_set_last (ERROR_PATH_NOT_FOUND);
goto free_strings;
}
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Couldn't find executable %s",
__func__, prog);
g_free (unquoted);
- SetLastError (ERROR_FILE_NOT_FOUND);
+ mono_w32error_set_last (ERROR_FILE_NOT_FOUND);
goto free_strings;
}
} else {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Couldn't find executable %s",
__func__, prog);
g_free (unquoted);
- SetLastError (ERROR_FILE_NOT_FOUND);
+ mono_w32error_set_last (ERROR_FILE_NOT_FOUND);
goto free_strings;
}
}
/* Give up */
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Couldn't find what to exec", __func__);
- SetLastError (ERROR_PATH_NOT_FOUND);
+ mono_w32error_set_last (ERROR_PATH_NOT_FOUND);
goto free_strings;
}
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Couldn't find executable %s",
__func__, token);
g_free (token);
- SetLastError (ERROR_FILE_NOT_FOUND);
+ mono_w32error_set_last (ERROR_FILE_NOT_FOUND);
goto free_strings;
}
} else {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Couldn't find executable %s", __func__, token);
g_free (token);
- SetLastError (ERROR_FILE_NOT_FOUND);
+ mono_w32error_set_last (ERROR_FILE_NOT_FOUND);
goto free_strings;
}
}
} else {
if (!is_executable (prog)) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Executable permisson not set on %s", __func__, prog);
- SetLastError (ERROR_ACCESS_DENIED);
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
goto free_strings;
}
}
out_fd = GPOINTER_TO_UINT (startup_handles->output);
err_fd = GPOINTER_TO_UINT (startup_handles->error);
} else {
- in_fd = GPOINTER_TO_UINT (GetStdHandle (STD_INPUT_HANDLE));
- out_fd = GPOINTER_TO_UINT (GetStdHandle (STD_OUTPUT_HANDLE));
- err_fd = GPOINTER_TO_UINT (GetStdHandle (STD_ERROR_HANDLE));
+ in_fd = GPOINTER_TO_UINT (mono_w32file_get_console_input ());
+ out_fd = GPOINTER_TO_UINT (mono_w32file_get_console_output ());
+ err_fd = GPOINTER_TO_UINT (mono_w32file_get_console_error ());
}
/*
switch (pid = fork ()) {
case -1: /* Error */ {
- SetLastError (ERROR_OUTOFMEMORY);
+ mono_w32error_set_last (ERROR_OUTOFMEMORY);
ret = FALSE;
break;
}
mono_os_sem_destroy (&process->exit_sem);
g_free (process);
- SetLastError (ERROR_OUTOFMEMORY);
+ mono_w32error_set_last (ERROR_OUTOFMEMORY);
ret = FALSE;
break;
}
return ret;
#else
- SetLastError (ERROR_NOT_SUPPORTED);
+ mono_w32error_set_last (ERROR_NOT_SUPPORTED);
return FALSE;
#endif // defined (HAVE_FORK) && defined (HAVE_EXECVE)
}
*/
args = utf16_concat (utf16_quote, lpFile, utf16_quote, lpParameters == NULL ? NULL : utf16_space, lpParameters, NULL);
if (args == NULL) {
- SetLastError (ERROR_INVALID_DATA);
+ mono_w32error_set_last (ERROR_INVALID_DATA);
ret = FALSE;
goto done;
}
ret = process_create (NULL, args, lpDirectory, NULL, process_info);
g_free (args);
- if (!ret && GetLastError () == ERROR_OUTOFMEMORY)
+ if (!ret && mono_w32error_get_last () == ERROR_OUTOFMEMORY)
goto done;
if (!ret) {
args = utf16_concat (handler_utf16, utf16_space, utf16_quote, lpFile, utf16_quote,
lpParameters == NULL ? NULL : utf16_space, lpParameters, NULL);
if (args == NULL) {
- SetLastError (ERROR_INVALID_DATA);
+ mono_w32error_set_last (ERROR_INVALID_DATA);
ret = FALSE;
goto done;
}
ret = process_create (NULL, args, lpDirectory, NULL, process_info);
g_free (args);
if (!ret) {
- if (GetLastError () != ERROR_OUTOFMEMORY)
- SetLastError (ERROR_INVALID_DATA);
+ if (mono_w32error_get_last () != ERROR_OUTOFMEMORY)
+ mono_w32error_set_last (ERROR_INVALID_DATA);
ret = FALSE;
goto done;
}
/* Shell exec should not return a process handle when it spawned a GUI thing, like a browser. */
- CloseHandle (process_info->process_handle);
+ mono_w32handle_close (process_info->process_handle);
process_info->process_handle = NULL;
}
done:
if (ret == FALSE) {
- process_info->pid = -GetLastError ();
+ process_info->pid = -mono_w32error_get_last ();
} else {
process_info->thread_handle = NULL;
#if !defined(MONO_CROSS_COMPILE)
g_free (shell_path);
if (!ret)
- process_info->pid = -GetLastError ();
+ process_info->pid = -mono_w32error_get_last ();
return ret;
}
return FALSE;
}
- if (process_handle->pid == wapi_getpid ()) {
+ if (process_handle->pid == current_pid) {
*exitcode = STILL_ACTIVE;
return TRUE;
}
{
if (WAPI_IS_PSEUDO_PROCESS_HANDLE (handle))
return TRUE;
- return CloseHandle (handle);
+ return mono_w32handle_close (handle);
}
MonoBoolean
res = mono_w32handle_lookup (handle, MONO_W32HANDLE_PROCESS, (gpointer*) &process_handle);
if (!res) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__, handle);
- SetLastError (ERROR_INVALID_HANDLE);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
return FALSE;
}
return TRUE;
switch (errno) {
- case EINVAL: SetLastError (ERROR_INVALID_PARAMETER); break;
- case EPERM: SetLastError (ERROR_ACCESS_DENIED); break;
- case ESRCH: SetLastError (ERROR_PROC_NOT_FOUND); break;
- default: SetLastError (ERROR_GEN_FAILURE); break;
+ case EINVAL: mono_w32error_set_last (ERROR_INVALID_PARAMETER); break;
+ case EPERM: mono_w32error_set_last (ERROR_ACCESS_DENIED); break;
+ case ESRCH: mono_w32error_set_last (ERROR_PROC_NOT_FOUND); break;
+ default: mono_w32error_set_last (ERROR_GEN_FAILURE); break;
}
return FALSE;
res = mono_w32handle_lookup (handle, MONO_W32HANDLE_PROCESS, (gpointer*) &process_handle);
if (!res) {
- SetLastError (ERROR_INVALID_HANDLE);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
return 0;
}
switch (errno) {
case EPERM:
case EACCES:
- SetLastError (ERROR_ACCESS_DENIED);
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
break;
case ESRCH:
- SetLastError (ERROR_PROC_NOT_FOUND);
+ mono_w32error_set_last (ERROR_PROC_NOT_FOUND);
break;
default:
- SetLastError (ERROR_GEN_FAILURE);
+ mono_w32error_set_last (ERROR_GEN_FAILURE);
}
return 0;
}
return MONO_W32PROCESS_PRIORITY_CLASS_NORMAL;
#else
- SetLastError (ERROR_NOT_SUPPORTED);
+ mono_w32error_set_last (ERROR_NOT_SUPPORTED);
return 0;
#endif
}
res = mono_w32handle_lookup (handle, MONO_W32HANDLE_PROCESS, (gpointer*) &process_handle);
if (!res) {
- SetLastError (ERROR_INVALID_HANDLE);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
return FALSE;
}
prio = -20;
break;
default:
- SetLastError (ERROR_INVALID_PARAMETER);
+ mono_w32error_set_last (ERROR_INVALID_PARAMETER);
return FALSE;
}
switch (errno) {
case EPERM:
case EACCES:
- SetLastError (ERROR_ACCESS_DENIED);
+ mono_w32error_set_last (ERROR_ACCESS_DENIED);
break;
case ESRCH:
- SetLastError (ERROR_PROC_NOT_FOUND);
+ mono_w32error_set_last (ERROR_PROC_NOT_FOUND);
break;
default:
- SetLastError (ERROR_GEN_FAILURE);
+ mono_w32error_set_last (ERROR_GEN_FAILURE);
}
}
return ret == 0;
#else
- SetLastError (ERROR_NOT_SUPPORTED);
+ mono_w32error_set_last (ERROR_NOT_SUPPORTED);
return FALSE;
#endif
}
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
- SetLastError (ERROR_INVALID_DATA);
+ mono_w32error_set_last (ERROR_INVALID_DATA);
return(NULL);
}
if (map_size < sizeof(IMAGE_NT_HEADERS32) + GUINT32_FROM_LE (dos_header->e_lfanew)) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File is too small: %d", __func__, map_size);
- SetLastError (ERROR_BAD_LENGTH);
+ mono_w32error_set_last (ERROR_BAD_LENGTH);
return(NULL);
}
if (nt_headers->Signature != IMAGE_NT_SIGNATURE) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Bad NT signature 0x%x", __func__, nt_headers->Signature);
- SetLastError (ERROR_INVALID_DATA);
+ mono_w32error_set_last (ERROR_INVALID_DATA);
return(NULL);
}
if (resource_rva == 0) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: No resources in file!", __func__);
- SetLastError (ERROR_INVALID_DATA);
+ mono_w32error_set_last (ERROR_INVALID_DATA);
return(NULL);
}
if (resource_dir == NULL) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find resource directory", __func__);
- SetLastError (ERROR_INVALID_DATA);
+ mono_w32error_set_last (ERROR_INVALID_DATA);
return(NULL);
}
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
- SetLastError (ERROR_INVALID_DATA);
+ mono_w32error_set_last (ERROR_INVALID_DATA);
return(NULL);
}
if (map_size < sizeof(IMAGE_NT_HEADERS64) + GUINT32_FROM_LE (dos_header->e_lfanew)) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File is too small: %d", __func__, map_size);
- SetLastError (ERROR_BAD_LENGTH);
+ mono_w32error_set_last (ERROR_BAD_LENGTH);
return(NULL);
}
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Bad NT signature 0x%x", __func__,
nt_headers->Signature);
- SetLastError (ERROR_INVALID_DATA);
+ mono_w32error_set_last (ERROR_INVALID_DATA);
return(NULL);
}
if (resource_rva == 0) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: No resources in file!", __func__);
- SetLastError (ERROR_INVALID_DATA);
+ mono_w32error_set_last (ERROR_INVALID_DATA);
return(NULL);
}
if (resource_dir == NULL) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find resource directory", __func__);
- SetLastError (ERROR_INVALID_DATA);
+ mono_w32error_set_last (ERROR_INVALID_DATA);
return(NULL);
}
if (filename_ext == NULL) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
- SetLastError (ERROR_INVALID_NAME);
+ mono_w32error_set_last (ERROR_INVALID_NAME);
return(NULL);
}
- fd = _wapi_open (filename_ext, O_RDONLY, 0);
- if (fd == -1) {
- mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error opening file %s: %s", __func__, filename_ext, strerror (errno));
+ fd = open (filename_ext, O_RDONLY, 0);
+ if (fd == -1 && (errno == ENOENT || errno == ENOTDIR) && IS_PORTABILITY_SET) {
+ gint saved_errno;
+ gchar *located_filename;
- SetLastError (_wapi_get_win32_file_error (errno));
- g_free (filename_ext);
+ saved_errno = errno;
- return(NULL);
+ located_filename = mono_portability_find_file (filename_ext, TRUE);
+ if (!located_filename) {
+ errno = saved_errno;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error opening file %s (1): %s", __func__, filename_ext, strerror (errno));
+
+ g_free (filename_ext);
+
+ mono_w32error_set_last (mono_w32error_unix_to_win32 (errno));
+ return NULL;
+ }
+
+ fd = open (located_filename, O_RDONLY, 0);
+ if (fd == -1) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error opening file %s (2): %s", __func__, filename_ext, strerror (errno));
+
+ g_free (filename_ext);
+ g_free (located_filename);
+
+ mono_w32error_set_last (mono_w32error_unix_to_win32 (errno));
+ return NULL;
+ }
+
+ g_free (located_filename);
}
if (fstat (fd, &statbuf) == -1) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error stat()ing file %s: %s", __func__, filename_ext, strerror (errno));
- SetLastError (_wapi_get_win32_file_error (errno));
+ mono_w32error_set_last (mono_w32error_unix_to_win32 (errno));
g_free (filename_ext);
close (fd);
return(NULL);
if (statbuf.st_size < sizeof(IMAGE_DOS_HEADER)) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File %s is too small: %lld", __func__, filename_ext, statbuf.st_size);
- SetLastError (ERROR_BAD_LENGTH);
+ mono_w32error_set_last (ERROR_BAD_LENGTH);
g_free (filename_ext);
close (fd);
return(NULL);
if (file_map == NULL) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error mmap()int file %s: %s", __func__, filename_ext, strerror (errno));
- SetLastError (_wapi_get_win32_file_error (errno));
+ mono_w32error_set_last (mono_w32error_unix_to_win32 (errno));
g_free (filename_ext);
close (fd);
return(NULL);
#include <mono/metadata/threadpool-io.h>
#include <mono/utils/strenc.h>
#include <mono/utils/mono-proclib.h>
-#include <mono/io-layer/io-layer.h>
/* FIXME: fix this code to not depend so much on the internals */
#include <mono/metadata/class-internals.h>
#include <mono/metadata/w32handle.h>
+#include <mono/utils/w32api.h>
#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
#include <shellapi.h>
#include "w32process.h"
#include "w32process-internals.h"
#include "w32process-win32-internals.h"
+#include "w32file.h"
#include "object.h"
#include "object-internals.h"
#include "class.h"
#include "class-internals.h"
#include "image.h"
#include "utils/mono-proclib.h"
-#include "io-layer/io-layer.h"
+#include "utils/w32api.h"
#define LOGDEBUG(...)
/* define LOGDEBUG(...) g_message(__VA_ARGS__) */
{
gpointer process_handle;
gpointer thread_handle;
- guint32 pid; /* Contains GetLastError () on failure */
+ guint32 pid; /* Contains mono_w32error_get_last () on failure */
guint32 tid;
MonoArray *env_variables;
MonoString *username;
#include "w32semaphore.h"
+#include "w32error.h"
#include "w32handle-namespace.h"
-#include "mono/io-layer/io-layer.h"
#include "mono/utils/mono-logger-internals.h"
#include "mono/metadata/w32handle.h"
+#define MAX_PATH 260
+
typedef struct {
guint32 val;
gint32 max;
if (handle == INVALID_HANDLE_VALUE) {
g_warning ("%s: error creating %s handle",
__func__, mono_w32handle_get_typename (type));
- SetLastError (ERROR_GEN_FAILURE);
+ mono_w32error_set_last (ERROR_GEN_FAILURE);
return NULL;
}
/* w32 seems to guarantee that opening named objects can't race each other */
mono_w32handle_namespace_lock ();
- utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
+ glong utf8_len = 0;
+ utf8_name = g_utf16_to_utf8 (name, -1, NULL, &utf8_len, NULL);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating named sem name [%s] initial %d max %d", __func__, utf8_name, initial, max);
if (handle == INVALID_HANDLE_VALUE) {
/* The name has already been used for a different object. */
handle = NULL;
- SetLastError (ERROR_INVALID_HANDLE);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
} else if (handle) {
/* Not an error, but this is how the caller is informed that the semaphore wasn't freshly created */
- SetLastError (ERROR_ALREADY_EXISTS);
+ mono_w32error_set_last (ERROR_ALREADY_EXISTS);
/* mono_w32handle_namespace_search_handle already adds a ref to the handle */
} else {
/* A new named semaphore */
MonoW32HandleNamedSemaphore namedsem_handle;
- strncpy (&namedsem_handle.sharedns.name [0], utf8_name, MAX_PATH);
- namedsem_handle.sharedns.name [MAX_PATH] = '\0';
+ size_t len = utf8_len < MAX_PATH ? utf8_len : MAX_PATH;
+ memcpy (&namedsem_handle.sharedns.name [0], utf8_name, len);
+ namedsem_handle.sharedns.name [len] = '\0';
handle = sem_handle_create ((MonoW32HandleSemaphore*) &namedsem_handle, MONO_W32HANDLE_NAMEDSEM, initial, max);
}
* for ERROR_ALREADY_EXISTS on success (!) to see if a
* semaphore was freshly created
*/
- SetLastError (ERROR_SUCCESS);
+ mono_w32error_set_last (ERROR_SUCCESS);
if (!name)
sem = sem_create (initialCount, maximumCount);
else
sem = namedsem_create (initialCount, maximumCount, mono_string_chars (name));
- *error = GetLastError ();
+ *error = mono_w32error_get_last ();
return sem;
}
MonoBoolean ret;
if (!handle) {
- SetLastError (ERROR_INVALID_HANDLE);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
return FALSE;
}
case MONO_W32HANDLE_NAMEDSEM:
break;
default:
- SetLastError (ERROR_INVALID_HANDLE);
+ mono_w32error_set_last (ERROR_INVALID_HANDLE);
return FALSE;
}
--- /dev/null
+/*
+* w32socket-internals.h
+*
+* Copyright 2016 Microsoft
+* Licensed under the MIT license. See LICENSE file in the project root for full license information.
+*/
+#ifndef __MONO_METADATA_W32SOCKET_INTERNALS_H__
+#define __MONO_METADATA_W32SOCKET_INTERNALS_H__
+
+#include <config.h>
+#include <glib.h>
+
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#include <mono/utils/w32api.h>
+
+#ifndef HAVE_SOCKLEN_T
+#define socklen_t int
+#endif
+
+#ifndef HOST_WIN32
+
+#define TF_DISCONNECT 0x01
+#define TF_REUSE_SOCKET 0x02
+
+typedef struct {
+ guint32 len;
+ gpointer buf;
+} WSABUF, *LPWSABUF;
+
+typedef struct {
+ gpointer Head;
+ guint32 HeadLength;
+ gpointer Tail;
+ guint32 TailLength;
+} TRANSMIT_FILE_BUFFERS, *LPTRANSMIT_FILE_BUFFERS;
+
+typedef struct {
+ guint32 Data1;
+ guint16 Data2;
+ guint16 Data3;
+ guint8 Data4[8];
+} GUID;
+
+typedef struct {
+ guint32 Internal;
+ guint32 InternalHigh;
+ guint32 Offset;
+ guint32 OffsetHigh;
+ gpointer hEvent;
+ gpointer handle1;
+ gpointer handle2;
+} OVERLAPPED;
+
+#endif
+
+void
+mono_w32socket_initialize (void);
+
+void
+mono_w32socket_cleanup (void);
+
+SOCKET
+mono_w32socket_accept (SOCKET s, struct sockaddr *addr, socklen_t *addrlen, gboolean blocking);
+
+int
+mono_w32socket_connect (SOCKET s, const struct sockaddr *name, int namelen, gboolean blocking);
+
+int
+mono_w32socket_recv (SOCKET s, char *buf, int len, int flags, gboolean blocking);
+
+int
+mono_w32socket_recvfrom (SOCKET s, char *buf, int len, int flags, struct sockaddr *from, socklen_t *fromlen, gboolean blocking);
+
+int
+mono_w32socket_recvbuffers (SOCKET s, LPWSABUF lpBuffers, guint32 dwBufferCount, guint32 *lpNumberOfBytesRecvd, guint32 *lpFlags, gpointer lpOverlapped, gpointer lpCompletionRoutine, gboolean blocking);
+
+int
+mono_w32socket_send (SOCKET s, char *buf, int len, int flags, gboolean blocking);
+
+int
+mono_w32socket_sendto (SOCKET s, const char *buf, int len, int flags, const struct sockaddr *to, int tolen, gboolean blocking);
+
+int
+mono_w32socket_sendbuffers (SOCKET s, LPWSABUF lpBuffers, guint32 dwBufferCount, guint32 *lpNumberOfBytesRecvd, guint32 lpFlags, gpointer lpOverlapped, gpointer lpCompletionRoutine, gboolean blocking);
+
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
+
+BOOL
+mono_w32socket_transmit_file (SOCKET hSocket, gpointer hFile, LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, guint32 dwReserved, gboolean blocking);
+
+#endif
+
+#ifndef HOST_WIN32
+
+SOCKET
+mono_w32socket_socket (int domain, int type, int protocol);
+
+gint
+mono_w32socket_bind (SOCKET sock, struct sockaddr *addr, socklen_t addrlen);
+
+gint
+mono_w32socket_getpeername (SOCKET sock, struct sockaddr *name, socklen_t *namelen);
+
+gint
+mono_w32socket_getsockname (SOCKET sock, struct sockaddr *name, socklen_t *namelen);
+
+gint
+mono_w32socket_getsockopt (SOCKET sock, gint level, gint optname, gpointer optval, socklen_t *optlen);
+
+gint
+mono_w32socket_setsockopt (SOCKET sock, gint level, gint optname, const gpointer optval, socklen_t optlen);
+
+gint
+mono_w32socket_listen (SOCKET sock, gint backlog);
+
+gint
+mono_w32socket_shutdown (SOCKET sock, gint how);
+
+gint
+mono_w32socket_ioctl (SOCKET sock, gint32 command, gchar *input, gint inputlen, gchar *output, gint outputlen, glong *written);
+
+gboolean
+mono_w32socket_close (SOCKET sock);
+
+#endif /* HOST_WIN32 */
+
+gint
+mono_w32socket_disconnect (SOCKET sock, gboolean reuse);
+
+gint
+mono_w32socket_set_blocking (SOCKET socket, gboolean blocking);
+
+gint
+mono_w32socket_get_available (SOCKET socket, guint64 *amount);
+
+void
+mono_w32socket_set_last_error (gint32 error);
+
+gint32
+mono_w32socket_get_last_error (void);
+
+gint32
+mono_w32socket_convert_error (gint error);
+
+#endif // __MONO_METADATA_W32SOCKET_INTERNALS_H__
--- /dev/null
+/*
+ * w32socket-unix.c: Unix specific socket code.
+ *
+ * Copyright 2016 Microsoft
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#include <config.h>
+#include <glib.h>
+
+#include <pthread.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#include <arpa/inet.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#ifdef HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#ifdef HAVE_SYS_FILIO_H
+#include <sys/filio.h> /* defines FIONBIO and FIONREAD */
+#endif
+#ifdef HAVE_SYS_SOCKIO_H
+#include <sys/sockio.h> /* defines SIOCATMARK */
+#endif
+#ifndef HAVE_MSG_NOSIGNAL
+#include <signal.h>
+#endif
+#ifdef HAVE_SYS_SENDFILE_H
+#include <sys/sendfile.h>
+#endif
+#include <sys/stat.h>
+
+#include "w32socket.h"
+#include "w32socket-internals.h"
+#include "w32error.h"
+#include "w32handle.h"
+#include "utils/mono-logger-internals.h"
+#include "utils/mono-poll.h"
+
+typedef struct {
+ int domain;
+ int type;
+ int protocol;
+ int saved_error;
+ int still_readable;
+} MonoW32HandleSocket;
+
+static guint32 in_cleanup = 0;
+
+static void
+socket_close (gpointer handle, gpointer data)
+{
+ int ret;
+ MonoW32HandleSocket *socket_handle = (MonoW32HandleSocket *)data;
+ MonoThreadInfo *info = mono_thread_info_current ();
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing socket handle %p", __func__, handle);
+
+ /* Shutdown the socket for reading, to interrupt any potential
+ * receives that may be blocking for data. See bug 75705. */
+ shutdown (GPOINTER_TO_UINT (handle), SHUT_RD);
+
+ do {
+ ret = close (GPOINTER_TO_UINT(handle));
+ } while (ret == -1 && errno == EINTR &&
+ !mono_thread_info_is_interrupt_state (info));
+
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: close error: %s", __func__, g_strerror (errno));
+ if (!in_cleanup)
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ }
+
+ if (!in_cleanup)
+ socket_handle->saved_error = 0;
+}
+
+static void
+socket_details (gpointer data)
+{
+ /* FIXME: do something */
+}
+
+static const gchar*
+socket_typename (void)
+{
+ return "Socket";
+}
+
+static gsize
+socket_typesize (void)
+{
+ return sizeof (MonoW32HandleSocket);
+}
+
+static MonoW32HandleOps ops = {
+ socket_close, /* close */
+ NULL, /* signal */
+ NULL, /* own */
+ NULL, /* is_owned */
+ NULL, /* special_wait */
+ NULL, /* prewait */
+ socket_details, /* details */
+ socket_typename, /* typename */
+ socket_typesize, /* typesize */
+};
+
+void
+mono_w32socket_initialize (void)
+{
+ mono_w32handle_register_ops (MONO_W32HANDLE_SOCKET, &ops);
+}
+
+static gboolean
+cleanup_close (gpointer handle, gpointer data, gpointer user_data)
+{
+ if (mono_w32handle_get_type (handle) == MONO_W32HANDLE_SOCKET)
+ mono_w32handle_force_close (handle, data);
+
+ return FALSE;
+}
+
+void
+mono_w32socket_cleanup (void)
+{
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: cleaning up", __func__);
+
+ in_cleanup = 1;
+ mono_w32handle_foreach (cleanup_close, NULL);
+ in_cleanup = 0;
+}
+
+SOCKET
+mono_w32socket_accept (SOCKET sock, struct sockaddr *addr, socklen_t *addrlen, gboolean blocking)
+{
+ gpointer handle;
+ gpointer new_handle;
+ MonoW32HandleSocket *socket_handle;
+ MonoW32HandleSocket new_socket_handle;
+ SOCKET new_fd;
+ MonoThreadInfo *info;
+
+ if (addr != NULL && *addrlen < sizeof(struct sockaddr)) {
+ mono_w32socket_set_last_error (WSAEFAULT);
+ return INVALID_SOCKET;
+ }
+
+ handle = GUINT_TO_POINTER (sock);
+ if (!mono_w32handle_lookup (handle, MONO_W32HANDLE_SOCKET, (gpointer *)&socket_handle)) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return INVALID_SOCKET;
+ }
+
+ info = mono_thread_info_current ();
+
+ do {
+ new_fd = accept (sock, addr, addrlen);
+ } while (new_fd == -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
+
+ if (new_fd == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: accept error: %s", __func__, g_strerror(errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return INVALID_SOCKET;
+ }
+
+ if (new_fd >= mono_w32handle_fd_reserve) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big", __func__);
+
+ mono_w32socket_set_last_error (WSASYSCALLFAILURE);
+
+ close (new_fd);
+
+ return INVALID_SOCKET;
+ }
+
+ new_socket_handle.domain = socket_handle->domain;
+ new_socket_handle.type = socket_handle->type;
+ new_socket_handle.protocol = socket_handle->protocol;
+ new_socket_handle.still_readable = 1;
+
+ new_handle = mono_w32handle_new_fd (MONO_W32HANDLE_SOCKET, new_fd,
+ &new_socket_handle);
+ if(new_handle == INVALID_HANDLE_VALUE) {
+ g_warning ("%s: error creating socket handle", __func__);
+ mono_w32socket_set_last_error (ERROR_GEN_FAILURE);
+ return INVALID_SOCKET;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning newly accepted socket handle %p with",
+ __func__, new_handle);
+
+ return new_fd;
+}
+
+int
+mono_w32socket_connect (SOCKET sock, const struct sockaddr *addr, int addrlen, gboolean blocking)
+{
+ gpointer handle;
+ MonoW32HandleSocket *socket_handle;
+
+ handle = GUINT_TO_POINTER (sock);
+ if (!mono_w32handle_lookup (handle, MONO_W32HANDLE_SOCKET, (gpointer *)&socket_handle)) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+ if (connect (sock, addr, addrlen) == -1) {
+ MonoThreadInfo *info;
+ mono_pollfd fds;
+ gint errnum, so_error;
+ socklen_t len;
+
+ errnum = errno;
+
+ if (errno != EINTR) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect error: %s", __func__,
+ g_strerror (errnum));
+
+ errnum = mono_w32socket_convert_error (errnum);
+ if (errnum == WSAEINPROGRESS)
+ errnum = WSAEWOULDBLOCK; /* see bug #73053 */
+
+ mono_w32socket_set_last_error (errnum);
+
+ /*
+ * On solaris x86 getsockopt (SO_ERROR) is not set after
+ * connect () fails so we need to save this error.
+ *
+ * But don't do this for EWOULDBLOCK (bug 317315)
+ */
+ if (errnum != WSAEWOULDBLOCK) {
+ /* ECONNRESET means the socket was closed by another thread */
+ /* Async close on mac raises ECONNABORTED. */
+ socket_handle->saved_error = errnum;
+ }
+ return SOCKET_ERROR;
+ }
+
+ info = mono_thread_info_current ();
+
+ fds.fd = sock;
+ fds.events = MONO_POLLOUT;
+ while (mono_poll (&fds, 1, -1) == -1 && !mono_thread_info_is_interrupt_state (info)) {
+ if (errno != EINTR) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect poll error: %s", __func__, g_strerror (errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+ }
+
+ len = sizeof(so_error);
+ if (getsockopt (sock, SOL_SOCKET, SO_ERROR, &so_error, &len) == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect getsockopt error: %s", __func__, g_strerror (errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+ if (so_error != 0) {
+ gint errnum = mono_w32socket_convert_error (so_error);
+
+ /* Need to save this socket error */
+ socket_handle->saved_error = errnum;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect getsockopt returned error: %s",
+ __func__, g_strerror (so_error));
+
+ mono_w32socket_set_last_error (errnum);
+ return SOCKET_ERROR;
+ }
+ }
+
+ return 0;
+}
+
+int
+mono_w32socket_recv (SOCKET sock, char *buf, int len, int flags, gboolean blocking)
+{
+ return mono_w32socket_recvfrom (sock, buf, len, flags, NULL, 0, blocking);
+}
+
+int
+mono_w32socket_recvfrom (SOCKET sock, char *buf, int len, int flags, struct sockaddr *from, socklen_t *fromlen, gboolean blocking)
+{
+ gpointer handle;
+ MonoW32HandleSocket *socket_handle;
+ int ret;
+ MonoThreadInfo *info;
+
+ handle = GUINT_TO_POINTER (sock);
+ if (!mono_w32handle_lookup (handle, MONO_W32HANDLE_SOCKET, (gpointer *)&socket_handle)) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+ info = mono_thread_info_current ();
+
+ do {
+ ret = recvfrom (sock, buf, len, flags, from, fromlen);
+ } while (ret == -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
+
+ if (ret == 0 && len > 0) {
+ /* According to the Linux man page, recvfrom only
+ * returns 0 when the socket has been shut down
+ * cleanly. Turn this into an EINTR to simulate win32
+ * behaviour of returning EINTR when a socket is
+ * closed while the recvfrom is blocking (we use a
+ * shutdown() in socket_close() to trigger this.) See
+ * bug 75705.
+ */
+ /* Distinguish between the socket being shut down at
+ * the local or remote ends, and reads that request 0
+ * bytes to be read
+ */
+
+ /* If this returns FALSE, it means the socket has been
+ * closed locally. If it returns TRUE, but
+ * still_readable != 1 then shutdown
+ * (SHUT_RD|SHUT_RDWR) has been called locally.
+ */
+ if (socket_handle->still_readable != 1) {
+ ret = -1;
+ errno = EINTR;
+ }
+ }
+
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: recv error: %s", __func__, g_strerror(errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+ return ret;
+}
+
+static void
+wsabuf_to_msghdr (WSABUF *buffers, guint32 count, struct msghdr *hdr)
+{
+ guint32 i;
+
+ memset (hdr, 0, sizeof (struct msghdr));
+ hdr->msg_iovlen = count;
+ hdr->msg_iov = g_new0 (struct iovec, count);
+ for (i = 0; i < count; i++) {
+ hdr->msg_iov [i].iov_base = buffers [i].buf;
+ hdr->msg_iov [i].iov_len = buffers [i].len;
+ }
+}
+
+static void
+msghdr_iov_free (struct msghdr *hdr)
+{
+ g_free (hdr->msg_iov);
+}
+
+int
+mono_w32socket_recvbuffers (SOCKET sock, WSABUF *buffers, guint32 count, guint32 *received, guint32 *flags, gpointer overlapped, gpointer complete, gboolean blocking)
+{
+ MonoW32HandleSocket *socket_handle;
+ MonoThreadInfo *info;
+ gpointer handle;
+ gint ret;
+ struct msghdr hdr;
+
+ g_assert (overlapped == NULL);
+ g_assert (complete == NULL);
+
+ handle = GUINT_TO_POINTER (sock);
+ if (!mono_w32handle_lookup (handle, MONO_W32HANDLE_SOCKET, (gpointer *)&socket_handle)) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+ info = mono_thread_info_current ();
+
+ wsabuf_to_msghdr (buffers, count, &hdr);
+
+ do {
+ ret = recvmsg (sock, &hdr, *flags);
+ } while (ret == -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
+
+ msghdr_iov_free (&hdr);
+
+ if (ret == 0) {
+ /* see mono_w32socket_recvfrom */
+ if (socket_handle->still_readable != 1) {
+ ret = -1;
+ errno = EINTR;
+ }
+ }
+
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: recvmsg error: %s", __func__, g_strerror(errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+ *received = ret;
+ *flags = hdr.msg_flags;
+
+ return 0;
+}
+
+int
+mono_w32socket_send (SOCKET sock, char *buf, int len, int flags, gboolean blocking)
+{
+ gpointer handle;
+ int ret;
+ MonoThreadInfo *info;
+
+ handle = GUINT_TO_POINTER (sock);
+ if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+ info = mono_thread_info_current ();
+
+ do {
+ ret = send (sock, buf, len, flags);
+ } while (ret == -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
+
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: send error: %s", __func__, g_strerror (errno));
+
+#ifdef O_NONBLOCK
+ /* At least linux returns EAGAIN/EWOULDBLOCK when the timeout has been set on
+ * a blocking socket. See bug #599488 */
+ if (errnum == EAGAIN) {
+ ret = fcntl (sock, F_GETFL, 0);
+ if (ret != -1 && (ret & O_NONBLOCK) == 0)
+ errnum = ETIMEDOUT;
+ }
+#endif /* O_NONBLOCK */
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+ return ret;
+}
+
+int
+mono_w32socket_sendto (SOCKET sock, const char *buf, int len, int flags, const struct sockaddr *to, int tolen, gboolean blocking)
+{
+ gpointer handle;
+ int ret;
+ MonoThreadInfo *info;
+
+ handle = GUINT_TO_POINTER (sock);
+ if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+ info = mono_thread_info_current ();
+
+ do {
+ ret = sendto (sock, buf, len, flags, to, tolen);
+ } while (ret == -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
+
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: send error: %s", __func__, g_strerror (errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+ return ret;
+}
+
+int
+mono_w32socket_sendbuffers (SOCKET sock, WSABUF *buffers, guint32 count, guint32 *sent, guint32 flags, gpointer overlapped, gpointer complete, gboolean blocking)
+{
+ struct msghdr hdr;
+ MonoThreadInfo *info;
+ gpointer handle;
+ gint ret;
+
+ g_assert (overlapped == NULL);
+ g_assert (complete == NULL);
+
+ handle = GUINT_TO_POINTER (sock);
+ if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+ info = mono_thread_info_current ();
+
+ wsabuf_to_msghdr (buffers, count, &hdr);
+
+ do {
+ ret = sendmsg (sock, &hdr, flags);
+ } while (ret == -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
+
+ msghdr_iov_free (&hdr);
+
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sendmsg error: %s", __func__, g_strerror (errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+ *sent = ret;
+ return 0;
+}
+
+#define SF_BUFFER_SIZE 16384
+
+BOOL
+mono_w32socket_transmit_file (SOCKET sock, gpointer file_handle, TRANSMIT_FILE_BUFFERS *buffers, guint32 flags, gboolean blocking)
+{
+ MonoThreadInfo *info;
+ gpointer handle;
+ gint file;
+ gssize ret;
+#if defined(HAVE_SENDFILE) && (defined(__linux__) || defined(DARWIN))
+ struct stat statbuf;
+#else
+ gchar *buffer;
+#endif
+
+ handle = GUINT_TO_POINTER (sock);
+ if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return FALSE;
+ }
+
+ /* Write the header */
+ if (buffers != NULL && buffers->Head != NULL && buffers->HeadLength > 0) {
+ ret = mono_w32socket_send (sock, buffers->Head, buffers->HeadLength, 0, FALSE);
+ if (ret == SOCKET_ERROR)
+ return FALSE;
+ }
+
+ info = mono_thread_info_current ();
+
+ file = GPOINTER_TO_INT (file_handle);
+
+#if defined(HAVE_SENDFILE) && (defined(__linux__) || defined(DARWIN))
+ ret = fstat (file, &statbuf);
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+ do {
+#ifdef __linux__
+ ret = sendfile (sock, file, NULL, statbuf.st_size);
+#elif defined(DARWIN)
+ /* TODO: header/tail could be sent in the 5th argument */
+ /* TODO: Might not send the entire file for non-blocking sockets */
+ ret = sendfile (file, sock, 0, &statbuf.st_size, NULL, 0);
+#endif
+ } while (ret != -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
+#else
+ buffer = g_malloc (SF_BUFFER_SIZE);
+
+ do {
+ do {
+ ret = read (file, buffer, SF_BUFFER_SIZE);
+ } while (ret == -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
+
+ if (ret == -1 || ret == 0)
+ break;
+
+ do {
+ ret = send (sock, buffer, ret, 0); /* short sends? enclose this in a loop? */
+ } while (ret == -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
+ } while (ret != -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
+
+ g_free (buffer);
+#endif
+
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return FALSE;
+ }
+
+ /* Write the tail */
+ if (buffers != NULL && buffers->Tail != NULL && buffers->TailLength > 0) {
+ ret = mono_w32socket_send (sock, buffers->Tail, buffers->TailLength, 0, FALSE);
+ if (ret == SOCKET_ERROR)
+ return FALSE;
+ }
+
+ if ((flags & TF_DISCONNECT) == TF_DISCONNECT)
+ mono_w32handle_close (handle);
+
+ return TRUE;
+}
+
+SOCKET
+mono_w32socket_socket (int domain, int type, int protocol)
+{
+ MonoW32HandleSocket socket_handle = {0};
+ gpointer handle;
+ SOCKET sock;
+
+ socket_handle.domain = domain;
+ socket_handle.type = type;
+ socket_handle.protocol = protocol;
+ socket_handle.still_readable = 1;
+
+ sock = socket (domain, type, protocol);
+ if (sock == -1 && domain == AF_INET && type == SOCK_RAW &&
+ protocol == 0) {
+ /* Retry with protocol == 4 (see bug #54565) */
+ // https://bugzilla.novell.com/show_bug.cgi?id=MONO54565
+ socket_handle.protocol = 4;
+ sock = socket (AF_INET, SOCK_RAW, 4);
+ }
+
+ if (sock == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: socket error: %s", __func__, g_strerror (errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return INVALID_SOCKET;
+ }
+
+ if (sock >= mono_w32handle_fd_reserve) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big (%d >= %d)",
+ __func__, sock, mono_w32handle_fd_reserve);
+
+ mono_w32socket_set_last_error (WSASYSCALLFAILURE);
+ close (sock);
+
+ return INVALID_SOCKET;
+ }
+
+ /* .net seems to set this by default for SOCK_STREAM, not for
+ * SOCK_DGRAM (see bug #36322)
+ * https://bugzilla.novell.com/show_bug.cgi?id=MONO36322
+ *
+ * It seems winsock has a rather different idea of what
+ * SO_REUSEADDR means. If it's set, then a new socket can be
+ * bound over an existing listening socket. There's a new
+ * windows-specific option called SO_EXCLUSIVEADDRUSE but
+ * using that means the socket MUST be closed properly, or a
+ * denial of service can occur. Luckily for us, winsock
+ * behaves as though any other system would when SO_REUSEADDR
+ * is true, so we don't need to do anything else here. See
+ * bug 53992.
+ * https://bugzilla.novell.com/show_bug.cgi?id=MONO53992
+ */
+ {
+ int ret, true_ = 1;
+
+ ret = setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, &true_, sizeof (true_));
+ if (ret == -1) {
+ close (sock);
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error setting SO_REUSEADDR", __func__);
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return INVALID_SOCKET;
+ }
+ }
+
+
+ handle = mono_w32handle_new_fd (MONO_W32HANDLE_SOCKET, sock, &socket_handle);
+ if (handle == INVALID_HANDLE_VALUE) {
+ g_warning ("%s: error creating socket handle", __func__);
+ mono_w32socket_set_last_error (WSASYSCALLFAILURE);
+ close (sock);
+ return INVALID_SOCKET;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning socket handle %p", __func__, handle);
+
+ return sock;
+}
+
+gint
+mono_w32socket_bind (SOCKET sock, struct sockaddr *addr, socklen_t addrlen)
+{
+ gpointer handle;
+ int ret;
+
+ handle = GUINT_TO_POINTER (sock);
+ if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+ ret = bind (sock, addr, addrlen);
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: bind error: %s", __func__, g_strerror(errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+ return 0;
+}
+
+gint
+mono_w32socket_getpeername (SOCKET sock, struct sockaddr *name, socklen_t *namelen)
+{
+ gpointer handle;
+ gint ret;
+
+ handle = GUINT_TO_POINTER (sock);
+ if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+ ret = getpeername (sock, name, namelen);
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: getpeername error: %s", __func__, g_strerror (errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+ return 0;
+}
+
+gint
+mono_w32socket_getsockname (SOCKET sock, struct sockaddr *name, socklen_t *namelen)
+{
+ gpointer handle;
+ gint ret;
+
+ handle = GUINT_TO_POINTER (sock);
+ if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+ ret = getsockname (sock, name, namelen);
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: getsockname error: %s", __func__, g_strerror (errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+ return 0;
+}
+
+gint
+mono_w32socket_getsockopt (SOCKET sock, gint level, gint optname, gpointer optval, socklen_t *optlen)
+{
+ gpointer handle;
+ gint ret;
+ struct timeval tv;
+ gpointer tmp_val;
+ MonoW32HandleSocket *socket_handle;
+
+ handle = GUINT_TO_POINTER (sock);
+ if (!mono_w32handle_lookup (handle, MONO_W32HANDLE_SOCKET, (gpointer *)&socket_handle)) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+ tmp_val = optval;
+ if (level == SOL_SOCKET &&
+ (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)) {
+ tmp_val = &tv;
+ *optlen = sizeof (tv);
+ }
+
+ ret = getsockopt (sock, level, optname, tmp_val, optlen);
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: getsockopt error: %s", __func__, g_strerror (errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+ if (level == SOL_SOCKET && (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)) {
+ *((int *) optval) = tv.tv_sec * 1000 + (tv.tv_usec / 1000); // milli from micro
+ *optlen = sizeof (int);
+ }
+
+ if (optname == SO_ERROR) {
+ if (*((int *)optval) != 0) {
+ *((int *) optval) = mono_w32socket_convert_error (*((int *)optval));
+ socket_handle->saved_error = *((int *)optval);
+ } else {
+ *((int *)optval) = socket_handle->saved_error;
+ }
+ }
+
+ return 0;
+}
+
+gint
+mono_w32socket_setsockopt (SOCKET sock, gint level, gint optname, const gpointer optval, socklen_t optlen)
+{
+ gpointer handle;
+ gint ret;
+ gpointer tmp_val;
+#if defined (__linux__)
+ /* This has its address taken so it cannot be moved to the if block which uses it */
+ gint bufsize = 0;
+#endif
+ struct timeval tv;
+
+ handle = GUINT_TO_POINTER (sock);
+ if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+ tmp_val = optval;
+ if (level == SOL_SOCKET &&
+ (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)) {
+ int ms = *((int *) optval);
+ tv.tv_sec = ms / 1000;
+ tv.tv_usec = (ms % 1000) * 1000; // micro from milli
+ tmp_val = &tv;
+ optlen = sizeof (tv);
+ }
+#if defined (__linux__)
+ else if (level == SOL_SOCKET &&
+ (optname == SO_SNDBUF || optname == SO_RCVBUF)) {
+ /* According to socket(7) the Linux kernel doubles the
+ * buffer sizes "to allow space for bookkeeping
+ * overhead."
+ */
+ bufsize = *((int *) optval);
+
+ bufsize /= 2;
+ tmp_val = &bufsize;
+ }
+#endif
+
+ ret = setsockopt (sock, level, optname, tmp_val, optlen);
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setsockopt error: %s", __func__, g_strerror (errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+#if defined (SO_REUSEPORT)
+ /* BSD's and MacOS X multicast sockets also need SO_REUSEPORT when SO_REUSEADDR is requested. */
+ if (level == SOL_SOCKET && optname == SO_REUSEADDR) {
+ int type;
+ socklen_t type_len = sizeof (type);
+
+ if (!getsockopt (sock, level, SO_TYPE, &type, &type_len)) {
+ if (type == SOCK_DGRAM || type == SOCK_STREAM)
+ setsockopt (sock, level, SO_REUSEPORT, tmp_val, optlen);
+ }
+ }
+#endif
+
+ return ret;
+}
+
+gint
+mono_w32socket_listen (SOCKET sock, gint backlog)
+{
+ gpointer handle;
+ gint ret;
+
+ handle = GUINT_TO_POINTER (sock);
+ if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+ ret = listen (sock, backlog);
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: listen error: %s", __func__, g_strerror (errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+ return 0;
+}
+
+gint
+mono_w32socket_shutdown (SOCKET sock, gint how)
+{
+ MonoW32HandleSocket *socket_handle;
+ gpointer handle;
+ gint ret;
+
+ handle = GUINT_TO_POINTER (sock);
+ if (!mono_w32handle_lookup (handle, MONO_W32HANDLE_SOCKET, (gpointer *)&socket_handle)) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+ if (how == SHUT_RD || how == SHUT_RDWR)
+ socket_handle->still_readable = 0;
+
+ ret = shutdown (sock, how);
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: shutdown error: %s", __func__, g_strerror (errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+ return ret;
+}
+
+gint
+mono_w32socket_disconnect (SOCKET sock, gboolean reuse)
+{
+ MonoW32HandleSocket *socket_handle;
+ gpointer handle;
+ SOCKET newsock;
+ gint ret;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: called on socket %d!", __func__, sock);
+
+ /* We could check the socket type here and fail unless its
+ * SOCK_STREAM, SOCK_SEQPACKET or SOCK_RDM (according to msdn)
+ * if we really wanted to */
+
+ handle = GUINT_TO_POINTER (sock);
+ if (!mono_w32handle_lookup (handle, MONO_W32HANDLE_SOCKET, (gpointer *)&socket_handle)) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+ newsock = socket (socket_handle->domain, socket_handle->type, socket_handle->protocol);
+ if (newsock == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: socket error: %s", __func__, g_strerror (errnum));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+ /* According to Stevens "Advanced Programming in the UNIX
+ * Environment: UNIX File I/O" dup2() is atomic so there
+ * should not be a race condition between the old fd being
+ * closed and the new socket fd being copied over */
+ do {
+ ret = dup2 (newsock, sock);
+ } while (ret == -1 && errno == EAGAIN);
+
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: dup2 error: %s", __func__, g_strerror (errnum));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+ close (newsock);
+
+ return 0;
+}
+
+static gboolean
+extension_disconect (SOCKET sock, OVERLAPPED *overlapped, guint32 flags, guint32 reserved)
+{
+ return mono_w32socket_disconnect (sock, flags & TF_REUSE_SOCKET) == 0;
+}
+
+static gboolean
+extension_transmit_file (SOCKET sock, gpointer file_handle, guint32 bytes_to_write, guint32 bytes_per_send,
+ OVERLAPPED *ol, TRANSMIT_FILE_BUFFERS *buffers, guint32 flags)
+{
+ return mono_w32socket_transmit_file (sock, file_handle, buffers, flags, FALSE);
+}
+
+static struct {
+ GUID guid;
+ gpointer func;
+} extension_functions[] = {
+ { {0x7fda2e11,0x8630,0x436f,{0xa0,0x31,0xf5,0x36,0xa6,0xee,0xc1,0x57}} /* WSAID_DISCONNECTEX */, extension_disconect },
+ { {0xb5367df0,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}} /* WSAID_TRANSMITFILE */, extension_transmit_file },
+ { {0} , NULL },
+};
+
+gint
+mono_w32socket_ioctl (SOCKET sock, gint32 command, gchar *input, gint inputlen, gchar *output, gint outputlen, glong *written)
+{
+ gpointer handle;
+ gint ret;
+ gchar *buffer;
+
+ handle = GUINT_TO_POINTER (sock);
+ if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+ if (command == 0xC8000006 /* SIO_GET_EXTENSION_FUNCTION_POINTER */) {
+ gint i;
+ GUID *guid;
+
+ if (inputlen < sizeof(GUID)) {
+ /* As far as I can tell, windows doesn't
+ * actually set an error here...
+ */
+ mono_w32socket_set_last_error (WSAEINVAL);
+ return SOCKET_ERROR;
+ }
+
+ if (outputlen < sizeof(gpointer)) {
+ /* Or here... */
+ mono_w32socket_set_last_error (WSAEINVAL);
+ return SOCKET_ERROR;
+ }
+
+ if (output == NULL) {
+ /* Or here */
+ mono_w32socket_set_last_error (WSAEINVAL);
+ return SOCKET_ERROR;
+ }
+
+ guid = (GUID*) input;
+ for (i = 0; extension_functions[i].func; i++) {
+ if (memcmp (guid, &extension_functions[i].guid, sizeof(GUID)) == 0) {
+ memcpy (output, &extension_functions[i].func, sizeof(gpointer));
+ *written = sizeof(gpointer);
+ return 0;
+ }
+ }
+
+ mono_w32socket_set_last_error (WSAEINVAL);
+ return SOCKET_ERROR;
+ }
+
+ if (command == 0x98000004 /* SIO_KEEPALIVE_VALS */) {
+ guint32 onoff;
+
+ if (inputlen < 3 * sizeof (guint32)) {
+ mono_w32socket_set_last_error (WSAEINVAL);
+ return SOCKET_ERROR;
+ }
+
+ onoff = *((guint32*) input);
+
+ ret = setsockopt (sock, SOL_SOCKET, SO_KEEPALIVE, &onoff, sizeof (guint32));
+ if (ret < 0) {
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errno));
+ return SOCKET_ERROR;
+ }
+
+#if defined(TCP_KEEPIDLE) && defined(TCP_KEEPINTVL)
+ if (onoff != 0) {
+ /* Values are in ms, but we need s */
+ guint32 keepalivetime, keepaliveinterval, rem;
+
+ keepalivetime = *(((guint32*) input) + 1);
+ keepaliveinterval = *(((guint32*) input) + 2);
+
+ /* keepalivetime and keepaliveinterval are > 0 (checked in managed code) */
+ rem = keepalivetime % 1000;
+ keepalivetime /= 1000;
+ if (keepalivetime == 0 || rem >= 500)
+ keepalivetime++;
+ ret = setsockopt (sock, IPPROTO_TCP, TCP_KEEPIDLE, &keepalivetime, sizeof (guint32));
+ if (ret == 0) {
+ rem = keepaliveinterval % 1000;
+ keepaliveinterval /= 1000;
+ if (keepaliveinterval == 0 || rem >= 500)
+ keepaliveinterval++;
+ ret = setsockopt (sock, IPPROTO_TCP, TCP_KEEPINTVL, &keepaliveinterval, sizeof (guint32));
+ }
+ if (ret != 0) {
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errno));
+ return SOCKET_ERROR;
+ }
+
+ return 0;
+ }
+#endif
+
+ return 0;
+ }
+
+ buffer = inputlen > 0 ? (gchar*) g_memdup (input, inputlen) : NULL;
+
+ ret = ioctl (sock, command, buffer);
+ if (ret == -1) {
+ g_free (buffer);
+
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: WSAIoctl error: %s", __func__, g_strerror (errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+ if (!buffer) {
+ *written = 0;
+ return 0;
+ }
+
+ /* We just copy the buffer to the output. Some ioctls
+ * don't even output any data, but, well...
+ *
+ * NB windows returns WSAEFAULT if outputlen is too small */
+ inputlen = (inputlen > outputlen) ? outputlen : inputlen;
+
+ if (inputlen > 0 && output != NULL)
+ memcpy (output, buffer, inputlen);
+
+ g_free (buffer);
+ *written = inputlen;
+
+ return 0;
+}
+
+gboolean
+mono_w32socket_close (SOCKET sock)
+{
+ return mono_w32handle_close (GINT_TO_POINTER (sock));
+}
+
+gint
+mono_w32socket_set_blocking (SOCKET socket, gboolean blocking)
+{
+ gint ret;
+ gpointer handle;
+
+ handle = GINT_TO_POINTER (socket);
+ if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+#ifdef O_NONBLOCK
+ /* This works better than ioctl(...FIONBIO...)
+ * on Linux (it causes connect to return
+ * EINPROGRESS, but the ioctl doesn't seem to) */
+ ret = fcntl (socket, F_GETFL, 0);
+ if (ret != -1)
+ ret = fcntl (socket, F_SETFL, blocking ? (ret & (~O_NONBLOCK)) : (ret | (O_NONBLOCK)));
+#endif /* O_NONBLOCK */
+
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: ioctl error: %s", __func__, g_strerror (errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+ return 0;
+}
+
+gint
+mono_w32socket_get_available (SOCKET socket, guint64 *amount)
+{
+ gint ret;
+ gpointer handle;
+
+ handle = GINT_TO_POINTER (socket);
+ if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
+ mono_w32socket_set_last_error (WSAENOTSOCK);
+ return SOCKET_ERROR;
+ }
+
+#if defined (PLATFORM_MACOSX)
+ // ioctl (socket, FIONREAD, XXX) returns the size of
+ // the UDP header as well on Darwin.
+ //
+ // Use getsockopt SO_NREAD instead to get the
+ // right values for TCP and UDP.
+ //
+ // ai_canonname can be null in some cases on darwin,
+ // where the runtime assumes it will be the value of
+ // the ip buffer.
+
+ socklen_t optlen = sizeof (int);
+ ret = getsockopt (socket, SOL_SOCKET, SO_NREAD, (gulong*) amount, &optlen);
+#else
+ ret = ioctl (socket, FIONREAD, (gulong*) amount);
+#endif
+
+ if (ret == -1) {
+ gint errnum = errno;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: ioctl error: %s", __func__, g_strerror (errno));
+ mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
+ return SOCKET_ERROR;
+ }
+
+ return 0;
+}
+
+void
+mono_w32socket_set_last_error (gint32 error)
+{
+ mono_w32error_set_last (error);
+}
+
+gint32
+mono_w32socket_get_last_error (void)
+{
+ return mono_w32error_get_last ();
+}
+
+gint32
+mono_w32socket_convert_error (gint error)
+{
+ switch (error) {
+ case 0: return ERROR_SUCCESS;
+ case EACCES: return WSAEACCES;
+#ifdef EADDRINUSE
+ case EADDRINUSE: return WSAEADDRINUSE;
+#endif
+#ifdef EAFNOSUPPORT
+ case EAFNOSUPPORT: return WSAEAFNOSUPPORT;
+#endif
+#if EAGAIN != EWOULDBLOCK
+ case EAGAIN: return WSAEWOULDBLOCK;
+#endif
+#ifdef EALREADY
+ case EALREADY: return WSAEALREADY;
+#endif
+ case EBADF: return WSAENOTSOCK;
+#ifdef ECONNABORTED
+ case ECONNABORTED: return WSAENETDOWN;
+#endif
+#ifdef ECONNREFUSED
+ case ECONNREFUSED: return WSAECONNREFUSED;
+#endif
+#ifdef ECONNRESET
+ case ECONNRESET: return WSAECONNRESET;
+#endif
+ case EFAULT: return WSAEFAULT;
+#ifdef EHOSTUNREACH
+ case EHOSTUNREACH: return WSAEHOSTUNREACH;
+#endif
+#ifdef EINPROGRESS
+ case EINPROGRESS: return WSAEINPROGRESS;
+#endif
+ case EINTR: return WSAEINTR;
+ case EINVAL: return WSAEINVAL;
+ /*FIXME: case EIO: return WSAE????; */
+#ifdef EISCONN
+ case EISCONN: return WSAEISCONN;
+#endif
+ /* FIXME: case ELOOP: return WSA????; */
+ case EMFILE: return WSAEMFILE;
+#ifdef EMSGSIZE
+ case EMSGSIZE: return WSAEMSGSIZE;
+#endif
+ /* FIXME: case ENAMETOOLONG: return WSAEACCES; */
+#ifdef ENETUNREACH
+ case ENETUNREACH: return WSAENETUNREACH;
+#endif
+#ifdef ENOBUFS
+ case ENOBUFS: return WSAENOBUFS; /* not documented */
+#endif
+ /* case ENOENT: return WSAE????; */
+ case ENOMEM: return WSAENOBUFS;
+#ifdef ENOPROTOOPT
+ case ENOPROTOOPT: return WSAENOPROTOOPT;
+#endif
+#ifdef ENOSR
+ case ENOSR: return WSAENETDOWN;
+#endif
+#ifdef ENOTCONN
+ case ENOTCONN: return WSAENOTCONN;
+#endif
+ /*FIXME: case ENOTDIR: return WSAE????; */
+#ifdef ENOTSOCK
+ case ENOTSOCK: return WSAENOTSOCK;
+#endif
+ case ENOTTY: return WSAENOTSOCK;
+#ifdef EOPNOTSUPP
+ case EOPNOTSUPP: return WSAEOPNOTSUPP;
+#endif
+ case EPERM: return WSAEACCES;
+ case EPIPE: return WSAESHUTDOWN;
+#ifdef EPROTONOSUPPORT
+ case EPROTONOSUPPORT: return WSAEPROTONOSUPPORT;
+#endif
+#if ERESTARTSYS
+ case ERESTARTSYS: return WSAENETDOWN;
+#endif
+ /*FIXME: case EROFS: return WSAE????; */
+#ifdef ESOCKTNOSUPPORT
+ case ESOCKTNOSUPPORT: return WSAESOCKTNOSUPPORT;
+#endif
+#ifdef ETIMEDOUT
+ case ETIMEDOUT: return WSAETIMEDOUT;
+#endif
+#ifdef EWOULDBLOCK
+ case EWOULDBLOCK: return WSAEWOULDBLOCK;
+#endif
+#ifdef EADDRNOTAVAIL
+ case EADDRNOTAVAIL: return WSAEADDRNOTAVAIL;
+#endif
+ /* This might happen with unix sockets */
+ case ENOENT: return WSAECONNREFUSED;
+#ifdef EDESTADDRREQ
+ case EDESTADDRREQ: return WSAEDESTADDRREQ;
+#endif
+#ifdef EHOSTDOWN
+ case EHOSTDOWN: return WSAEHOSTDOWN;
+#endif
+#ifdef ENETDOWN
+ case ENETDOWN: return WSAENETDOWN;
+#endif
+ case ENODEV: return WSAENETDOWN;
+ default:
+ g_error ("%s: no translation into winsock error for (%d) \"%s\"", __func__, error, g_strerror (error));
+ }
+}
+
+gboolean
+ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto)
+{
+#if defined (SO_REUSEPORT)
+ return TRUE;
+#else
+#ifdef __linux__
+ /* Linux always supports double binding for UDP, even on older kernels. */
+ if (proto == ProtocolType_Udp)
+ return TRUE;
+#endif
+ return FALSE;
+#endif
+}
--- /dev/null
+/*
+ * w32socket-win32.c: Windows specific socket code.
+ *
+ * Copyright 2016 Microsoft
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#include <config.h>
+#include <glib.h>
+
+#include <string.h>
+#include <stdlib.h>
+#include <ws2tcpip.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <errno.h>
+
+#include <sys/types.h>
+
+#include "w32socket.h"
+#include "w32socket-internals.h"
+
+#include "utils/w32api.h"
+
+#define LOGDEBUG(...)
+
+void
+mono_w32socket_initialize (void)
+{
+}
+
+void
+mono_w32socket_cleanup (void)
+{
+}
+
+static gboolean set_blocking (SOCKET sock, gboolean block)
+{
+ u_long non_block = block ? 0 : 1;
+ return ioctlsocket (sock, FIONBIO, &non_block) != SOCKET_ERROR;
+}
+
+static DWORD get_socket_timeout (SOCKET sock, int optname)
+{
+ DWORD timeout = 0;
+ int optlen = sizeof (DWORD);
+ if (getsockopt (sock, SOL_SOCKET, optname, (char *)&timeout, &optlen) == SOCKET_ERROR) {
+ WSASetLastError (0);
+ return WSA_INFINITE;
+ }
+ if (timeout == 0)
+ timeout = WSA_INFINITE; // 0 means infinite
+ return timeout;
+}
+
+/*
+* Performs an alertable wait for the specified event (FD_ACCEPT_BIT,
+* FD_CONNECT_BIT, FD_READ_BIT, FD_WRITE_BIT) on the specified socket.
+* Returns TRUE if the event is fired without errors. Calls WSASetLastError()
+* with WSAEINTR and returns FALSE if the thread is alerted. If the event is
+* fired but with an error WSASetLastError() is called to set the error and the
+* function returns FALSE.
+*/
+static gboolean alertable_socket_wait (SOCKET sock, int event_bit)
+{
+ static char *EVENT_NAMES[] = { "FD_READ", "FD_WRITE", NULL /*FD_OOB*/, "FD_ACCEPT", "FD_CONNECT", "FD_CLOSE" };
+ gboolean success = FALSE;
+ int error = -1;
+ DWORD timeout = WSA_INFINITE;
+ if (event_bit == FD_READ_BIT || event_bit == FD_WRITE_BIT) {
+ timeout = get_socket_timeout (sock, event_bit == FD_READ_BIT ? SO_RCVTIMEO : SO_SNDTIMEO);
+ }
+ WSASetLastError (0);
+ WSAEVENT event = WSACreateEvent ();
+ if (event != WSA_INVALID_EVENT) {
+ if (WSAEventSelect (sock, event, (1 << event_bit) | FD_CLOSE) != SOCKET_ERROR) {
+ LOGDEBUG (g_message ("%06d - Calling WSAWaitForMultipleEvents () on socket %d", GetCurrentThreadId (), sock));
+ DWORD ret = WSAWaitForMultipleEvents (1, &event, TRUE, timeout, TRUE);
+ if (ret == WSA_WAIT_IO_COMPLETION) {
+ LOGDEBUG (g_message ("%06d - WSAWaitForMultipleEvents () returned WSA_WAIT_IO_COMPLETION for socket %d", GetCurrentThreadId (), sock));
+ error = WSAEINTR;
+ } else if (ret == WSA_WAIT_TIMEOUT) {
+ error = WSAETIMEDOUT;
+ } else {
+ g_assert (ret == WSA_WAIT_EVENT_0);
+ WSANETWORKEVENTS ne = { 0 };
+ if (WSAEnumNetworkEvents (sock, event, &ne) != SOCKET_ERROR) {
+ if (ne.lNetworkEvents & (1 << event_bit) && ne.iErrorCode[event_bit]) {
+ LOGDEBUG (g_message ("%06d - %s error %d on socket %d", GetCurrentThreadId (), EVENT_NAMES[event_bit], ne.iErrorCode[event_bit], sock));
+ error = ne.iErrorCode[event_bit];
+ } else if (ne.lNetworkEvents & FD_CLOSE_BIT && ne.iErrorCode[FD_CLOSE_BIT]) {
+ LOGDEBUG (g_message ("%06d - FD_CLOSE error %d on socket %d", GetCurrentThreadId (), ne.iErrorCode[FD_CLOSE_BIT], sock));
+ error = ne.iErrorCode[FD_CLOSE_BIT];
+ } else {
+ LOGDEBUG (g_message ("%06d - WSAEnumNetworkEvents () finished successfully on socket %d", GetCurrentThreadId (), sock));
+ success = TRUE;
+ error = 0;
+ }
+ }
+ }
+ WSAEventSelect (sock, NULL, 0);
+ }
+ WSACloseEvent (event);
+ }
+ if (error != -1) {
+ WSASetLastError (error);
+ }
+ return success;
+}
+
+#define ALERTABLE_SOCKET_CALL(event_bit, blocking, repeat, ret, op, sock, ...) \
+ LOGDEBUG (g_message ("%06d - Performing %s " #op " () on socket %d", GetCurrentThreadId (), blocking ? "blocking" : "non-blocking", sock)); \
+ if (blocking) { \
+ if (set_blocking(sock, FALSE)) { \
+ while (-1 == (int) (ret = op (sock, __VA_ARGS__))) { \
+ int _error = WSAGetLastError ();\
+ if (_error != WSAEWOULDBLOCK && _error != WSA_IO_PENDING) \
+ break; \
+ if (!alertable_socket_wait (sock, event_bit) || !repeat) \
+ break; \
+ } \
+ int _saved_error = WSAGetLastError (); \
+ set_blocking (sock, TRUE); \
+ WSASetLastError (_saved_error); \
+ } \
+ } else { \
+ ret = op (sock, __VA_ARGS__); \
+ } \
+ int _saved_error = WSAGetLastError (); \
+ LOGDEBUG (g_message ("%06d - Finished %s " #op " () on socket %d (ret = %d, WSAGetLastError() = %d)", GetCurrentThreadId (), \
+ blocking ? "blocking" : "non-blocking", sock, ret, _saved_error)); \
+ WSASetLastError (_saved_error);
+
+SOCKET mono_w32socket_accept (SOCKET s, struct sockaddr *addr, socklen_t *addrlen, gboolean blocking)
+{
+ MonoInternalThread *curthread = mono_thread_internal_current ();
+ SOCKET newsock = INVALID_SOCKET;
+ curthread->interrupt_on_stop = (gpointer)TRUE;
+ ALERTABLE_SOCKET_CALL (FD_ACCEPT_BIT, blocking, TRUE, newsock, accept, s, addr, addrlen);
+ curthread->interrupt_on_stop = (gpointer)FALSE;
+ return newsock;
+}
+
+int mono_w32socket_connect (SOCKET s, const struct sockaddr *name, int namelen, gboolean blocking)
+{
+ int ret = SOCKET_ERROR;
+ ALERTABLE_SOCKET_CALL (FD_CONNECT_BIT, blocking, FALSE, ret, connect, s, name, namelen);
+ ret = WSAGetLastError () != 0 ? SOCKET_ERROR : 0;
+ return ret;
+}
+
+int mono_w32socket_recv (SOCKET s, char *buf, int len, int flags, gboolean blocking)
+{
+ MonoInternalThread *curthread = mono_thread_internal_current ();
+ int ret = SOCKET_ERROR;
+ curthread->interrupt_on_stop = (gpointer)TRUE;
+ ALERTABLE_SOCKET_CALL (FD_READ_BIT, blocking, TRUE, ret, recv, s, buf, len, flags);
+ curthread->interrupt_on_stop = (gpointer)FALSE;
+ return ret;
+}
+
+int mono_w32socket_recvfrom (SOCKET s, char *buf, int len, int flags, struct sockaddr *from, socklen_t *fromlen, gboolean blocking)
+{
+ int ret = SOCKET_ERROR;
+ ALERTABLE_SOCKET_CALL (FD_READ_BIT, blocking, TRUE, ret, recvfrom, s, buf, len, flags, from, fromlen);
+ return ret;
+}
+
+int mono_w32socket_recvbuffers (SOCKET s, WSABUF *lpBuffers, guint32 dwBufferCount, guint32 *lpNumberOfBytesRecvd, guint32 *lpFlags, gpointer lpOverlapped, gpointer lpCompletionRoutine, gboolean blocking)
+{
+ int ret = SOCKET_ERROR;
+ ALERTABLE_SOCKET_CALL (FD_READ_BIT, blocking, TRUE, ret, WSARecv, s, lpBuffers, dwBufferCount, lpNumberOfBytesRecvd, lpFlags, lpOverlapped, lpCompletionRoutine);
+ return ret;
+}
+
+int mono_w32socket_send (SOCKET s, char *buf, int len, int flags, gboolean blocking)
+{
+ int ret = SOCKET_ERROR;
+ ALERTABLE_SOCKET_CALL (FD_WRITE_BIT, blocking, FALSE, ret, send, s, buf, len, flags);
+ return ret;
+}
+
+int mono_w32socket_sendto (SOCKET s, const char *buf, int len, int flags, const struct sockaddr *to, int tolen, gboolean blocking)
+{
+ int ret = SOCKET_ERROR;
+ ALERTABLE_SOCKET_CALL (FD_WRITE_BIT, blocking, FALSE, ret, sendto, s, buf, len, flags, to, tolen);
+ return ret;
+}
+
+int mono_w32socket_sendbuffers (SOCKET s, WSABUF *lpBuffers, guint32 dwBufferCount, guint32 *lpNumberOfBytesRecvd, guint32 lpFlags, gpointer lpOverlapped, gpointer lpCompletionRoutine, gboolean blocking)
+{
+ int ret = SOCKET_ERROR;
+ ALERTABLE_SOCKET_CALL (FD_WRITE_BIT, blocking, FALSE, ret, WSASend, s, lpBuffers, dwBufferCount, lpNumberOfBytesRecvd, lpFlags, lpOverlapped, lpCompletionRoutine);
+ return ret;
+}
+
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
+BOOL mono_w32socket_transmit_file (SOCKET hSocket, gpointer hFile, TRANSMIT_FILE_BUFFERS *lpTransmitBuffers, guint32 dwReserved, gboolean blocking)
+{
+ LOGDEBUG (g_message ("%06d - Performing %s TransmitFile () on socket %d", GetCurrentThreadId (), blocking ? "blocking" : "non-blocking", hSocket));
+
+ int error = 0;
+ if (blocking) {
+ OVERLAPPED overlapped = { 0 };
+ overlapped.hEvent = WSACreateEvent ();
+ if (overlapped.hEvent == WSA_INVALID_EVENT)
+ return FALSE;
+ if (!TransmitFile (hSocket, hFile, 0, 0, &overlapped, lpTransmitBuffers, dwReserved)) {
+ error = WSAGetLastError ();
+ if (error == WSA_IO_PENDING) {
+ error = 0;
+ // NOTE: .NET's Socket.SendFile() doesn't honor the Socket's SendTimeout so we shouldn't either
+ DWORD ret = WaitForSingleObjectEx (overlapped.hEvent, INFINITE, TRUE);
+ if (ret == WAIT_IO_COMPLETION) {
+ LOGDEBUG (g_message ("%06d - WaitForSingleObjectEx () returned WSA_WAIT_IO_COMPLETION for socket %d", GetCurrentThreadId (), hSocket));
+ error = WSAEINTR;
+ } else if (ret == WAIT_TIMEOUT) {
+ error = WSAETIMEDOUT;
+ } else if (ret != WAIT_OBJECT_0) {
+ error = GetLastError ();
+ }
+ }
+ }
+ WSACloseEvent (overlapped.hEvent);
+ } else {
+ if (!TransmitFile (hSocket, hFile, 0, 0, NULL, lpTransmitBuffers, dwReserved)) {
+ error = WSAGetLastError ();
+ }
+ }
+
+ LOGDEBUG (g_message ("%06d - Finished %s TransmitFile () on socket %d (ret = %d, WSAGetLastError() = %d)", GetCurrentThreadId (), \
+ blocking ? "blocking" : "non-blocking", hSocket, error == 0, error));
+ WSASetLastError (error);
+
+ return error == 0;
+}
+#endif /* #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
+
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
+gint
+mono_w32socket_disconnect (SOCKET sock, gboolean reuse)
+{
+ LPFN_DISCONNECTEX disconnect;
+ LPFN_TRANSMITFILE transmit_file;
+ DWORD output_bytes;
+ gint ret;
+
+ /* Use the SIO_GET_EXTENSION_FUNCTION_POINTER to determine
+ * the address of the disconnect method without taking
+ * a hard dependency on a single provider
+ *
+ * For an explanation of why this is done, you can read the
+ * article at http://www.codeproject.com/internet/jbsocketserver3.asp
+ *
+ * I _think_ the extension function pointers need to be looked
+ * up for each socket.
+ *
+ * FIXME: check the best way to store pointers to functions in
+ * managed objects that still works on 64bit platforms. */
+
+ GUID disconnect_guid = WSAID_DISCONNECTEX;
+ ret = WSAIoctl (sock, SIO_GET_EXTENSION_FUNCTION_POINTER, &disconnect_guid, sizeof (GUID), &disconnect, sizeof (LPFN_DISCONNECTEX), &output_bytes, NULL, NULL);
+ if (ret == 0) {
+ if (!disconnect (sock, NULL, reuse ? TF_REUSE_SOCKET : 0, 0))
+ return WSAGetLastError ();
+
+ return 0;
+ }
+
+ GUID transmit_file_guid = WSAID_TRANSMITFILE;
+ ret = WSAIoctl (sock, SIO_GET_EXTENSION_FUNCTION_POINTER, &transmit_file_guid, sizeof (GUID), &transmit_file, sizeof (LPFN_TRANSMITFILE), &output_bytes, NULL, NULL);
+ if (ret == 0) {
+ if (!transmit_file (sock, NULL, 0, 0, NULL, NULL, TF_DISCONNECT | (reuse ? TF_REUSE_SOCKET : 0)))
+ return WSAGetLastError ();
+
+ return 0;
+ }
+
+ return ERROR_NOT_SUPPORTED;
+}
+#endif /* #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
+
+gint
+mono_w32socket_set_blocking (SOCKET sock, gboolean blocking)
+{
+ gulong nonblocking_long = !blocking;
+ return ioctlsocket (sock, FIONBIO, &nonblocking_long);
+}
+
+gint
+mono_w32socket_get_available (SOCKET sock, guint64 *amount)
+{
+ return ioctlsocket (sock, FIONREAD, (int*) amount);
+}
+
+void
+mono_w32socket_set_last_error (gint32 error)
+{
+ WSASetLastError (error);
+}
+
+gint32
+mono_w32socket_get_last_error (void)
+{
+ return WSAGetLastError ();
+}
+
+gint32
+mono_w32socket_convert_error (gint error)
+{
+ return (error > 0 && error < WSABASEERR) ? error + WSABASEERR : error;
+}
+
+gboolean
+ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto)
+{
+ return TRUE;
+}
--- /dev/null
+/*
+ * socket-io.c: Socket IO internal calls
+ *
+ * Authors:
+ * Dick Porter (dick@ximian.com)
+ * Gonzalo Paniagua Javier (gonzalo@ximian.com)
+ *
+ * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
+ * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
+ *
+ * This file has been re-licensed under the MIT License:
+ * http://opensource.org/licenses/MIT
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#include <config.h>
+
+#ifndef DISABLE_SOCKETS
+
+#if defined(__APPLE__) || defined(__FreeBSD__)
+#define __APPLE_USE_RFC_3542
+#endif
+
+#include <glib.h>
+#include <string.h>
+#include <stdlib.h>
+#ifdef HOST_WIN32
+#include <ws2tcpip.h>
+#else
+#include <sys/socket.h>
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#include <arpa/inet.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <errno.h>
+
+#include <sys/types.h>
+
+#include <mono/metadata/object.h>
+#include <mono/metadata/exception.h>
+#include <mono/metadata/assembly.h>
+#include <mono/metadata/appdomain.h>
+#include <mono/metadata/w32file.h>
+#include <mono/metadata/threads.h>
+#include <mono/metadata/threads-types.h>
+#include <mono/metadata/threadpool-io.h>
+#include <mono/utils/mono-poll.h>
+/* FIXME change this code to not mess so much with the internals */
+#include <mono/metadata/class-internals.h>
+#include <mono/metadata/domain-internals.h>
+#include <mono/utils/mono-threads.h>
+#include <mono/utils/mono-memory-model.h>
+#include <mono/utils/networking.h>
+#include <mono/metadata/w32handle.h>
+#include <mono/metadata/w32socket.h>
+#include <mono/metadata/w32socket-internals.h>
+#include <mono/metadata/w32error.h>
+
+#include <time.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
+
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#ifdef HAVE_SYS_FILIO_H
+#include <sys/filio.h> /* defines FIONBIO and FIONREAD */
+#endif
+#ifdef HAVE_SYS_SOCKIO_H
+#include <sys/sockio.h> /* defines SIOCATMARK */
+#endif
+#ifdef HAVE_SYS_UN_H
+#include <sys/un.h>
+#endif
+
+#ifdef HAVE_GETIFADDRS
+// <net/if.h> must be included before <ifaddrs.h>
+#include <ifaddrs.h>
+#endif
+
+#if defined(_MSC_VER) && G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
+#include <MSWSock.h>
+#endif
+
+#define LOGDEBUG(...)
+/* define LOGDEBUG(...) g_message(__VA_ARGS__) */
+
+#ifdef HOST_WIN32
+
+static SOCKET
+mono_w32socket_socket (int domain, int type, int protocol)
+{
+ return WSASocket (domain, type, protocol, NULL, 0, WSA_FLAG_OVERLAPPED);
+}
+
+static gint
+mono_w32socket_bind (SOCKET sock, struct sockaddr *addr, socklen_t addrlen)
+{
+ return bind (sock, addr, addrlen);
+}
+
+static gint
+mono_w32socket_getpeername (SOCKET sock, struct sockaddr *name, socklen_t *namelen)
+{
+ return getpeername (sock, name, namelen);
+}
+
+static gint
+mono_w32socket_getsockname (SOCKET sock, struct sockaddr *name, socklen_t *namelen)
+{
+ return getsockname (sock, name, namelen);
+}
+
+static gint
+mono_w32socket_getsockopt (SOCKET sock, gint level, gint optname, gpointer optval, socklen_t *optlen)
+{
+ return getsockopt (sock, level, optname, optval, optlen);
+}
+
+static gint
+mono_w32socket_setsockopt (SOCKET sock, gint level, gint optname, const gpointer optval, socklen_t optlen)
+{
+ return setsockopt (sock, level, optname, optval, optlen);
+}
+
+static gint
+mono_w32socket_listen (SOCKET sock, gint backlog)
+{
+ return listen (sock, backlog);
+}
+
+static gint
+mono_w32socket_shutdown (SOCKET sock, gint how)
+{
+ return shutdown (sock, how);
+}
+
+static gint
+mono_w32socket_ioctl (SOCKET sock, gint32 command, gchar *input, gint inputlen, gchar *output, gint outputlen, glong *written)
+{
+ return WSAIoctl (sock, command, input, inputlen, output, outputlen, written, NULL, NULL);
+}
+
+static gboolean
+mono_w32socket_close (SOCKET sock)
+{
+ return CloseHandle (sock);
+}
+
+#endif /* HOST_WIN32 */
+
+static void
+abort_syscall (gpointer data)
+{
+ mono_thread_info_abort_socket_syscall_for_close ((MonoNativeThreadId) (gsize) data);
+}
+
+static gint32
+convert_family (MonoAddressFamily mono_family)
+{
+ switch (mono_family) {
+ case AddressFamily_Unknown:
+ case AddressFamily_ImpLink:
+ case AddressFamily_Pup:
+ case AddressFamily_Chaos:
+ case AddressFamily_Iso:
+ case AddressFamily_Ecma:
+ case AddressFamily_DataKit:
+ case AddressFamily_Ccitt:
+ case AddressFamily_DataLink:
+ case AddressFamily_Lat:
+ case AddressFamily_HyperChannel:
+ case AddressFamily_NetBios:
+ case AddressFamily_VoiceView:
+ case AddressFamily_FireFox:
+ case AddressFamily_Banyan:
+ case AddressFamily_Atm:
+ case AddressFamily_Cluster:
+ case AddressFamily_Ieee12844:
+ case AddressFamily_NetworkDesigners:
+ g_warning ("System.Net.Sockets.AddressFamily has unsupported value 0x%x", mono_family);
+ return -1;
+ case AddressFamily_Unspecified:
+ return AF_UNSPEC;
+ case AddressFamily_Unix:
+ return AF_UNIX;
+ case AddressFamily_InterNetwork:
+ return AF_INET;
+ case AddressFamily_AppleTalk:
+ return AF_APPLETALK;
+ case AddressFamily_InterNetworkV6:
+ return AF_INET6;
+ case AddressFamily_DecNet:
+#ifdef AF_DECnet
+ return AF_DECnet;
+#else
+ return -1;
+#endif
+ case AddressFamily_Ipx:
+#ifdef AF_IPX
+ return AF_IPX;
+#else
+ return -1;
+#endif
+ case AddressFamily_Sna:
+#ifdef AF_SNA
+ return AF_SNA;
+#else
+ return -1;
+#endif
+ case AddressFamily_Irda:
+#ifdef AF_IRDA
+ return AF_IRDA;
+#else
+ return -1;
+#endif
+ default:
+ g_warning ("System.Net.Sockets.AddressFamily has unknown value 0x%x", mono_family);
+ return -1;
+ }
+}
+
+static MonoAddressFamily
+convert_to_mono_family (guint16 af_family)
+{
+ switch (af_family) {
+ case AF_UNSPEC:
+ return AddressFamily_Unspecified;
+ case AF_UNIX:
+ return AddressFamily_Unix;
+ case AF_INET:
+ return AddressFamily_InterNetwork;
+#ifdef AF_IPX
+ case AF_IPX:
+ return AddressFamily_Ipx;
+#endif
+#ifdef AF_SNA
+ case AF_SNA:
+ return AddressFamily_Sna;
+#endif
+#ifdef AF_DECnet
+ case AF_DECnet:
+ return AddressFamily_DecNet;
+#endif
+ case AF_APPLETALK:
+ return AddressFamily_AppleTalk;
+ case AF_INET6:
+ return AddressFamily_InterNetworkV6;
+#ifdef AF_IRDA
+ case AF_IRDA:
+ return AddressFamily_Irda;
+#endif
+ default:
+ g_warning ("unknown address family 0x%x", af_family);
+ return AddressFamily_Unknown;
+ }
+}
+
+static gint32
+convert_type (MonoSocketType mono_type)
+{
+ switch (mono_type) {
+ case SocketType_Stream:
+ return SOCK_STREAM;
+ case SocketType_Dgram:
+ return SOCK_DGRAM;
+ case SocketType_Raw:
+ return SOCK_RAW;
+ case SocketType_Rdm:
+#ifdef SOCK_RDM
+ return SOCK_RDM;
+#else
+ return -1;
+#endif
+ case SocketType_Seqpacket:
+ return SOCK_SEQPACKET;
+ case SocketType_Unknown:
+ g_warning ("System.Net.Sockets.SocketType has unsupported value 0x%x", mono_type);
+ return -1;
+ default:
+ g_warning ("System.Net.Sockets.SocketType has unknown value 0x%x", mono_type);
+ return -1;
+ }
+}
+
+static gint32
+convert_proto (MonoProtocolType mono_proto)
+{
+ switch (mono_proto) {
+ case ProtocolType_IP:
+ case ProtocolType_IPv6:
+ case ProtocolType_Icmp:
+ case ProtocolType_Igmp:
+ case ProtocolType_Ggp:
+ case ProtocolType_Tcp:
+ case ProtocolType_Pup:
+ case ProtocolType_Udp:
+ case ProtocolType_Idp:
+ /* These protocols are known (on my system at least) */
+ return mono_proto;
+ case ProtocolType_ND:
+ case ProtocolType_Raw:
+ case ProtocolType_Ipx:
+ case ProtocolType_Spx:
+ case ProtocolType_SpxII:
+ case ProtocolType_Unknown:
+ /* These protocols arent */
+ g_warning ("System.Net.Sockets.ProtocolType has unsupported value 0x%x", mono_proto);
+ return -1;
+ default:
+ return -1;
+ }
+}
+
+/* Convert MonoSocketFlags */
+static gint32
+convert_socketflags (gint32 sflags)
+{
+ gint32 flags = 0;
+
+ if (!sflags)
+ /* SocketFlags.None */
+ return 0;
+
+ if (sflags & ~(SocketFlags_OutOfBand | SocketFlags_MaxIOVectorLength | SocketFlags_Peek |
+ SocketFlags_DontRoute | SocketFlags_Partial))
+ /* Contains invalid flag values */
+ return -1;
+
+ if (sflags & SocketFlags_OutOfBand)
+ flags |= MSG_OOB;
+ if (sflags & SocketFlags_Peek)
+ flags |= MSG_PEEK;
+ if (sflags & SocketFlags_DontRoute)
+ flags |= MSG_DONTROUTE;
+
+ /* Ignore Partial - see bug 349688. Don't return -1, because
+ * according to the comment in that bug ms runtime doesn't for
+ * UDP sockets (this means we will silently ignore it for TCP
+ * too)
+ */
+#ifdef MSG_MORE
+ if (sflags & SocketFlags_Partial)
+ flags |= MSG_MORE;
+#endif
+#if 0
+ /* Don't do anything for MaxIOVectorLength */
+ if (sflags & SocketFlags_MaxIOVectorLength)
+ return -1;
+#endif
+ return flags;
+}
+
+/*
+ * Returns:
+ * 0 on success (mapped mono_level and mono_name to system_level and system_name
+ * -1 on error
+ * -2 on non-fatal error (ie, must ignore)
+ */
+static gint32
+convert_sockopt_level_and_name (MonoSocketOptionLevel mono_level, MonoSocketOptionName mono_name, int *system_level, int *system_name)
+{
+ switch (mono_level) {
+ case SocketOptionLevel_Socket:
+ *system_level = SOL_SOCKET;
+
+ switch (mono_name) {
+ case SocketOptionName_DontLinger:
+ /* This is SO_LINGER, because the setsockopt
+ * internal call maps DontLinger to SO_LINGER
+ * with l_onoff=0
+ */
+ *system_name = SO_LINGER;
+ break;
+ case SocketOptionName_Debug:
+ *system_name = SO_DEBUG;
+ break;
+#ifdef SO_ACCEPTCONN
+ case SocketOptionName_AcceptConnection:
+ *system_name = SO_ACCEPTCONN;
+ break;
+#endif
+ case SocketOptionName_ReuseAddress:
+ *system_name = SO_REUSEADDR;
+ break;
+ case SocketOptionName_KeepAlive:
+ *system_name = SO_KEEPALIVE;
+ break;
+ case SocketOptionName_DontRoute:
+ *system_name = SO_DONTROUTE;
+ break;
+ case SocketOptionName_Broadcast:
+ *system_name = SO_BROADCAST;
+ break;
+ case SocketOptionName_Linger:
+ *system_name = SO_LINGER;
+ break;
+ case SocketOptionName_OutOfBandInline:
+ *system_name = SO_OOBINLINE;
+ break;
+ case SocketOptionName_SendBuffer:
+ *system_name = SO_SNDBUF;
+ break;
+ case SocketOptionName_ReceiveBuffer:
+ *system_name = SO_RCVBUF;
+ break;
+ case SocketOptionName_SendLowWater:
+ *system_name = SO_SNDLOWAT;
+ break;
+ case SocketOptionName_ReceiveLowWater:
+ *system_name = SO_RCVLOWAT;
+ break;
+ case SocketOptionName_SendTimeout:
+ *system_name = SO_SNDTIMEO;
+ break;
+ case SocketOptionName_ReceiveTimeout:
+ *system_name = SO_RCVTIMEO;
+ break;
+ case SocketOptionName_Error:
+ *system_name = SO_ERROR;
+ break;
+ case SocketOptionName_Type:
+ *system_name = SO_TYPE;
+ break;
+#ifdef SO_PEERCRED
+ case SocketOptionName_PeerCred:
+ *system_name = SO_PEERCRED;
+ break;
+#endif
+ case SocketOptionName_ExclusiveAddressUse:
+#ifdef SO_EXCLUSIVEADDRUSE
+ *system_name = SO_EXCLUSIVEADDRUSE;
+ break;
+#endif
+ case SocketOptionName_UseLoopback:
+#ifdef SO_USELOOPBACK
+ *system_name = SO_USELOOPBACK;
+ break;
+#endif
+ case SocketOptionName_MaxConnections:
+#ifdef SO_MAXCONN
+ *system_name = SO_MAXCONN;
+ break;
+#elif defined(SOMAXCONN)
+ *system_name = SOMAXCONN;
+ break;
+#endif
+ default:
+ g_warning ("System.Net.Sockets.SocketOptionName 0x%x is not supported at Socket level", mono_name);
+ return -1;
+ }
+ break;
+
+ case SocketOptionLevel_IP:
+ *system_level = mono_networking_get_ip_protocol ();
+
+ switch (mono_name) {
+ case SocketOptionName_IPOptions:
+ *system_name = IP_OPTIONS;
+ break;
+#ifdef IP_HDRINCL
+ case SocketOptionName_HeaderIncluded:
+ *system_name = IP_HDRINCL;
+ break;
+#endif
+#ifdef IP_TOS
+ case SocketOptionName_TypeOfService:
+ *system_name = IP_TOS;
+ break;
+#endif
+#ifdef IP_TTL
+ case SocketOptionName_IpTimeToLive:
+ *system_name = IP_TTL;
+ break;
+#endif
+ case SocketOptionName_MulticastInterface:
+ *system_name = IP_MULTICAST_IF;
+ break;
+ case SocketOptionName_MulticastTimeToLive:
+ *system_name = IP_MULTICAST_TTL;
+ break;
+ case SocketOptionName_MulticastLoopback:
+ *system_name = IP_MULTICAST_LOOP;
+ break;
+ case SocketOptionName_AddMembership:
+ *system_name = IP_ADD_MEMBERSHIP;
+ break;
+ case SocketOptionName_DropMembership:
+ *system_name = IP_DROP_MEMBERSHIP;
+ break;
+#ifdef HAVE_IP_PKTINFO
+ case SocketOptionName_PacketInformation:
+ *system_name = IP_PKTINFO;
+ break;
+#endif /* HAVE_IP_PKTINFO */
+
+ case SocketOptionName_DontFragment:
+#ifdef HAVE_IP_DONTFRAGMENT
+ *system_name = IP_DONTFRAGMENT;
+ break;
+#elif defined HAVE_IP_MTU_DISCOVER
+ /* Not quite the same */
+ *system_name = IP_MTU_DISCOVER;
+ break;
+#else
+ /* If the flag is not available on this system, we can ignore this error */
+ return -2;
+#endif /* HAVE_IP_DONTFRAGMENT */
+ case SocketOptionName_AddSourceMembership:
+ case SocketOptionName_DropSourceMembership:
+ case SocketOptionName_BlockSource:
+ case SocketOptionName_UnblockSource:
+ /* Can't figure out how to map these, so fall
+ * through
+ */
+ default:
+ g_warning ("System.Net.Sockets.SocketOptionName 0x%x is not supported at IP level", mono_name);
+ return -1;
+ }
+ break;
+
+ case SocketOptionLevel_IPv6:
+ *system_level = mono_networking_get_ipv6_protocol ();
+
+ switch (mono_name) {
+ case SocketOptionName_IpTimeToLive:
+ case SocketOptionName_HopLimit:
+ *system_name = IPV6_UNICAST_HOPS;
+ break;
+ case SocketOptionName_MulticastInterface:
+ *system_name = IPV6_MULTICAST_IF;
+ break;
+ case SocketOptionName_MulticastTimeToLive:
+ *system_name = IPV6_MULTICAST_HOPS;
+ break;
+ case SocketOptionName_MulticastLoopback:
+ *system_name = IPV6_MULTICAST_LOOP;
+ break;
+ case SocketOptionName_AddMembership:
+ *system_name = IPV6_JOIN_GROUP;
+ break;
+ case SocketOptionName_DropMembership:
+ *system_name = IPV6_LEAVE_GROUP;
+ break;
+ case SocketOptionName_IPv6Only:
+#ifdef IPV6_V6ONLY
+ *system_name = IPV6_V6ONLY;
+#else
+ return -1;
+#endif
+ break;
+ case SocketOptionName_PacketInformation:
+#ifdef HAVE_IPV6_PKTINFO
+ *system_name = IPV6_PKTINFO;
+#endif
+ break;
+ case SocketOptionName_HeaderIncluded:
+ case SocketOptionName_IPOptions:
+ case SocketOptionName_TypeOfService:
+ case SocketOptionName_DontFragment:
+ case SocketOptionName_AddSourceMembership:
+ case SocketOptionName_DropSourceMembership:
+ case SocketOptionName_BlockSource:
+ case SocketOptionName_UnblockSource:
+ /* Can't figure out how to map these, so fall
+ * through
+ */
+ default:
+ g_warning ("System.Net.Sockets.SocketOptionName 0x%x is not supported at IPv6 level", mono_name);
+ return -1;
+ }
+ break; /* SocketOptionLevel_IPv6 */
+
+ case SocketOptionLevel_Tcp:
+ *system_level = mono_networking_get_tcp_protocol ();
+
+ switch (mono_name) {
+ case SocketOptionName_NoDelay:
+ *system_name = TCP_NODELAY;
+ break;
+#if 0
+ /* The documentation is talking complete
+ * bollocks here: rfc-1222 is titled
+ * 'Advancing the NSFNET Routing Architecture'
+ * and doesn't mention either of the words
+ * "expedite" or "urgent".
+ */
+ case SocketOptionName_BsdUrgent:
+ case SocketOptionName_Expedited:
+#endif
+ default:
+ g_warning ("System.Net.Sockets.SocketOptionName 0x%x is not supported at TCP level", mono_name);
+ return -1;
+ }
+ break;
+
+ case SocketOptionLevel_Udp:
+ g_warning ("System.Net.Sockets.SocketOptionLevel has unsupported value 0x%x", mono_level);
+
+ switch(mono_name) {
+ case SocketOptionName_NoChecksum:
+ case SocketOptionName_ChecksumCoverage:
+ default:
+ g_warning ("System.Net.Sockets.SocketOptionName 0x%x is not supported at UDP level", mono_name);
+ return -1;
+ }
+ return -1;
+ break;
+
+ default:
+ g_warning ("System.Net.Sockets.SocketOptionLevel has unknown value 0x%x", mono_level);
+ return -1;
+ }
+
+ return 0;
+}
+
+static MonoImage*
+get_socket_assembly (void)
+{
+ MonoDomain *domain = mono_domain_get ();
+
+ if (domain->socket_assembly == NULL) {
+ MonoImage *socket_assembly;
+
+ socket_assembly = mono_image_loaded ("System");
+ if (!socket_assembly) {
+ MonoAssembly *sa = mono_assembly_open ("System.dll", NULL);
+
+ if (!sa) {
+ g_assert_not_reached ();
+ } else {
+ socket_assembly = mono_assembly_get_image (sa);
+ }
+ }
+ mono_atomic_store_release (&domain->socket_assembly, socket_assembly);
+ }
+
+ return domain->socket_assembly;
+}
+
+gpointer
+ves_icall_System_Net_Sockets_Socket_Socket_internal (MonoObject *this_obj, gint32 family, gint32 type, gint32 proto, gint32 *werror)
+{
+ SOCKET sock;
+ gint32 sock_family;
+ gint32 sock_proto;
+ gint32 sock_type;
+
+ *werror = 0;
+
+ sock_family = convert_family ((MonoAddressFamily)family);
+ if (sock_family == -1) {
+ *werror = WSAEAFNOSUPPORT;
+ return NULL;
+ }
+
+ sock_proto = convert_proto ((MonoProtocolType)proto);
+ if (sock_proto == -1) {
+ *werror = WSAEPROTONOSUPPORT;
+ return NULL;
+ }
+
+ sock_type = convert_type ((MonoSocketType)type);
+ if (sock_type == -1) {
+ *werror = WSAESOCKTNOSUPPORT;
+ return NULL;
+ }
+
+ sock = mono_w32socket_socket (sock_family, sock_type, sock_proto);
+
+ if (sock == INVALID_SOCKET) {
+ *werror = mono_w32socket_get_last_error ();
+ return NULL;
+ }
+
+ return GUINT_TO_POINTER (sock);
+}
+
+/* FIXME: the SOCKET parameter (here and in other functions in this
+ * file) is really an IntPtr which needs to be converted to a guint32.
+ */
+void
+ves_icall_System_Net_Sockets_Socket_Close_internal (gsize sock, gint32 *werror)
+{
+ LOGDEBUG (g_message ("%s: closing 0x%x", __func__, sock));
+
+ *werror = 0;
+
+ /* Clear any pending work item from this socket if the underlying
+ * polling system does not notify when the socket is closed */
+ mono_threadpool_io_remove_socket (GPOINTER_TO_INT (sock));
+
+ MONO_ENTER_GC_SAFE;
+ mono_w32socket_close ((SOCKET) sock);
+ MONO_EXIT_GC_SAFE;
+}
+
+gint32
+ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal (void)
+{
+ LOGDEBUG (g_message("%s: returning %d", __func__, mono_w32socket_get_last_error ()));
+
+ return mono_w32socket_get_last_error ();
+}
+
+gint32
+ves_icall_System_Net_Sockets_Socket_Available_internal (gsize sock, gint32 *werror)
+{
+ int ret;
+ guint64 amount;
+
+ *werror = 0;
+
+ /* FIXME: this might require amount to be unsigned long. */
+ ret = mono_w32socket_get_available (sock, &amount);
+ if (ret == SOCKET_ERROR) {
+ *werror = mono_w32socket_get_last_error ();
+ return 0;
+ }
+
+ return amount;
+}
+
+void
+ves_icall_System_Net_Sockets_Socket_Blocking_internal (gsize sock, gboolean block, gint32 *werror)
+{
+ int ret;
+
+ *werror = 0;
+
+ ret = mono_w32socket_set_blocking (sock, block);
+ if (ret == SOCKET_ERROR)
+ *werror = mono_w32socket_get_last_error ();
+}
+
+gpointer
+ves_icall_System_Net_Sockets_Socket_Accept_internal (gsize sock, gint32 *werror, gboolean blocking)
+{
+ gboolean interrupted;
+ SOCKET newsock;
+
+ *werror = 0;
+
+ mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
+ if (interrupted) {
+ *werror = WSAEINTR;
+ return NULL;
+ }
+
+ MONO_ENTER_GC_SAFE;
+ newsock = mono_w32socket_accept (sock, NULL, 0, blocking);
+ MONO_EXIT_GC_SAFE;
+
+ if (newsock == INVALID_SOCKET)
+ *werror = mono_w32socket_get_last_error ();
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted)
+ *werror = WSAEINTR;
+
+ if (*werror)
+ return NULL;
+
+ return GUINT_TO_POINTER (newsock);
+}
+
+void
+ves_icall_System_Net_Sockets_Socket_Listen_internal(gsize sock, guint32 backlog, gint32 *werror)
+{
+ int ret;
+
+ *werror = 0;
+
+ MONO_ENTER_GC_SAFE;
+
+ ret = mono_w32socket_listen (sock, backlog);
+
+ MONO_EXIT_GC_SAFE;
+
+ if (ret == SOCKET_ERROR)
+ *werror = mono_w32socket_get_last_error ();
+}
+
+// Check whether it's ::ffff::0:0.
+static gboolean
+is_ipv4_mapped_any (const struct in6_addr *addr)
+{
+ int i;
+
+ for (i = 0; i < 10; i++) {
+ if (addr->s6_addr [i])
+ return FALSE;
+ }
+ if ((addr->s6_addr [10] != 0xff) || (addr->s6_addr [11] != 0xff))
+ return FALSE;
+ for (i = 12; i < 16; i++) {
+ if (addr->s6_addr [i])
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static MonoObject*
+create_object_from_sockaddr (struct sockaddr *saddr, int sa_size, gint32 *werror, MonoError *error)
+{
+ MonoDomain *domain = mono_domain_get ();
+ MonoObject *sockaddr_obj;
+ MonoArray *data;
+ MonoAddressFamily family;
+
+ mono_error_init (error);
+
+ /* Build a System.Net.SocketAddress object instance */
+ if (!domain->sockaddr_class)
+ domain->sockaddr_class = mono_class_load_from_name (get_socket_assembly (), "System.Net", "SocketAddress");
+ sockaddr_obj = mono_object_new_checked (domain, domain->sockaddr_class, error);
+ return_val_if_nok (error, NULL);
+
+ /* Locate the SocketAddress data buffer in the object */
+ if (!domain->sockaddr_data_field) {
+ domain->sockaddr_data_field = mono_class_get_field_from_name (domain->sockaddr_class, "m_Buffer");
+ g_assert (domain->sockaddr_data_field);
+ }
+
+ /* Locate the SocketAddress data buffer length in the object */
+ if (!domain->sockaddr_data_length_field) {
+ domain->sockaddr_data_length_field = mono_class_get_field_from_name (domain->sockaddr_class, "m_Size");
+ g_assert (domain->sockaddr_data_length_field);
+ }
+
+ /* May be the +2 here is too conservative, as sa_len returns
+ * the length of the entire sockaddr_in/in6, including
+ * sizeof (unsigned short) of the family */
+ /* We can't really avoid the +2 as all code below depends on this size - INCLUDING unix domain sockets.*/
+ data = mono_array_new_cached (domain, mono_get_byte_class (), sa_size + 2, error);
+ return_val_if_nok (error, NULL);
+
+ /* The data buffer is laid out as follows:
+ * bytes 0 and 1 are the address family
+ * bytes 2 and 3 are the port info
+ * the rest is the address info
+ */
+
+ family = convert_to_mono_family (saddr->sa_family);
+ if (family == AddressFamily_Unknown) {
+ *werror = WSAEAFNOSUPPORT;
+ return NULL;
+ }
+
+ mono_array_set (data, guint8, 0, family & 0x0FF);
+ mono_array_set (data, guint8, 1, (family >> 8) & 0x0FF);
+
+ if (saddr->sa_family == AF_INET) {
+ struct sockaddr_in *sa_in = (struct sockaddr_in *)saddr;
+ guint16 port = ntohs (sa_in->sin_port);
+ guint32 address = ntohl (sa_in->sin_addr.s_addr);
+ int buffer_size = 8;
+
+ if (sa_size < buffer_size) {
+ mono_error_set_exception_instance (error, mono_exception_from_name (mono_get_corlib (), "System", "SystemException"));
+ return NULL;
+ }
+
+ mono_array_set (data, guint8, 2, (port>>8) & 0xff);
+ mono_array_set (data, guint8, 3, (port) & 0xff);
+ mono_array_set (data, guint8, 4, (address>>24) & 0xff);
+ mono_array_set (data, guint8, 5, (address>>16) & 0xff);
+ mono_array_set (data, guint8, 6, (address>>8) & 0xff);
+ mono_array_set (data, guint8, 7, (address) & 0xff);
+
+ mono_field_set_value (sockaddr_obj, domain->sockaddr_data_field, data);
+ mono_field_set_value (sockaddr_obj, domain->sockaddr_data_length_field, &buffer_size);
+
+ return sockaddr_obj;
+ } else if (saddr->sa_family == AF_INET6) {
+ struct sockaddr_in6 *sa_in = (struct sockaddr_in6 *)saddr;
+ int i;
+ int buffer_size = 28;
+
+ guint16 port = ntohs (sa_in->sin6_port);
+
+ if (sa_size < buffer_size) {
+ mono_error_set_exception_instance (error, mono_exception_from_name (mono_get_corlib (), "System", "SystemException"));
+ return NULL;
+ }
+
+ mono_array_set (data, guint8, 2, (port>>8) & 0xff);
+ mono_array_set (data, guint8, 3, (port) & 0xff);
+
+ if (is_ipv4_mapped_any (&sa_in->sin6_addr)) {
+ // Map ::ffff:0:0 to :: (bug #5502)
+ for (i = 0; i < 16; i++)
+ mono_array_set (data, guint8, 8 + i, 0);
+ } else {
+ for (i = 0; i < 16; i++) {
+ mono_array_set (data, guint8, 8 + i,
+ sa_in->sin6_addr.s6_addr [i]);
+ }
+ }
+
+ mono_array_set (data, guint8, 24, sa_in->sin6_scope_id & 0xff);
+ mono_array_set (data, guint8, 25,
+ (sa_in->sin6_scope_id >> 8) & 0xff);
+ mono_array_set (data, guint8, 26,
+ (sa_in->sin6_scope_id >> 16) & 0xff);
+ mono_array_set (data, guint8, 27,
+ (sa_in->sin6_scope_id >> 24) & 0xff);
+
+ mono_field_set_value (sockaddr_obj, domain->sockaddr_data_field, data);
+ mono_field_set_value (sockaddr_obj, domain->sockaddr_data_length_field, &buffer_size);
+
+ return sockaddr_obj;
+ }
+#ifdef HAVE_SYS_UN_H
+ else if (saddr->sa_family == AF_UNIX) {
+ int i;
+ int buffer_size = sa_size + 2;
+
+ for (i = 0; i < sa_size; i++)
+ mono_array_set (data, guint8, i + 2, saddr->sa_data [i]);
+
+ mono_field_set_value (sockaddr_obj, domain->sockaddr_data_field, data);
+ mono_field_set_value (sockaddr_obj, domain->sockaddr_data_length_field, &buffer_size);
+
+ return sockaddr_obj;
+ }
+#endif
+ else {
+ *werror = WSAEAFNOSUPPORT;
+ return NULL;
+ }
+}
+
+static int
+get_sockaddr_size (int family)
+{
+ int size;
+
+ size = 0;
+ if (family == AF_INET) {
+ size = sizeof (struct sockaddr_in);
+ } else if (family == AF_INET6) {
+ size = sizeof (struct sockaddr_in6);
+ }
+#ifdef HAVE_SYS_UN_H
+ else if (family == AF_UNIX) {
+ size = sizeof (struct sockaddr_un);
+ }
+#endif
+ return size;
+}
+
+MonoObject*
+ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal (gsize sock, gint32 af, gint32 *werror)
+{
+ gchar *sa;
+ socklen_t salen;
+ int ret;
+ MonoObject *result;
+ MonoError error;
+
+ *werror = 0;
+
+ salen = get_sockaddr_size (convert_family ((MonoAddressFamily)af));
+ if (salen == 0) {
+ *werror = WSAEAFNOSUPPORT;
+ return NULL;
+ }
+ sa = (salen <= 128) ? (gchar *)alloca (salen) : (gchar *)g_malloc0 (salen);
+
+ MONO_ENTER_GC_SAFE;
+
+ ret = mono_w32socket_getsockname (sock, (struct sockaddr *)sa, &salen);
+
+ MONO_EXIT_GC_SAFE;
+
+ if (ret == SOCKET_ERROR) {
+ *werror = mono_w32socket_get_last_error ();
+ if (salen > 128)
+ g_free (sa);
+ return NULL;
+ }
+
+ LOGDEBUG (g_message("%s: bound to %s port %d", __func__, inet_ntoa (((struct sockaddr_in *)&sa)->sin_addr), ntohs (((struct sockaddr_in *)&sa)->sin_port)));
+
+ result = create_object_from_sockaddr ((struct sockaddr *)sa, salen, werror, &error);
+ if (salen > 128)
+ g_free (sa);
+ if (!mono_error_ok (&error))
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
+MonoObject*
+ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal (gsize sock, gint32 af, gint32 *werror)
+{
+ gchar *sa;
+ socklen_t salen;
+ int ret;
+ MonoObject *result;
+ MonoError error;
+
+ *werror = 0;
+
+ salen = get_sockaddr_size (convert_family ((MonoAddressFamily)af));
+ if (salen == 0) {
+ *werror = WSAEAFNOSUPPORT;
+ return NULL;
+ }
+ sa = (salen <= 128) ? (gchar *)alloca (salen) : (gchar *)g_malloc0 (salen);
+ /* Note: linux returns just 2 for AF_UNIX. Always. */
+
+ MONO_ENTER_GC_SAFE;
+
+ ret = mono_w32socket_getpeername (sock, (struct sockaddr *)sa, &salen);
+
+ MONO_EXIT_GC_SAFE;
+
+ if (ret == SOCKET_ERROR) {
+ *werror = mono_w32socket_get_last_error ();
+ if (salen > 128)
+ g_free (sa);
+ return NULL;
+ }
+
+ LOGDEBUG (g_message("%s: connected to %s port %d", __func__, inet_ntoa (((struct sockaddr_in *)&sa)->sin_addr), ntohs (((struct sockaddr_in *)&sa)->sin_port)));
+
+ result = create_object_from_sockaddr ((struct sockaddr *)sa, salen, werror, &error);
+ if (salen > 128)
+ g_free (sa);
+ if (!mono_error_ok (&error))
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
+static struct sockaddr*
+create_sockaddr_from_object (MonoObject *saddr_obj, socklen_t *sa_size, gint32 *werror, MonoError *error)
+{
+ MonoDomain *domain = mono_domain_get ();
+ MonoArray *data;
+ gint32 family;
+ int len;
+
+ mono_error_init (error);
+
+ if (!domain->sockaddr_class)
+ domain->sockaddr_class = mono_class_load_from_name (get_socket_assembly (), "System.Net", "SocketAddress");
+
+ /* Locate the SocketAddress data buffer in the object */
+ if (!domain->sockaddr_data_field) {
+ domain->sockaddr_data_field = mono_class_get_field_from_name (domain->sockaddr_class, "m_Buffer");
+ g_assert (domain->sockaddr_data_field);
+ }
+
+ /* Locate the SocketAddress data buffer length in the object */
+ if (!domain->sockaddr_data_length_field) {
+ domain->sockaddr_data_length_field = mono_class_get_field_from_name (domain->sockaddr_class, "m_Size");
+ g_assert (domain->sockaddr_data_length_field);
+ }
+
+ data = *(MonoArray **)(((char *)saddr_obj) + domain->sockaddr_data_field->offset);
+
+ /* The data buffer is laid out as follows:
+ * byte 0 is the address family low byte
+ * byte 1 is the address family high byte
+ * INET:
+ * bytes 2 and 3 are the port info
+ * the rest is the address info
+ * UNIX:
+ * the rest is the file name
+ */
+ len = *(int *)(((char *)saddr_obj) + domain->sockaddr_data_length_field->offset);
+ g_assert (len >= 2);
+
+ family = convert_family ((MonoAddressFamily)(mono_array_get (data, guint8, 0) + (mono_array_get (data, guint8, 1) << 8)));
+ if (family == AF_INET) {
+ struct sockaddr_in *sa;
+ guint16 port;
+ guint32 address;
+
+ if (len < 8) {
+ mono_error_set_exception_instance (error, mono_exception_from_name (mono_get_corlib (), "System", "SystemException"));
+ return NULL;
+ }
+
+ sa = g_new0 (struct sockaddr_in, 1);
+ port = (mono_array_get (data, guint8, 2) << 8) +
+ mono_array_get (data, guint8, 3);
+ address = (mono_array_get (data, guint8, 4) << 24) +
+ (mono_array_get (data, guint8, 5) << 16 ) +
+ (mono_array_get (data, guint8, 6) << 8) +
+ mono_array_get (data, guint8, 7);
+
+ sa->sin_family = family;
+ sa->sin_addr.s_addr = htonl (address);
+ sa->sin_port = htons (port);
+
+ *sa_size = sizeof (struct sockaddr_in);
+ return (struct sockaddr *)sa;
+ } else if (family == AF_INET6) {
+ struct sockaddr_in6 *sa;
+ int i;
+ guint16 port;
+ guint32 scopeid;
+
+ if (len < 28) {
+ mono_error_set_exception_instance (error, mono_exception_from_name (mono_get_corlib (), "System", "SystemException"));
+ return NULL;
+ }
+
+ sa = g_new0 (struct sockaddr_in6, 1);
+ port = mono_array_get (data, guint8, 3) +
+ (mono_array_get (data, guint8, 2) << 8);
+ scopeid = mono_array_get (data, guint8, 24) +
+ (mono_array_get (data, guint8, 25) << 8) +
+ (mono_array_get (data, guint8, 26) << 16) +
+ (mono_array_get (data, guint8, 27) << 24);
+
+ sa->sin6_family = family;
+ sa->sin6_port = htons (port);
+ sa->sin6_scope_id = scopeid;
+
+ for (i = 0; i < 16; i++)
+ sa->sin6_addr.s6_addr [i] = mono_array_get (data, guint8, 8 + i);
+
+ *sa_size = sizeof (struct sockaddr_in6);
+ return (struct sockaddr *)sa;
+ }
+#ifdef HAVE_SYS_UN_H
+ else if (family == AF_UNIX) {
+ struct sockaddr_un *sock_un;
+ int i;
+
+ /* Need a byte for the '\0' terminator/prefix, and the first
+ * two bytes hold the SocketAddress family
+ */
+ if (len - 2 >= sizeof (sock_un->sun_path)) {
+ mono_error_set_exception_instance (error, mono_get_exception_index_out_of_range ());
+ return NULL;
+ }
+
+ sock_un = g_new0 (struct sockaddr_un, 1);
+
+ sock_un->sun_family = family;
+ for (i = 0; i < len - 2; i++)
+ sock_un->sun_path [i] = mono_array_get (data, guint8, i + 2);
+
+ *sa_size = len;
+ return (struct sockaddr *)sock_un;
+ }
+#endif
+ else {
+ *werror = WSAEAFNOSUPPORT;
+ return 0;
+ }
+}
+
+void
+ves_icall_System_Net_Sockets_Socket_Bind_internal (gsize sock, MonoObject *sockaddr, gint32 *werror)
+{
+ MonoError error;
+ struct sockaddr *sa;
+ socklen_t sa_size;
+ int ret;
+
+ *werror = 0;
+
+ sa = create_sockaddr_from_object (sockaddr, &sa_size, werror, &error);
+ if (*werror != 0)
+ return;
+ if (!mono_error_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return;
+ }
+
+ LOGDEBUG (g_message("%s: binding to %s port %d", __func__, inet_ntoa (((struct sockaddr_in *)sa)->sin_addr), ntohs (((struct sockaddr_in *)sa)->sin_port)));
+
+ ret = mono_w32socket_bind (sock, sa, sa_size);
+
+ if (ret == SOCKET_ERROR)
+ *werror = mono_w32socket_get_last_error ();
+
+ g_free (sa);
+}
+
+enum {
+ SelectModeRead,
+ SelectModeWrite,
+ SelectModeError
+};
+
+MonoBoolean
+ves_icall_System_Net_Sockets_Socket_Poll_internal (gsize sock, gint mode,
+ gint timeout, gint32 *werror)
+{
+ MonoInternalThread *thread = mono_thread_internal_current ();
+ mono_pollfd *pfds;
+ int ret;
+ gboolean interrupted;
+ time_t start;
+
+ *werror = 0;
+
+ pfds = g_new0 (mono_pollfd, 1);
+ pfds->fd = GPOINTER_TO_INT (sock);
+
+ switch (mode) {
+ case SelectModeRead:
+ pfds->events = MONO_POLLIN;
+ break;
+ case SelectModeWrite:
+ pfds->events = MONO_POLLOUT;
+ break;
+ default:
+ pfds->events = MONO_POLLERR | MONO_POLLHUP | MONO_POLLNVAL;
+ break;
+ }
+
+ timeout = (timeout >= 0) ? (timeout / 1000) : -1;
+ start = time (NULL);
+
+ do {
+ mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
+ if (interrupted) {
+ g_free (pfds);
+ *werror = WSAEINTR;
+ return FALSE;
+ }
+
+ MONO_ENTER_GC_SAFE;
+
+ ret = mono_poll (pfds, 1, timeout);
+
+ MONO_EXIT_GC_SAFE;
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ g_free (pfds);
+ *werror = WSAEINTR;
+ return FALSE;
+ }
+
+ if (timeout > 0 && ret < 0) {
+ int err = errno;
+ int sec = time (NULL) - start;
+
+ timeout -= sec * 1000;
+ if (timeout < 0) {
+ timeout = 0;
+ }
+
+ errno = err;
+ }
+
+ if (ret == -1 && errno == EINTR) {
+ if (mono_thread_test_state (thread, (MonoThreadState)(ThreadState_AbortRequested | ThreadState_StopRequested))) {
+ g_free (pfds);
+ return FALSE;
+ }
+
+ /* Suspend requested? */
+ mono_thread_interruption_checkpoint ();
+
+ errno = EINTR;
+ }
+ } while (ret == -1 && errno == EINTR);
+
+ if (ret == -1) {
+ *werror = mono_w32socket_convert_error (errno);
+ g_free (pfds);
+ return FALSE;
+ }
+
+ g_free (pfds);
+ return ret != 0;
+}
+
+void
+ves_icall_System_Net_Sockets_Socket_Connect_internal (gsize sock, MonoObject *sockaddr, gint32 *werror, gboolean blocking)
+{
+ MonoError error;
+ struct sockaddr *sa;
+ socklen_t sa_size;
+ int ret;
+ gboolean interrupted;
+
+ *werror = 0;
+
+ sa = create_sockaddr_from_object (sockaddr, &sa_size, werror, &error);
+ if (*werror != 0)
+ return;
+ if (!mono_error_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return;
+ }
+
+ LOGDEBUG (g_message("%s: connecting to %s port %d", __func__, inet_ntoa (((struct sockaddr_in *)sa)->sin_addr), ntohs (((struct sockaddr_in *)sa)->sin_port)));
+
+ mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
+ if (interrupted) {
+ *werror = WSAEINTR;
+ return;
+ }
+
+ MONO_ENTER_GC_SAFE;
+ ret = mono_w32socket_connect (sock, sa, sa_size, blocking);
+ MONO_EXIT_GC_SAFE;
+
+ if (ret == SOCKET_ERROR)
+ *werror = mono_w32socket_get_last_error ();
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted)
+ *werror = WSAEINTR;
+
+ g_free (sa);
+}
+
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
+
+void
+ves_icall_System_Net_Sockets_Socket_Disconnect_internal (gsize sock, MonoBoolean reuse, gint32 *werror)
+{
+ gboolean interrupted;
+
+ LOGDEBUG (g_message("%s: disconnecting from socket %p (reuse %d)", __func__, sock, reuse));
+
+ mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
+ if (interrupted) {
+ *werror = WSAEINTR;
+ return;
+ }
+
+ MONO_ENTER_GC_SAFE;
+ *werror = mono_w32socket_disconnect (sock, reuse);
+ MONO_EXIT_GC_SAFE;
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted)
+ *werror = WSAEINTR;
+}
+#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
+
+gint32
+ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, gint32 *werror, gboolean blocking)
+{
+ int ret;
+ gchar *buf;
+ gint32 alen;
+ int recvflags = 0;
+ gboolean interrupted;
+ MonoInternalThread* curthread G_GNUC_UNUSED = mono_thread_internal_current ();
+
+ *werror = 0;
+
+ alen = mono_array_length (buffer);
+ if (offset > alen - count)
+ return 0;
+
+ buf = mono_array_addr (buffer, gchar, offset);
+
+ recvflags = convert_socketflags (flags);
+ if (recvflags == -1) {
+ *werror = WSAEOPNOTSUPP;
+ return 0;
+ }
+
+ mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
+ if (interrupted)
+ return 0;
+
+ MONO_ENTER_GC_SAFE;
+ ret = mono_w32socket_recv (sock, buf, count, recvflags, blocking);
+ MONO_EXIT_GC_SAFE;
+
+ if (ret == SOCKET_ERROR)
+ *werror = mono_w32socket_get_last_error ();
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted)
+ *werror = WSAEINTR;
+
+ if (*werror)
+ return 0;
+
+ return ret;
+}
+
+gint32
+ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArray *buffers, gint32 flags, gint32 *werror, gboolean blocking)
+{
+ int ret, count;
+ gboolean interrupted;
+ guint32 recv;
+ WSABUF *wsabufs;
+ guint32 recvflags = 0;
+
+ *werror = 0;
+
+ wsabufs = mono_array_addr (buffers, WSABUF, 0);
+ count = mono_array_length (buffers);
+
+ recvflags = convert_socketflags (flags);
+ if (recvflags == -1) {
+ *werror = WSAEOPNOTSUPP;
+ return 0;
+ }
+
+ mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
+ if (interrupted) {
+ *werror = WSAEINTR;
+ return 0;
+ }
+
+ MONO_ENTER_GC_SAFE;
+ ret = mono_w32socket_recvbuffers (sock, wsabufs, count, &recv, &recvflags, NULL, NULL, blocking);
+ MONO_EXIT_GC_SAFE;
+
+ if (ret == SOCKET_ERROR)
+ *werror = mono_w32socket_get_last_error ();
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted)
+ *werror = WSAEINTR;
+
+ if (*werror)
+ return 0;
+
+ return recv;
+}
+
+gint32
+ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, MonoObject **sockaddr, gint32 *werror, gboolean blocking)
+{
+ MonoError error;
+ int ret;
+ gchar *buf;
+ gint32 alen;
+ int recvflags = 0;
+ struct sockaddr *sa;
+ socklen_t sa_size;
+ gboolean interrupted;
+
+ *werror = 0;
+
+ alen = mono_array_length (buffer);
+ if (offset > alen - count)
+ return 0;
+
+ sa = create_sockaddr_from_object (*sockaddr, &sa_size, werror, &error);
+ if (*werror != 0)
+ return 0;
+ if (!mono_error_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return 0;
+ }
+
+ buf = mono_array_addr (buffer, gchar, offset);
+
+ recvflags = convert_socketflags (flags);
+ if (recvflags == -1) {
+ *werror = WSAEOPNOTSUPP;
+ return 0;
+ }
+
+ mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
+ if (interrupted) {
+ g_free (sa);
+ *werror = WSAEINTR;
+ return 0;
+ }
+
+ MONO_ENTER_GC_SAFE;
+ ret = mono_w32socket_recvfrom (sock, buf, count, recvflags, sa, &sa_size, blocking);
+ MONO_EXIT_GC_SAFE;
+
+ if (ret == SOCKET_ERROR)
+ *werror = mono_w32socket_get_last_error ();
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
+
+ if (interrupted)
+ *werror = WSAEINTR;
+
+ if (*werror) {
+ g_free(sa);
+ return 0;
+ }
+
+ /* If we didn't get a socket size, then we're probably a
+ * connected connection-oriented socket and the stack hasn't
+ * returned the remote address. All we can do is return null.
+ */
+ if (sa_size) {
+ *sockaddr = create_object_from_sockaddr (sa, sa_size, werror, &error);
+ if (!mono_error_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ g_free (sa);
+ return 0;
+ }
+ } else {
+ *sockaddr = NULL;
+ }
+
+ g_free (sa);
+
+ return ret;
+}
+
+gint32
+ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, gint32 *werror, gboolean blocking)
+{
+ int ret;
+ gchar *buf;
+ gint32 alen;
+ int sendflags = 0;
+ gboolean interrupted;
+
+ *werror = 0;
+
+ alen = mono_array_length (buffer);
+ if (offset > alen - count)
+ return 0;
+
+ LOGDEBUG (g_message("%s: alen: %d", __func__, alen));
+
+ buf = mono_array_addr (buffer, gchar, offset);
+
+ LOGDEBUG (g_message("%s: Sending %d bytes", __func__, count));
+
+ sendflags = convert_socketflags (flags);
+ if (sendflags == -1) {
+ *werror = WSAEOPNOTSUPP;
+ return 0;
+ }
+
+ mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
+ if (interrupted) {
+ *werror = WSAEINTR;
+ return 0;
+ }
+
+ MONO_ENTER_GC_SAFE;
+ ret = mono_w32socket_send (sock, buf, count, sendflags, blocking);
+ MONO_EXIT_GC_SAFE;
+
+ if (ret == SOCKET_ERROR)
+ *werror = mono_w32socket_get_last_error ();
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted)
+ *werror = WSAEINTR;
+
+ if (*werror)
+ return 0;
+
+ return ret;
+}
+
+gint32
+ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArray *buffers, gint32 flags, gint32 *werror, gboolean blocking)
+{
+ int ret, count;
+ guint32 sent;
+ WSABUF *wsabufs;
+ guint32 sendflags = 0;
+ gboolean interrupted;
+
+ *werror = 0;
+
+ wsabufs = mono_array_addr (buffers, WSABUF, 0);
+ count = mono_array_length (buffers);
+
+ sendflags = convert_socketflags (flags);
+ if (sendflags == -1) {
+ *werror = WSAEOPNOTSUPP;
+ return 0;
+ }
+
+ mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
+ if (interrupted) {
+ *werror = WSAEINTR;
+ return 0;
+ }
+
+ MONO_ENTER_GC_SAFE;
+ ret = mono_w32socket_sendbuffers (sock, wsabufs, count, &sent, sendflags, NULL, NULL, blocking);
+ MONO_EXIT_GC_SAFE;
+
+ if (ret == SOCKET_ERROR)
+ *werror = mono_w32socket_get_last_error ();
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted)
+ *werror = WSAEINTR;
+
+ if (*werror)
+ return 0;
+
+ return sent;
+}
+
+gint32
+ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, MonoObject *sockaddr, gint32 *werror, gboolean blocking)
+{
+ MonoError error;
+ int ret;
+ gchar *buf;
+ gint32 alen;
+ int sendflags = 0;
+ struct sockaddr *sa;
+ socklen_t sa_size;
+ gboolean interrupted;
+
+ *werror = 0;
+
+ alen = mono_array_length (buffer);
+ if (offset > alen - count) {
+ return 0;
+ }
+
+ sa = create_sockaddr_from_object(sockaddr, &sa_size, werror, &error);
+ if (*werror != 0)
+ return 0;
+ if (!mono_error_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return 0;
+ }
+
+ LOGDEBUG (g_message ("%s: alen: %d", __func__, alen));
+
+ buf = mono_array_addr (buffer, gchar, offset);
+
+ LOGDEBUG (g_message("%s: Sending %d bytes", __func__, count));
+
+ sendflags = convert_socketflags (flags);
+ if (sendflags == -1) {
+ g_free (sa);
+ *werror = WSAEOPNOTSUPP;
+ return 0;
+ }
+
+ mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
+ if (interrupted) {
+ g_free (sa);
+ *werror = WSAEINTR;
+ return 0;
+ }
+
+ MONO_ENTER_GC_SAFE;
+ ret = mono_w32socket_sendto (sock, buf, count, sendflags, sa, sa_size, blocking);
+ MONO_EXIT_GC_SAFE;
+
+ if (ret == SOCKET_ERROR)
+ *werror = mono_w32socket_get_last_error ();
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted)
+ *werror = WSAEINTR;
+
+ g_free(sa);
+
+ if (*werror)
+ return 0;
+
+ return ret;
+}
+
+static SOCKET
+Socket_to_SOCKET (MonoObject *sockobj)
+{
+ MonoSafeHandle *safe_handle;
+ MonoClassField *field;
+
+ field = mono_class_get_field_from_name (sockobj->vtable->klass, "m_Handle");
+ safe_handle = ((MonoSafeHandle *)(*(gpointer *)(((char *)sockobj) + field->offset)));
+
+ if (safe_handle == NULL)
+ return -1;
+
+ return (SOCKET)safe_handle->handle;
+}
+
+#define POLL_ERRORS (MONO_POLLERR | MONO_POLLHUP | MONO_POLLNVAL)
+
+void
+ves_icall_System_Net_Sockets_Socket_Select_internal (MonoArray **sockets, gint32 timeout, gint32 *werror)
+{
+ MonoError error;
+ MonoInternalThread *thread = mono_thread_internal_current ();
+ MonoObject *obj;
+ mono_pollfd *pfds;
+ int nfds, idx;
+ int ret;
+ int i, count;
+ int mode;
+ MonoClass *sock_arr_class;
+ MonoArray *socks;
+ time_t start;
+ uintptr_t socks_size;
+ gboolean interrupted;
+
+ *werror = 0;
+
+ /* *sockets -> READ, null, WRITE, null, ERROR, null */
+ count = mono_array_length (*sockets);
+ nfds = count - 3; /* NULL separators */
+ pfds = g_new0 (mono_pollfd, nfds);
+ mode = idx = 0;
+ for (i = 0; i < count; i++) {
+ obj = mono_array_get (*sockets, MonoObject *, i);
+ if (obj == NULL) {
+ mode++;
+ continue;
+ }
+
+ if (idx >= nfds) {
+ /* The socket array was bogus */
+ g_free (pfds);
+ *werror = WSAEFAULT;
+ return;
+ }
+
+ pfds [idx].fd = Socket_to_SOCKET (obj);
+ pfds [idx].events = (mode == 0) ? MONO_POLLIN : (mode == 1) ? MONO_POLLOUT : POLL_ERRORS;
+ idx++;
+ }
+
+ timeout = (timeout >= 0) ? (timeout / 1000) : -1;
+ start = time (NULL);
+ do {
+ mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
+ if (interrupted) {
+ g_free (pfds);
+ *werror = WSAEINTR;
+ return;
+ }
+
+ MONO_ENTER_GC_SAFE;
+
+ ret = mono_poll (pfds, nfds, timeout);
+
+ MONO_EXIT_GC_SAFE;
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ g_free (pfds);
+ *werror = WSAEINTR;
+ return;
+ }
+
+ if (timeout > 0 && ret < 0) {
+ int err = errno;
+ int sec = time (NULL) - start;
+
+ timeout -= sec * 1000;
+ if (timeout < 0)
+ timeout = 0;
+ errno = err;
+ }
+
+ if (ret == -1 && errno == EINTR) {
+ if (mono_thread_test_state (thread, (MonoThreadState)(ThreadState_AbortRequested | ThreadState_StopRequested))) {
+ g_free (pfds);
+ *sockets = NULL;
+ return;
+ }
+
+ /* Suspend requested? */
+ mono_thread_interruption_checkpoint ();
+
+ errno = EINTR;
+ }
+ } while (ret == -1 && errno == EINTR);
+
+ if (ret == -1) {
+ *werror = mono_w32socket_convert_error (errno);
+ g_free (pfds);
+ return;
+ }
+
+ if (ret == 0) {
+ g_free (pfds);
+ *sockets = NULL;
+ return;
+ }
+
+ sock_arr_class = ((MonoObject *)*sockets)->vtable->klass;
+ socks_size = ((uintptr_t)ret) + 3; /* space for the NULL delimiters */
+ socks = mono_array_new_full_checked (mono_domain_get (), sock_arr_class, &socks_size, NULL, &error);
+ if (!mono_error_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ g_free (pfds);
+ return;
+ }
+
+ mode = idx = 0;
+ for (i = 0; i < count && ret > 0; i++) {
+ mono_pollfd *pfd;
+
+ obj = mono_array_get (*sockets, MonoObject *, i);
+ if (obj == NULL) {
+ mode++;
+ idx++;
+ continue;
+ }
+
+ pfd = &pfds [i - mode];
+ if (pfd->revents == 0)
+ continue;
+
+ ret--;
+ if (mode == 0 && (pfd->revents & (MONO_POLLIN | POLL_ERRORS)) != 0) {
+ mono_array_setref (socks, idx++, obj);
+ } else if (mode == 1 && (pfd->revents & (MONO_POLLOUT | POLL_ERRORS)) != 0) {
+ mono_array_setref (socks, idx++, obj);
+ } else if ((pfd->revents & POLL_ERRORS) != 0) {
+ mono_array_setref (socks, idx++, obj);
+ }
+ }
+
+ *sockets = socks;
+ g_free (pfds);
+}
+
+static MonoObject*
+int_to_object (MonoDomain *domain, int val, MonoError *error)
+{
+ return mono_value_box_checked (domain, mono_get_int32_class (), &val, error);
+}
+
+void
+ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal (gsize sock, gint32 level, gint32 name, MonoObject **obj_val, gint32 *werror)
+{
+ int system_level = 0;
+ int system_name = 0;
+ int ret;
+ int val = 0;
+ socklen_t valsize = sizeof (val);
+ struct linger linger;
+ socklen_t lingersize = sizeof (linger);
+ int time_ms = 0;
+ socklen_t time_ms_size = sizeof (time_ms);
+#ifdef SO_PEERCRED
+# if defined(__OpenBSD__)
+ struct sockpeercred cred;
+# else
+ struct ucred cred;
+# endif
+ socklen_t credsize = sizeof (cred);
+#endif
+ MonoError error;
+ MonoDomain *domain = mono_domain_get ();
+ MonoObject *obj;
+ MonoClass *obj_class;
+ MonoClassField *field;
+
+ *werror = 0;
+
+#if !defined(SO_EXCLUSIVEADDRUSE) && defined(SO_REUSEADDR)
+ if (level == SocketOptionLevel_Socket && name == SocketOptionName_ExclusiveAddressUse) {
+ system_level = SOL_SOCKET;
+ system_name = SO_REUSEADDR;
+ ret = 0;
+ } else
+#endif
+ {
+ ret = convert_sockopt_level_and_name ((MonoSocketOptionLevel)level, (MonoSocketOptionName)name, &system_level, &system_name);
+ }
+
+ if (ret == -1) {
+ *werror = WSAENOPROTOOPT;
+ return;
+ }
+ if (ret == -2) {
+ *obj_val = int_to_object (domain, 0, &error);
+ mono_error_set_pending_exception (&error);
+ return;
+ }
+
+ MONO_ENTER_GC_SAFE;
+
+ /* No need to deal with MulticastOption names here, because
+ * you cant getsockopt AddMembership or DropMembership (the
+ * int getsockopt will error, causing an exception)
+ */
+ switch (name) {
+ case SocketOptionName_Linger:
+ case SocketOptionName_DontLinger:
+ ret = mono_w32socket_getsockopt (sock, system_level, system_name, &linger, &lingersize);
+ break;
+
+ case SocketOptionName_SendTimeout:
+ case SocketOptionName_ReceiveTimeout:
+ ret = mono_w32socket_getsockopt (sock, system_level, system_name, (char *)&time_ms, &time_ms_size);
+ break;
+
+#ifdef SO_PEERCRED
+ case SocketOptionName_PeerCred:
+ ret = mono_w32socket_getsockopt (sock, system_level, system_name, &cred, &credsize);
+ break;
+#endif
+
+ default:
+ ret = mono_w32socket_getsockopt (sock, system_level, system_name, &val, &valsize);
+ }
+
+ MONO_EXIT_GC_SAFE;
+
+ if (ret == SOCKET_ERROR) {
+ *werror = mono_w32socket_get_last_error ();
+ return;
+ }
+
+ switch (name) {
+ case SocketOptionName_Linger:
+ /* build a System.Net.Sockets.LingerOption */
+ obj_class = mono_class_load_from_name (get_socket_assembly (),
+ "System.Net.Sockets",
+ "LingerOption");
+ obj = mono_object_new_checked (domain, obj_class, &error);
+ if (!mono_error_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return;
+ }
+
+ /* Locate and set the fields "bool enabled" and "int
+ * lingerTime"
+ */
+ field = mono_class_get_field_from_name(obj_class, "enabled");
+ *(guint8 *)(((char *)obj)+field->offset) = linger.l_onoff;
+
+ field = mono_class_get_field_from_name(obj_class, "lingerTime");
+ *(guint32 *)(((char *)obj)+field->offset)=linger.l_linger;
+ break;
+ case SocketOptionName_DontLinger:
+ /* construct a bool int in val - true if linger is off */
+ obj = int_to_object (domain, !linger.l_onoff, &error);
+ mono_error_set_pending_exception (&error);
+ break;
+ case SocketOptionName_SendTimeout:
+ case SocketOptionName_ReceiveTimeout:
+ obj = int_to_object (domain, time_ms, &error);
+ mono_error_set_pending_exception (&error);
+ break;
+
+#ifdef SO_PEERCRED
+ case SocketOptionName_PeerCred: {
+ /*
+ * build a Mono.Posix.PeerCred+PeerCredData if
+ * possible
+ */
+ static MonoImage *mono_posix_image = NULL;
+ MonoPeerCredData *cred_data;
+
+ if (mono_posix_image == NULL) {
+ mono_posix_image = mono_image_loaded ("Mono.Posix");
+ if (!mono_posix_image) {
+ MonoAssembly *sa = mono_assembly_open ("Mono.Posix.dll", NULL);
+ if (!sa) {
+ *werror = WSAENOPROTOOPT;
+ return;
+ } else {
+ mono_posix_image = mono_assembly_get_image (sa);
+ }
+ }
+ }
+
+ obj_class = mono_class_load_from_name (mono_posix_image,
+ "Mono.Posix",
+ "PeerCredData");
+ obj = mono_object_new_checked (domain, obj_class, &error);
+ if (!mono_error_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return;
+ }
+ cred_data = (MonoPeerCredData *)obj;
+ cred_data->pid = cred.pid;
+ cred_data->uid = cred.uid;
+ cred_data->gid = cred.gid;
+ break;
+ }
+#endif
+
+ default:
+#if !defined(SO_EXCLUSIVEADDRUSE) && defined(SO_REUSEADDR)
+ if (level == SocketOptionLevel_Socket && name == SocketOptionName_ExclusiveAddressUse)
+ val = val ? 0 : 1;
+#endif
+ obj = int_to_object (domain, val, &error);
+ mono_error_set_pending_exception (&error);
+ }
+
+ *obj_val = obj;
+}
+
+void
+ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal (gsize sock, gint32 level, gint32 name, MonoArray **byte_val, gint32 *werror)
+{
+ int system_level = 0;
+ int system_name = 0;
+ int ret;
+ guchar *buf;
+ socklen_t valsize;
+
+ *werror = 0;
+
+ ret = convert_sockopt_level_and_name((MonoSocketOptionLevel)level, (MonoSocketOptionName)name, &system_level,
+ &system_name);
+ if (ret == -1) {
+ *werror = WSAENOPROTOOPT;
+ return;
+ }
+ if (ret == -2)
+ return;
+
+ valsize = mono_array_length (*byte_val);
+ buf = mono_array_addr (*byte_val, guchar, 0);
+
+ MONO_ENTER_GC_SAFE;
+
+ ret = mono_w32socket_getsockopt (sock, system_level, system_name, buf, &valsize);
+
+ MONO_EXIT_GC_SAFE;
+
+ if (ret == SOCKET_ERROR)
+ *werror = mono_w32socket_get_last_error ();
+}
+
+#if defined(HAVE_STRUCT_IP_MREQN) || defined(HAVE_STRUCT_IP_MREQ)
+static struct in_addr
+ipaddress_to_struct_in_addr (MonoObject *ipaddr)
+{
+ struct in_addr inaddr;
+ MonoClassField *field;
+
+ field = mono_class_get_field_from_name (ipaddr->vtable->klass, "m_Address");
+
+ /* No idea why .net uses a 64bit type to hold a 32bit value...
+ *
+ * Internal value of IPAddess is in little-endian order
+ */
+ inaddr.s_addr = GUINT_FROM_LE ((guint32)*(guint64 *)(((char *)ipaddr) + field->offset));
+
+ return inaddr;
+}
+
+static struct in6_addr
+ipaddress_to_struct_in6_addr (MonoObject *ipaddr)
+{
+ struct in6_addr in6addr;
+ MonoClassField *field;
+ MonoArray *data;
+ int i;
+
+ field = mono_class_get_field_from_name (ipaddr->vtable->klass, "m_Numbers");
+ g_assert (field);
+ data = *(MonoArray **)(((char *)ipaddr) + field->offset);
+
+ for (i = 0; i < 8; i++) {
+ const guint16 s = GUINT16_TO_BE (mono_array_get (data, guint16, i));
+
+/* Solaris/MacOS have only the 8 bit version. */
+#ifndef s6_addr16
+ in6addr.s6_addr[2 * i + 1] = (s >> 8) & 0xff;
+ in6addr.s6_addr[2 * i] = s & 0xff;
+#else
+ in6addr.s6_addr16[i] = s;
+#endif
+ }
+ return in6addr;
+}
+#endif
+
+#if defined(__APPLE__) || defined(__FreeBSD__)
+
+static int
+get_local_interface_id (int family)
+{
+#if !defined(HAVE_GETIFADDRS) || !defined(HAVE_IF_NAMETOINDEX)
+ return 0;
+#else
+ struct ifaddrs *ifap = NULL, *ptr;
+ int idx = 0;
+
+ if (getifaddrs (&ifap))
+ return 0;
+
+ for (ptr = ifap; ptr; ptr = ptr->ifa_next) {
+ if (!ptr->ifa_addr || !ptr->ifa_name)
+ continue;
+ if (ptr->ifa_addr->sa_family != family)
+ continue;
+ if ((ptr->ifa_flags & IFF_LOOPBACK) != 0)
+ continue;
+ if ((ptr->ifa_flags & IFF_MULTICAST) == 0)
+ continue;
+
+ idx = if_nametoindex (ptr->ifa_name);
+ break;
+ }
+
+ freeifaddrs (ifap);
+ return idx;
+#endif
+}
+
+#endif /* defined(__APPLE__) || defined(__FreeBSD__) */
+
+void
+ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (gsize sock, gint32 level, gint32 name, MonoObject *obj_val, MonoArray *byte_val, gint32 int_val, gint32 *werror)
+{
+ struct linger linger;
+ int system_level = 0;
+ int system_name = 0;
+ int ret;
+ int sol_ip;
+ int sol_ipv6;
+
+ *werror = 0;
+
+ sol_ipv6 = mono_networking_get_ipv6_protocol ();
+ sol_ip = mono_networking_get_ip_protocol ();
+
+ ret = convert_sockopt_level_and_name ((MonoSocketOptionLevel)level, (MonoSocketOptionName)name, &system_level,
+ &system_name);
+
+#if !defined(SO_EXCLUSIVEADDRUSE) && defined(SO_REUSEADDR)
+ if (level == SocketOptionLevel_Socket && name == SocketOptionName_ExclusiveAddressUse) {
+ system_name = SO_REUSEADDR;
+ int_val = int_val ? 0 : 1;
+ ret = 0;
+ }
+#endif
+
+ if (ret == -1) {
+ *werror = WSAENOPROTOOPT;
+ return;
+ }
+ if (ret == -2)
+ return;
+
+ /* Only one of obj_val, byte_val or int_val has data */
+ if (obj_val) {
+ MonoClassField *field;
+ int valsize;
+
+ switch (name) {
+ case SocketOptionName_Linger:
+ /* Dig out "bool enabled" and "int lingerTime"
+ * fields
+ */
+ field = mono_class_get_field_from_name (obj_val->vtable->klass, "enabled");
+ linger.l_onoff = *(guint8 *)(((char *)obj_val) + field->offset);
+ field = mono_class_get_field_from_name (obj_val->vtable->klass, "lingerTime");
+ linger.l_linger = *(guint32 *)(((char *)obj_val) + field->offset);
+
+ valsize = sizeof (linger);
+ ret = mono_w32socket_setsockopt (sock, system_level, system_name, &linger, valsize);
+ break;
+ case SocketOptionName_AddMembership:
+ case SocketOptionName_DropMembership:
+#if defined(HAVE_STRUCT_IP_MREQN) || defined(HAVE_STRUCT_IP_MREQ)
+ {
+ MonoObject *address = NULL;
+
+ if (system_level == sol_ipv6) {
+ struct ipv6_mreq mreq6;
+
+ /*
+ * Get group address
+ */
+ field = mono_class_get_field_from_name (obj_val->vtable->klass, "m_Group");
+ g_assert (field);
+ address = *(MonoObject **)(((char *)obj_val) + field->offset);
+
+ if (address)
+ mreq6.ipv6mr_multiaddr = ipaddress_to_struct_in6_addr (address);
+
+ field = mono_class_get_field_from_name (obj_val->vtable->klass, "m_Interface");
+ mreq6.ipv6mr_interface = *(guint64 *)(((char *)obj_val) + field->offset);
+
+#if defined(__APPLE__) || defined(__FreeBSD__)
+ /*
+ * Bug #5504:
+ *
+ * Mac OS Lion doesn't allow ipv6mr_interface = 0.
+ *
+ * Tests on Windows and Linux show that the multicast group is only
+ * joined on one NIC when interface = 0, so we simply use the interface
+ * id from the first non-loopback interface (this is also what
+ * Dns.GetHostName (string.Empty) would return).
+ */
+ if (!mreq6.ipv6mr_interface)
+ mreq6.ipv6mr_interface = get_local_interface_id (AF_INET6);
+#endif
+
+ ret = mono_w32socket_setsockopt (sock, system_level, system_name, &mreq6, sizeof (mreq6));
+ } else if (system_level == sol_ip) {
+#ifdef HAVE_STRUCT_IP_MREQN
+ struct ip_mreqn mreq = {{0}};
+#else
+ struct ip_mreq mreq = {{0}};
+#endif /* HAVE_STRUCT_IP_MREQN */
+
+ /*
+ * pain! MulticastOption holds two IPAddress
+ * members, so I have to dig the value out of
+ * those :-(
+ */
+ field = mono_class_get_field_from_name (obj_val->vtable->klass, "group");
+ address = *(MonoObject **)(((char *)obj_val) + field->offset);
+
+ /* address might not be defined and if so, set the address to ADDR_ANY.
+ */
+ if (address)
+ mreq.imr_multiaddr = ipaddress_to_struct_in_addr (address);
+
+ field = mono_class_get_field_from_name (obj_val->vtable->klass, "localAddress");
+ address = *(MonoObject **)(((char *)obj_val) + field->offset);
+
+#ifdef HAVE_STRUCT_IP_MREQN
+ if (address)
+ mreq.imr_address = ipaddress_to_struct_in_addr (address);
+
+ field = mono_class_get_field_from_name (obj_val->vtable->klass, "ifIndex");
+ mreq.imr_ifindex = *(gint32 *)(((char *)obj_val) + field->offset);
+#else
+ if (address)
+ mreq.imr_interface = ipaddress_to_struct_in_addr (address);
+#endif /* HAVE_STRUCT_IP_MREQN */
+
+ ret = mono_w32socket_setsockopt (sock, system_level, system_name, &mreq, sizeof (mreq));
+ }
+ break;
+ }
+#endif /* HAVE_STRUCT_IP_MREQN || HAVE_STRUCT_IP_MREQ */
+ default:
+ /* Cause an exception to be thrown */
+ *werror = WSAEINVAL;
+ return;
+ }
+ } else if (byte_val!=NULL) {
+ int valsize = mono_array_length (byte_val);
+ guchar *buf = mono_array_addr (byte_val, guchar, 0);
+
+ switch(name) {
+ case SocketOptionName_DontLinger:
+ if (valsize == 1) {
+ linger.l_onoff = (*buf) ? 0 : 1;
+ linger.l_linger = 0;
+ ret = mono_w32socket_setsockopt (sock, system_level, system_name, &linger, sizeof (linger));
+ } else {
+ *werror = WSAEINVAL;
+ }
+ break;
+ default:
+ ret = mono_w32socket_setsockopt (sock, system_level, system_name, buf, valsize);
+ break;
+ }
+ } else {
+ /* ReceiveTimeout/SendTimeout get here */
+ switch (name) {
+ case SocketOptionName_DontLinger:
+ linger.l_onoff = !int_val;
+ linger.l_linger = 0;
+ ret = mono_w32socket_setsockopt (sock, system_level, system_name, &linger, sizeof (linger));
+ break;
+ case SocketOptionName_MulticastInterface:
+#ifndef HOST_WIN32
+#ifdef HAVE_STRUCT_IP_MREQN
+ int_val = GUINT32_FROM_BE (int_val);
+ if ((int_val & 0xff000000) == 0) {
+ /* int_val is interface index */
+ struct ip_mreqn mreq = {{0}};
+ mreq.imr_ifindex = int_val;
+ ret = mono_w32socket_setsockopt (sock, system_level, system_name, (char *) &mreq, sizeof (mreq));
+ break;
+ }
+ int_val = GUINT32_TO_BE (int_val);
+#endif /* HAVE_STRUCT_IP_MREQN */
+#endif /* HOST_WIN32 */
+ /* int_val is in_addr */
+ ret = mono_w32socket_setsockopt (sock, system_level, system_name, (char *) &int_val, sizeof (int_val));
+ break;
+ case SocketOptionName_DontFragment:
+#ifdef HAVE_IP_MTU_DISCOVER
+ /* Fiddle with the value slightly if we're
+ * turning DF on
+ */
+ if (int_val == 1)
+ int_val = IP_PMTUDISC_DO;
+ /* Fall through */
+#endif
+
+ default:
+ ret = mono_w32socket_setsockopt (sock, system_level, system_name, (char *) &int_val, sizeof (int_val));
+ }
+ }
+
+ if (ret == SOCKET_ERROR)
+ *werror = mono_w32socket_get_last_error ();
+}
+
+void
+ves_icall_System_Net_Sockets_Socket_Shutdown_internal (gsize sock, gint32 how, gint32 *werror)
+{
+ int ret;
+ gboolean interrupted;
+
+ *werror = 0;
+
+ mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
+ if (interrupted) {
+ *werror = WSAEINTR;
+ return;
+ }
+
+ MONO_ENTER_GC_SAFE;
+
+ /* Currently, the values for how (recv=0, send=1, both=2) match the BSD API */
+ ret = mono_w32socket_shutdown (sock, how);
+
+ MONO_EXIT_GC_SAFE;
+
+ if (ret == SOCKET_ERROR)
+ *werror = mono_w32socket_get_last_error ();
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ *werror = WSAEINTR;
+ }
+
+}
+
+gint
+ves_icall_System_Net_Sockets_Socket_IOControl_internal (gsize sock, gint32 code, MonoArray *input, MonoArray *output, gint32 *werror)
+{
+ glong output_bytes = 0;
+ gchar *i_buffer, *o_buffer;
+ gint i_len, o_len;
+ gint ret;
+
+ *werror = 0;
+
+ if ((guint32)code == FIONBIO)
+ /* Invalid command. Must use Socket.Blocking */
+ return -1;
+
+ if (input == NULL) {
+ i_buffer = NULL;
+ i_len = 0;
+ } else {
+ i_buffer = mono_array_addr (input, gchar, 0);
+ i_len = mono_array_length (input);
+ }
+
+ if (output == NULL) {
+ o_buffer = NULL;
+ o_len = 0;
+ } else {
+ o_buffer = mono_array_addr (output, gchar, 0);
+ o_len = mono_array_length (output);
+ }
+
+ MONO_ENTER_GC_SAFE;
+
+ ret = mono_w32socket_ioctl (sock, code, i_buffer, i_len, o_buffer, o_len, &output_bytes);
+
+ MONO_EXIT_GC_SAFE;
+
+ if (ret == SOCKET_ERROR) {
+ *werror = mono_w32socket_get_last_error ();
+ return -1;
+ }
+
+ return (gint)output_bytes;
+}
+
+static gboolean
+addrinfo_to_IPHostEntry (MonoAddressInfo *info, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gboolean add_local_ips, MonoError *error)
+{
+ gint32 count, i;
+ MonoAddressEntry *ai = NULL;
+ struct in_addr *local_in = NULL;
+ int nlocal_in = 0;
+ struct in6_addr *local_in6 = NULL;
+ int nlocal_in6 = 0;
+ int addr_index;
+ MonoDomain *domain = mono_domain_get ();
+
+ mono_error_init (error);
+ addr_index = 0;
+ *h_aliases = mono_array_new_checked (domain, mono_get_string_class (), 0, error);
+ return_val_if_nok (error, FALSE);
+ if (add_local_ips) {
+ local_in = (struct in_addr *) mono_get_local_interfaces (AF_INET, &nlocal_in);
+ local_in6 = (struct in6_addr *) mono_get_local_interfaces (AF_INET6, &nlocal_in6);
+ if (nlocal_in || nlocal_in6) {
+ char addr [INET6_ADDRSTRLEN];
+ *h_addr_list = mono_array_new_checked (domain, mono_get_string_class (), nlocal_in + nlocal_in6, error);
+ if (!is_ok (error))
+ goto leave;
+
+ if (nlocal_in) {
+ MonoString *addr_string;
+ int i;
+
+ for (i = 0; i < nlocal_in; i++) {
+ MonoAddress maddr;
+ mono_address_init (&maddr, AF_INET, &local_in [i]);
+ if (mono_networking_addr_to_str (&maddr, addr, sizeof (addr))) {
+ addr_string = mono_string_new (domain, addr);
+ mono_array_setref (*h_addr_list, addr_index, addr_string);
+ addr_index++;
+ }
+ }
+ }
+
+ if (nlocal_in6) {
+ MonoString *addr_string;
+ int i;
+
+ for (i = 0; i < nlocal_in6; i++) {
+ MonoAddress maddr;
+ mono_address_init (&maddr, AF_INET6, &local_in6 [i]);
+ if (mono_networking_addr_to_str (&maddr, addr, sizeof (addr))) {
+ addr_string = mono_string_new (domain, addr);
+ mono_array_setref (*h_addr_list, addr_index, addr_string);
+ addr_index++;
+ }
+ }
+ }
+
+ leave:
+ g_free (local_in);
+ g_free (local_in6);
+ if (info)
+ mono_free_address_info (info);
+ return is_ok (error);;
+ }
+
+ g_free (local_in);
+ g_free (local_in6);
+ }
+
+ for (count = 0, ai = info->entries; ai != NULL; ai = ai->next) {
+ if (ai->family != AF_INET && ai->family != AF_INET6)
+ continue;
+ count++;
+ }
+
+ *h_addr_list = mono_array_new_checked (domain, mono_get_string_class (), count, error);
+ if (!is_ok (error))
+ goto leave2;
+
+ for (ai = info->entries, i = 0; ai != NULL; ai = ai->next) {
+ MonoAddress maddr;
+ MonoString *addr_string;
+ char buffer [INET6_ADDRSTRLEN]; /* Max. size for IPv6 */
+
+ if ((ai->family != PF_INET) && (ai->family != PF_INET6))
+ continue;
+
+ mono_address_init (&maddr, ai->family, &ai->address);
+ if (mono_networking_addr_to_str (&maddr, buffer, sizeof (buffer)))
+ addr_string = mono_string_new (domain, buffer);
+ else
+ addr_string = mono_string_new (domain, "");
+
+ mono_array_setref (*h_addr_list, addr_index, addr_string);
+
+ if (!i) {
+ i++;
+ if (ai->canonical_name != NULL) {
+ *h_name = mono_string_new (domain, ai->canonical_name);
+ } else {
+ *h_name = mono_string_new (domain, buffer);
+ }
+ }
+
+ addr_index++;
+ }
+
+leave2:
+ if (info)
+ mono_free_address_info (info);
+
+ return is_ok (error);
+}
+
+MonoBoolean
+ves_icall_System_Net_Dns_GetHostByName_internal (MonoString *host, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gint32 hint)
+{
+ MonoError error;
+ gboolean add_local_ips = FALSE, add_info_ok = TRUE;
+ gchar this_hostname [256];
+ MonoAddressInfo *info = NULL;
+
+ char *hostname = mono_string_to_utf8_checked (host, &error);
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
+
+ if (*hostname == '\0') {
+ add_local_ips = TRUE;
+ *h_name = host;
+ }
+
+ if (!add_local_ips && gethostname (this_hostname, sizeof (this_hostname)) != -1) {
+ if (!strcmp (hostname, this_hostname)) {
+ add_local_ips = TRUE;
+ *h_name = host;
+ }
+ }
+
+#ifdef HOST_WIN32
+ // Win32 APIs already returns local interface addresses for empty hostname ("")
+ // so we never want to add them manually.
+ add_local_ips = FALSE;
+ if (mono_get_address_info(hostname, 0, MONO_HINT_CANONICAL_NAME | hint, &info))
+ add_info_ok = FALSE;
+#else
+ if (*hostname && mono_get_address_info (hostname, 0, MONO_HINT_CANONICAL_NAME | hint, &info))
+ add_info_ok = FALSE;
+#endif
+
+ g_free(hostname);
+
+ if (add_info_ok) {
+ MonoBoolean result = addrinfo_to_IPHostEntry (info, h_name, h_aliases, h_addr_list, add_local_ips, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+ }
+ return FALSE;
+}
+
+MonoBoolean
+ves_icall_System_Net_Dns_GetHostByAddr_internal (MonoString *addr, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gint32 hint)
+{
+ char *address;
+ struct sockaddr_in saddr;
+ struct sockaddr_in6 saddr6;
+ MonoAddressInfo *info = NULL;
+ MonoError error;
+ gint32 family;
+ gchar hostname [NI_MAXHOST] = { 0 };
+ gboolean ret;
+
+ address = mono_string_to_utf8_checked (addr, &error);
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
+
+ if (inet_pton (AF_INET, address, &saddr.sin_addr ) == 1) {
+ family = AF_INET;
+ saddr.sin_family = AF_INET;
+ } else if (inet_pton (AF_INET6, address, &saddr6.sin6_addr) == 1) {
+ family = AF_INET6;
+ saddr6.sin6_family = AF_INET6;
+ } else {
+ g_free (address);
+ return FALSE;
+ }
+
+ g_free (address);
+
+ MONO_ENTER_GC_SAFE;
+
+ switch (family) {
+ case AF_INET: {
+#if HAVE_SOCKADDR_IN_SIN_LEN
+ saddr.sin_len = sizeof (saddr);
+#endif
+ ret = getnameinfo ((struct sockaddr*)&saddr, sizeof (saddr), hostname, sizeof (hostname), NULL, 0, 0) == 0;
+ break;
+ }
+ case AF_INET6: {
+#if HAVE_SOCKADDR_IN6_SIN_LEN
+ saddr6.sin6_len = sizeof (saddr6);
+#endif
+ ret = getnameinfo ((struct sockaddr*)&saddr6, sizeof (saddr6), hostname, sizeof (hostname), NULL, 0, 0) == 0;
+ break;
+ }
+ default:
+ g_assert_not_reached ();
+ }
+
+ MONO_EXIT_GC_SAFE;
+
+ if (!ret)
+ return FALSE;
+
+ if (mono_get_address_info (hostname, 0, hint | MONO_HINT_CANONICAL_NAME | MONO_HINT_CONFIGURED_ONLY, &info) != 0)
+ return FALSE;
+
+ MonoBoolean result = addrinfo_to_IPHostEntry (info, h_name, h_aliases, h_addr_list, FALSE, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
+MonoBoolean
+ves_icall_System_Net_Dns_GetHostName_internal (MonoString **h_name)
+{
+ gchar hostname [NI_MAXHOST] = { 0 };
+ int ret;
+
+ ret = gethostname (hostname, sizeof (hostname));
+ if (ret == -1)
+ return FALSE;
+
+ *h_name = mono_string_new (mono_domain_get (), hostname);
+
+ return TRUE;
+}
+
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
+gboolean
+ves_icall_System_Net_Sockets_Socket_SendFile_internal (gsize sock, MonoString *filename, MonoArray *pre_buffer, MonoArray *post_buffer, gint flags, gint32 *werror, gboolean blocking)
+{
+ HANDLE file;
+ gboolean ret;
+ gboolean interrupted;
+ TRANSMIT_FILE_BUFFERS buffers;
+
+ *werror = 0;
+
+ if (filename == NULL)
+ return FALSE;
+
+ /* FIXME: replace file by a proper fd that we can call open and close on, as they are interruptible */
+
+ file = mono_w32file_create (mono_string_chars (filename), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, 0);
+ if (file == INVALID_HANDLE_VALUE) {
+ *werror = mono_w32error_get_last ();
+ return FALSE;
+ }
+
+ memset (&buffers, 0, sizeof (buffers));
+ if (pre_buffer != NULL) {
+ buffers.Head = mono_array_addr (pre_buffer, guchar, 0);
+ buffers.HeadLength = mono_array_length (pre_buffer);
+ }
+ if (post_buffer != NULL) {
+ buffers.Tail = mono_array_addr (post_buffer, guchar, 0);
+ buffers.TailLength = mono_array_length (post_buffer);
+ }
+
+ mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
+ if (interrupted) {
+ mono_w32file_close (file);
+ mono_w32error_set_last (WSAEINTR);
+ return FALSE;
+ }
+
+ MONO_ENTER_GC_SAFE;
+ ret = mono_w32socket_transmit_file (sock, file, &buffers, flags, blocking);
+ MONO_EXIT_GC_SAFE;
+
+ if (!ret)
+ *werror = mono_w32socket_get_last_error ();
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ mono_w32file_close (file);
+ *werror = WSAEINTR;
+ return FALSE;
+ }
+
+ MONO_ENTER_GC_SAFE;
+
+ mono_w32file_close (file);
+
+ MONO_EXIT_GC_SAFE;
+
+ if (*werror)
+ return FALSE;
+
+ return ret;
+}
+#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
+
+void
+mono_network_init (void)
+{
+ mono_networking_init ();
+ mono_w32socket_initialize ();
+}
+
+void
+mono_network_cleanup (void)
+{
+ mono_w32socket_cleanup ();
+ mono_networking_shutdown ();
+}
+
+void
+icall_cancel_blocking_socket_operation (MonoThread *thread)
+{
+ MonoInternalThread *internal;
+
+ internal = thread->internal_thread;
+ g_assert (internal);
+
+ mono_thread_info_abort_socket_syscall_for_close (MONO_UINT_TO_NATIVE_THREAD_ID (internal->tid));
+}
+
+#endif /* #ifndef DISABLE_SOCKETS */
--- /dev/null
+/*
+ * w32socket.h: System.Net.Sockets.Socket support
+ *
+ * Author:
+ * Dick Porter (dick@ximian.com)
+ *
+ * (C) 2001 Ximian, Inc.
+ */
+
+#ifndef _MONO_METADATA_W32SOCKET_H_
+#define _MONO_METADATA_W32SOCKET_H_
+
+#include <config.h>
+#include <glib.h>
+
+#include <mono/metadata/object-internals.h>
+
+#define INVALID_SOCKET ((SOCKET)(guint32)(~0))
+#define SOCKET_ERROR (-1)
+
+#ifndef HOST_WIN32
+typedef gint SOCKET;
+#endif
+
+/* This is a copy of System.Net.Sockets.SocketType */
+typedef enum {
+ SocketType_Stream=1,
+ SocketType_Dgram=2,
+ SocketType_Raw=3,
+ SocketType_Rdm=4,
+ SocketType_Seqpacket=5,
+ SocketType_Unknown=-1
+} MonoSocketType;
+
+/* This is a copy of System.Net.Sockets.AddressFamily */
+typedef enum {
+ AddressFamily_Unknown=-1,
+ AddressFamily_Unspecified=0,
+ AddressFamily_Unix=1,
+ AddressFamily_InterNetwork=2,
+ AddressFamily_ImpLink=3,
+ AddressFamily_Pup=4,
+ AddressFamily_Chaos=5,
+ AddressFamily_NS=6,
+ AddressFamily_Ipx=6,
+ AddressFamily_Iso=7,
+ AddressFamily_Osi=7,
+ AddressFamily_Ecma=8,
+ AddressFamily_DataKit=9,
+ AddressFamily_Ccitt=10,
+ AddressFamily_Sna=11,
+ AddressFamily_DecNet=12,
+ AddressFamily_DataLink=13,
+ AddressFamily_Lat=14,
+ AddressFamily_HyperChannel=15,
+ AddressFamily_AppleTalk=16,
+ AddressFamily_NetBios=17,
+ AddressFamily_VoiceView=18,
+ AddressFamily_FireFox=19,
+ AddressFamily_Banyan=21,
+ AddressFamily_Atm=22,
+ AddressFamily_InterNetworkV6=23,
+ AddressFamily_Cluster=24,
+ AddressFamily_Ieee12844=25,
+ AddressFamily_Irda=26,
+ AddressFamily_NetworkDesigners=28
+} MonoAddressFamily;
+
+/* This is a copy of System.Net.Sockets.ProtocolType */
+typedef enum {
+ ProtocolType_IP=0,
+ ProtocolType_Icmp=1,
+ ProtocolType_Igmp=2,
+ ProtocolType_Ggp=3,
+ ProtocolType_Tcp=6,
+ ProtocolType_Pup=12,
+ ProtocolType_Udp=17,
+ ProtocolType_Idp=22,
+ ProtocolType_IPv6=41,
+ ProtocolType_ND=77,
+ ProtocolType_Raw=255,
+ ProtocolType_Unspecified=0,
+ ProtocolType_Ipx=1000,
+ ProtocolType_Spx=1256,
+ ProtocolType_SpxII=1257,
+ ProtocolType_Unknown=-1
+} MonoProtocolType;
+
+/* This is a copy of System.Net.Sockets.SocketOptionLevel */
+typedef enum {
+ SocketOptionLevel_Socket=65535,
+ SocketOptionLevel_IP=0,
+ SocketOptionLevel_IPv6=41,
+ SocketOptionLevel_Tcp=6,
+ SocketOptionLevel_Udp=17
+} MonoSocketOptionLevel;
+
+/* This is a copy of System.Net.Sockets.SocketOptionName */
+typedef enum {
+ SocketOptionName_Debug=1,
+ SocketOptionName_AcceptConnection=2,
+ SocketOptionName_ReuseAddress=4,
+ SocketOptionName_KeepAlive=8,
+ SocketOptionName_DontRoute=16,
+ SocketOptionName_IPProtectionLevel = 23,
+ SocketOptionName_IPv6Only = 27,
+ SocketOptionName_Broadcast=32,
+ SocketOptionName_UseLoopback=64,
+ SocketOptionName_Linger=128,
+ SocketOptionName_OutOfBandInline=256,
+ SocketOptionName_DontLinger= -129,
+ SocketOptionName_ExclusiveAddressUse= -5,
+ SocketOptionName_SendBuffer= 4097,
+ SocketOptionName_ReceiveBuffer=4098,
+ SocketOptionName_SendLowWater=4099,
+ SocketOptionName_ReceiveLowWater=4100,
+ SocketOptionName_SendTimeout=4101,
+ SocketOptionName_ReceiveTimeout=4102,
+ SocketOptionName_Error=4103,
+ SocketOptionName_Type=4104,
+ SocketOptionName_MaxConnections=2147483647,
+ SocketOptionName_IPOptions=1,
+ SocketOptionName_HeaderIncluded=2,
+ SocketOptionName_TypeOfService=3,
+ SocketOptionName_IpTimeToLive=4,
+ SocketOptionName_MulticastInterface=9,
+ SocketOptionName_MulticastTimeToLive=10,
+ SocketOptionName_MulticastLoopback=11,
+ SocketOptionName_AddMembership=12,
+ SocketOptionName_DropMembership=13,
+ SocketOptionName_DontFragment=14,
+ SocketOptionName_AddSourceMembership=15,
+ SocketOptionName_DropSourceMembership=16,
+ SocketOptionName_BlockSource=17,
+ SocketOptionName_UnblockSource=18,
+ SocketOptionName_PacketInformation=19,
+ SocketOptionName_NoDelay=1,
+ SocketOptionName_BsdUrgent=2,
+ SocketOptionName_Expedited=2,
+ SocketOptionName_NoChecksum=1,
+ SocketOptionName_ChecksumCoverage=20,
+ SocketOptionName_HopLimit=21,
+
+ /* This is Mono-specific, keep it in sync with
+ * Mono.Posix/PeerCred.cs
+ */
+ SocketOptionName_PeerCred=10001
+} MonoSocketOptionName;
+
+/* This is a copy of System.Net.Sockets.SocketFlags */
+typedef enum {
+ SocketFlags_None = 0x0000,
+ SocketFlags_OutOfBand = 0x0001,
+ SocketFlags_MaxIOVectorLength = 0x0010,
+ SocketFlags_Peek = 0x0002,
+ SocketFlags_DontRoute = 0x0004,
+ SocketFlags_Partial = 0x8000
+} MonoSocketFlags;
+
+typedef struct
+{
+ MonoObject obj;
+ gint pid;
+ gint uid;
+ gint gid;
+} MonoPeerCredData;
+
+gpointer
+ves_icall_System_Net_Sockets_Socket_Socket_internal (MonoObject *this_obj, gint32 family, gint32 type, gint32 proto,
+ gint32 *error);
+
+void
+ves_icall_System_Net_Sockets_Socket_Close_internal (gsize sock, gint32 *error);
+
+gint32
+ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal (void);
+
+gint32
+ves_icall_System_Net_Sockets_Socket_Available_internal (gsize sock, gint32 *error);
+
+void
+ves_icall_System_Net_Sockets_Socket_Blocking_internal (gsize sock, gboolean block, gint32 *error);
+
+gpointer
+ves_icall_System_Net_Sockets_Socket_Accept_internal (gsize sock, gint32 *error, gboolean blocking);
+
+void
+ves_icall_System_Net_Sockets_Socket_Listen_internal (gsize sock, guint32 backlog, gint32 *error);
+
+MonoObject*
+ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal (gsize sock, gint32 af, gint32 *error);
+
+MonoObject*
+ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal (gsize sock, gint32 af, gint32 *error);
+
+void
+ves_icall_System_Net_Sockets_Socket_Bind_internal (gsize sock, MonoObject *sockaddr, gint32 *error);
+
+void
+ves_icall_System_Net_Sockets_Socket_Connect_internal (gsize sock, MonoObject *sockaddr, gint32 *error, gboolean blocking);
+
+gint32
+ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count,
+ gint32 flags, gint32 *error, gboolean blocking);
+
+gint32
+ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArray *buffers, gint32 flags, gint32 *error,
+ gboolean blocking);
+
+gint32
+ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count,
+ gint32 flags, MonoObject **sockaddr, gint32 *error, gboolean blocking);
+
+gint32
+ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count,
+ gint32 flags, gint32 *error, gboolean blocking);
+
+gint32
+ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArray *buffers, gint32 flags, gint32 *error,
+ gboolean blocking);
+
+gint32
+ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count,
+ gint32 flags, MonoObject *sockaddr, gint32 *error, gboolean blocking);
+
+void
+ves_icall_System_Net_Sockets_Socket_Select_internal (MonoArray **sockets, gint32 timeout, gint32 *error);
+
+void
+ves_icall_System_Net_Sockets_Socket_Shutdown_internal (gsize sock, gint32 how, gint32 *error);
+
+void
+ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal (gsize sock, gint32 level, gint32 name,
+ MonoObject **obj_val, gint32 *error);
+
+void
+ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal (gsize sock, gint32 level, gint32 name,
+ MonoArray **byte_val, gint32 *error);
+
+void
+ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (gsize sock, gint32 level, gint32 name,
+ MonoObject *obj_val, MonoArray *byte_val, gint32 int_val, gint32 *error);
+
+int
+ves_icall_System_Net_Sockets_Socket_IOControl_internal (gsize sock, gint32 code, MonoArray *input, MonoArray *output,
+ gint32 *error);
+
+MonoBoolean
+ves_icall_System_Net_Dns_GetHostByName_internal (MonoString *host, MonoString **h_name, MonoArray **h_aliases,
+ MonoArray **h_addr_list, gint32 hint);
+
+MonoBoolean
+ves_icall_System_Net_Dns_GetHostByAddr_internal (MonoString *addr, MonoString **h_name, MonoArray **h_aliases,
+ MonoArray **h_addr_list, gint32 hint);
+
+MonoBoolean
+ves_icall_System_Net_Dns_GetHostName_internal (MonoString **h_name);
+
+MonoBoolean
+ves_icall_System_Net_Sockets_Socket_Poll_internal (gsize sock, gint mode, gint timeout, gint32 *error);
+
+void
+ves_icall_System_Net_Sockets_Socket_Disconnect_internal (gsize sock, MonoBoolean reuse, gint32 *error);
+
+gboolean
+ves_icall_System_Net_Sockets_Socket_SendFile_internal (gsize sock, MonoString *filename, MonoArray *pre_buffer,
+ MonoArray *post_buffer, gint flags, gint32 *error, gboolean blocking);
+
+void
+icall_cancel_blocking_socket_operation (MonoThread *thread);
+
+gboolean
+ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto);
+
+void
+mono_network_init(void);
+
+void
+mono_network_cleanup(void);
+
+#endif /* _MONO_METADATA_W32SOCKET_H_ */
boehm_libs= \
$(monodir)/mono/metadata/libmonoruntime.la \
- $(monodir)/mono/io-layer/libwapi.la \
$(monodir)/mono/utils/libmonoutils.la \
$(GLIB_LIBS) $(LIBICONV) \
$(libgc_libs)
sgen_libs = \
$(monodir)/mono/metadata/libmonoruntimesgen.la \
$(monodir)/mono/sgen/libmonosgen.la \
- $(monodir)/mono/io-layer/libwapi.la \
$(monodir)/mono/utils/libmonoutils.la \
$(GLIB_LIBS) $(LIBICONV)
boehm_static_libs= \
$(monodir)/mono/metadata/libmonoruntime-static.la \
- $(monodir)/mono/io-layer/libwapi.la \
$(monodir)/mono/utils/libmonoutils.la \
$(GLIB_LIBS) $(LIBICONV) \
$(libgc_static_libs)
sgen_static_libs = \
$(monodir)/mono/metadata/libmonoruntimesgen-static.la \
$(monodir)/mono/sgen/libmonosgen-static.la \
- $(monodir)/mono/io-layer/libwapi.la \
$(monodir)/mono/utils/libmonoutils.la \
$(GLIB_LIBS) $(LIBICONV)
regtests_UNIVERSAL=basic.exe basic-float.exe basic-long.exe basic-calls.exe objects.exe arrays.exe basic-math.exe exceptions.exe iltests.exe devirtualization.exe generics.exe basic-simd.exe basic-vectors.exe
-iregtests=basic.exe basic-float.exe basic-long.exe basic-calls.exe
+iregtests=basic.exe basic-float.exe basic-long.exe basic-calls.exe generics-interp.exe
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
regtests= \
$(regtests_UNIVERSAL)
else
regtests= \
$(regtests_UNIVERSAL) \
- $(regtests_TESTING_AOT_FULL_BLACKLIST)
+ $(regtests_FULL_AOT_TESTS_BLACKLIST)
endif
if X86
fullaot_regtests = $(regtests) aot-tests.exe $(if $(GSHAREDVT),gshared.exe)
# Skip aoting the tests that aren't compiled
-# on the testing_aot_full profile because they're skipped
+# on the full aot profiles because they're skipped
# on mobile profiles
-FULLAOT_LIBS_TESTING_AOT_FULL_BLACKLIST = \
+FULLAOT_LIBS_FULL_AOT_TESTS_BLACKLIST = \
Mono.Posix.dll \
System.Configuration.dll
System.Numerics.dll \
System.Numerics.Vectors.dll
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
FULLAOT_LIBS= \
- Mono.Dynamic.Interpreter.dll \
$(FULLAOT_LIBS_UNIVERSAL)
else
FULLAOT_LIBS= \
$(FULLAOT_LIBS_UNIVERSAL) \
- $(FULLAOT_LIBS_TESTING_AOT_FULL_BLACKLIST)
+ $(FULLAOT_LIBS_FULL_AOT_TESTS_BLACKLIST)
endif
FULLAOT_TMP_DIR=$(top_builddir)/mono/mini/fullaot-tmp
#include <mono/utils/json.h>
#include <mono/utils/mono-threads-coop.h>
#include <mono/profiler/mono-profiler-aot.h>
-#include <mono/io-layer/io-layer.h>
+#include <mono/utils/w32api.h>
#include "aot-compiler.h"
#include "seq-points.h"
MonoError error;
MonoThread *thread = mono_thread_attach (domain);
- mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "AOT compiler"), TRUE, &error);
+ mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "AOT compiler"), TRUE, FALSE, &error);
mono_error_assert_ok (&error);
for (i = 0; i < methods->len; ++i)
}
}
+ fclose (infile);
acfg->profile_data = g_list_append (acfg->profile_data, data);
}
gboolean mono_aot_is_direct_callable (MonoJumpInfo *patch_info) MONO_LLVM_INTERNAL;
void mono_aot_mark_unused_llvm_plt_entry(MonoJumpInfo *patch_info) MONO_LLVM_INTERNAL;
char* mono_aot_get_plt_symbol (MonoJumpInfoType type, gconstpointer data) MONO_LLVM_INTERNAL;
-char* mono_aot_get_direct_call_symbol (MonoJumpInfoType type, gconstpointer data);
+char* mono_aot_get_direct_call_symbol (MonoJumpInfoType type, gconstpointer data) MONO_LLVM_INTERNAL;
int mono_aot_get_method_index (MonoMethod *method) MONO_LLVM_INTERNAL;
MonoJumpInfo* mono_aot_patch_info_dup (MonoJumpInfo* ji) MONO_LLVM_INTERNAL;
amodule_lock (amodule);
- InterlockedIncrement (&mono_jit_stats.methods_aot);
-
- amodule->methods_loaded [method_index / 32] |= 1 << (method_index % 32);
-
init_plt (amodule);
+ InterlockedIncrement (&mono_jit_stats.methods_aot);
+
if (method && method->wrapper_type)
g_hash_table_insert (amodule->method_to_code, method, code);
+ /* Commit changes since methods_loaded is accessed outside the lock */
+ mono_memory_barrier ();
+
+ amodule->methods_loaded [method_index / 32] |= 1 << (method_index % 32);
+
amodule_unlock (amodule);
if (mono_profiler_get_events () & MONO_PROFILE_JIT_COMPILATION) {
#include <unistd.h>
#include <errno.h>
#include <arpa/inet.h>
-#include <errno.h>
#if 0
#define CFG_DEBUG
call: dest:a clob:c len:17
tailcall: len:120 clob:c
br: len:5
-seq_point: len:24 clob:c
+seq_point: len:26 clob:c
il_seq_point: len:0
int_beq: len:6
#include <mono/metadata/environment.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/threadpool.h>
-#include <mono/metadata/socket-io.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/runtime.h>
#include <mono/metadata/verify-internals.h>
#include <mono/metadata/reflection-internals.h>
+#include <mono/metadata/w32socket.h>
#include <mono/utils/mono-coop-mutex.h>
#include <mono/utils/mono-coop-semaphore.h>
#include <mono/utils/mono-error-internals.h>
#include "debugger-agent.h"
#include "mini.h"
#include "seq-points.h"
-#include <mono/io-layer/io-layer.h>
+#include <mono/utils/w32api.h>
/*
* On iOS we can't use System.Environment.Exit () as it will do the wrong
#define HEADER_LENGTH 11
#define MAJOR_VERSION 2
-#define MINOR_VERSION 44
+#define MINOR_VERSION 45
typedef enum {
CMD_SET_VM = 1,
CMD_ASSEMBLY_GET_MANIFEST_MODULE = 3,
CMD_ASSEMBLY_GET_OBJECT = 4,
CMD_ASSEMBLY_GET_TYPE = 5,
- CMD_ASSEMBLY_GET_NAME = 6
+ CMD_ASSEMBLY_GET_NAME = 6,
+ CMD_ASSEMBLY_GET_DOMAIN = 7
} CmdAssembly;
typedef enum {
int nframes;
/* If set, don't stop in methods that are not part of user assemblies */
MonoAssembly** user_assemblies;
+ /* Used to distinguish stepping breakpoint hits in parallel tasks executions */
+ int async_id;
+ /* Used to know if we are in process of async step-out and distishing from exception breakpoints */
+ MonoMethod* async_stepout_method;
} SingleStepReq;
/*
if (pos == NULL || pos == address)
return 1;
- *host = (char *)g_malloc (pos - address + 1);
- strncpy (*host, address, pos - address);
- (*host) [pos - address] = '\0';
+ size_t len = pos - address;
+ *host = (char *)g_malloc (len + 1);
+ memcpy (*host, address, len);
+ (*host) [len] = '\0';
*port = atoi (pos + 1);
static void
send_types_for_domain (MonoDomain *domain, void *user_data)
{
+ MonoDomain* old_domain;
AgentDomainInfo *info = NULL;
info = get_agent_domain_info (domain);
g_assert (info);
+
+ old_domain = mono_domain_get ();
+
+ mono_domain_set (domain, TRUE);
mono_loader_lock ();
g_hash_table_foreach (info->loaded_classes, emit_type_load, NULL);
mono_loader_unlock ();
+
+ mono_domain_set (old_domain, TRUE);
+}
+
+static void
+send_assemblies_for_domain (MonoDomain *domain, void *user_data)
+{
+ GSList *tmp;
+ MonoDomain* old_domain;
+
+ old_domain = mono_domain_get ();
+
+ mono_domain_set (domain, TRUE);
+
+ mono_domain_assemblies_lock (domain);
+ for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) {
+ MonoAssembly* ass = (MonoAssembly *)tmp->data;
+ emit_assembly_load (ass, NULL);
+ }
+ mono_domain_assemblies_unlock (domain);
+
+ mono_domain_set (old_domain, TRUE);
}
static void
compute_frame_info (tls->thread, tls);
}
+static gboolean
+ensure_jit (StackFrame* frame)
+{
+ if (!frame->jit) {
+ frame->jit = mono_debug_find_method (frame->api_method, frame->domain);
+ if (!frame->jit && frame->api_method->is_inflated)
+ frame->jit = mono_debug_find_method(mono_method_get_declaring_generic_method (frame->api_method), frame->domain);
+ if (!frame->jit) {
+ char *s;
+
+ /* This could happen for aot images with no jit debug info */
+ s = mono_method_full_name (frame->api_method, TRUE);
+ DEBUG_PRINTF(1, "[dbg] No debug information found for '%s'.\n", s);
+ g_free (s);
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
/*
* ss_update:
*
* Return FALSE if single stepping needs to continue.
*/
static gboolean
-ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *tls, MonoContext *ctx)
+ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *tls, MonoContext *ctx, MonoMethod* method)
{
MonoDebugMethodInfo *minfo;
MonoDebugSourceLocation *loc = NULL;
gboolean hit = TRUE;
- MonoMethod *method;
+
+ if (req->async_stepout_method == method) {
+ DEBUG_PRINTF (1, "[%p] Breakpoint hit during async step-out at %s hit, continuing stepping out.\n", (gpointer)(gsize)mono_native_thread_id_get (), method->name);
+ return FALSE;
+ }
if (req->depth == STEP_DEPTH_OVER && (sp->flags & MONO_SEQ_POINT_FLAG_NONEMPTY_STACK)) {
/*
return FALSE;
}
- if ((req->depth == STEP_DEPTH_OVER || req->depth == STEP_DEPTH_OUT) && hit) {
+ if ((req->depth == STEP_DEPTH_OVER || req->depth == STEP_DEPTH_OUT) && hit && !req->async_stepout_method) {
gboolean is_step_out = req->depth == STEP_DEPTH_OUT;
ss_calculate_framecount (tls, ctx);
}
if (req->depth == STEP_DEPTH_INTO && req->size == STEP_SIZE_MIN && (sp->flags & MONO_SEQ_POINT_FLAG_NONEMPTY_STACK) && ss_req->start_method){
- method = jinfo_get_method (ji);
ss_calculate_framecount (tls, ctx);
if (ss_req->start_method == method && req->nframes && tls->frame_count == req->nframes) {//Check also frame count(could be recursion)
DEBUG_PRINTF (1, "[%p] Seq point at nonempty stack %x while stepping in, continuing single stepping.\n", (gpointer) (gsize) mono_native_thread_id_get (), sp->il_offset);
}
}
+ MonoDebugMethodAsyncInfo* asyncMethod = mono_debug_lookup_method_async_debug_info (method);
+ if (asyncMethod) {
+ for (int i = 0; i < asyncMethod->num_awaits; i++)
+ {
+ if (asyncMethod->yield_offsets[i] == sp->il_offset || asyncMethod->resume_offsets[i] == sp->il_offset) {
+ mono_debug_free_method_async_debug_info (asyncMethod);
+ return FALSE;
+ }
+ }
+ mono_debug_free_method_async_debug_info (asyncMethod);
+ }
+
if (req->size != STEP_SIZE_LINE)
return TRUE;
/* Have to check whenever a different source line was reached */
- method = jinfo_get_method (ji);
minfo = mono_debug_lookup_method (method);
if (minfo)
return bp->method && bp->method->klass->image->assembly == assembly;
}
+static MonoObject*
+get_this (StackFrame *frame)
+{
+ //Logic inspiered by "add_var" method and took out path that happens in async method for getting this
+ MonoDebugVarInfo *var = frame->jit->this_var;
+ if ((var->index & MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS) != MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET)
+ return NULL;
+
+ guint8 * addr = (guint8 *)mono_arch_context_get_int_reg (&frame->ctx, var->index & ~MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS);
+ addr += (gint32)var->offset;
+ return *(MonoObject**)addr;
+}
+
+//This ID is used to figure out if breakpoint hit on resumeOffset belongs to us or not
+//since thread probably changed...
+static int
+get_this_async_id (StackFrame *frame)
+{
+ return get_objid (get_this (frame));
+}
+
+static MonoMethod* set_notification_method_cache = NULL;
+
+static MonoMethod*
+get_set_notification_method ()
+{
+ if(set_notification_method_cache != NULL)
+ return set_notification_method_cache;
+ MonoError error;
+ MonoClass* async_builder_class = mono_class_load_from_name (mono_defaults.corlib, "System.Runtime.CompilerServices", "AsyncTaskMethodBuilder");
+ GPtrArray* array = mono_class_get_methods_by_name (async_builder_class, "SetNotificationForWaitCompletion", 0x24, FALSE, FALSE, &error);
+ mono_error_assert_ok (&error);
+ g_assert (array->len == 1);
+ set_notification_method_cache = (MonoMethod *)g_ptr_array_index (array, 0);
+ g_ptr_array_free (array, TRUE);
+ return set_notification_method_cache;
+}
+
+static void
+set_set_notification_for_wait_completion_flag (StackFrame *frame)
+{
+ MonoObject* obj = get_this (frame);
+ g_assert (obj);
+ MonoClassField *builder_field = mono_class_get_field_from_name (obj->vtable->klass, "<>t__builder");
+ g_assert (builder_field);
+ MonoObject* builder;
+ MonoError error;
+ builder = mono_field_get_value_object_checked (frame->domain, builder_field, obj, &error);
+ mono_error_assert_ok (&error);
+ g_assert (builder);
+
+ void* args [1];
+ gboolean arg = TRUE;
+ args [0] = &arg;
+ mono_runtime_invoke_checked (get_set_notification_method(), mono_object_unbox (builder), args, &error);
+ mono_error_assert_ok (&error);
+ mono_field_set_value (obj, builder_field, mono_object_unbox (builder));
+}
+
+static MonoMethod* notify_debugger_of_wait_completion_method_cache = NULL;
+
+static MonoMethod*
+get_notify_debugger_of_wait_completion_method ()
+{
+ if (notify_debugger_of_wait_completion_method_cache != NULL)
+ return notify_debugger_of_wait_completion_method_cache;
+ MonoError error;
+ MonoClass* task_class = mono_class_load_from_name (mono_defaults.corlib, "System.Threading.Tasks", "Task");
+ GPtrArray* array = mono_class_get_methods_by_name (task_class, "NotifyDebuggerOfWaitCompletion", 0x24, FALSE, FALSE, &error);
+ mono_error_assert_ok (&error);
+ g_assert (array->len == 1);
+ notify_debugger_of_wait_completion_method_cache = (MonoMethod *)g_ptr_array_index (array, 0);
+ g_ptr_array_free (array, TRUE);
+ return notify_debugger_of_wait_completion_method_cache;
+}
+
static void
process_breakpoint_inner (DebuggerTlsData *tls, gboolean from_signal)
{
SingleStepReq *ss_req = (SingleStepReq *)req->info;
gboolean hit;
- if (mono_thread_internal_current () != ss_req->thread)
- continue;
+ //if we hit async_stepout_method, it's our no matter which thread
+ if ((ss_req->async_stepout_method != method) && (ss_req->async_id || mono_thread_internal_current () != ss_req->thread)) {
+ //We have different thread and we don't have async stepping in progress
+ //it's breakpoint in parallel thread, ignore it
+ if (ss_req->async_id == 0)
+ continue;
+
+ tls->context.valid = FALSE;
+ tls->async_state.valid = FALSE;
+ invalidate_frames (tls);
+ ss_calculate_framecount(tls, ctx);
+ //make sure we have enough data to get current async method instance id
+ if (tls->frame_count == 0 || !ensure_jit (tls->frames [0]))
+ continue;
- hit = ss_update (ss_req, ji, &sp, tls, ctx);
+ //Check method is async before calling get_this_async_id
+ MonoDebugMethodAsyncInfo* asyncMethod = mono_debug_lookup_method_async_debug_info (method);
+ if (!asyncMethod)
+ continue;
+ else
+ mono_debug_free_method_async_debug_info (asyncMethod);
+
+ //breakpoint was hit in parallelly executing async method, ignore it
+ if (ss_req->async_id != get_this_async_id (tls->frames [0]))
+ continue;
+ }
+
+ //Update stepping request to new thread/frame_count that we are continuing on
+ //so continuing with normal stepping works as expected
+ if (ss_req->async_stepout_method || ss_req->async_id) {
+ tls->context.valid = FALSE;
+ tls->async_state.valid = FALSE;
+ invalidate_frames (tls);
+ ss_calculate_framecount (tls, ctx);
+ ss_req->thread = mono_thread_internal_current ();
+ ss_req->nframes = tls->frame_count;
+ }
+
+ hit = ss_update (ss_req, ji, &sp, tls, ctx, method);
if (hit)
g_ptr_array_add (ss_reqs, req);
il_offset = sp.il_offset;
- if (!ss_update (ss_req, ji, &sp, tls, ctx))
+ if (!ss_update (ss_req, ji, &sp, tls, ctx, method))
return;
/* Start single stepping again from the current sequence point */
ss_req->bps = NULL;
}
+ ss_req->async_id = 0;
+ ss_req->async_stepout_method = NULL;
if (ss_req->global) {
stop_single_stepping ();
ss_req->global = FALSE;
}
}
+static gboolean
+is_last_non_empty (SeqPoint* sp, MonoSeqPointInfo *info)
+{
+ if (!sp->next_len)
+ return TRUE;
+ SeqPoint* next = g_new (SeqPoint, sp->next_len);
+ mono_seq_point_init_next (info, *sp, next);
+ for (int i = 0; i < sp->next_len; i++) {
+ if (next [i].flags & MONO_SEQ_POINT_FLAG_NONEMPTY_STACK) {
+ if (!is_last_non_empty (&next [i], info)) {
+ g_free (next);
+ return FALSE;
+ }
+ } else {
+ g_free (next);
+ return FALSE;
+ }
+ }
+ g_free (next);
+ return TRUE;
+}
+
/*
* ss_start:
*
nframes = tls->frame_count;
}
+ MonoDebugMethodAsyncInfo* asyncMethod = mono_debug_lookup_method_async_debug_info (method);
+
/* Need to stop in catch clauses as well */
for (i = ss_req->depth == STEP_DEPTH_OUT ? 1 : 0; i < nframes; ++i) {
StackFrame *frame = frames [i];
if (frame->ji) {
MonoJitInfo *jinfo = frame->ji;
for (j = 0; j < jinfo->num_clauses; ++j) {
+ // In case of async method we don't want to place breakpoint on last catch handler(which state machine added for whole method)
+ if (asyncMethod && asyncMethod->num_awaits && i == 0 && j + 1 == jinfo->num_clauses)
+ break;
MonoJitExceptionInfo *ei = &jinfo->clauses [j];
if (mono_find_next_seq_point_for_native_offset (frame->domain, frame->method, (char*)ei->handler_start - (char*)jinfo->code_start, NULL, &local_sp))
}
}
+ if (asyncMethod && asyncMethod->num_awaits && nframes && ensure_jit (frames [0])) {
+ //asyncMethod has value and num_awaits > 0, this means we are inside async method with awaits
+
+ // Check if we hit yield_offset during normal stepping, because if we did...
+ // Go into special async stepping mode which places breakpoint on resumeOffset
+ // of this await call and sets async_id so we can distinguish it from parallel executions
+ for (i = 0; i < asyncMethod->num_awaits; i++) {
+ if (sp->il_offset == asyncMethod->yield_offsets [i]) {
+ ss_req->async_id = get_this_async_id (frames [0]);
+ ss_bp_add_one (ss_req, &ss_req_bp_count, &ss_req_bp_cache, method, asyncMethod->resume_offsets [i]);
+ if (ss_req_bp_cache)
+ g_hash_table_destroy (ss_req_bp_cache);
+ mono_debug_free_method_async_debug_info (asyncMethod);
+ return;
+ }
+ }
+ //If we are at end of async method and doing step-in or step-over...
+ //Switch to step-out, so whole NotifyDebuggerOfWaitCompletion magic happens...
+ if (is_last_non_empty (sp, info)) {
+ ss_req->depth = STEP_DEPTH_OUT;//setting depth to step-out is important, don't inline IF, because code later depends on this
+ }
+ if (ss_req->depth == STEP_DEPTH_OUT) {
+ set_set_notification_for_wait_completion_flag (frames [0]);
+ ss_req->async_id = get_this_async_id (frames [0]);
+ ss_req->async_stepout_method = get_notify_debugger_of_wait_completion_method ();
+ ss_bp_add_one (ss_req, &ss_req_bp_count, &ss_req_bp_cache, ss_req->async_stepout_method, 0);
+ if (ss_req_bp_cache)
+ g_hash_table_destroy (ss_req_bp_cache);
+ mono_debug_free_method_async_debug_info (asyncMethod);
+ return;
+ }
+ }
+
+ if (asyncMethod)
+ mono_debug_free_method_async_debug_info (asyncMethod);
+
/*
- * Find the first sequence point in the current or in a previous frame which
- * is not the last in its method.
- */
+ * Find the first sequence point in the current or in a previous frame which
+ * is not the last in its method.
+ */
if (ss_req->depth == STEP_DEPTH_OUT) {
/* Ignore seq points in current method */
while (frame_index < nframes) {
break;
case EVENT_KIND_ASSEMBLY_LOAD:
/* Emit load events for currently loaded assemblies */
- mono_assembly_foreach (emit_assembly_load, NULL);
+ mono_domain_foreach (send_assemblies_for_domain, NULL);
break;
case EVENT_KIND_THREAD_START:
/* Emit start events for currently started threads */
mono_error_cleanup (&error);
return err;
}
+ case CMD_ASSEMBLY_GET_DOMAIN: {
+ buffer_add_domainid (buf, domain);
+ break;
+ }
case CMD_ASSEMBLY_GET_TYPE: {
MonoError error;
char *s = decode_string (p, &p, end);
if (!frame->has_ctx)
return ERR_ABSENT_INFORMATION;
- if (!frame->jit) {
- frame->jit = mono_debug_find_method (frame->api_method, frame->domain);
- if (!frame->jit && frame->api_method->is_inflated)
- frame->jit = mono_debug_find_method (mono_method_get_declaring_generic_method (frame->api_method), frame->domain);
- if (!frame->jit) {
- char *s;
+ if (!ensure_jit (frame))
+ return ERR_ABSENT_INFORMATION;
- /* This could happen for aot images with no jit debug info */
- s = mono_method_full_name (frame->api_method, TRUE);
- DEBUG_PRINTF (1, "[dbg] No debug information found for '%s'.\n", s);
- g_free (s);
- return ERR_ABSENT_INFORMATION;
- }
- }
jit = frame->jit;
sig = mono_method_signature (frame->actual_method);
"GET_MANIFEST_MODULE",
"GET_OBJECT",
"GET_TYPE",
- "GET_NAME"
+ "GET_NAME",
+ "GET_DOMAIN"
};
static const char* module_cmds_str[] = {
debugger_thread_id = mono_native_thread_id_get ();
MonoThread *thread = mono_thread_attach (mono_get_root_domain ());
- mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "Debugger agent"), TRUE, &error);
+ mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "Debugger agent"), TRUE, FALSE, &error);
mono_error_assert_ok (&error);
thread->internal_thread->state |= ThreadState_Background;
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/marshal.h>
-#include <mono/metadata/socket-io.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/debug-helpers.h>
-#include <mono/io-layer/io-layer.h>
#include "mono/metadata/profiler.h"
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/mono-config.h>
#endif
-static const OptFunc
-opt_funcs [sizeof (int) * 8] = {
- NULL
-};
-
#ifdef __native_client__
extern char *nacl_mono_path;
#endif
{
guint32 exclude = 0;
const char *n;
- int i, invert, len;
+ int i, invert;
+ char **parts, **ptr;
/* Initialize the hwcap module if necessary. */
mono_hwcap_init ();
if (!p)
return opt;
- while (*p) {
+ parts = g_strsplit (p, ",", -1);
+ for (ptr = parts; ptr && *ptr; ptr ++) {
+ char *arg = *ptr;
+ char *p = arg;
+
if (*p == '-') {
p++;
invert = TRUE;
}
for (i = 0; i < G_N_ELEMENTS (opt_names) && optflag_get_name (i); ++i) {
n = optflag_get_name (i);
- len = strlen (n);
- if (strncmp (p, n, len) == 0) {
+ if (!strcmp (p, n)) {
if (invert)
opt &= ~ (1 << i);
else
opt |= 1 << i;
- p += len;
- if (*p == ',') {
- p++;
- break;
- } else if (*p == '=') {
- p++;
- if (opt_funcs [i])
- opt_funcs [i] (p);
- while (*p && *p++ != ',');
- break;
- }
- /* error out */
break;
}
}
opt = 0;
else
opt = ~(EXCLUDED_FROM_ALL | exclude);
- p += 3;
- if (*p == ',')
- p++;
} else {
fprintf (stderr, "Invalid optimization name `%s'\n", p);
exit (1);
}
}
+
+ g_free (arg);
}
+ g_free (parts);
+
return opt;
}
g_print ("Compiling %d %s\n", count, desc);
g_free (desc);
}
- cfg = mini_method_compile (method, mono_get_optimizations_for_method (method, args->opts), mono_get_root_domain (), (JitFlags)0, 0, -1);
+ cfg = mini_method_compile (method, mono_get_optimizations_for_method (method, args->opts), mono_get_root_domain (), (JitFlags)JIT_FLAG_DISCARD_RESULTS, 0, -1);
if (cfg->exception_type != MONO_EXCEPTION_NONE) {
printf ("Compilation of %s failed with exception '%s':\n", mono_method_full_name (cfg->method, TRUE), cfg->exception_message);
fail_count ++;
}
mono_set_defaults (mini_verbose, opt);
-#if ENABLE_INTERPRETER
- if (mono_use_interpreter)
- domain = mono_interp_init (argv [i]);
- else
+#ifdef ENABLE_INTERPRETER
+ mono_interp_init ();
#endif
domain = mini_init (argv [i], forced_version);
#include <mono/metadata/mono-endian.h>
#include <mono/metadata/debug-mono-symfile.h>
#include <mono/metadata/mono-debug-debugger.h>
-#include <mono/utils/mono-compiler.h>
#ifndef HOST_WIN32
#include <mono/utils/freebsd-elf32.h>
#define restore_regs_from_context(ctx_reg,ip_reg,tmp_reg) do { \
int reg; \
ppc_ldptr (code, ip_reg, G_STRUCT_OFFSET (MonoContext, sc_ir), ctx_reg); \
- ppc_load_multiple_regs (code, ppc_r13, G_STRUCT_OFFSET (MonoContext, regs), ctx_reg); \
- for (reg = 0; reg < MONO_SAVED_FREGS; ++reg) { \
- ppc_lfd (code, (14 + reg), \
+ ppc_load_multiple_regs (code, MONO_PPC_FIRST_SAVED_GREG, \
+ G_STRUCT_OFFSET (MonoContext, regs) + MONO_PPC_FIRST_SAVED_GREG * sizeof (gpointer), ctx_reg); \
+ for (reg = MONO_PPC_FIRST_SAVED_FREG; reg < MONO_MAX_FREGS; ++reg) { \
+ ppc_lfd (code, reg, \
G_STRUCT_OFFSET(MonoContext, fregs) + reg * sizeof (gdouble), ctx_reg); \
} \
} while (0)
return start;
}
-#define SAVED_REGS_LENGTH (sizeof (gdouble) * MONO_SAVED_FREGS + sizeof (gpointer) * MONO_SAVED_GREGS)
+#define SAVED_REGS_LENGTH (sizeof (gdouble) * MONO_MAX_FREGS + sizeof (gpointer) * MONO_MAX_IREGS)
#define ALIGN_STACK_FRAME_SIZE(s) (((s) + MONO_ARCH_FRAME_ALIGNMENT - 1) & ~(MONO_ARCH_FRAME_ALIGNMENT - 1))
/* The 64 bytes here are for outgoing arguments and a bit of spare.
We don't use it all, but it doesn't hurt. */
{
int i;
- for (i = 31; i >= 14; --i) {
+ for (i = MONO_MAX_FREGS - 1; i >= MONO_PPC_FIRST_SAVED_FREG; --i) {
pos -= sizeof (gdouble);
ppc_stfd (code, i, pos, ppc_sp);
}
+ pos -= (MONO_MAX_FREGS - MONO_SAVED_FREGS) * sizeof (gdouble);
pos -= sizeof (gpointer) * MONO_SAVED_GREGS;
- ppc_store_multiple_regs (code, ppc_r13, pos, ppc_sp);
+ ppc_store_multiple_regs (code, MONO_PPC_FIRST_SAVED_GREG, pos, ppc_sp);
return code;
}
/* restore all the regs from the stack */
pos = alloc_size;
- for (i = 31; i >= 14; --i) {
+ for (i = MONO_MAX_FREGS - 1; i >= MONO_PPC_FIRST_SAVED_FREG; --i) {
pos -= sizeof (gdouble);
ppc_lfd (code, i, pos, ppc_sp);
}
+ pos -= (MONO_MAX_FREGS - MONO_SAVED_FREGS) * sizeof (gdouble);
pos -= sizeof (gpointer) * MONO_SAVED_GREGS;
- ppc_load_multiple_regs (code, ppc_r13, pos, ppc_sp);
+ ppc_load_multiple_regs (code, MONO_PPC_FIRST_SAVED_GREG, pos, ppc_sp);
ppc_addic (code, ppc_sp, ppc_sp, alloc_size);
ppc_blr (code);
/*printf ("stack in throw: %p\n", esp);*/
MONO_CONTEXT_SET_BP (&ctx, esp);
MONO_CONTEXT_SET_IP (&ctx, eip);
- memcpy (&ctx.regs, int_regs, sizeof (mgreg_t) * MONO_SAVED_GREGS);
- memcpy (&ctx.fregs, fp_regs, sizeof (double) * MONO_SAVED_FREGS);
+ memcpy (&ctx.regs, int_regs, sizeof (mgreg_t) * MONO_MAX_IREGS);
+ memcpy (&ctx.fregs, fp_regs, sizeof (double) * MONO_MAX_FREGS);
if (mono_object_isinst_checked (exc, mono_defaults.exception_class, &error)) {
MonoException *mono_ex = (MonoException*)exc;
else
ppc_mr (code, ppc_r4, ppc_r0); /* caller ip */
/* pointer to the saved fp regs */
- pos = alloc_size - sizeof (gdouble) * MONO_SAVED_FREGS;
+ pos = alloc_size - sizeof (gdouble) * MONO_MAX_FREGS;
ppc_addi (code, ppc_r7, ppc_sp, pos);
/* pointer to the saved int regs */
- pos -= sizeof (gpointer) * MONO_SAVED_GREGS;
+ pos -= sizeof (gpointer) * MONO_MAX_IREGS;
ppc_addi (code, ppc_r6, ppc_sp, pos);
ppc_li (code, ppc_r8, rethrow);
if (!ji->is_trampoline && jinfo_get_method (ji)->save_lmf) {
/* sframe->sp points just past the end of the LMF */
guint8 *lmf_addr = (guint8*)sframe->sp - sizeof (MonoLMF);
- memcpy (&new_ctx->fregs, lmf_addr + G_STRUCT_OFFSET (MonoLMF, fregs), sizeof (double) * MONO_SAVED_FREGS);
- memcpy (&new_ctx->regs, lmf_addr + G_STRUCT_OFFSET (MonoLMF, iregs), sizeof (mgreg_t) * MONO_SAVED_GREGS);
+ memcpy (&new_ctx->fregs [MONO_PPC_FIRST_SAVED_FREG], lmf_addr + G_STRUCT_OFFSET (MonoLMF, fregs), sizeof (double) * MONO_SAVED_FREGS);
+ memcpy (&new_ctx->regs [MONO_PPC_FIRST_SAVED_GREG], lmf_addr + G_STRUCT_OFFSET (MonoLMF, iregs), sizeof (mgreg_t) * MONO_SAVED_GREGS);
/* the calling IP is in the parent frame */
sframe = (MonoPPCStackFrame*)sframe->sp;
/* we substract 4, so that the IP points into the call instruction */
} else {
regs [ppc_lr] = ctx->sc_ir;
regs [ppc_sp] = ctx->sc_sp;
- for (i = 0; i < MONO_SAVED_GREGS; ++i)
- regs [ppc_r13 + i] = ctx->regs [i];
+ for (i = MONO_PPC_FIRST_SAVED_GREG; i < MONO_MAX_IREGS; ++i)
+ regs [i] = ctx->regs [i];
mono_unwind_frame (unwind_info, unwind_info_len, ji->code_start,
(guint8*)ji->code_start + ji->code_size,
MONO_CONTEXT_SET_IP (new_ctx, regs [ppc_lr] - 4);
MONO_CONTEXT_SET_BP (new_ctx, cfa);
- for (i = 0; i < MONO_SAVED_GREGS; ++i)
- new_ctx->regs [i] = regs [ppc_r13 + i];
+ for (i = MONO_PPC_FIRST_SAVED_GREG; i < MONO_MAX_IREGS; ++i)
+ new_ctx->regs [i] = regs [i];
}
return TRUE;
MONO_CONTEXT_SET_IP (new_ctx, sframe->lr);*/
MONO_CONTEXT_SET_BP (new_ctx, (*lmf)->ebp);
MONO_CONTEXT_SET_IP (new_ctx, (*lmf)->eip);
- memcpy (&new_ctx->regs, (*lmf)->iregs, sizeof (mgreg_t) * MONO_SAVED_GREGS);
- memcpy (&new_ctx->fregs, (*lmf)->fregs, sizeof (double) * MONO_SAVED_FREGS);
+ memcpy (&new_ctx->regs [MONO_PPC_FIRST_SAVED_GREG], (*lmf)->iregs, sizeof (mgreg_t) * MONO_SAVED_GREGS);
+ memcpy (&new_ctx->fregs [MONO_PPC_FIRST_SAVED_FREG], (*lmf)->fregs, sizeof (double) * MONO_SAVED_FREGS);
frame->ji = ji;
frame->type = FRAME_TYPE_MANAGED_TO_NATIVE;
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Threading;
+using System.Threading.Tasks;
+
+#if __MOBILE__
+class GenericsTests
+#else
+class Tests
+#endif
+{
+ struct TestStruct {
+ public int i;
+ public int j;
+
+ public TestStruct (int i, int j) {
+ this.i = i;
+ this.j = j;
+ }
+ }
+
+#if !__MOBILE__
+ public static int Main (string[] args) {
+ return TestDriver.RunTests (typeof (Tests), args);
+ }
+#endif
+
+ public static int test_1_no_nullable_unbox ()
+ {
+ return Unbox<int> (1);
+ }
+
+ public static int test_1_nullable_unbox_null ()
+ {
+ return Unbox<int?> (null).HasValue ? 0 : 1;
+ }
+
+ public static int test_1_nullable_box ()
+ {
+ return (int) Box<int?> (1);
+ }
+
+ public static int test_1_nullable_box_null ()
+ {
+ return Box<int?> (null) == null ? 1 : 0;
+ }
+
+ public static int test_1_isinst_nullable ()
+ {
+ object o = 1;
+ return (o is int?) ? 1 : 0;
+ }
+
+ public static int test_1_nullable_unbox_vtype ()
+ {
+ return Unbox<TestStruct?> (new TestStruct (1, 2)).Value.i;
+ }
+
+
+ public static int test_1_nullable_unbox_null_vtype ()
+ {
+ return Unbox<TestStruct?> (null).HasValue ? 0 : 1;
+ }
+
+ public static int test_1_nullable_box_vtype ()
+ {
+ return ((TestStruct)(Box<TestStruct?> (new TestStruct (1, 2)))).i;
+ }
+
+ public static int test_1_nullable_box_null_vtype ()
+ {
+ return Box<TestStruct?> (null) == null ? 1 : 0;
+ }
+
+ public static int test_1_isinst_nullable_vtype ()
+ {
+ object o = new TestStruct (1, 2);
+ return (o is TestStruct?) ? 1 : 0;
+ }
+
+ public static int test_0_nullable_normal_unbox ()
+ {
+ int? i = 5;
+
+ object o = i;
+ // This uses unbox instead of unbox_any
+ int? j = (int?)o;
+
+ if (j != 5)
+ return 1;
+
+ return 0;
+ }
+
+ public static void stelem_any<T> (T[] arr, T elem) {
+ arr [0] = elem;
+ }
+
+ public static T ldelem_any<T> (T[] arr) {
+ return arr [0];
+ }
+
+ public static int test_1_ldelem_stelem_any_int () {
+ int[] arr = new int [3];
+ stelem_any (arr, 1);
+
+ return ldelem_any (arr);
+ }
+
+ public static T return_ref<T> (ref T t) {
+ return t;
+ }
+
+ public static T ldelema_any<T> (T[] arr) {
+ return return_ref<T> (ref arr [0]);
+ }
+
+ public static int test_0_ldelema () {
+ string[] arr = new string [1];
+
+ arr [0] = "Hello";
+
+ if (ldelema_any <string> (arr) == "Hello")
+ return 0;
+ else
+ return 1;
+ }
+
+ public static T[,] newarr_multi<T> () {
+ return new T [1, 1];
+ }
+
+ public static int test_0_newarr_multi_dim () {
+ return newarr_multi<string> ().GetType () == typeof (string[,]) ? 0 : 1;
+ }
+
+ static object Box<T> (T t)
+ {
+ return t;
+ }
+
+ static T Unbox <T> (object o) {
+ return (T) o;
+ }
+}
+++ /dev/null
-#include <mono/metadata/object.h>
-#include <mono/metadata/appdomain.h>
-
-int
-mono_main (int argc, char* argv[]);
-
-MonoDomain *
-mono_interp_init(const char *file);
-
-int
-mono_interp_exec(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]);
-
-void
-mono_interp_cleanup(MonoDomain *domain);
-
#include "interp.h"
#include "mintops.h"
-#include "embed.h"
#include "hacks.h"
#include <mono/mini/mini.h>
#endif
#endif
-static gint *abort_requested;
-
-int mono_interp_traceopt = 0;
-
-#define INIT_FRAME(frame,parent_frame,obj_this,method_args,method_retval,domain,mono_method,error) \
+#define INIT_FRAME(frame,parent_frame,method_args,method_retval,domain,mono_method,error) \
do { \
(frame)->parent = (parent_frame); \
- (frame)->obj = (obj_this); \
(frame)->stack_args = (method_args); \
(frame)->retval = (method_retval); \
(frame)->runtime_method = mono_interp_get_runtime_method ((domain), (mono_method), (error)); \
#define DEBUG_INTERP 0
#define COUNT_OPS 0
#if DEBUG_INTERP
+int mono_interp_traceopt = 2;
/* If true, then we output the opcodes as we interpret them */
static int global_tracing = 1;
debug_indent_level++;
output_indent ();
mn = mono_method_full_name (method, FALSE);
- g_printerr ("(0x%08x) Entering %s (", mono_thread_internal_current (), mn);
+ g_print ("(%p) Entering %s (", mono_thread_internal_current (), mn);
g_free (mn);
- g_printerr ("%s)\n", args);
+ g_print ("%s)\n", args);
g_free (args);
}
if (mono_profiler_events & MONO_PROFILE_ENTER_LEAVE)
args = dump_retval (frame); \
output_indent (); \
mn = mono_method_full_name (frame->runtime_method->method, FALSE); \
- g_printerr ("(0x%08x) Leaving %s", mono_thread_internal_current (), mn); \
+ g_print ("(%p) Leaving %s", mono_thread_internal_current (), mn); \
g_free (mn); \
- g_printerr (" => %s\n", args); \
+ g_print (" => %s\n", args); \
g_free (args); \
debug_indent_level--; \
if (tracing == 3) global_tracing = 0; \
#else
+int mono_interp_traceopt = 0;
static void debug_enter (MonoInvocation *frame, int *tracing)
{
}
THROW_EX (mono_get_exception_execution_engine (NULL), ip); \
} while (0);
-static gpointer
-interp_create_remoting_trampoline (MonoDomain *domain, MonoMethod *method, MonoRemotingTarget target, MonoError *error)
-{
- g_error ("FIXME: use domain and error");
- // return mono_interp_get_runtime_method (mono_marshal_get_remoting_invoke_for_target (method, target));
-}
-
static mono_mutex_t runtime_method_lookup_section;
RuntimeMethod*
memcpy (data, val->data.p, size);
}
return;
+ case MONO_TYPE_GENERICINST:
+ stackval_to_data (&type->data.generic_class->container_class->byval_arg, val, data, pinvoke);
+ return;
default:
g_warning ("got type %x", type->type);
g_assert_not_reached ();
gpointer ea;
MonoType *mt;
- o = frame->obj;
+ o = frame->stack_args->data.p;
ao = (MonoArray *)o;
ac = o->vtable->klass;
gpointer ea;
MonoType *mt;
- o = frame->obj;
+ o = frame->stack_args->data.p;
ao = (MonoArray *)o;
ac = o->vtable->klass;
gint32 i, t, pos, esize;
gpointer ea;
- o = frame->obj;
+ o = frame->stack_args->data.p;
ao = (MonoArray *)o;
ac = o->vtable->klass;
size_t int_i = 0;
if (sig->hasthis) {
- margs->iargs [0] = frame->obj;
+ margs->iargs [0] = frame->stack_args->data.p;
int_i++;
}
case MONO_TYPE_I8:
margs->iargs [int_i] = frame->stack_args [i].data.p;
#if DEBUG_INTERP
- g_printerr ("build_args_from_sig: margs->iargs[%d]: %p (frame @ %d)\n", int_i, margs->iargs[int_i], i);
+ g_print ("build_args_from_sig: margs->iargs[%d]: %p (frame @ %d)\n", int_i, margs->iargs[int_i], i);
#endif
int_i++;
break;
MethodArguments *margs = build_args_from_sig (sig, frame);
#if DEBUG_INTERP
- g_printerr ("ICALL: mono_interp_enter_icall_trampoline = %p, addr = %p\n", mono_interp_enter_icall_trampoline, addr);
- g_printerr ("margs(out): ilen=%d, flen=%d\n", margs->ilen, margs->flen);
+ g_print ("ICALL: mono_interp_enter_icall_trampoline = %p, addr = %p\n", mono_interp_enter_icall_trampoline, addr);
+ g_print ("margs(out): ilen=%d, flen=%d\n", margs->ilen, margs->flen);
#endif
context->current_frame = frame;
/* domain can only be changed by native code */
context->domain = mono_domain_get ();
- if (*abort_requested)
+ if (*mono_thread_interruption_request_flag ())
mono_thread_interruption_checkpoint ();
if (!MONO_TYPE_ISSTRUCT (sig->ret))
{
MonoMethod *method = frame->runtime_method->method;
const char *name = method->name;
- MonoObject *obj = (MonoObject*)frame->obj;
+ MonoObject *obj = (MonoObject*) frame->stack_args->data.p;
MonoObject *isinst_obj;
MonoError error;
mono_error_cleanup (&error); /* FIXME: don't swallow the error */
if (obj && isinst_obj) {
if (*name == '.' && (strcmp (name, ".ctor") == 0)) {
- interp_delegate_ctor (context->domain, obj, frame->stack_args[0].data.p, frame->stack_args[1].data.p);
+ interp_delegate_ctor (context->domain, obj, frame->stack_args [1].data.p, frame->stack_args[2].data.p);
return;
}
}
return g_string_free (str, FALSE);
while (s < sp) {
- g_string_append_printf (str, "[%lld/0x%0llx] ", s->data.l, s->data.l);
+ g_string_append_printf (str, "[%p (%lld)] ", s->data.l, s->data.l);
++s;
}
return g_string_free (str, FALSE);
break;
case MONO_TYPE_I8:
case MONO_TYPE_U8:
- default:
- g_string_append_printf (str, "[%lld/0x%0llx] ", s->data.l, s->data.l);
+ default: {
+ GString *res = g_string_new ("");
+ mono_type_get_desc (res, type, TRUE);
+ g_string_append_printf (str, "[{%s} %lld/0x%0llx] ", res->str, s->data.l, s->data.l);
+ g_string_free (res, TRUE);
break;
}
+ }
}
static char*
int i;
MonoMethodSignature *signature = mono_method_signature (inv->runtime_method->method);
- if (signature->param_count == 0)
+ if (signature->param_count == 0 && !signature->hasthis)
return g_string_free (str, FALSE);
- if (signature->hasthis)
- g_string_append_printf (str, "%p ", inv->obj);
+ if (signature->hasthis) {
+ MonoMethod *method = inv->runtime_method->method;
+ dump_stackval (str, inv->stack_args, &method->klass->byval_arg);
+ }
for (i = 0; i < signature->param_count; ++i)
- dump_stackval (str, inv->stack_args + i, signature->params [i]);
+ dump_stackval (str, inv->stack_args + (!!signature->hasthis) + i, signature->params [i]);
return g_string_free (str, FALSE);
}
#define CHECK_MUL_OVERFLOW_NAT_UN(a,b) CHECK_MUL_OVERFLOW64_UN(a,b)
#endif
-static MonoObject*
+MonoObject*
interp_mono_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc, MonoError *error)
{
MonoInvocation frame;
int i, type, isobject = 0;
void *ret = NULL;
stackval result;
- stackval *args = alloca (sizeof (stackval) * sig->param_count);
+ stackval *args = alloca (sizeof (stackval) * (sig->param_count + !!sig->hasthis));
ThreadContext context_struct;
MonoInvocation *old_frame = NULL;
jmp_buf env;
break;
}
+ if (sig->hasthis)
+ args [0].data.p = obj;
+
for (i = 0; i < sig->param_count; ++i) {
+ int a_index = i + !!sig->hasthis;
if (sig->params [i]->byref) {
- args [i].data.p = params [i];
+ args [a_index].data.p = params [i];
continue;
}
type = sig->params [i]->type;
case MONO_TYPE_U1:
case MONO_TYPE_I1:
case MONO_TYPE_BOOLEAN:
- args [i].data.i = *(MonoBoolean*)params [i];
+ args [a_index].data.i = *(MonoBoolean*)params [i];
break;
case MONO_TYPE_U2:
case MONO_TYPE_I2:
case MONO_TYPE_CHAR:
- args [i].data.i = *(gint16*)params [i];
+ args [a_index].data.i = *(gint16*)params [i];
break;
#if SIZEOF_VOID_P == 4
case MONO_TYPE_U: /* use VAL_POINTER? */
#endif
case MONO_TYPE_U4:
case MONO_TYPE_I4:
- args [i].data.i = *(gint32*)params [i];
+ args [a_index].data.i = *(gint32*)params [i];
break;
#if SIZEOF_VOID_P == 8
case MONO_TYPE_U:
#endif
case MONO_TYPE_U8:
case MONO_TYPE_I8:
- args [i].data.l = *(gint64*)params [i];
+ args [a_index].data.l = *(gint64*)params [i];
break;
case MONO_TYPE_VALUETYPE:
if (sig->params [i]->data.klass->enumtype) {
type = mono_class_enum_basetype (sig->params [i]->data.klass)->type;
goto handle_enum;
} else {
- args [i].data.p = params [i];
+ args [a_index].data.p = params [i];
}
break;
case MONO_TYPE_STRING:
case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_OBJECT:
- args [i].data.p = params [i];
+ args [a_index].data.p = params [i];
break;
default:
g_error ("type 0x%x not handled in runtime invoke", sig->params [i]->type);
if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
method = mono_marshal_get_native_wrapper (method, FALSE, FALSE);
- INIT_FRAME(&frame,context->current_frame,obj,args,&result,mono_get_root_domain (),method,error);
+ INIT_FRAME (&frame,context->current_frame,args,&result,mono_get_root_domain (),method,error);
if (exc)
frame.invoke_trap = 1;
context->managed_code = 1;
static GHashTable *method_pointer_hash = NULL;
-static gpointer
-mono_create_method_pointer (MonoMethod *method, MonoError *error)
+gpointer
+interp_create_method_pointer (MonoMethod *method, MonoError *error)
{
gpointer addr;
MonoJitInfo *ji;
- mono_error_init (error);
mono_os_mutex_lock (&create_method_pointer_mutex);
if (!method_pointer_hash) {
} \
sp->data.l = 0; \
output_indent (); \
- g_print ("(%u) ", mono_thread_internal_current ()); \
+ char *mn = mono_method_full_name (frame->runtime_method->method, FALSE); \
+ g_print ("(%p) %s -> ", mono_thread_internal_current (), mn); \
+ g_free (mn); \
mono_interp_dis_mintop(rtm->code, ip); \
g_print ("\t%d:%s\n", vt_sp - vtalloc, ins); \
g_free (ins); \
context->managed_code = 0;
#if DEBUG_INTERP
char *mn = mono_method_full_name (frame->runtime_method->method, FALSE);
- g_printerr ("(0x%08x) Transforming %s\n", mono_thread_internal_current (), mn);
+ g_print ("(%p) Transforming %s\n", mono_thread_internal_current (), mn);
g_free (mn);
#endif
frame->ex = mono_interp_transform_method (frame->runtime_method, context);
vt_sp -= READ32(ip + 2);
if (ret_size > 0) {
memmove (vt_sp, ret_vt_sp, ret_size);
+ sp [-1].data.p = vt_sp;
vt_sp += (ret_size + 7) & ~7;
}
ip += 4;
child_frame.retval = sp;
/* decrement by the actual number of args */
sp -= csignature->param_count;
- child_frame.stack_args = sp;
- if (csignature->hasthis) {
+ if (csignature->hasthis)
--sp;
- child_frame.obj = sp->data.p;
- } else {
- child_frame.obj = NULL;
- }
- if (csignature->hasthis && mono_object_is_transparent_proxy (child_frame.obj)) {
+ child_frame.stack_args = sp;
+ if (csignature->hasthis && mono_object_is_transparent_proxy (sp->data.p)) {
child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
mono_error_cleanup (&error); /* FIXME: don't swallow the error */
} else if (child_frame.runtime_method->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
child_frame.retval = sp;
/* decrement by the actual number of args */
sp -= csignature->param_count;
- child_frame.stack_args = sp;
- if (csignature->hasthis) {
+ if (csignature->hasthis)
--sp;
- child_frame.obj = sp->data.p;
- } else {
- child_frame.obj = NULL;
- }
+ child_frame.stack_args = sp;
ves_pinvoke_method (&child_frame, csignature, (MonoFuncV) code, FALSE, context);
context->current_frame = frame;
child_frame.retval = sp;
/* decrement by the actual number of args */
sp -= child_frame.runtime_method->param_count;
- child_frame.stack_args = sp;
- if (child_frame.runtime_method->hasthis) {
+ if (child_frame.runtime_method->hasthis)
--sp;
- child_frame.obj = sp->data.p;
- } else {
- child_frame.obj = NULL;
- }
- if (child_frame.runtime_method->hasthis && !child_frame.runtime_method->valuetype && mono_object_is_transparent_proxy (child_frame.obj)) {
+ child_frame.stack_args = sp;
+ if (child_frame.runtime_method->hasthis && !child_frame.runtime_method->valuetype && mono_object_is_transparent_proxy (sp->data.p)) {
child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
mono_error_cleanup (&error); /* FIXME: don't swallow the error */
}
child_frame.retval = sp;
/* decrement by the actual number of args */
sp -= child_frame.runtime_method->param_count;
- child_frame.stack_args = sp;
- if (child_frame.runtime_method->hasthis) {
+ if (child_frame.runtime_method->hasthis)
--sp;
- child_frame.obj = sp->data.p;
- } else {
- child_frame.obj = NULL;
- }
+ child_frame.stack_args = sp;
- if (child_frame.runtime_method->hasthis && !child_frame.runtime_method->valuetype && mono_object_is_transparent_proxy (child_frame.obj)) {
+ if (child_frame.runtime_method->hasthis && !child_frame.runtime_method->valuetype && mono_object_is_transparent_proxy (sp->data.p)) {
child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
mono_error_cleanup (&error); /* FIXME: don't swallow the error */
}
child_frame.retval = sp;
/* decrement by the actual number of args */
- sp -= child_frame.runtime_method->param_count;
+ sp -= child_frame.runtime_method->param_count + 1;
child_frame.stack_args = sp;
- --sp;
- child_frame.obj = this_arg = sp->data.p;
+ this_arg = sp->data.p;
if (!this_arg)
THROW_EX (mono_get_exception_null_reference(), ip - 2);
child_frame.runtime_method = get_virtual_method (context->domain, child_frame.runtime_method, this_arg);
if (this_arg->vtable->klass->valuetype && child_frame.runtime_method->valuetype) {
- child_frame.obj = (char *)this_arg + sizeof(MonoObject);
+ sp->data.p = (char *) this_arg + sizeof (MonoObject);
}
ves_exec_method_with_context (&child_frame, context);
child_frame.retval = sp;
/* decrement by the actual number of args */
- sp -= child_frame.runtime_method->param_count;
+ sp -= child_frame.runtime_method->param_count + 1;
child_frame.stack_args = sp;
- --sp;
- child_frame.obj = this_arg = sp->data.p;
+ this_arg = sp->data.p;
if (!this_arg)
THROW_EX (mono_get_exception_null_reference(), ip - 2);
child_frame.runtime_method = get_virtual_method (context->domain, child_frame.runtime_method, this_arg);
if (this_arg->vtable->klass->valuetype && child_frame.runtime_method->valuetype) {
- child_frame.obj = (char *)this_arg + sizeof(MonoObject);
+ sp->data.p = (char *) this_arg + sizeof (MonoObject);
}
ves_exec_method_with_context (&child_frame, context);
g_hash_table_insert (profiling_classes, newobj_class, GUINT_TO_POINTER (count));
}*/
-
if (newobj_class->parent == mono_defaults.array_class) {
sp -= csig->param_count;
o = ves_array_create (context->domain, newobj_class, csig, sp);
goto array_constructed;
}
+ g_assert (csig->hasthis);
+ if (csig->param_count) {
+ sp -= csig->param_count;
+ memmove (sp + 1, sp, csig->param_count * sizeof (stackval));
+ }
+ child_frame.stack_args = sp;
+
/*
* First arg is the object.
*/
if (newobj_class->valuetype) {
- if (!newobj_class->enumtype && (newobj_class->byval_arg.type == MONO_TYPE_VALUETYPE)) {
- child_frame.obj = vt_sp;
+ MonoType *t = &newobj_class->byval_arg;
+ if (!newobj_class->enumtype && (t->type == MONO_TYPE_VALUETYPE || (t->type == MONO_TYPE_GENERICINST && mono_type_generic_inst_is_valuetype (t)))) {
+ sp->data.p = vt_sp;
valuetype_this.data.p = vt_sp;
} else {
memset (&valuetype_this, 0, sizeof (stackval));
- child_frame.obj = &valuetype_this;
+ sp->data.p = &valuetype_this;
}
} else {
if (newobj_class != mono_defaults.string_class) {
o = mono_object_new_checked (context->domain, newobj_class, &error);
mono_error_cleanup (&error); /* FIXME: don't swallow the error */
context->managed_code = 1;
- if (*abort_requested)
+ if (*mono_thread_interruption_request_flag ())
mono_thread_interruption_checkpoint ();
- child_frame.obj = o;
+ sp->data.p = o;
} else {
child_frame.retval = &retval;
}
}
- if (csig->param_count) {
- sp -= csig->param_count;
- child_frame.stack_args = sp;
- } else {
- child_frame.stack_args = NULL;
- }
-
g_assert (csig->call_convention == MONO_CALL_DEFAULT);
child_frame.ip = NULL;
MINT_IN_CASE(MINT_CASTCLASS)
c = rtm->data_items [*(guint16 *)(ip + 1)];
if ((o = sp [-1].data.p)) {
- if (c->marshalbyref) {
- MonoObject *isinst_obj = mono_object_isinst_mbyref_checked (o, c, &error);
- mono_error_cleanup (&error); /* FIXME: don't swallow the error */
- if (!isinst_obj)
- THROW_EX (mono_get_exception_invalid_cast (), ip);
- } else {
- MonoVTable *vt = o->vtable;
- MonoClass *oklass = vt->klass;
- if (mono_class_is_interface (c)) {
- g_error ("FIXME: interface method lookup");
- if (c->interface_id > vt->max_interface_id /* || vt->interface_offsets [c->interface_id] == 0 */) {
- THROW_EX (mono_get_exception_invalid_cast (), ip);
- }
- } else if (c->rank) {
- MonoObject *isinst_obj = mono_object_isinst_checked (o, c, &error);
- mono_error_cleanup (&error); /* FIXME: don't swallow the error */
- if (!isinst_obj)
- THROW_EX (mono_get_exception_invalid_cast (), ip);
- } else if (!mono_class_has_parent (oklass, c)) {
- THROW_EX (mono_get_exception_invalid_cast (), ip);
- }
- }
+ MonoObject *isinst_obj = mono_object_isinst_checked (o, c, &error);
+ mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+ if (!isinst_obj)
+ THROW_EX (mono_get_exception_invalid_cast (), ip);
}
ip += 2;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ISINST)
c = rtm->data_items [*(guint16 *)(ip + 1)];
if ((o = sp [-1].data.p)) {
- if (c->marshalbyref) {
- MonoObject *isinst_obj = mono_object_isinst_mbyref_checked (o, c, &error);
- mono_error_cleanup (&error); /* FIXME: don't swallow the error */
- if (!isinst_obj)
- sp [-1].data.p = NULL;
- } else {
- MonoVTable *vt = o->vtable;
- MonoClass *oklass = vt->klass;
- if (mono_class_is_interface (c)) {
- g_error ("FIXME: interface method lookup");
- if (c->interface_id > vt->max_interface_id /* || vt->interface_offsets [c->interface_id] == 0 */) {
- sp [-1].data.p = NULL;
- }
- } else if (c->rank) {
- MonoObject *isinst_obj = mono_object_isinst_checked (o, c, &error);
- mono_error_cleanup (&error); /* FIXME: don't swallow the error */
- if (!isinst_obj)
- sp [-1].data.p = NULL;
- } else if (!mono_class_has_parent (oklass, c)) {
- sp [-1].data.p = NULL;
- }
- }
+ MonoObject *isinst_obj = mono_object_isinst_checked (o, c, &error);
+ mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+ if (!isinst_obj)
+ sp [-1].data.p = NULL;
}
ip += 2;
MINT_IN_BREAK;
THROW_EX (mono_get_exception_invalid_cast (), ip);
if (c->byval_arg.type == MONO_TYPE_VALUETYPE && !c->enumtype) {
- g_error ("unbox: implement vt");
- } else {
- stackval_from_data (&c->byval_arg, &sp [-1], mono_object_unbox (o), FALSE);
+ int size = mono_class_native_size (c, NULL);
+ sp [-1].data.p = vt_sp;
+ vt_sp += (size + 7) & ~7;
}
+ stackval_from_data (&c->byval_arg, &sp [-1], mono_object_unbox (o), FALSE);
ip += 2;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_THROW)
MINT_IN_BREAK;
}
- MINT_IN_CASE(MINT_LDTHIS)
- sp->data.p = frame->obj;
- ++ip;
- ++sp;
- MINT_IN_BREAK;
- MINT_IN_CASE(MINT_STTHIS)
- --sp;
- frame->obj = sp->data.p;
- ++ip;
- MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDTHISA)
- sp->data.p = &frame->obj;
+ g_error ("should not happen");
+ // sp->data.p = &frame->obj;
++ip;
++sp;
MINT_IN_BREAK;
exit (1);
}
-static void
-add_signal_handler (int signo, void (*handler)(int))
-{
-#ifdef HOST_WIN32
- signal (signo, handler);
-#else
- struct sigaction sa;
-
- sa.sa_handler = handler;
- sigemptyset (&sa.sa_mask);
- sa.sa_flags = 0;
-
- g_assert (sigaction (signo, &sa, NULL) != -1);
-#endif
-}
-
-static void
-segv_handler (int signum)
-{
- ThreadContext *context = mono_native_tls_get_value (thread_context_id);
- MonoException *segv_exception;
-
- if (context == NULL)
- return;
- segv_exception = mono_get_exception_null_reference ();
- segv_exception->message = mono_string_new (mono_domain_get (), "Null Reference (SIGSEGV)");
- mono_raise_exception (segv_exception);
-}
-
-
-static void
-quit_handler (int signum)
-{
- ThreadContext *context = mono_native_tls_get_value (thread_context_id);
- MonoException *quit_exception;
-
- if (context == NULL)
- return;
- quit_exception = mono_get_exception_execution_engine ("Interrupted (SIGQUIT).");
- mono_raise_exception (quit_exception);
-}
-
-static void
-abrt_handler (int signum)
-{
- ThreadContext *context = mono_native_tls_get_value (thread_context_id);
- MonoException *abrt_exception;
-
- if (context == NULL)
- return;
- abrt_exception = mono_get_exception_execution_engine ("Abort (SIGABRT).");
- mono_raise_exception (abrt_exception);
-}
-
-#if 0
-static void
-thread_abort_handler (int signum)
-{
- ThreadContext *context = mono_native_tls_get_value (thread_context_id);
- MonoException *exc;
-
- if (context == NULL)
- return;
-
- exc = mono_thread_request_interruption (context->managed_code);
- if (exc) mono_raise_exception (exc);
-}
-#endif
-
static MonoBoolean
interp_ves_icall_get_frame_info (gint32 skip, MonoBoolean need_file_info,
MonoReflectionMethod **method,
return delegate;
}
-
-typedef struct
-{
- MonoDomain *domain;
- int enable_debugging;
- char *file;
- int argc;
- char **argv;
-} MainThreadArgs;
-
-static void main_thread_handler (gpointer user_data)
-{
- MainThreadArgs *main_args=(MainThreadArgs *)user_data;
- MonoAssembly *assembly;
-
- if (main_args->enable_debugging) {
- mono_debug_init (MONO_DEBUG_FORMAT_MONO);
- }
-
- assembly = mono_domain_assembly_open (main_args->domain, main_args->file);
-
- if (!assembly){
- fprintf (stderr, "Can not open image %s\n", main_args->file);
- exit (1);
- }
-
- ves_exec (main_args->domain, assembly, main_args->argc, main_args->argv);
-}
-
-static void
-interp_mono_runtime_install_handlers (void)
-{
- add_signal_handler (SIGSEGV, segv_handler);
- add_signal_handler (SIGINT, quit_handler);
- add_signal_handler (SIGABRT, abrt_handler);
-#if 0
- add_signal_handler (mono_thread_get_abort_signal (), thread_abort_handler);
-#endif
-}
-
-static void
-quit_function (MonoDomain *domain, gpointer user_data)
-{
- mono_profiler_shutdown ();
-
- mono_runtime_cleanup (domain);
- mono_domain_free (domain, TRUE);
-
-}
-
void
-mono_interp_cleanup(MonoDomain *domain)
-{
- quit_function (domain, NULL);
-}
-
-int
-mono_interp_exec(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[])
+mono_interp_init ()
{
- return ves_exec (domain, assembly, argc, argv);
-}
-
-static gpointer
-interp_get_imt_trampoline (MonoVTable *vtable, int imt_slot_index)
-{
- // FIXME: implement me
- return NULL;
-}
-
-static gpointer
-interp_create_ftnptr (MonoDomain *domain, gpointer addr)
-{
- // FIXME: true on all arch?
- return addr;
-}
-
-// FIXME
-static gboolean
-mono_current_thread_has_handle_block_guard (void)
-{
- return FALSE;
-}
-
-// FIXME
-static gboolean
-mono_above_abort_threshold (void)
-{
- return FALSE;
-}
-
-MonoDomain *
-mono_interp_init(const char *file)
-{
- MonoDomain *domain;
- MonoRuntimeCallbacks callbacks;
- MonoRuntimeExceptionHandlingCallbacks ecallbacks;
- MonoError error;
-
- g_log_set_always_fatal (G_LOG_LEVEL_ERROR);
- g_log_set_fatal_mask (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR);
-
mono_native_tls_alloc (&thread_context_id, NULL);
mono_native_tls_set_value (thread_context_id, NULL);
mono_os_mutex_init_recursive (&runtime_method_lookup_section);
mono_os_mutex_init_recursive (&create_method_pointer_mutex);
- mono_tls_init_runtime_keys ();
-
- // TODO: use callbacks?
- interp_mono_runtime_install_handlers ();
mono_interp_transform_init ();
-
- memset (&callbacks, 0, sizeof (callbacks));
- // TODO: replace with `mono_install_callbacks`
- callbacks.compile_method = mono_create_method_pointer;
- callbacks.runtime_invoke = interp_mono_runtime_invoke;
- callbacks.get_imt_trampoline = interp_get_imt_trampoline;
- callbacks.create_ftnptr = interp_create_ftnptr;
-#ifndef DISABLE_REMOTING
- callbacks.create_remoting_trampoline = interp_create_remoting_trampoline;
-#endif
- callbacks.create_jit_trampoline = interp_create_trampoline;
- mono_install_callbacks (&callbacks);
-
-
- memset (&ecallbacks, 0, sizeof (ecallbacks));
- ecallbacks.mono_raise_exception = interp_ex_handler;
- ecallbacks.mono_current_thread_has_handle_block_guard = mono_current_thread_has_handle_block_guard;
- ecallbacks.mono_above_abort_threshold = mono_above_abort_threshold;
-#if 0
- // FIXME: ...
- mono_install_stack_walk (interp_walk_stack);
-#endif
- mono_install_eh_callbacks (&ecallbacks);
-
- mono_install_runtime_cleanup (quit_function);
-
- abort_requested = mono_thread_interruption_request_flag ();
-
- domain = mono_init_from_assembly (file, file);
-#ifdef __hpux /* generates very big stack frames */
- mono_threads_set_default_stacksize(32*1024*1024);
-#endif
- mono_icall_init ();
- /* TODO: this should use ves_icall_get_frame from mini-exceptions.c? */
- mono_add_internal_call ("System.Diagnostics.StackFrame::get_frame_info", interp_ves_icall_get_frame_info);
- /* TODO: this should use ves_icall_get_trace from mini-exceptions.c? */
- mono_add_internal_call ("System.Diagnostics.StackTrace::get_trace", interp_ves_icall_get_trace);
- mono_add_internal_call ("Mono.Runtime::mono_runtime_install_handlers", interp_mono_runtime_install_handlers);
- mono_add_internal_call ("System.Delegate::CreateDelegate_internal", ves_icall_System_Delegate_CreateDelegate_internal);
-
- mono_register_jit_icall (mono_thread_interruption_checkpoint, "mono_thread_interruption_checkpoint", mono_create_icall_signature ("object"), FALSE);
-
- mono_runtime_init_checked (domain, NULL, NULL, &error);
- mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-
- mono_thread_attach (domain);
- return domain;
}
typedef int (*TestMethod) (void);
RuntimeMethod *runtime_method; /* parent */
MonoMethod *method; /* parent */
stackval *retval; /* parent */
- void *obj; /* this - parent */
char *args;
stackval *stack_args; /* parent */
stackval *stack;
static void inline stackval_to_data (MonoType *type, stackval *val, char *data, gboolean pinvoke);
void ves_exec_method (MonoInvocation *frame);
-MonoDomain *
-mono_interp_init(const char *file);
-
/*
* defined in an arch specific file.
*/
OPDEF(MINT_LDARG_P, "ldarg.p", 2, MintOpUShortInt)
OPDEF(MINT_LDARG_VT, "ldarg.vt", 4, MintOpShortAndInt)
-OPDEF(MINT_LDTHIS, "ldthis", 1, MintOpNoArgs)
-
OPDEF(MINT_STARG_I1, "starg.i1", 2, MintOpUShortInt)
OPDEF(MINT_STARG_U1, "starg.u1", 2, MintOpUShortInt)
OPDEF(MINT_STARG_I2, "starg.i2", 2, MintOpUShortInt)
OPDEF(MINT_STARG_P, "starg.p", 2, MintOpUShortInt)
OPDEF(MINT_STARG_VT, "starg.vt", 4, MintOpShortAndInt)
-OPDEF(MINT_STTHIS, "stthis", 1, MintOpNoArgs)
-
OPDEF(MINT_STINARG_I1, "stinarg.i1", 2, MintOpUShortInt)
OPDEF(MINT_STINARG_U1, "stinarg.u1", 2, MintOpUShortInt)
OPDEF(MINT_STINARG_I2, "stinarg.i2", 2, MintOpUShortInt)
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/tabledefs.h>
-#define OPDEF(a,b,c,d,e,f,g,h,i,j) \
- a = i,
-
-enum {
-#include "mono/cil/opcode.def"
- CEE_LASTOP
-};
-#undef OPDEF
+#include <mono/mini/mini.h>
#include "mintops.h"
#include "interp.h"
goto enum_type;
} else
return MINT_TYPE_VT;
+ case MONO_TYPE_GENERICINST:
+ type = &type->data.generic_class->container_class->byval_arg;
+ goto enum_type;
default:
g_warning ("got type 0x%02x", type->type);
g_assert_not_reached ();
{
int mt;
MonoClass *klass = NULL;
- if (n == 0 && mono_method_signature (td->method)->hasthis) {
- if (td->method->klass->valuetype)
+ MonoType *type;
+
+ gboolean hasthis = mono_method_signature (td->method)->hasthis;
+ if (hasthis && n == 0)
+ type = &td->method->klass->byval_arg;
+ else
+ type = mono_method_signature (td->method)->params [hasthis ? n - 1 : n];
+
+ mt = mint_type (type);
+ if (mt == MINT_TYPE_VT) {
+ gint32 size;
+ klass = mono_class_from_mono_type (type);
+ if (mono_method_signature (td->method)->pinvoke)
+ size = mono_class_native_size (klass, NULL);
+ else
+ size = mono_class_value_size (klass, NULL);
+
+ if (hasthis && n == 0) {
mt = MINT_TYPE_P;
- else {
- mt = MINT_TYPE_O;
- klass = td->method->klass;
- }
- ADD_CODE(td, MINT_LDTHIS);
- } else {
- MonoType *type;
- n -= mono_method_signature (td->method)->hasthis;
- type = mono_method_signature (td->method)->params [n];
- mt = mint_type (type);
- if (mt == MINT_TYPE_VT) {
- gint32 size;
- if (mono_method_signature (td->method)->pinvoke)
- size = mono_class_native_size (type->data.klass, NULL);
- else
- size = mono_class_value_size (type->data.klass, NULL);
- PUSH_VT(td, size);
- ADD_CODE(td, MINT_LDARG_VT);
- ADD_CODE(td, td->rtm->arg_offsets [n]); /* FIX for large offset */
- WRITE32(td, &size);
- klass = type->data.klass;
+ ADD_CODE (td, MINT_LDARG_P);
+ ADD_CODE (td, td->rtm->arg_offsets [n]); /* FIX for large offset */
+ klass = NULL;
} else {
- ADD_CODE(td, MINT_LDARG_I1 + (mt - MINT_TYPE_I1));
- ADD_CODE(td, td->rtm->arg_offsets [n]); /* FIX for large offset */
- if (mt == MINT_TYPE_O)
- klass = mono_class_from_mono_type (type);
+ PUSH_VT (td, size);
+ ADD_CODE (td, MINT_LDARG_VT);
+ ADD_CODE (td, td->rtm->arg_offsets [n]); /* FIX for large offset */
+ WRITE32 (td, &size);
}
+ } else {
+ ADD_CODE(td, MINT_LDARG_I1 + (mt - MINT_TYPE_I1));
+ ADD_CODE(td, td->rtm->arg_offsets [n]); /* FIX for large offset */
+ if (mt == MINT_TYPE_O)
+ klass = mono_class_from_mono_type (type);
}
PUSH_TYPE(td, stack_type[mt], klass);
}
{
int mt;
CHECK_STACK (td, 1);
- if (n == 0 && mono_method_signature (td->method)->hasthis)
- ADD_CODE(td, MINT_STTHIS);
- else {
- MonoType *type;
- n -= mono_method_signature (td->method)->hasthis;
- type = mono_method_signature (td->method)->params [n];
- mt = mint_type (type);
- if (mt == MINT_TYPE_VT) {
- gint32 size;
- if (mono_method_signature (td->method)->pinvoke)
- size = mono_class_native_size (type->data.klass, NULL);
- else
- size = mono_class_value_size (type->data.klass, NULL);
- ADD_CODE(td, MINT_STARG_VT);
- ADD_CODE(td, n);
- WRITE32(td, &size);
- if (td->sp [-1].type == STACK_TYPE_VT)
- POP_VT(td, size);
- } else {
- ADD_CODE(td, MINT_STARG_I1 + (mt - MINT_TYPE_I1));
- ADD_CODE(td, td->rtm->arg_offsets [n]);
- }
+ MonoType *type;
+
+ gboolean hasthis = mono_method_signature (td->method)->hasthis;
+ if (hasthis && n == 0)
+ type = &td->method->klass->byval_arg;
+ else
+ type = mono_method_signature (td->method)->params [n - !!hasthis];
+
+ mt = mint_type (type);
+ if (mt == MINT_TYPE_VT) {
+ gint32 size;
+ g_error ("data.klass");
+ if (mono_method_signature (td->method)->pinvoke)
+ size = mono_class_native_size (type->data.klass, NULL);
+ else
+ size = mono_class_value_size (type->data.klass, NULL);
+ ADD_CODE(td, MINT_STARG_VT);
+ ADD_CODE(td, n);
+ WRITE32(td, &size);
+ if (td->sp [-1].type == STACK_TYPE_VT)
+ POP_VT(td, size);
+ } else {
+ ADD_CODE(td, MINT_STARG_I1 + (mt - MINT_TYPE_I1));
+ ADD_CODE(td, td->rtm->arg_offsets [n]);
}
--td->sp;
}
static void
store_inarg(TransformData *td, int n)
{
- MonoType *type = mono_method_signature (td->method)->params [n];
+ MonoType *type;
+ gboolean hasthis = mono_method_signature (td->method)->hasthis;
+ if (hasthis && n == 0)
+ type = &td->method->klass->byval_arg;
+ else
+ type = mono_method_signature (td->method)->params [n - !!hasthis];
+
int mt = mint_type (type);
if (mt == MINT_TYPE_VT) {
+ if (hasthis && n == 0) {
+ ADD_CODE (td, MINT_STINARG_P);
+ ADD_CODE (td, n);
+ return;
+ }
+ MonoClass *klass = mono_class_from_mono_type (type);
gint32 size;
if (mono_method_signature (td->method)->pinvoke)
- size = mono_class_native_size (type->data.klass, NULL);
+ size = mono_class_native_size (klass, NULL);
else
- size = mono_class_value_size (type->data.klass, NULL);
+ size = mono_class_value_size (klass, NULL);
ADD_CODE(td, MINT_STINARG_VT);
ADD_CODE(td, n);
WRITE32(td, &size);
int offset = td->rtm->local_offsets [n];
MonoClass *klass = NULL;
if (mt == MINT_TYPE_VT) {
- gint32 size = mono_class_value_size (type->data.klass, NULL);
+ klass = mono_class_from_mono_type (type);
+ gint32 size = mono_class_value_size (klass, NULL);
PUSH_VT(td, size);
ADD_CODE(td, MINT_LDLOC_VT);
ADD_CODE(td, offset); /*FIX for large offset */
WRITE32(td, &size);
- klass = type->data.klass;
} else {
+ g_assert (mt < MINT_TYPE_VT);
if (mt == MINT_TYPE_I4 && !td->is_bb_start [td->in_start - td->il_code] && td->last_new_ip != NULL &&
td->last_new_ip [0] == MINT_STLOC_I4 && td->last_new_ip [1] == offset) {
td->last_new_ip [0] = MINT_STLOC_NP_I4;
stack_type [mt], td->sp [-1].type);
}
if (mt == MINT_TYPE_VT) {
- gint32 size = mono_class_value_size (type->data.klass, NULL);
+ MonoClass *klass = mono_class_from_mono_type (type);
+ gint32 size = mono_class_value_size (klass, NULL);
ADD_CODE(td, MINT_STLOC_VT);
ADD_CODE(td, offset); /*FIX for large offset */
WRITE32(td, &size);
if (td->sp [-1].type == STACK_TYPE_VT)
POP_VT(td, size);
} else {
+ g_assert (mt < MINT_TYPE_VT);
ADD_CODE(td, MINT_STLOC_I1 + (mt - MINT_TYPE_I1));
ADD_CODE(td, offset); /*FIX for large offset */
}
}
static void
-interp_transform_call (TransformData *td, MonoMethod *method, MonoDomain *domain, MonoGenericContext *generic_context, unsigned char *is_bb_start, int body_start_offset)
+interp_transform_call (TransformData *td, MonoMethod *method, MonoMethod *target_method, MonoDomain *domain, MonoGenericContext *generic_context, unsigned char *is_bb_start, int body_start_offset)
{
MonoImage *image = method->klass->image;
- MonoMethod *m;
MonoMethodSignature *csignature;
MonoError error;
int virtual = *td->ip == CEE_CALLVIRT;
guint32 token = read32 (td->ip + 1);
- if (calli) {
- CHECK_STACK(td, 1);
- native = (method->wrapper_type != MONO_WRAPPER_DELEGATE_INVOKE && td->sp [-1].type == STACK_TYPE_I);
- --td->sp;
- if (method->wrapper_type != MONO_WRAPPER_NONE)
- csignature = (MonoMethodSignature *)mono_method_get_wrapper_data (method, token);
- else
- csignature = mono_metadata_parse_signature (image, token);
- m = NULL;
- } else {
- if (method->wrapper_type == MONO_WRAPPER_NONE)
- m = mono_get_method_full (image, token, NULL, generic_context);
- else
- m = (MonoMethod *)mono_method_get_wrapper_data (method, token);
- csignature = mono_method_signature (m);
- if (m->klass == mono_defaults.string_class) {
- if (m->name [0] == 'g') {
- if (strcmp (m->name, "get_Chars") == 0)
- op = MINT_GETCHR;
- else if (strcmp (m->name, "get_Length") == 0)
- op = MINT_STRLEN;
- }
- } else if (m->klass == mono_defaults.array_class) {
- if (strcmp (m->name, "get_Rank") == 0)
- op = MINT_ARRAY_RANK;
- else if (strcmp (m->name, "get_Length") == 0)
- op = MINT_LDLEN;
+ if (target_method == NULL) {
+ if (calli) {
+ CHECK_STACK(td, 1);
+ native = (method->wrapper_type != MONO_WRAPPER_DELEGATE_INVOKE && td->sp [-1].type == STACK_TYPE_I);
+ --td->sp;
+ if (method->wrapper_type != MONO_WRAPPER_NONE)
+ csignature = (MonoMethodSignature *)mono_method_get_wrapper_data (method, token);
+ else
+ csignature = mono_metadata_parse_signature (image, token);
+ target_method = NULL;
+ } else {
+ if (method->wrapper_type == MONO_WRAPPER_NONE)
+ target_method = mono_get_method_full (image, token, NULL, generic_context);
+ else
+ target_method = (MonoMethod *)mono_method_get_wrapper_data (method, token);
+ csignature = mono_method_signature (target_method);
+ if (target_method->klass == mono_defaults.string_class) {
+ if (target_method->name [0] == 'g') {
+ if (strcmp (target_method->name, "get_Chars") == 0)
+ op = MINT_GETCHR;
+ else if (strcmp (target_method->name, "get_Length") == 0)
+ op = MINT_STRLEN;
+ }
+ } else if (target_method->klass == mono_defaults.array_class) {
+ if (strcmp (target_method->name, "get_Rank") == 0)
+ op = MINT_ARRAY_RANK;
+ else if (strcmp (target_method->name, "get_Length") == 0)
+ op = MINT_LDLEN;
+ }
}
+ } else {
+ csignature = mono_method_signature (target_method);
}
+
CHECK_STACK (td, csignature->param_count + csignature->hasthis);
- if (!calli && (!virtual || (m->flags & METHOD_ATTRIBUTE_VIRTUAL) == 0) &&
- (m->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) == 0 &&
- (m->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) == 0) {
- int called_inited = mono_class_vtable (domain, m->klass)->initialized;
- MonoMethodHeader *mheader = mono_method_get_header (m);
+ if (!calli && (!virtual || (target_method->flags & METHOD_ATTRIBUTE_VIRTUAL) == 0) &&
+ (target_method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) == 0 &&
+ (target_method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) == 0) {
+ int called_inited = mono_class_vtable (domain, target_method->klass)->initialized;
+ MonoMethodHeader *mheader = mono_method_get_header (target_method);
- if (/*mono_metadata_signature_equal (method->signature, m->signature) */ method == m && *(td->ip + 5) == CEE_RET) {
+ if (/*mono_metadata_signature_equal (method->signature, target_method->signature) */ method == target_method && *(td->ip + 5) == CEE_RET) {
int offset;
if (mono_interp_traceopt)
- g_print ("Optimize tail call of %s.%s\n", m->klass->name, m->name);
+ g_print ("Optimize tail call of %s.%s\n", target_method->klass->name, target_method->name);
for (i = csignature->param_count - 1; i >= 0; --i)
store_arg (td, i + csignature->hasthis);
if (csignature->hasthis) {
- ADD_CODE(td, MINT_STTHIS);
+ g_error ("STTHIS removal");
+ // ADD_CODE(td, MINT_STTHIS);
--td->sp;
}
ADD_CODE(td, MINT_BR_S);
/* mheader might not exist if this is a delegate invoc, etc */
if (mheader && *mheader->code == CEE_RET && called_inited) {
if (mono_interp_traceopt)
- g_print ("Inline (empty) call of %s.%s\n", m->klass->name, m->name);
+ g_print ("Inline (empty) call of %s.%s\n", target_method->klass->name, target_method->name);
for (i = 0; i < csignature->param_count; i++)
ADD_CODE(td, MINT_POP); /*FIX: vt */
if (csignature->hasthis) {
}
}
}
- if (method->wrapper_type == MONO_WRAPPER_NONE && m != NULL) {
- if (m->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
- m = mono_marshal_get_native_wrapper (m, FALSE, FALSE);
- if (!virtual && m->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
- m = mono_marshal_get_synchronized_wrapper (m);
+ if (method->wrapper_type == MONO_WRAPPER_NONE && target_method != NULL) {
+ if (target_method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
+ target_method = mono_marshal_get_native_wrapper (target_method, FALSE, FALSE);
+ if (!virtual && target_method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
+ target_method = mono_marshal_get_synchronized_wrapper (target_method);
}
g_assert (csignature->call_convention == MONO_CALL_DEFAULT || csignature->call_convention == MONO_CALL_C);
- td->sp -= csignature->param_count + csignature->hasthis;
+ td->sp -= csignature->param_count + !!csignature->hasthis;
for (i = 0; i < csignature->param_count; ++i) {
- if (td->sp [i + csignature->hasthis].type == STACK_TYPE_VT) {
+ if (td->sp [i + !!csignature->hasthis].type == STACK_TYPE_VT) {
gint32 size;
+ MonoClass *klass = mono_class_from_mono_type (csignature->params [i]);
if (csignature->pinvoke && method->wrapper_type != MONO_WRAPPER_NONE)
- size = mono_class_native_size (csignature->params [i]->data.klass, NULL);
+ size = mono_class_native_size (klass, NULL);
else
- size = mono_class_value_size (csignature->params [i]->data.klass, NULL);
+ size = mono_class_value_size (klass, NULL);
size = (size + 7) & ~7;
vt_stack_used += size;
}
/* need to handle typedbyref ... */
if (csignature->ret->type != MONO_TYPE_VOID) {
int mt = mint_type(csignature->ret);
- MonoClass *klass = NULL;
+ MonoClass *klass = mono_class_from_mono_type (csignature->ret);
if (mt == MINT_TYPE_VT) {
if (csignature->pinvoke && method->wrapper_type != MONO_WRAPPER_NONE)
- vt_res_size = mono_class_native_size (csignature->ret->data.klass, NULL);
+ vt_res_size = mono_class_native_size (klass, NULL);
else
- vt_res_size = mono_class_value_size (csignature->ret->data.klass, NULL);
+ vt_res_size = mono_class_value_size (klass, NULL);
PUSH_VT(td, vt_res_size);
- klass = csignature->ret->data.klass;
- } else if (mt == MINT_TYPE_O)
- klass = mono_class_from_mono_type (csignature->ret);
+ }
PUSH_TYPE(td, stack_type[mt], klass);
} else
is_void = TRUE;
if (calli) {
ADD_CODE(td, get_data_item_index (td, (void *)csignature));
} else {
- ADD_CODE(td, get_data_item_index (td, (void *)mono_interp_get_runtime_method (domain, m, &error)));
+ ADD_CODE(td, get_data_item_index (td, (void *)mono_interp_get_runtime_method (domain, target_method, &error)));
mono_error_cleanup (&error); /* FIXME: don't swallow the error */
}
}
g_free (name);
}
+ if (signature->hasthis)
+ store_inarg (&td, 0);
for (i = 0; i < signature->param_count; i++)
- store_inarg(&td, i);
+ store_inarg (&td, i + !!signature->hasthis);
body_start_offset = td.new_ip - td.new_code;
break;
case CEE_LDARGA_S: {
int n = ((guint8 *)td.ip)[1];
- if (n == 0 && signature->hasthis)
+ if (n == 0 && signature->hasthis) {
+ g_error ("LDTHISA: NOPE");
ADD_CODE(&td, MINT_LDTHISA);
+ }
else {
ADD_CODE(&td, MINT_LDARGA);
ADD_CODE(&td, td.rtm->arg_offsets [n - signature->hasthis]);
case CEE_CALLVIRT: /* Fall through */
case CEE_CALLI: /* Fall through */
case CEE_CALL: {
- interp_transform_call (&td, method, domain, generic_context, is_bb_start, body_start_offset);
+ interp_transform_call (&td, method, NULL, domain, generic_context, is_bb_start, body_start_offset);
break;
}
case CEE_RET: {
int vt_size = 0;
if (signature->ret->type != MONO_TYPE_VOID) {
--td.sp;
- if (mint_type(signature->ret) == MINT_TYPE_VT) {
- vt_size = mono_class_value_size (signature->ret->data.klass, NULL);
+ MonoClass *klass = mono_class_from_mono_type (signature->ret);
+ if (mint_type (&klass->byval_arg) == MINT_TYPE_VT) {
+ vt_size = mono_class_value_size (klass, NULL);
vt_size = (vt_size + 7) & ~7;
}
}
if (td.sp > td.stack)
g_warning ("%s.%s: CEE_RET: more values on stack: %d", td.method->klass->name, td.method->name, td.sp - td.stack);
if (td.vt_sp != vt_size)
- g_warning ("%s.%s: CEE_RET: value type stack: %d", td.method->klass->name, td.method->name, td.vt_sp);
+ g_error ("%s.%s: CEE_RET: value type stack: %d vs. %d", td.method->klass->name, td.method->name, td.vt_sp, vt_size);
if (vt_size == 0)
SIMPLE_OP(td, signature->ret->type == MONO_TYPE_VOID ? MINT_RET_VOID : MINT_RET);
else {
ADD_CODE(&td, MINT_LDOBJ);
ADD_CODE(&td, get_data_item_index(&td, klass));
- if (klass->byval_arg.type == MONO_TYPE_VALUETYPE && !klass->byval_arg.data.klass->enumtype) {
+ if (mint_type (&klass->byval_arg) == MINT_TYPE_VT) {
size = mono_class_value_size (klass, NULL);
PUSH_VT(&td, size);
}
ADD_CODE(&td, MINT_NEWOBJ);
ADD_CODE(&td, get_data_item_index (&td, mono_interp_get_runtime_method (domain, m, &error)));
mono_error_cleanup (&error); /* FIXME: don't swallow the error */
- if (klass->byval_arg.type == MONO_TYPE_VALUETYPE) {
+
+ if (mint_type (&klass->byval_arg) == MINT_TYPE_VT) {
vt_res_size = mono_class_value_size (klass, NULL);
- PUSH_VT(&td, vt_res_size);
+ PUSH_VT (&td, vt_res_size);
}
for (i = 0; i < csignature->param_count; ++i) {
int mt = mint_type(csignature->params [i]);
if (mt == MINT_TYPE_VT) {
- gint32 size = mono_class_value_size (csignature->params [i]->data.klass, NULL);
+ MonoClass *k = mono_class_from_mono_type (csignature->params [i]);
+ gint32 size = mono_class_value_size (k, NULL);
size = (size + 7) & ~7;
vt_stack_used += size;
}
WRITE32(&td, &vt_stack_used);
td.vt_sp -= vt_stack_used;
}
- PUSH_TYPE(&td, stack_type [mint_type (&klass->byval_arg)], klass);
+ PUSH_TYPE (&td, stack_type [mint_type (&klass->byval_arg)], klass);
break;
}
case CEE_CASTCLASS:
SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
++td.ip;
break;
- case CEE_UNBOX_ANY: /* let's play a dangerous game, TODO */
case CEE_UNBOX:
CHECK_STACK (&td, 1);
token = read32 (td.ip + 1);
klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
else
klass = mono_class_get_full (image, token, generic_context);
+
+ if (mono_class_is_nullable (klass)) {
+ g_error ("cee_unbox: implement Nullable");
+ }
ADD_CODE(&td, MINT_UNBOX);
ADD_CODE(&td, get_data_item_index (&td, klass));
SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_MP);
td.ip += 5;
+ break;
+ case CEE_UNBOX_ANY:
+ CHECK_STACK (&td, 1);
+ token = read32 (td.ip + 1);
+
+ g_assert (method->wrapper_type == MONO_WRAPPER_NONE);
+ klass = mono_class_get_full (image, token, generic_context);
+
+ if (mini_type_is_reference (&klass->byval_arg)) {
+ g_error ("unbox_any: generic class is reference type");
+ } else if (mono_class_is_nullable (klass)) {
+ MonoMethod *target_method = mono_class_get_method_from_name (klass, "Unbox", 1);
+ /* td.ip is incremented by interp_transform_call */
+ interp_transform_call (&td, method, target_method, domain, generic_context, is_bb_start, body_start_offset);
+ } else {
+ int mt = mint_type (&klass->byval_arg);
+ ADD_CODE (&td, MINT_UNBOX);
+ ADD_CODE (&td, get_data_item_index (&td, klass));
+ SET_TYPE (td.sp - 1, stack_type [mt], klass);
+ if (mt == MINT_TYPE_VT) {
+ int size = mono_class_value_size (klass, NULL);
+ PUSH_VT (&td, size);
+ }
+ td.ip += 5;
+ }
+
break;
case CEE_THROW:
CHECK_STACK (&td, 1);
token = read32 (td.ip + 1);
field = mono_field_from_token (image, token, &klass, generic_context);
mono_class_init (klass);
- mt = mint_type(field->type);
+
+ MonoClass *field_klass = mono_class_from_mono_type (field->type);
+ mt = mint_type (&field_klass->byval_arg);
if (klass->marshalbyref) {
ADD_CODE(&td, mt == MINT_TYPE_VT ? MINT_LDRMFLD_VT : MINT_LDRMFLD);
ADD_CODE(&td, get_data_item_index (&td, field));
ADD_CODE(&td, MINT_LDFLD_I1 + mt - MINT_TYPE_I1);
ADD_CODE(&td, klass->valuetype ? field->offset - sizeof(MonoObject) : field->offset);
}
- klass = NULL;
if (mt == MINT_TYPE_VT) {
- int size = mono_class_value_size (field->type->data.klass, NULL);
+ int size = mono_class_value_size (field_klass, NULL);
PUSH_VT(&td, size);
WRITE32(&td, &size);
- klass = field->type->data.klass;
- } else if (mt == MINT_TYPE_O)
- klass = mono_class_from_mono_type (field->type);
+ }
+ if (td.sp [-1].type == STACK_TYPE_VT) {
+ int size = mono_class_value_size (klass, NULL);
+ size = (size + 7) & ~7;
+ td.vt_sp -= size;
+ }
td.ip += 5;
- SET_TYPE(td.sp - 1, stack_type [mt], klass);
+ SET_TYPE(td.sp - 1, stack_type [mt], field_klass);
break;
}
case CEE_STFLD:
ADD_CODE(&td, klass->valuetype ? field->offset - sizeof(MonoObject) : field->offset);
}
if (mt == MINT_TYPE_VT) {
- int size = mono_class_value_size (field->type->data.klass, NULL);
+ MonoClass *klass = mono_class_from_mono_type (field->type);
+ int size = mono_class_value_size (klass, NULL);
POP_VT(&td, size);
WRITE32(&td, &size);
}
ADD_CODE(&td, get_data_item_index (&td, field));
klass = NULL;
if (mt == MINT_TYPE_VT) {
+ g_error ("data.klass");
int size = mono_class_value_size (field->type->data.klass, NULL);
PUSH_VT(&td, size);
WRITE32(&td, &size);
ADD_CODE(&td, mt == MINT_TYPE_VT ? MINT_STSFLD_VT : MINT_STSFLD);
ADD_CODE(&td, get_data_item_index (&td, field));
if (mt == MINT_TYPE_VT) {
+ g_error ("data.klass");
int size = mono_class_value_size (field->type->data.klass, NULL);
POP_VT(&td, size);
WRITE32(&td, &size);
else
klass = mono_class_get_full (image, token, generic_context);
g_assert (klass->valuetype);
- if (klass->byval_arg.type == MONO_TYPE_VALUETYPE && !klass->enumtype) {
- size = mono_class_value_size (klass, NULL);
- size = (size + 7) & ~7;
- td.vt_sp -= size;
+
+ if (mono_class_is_nullable (klass)) {
+ MonoMethod *target_method = mono_class_get_method_from_name (klass, "Box", 1);
+ /* td.ip is incremented by interp_transform_call */
+ interp_transform_call (&td, method, target_method, domain, generic_context, is_bb_start, body_start_offset);
+ } else {
+ if (klass->byval_arg.type == MONO_TYPE_VALUETYPE && !klass->enumtype) {
+ size = mono_class_value_size (klass, NULL);
+ size = (size + 7) & ~7;
+ td.vt_sp -= size;
+ }
+ ADD_CODE(&td, MINT_BOX);
+ ADD_CODE(&td, get_data_item_index (&td, klass));
+ SET_TYPE(td.sp - 1, STACK_TYPE_O, klass);
+ td.ip += 5;
}
- ADD_CODE(&td, MINT_BOX);
- ADD_CODE(&td, get_data_item_index (&td, klass));
- SET_TYPE(td.sp - 1, STACK_TYPE_O, klass);
- td.ip += 5;
+
break;
}
case CEE_NEWARR:
--td.sp;
SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_O);
break;
+ case CEE_LDELEM:
+ CHECK_STACK (&td, 2);
+ token = read32 (td.ip + 1);
+ klass = mono_class_get_full (image, token, generic_context);
+ switch (mint_type (&klass->byval_arg)) {
+ case MINT_TYPE_I4:
+ ENSURE_I4 (&td, 1);
+ SIMPLE_OP (td, MINT_LDELEM_I4);
+ --td.sp;
+ SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+ break;
+ default: {
+ GString *res = g_string_new ("");
+ mono_type_get_desc (res, &klass->byval_arg, TRUE);
+ g_print ("LDELEM: %s -> %d (%s)\n", klass->name, mint_type (&klass->byval_arg), res->str);
+ g_string_free (res, TRUE);
+ g_assert (0);
+ break;
+ }
+ }
+ td.ip += 4;
+ break;
case CEE_STELEM_I:
CHECK_STACK (&td, 3);
ENSURE_I4 (&td, 2);
SIMPLE_OP (td, MINT_STELEM_REF);
td.sp -= 3;
break;
+ case CEE_STELEM:
+ CHECK_STACK (&td, 3);
+ ENSURE_I4 (&td, 2);
+ token = read32 (td.ip + 1);
+ klass = mono_class_get_full (image, token, generic_context);
+ switch (mint_type (&klass->byval_arg)) {
+ case MINT_TYPE_I4:
+ SIMPLE_OP (td, MINT_STELEM_I4);
+ break;
+ default: {
+ GString *res = g_string_new ("");
+ mono_type_get_desc (res, &klass->byval_arg, TRUE);
+ g_print ("STELEM: %s -> %d (%s)\n", klass->name, mint_type (&klass->byval_arg), res->str);
+ g_string_free (res, TRUE);
+ g_assert (0);
+ break;
+ }
+ }
+ td.ip += 4;
+ td.sp -= 3;
+ break;
#if 0
- case CEE_LDELEM:
- case CEE_STELEM:
-
case CEE_CONV_OVF_U1:
case CEE_CONV_OVF_I8:
switch (*td.ip) {
case CEE_MONO_CALLI_EXTRA_ARG:
/* Same as CEE_CALLI, llvm specific */
- interp_transform_call (&td, method, domain, generic_context, is_bb_start, body_start_offset);
+ interp_transform_call (&td, method, NULL, domain, generic_context, is_bb_start, body_start_offset);
break;
case CEE_MONO_ICALL: {
guint32 token;
break;
case CEE_LDARGA: {
int n = read16 (td.ip + 1);
- if (n == 0 && signature->hasthis)
+ if (n == 0 && signature->hasthis) {
+ g_error ("LDTHISA: NOPE");
ADD_CODE(&td, MINT_LDTHISA);
+ }
else {
ADD_CODE(&td, MINT_LDARGA);
ADD_CODE(&td, td.rtm->arg_offsets [n - signature->hasthis]); /* FIX for large offsets */
/* assumes all internal calls with an array this are built in... */
if (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL && (! mono_method_signature (method)->hasthis || method->klass->rank == 0)) {
nm = mono_marshal_get_native_wrapper (method, TRUE, FALSE);
+ signature = mono_method_signature (nm);
} else {
const char *name = method->name;
if (method->klass->parent == mono_defaults.multicastdelegate_class) {
runtime_method->locals_size = offset;
g_assert (runtime_method->locals_size < 65536);
offset = 0;
- runtime_method->arg_offsets = g_malloc(signature->param_count * sizeof(guint32));
+ runtime_method->arg_offsets = g_malloc ((!!signature->hasthis + signature->param_count) * sizeof(guint32));
+
+ if (signature->hasthis) {
+ g_assert (!signature->pinvoke);
+ size = mono_type_stack_size (&method->klass->byval_arg, &align);
+ offset += align - 1;
+ offset &= ~(align - 1);
+ runtime_method->arg_offsets [0] = offset;
+ offset += size;
+ }
+
for (i = 0; i < signature->param_count; ++i) {
if (signature->pinvoke) {
guint32 dummy;
size = mono_type_stack_size (signature->params [i], &align);
offset += align - 1;
offset &= ~(align - 1);
- runtime_method->arg_offsets [i] = offset;
+ runtime_method->arg_offsets [i + !!signature->hasthis] = offset;
offset += size;
}
offset = (offset + 7) & ~7;
static void
mono_analyze_liveness2 (MonoCompile *cfg)
{
- int bnum, idx, i, j, nins, max, max_vars, block_from, block_to, pos, reverse_len;
+ int bnum, idx, i, j, nins, max, max_vars, block_from, block_to, pos;
gint32 *last_use;
static guint32 disabled = -1;
- MonoInst **reverse;
if (disabled == -1)
disabled = g_getenv ("DISABLED") != NULL;
max_vars = cfg->num_varinfo;
last_use = g_new0 (gint32, max_vars);
- reverse_len = 1024;
- reverse = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * reverse_len);
-
for (idx = 0; idx < max_vars; ++idx) {
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
if (cfg->ret)
last_use [cfg->ret->inst_c0] = block_to;
- for (nins = 0, pos = block_from, ins = bb->code; ins; ins = ins->next, ++nins, ++pos) {
- if (nins >= reverse_len) {
- int new_reverse_len = reverse_len * 2;
- MonoInst **new_reverse = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * new_reverse_len);
- memcpy (new_reverse, reverse, sizeof (MonoInst*) * reverse_len);
- reverse = new_reverse;
- reverse_len = new_reverse_len;
- }
-
- reverse [nins] = ins;
- }
+ pos = block_from + 1;
+ MONO_BB_FOR_EACH_INS (bb, ins) pos++;
/* Process instructions backwards */
- for (i = nins - 1; i >= 0; --i) {
- MonoInst *ins = (MonoInst*)reverse [i];
-
- update_liveness2 (cfg, ins, FALSE, pos, last_use);
-
- pos --;
+ MONO_BB_FOR_EACH_INS_REVERSE (bb, ins) {
+ update_liveness2 (cfg, ins, FALSE, pos, last_use);
+ pos--;
}
for (idx = 0; idx < max_vars; ++idx) {
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/mono-debug-debugger.h>
#include <mono/metadata/debug-mono-symfile.h>
+#include <mono/utils/mono-counters.h>
#if !defined(DISABLE_JIT) && !defined(DISABLE_LLDB)
guint32 version;
/* Align */
guint32 dummy;
- /* Keep these as pointers so accessing them is atomic */
DebugEntry *entry;
/* List of all entries */
+ /* Keep this as a pointer so accessing it is atomic */
DebugEntry *all_entries;
+ /* The current entry embedded here to reduce the amount of roundtrips */
+ guint32 type;
+ guint32 dummy2;
+ guint64 size;
+ guint64 addr;
} JitDescriptor;
/*
static DebugEntry *last_entry;
static mono_mutex_t mutex;
static GHashTable *dyn_codegen_regions;
+static double register_time;
+static int num_entries;
#define lldb_lock() mono_os_mutex_lock (&mutex)
#define lldb_unlock() mono_os_mutex_unlock (&mutex)
}
__mono_jit_debug_descriptor.entry = entry;
+
+ __mono_jit_debug_descriptor.type = entry->type;
+ __mono_jit_debug_descriptor.size = entry->size;
+ __mono_jit_debug_descriptor.addr = entry->addr;
+ mono_memory_barrier ();
+
+ GTimer *timer = mono_time_track_start ();
__mono_jit_debug_register_code ();
+ mono_time_track_end (®ister_time, timer);
+ num_entries ++;
+ //printf ("%lf %d %d\n", register_time, num_entries, entry->type);
lldb_unlock ();
}
{
enabled = TRUE;
mono_os_mutex_init_recursive (&mutex);
+
+ mono_counters_register ("Time spent in LLDB", MONO_COUNTER_JIT | MONO_COUNTER_DOUBLE, ®ister_time);
}
typedef struct
mono_global_codeman_foreach (find_code_region, &udata);
if (!udata.found)
mono_domain_code_foreach (mono_get_root_domain (), find_code_region, &udata);
- g_assert (udata.found);
+ if (!udata.found)
+ /* Can happen with AOT */
+ return;
region_id = register_codegen_region (udata.region_start, udata.region_size, FALSE);
void
mono_lldb_save_specific_trampoline_info (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, gpointer code, guint32 code_len)
{
+ /*
+ * Avoid emitting these for now,
+ * they slow down execution too much, and they are
+ * only needed during single stepping which doesn't
+ * work anyway.
+ */
+#if 0
TrampolineEntry *entry;
UserData udata;
int region_id;
add_entry (ENTRY_TRAMPOLINE, buf);
buffer_free (buf);
+#endif
}
/*
#include <mono/metadata/profiler.h>
#include <mono/metadata/monitor.h>
#include <mono/metadata/debug-mono-symfile.h>
-#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-memory-model.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/metadata/mono-basic-block.h>
static MonoMethodSignature *helper_sig_set_tls_tramp;
/* type loading helpers */
-static GENERATE_GET_CLASS_WITH_CACHE (runtime_helpers, System.Runtime.CompilerServices, RuntimeHelpers)
-static GENERATE_TRY_GET_CLASS_WITH_CACHE (debuggable_attribute, System.Diagnostics, DebuggableAttribute)
+static GENERATE_GET_CLASS_WITH_CACHE (runtime_helpers, "System.Runtime.CompilerServices", "RuntimeHelpers")
+static GENERATE_TRY_GET_CLASS_WITH_CACHE (debuggable_attribute, "System.Diagnostics", "DebuggableAttribute")
/*
* Instruction metadata
#undef MINI_OP
#undef MINI_OP3
-#define MONO_INIT_VARINFO(vi,id) do { \
- (vi)->range.first_use.pos.bid = 0xffff; \
- (vi)->reg = -1; \
- (vi)->idx = (id); \
-} while (0)
-
guint32
mono_alloc_ireg (MonoCompile *cfg)
{
* Get rid of the begin and end bblocks if possible to aid local
* optimizations.
*/
- mono_merge_basic_blocks (cfg, prev_cbb, sbblock);
+ if (prev_cbb->out_count == 1)
+ mono_merge_basic_blocks (cfg, prev_cbb, sbblock);
if ((prev_cbb->out_count == 1) && (prev_cbb->out_bb [0]->in_count == 1) && (prev_cbb->out_bb [0] != ebblock))
mono_merge_basic_blocks (cfg, prev_cbb, prev_cbb->out_bb [0]);
mono_bitset_set_fast (seq_point_locs, sps [i].il_offset);
}
g_free (sps);
+
+ MonoDebugMethodAsyncInfo* asyncMethod = mono_debug_lookup_method_async_debug_info (method);
+ if (asyncMethod) {
+ for (i = 0; asyncMethod != NULL && i < asyncMethod->num_awaits; i++)
+ {
+ mono_bitset_set_fast (seq_point_locs, asyncMethod->resume_offsets[i]);
+ mono_bitset_set_fast (seq_point_locs, asyncMethod->yield_offsets[i]);
+ }
+ mono_debug_free_method_async_debug_info (asyncMethod);
+ }
} else if (!method->wrapper_type && !method->dynamic && mono_debug_image_has_debug_info (method->klass->image)) {
/* Methods without line number info like auto-generated property accessors */
seq_point_locs = mono_bitset_mem_new (mono_mempool_alloc0 (cfg->mempool, mono_bitset_alloc_size (header->code_size, 0)), header->code_size, 0);
CHECK_CFG_ERROR;
}
}
+
+ if (constrained_class->enumtype && !strcmp (cmethod->name, "GetHashCode")) {
+ /* Use the corresponding method from the base type to avoid boxing */
+ MonoType *base_type = mono_class_enum_basetype (constrained_class);
+ g_assert (base_type);
+ constrained_class = mono_class_from_mono_type (base_type);
+ cmethod = mono_class_get_method_from_name (constrained_class, cmethod->name, 0);
+ g_assert (cmethod);
+ }
}
if (!dont_verify && !cfg->skip_visibility) {
gpointer
mono_amd64_handler_block_trampoline_helper (void);
-#ifdef TARGET_WIN32
+#if defined(TARGET_WIN32) && !defined(DISABLE_JIT)
void mono_arch_unwindinfo_add_push_nonvol (gpointer* monoui, gpointer codebegin, gpointer nextip, guchar reg );
void mono_arch_unwindinfo_add_set_fpreg (gpointer* monoui, gpointer codebegin, gpointer nextip, guchar reg );
#else
arm_fpu = MONO_ARM_FPU_VFP;
-#if defined(ARM_FPU_NONE) && !defined(__APPLE__)
+#if defined(ARM_FPU_NONE) && !defined(TARGET_IOS)
/*
* If we're compiling with a soft float fallback and it
* turns out that no VFP unit is available, we need to
v7_supported = TRUE;
#endif
-#if defined(__APPLE__)
+#if defined(TARGET_IOS)
/* iOS is special-cased here because we don't yet
have a way to properly detect CPU features on it. */
thumb_supported = TRUE;
#define MONO_ARCH_HAVE_PATCH_CODE_NEW 1
#define MONO_ARCH_HAVE_OP_GENERIC_CLASS_INIT 1
-#ifdef TARGET_WATCHOS
+#if defined(TARGET_WATCHOS) || (defined(__linux__) && !defined(TARGET_ANDROID))
#define MONO_ARCH_DISABLE_HW_TRAPS 1
#define MONO_ARCH_HAVE_UNWIND_BACKTRACE 1
#endif
static gboolean ios_abi;
-static __attribute__((warn_unused_result)) guint8* emit_load_regset (guint8 *code, guint64 regs, int basereg, int offset);
+static __attribute__ ((__warn_unused_result__)) guint8* emit_load_regset (guint8 *code, guint64 regs, int basereg, int offset);
const char*
mono_arch_regname (int reg)
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_addw_imm (guint8 *code, int dreg, int sreg, int imm)
{
if (!arm_is_arith_imm (imm)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_addx_imm (guint8 *code, int dreg, int sreg, int imm)
{
if (!arm_is_arith_imm (imm)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_subw_imm (guint8 *code, int dreg, int sreg, int imm)
{
if (!arm_is_arith_imm (imm)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_subx_imm (guint8 *code, int dreg, int sreg, int imm)
{
if (!arm_is_arith_imm (imm)) {
}
/* Emit sp+=imm. Clobbers ip0/ip1 */
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_addx_sp_imm (guint8 *code, int imm)
{
code = emit_imm (code, ARMREG_IP0, imm);
}
/* Emit sp-=imm. Clobbers ip0/ip1 */
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_subx_sp_imm (guint8 *code, int imm)
{
code = emit_imm (code, ARMREG_IP0, imm);
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_andw_imm (guint8 *code, int dreg, int sreg, int imm)
{
// FIXME:
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_andx_imm (guint8 *code, int dreg, int sreg, int imm)
{
// FIXME:
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_orrw_imm (guint8 *code, int dreg, int sreg, int imm)
{
// FIXME:
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_orrx_imm (guint8 *code, int dreg, int sreg, int imm)
{
// FIXME:
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_eorw_imm (guint8 *code, int dreg, int sreg, int imm)
{
// FIXME:
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_eorx_imm (guint8 *code, int dreg, int sreg, int imm)
{
// FIXME:
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_cmpw_imm (guint8 *code, int sreg, int imm)
{
if (imm == 0) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_cmpx_imm (guint8 *code, int sreg, int imm)
{
if (imm == 0) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_strb (guint8 *code, int rt, int rn, int imm)
{
if (arm_is_strb_imm (imm)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_strh (guint8 *code, int rt, int rn, int imm)
{
if (arm_is_strh_imm (imm)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_strw (guint8 *code, int rt, int rn, int imm)
{
if (arm_is_strw_imm (imm)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_strfpw (guint8 *code, int rt, int rn, int imm)
{
if (arm_is_strw_imm (imm)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_strfpx (guint8 *code, int rt, int rn, int imm)
{
if (arm_is_strx_imm (imm)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_strx (guint8 *code, int rt, int rn, int imm)
{
if (arm_is_strx_imm (imm)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_ldrb (guint8 *code, int rt, int rn, int imm)
{
if (arm_is_pimm12_scaled (imm, 1)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_ldrsbx (guint8 *code, int rt, int rn, int imm)
{
if (arm_is_pimm12_scaled (imm, 1)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_ldrh (guint8 *code, int rt, int rn, int imm)
{
if (arm_is_pimm12_scaled (imm, 2)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_ldrshx (guint8 *code, int rt, int rn, int imm)
{
if (arm_is_pimm12_scaled (imm, 2)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_ldrswx (guint8 *code, int rt, int rn, int imm)
{
if (arm_is_pimm12_scaled (imm, 4)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_ldrw (guint8 *code, int rt, int rn, int imm)
{
if (arm_is_pimm12_scaled (imm, 4)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_ldrx (guint8 *code, int rt, int rn, int imm)
{
if (arm_is_pimm12_scaled (imm, 8)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_ldrfpw (guint8 *code, int rt, int rn, int imm)
{
if (arm_is_pimm12_scaled (imm, 4)) {
return code;
}
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_ldrfpx (guint8 *code, int rt, int rn, int imm)
{
if (arm_is_pimm12_scaled (imm, 8)) {
* - ldrp [fp, lr], [sp], !stack_offfset
* Clobbers TEMP_REGS.
*/
-__attribute__((warn_unused_result)) guint8*
+__attribute__ ((__warn_unused_result__)) guint8*
mono_arm_emit_destroy_frame (guint8 *code, int stack_offset, guint64 temp_regs)
{
arm_movspx (code, ARMREG_SP, ARMREG_FP);
}
/* This clobbers LR */
-static inline __attribute__((warn_unused_result)) guint8*
+static inline __attribute__ ((__warn_unused_result__)) guint8*
emit_cond_exc (MonoCompile *cfg, guint8 *code, int opcode, const char *exc_name)
{
int cond;
* Emit code to store the registers in REGS into the appropriate elements of
* the register array at BASEREG+OFFSET.
*/
-static __attribute__((warn_unused_result)) guint8*
+static __attribute__ ((__warn_unused_result__)) guint8*
emit_store_regarray (guint8 *code, guint64 regs, int basereg, int offset)
{
int i;
* Emit code to load the registers in REGS from the appropriate elements of
* the register array at BASEREG+OFFSET.
*/
-static __attribute__((warn_unused_result)) guint8*
+static __attribute__ ((__warn_unused_result__)) guint8*
emit_load_regarray (guint8 *code, guint64 regs, int basereg, int offset)
{
int i;
* Emit code to store the registers in REGS into consecutive memory locations starting
* at BASEREG+OFFSET.
*/
-static __attribute__((warn_unused_result)) guint8*
+static __attribute__ ((__warn_unused_result__)) guint8*
emit_store_regset (guint8 *code, guint64 regs, int basereg, int offset)
{
int i, pos;
* Emit code to load the registers in REGS from consecutive memory locations starting
* at BASEREG+OFFSET.
*/
-static __attribute__((warn_unused_result)) guint8*
+static __attribute__ ((__warn_unused_result__)) guint8*
emit_load_regset (guint8 *code, guint64 regs, int basereg, int offset)
{
int i, pos;
return code;
}
-__attribute__((warn_unused_result)) guint8*
+__attribute__ ((__warn_unused_result__)) guint8*
mono_arm_emit_load_regarray (guint8 *code, guint64 regs, int basereg, int offset)
{
return emit_load_regarray (code, regs, basereg, offset);
}
-__attribute__((warn_unused_result)) guint8*
+__attribute__ ((__warn_unused_result__)) guint8*
mono_arm_emit_store_regarray (guint8 *code, guint64 regs, int basereg, int offset)
{
return emit_store_regarray (code, regs, basereg, offset);
}
-__attribute__((warn_unused_result)) guint8*
+__attribute__ ((__warn_unused_result__)) guint8*
mono_arm_emit_store_regset (guint8 *code, guint64 regs, int basereg, int offset)
{
return emit_store_regset (code, regs, basereg, offset);
/* Same as emit_store_regset, but emit unwind info too */
/* CFA_OFFSET is the offset between the CFA and basereg */
-static __attribute__((warn_unused_result)) guint8*
+static __attribute__ ((__warn_unused_result__)) guint8*
emit_store_regset_cfa (MonoCompile *cfg, guint8 *code, guint64 regs, int basereg, int offset, int cfa_offset, guint64 no_cfa_regset)
{
int i, j, pos, nregs;
#include <mono/metadata/threads.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/debug-helpers.h>
-#include <mono/io-layer/io-layer.h>
#include "mono/metadata/profiler.h"
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/mono-config.h>
}
/* Class lazy loading functions */
-static GENERATE_GET_CLASS_WITH_CACHE (runtime_compat_attr, System.Runtime.CompilerServices, RuntimeCompatibilityAttribute)
+static GENERATE_GET_CLASS_WITH_CACHE (runtime_compat_attr, "System.Runtime.CompilerServices", "RuntimeCompatibilityAttribute")
/*
* wrap_non_exception_throws:
}
static void
-setup_stack_trace (MonoException *mono_ex, GSList *dynamic_methods, MonoArray *initial_trace_ips, GList **trace_ips)
+setup_stack_trace (MonoException *mono_ex, GSList *dynamic_methods, GList **trace_ips)
{
- if (mono_ex && !initial_trace_ips) {
+ if (mono_ex) {
*trace_ips = g_list_reverse (*trace_ips);
MonoError error;
MonoArray *ips_arr = mono_glist_to_array (*trace_ips, mono_defaults.int_class, &error);
static int (*call_filter) (MonoContext *, gpointer) = NULL;
MonoJitTlsData *jit_tls = (MonoJitTlsData *)mono_tls_get_jit_tls ();
MonoLMF *lmf = mono_get_lmf ();
- MonoArray *initial_trace_ips = NULL;
GList *trace_ips = NULL;
GSList *dynamic_methods = NULL;
MonoException *mono_ex;
stack_overflow = TRUE;
mono_ex = (MonoException*)obj;
- initial_trace_ips = mono_ex->trace_ips;
+ MonoArray *initial_trace_ips = mono_ex->trace_ips;
+ if (initial_trace_ips) {
+ int len = mono_array_length (initial_trace_ips) >> 1;
+
+ for (i = 0; i < (len - 1); i++) {
+ gpointer ip = mono_array_get (initial_trace_ips, gpointer, i * 2 + 0);
+ gpointer generic_info = mono_array_get (initial_trace_ips, gpointer, i * 2 + 1);
+ trace_ips = g_list_prepend (trace_ips, ip);
+ trace_ips = g_list_prepend (trace_ips, generic_info);
+ }
+ }
- if (mono_object_isinst_checked (obj, mono_defaults.exception_class, &error)) {
- mono_ex = (MonoException*)obj;
- initial_trace_ips = mono_ex->trace_ips;
- } else {
+ if (!mono_object_isinst_checked (obj, mono_defaults.exception_class, &error)) {
mono_error_assert_ok (&error);
mono_ex = NULL;
}
}
if (!unwind_res) {
- setup_stack_trace (mono_ex, dynamic_methods, initial_trace_ips, &trace_ips);
+ setup_stack_trace (mono_ex, dynamic_methods, &trace_ips);
g_slist_free (dynamic_methods);
return FALSE;
}
}
if (method->wrapper_type != MONO_WRAPPER_RUNTIME_INVOKE && mono_ex) {
- /*
- * Avoid overwriting the stack trace if the exception is
- * rethrown. Also avoid giant stack traces during a stack
- * overflow.
- */
- if (!initial_trace_ips && (frame_count < 1000)) {
+ // avoid giant stack traces during a stack overflow
+ if (frame_count < 1000) {
trace_ips = g_list_prepend (trace_ips, MONO_CONTEXT_GET_IP (ctx));
- trace_ips = g_list_prepend (trace_ips,
- get_generic_info_from_stack_frame (ji, ctx));
+ trace_ips = g_list_prepend (trace_ips, get_generic_info_from_stack_frame (ji, ctx));
}
}
FIXME Not 100% sure if it's a good idea even with user clauses.
*/
if (is_user_frame)
- setup_stack_trace (mono_ex, dynamic_methods, initial_trace_ips, &trace_ips);
+ setup_stack_trace (mono_ex, dynamic_methods, &trace_ips);
#ifndef MONO_CROSS_COMPILE
#ifdef MONO_CONTEXT_SET_LLVM_EXC_REG
if (filtered) {
if (!is_user_frame)
- setup_stack_trace (mono_ex, dynamic_methods, initial_trace_ips, &trace_ips);
+ setup_stack_trace (mono_ex, dynamic_methods, &trace_ips);
g_slist_free (dynamic_methods);
/* mono_debugger_agent_handle_exception () needs this */
mini_set_abort_threshold (ctx);
MonoError isinst_error;
mono_error_init (&isinst_error);
if (ei->flags == MONO_EXCEPTION_CLAUSE_NONE && mono_object_isinst_checked (ex_obj, catch_class, &error)) {
- setup_stack_trace (mono_ex, dynamic_methods, initial_trace_ips, &trace_ips);
+ setup_stack_trace (mono_ex, dynamic_methods, &trace_ips);
g_slist_free (dynamic_methods);
if (out_ji)
MonoThreadInfo *thread = mono_thread_info_current_unchecked ();
if (!thread) {
ctx->valid = FALSE;
- g_error ("Invoked mono_thread_state_init_from_sigctx from non-Mono thread");
return FALSE;
}
}
/* Lazy class loading functions */
-static GENERATE_TRY_GET_CLASS_WITH_CACHE (iasync_state_machine, System.Runtime.CompilerServices, IAsyncStateMachine)
+static GENERATE_TRY_GET_CLASS_WITH_CACHE (iasync_state_machine, "System.Runtime.CompilerServices", "IAsyncStateMachine")
static G_GNUC_UNUSED gboolean
is_async_state_machine_class (MonoClass *klass)
#include <mono/metadata/threads.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/debug-helpers.h>
-#include <mono/io-layer/io-layer.h>
#include "mono/metadata/profiler.h"
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/mono-config.h>
commands = fopen (commands_filename, "w");
if (!commands) {
- unlink (commands_filename);
+ unlink (commands_filename);
return;
}
return;
exec:
+ fclose (commands);
execv (argv [0], (char**)argv);
_exit (-1);
if (reg == ppc_r1)
return (mgreg_t)MONO_CONTEXT_GET_SP (ctx);
- g_assert (reg >= ppc_r13);
-
- return ctx->regs [reg - ppc_r13];
+ return ctx->regs [reg];
}
guint32
#define MONO_SAVED_GREGS 19
#define MONO_SAVED_FREGS 18
+#define MONO_PPC_FIRST_SAVED_GREG ppc_r13
+#define MONO_PPC_FIRST_SAVED_FREG ppc_f14
+
#define MONO_ARCH_FRAME_ALIGNMENT 16
/* fixme: align to 16byte instead of 32byte (we align to 32byte to get
#include <mono/utils/mono-threads-coop.h>
#include <mono/utils/checked-build.h>
#include <mono/metadata/w32handle.h>
-#include <mono/io-layer/io-layer.h>
#include "mini.h"
#include "seq-points.h"
*/
#ifdef __GNUC__
/* Prevent the linker from optimizing this away in embedding setups to help debugging */
- __attribute__((used))
+ __attribute__ ((__used__))
#endif
void
mono_print_method_from_ip (void *ip)
mono_error_init (error);
+#ifdef ENABLE_INTERPRETER
+ if (mono_use_interpreter)
+ return interp_create_method_pointer (method, error);
+#endif
+
if (mono_llvm_only)
/* Should be handled by the caller */
g_assert (!(method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED));
MonoJitInfo *ji = NULL;
gboolean callee_gsharedvt = FALSE;
+#ifdef ENABLE_INTERPRETER
+ if (mono_use_interpreter)
+ return interp_mono_runtime_invoke (method, obj, params, exc, error);
+#endif
+
mono_error_init (error);
if (obj == NULL && !(method->flags & METHOD_ATTRIBUTE_STATIC) && !method->string_ctor && (method->wrapper_type == 0)) {
typedef struct {
gint64 gr[5]; /* R2-R6 */
gdouble fp[3]; /* F0-F2 */
-} __attribute__ ((packed)) RegParm;
+} __attribute__ ((__packed__)) RegParm;
typedef struct {
RR_Format basr;
void *pTrigger;
RXY_Format lg;
RXY_Format trigger;
-} __attribute__ ((packed)) breakpoint_t;
+} __attribute__ ((__packed__)) breakpoint_t;
/*========================= End of Typedefs ========================*/
#include <mono/metadata/threads.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/debug-helpers.h>
-#include <mono/io-layer/io-layer.h>
#include "mono/metadata/profiler.h"
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/mono-config.h>
/* Load ss_tramp_var */
/* This is equal to &ss_trampoline */
x86_mov_reg_membase (code, X86_ECX, var->inst_basereg, var->inst_offset, sizeof (mgreg_t));
- x86_alu_membase_imm (code, X86_CMP, X86_ECX, 0, 0);
+ x86_mov_reg_membase (code, X86_ECX, X86_ECX, 0, sizeof (mgreg_t));
+ x86_alu_reg_imm (code, X86_CMP, X86_ECX, 0);
br[0] = code; x86_branch8 (code, X86_CC_EQ, 0, FALSE);
- x86_call_membase (code, X86_ECX, 0);
+ x86_call_reg (code, X86_ECX);
x86_patch (br [0], code);
}
#include <mono/utils/dtrace.h>
#include <mono/utils/mono-threads.h>
#include <mono/utils/mono-threads-coop.h>
-#include <mono/io-layer/io-layer.h>
#include "mini.h"
#include "seq-points.h"
}
}
-#define MONO_INIT_VARINFO(vi,id) do { \
- (vi)->range.first_use.pos.bid = 0xffff; \
- (vi)->reg = -1; \
- (vi)->idx = (id); \
-} while (0)
-
/**
* mono_unlink_bblock:
*
cfg->varinfo [num] = inst;
- MONO_INIT_VARINFO (&cfg->vars [num], num);
- MONO_VARINFO (cfg, num)->vreg = vreg;
+ cfg->vars [num].idx = num;
+ cfg->vars [num].vreg = vreg;
+ cfg->vars [num].range.first_use.pos.bid = 0xffff;
+ cfg->vars [num].reg = -1;
if (vreg != -1)
set_vreg_to_inst (cfg, vreg, inst);
g_free (id);
}
- if (!cfg->compile_aot) {
+ if (!cfg->compile_aot && !(flags & JIT_FLAG_DISCARD_RESULTS)) {
mono_domain_lock (cfg->domain);
mono_jit_info_table_add (cfg->domain, cfg->jit_info);
#include "jit.h"
#include "cfgdump.h"
-#include "mono/metadata/class-internals.h"
-#include "mono/metadata/domain-internals.h"
-#include "mono/metadata/object.h"
#include "mono/metadata/tabledefs.h"
#include "mono/metadata/marshal.h"
#include "mono/metadata/security-manager.h"
#include "mono/metadata/exception.h"
-#include "mono/utils/mono-compiler.h"
#ifdef __native_client_codegen__
#include <nacl/nacl_dyncode.h>
#define MONO_BB_FOR_EACH_INS_SAFE(bb, n, ins) for ((ins) = (bb)->code, n = (ins) ? (ins)->next : NULL; (ins); (ins) = (n), (n) = (ins) ? (ins)->next : NULL)
+#define MONO_BB_FOR_EACH_INS_REVERSE(bb, ins) for ((ins) = (bb)->last_ins; (ins); (ins) = (ins)->prev)
+
#define MONO_BB_FOR_EACH_INS_REVERSE_SAFE(bb, p, ins) for ((ins) = (bb)->last_ins, p = (ins) ? (ins)->prev : NULL; (ins); (ins) = (p), (p) = (ins) ? (ins)->prev : NULL)
#define mono_bb_first_ins(bb) (bb)->code
/* Whenever to compile in llvm-only mode */
JIT_FLAG_LLVM_ONLY = (1 << 6),
/* Whenever calls to pinvoke functions are made directly */
- JIT_FLAG_DIRECT_PINVOKE = (1 << 7)
+ JIT_FLAG_DIRECT_PINVOKE = (1 << 7),
+ /* Whenever this is a compile-all run and the result should be discarded */
+ JIT_FLAG_DISCARD_RESULTS = (1 << 8),
} JitFlags;
/* Bit-fields in the MonoBasicBlock.region */
void mono_optimize_branches (MonoCompile *cfg);
void mono_blockset_print (MonoCompile *cfg, MonoBitSet *set, const char *name, guint idom);
-const char*mono_ji_type_to_string (MonoJumpInfoType type);
+const char*mono_ji_type_to_string (MonoJumpInfoType type) MONO_LLVM_INTERNAL;
void mono_print_ji (const MonoJumpInfo *ji);
void mono_print_ins_index (int i, MonoInst *ins);
GString *mono_print_ins_index_strbuf (int i, MonoInst *ins);
GSList *mono_arch_get_trampolines (gboolean aot);
#ifdef ENABLE_INTERPRETER
gpointer mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info);
+void mono_interp_init (void);
+gpointer interp_create_method_pointer (MonoMethod *method, MonoError *error);
+MonoObject* interp_mono_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc, MonoError *error);
#endif
/* Handle block guard */
public static int test_142_byte_enum_arg_zero_extend () {
return enum_arg_zero_extend (ByteEnum2.High);
}
+
+ enum Mine { One, Two }
+
+ public static int test_0_enum_gethashcode_opt () {
+ int sum = 0;
+ for (int i = 0; i < 1000000; ++i)
+ sum += Mine.Two.GetHashCode();
+
+ return 0;
+ }
}
#if __MOBILE__
OPTFLAG(SSAPRE ,19, "ssapre", "SSA based Partial Redundancy Elimination (obsolete)")
OPTFLAG(EXCEPTION,20, "exception", "Optimize exception catch blocks")
OPTFLAG(SSA ,21, "ssa", "Use plain SSA form")
+OPTFLAG(FLOAT32 ,22, "float32", "Use 32 bit float arithmetic if possible")
OPTFLAG(SSE2 ,23, "sse2", "SSE2 instructions on x86")
-OPTFLAG(GSHARED ,25, "gshared", "Generic Sharing")
-/* The id has to be smaller than gshared's, the parser code depends on this */
OPTFLAG(GSHAREDVT,24, "gsharedvt", "Generic sharing for valuetypes")
+OPTFLAG (GSHARED, 25, "gshared", "Generic Sharing")
OPTFLAG(SIMD ,26, "simd", "Simd intrinsics")
OPTFLAG(UNSAFE ,27, "unsafe", "Remove bound checks and perform other dangerous changes")
OPTFLAG(ALIAS_ANALYSIS ,28, "alias-analysis", "Alias analysis of locals")
-OPTFLAG(FLOAT32 ,29, "float32", "Use 32 bit float arithmetic if possible")
-
}
}
- g_free (predecessors);
+ g_array_free (predecessors, TRUE);
}
static void
if (l) {
endfinally_seq_point = (MonoInst *)l->data;
- for (bb2 = cfg->bb_entry; bb2; bb2 = bb2->next_bb) {
+ for (bb2 = bb->next_bb; bb2; bb2 = bb2->next_bb) {
GSList *l = g_slist_last (bb2->seq_points);
if (l) {
}
if (value != NULL)
g_free (value);
- value = (char *)g_malloc (input - start + 1);
- strncpy (value, start, input-start);
- value [input-start] = 0;
+ size_t len = input - start;
+ value = (char *)g_malloc (len + 1);
+ memcpy (value, start, len);
+ value [len] = 0;
}
enum Token {
endif
endif
+if TARGET_OSX
+libmono_dep =
+else
+libmono_dep = $(monodir)/mono/mini/$(LIBMONO_LA)
+endif
+
if PLATFORM_ANDROID
prof_ldflags = -avoid-version
endif
# functionality, so create a separate static version of the library.
libmono_profiler_aot_la_SOURCES = mono-profiler-aot.c
-libmono_profiler_aot_la_LIBADD = $(monodir)/mono/mini/$(LIBMONO_LA) $(GLIB_LIBS) $(LIBICONV)
+libmono_profiler_aot_la_LIBADD = $(libmono_dep) $(GLIB_LIBS) $(LIBICONV)
libmono_profiler_aot_la_LDFLAGS = $(prof_ldflags)
libmono_profiler_aot_static_la_SOURCES = mono-profiler-aot.c
libmono_profiler_aot_static_la_LDFLAGS = -static
libmono_profiler_iomap_la_SOURCES = mono-profiler-iomap.c
-libmono_profiler_iomap_la_LIBADD = $(monodir)/mono/mini/$(LIBMONO_LA) $(GLIB_LIBS) $(LIBICONV)
+libmono_profiler_iomap_la_LIBADD = $(libmono_dep) $(GLIB_LIBS) $(LIBICONV)
libmono_profiler_iomap_la_LDFLAGS = $(prof_ldflags)
libmono_profiler_iomap_static_la_SOURCES = mono-profiler-iomap.c
libmono_profiler_iomap_static_la_LDFLAGS = -static
libmono_profiler_log_la_SOURCES = mono-profiler-log.c
-libmono_profiler_log_la_LIBADD = $(monodir)/mono/mini/$(LIBMONO_LA) $(GLIB_LIBS) $(Z_LIBS)
+libmono_profiler_log_la_LIBADD = $(libmono_dep) $(GLIB_LIBS) $(Z_LIBS)
libmono_profiler_log_la_LDFLAGS = $(prof_ldflags)
libmono_profiler_log_static_la_SOURCES = mono-profiler-log.c
libmono_profiler_log_static_la_LDFLAGS = -static
libmono_profiler_vtune_la_LDFLAGS = $(prof_ldflags)
libmono_profiler_vtune_static_la_SOURCES = mono-profiler-vtune.c
libmono_profiler_vtune_static_la_LDFLAGS = -static
+libmono_profiler_vtune_static_la_CFLAGS = $(VTUNE_CFLAGS)
+libmono_profiler_vtune_static_la_LIBADD = $(VTUNE_LIBS)
endif
mprof_report_SOURCES = mprof-report.c
CLASS=$(mcs_topdir)/class/lib/$(DEFAULT_PROFILE)
-with_mono_path = MONO_PATH=$(CLASS)
-
-RUNTIME = $(with_mono_path) $(top_builddir)/runtime/mono-wrapper
-MCS = $(RUNTIME) $(CSC) -lib:$(CLASS) -unsafe -nologo -noconfig -nowarn:0162 -nowarn:0168 -nowarn:0219 -debug:portable
+TOOLS_RUNTIME = MONO_PATH=$(mcs_topdir)/class/lib/build $(top_builddir)/runtime/mono-wrapper
+MCS = $(TOOLS_RUNTIME) $(CSC) -lib:$(CLASS) -unsafe -nologo -noconfig -nowarn:0162 -nowarn:0168 -nowarn:0219 -debug:portable
%.exe: %.cs
$(MCS) -out:$@ $<
testlog: $(PLOG_TESTS)
- $(with_mono_path) perl $(srcdir)/ptestrunner.pl $(top_builddir)
+ MONO_PATH=$(CLASS) perl $(srcdir)/ptestrunner.pl $(top_builddir)
check-local: $(check_targets)
EXTRA_DIST=mono-profiler-log.h \
+ mono-profiler-aot.h \
$(PLOG_TESTS_SRC) \
ptestrunner.pl \
$(suppression_DATA)
printf ("Creating output file: %s\n", prof->outfile_name);
- outfile = fopen (prof->outfile_name, "w+");
+ if (prof->outfile_name [0] == '#') {
+ int fd = strtol (prof->outfile_name + 1, NULL, 10);
+ outfile = fdopen (fd, "a");
+ } else {
+ outfile = fopen (prof->outfile_name, "w+");
+ }
if (!outfile) {
fprintf (stderr, "Unable to create output file '%s': %s.\n", prof->outfile_name, strerror (errno));
return;
return index;
}
-/*
- * Removes all NULL pointers from the array. Not thread safe
- */
-void
-sgen_array_list_remove_nulls (SgenArrayList *array)
-{
- guint32 start = 0;
- volatile gpointer *slot;
-
- SGEN_ARRAY_LIST_FOREACH_SLOT (array, slot) {
- if (*slot)
- *sgen_array_list_get_slot (array, start++) = *slot;
- } SGEN_ARRAY_LIST_END_FOREACH_SLOT;
-
- mono_memory_write_barrier ();
- array->next_slot = start;
-}
-
/*
* Does a linear search through the pointer array to find `ptr`. Returns the index if
* found, otherwise (guint32)-1.
return (guint32)-1;
}
+gboolean
+sgen_array_list_default_cas_setter (volatile gpointer *slot, gpointer ptr, int data)
+{
+ if (InterlockedCompareExchangePointer (slot, ptr, NULL) == NULL)
+ return TRUE;
+ return FALSE;
+}
+
+gboolean
+sgen_array_list_default_is_slot_set (volatile gpointer *slot)
+{
+ return *slot != NULL;
+}
+
#endif
guint32 sgen_array_list_alloc_block (SgenArrayList *array, guint32 slots_to_add);
guint32 sgen_array_list_add (SgenArrayList *array, gpointer ptr, int data, gboolean increase_size_before_set);
guint32 sgen_array_list_find (SgenArrayList *array, gpointer ptr);
-void sgen_array_list_remove_nulls (SgenArrayList *array);
+gboolean sgen_array_list_default_cas_setter (volatile gpointer *slot, gpointer ptr, int data);
+gboolean sgen_array_list_default_is_slot_set (volatile gpointer *slot);
+
#endif
sgen_card_table_clear_cards ();
#endif
SGEN_TV_GETTIME (atv);
- sgen_get_major_collector ()->scan_card_table (CARDTABLE_SCAN_GLOBAL, ctx);
+ sgen_get_major_collector ()->scan_card_table (CARDTABLE_SCAN_GLOBAL, ctx, 0, 1);
SGEN_TV_GETTIME (btv);
last_major_scan_time = SGEN_TV_ELAPSED (atv, btv);
major_card_scan_time += last_major_scan_time;
- sgen_los_scan_card_table (CARDTABLE_SCAN_GLOBAL, ctx);
+ sgen_los_scan_card_table (CARDTABLE_SCAN_GLOBAL, ctx, 0, 1);
SGEN_TV_GETTIME (atv);
last_los_scan_time = SGEN_TV_ELAPSED (btv, atv);
los_card_scan_time += last_los_scan_time;
{
HEAVY_STAT (++large_objects);
- if (sgen_client_cardtable_scan_object (obj, block_obj_size, cards, ctx))
+ if (sgen_client_cardtable_scan_object (obj, cards, ctx))
return;
HEAVY_STAT (++bloby_objects);
* parts of the object based on which cards are marked, do so and return TRUE. Otherwise,
* return FALSE.
*/
-gboolean sgen_client_cardtable_scan_object (GCObject *obj, mword block_obj_size, guint8 *cards, ScanCopyContext ctx);
+gboolean sgen_client_cardtable_scan_object (GCObject *obj, guint8 *cards, ScanCopyContext ctx);
/*
* Called after nursery objects have been pinned. No action is necessary.
extern guint64 stat_slots_allocated_in_vain;
/*
- * Copies an object and enqueues it if a queue is given.
- *
* This function can be used even if the vtable of obj is not valid
* anymore, which is the case in the parallel collector.
*/
static MONO_ALWAYS_INLINE void
-par_copy_object_no_checks (char *destination, GCVTable vt, void *obj, mword objsize, SgenGrayQueue *queue)
+par_copy_object_no_checks (char *destination, GCVTable vt, void *obj, mword objsize)
{
sgen_client_pre_copy_checks (destination, vt, obj, objsize);
binary_protocol_copy (obj, destination, vt, objsize);
SGEN_ASSERT (9, sgen_vtable_get_descriptor (vt), "vtable %p has no gc descriptor", vt);
sgen_client_update_copied_object (destination, vt, obj, objsize);
- obj = destination;
- if (queue) {
- SGEN_LOG (9, "Enqueuing gray object %p (%s)", obj, sgen_client_vtable_get_name (vt));
- GRAY_OBJECT_ENQUEUE (queue, (GCObject *)obj, sgen_vtable_get_descriptor (vt));
- }
}
/*
+ * Copies an object and enqueues it if a queue is given.
* This can return OBJ itself on OOM.
*/
static MONO_NEVER_INLINE GCObject *
GCVTable vt = SGEN_LOAD_VTABLE_UNCHECKED (obj);
gboolean has_references = SGEN_VTABLE_HAS_REFERENCES (vt);
mword objsize = SGEN_ALIGN_UP (sgen_client_par_object_get_size (vt, obj));
- /* FIXME: Does this not mark the newly allocated object? */
void *destination = COLLECTOR_SERIAL_ALLOC_FOR_PROMOTION (vt, obj, objsize, has_references);
if (G_UNLIKELY (!destination)) {
return obj;
}
- if (!has_references)
- queue = NULL;
-
- par_copy_object_no_checks ((char *)destination, vt, obj, objsize, queue);
- /* FIXME: mark mod union cards if necessary */
+ par_copy_object_no_checks ((char *)destination, vt, obj, objsize);
/* set the forwarding pointer */
SGEN_FORWARD_OBJECT (obj, destination);
+ if (has_references) {
+ SGEN_LOG (9, "Enqueuing gray object %p (%s)", destination, sgen_client_vtable_get_name (vt));
+ GRAY_OBJECT_ENQUEUE_SERIAL (queue, (GCObject *)destination, sgen_vtable_get_descriptor (vt));
+ }
+
return (GCObject *)destination;
}
+#if defined(COPY_OR_MARK_PARALLEL)
+static MONO_NEVER_INLINE GCObject *
+copy_object_no_checks_par (GCObject *obj, SgenGrayQueue *queue)
+{
+ mword vtable_word = *(mword*)obj;
+ GCObject *destination;
+
+ destination = (GCObject*) SGEN_VTABLE_IS_FORWARDED (vtable_word);
+
+ if (!destination) {
+ GCVTable vt = (GCVTable) vtable_word;
+ GCObject *final_destination;
+ /*
+ * At this point we know vt is not tagged and we shouldn't access the vtable through obj
+ * since it could get copied at any time by another thread.
+ */
+ gboolean has_references = SGEN_VTABLE_HAS_REFERENCES (vt);
+ mword objsize = SGEN_ALIGN_UP (sgen_client_par_object_get_size (vt, obj));
+ destination = major_collector.alloc_object_par (vt, objsize, has_references);
+
+ par_copy_object_no_checks ((char*)destination, vt, obj, objsize);
+
+ /* FIXME we might need a membar here so other threads see the vtable before we forward */
+
+ /* set the forwarding pointer */
+ SGEN_FORWARD_OBJECT_PAR (obj, destination, final_destination);
+
+ if (destination == final_destination) {
+ /* In a racing case, only the worker that allocated the object enqueues it */
+ if (has_references) {
+ SGEN_LOG (9, "Enqueuing gray object %p (%s)", destination, sgen_client_vtable_get_name (vt));
+ GRAY_OBJECT_ENQUEUE_PARALLEL (queue, (GCObject *)destination, sgen_vtable_get_descriptor (vt));
+ }
+ } else {
+ destination = final_destination;
+ }
+ }
+
+ return destination;
+}
+#endif
+
#undef COLLECTOR_SERIAL_ALLOC_FOR_PROMOTION
#undef collector_pin_object
+#undef COPY_OR_MARK_PARALLEL
#include "mono/sgen/sgen-protocol.h"
#include "mono/sgen/sgen-memory-governor.h"
#include "mono/sgen/sgen-hash-table.h"
-#include "mono/sgen/sgen-cardtable.h"
#include "mono/sgen/sgen-pinning.h"
#include "mono/sgen/sgen-workers.h"
#include "mono/sgen/sgen-client.h"
}
static void
-gray_queue_enable_redirect (SgenGrayQueue *queue)
+gray_queue_redirect (SgenGrayQueue *queue)
{
SGEN_ASSERT (0, concurrent_collection_in_progress, "Where are we redirecting the gray queue to, without a concurrent collection?");
- sgen_gray_queue_set_alloc_prepare (queue, sgen_workers_take_from_queue_and_awake);
- sgen_workers_take_from_queue_and_awake (queue);
+ sgen_workers_take_from_queue (queue);
}
void
gboolean
sgen_drain_gray_stack (ScanCopyContext ctx)
{
- ScanObjectFunc scan_func = ctx.ops->scan_object;
- SgenGrayQueue *queue = ctx.queue;
-
- if (ctx.ops->drain_gray_stack)
- return ctx.ops->drain_gray_stack (queue);
+ SGEN_ASSERT (0, ctx.ops->drain_gray_stack, "Why do we have a scan/copy context with a missing drain gray stack function?");
- for (;;) {
- GCObject *obj;
- SgenDescriptor desc;
- GRAY_OBJECT_DEQUEUE (queue, &obj, &desc);
- if (!obj)
- return TRUE;
- SGEN_LOG (9, "Precise gray object scan %p (%s)", obj, sgen_client_vtable_get_name (SGEN_LOAD_VTABLE (obj)));
- scan_func (obj, desc, queue);
- }
- return FALSE;
+ return ctx.ops->drain_gray_stack (ctx.queue);
}
/*
safe_object_get_size (obj_to_pin));
pin_object (obj_to_pin);
- GRAY_OBJECT_ENQUEUE (queue, obj_to_pin, desc);
+ GRAY_OBJECT_ENQUEUE_SERIAL (queue, obj_to_pin, desc);
sgen_pin_stats_register_object (obj_to_pin, GENERATION_NURSERY);
definitely_pinned [count] = obj_to_pin;
count++;
++objects_pinned;
sgen_pin_stats_register_object (object, GENERATION_NURSERY);
- GRAY_OBJECT_ENQUEUE (queue, object, sgen_obj_get_descriptor_safe (object));
+ GRAY_OBJECT_ENQUEUE_SERIAL (queue, object, sgen_obj_get_descriptor_safe (object));
}
/* Sort the addresses in array in increasing order.
SgenGrayQueue *gc_thread_gray_queue;
} ScanJob;
+typedef struct {
+ ScanJob scan_job;
+ int job_index;
+} ParallelScanJob;
+
static ScanCopyContext
scan_copy_context_for_scan_job (void *worker_data_untyped, ScanJob *job)
{
static void
job_scan_major_mod_union_card_table (void *worker_data_untyped, SgenThreadPoolJob *job)
{
- ScanJob *job_data = (ScanJob*)job;
- ScanCopyContext ctx = scan_copy_context_for_scan_job (worker_data_untyped, job_data);
+ ParallelScanJob *job_data = (ParallelScanJob*)job;
+ ScanCopyContext ctx = scan_copy_context_for_scan_job (worker_data_untyped, (ScanJob*)job_data);
g_assert (concurrent_collection_in_progress);
- major_collector.scan_card_table (CARDTABLE_SCAN_MOD_UNION, ctx);
+ major_collector.scan_card_table (CARDTABLE_SCAN_MOD_UNION, ctx, job_data->job_index, sgen_workers_get_job_split_count ());
}
static void
job_scan_los_mod_union_card_table (void *worker_data_untyped, SgenThreadPoolJob *job)
{
- ScanJob *job_data = (ScanJob*)job;
- ScanCopyContext ctx = scan_copy_context_for_scan_job (worker_data_untyped, job_data);
+ ParallelScanJob *job_data = (ParallelScanJob*)job;
+ ScanCopyContext ctx = scan_copy_context_for_scan_job (worker_data_untyped, (ScanJob*)job_data);
+
+ g_assert (concurrent_collection_in_progress);
+ sgen_los_scan_card_table (CARDTABLE_SCAN_MOD_UNION, ctx, job_data->job_index, sgen_workers_get_job_split_count ());
+}
+
+static void
+job_major_mod_union_preclean (void *worker_data_untyped, SgenThreadPoolJob *job)
+{
+ ParallelScanJob *job_data = (ParallelScanJob*)job;
+ ScanCopyContext ctx = scan_copy_context_for_scan_job (worker_data_untyped, (ScanJob*)job_data);
g_assert (concurrent_collection_in_progress);
- sgen_los_scan_card_table (CARDTABLE_SCAN_MOD_UNION, ctx);
+
+ major_collector.scan_card_table (CARDTABLE_SCAN_MOD_UNION_PRECLEAN, ctx, job_data->job_index, sgen_workers_get_job_split_count ());
}
static void
-job_mod_union_preclean (void *worker_data_untyped, SgenThreadPoolJob *job)
+job_los_mod_union_preclean (void *worker_data_untyped, SgenThreadPoolJob *job)
+{
+ ParallelScanJob *job_data = (ParallelScanJob*)job;
+ ScanCopyContext ctx = scan_copy_context_for_scan_job (worker_data_untyped, (ScanJob*)job_data);
+
+ g_assert (concurrent_collection_in_progress);
+
+ sgen_los_scan_card_table (CARDTABLE_SCAN_MOD_UNION_PRECLEAN, ctx, job_data->job_index, sgen_workers_get_job_split_count ());
+}
+
+static void
+job_scan_last_pinned (void *worker_data_untyped, SgenThreadPoolJob *job)
{
ScanJob *job_data = (ScanJob*)job;
ScanCopyContext ctx = scan_copy_context_for_scan_job (worker_data_untyped, job_data);
g_assert (concurrent_collection_in_progress);
- major_collector.scan_card_table (CARDTABLE_SCAN_MOD_UNION_PRECLEAN, ctx);
- sgen_los_scan_card_table (CARDTABLE_SCAN_MOD_UNION_PRECLEAN, ctx);
-
sgen_scan_pin_queue_objects (ctx);
}
+static void
+workers_finish_callback (void)
+{
+ ParallelScanJob *psj;
+ ScanJob *sj;
+ int split_count = sgen_workers_get_job_split_count ();
+ int i;
+ /* Mod union preclean jobs */
+ for (i = 0; i < split_count; i++) {
+ psj = (ParallelScanJob*)sgen_thread_pool_job_alloc ("preclean major mod union cardtable", job_major_mod_union_preclean, sizeof (ParallelScanJob));
+ psj->scan_job.ops = sgen_workers_get_idle_func_object_ops ();
+ psj->scan_job.gc_thread_gray_queue = NULL;
+ psj->job_index = i;
+ sgen_workers_enqueue_job (&psj->scan_job.job, TRUE);
+ }
+
+ for (i = 0; i < split_count; i++) {
+ psj = (ParallelScanJob*)sgen_thread_pool_job_alloc ("preclean los mod union cardtable", job_los_mod_union_preclean, sizeof (ParallelScanJob));
+ psj->scan_job.ops = sgen_workers_get_idle_func_object_ops ();
+ psj->scan_job.gc_thread_gray_queue = NULL;
+ psj->job_index = i;
+ sgen_workers_enqueue_job (&psj->scan_job.job, TRUE);
+ }
+
+ sj = (ScanJob*)sgen_thread_pool_job_alloc ("scan last pinned", job_scan_last_pinned, sizeof (ScanJob));
+ sj->ops = sgen_workers_get_idle_func_object_ops ();
+ sj->gc_thread_gray_queue = NULL;
+ sgen_workers_enqueue_job (&sj->job, TRUE);
+}
+
static void
init_gray_queue (SgenGrayQueue *gc_thread_gray_queue, gboolean use_workers)
{
} CopyOrMarkFromRootsMode;
static void
-major_copy_or_mark_from_roots (SgenGrayQueue *gc_thread_gray_queue, size_t *old_next_pin_slot, CopyOrMarkFromRootsMode mode, SgenObjectOperations *object_ops)
+major_copy_or_mark_from_roots (SgenGrayQueue *gc_thread_gray_queue, size_t *old_next_pin_slot, CopyOrMarkFromRootsMode mode, SgenObjectOperations *object_ops_nopar, SgenObjectOperations *object_ops_par)
{
LOSObject *bigobj;
TV_DECLARE (atv);
*/
char *heap_start = NULL;
char *heap_end = (char*)-1;
- ScanCopyContext ctx = CONTEXT_FROM_OBJECT_OPERATIONS (object_ops, gc_thread_gray_queue);
+ ScanCopyContext ctx = CONTEXT_FROM_OBJECT_OPERATIONS (object_ops_nopar, gc_thread_gray_queue);
gboolean concurrent = mode != COPY_OR_MARK_FROM_ROOTS_SERIAL;
SGEN_ASSERT (0, !!concurrent == !!concurrent_collection_in_progress, "We've been called with the wrong mode.");
}
sgen_los_pin_object (bigobj->data);
if (SGEN_OBJECT_HAS_REFERENCES (bigobj->data))
- GRAY_OBJECT_ENQUEUE (gc_thread_gray_queue, bigobj->data, sgen_obj_get_descriptor ((GCObject*)bigobj->data));
+ GRAY_OBJECT_ENQUEUE_SERIAL (gc_thread_gray_queue, bigobj->data, sgen_obj_get_descriptor ((GCObject*)bigobj->data));
sgen_pin_stats_register_object (bigobj->data, GENERATION_OLD);
SGEN_LOG (6, "Marked large object %p (%s) size: %lu from roots", bigobj->data,
sgen_client_vtable_get_name (SGEN_LOAD_VTABLE (bigobj->data)),
SGEN_ASSERT (0, sgen_workers_all_done (), "Why are the workers not done when we start or finish a major collection?");
if (mode == COPY_OR_MARK_FROM_ROOTS_FINISH_CONCURRENT) {
+ sgen_workers_set_num_active_workers (0);
if (sgen_workers_have_idle_work ()) {
/*
* We force the finish of the worker with the new object ops context
* which can also do copying. We need to have finished pinning.
*/
- sgen_workers_start_all_workers (object_ops, NULL);
+ sgen_workers_start_all_workers (object_ops_nopar, object_ops_par, NULL);
+
sgen_workers_join ();
}
}
sgen_client_collecting_major_3 (&fin_ready_queue, &critical_fin_queue);
- enqueue_scan_from_roots_jobs (gc_thread_gray_queue, heap_start, heap_end, object_ops, FALSE);
+ enqueue_scan_from_roots_jobs (gc_thread_gray_queue, heap_start, heap_end, object_ops_nopar, FALSE);
TV_GETTIME (btv);
time_major_scan_roots += TV_ELAPSED (atv, btv);
* the roots.
*/
if (mode == COPY_OR_MARK_FROM_ROOTS_START_CONCURRENT) {
+ sgen_workers_set_num_active_workers (1);
+ gray_queue_redirect (gc_thread_gray_queue);
if (precleaning_enabled) {
- ScanJob *sj;
- /* Mod union preclean job */
- sj = (ScanJob*)sgen_thread_pool_job_alloc ("preclean mod union cardtable", job_mod_union_preclean, sizeof (ScanJob));
- sj->ops = object_ops;
- sj->gc_thread_gray_queue = NULL;
- sgen_workers_start_all_workers (object_ops, &sj->job);
+ sgen_workers_start_all_workers (object_ops_nopar, object_ops_par, workers_finish_callback);
} else {
- sgen_workers_start_all_workers (object_ops, NULL);
+ sgen_workers_start_all_workers (object_ops_nopar, object_ops_par, NULL);
}
- gray_queue_enable_redirect (gc_thread_gray_queue);
}
if (mode == COPY_OR_MARK_FROM_ROOTS_FINISH_CONCURRENT) {
- ScanJob *sj;
+ int i, split_count = sgen_workers_get_job_split_count ();
+
+ gray_queue_redirect (gc_thread_gray_queue);
/* Mod union card table */
- sj = (ScanJob*)sgen_thread_pool_job_alloc ("scan mod union cardtable", job_scan_major_mod_union_card_table, sizeof (ScanJob));
- sj->ops = object_ops;
- sj->gc_thread_gray_queue = gc_thread_gray_queue;
- sgen_workers_enqueue_job (&sj->job, FALSE);
-
- sj = (ScanJob*)sgen_thread_pool_job_alloc ("scan LOS mod union cardtable", job_scan_los_mod_union_card_table, sizeof (ScanJob));
- sj->ops = object_ops;
- sj->gc_thread_gray_queue = gc_thread_gray_queue;
- sgen_workers_enqueue_job (&sj->job, FALSE);
-
- TV_GETTIME (atv);
- time_major_scan_mod_union += TV_ELAPSED (btv, atv);
+ for (i = 0; i < split_count; i++) {
+ ParallelScanJob *psj;
+
+ psj = (ParallelScanJob*)sgen_thread_pool_job_alloc ("scan mod union cardtable", job_scan_major_mod_union_card_table, sizeof (ParallelScanJob));
+ psj->scan_job.ops = object_ops_par ? object_ops_par : object_ops_nopar;
+ psj->scan_job.gc_thread_gray_queue = NULL;
+ psj->job_index = i;
+ sgen_workers_enqueue_job (&psj->scan_job.job, TRUE);
+
+ psj = (ParallelScanJob*)sgen_thread_pool_job_alloc ("scan LOS mod union cardtable", job_scan_los_mod_union_card_table, sizeof (ParallelScanJob));
+ psj->scan_job.ops = object_ops_par ? object_ops_par : object_ops_nopar;
+ psj->scan_job.gc_thread_gray_queue = NULL;
+ psj->job_index = i;
+ sgen_workers_enqueue_job (&psj->scan_job.job, TRUE);
+ }
+
+ /*
+ * If we enqueue a job while workers are running we need to sgen_workers_ensure_awake
+ * in order to make sure that we are running the idle func and draining all worker
+ * gray queues. The operation of starting workers implies this, so we start them after
+ * in order to avoid doing this operation twice. The workers will drain the main gray
+ * stack that contained roots and pinned objects and also scan the mod union card
+ * table.
+ */
+ sgen_workers_start_all_workers (object_ops_nopar, object_ops_par, NULL);
+ sgen_workers_join ();
}
sgen_pin_stats_report ();
static void
major_start_collection (SgenGrayQueue *gc_thread_gray_queue, const char *reason, gboolean concurrent, size_t *old_next_pin_slot)
{
- SgenObjectOperations *object_ops;
+ SgenObjectOperations *object_ops_nopar, *object_ops_par = NULL;
binary_protocol_collection_begin (gc_stats.major_gc_count, GENERATION_OLD);
g_assert (major_collector.is_concurrent);
concurrent_collection_in_progress = TRUE;
- object_ops = &major_collector.major_ops_concurrent_start;
+ object_ops_nopar = &major_collector.major_ops_concurrent_start;
+ if (major_collector.is_parallel)
+ object_ops_par = &major_collector.major_ops_conc_par_start;
+
} else {
- object_ops = &major_collector.major_ops_serial;
+ object_ops_nopar = &major_collector.major_ops_serial;
}
reset_pinned_from_failed_allocation ();
if (major_collector.start_major_collection)
major_collector.start_major_collection ();
- major_copy_or_mark_from_roots (gc_thread_gray_queue, old_next_pin_slot, concurrent ? COPY_OR_MARK_FROM_ROOTS_START_CONCURRENT : COPY_OR_MARK_FROM_ROOTS_SERIAL, object_ops);
+ major_copy_or_mark_from_roots (gc_thread_gray_queue, old_next_pin_slot, concurrent ? COPY_OR_MARK_FROM_ROOTS_START_CONCURRENT : COPY_OR_MARK_FROM_ROOTS_SERIAL, object_ops_nopar, object_ops_par);
}
static void
major_finish_collection (SgenGrayQueue *gc_thread_gray_queue, const char *reason, gboolean is_overflow, size_t old_next_pin_slot, gboolean forced)
{
ScannedObjectCounts counts;
- SgenObjectOperations *object_ops;
+ SgenObjectOperations *object_ops_nopar;
mword fragment_total;
TV_DECLARE (atv);
TV_DECLARE (btv);
TV_GETTIME (btv);
if (concurrent_collection_in_progress) {
- object_ops = &major_collector.major_ops_concurrent_finish;
+ SgenObjectOperations *object_ops_par = NULL;
- major_copy_or_mark_from_roots (gc_thread_gray_queue, NULL, COPY_OR_MARK_FROM_ROOTS_FINISH_CONCURRENT, object_ops);
+ object_ops_nopar = &major_collector.major_ops_concurrent_finish;
+ if (major_collector.is_parallel)
+ object_ops_par = &major_collector.major_ops_conc_par_finish;
+
+ major_copy_or_mark_from_roots (gc_thread_gray_queue, NULL, COPY_OR_MARK_FROM_ROOTS_FINISH_CONCURRENT, object_ops_nopar, object_ops_par);
#ifdef SGEN_DEBUG_INTERNAL_ALLOC
main_gc_thread = NULL;
#endif
} else {
- object_ops = &major_collector.major_ops_serial;
+ object_ops_nopar = &major_collector.major_ops_serial;
}
sgen_workers_assert_gray_queue_is_empty ();
- finish_gray_stack (GENERATION_OLD, CONTEXT_FROM_OBJECT_OPERATIONS (object_ops, gc_thread_gray_queue));
+ finish_gray_stack (GENERATION_OLD, CONTEXT_FROM_OBJECT_OPERATIONS (object_ops_nopar, gc_thread_gray_queue));
TV_GETTIME (atv);
time_major_finish_gray_stack += TV_ELAPSED (btv, atv);
sgen_marksweep_init (&major_collector);
} else if (!strcmp (major_collector_opt, "marksweep-conc")) {
sgen_marksweep_conc_init (&major_collector);
+ } else if (!strcmp (major_collector_opt, "marksweep-conc-par")) {
+ sgen_marksweep_conc_par_init (&major_collector);
} else {
sgen_env_var_error (MONO_GC_PARAMS_NAME, "Using `" DEFAULT_MAJOR_NAME "` instead.", "Unknown major collector `%s'.", major_collector_opt);
goto use_default_major;
if (major_collector.post_param_init)
major_collector.post_param_init (&major_collector);
- if (major_collector.needs_thread_pool)
- sgen_workers_init (1);
+ if (major_collector.needs_thread_pool) {
+ int num_workers = 1;
+ if (major_collector.is_parallel) {
+ /* FIXME Detect the number of physical cores, instead of logical */
+ num_workers = mono_cpu_count () / 2;
+ if (num_workers < 1)
+ num_workers = 1;
+ }
+ sgen_workers_init (num_workers, (SgenWorkerCallback) major_collector.worker_init_cb);
+ }
sgen_memgov_init (max_heap, soft_limit, debug_print_allowance, allowance_ratio, save_target);
#define SGEN_POINTER_UNTAG_VTABLE(p) SGEN_POINTER_UNTAG_ALL((p))
/* returns NULL if not forwarded, or the forwarded address */
-#define SGEN_VTABLE_IS_FORWARDED(vtable) ((GCVTable *)(SGEN_POINTER_IS_TAGGED_FORWARDED ((vtable)) ? SGEN_POINTER_UNTAG_VTABLE ((vtable)) : NULL))
+#define SGEN_VTABLE_IS_FORWARDED(vtable) ((GCObject *)(SGEN_POINTER_IS_TAGGED_FORWARDED ((vtable)) ? SGEN_POINTER_UNTAG_VTABLE ((vtable)) : NULL))
#define SGEN_OBJECT_IS_FORWARDED(obj) ((GCObject *)SGEN_VTABLE_IS_FORWARDED (((mword*)(obj))[0]))
#define SGEN_VTABLE_IS_PINNED(vtable) SGEN_POINTER_IS_TAGGED_PINNED ((vtable))
#define SGEN_FORWARD_OBJECT(obj,fw_addr) do { \
*(void**)(obj) = SGEN_POINTER_TAG_FORWARDED ((fw_addr)); \
} while (0)
+#define SGEN_FORWARD_OBJECT_PAR(obj,fw_addr,final_fw_addr) do { \
+ gpointer old_vtable_word = *(gpointer*)obj; \
+ gpointer new_vtable_word; \
+ final_fw_addr = SGEN_VTABLE_IS_FORWARDED (old_vtable_word); \
+ if (final_fw_addr) \
+ break; \
+ new_vtable_word = SGEN_POINTER_TAG_FORWARDED ((fw_addr)); \
+ old_vtable_word = InterlockedCompareExchangePointer ((gpointer*)obj, new_vtable_word, old_vtable_word); \
+ final_fw_addr = SGEN_VTABLE_IS_FORWARDED (old_vtable_word); \
+ if (!final_fw_addr) \
+ final_fw_addr = (fw_addr); \
+ } while (0)
#define SGEN_PIN_OBJECT(obj) do { \
*(void**)(obj) = SGEN_POINTER_TAG_PINNED (*(void**)(obj)); \
} while (0)
struct _SgenMajorCollector {
size_t section_size;
gboolean is_concurrent;
+ gboolean is_parallel;
gboolean needs_thread_pool;
gboolean supports_cardtable;
gboolean sweeps_lazily;
SgenObjectOperations major_ops_serial;
SgenObjectOperations major_ops_concurrent_start;
SgenObjectOperations major_ops_concurrent_finish;
+ SgenObjectOperations major_ops_conc_par_start;
+ SgenObjectOperations major_ops_conc_par_finish;
GCObject* (*alloc_object) (GCVTable vtable, size_t size, gboolean has_references);
+ GCObject* (*alloc_object_par) (GCVTable vtable, size_t size, gboolean has_references);
void (*free_pinned_object) (GCObject *obj, size_t size);
/*
void (*free_non_pinned_object) (GCObject *obj, size_t size);
void (*pin_objects) (SgenGrayQueue *queue);
void (*pin_major_object) (GCObject *obj, SgenGrayQueue *queue);
- void (*scan_card_table) (CardTableScanType scan_type, ScanCopyContext ctx);
+ void (*scan_card_table) (CardTableScanType scan_type, ScanCopyContext ctx, int job_index, int job_split_count);
void (*iterate_live_block_ranges) (sgen_cardtable_block_callback callback);
void (*iterate_block_ranges) (sgen_cardtable_block_callback callback);
void (*update_cardtable_mod_union) (void);
guint8* (*get_cardtable_mod_union_for_reference) (char *object);
long long (*get_and_reset_num_major_objects_marked) (void);
void (*count_cards) (long long *num_total_cards, long long *num_marked_cards);
+
+ void (*worker_init_cb) (gpointer worker);
};
extern SgenMajorCollector major_collector;
void sgen_marksweep_init (SgenMajorCollector *collector);
-void sgen_marksweep_fixed_init (SgenMajorCollector *collector);
-void sgen_marksweep_par_init (SgenMajorCollector *collector);
-void sgen_marksweep_fixed_par_init (SgenMajorCollector *collector);
void sgen_marksweep_conc_init (SgenMajorCollector *collector);
+void sgen_marksweep_conc_par_init (SgenMajorCollector *collector);
SgenMajorCollector* sgen_get_major_collector (void);
static inline mword
sgen_safe_object_get_size (GCObject *obj)
{
- GCObject *forwarded;
-
- if ((forwarded = SGEN_OBJECT_IS_FORWARDED (obj)))
- obj = forwarded;
+ GCObject *forwarded;
+ GCVTable vtable = SGEN_LOAD_VTABLE_UNCHECKED (obj);
- return sgen_client_par_object_get_size (SGEN_LOAD_VTABLE (obj), obj);
+ /*
+ * Once we load the vtable, we must always use it, in case we are in parallel case.
+ * Otherwise the object might get forwarded in the meantime and we would read an
+ * invalid vtable. An object cannot be forwarded for a second time during same GC.
+ */
+ if ((forwarded = SGEN_VTABLE_IS_FORWARDED (vtable)))
+ return sgen_client_par_object_get_size (SGEN_LOAD_VTABLE (forwarded), obj);
+ else
+ return sgen_client_par_object_get_size ((GCVTable)SGEN_POINTER_UNTAG_ALL (vtable), obj);
}
static inline gboolean
gboolean sgen_ptr_is_in_los (char *ptr, char **start);
void sgen_los_iterate_objects (IterateObjectCallbackFunc cb, void *user_data);
void sgen_los_iterate_live_block_ranges (sgen_cardtable_block_callback callback);
-void sgen_los_scan_card_table (CardTableScanType scan_type, ScanCopyContext ctx);
+void sgen_los_scan_card_table (CardTableScanType scan_type, ScanCopyContext ctx, int job_index, int job_split_count);
void sgen_los_update_cardtable_mod_union (void);
void sgen_los_count_cards (long long *num_total_cards, long long *num_marked_cards);
gboolean sgen_los_is_valid_object (char *object);
LOSObject* sgen_los_header_for_object (GCObject *data);
mword sgen_los_object_size (LOSObject *obj);
void sgen_los_pin_object (GCObject *obj);
+gboolean sgen_los_pin_object_par (GCObject *obj);
gboolean sgen_los_object_is_pinned (GCObject *obj);
void sgen_los_mark_mod_union_card (GCObject *mono_obj, void **ptr);
static GrayQueueSection *last_gray_queue_free_list;
void
-sgen_gray_object_alloc_queue_section (SgenGrayQueue *queue)
+sgen_gray_object_alloc_queue_section (SgenGrayQueue *queue, gboolean is_parallel)
{
GrayQueueSection *section;
- if (queue->alloc_prepare_func)
- queue->alloc_prepare_func (queue);
-
if (queue->free_list) {
/* Use the previously allocated queue sections if possible */
section = queue->free_list;
STATE_SET (section, GRAY_QUEUE_SECTION_STATE_FLOATING);
}
- section->size = SGEN_GRAY_QUEUE_SECTION_SIZE;
+ /* Section is empty */
+ section->size = 0;
STATE_TRANSITION (section, GRAY_QUEUE_SECTION_STATE_FLOATING, GRAY_QUEUE_SECTION_STATE_ENQUEUED);
/* Link it with the others */
section->next = queue->first;
+ section->prev = NULL;
+ if (queue->first)
+ queue->first->prev = section;
+ else
+ queue->last = section;
queue->first = section;
queue->cursor = section->entries - 1;
+
+ if (is_parallel) {
+ mono_memory_write_barrier ();
+ /*
+ * FIXME
+ * we could probably optimize the code to only rely on the write barrier
+ * for synchronization with the stealer thread. Additionally we could also
+ * do a write barrier once every other gray queue change, and request
+ * to have a minimum of sections before stealing, to keep consistency.
+ */
+ InterlockedIncrement (&queue->num_sections);
+ } else {
+ queue->num_sections++;
+ }
}
void
*/
void
-sgen_gray_object_enqueue (SgenGrayQueue *queue, GCObject *obj, SgenDescriptor desc)
+sgen_gray_object_enqueue (SgenGrayQueue *queue, GCObject *obj, SgenDescriptor desc, gboolean is_parallel)
{
GrayQueueEntry entry = SGEN_GRAY_QUEUE_ENTRY (obj, desc);
if (G_UNLIKELY (!queue->first || queue->cursor == GRAY_LAST_CURSOR_POSITION (queue->first))) {
if (queue->first) {
- /* Set the current section size back to default, might have been changed by sgen_gray_object_dequeue_section */
+ /*
+ * We don't actively update the section size with each push/pop. For the first
+ * section we determine the size from the cursor position. For the reset of the
+ * sections we need to have the size set.
+ */
queue->first->size = SGEN_GRAY_QUEUE_SECTION_SIZE;
}
- sgen_gray_object_alloc_queue_section (queue);
+ sgen_gray_object_alloc_queue_section (queue, is_parallel);
}
STATE_ASSERT (queue->first, GRAY_QUEUE_SECTION_STATE_ENQUEUED);
SGEN_ASSERT (9, queue->cursor <= GRAY_LAST_CURSOR_POSITION (queue->first), "gray queue %p overflow, first %p, cursor %p", queue, queue->first, queue->cursor);
#endif
}
+/*
+ * We attempt to spread the objects in the gray queue across a number
+ * of sections. If the queue has more sections, then it's already spread,
+ * if it doesn't have enough sections, then we allocate as many as we
+ * can.
+ */
+void
+sgen_gray_object_spread (SgenGrayQueue *queue, int num_sections)
+{
+ GrayQueueSection *section_start, *section_end;
+ int total_entries = 0, num_entries_per_section;
+ int num_sections_final;
+
+ if (queue->num_sections >= num_sections)
+ return;
+
+ if (!queue->first)
+ return;
+
+ /* Compute number of elements in the gray queue */
+ queue->first->size = queue->cursor - queue->first->entries + 1;
+ total_entries = queue->first->size;
+ for (section_start = queue->first->next; section_start != NULL; section_start = section_start->next) {
+ SGEN_ASSERT (0, section_start->size == SGEN_GRAY_QUEUE_SECTION_SIZE, "We expect all section aside from the first one to be full");
+ total_entries += section_start->size;
+ }
+
+ /* Compute how many sections we should have and elements per section */
+ num_sections_final = (total_entries > num_sections) ? num_sections : total_entries;
+ num_entries_per_section = total_entries / num_sections_final;
+
+ /* Allocate all needed sections */
+ while (queue->num_sections < num_sections_final)
+ sgen_gray_object_alloc_queue_section (queue, TRUE);
+
+ /* Spread out the elements in the sections. By design, sections at the end are fuller. */
+ section_start = queue->first;
+ section_end = queue->last;
+ while (section_start != section_end) {
+ /* We move entries from end to start, until they meet */
+ while (section_start->size < num_entries_per_section) {
+ GrayQueueEntry entry;
+ if (section_end->size <= num_entries_per_section) {
+ section_end = section_end->prev;
+ if (section_end == section_start)
+ break;
+ }
+ if (section_end->size <= num_entries_per_section)
+ break;
+
+ section_end->size--;
+ entry = section_end->entries [section_end->size];
+ section_start->entries [section_start->size] = entry;
+ section_start->size++;
+ }
+ section_start = section_start->next;
+ }
+
+ queue->cursor = queue->first->entries + queue->first->size - 1;
+ queue->num_sections = num_sections_final;
+}
+
GrayQueueEntry
-sgen_gray_object_dequeue (SgenGrayQueue *queue)
+sgen_gray_object_dequeue (SgenGrayQueue *queue, gboolean is_parallel)
{
GrayQueueEntry entry;
#endif
if (G_UNLIKELY (queue->cursor < GRAY_FIRST_CURSOR_POSITION (queue->first))) {
- GrayQueueSection *section = queue->first;
+ GrayQueueSection *section;
+ gint32 old_num_sections = 0;
+
+ if (is_parallel)
+ old_num_sections = InterlockedDecrement (&queue->num_sections);
+ else
+ queue->num_sections--;
+
+ if (is_parallel && old_num_sections <= 0) {
+ mono_os_mutex_lock (&queue->steal_mutex);
+ }
+
+ section = queue->first;
queue->first = section->next;
+ if (queue->first) {
+ queue->first->prev = NULL;
+ } else {
+ queue->last = NULL;
+ SGEN_ASSERT (0, !old_num_sections, "Why do we have an inconsistent number of sections ?");
+ }
section->next = queue->free_list;
STATE_TRANSITION (section, GRAY_QUEUE_SECTION_STATE_ENQUEUED, GRAY_QUEUE_SECTION_STATE_FREE_LIST);
queue->free_list = section;
queue->cursor = queue->first ? queue->first->entries + queue->first->size - 1 : NULL;
+
+ if (is_parallel && old_num_sections <= 0) {
+ mono_os_mutex_unlock (&queue->steal_mutex);
+ }
}
return entry;
if (!queue->first)
return NULL;
+ /* We never steal from this queue */
+ queue->num_sections--;
+
section = queue->first;
queue->first = section->next;
+ if (queue->first)
+ queue->first->prev = NULL;
+ else
+ queue->last = NULL;
section->next = NULL;
section->size = queue->cursor - section->entries + 1;
return section;
}
+GrayQueueSection*
+sgen_gray_object_steal_section (SgenGrayQueue *queue)
+{
+ gint32 sections_remaining;
+ GrayQueueSection *section = NULL;
+
+ /*
+ * With each push/pop into the queue we increment the number of sections.
+ * There is only one thread accessing the top (the owner) and potentially
+ * multiple workers trying to steal sections from the bottom, so we need
+ * to lock. A num sections decrement from the owner means that the first
+ * section is reserved, while a decrement by the stealer means that the
+ * last section is reserved. If after we decrement the num sections, we
+ * have at least one more section present, it means we can't race with
+ * the other thread. If this is not the case the steal end abandons the
+ * pop, setting back the num_sections, while the owner end will take a
+ * lock to make sure we are not racing with the stealer (since the stealer
+ * might have popped an entry and be in the process of updating the entry
+ * that the owner is trying to pop.
+ */
+
+ if (queue->num_sections <= 1)
+ return NULL;
+
+ /* Give up if there is contention on the last section */
+ if (mono_os_mutex_trylock (&queue->steal_mutex) != 0)
+ return NULL;
+
+ sections_remaining = InterlockedDecrement (&queue->num_sections);
+ if (sections_remaining <= 0) {
+ /* The section that we tried to steal might be the head of the queue. */
+ InterlockedIncrement (&queue->num_sections);
+ } else {
+ /* We have reserved for us the tail section of the queue */
+ section = queue->last;
+ SGEN_ASSERT (0, section, "Why we don't have any sections to steal?");
+ SGEN_ASSERT (0, !section->next, "Why aren't we stealing the tail?");
+ queue->last = section->prev;
+ section->prev = NULL;
+ SGEN_ASSERT (0, queue->last, "Why are we stealing the last section?");
+ queue->last->next = NULL;
+
+ STATE_TRANSITION (section, GRAY_QUEUE_SECTION_STATE_ENQUEUED, GRAY_QUEUE_SECTION_STATE_FLOATING);
+ }
+
+ mono_os_mutex_unlock (&queue->steal_mutex);
+ return section;
+}
+
void
-sgen_gray_object_enqueue_section (SgenGrayQueue *queue, GrayQueueSection *section)
+sgen_gray_object_enqueue_section (SgenGrayQueue *queue, GrayQueueSection *section, gboolean is_parallel)
{
STATE_TRANSITION (section, GRAY_QUEUE_SECTION_STATE_FLOATING, GRAY_QUEUE_SECTION_STATE_ENQUEUED);
queue->first->size = queue->cursor - queue->first->entries + 1;
section->next = queue->first;
+ section->prev = NULL;
+ if (queue->first)
+ queue->first->prev = section;
+ else
+ queue->last = section;
queue->first = section;
queue->cursor = queue->first->entries + queue->first->size - 1;
#ifdef SGEN_CHECK_GRAY_OBJECT_ENQUEUE
queue->enqueue_check_func (section->entries [i].obj);
}
#endif
+ if (is_parallel) {
+ mono_memory_write_barrier ();
+ InterlockedIncrement (&queue->num_sections);
+ } else {
+ queue->num_sections++;
+ }
}
void
queue->enqueue_check_func = enqueue_check_func;
#endif
+ mono_os_mutex_init (&queue->steal_mutex);
+
if (reuse_free_list) {
queue->free_list = last_gray_queue_free_list;
last_gray_queue_free_list = NULL;
memset (queue, 0, sizeof (SgenGrayQueue));
}
-void
-sgen_gray_queue_set_alloc_prepare (SgenGrayQueue *queue, GrayQueueAllocPrepareFunc alloc_prepare_func)
-{
- SGEN_ASSERT (0, !queue->alloc_prepare_func, "Can't set gray queue alloc-prepare twice");
- queue->alloc_prepare_func = alloc_prepare_func;
-}
-
void
sgen_gray_object_queue_deinit (SgenGrayQueue *queue)
{
/* SGEN_GRAY_QUEUE_HEADER_SIZE is number of machine words */
#ifdef SGEN_CHECK_GRAY_OBJECT_SECTIONS
-#define SGEN_GRAY_QUEUE_HEADER_SIZE 4
+#define SGEN_GRAY_QUEUE_HEADER_SIZE 5
#else
-#define SGEN_GRAY_QUEUE_HEADER_SIZE 2
+#define SGEN_GRAY_QUEUE_HEADER_SIZE 3
#endif
#define SGEN_GRAY_QUEUE_SECTION_SIZE (128 - SGEN_GRAY_QUEUE_HEADER_SIZE)
#define SGEN_GRAY_QUEUE_ENTRY(obj,desc) { (obj), (desc) }
+#define GRAY_OBJECT_ENQUEUE_SERIAL(queue, obj, desc) (GRAY_OBJECT_ENQUEUE (queue, obj, desc, FALSE))
+#define GRAY_OBJECT_ENQUEUE_PARALLEL(queue, obj, desc) (GRAY_OBJECT_ENQUEUE (queue, obj, desc, TRUE))
+#define GRAY_OBJECT_DEQUEUE_SERIAL(queue, obj, desc) (GRAY_OBJECT_DEQUEUE (queue, obj, desc, FALSE))
+#define GRAY_OBJECT_DEQUEUE_PARALLEL(queue, obj, desc) (GRAY_OBJECT_DEQUEUE (queue, obj, desc, TRUE))
+
/*
* This is a stack now instead of a queue, so the most recently added items are removed
* first, improving cache locality, and keeping the stack size manageable.
GrayQueueSectionState state;
#endif
int size;
- GrayQueueSection *next;
+ GrayQueueSection *next, *prev;
GrayQueueEntry entries [SGEN_GRAY_QUEUE_SECTION_SIZE];
};
struct _SgenGrayQueue {
GrayQueueEntry *cursor;
- GrayQueueSection *first;
+ GrayQueueSection *first, *last;
GrayQueueSection *free_list;
- GrayQueueAllocPrepareFunc alloc_prepare_func;
+ mono_mutex_t steal_mutex;
+ gint32 num_sections;
#ifdef SGEN_CHECK_GRAY_OBJECT_ENQUEUE
GrayQueueEnqueueCheckFunc enqueue_check_func;
#endif
void sgen_init_gray_queues (void);
-void sgen_gray_object_enqueue (SgenGrayQueue *queue, GCObject *obj, SgenDescriptor desc);
-GrayQueueEntry sgen_gray_object_dequeue (SgenGrayQueue *queue);
+void sgen_gray_object_enqueue (SgenGrayQueue *queue, GCObject *obj, SgenDescriptor desc, gboolean is_parallel);
+GrayQueueEntry sgen_gray_object_dequeue (SgenGrayQueue *queue, gboolean is_parallel);
GrayQueueSection* sgen_gray_object_dequeue_section (SgenGrayQueue *queue);
-void sgen_gray_object_enqueue_section (SgenGrayQueue *queue, GrayQueueSection *section);
+GrayQueueSection* sgen_gray_object_steal_section (SgenGrayQueue *queue);
+void sgen_gray_object_spread (SgenGrayQueue *queue, int num_sections);
+void sgen_gray_object_enqueue_section (SgenGrayQueue *queue, GrayQueueSection *section, gboolean is_parallel);
void sgen_gray_object_queue_trim_free_list (SgenGrayQueue *queue);
void sgen_gray_object_queue_init (SgenGrayQueue *queue, GrayQueueEnqueueCheckFunc enqueue_check_func, gboolean reuse_free_list);
void sgen_gray_object_queue_dispose (SgenGrayQueue *queue);
-void sgen_gray_queue_set_alloc_prepare (SgenGrayQueue *queue, GrayQueueAllocPrepareFunc alloc_prepare_func);
void sgen_gray_object_queue_deinit (SgenGrayQueue *queue);
-void sgen_gray_object_alloc_queue_section (SgenGrayQueue *queue);
+void sgen_gray_object_alloc_queue_section (SgenGrayQueue *queue, gboolean is_parallel);
void sgen_gray_object_free_queue_section (GrayQueueSection *section);
void sgen_section_gray_queue_init (SgenSectionGrayQueue *queue, gboolean locked,
}
static inline MONO_ALWAYS_INLINE void
-GRAY_OBJECT_ENQUEUE (SgenGrayQueue *queue, GCObject *obj, SgenDescriptor desc)
+GRAY_OBJECT_ENQUEUE (SgenGrayQueue *queue, GCObject *obj, SgenDescriptor desc, gboolean is_parallel)
{
#if SGEN_MAX_DEBUG_LEVEL >= 9
- sgen_gray_object_enqueue (queue, obj, desc);
+ sgen_gray_object_enqueue (queue, obj, desc, is_parallel);
#else
if (G_UNLIKELY (!queue->first || queue->cursor == GRAY_LAST_CURSOR_POSITION (queue->first))) {
- sgen_gray_object_enqueue (queue, obj, desc);
+ sgen_gray_object_enqueue (queue, obj, desc, is_parallel);
} else {
GrayQueueEntry entry = SGEN_GRAY_QUEUE_ENTRY (obj, desc);
}
static inline MONO_ALWAYS_INLINE void
-GRAY_OBJECT_DEQUEUE (SgenGrayQueue *queue, GCObject** obj, SgenDescriptor *desc)
+GRAY_OBJECT_DEQUEUE (SgenGrayQueue *queue, GCObject** obj, SgenDescriptor *desc, gboolean is_parallel)
{
GrayQueueEntry entry;
#if SGEN_MAX_DEBUG_LEVEL >= 9
- entry = sgen_gray_object_dequeue (queue);
+ entry = sgen_gray_object_dequeue (queue, is_parallel);
*obj = entry.obj;
*desc = entry.desc;
#else
*obj = NULL;
} else if (G_UNLIKELY (queue->cursor == GRAY_FIRST_CURSOR_POSITION (queue->first))) {
- entry = sgen_gray_object_dequeue (queue);
+ entry = sgen_gray_object_dequeue (queue, is_parallel);
*obj = entry.obj;
*desc = entry.desc;
} else {
}
void
-sgen_los_scan_card_table (CardTableScanType scan_type, ScanCopyContext ctx)
+sgen_los_scan_card_table (CardTableScanType scan_type, ScanCopyContext ctx, int job_index, int job_split_count)
{
LOSObject *obj;
+ int i = 0;
binary_protocol_los_card_table_scan_start (sgen_timestamp (), scan_type & CARDTABLE_SCAN_MOD_UNION);
- for (obj = los_object_list; obj; obj = obj->next) {
+ for (obj = los_object_list; obj; obj = obj->next, i++) {
mword num_cards = 0;
guint8 *cards;
+ if (i % job_split_count != job_index)
+ continue;
+
if (!SGEN_OBJECT_HAS_REFERENCES (obj->data))
continue;
if (!sgen_los_object_is_pinned (obj->data))
continue;
+ if (!obj->cardtable_mod_union)
+ continue;
+
cards = get_cardtable_mod_union_for_object (obj);
g_assert (cards);
if (scan_type == CARDTABLE_SCAN_MOD_UNION_PRECLEAN) {
binary_protocol_pin (data, (gpointer)SGEN_LOAD_VTABLE (data), sgen_safe_object_get_size (data));
}
+gboolean
+sgen_los_pin_object_par (GCObject *data)
+{
+ LOSObject *obj = sgen_los_header_for_object (data);
+ mword old_size = obj->size;
+ if (old_size & 1)
+ return FALSE;
+#if SIZEOF_VOID_P == 4
+ old_size = InterlockedCompareExchange ((volatile gint32*)&obj->size, old_size | 1, old_size);
+#else
+ old_size = InterlockedCompareExchange64 ((volatile gint64*)&obj->size, old_size | 1, old_size);
+#endif
+ if (old_size & 1)
+ return FALSE;
+ binary_protocol_pin (data, (gpointer)SGEN_LOAD_VTABLE (data), sgen_safe_object_get_size (data));
+ return TRUE;
+}
+
static void
sgen_los_unpin_object (GCObject *data)
{
if (sgen_ptr_in_nursery (obj)) {
#if !defined(COPY_OR_MARK_CONCURRENT) && !defined(COPY_OR_MARK_CONCURRENT_WITH_EVACUATION)
int word, bit;
+ gboolean first = TRUE;
GCObject *forwarded, *old_obj;
mword vtable_word = *(mword*)obj;
do_copy_object:
#endif
old_obj = obj;
+#ifdef COPY_OR_MARK_PARALLEL
+ obj = copy_object_no_checks_par (obj, queue);
+#else
obj = copy_object_no_checks (obj, queue);
+#endif
if (G_UNLIKELY (old_obj == obj)) {
/*
* If we fail to evacuate an object we just stop doing it for a
block = MS_BLOCK_FOR_OBJ (obj);
MS_CALC_MARK_BIT (word, bit, obj);
SGEN_ASSERT (9, !MS_MARK_BIT (block, word, bit), "object %p already marked", obj);
+#ifdef COPY_OR_MARK_PARALLEL
+ MS_SET_MARK_BIT_PAR (block, word, bit, first);
+#else
MS_SET_MARK_BIT (block, word, bit);
- binary_protocol_mark (obj, (gpointer)SGEN_LOAD_VTABLE (obj), sgen_safe_object_get_size (obj));
+#endif
+ if (first)
+ binary_protocol_mark (obj, (gpointer)SGEN_LOAD_VTABLE (obj), sgen_safe_object_get_size (obj));
return FALSE;
#endif
}
#endif
+#ifdef COPY_OR_MARK_PARALLEL
+ MS_MARK_OBJECT_AND_ENQUEUE_PAR (obj, desc, block, queue);
+#else
MS_MARK_OBJECT_AND_ENQUEUE (obj, desc, block, queue);
+#endif
} else {
+ gboolean first = TRUE;
HEAVY_STAT (++stat_optimized_copy_major_large);
-
+#ifdef COPY_OR_MARK_PARALLEL
+ first = sgen_los_pin_object_par (obj);
+#else
if (sgen_los_object_is_pinned (obj))
- return FALSE;
- binary_protocol_pin (obj, (gpointer)SGEN_LOAD_VTABLE (obj), sgen_safe_object_get_size (obj));
+ first = FALSE;
+ else
+ sgen_los_pin_object (obj);
+#endif
- sgen_los_pin_object (obj);
- if (SGEN_OBJECT_HAS_REFERENCES (obj))
- GRAY_OBJECT_ENQUEUE (queue, obj, desc);
+ if (first) {
+ binary_protocol_pin (obj, (gpointer)SGEN_LOAD_VTABLE (obj), sgen_safe_object_get_size (obj));
+ if (SGEN_OBJECT_HAS_REFERENCES (obj))
+#ifdef COPY_OR_MARK_PARALLEL
+ GRAY_OBJECT_ENQUEUE_PARALLEL (queue, obj, desc);
+#else
+ GRAY_OBJECT_ENQUEUE_SERIAL (queue, obj, desc);
+#endif
+ }
}
return FALSE;
}
static gboolean
DRAIN_GRAY_STACK_FUNCTION_NAME (SgenGrayQueue *queue)
{
-#if defined(COPY_OR_MARK_CONCURRENT) || defined(COPY_OR_MARK_CONCURRENT_WITH_EVACUATION)
+#if defined(COPY_OR_MARK_CONCURRENT) || defined(COPY_OR_MARK_CONCURRENT_WITH_EVACUATION) || defined(COPY_OR_MARK_PARALLEL)
int i;
for (i = 0; i < 32; i++) {
#else
HEAVY_STAT (++stat_drain_loops);
- GRAY_OBJECT_DEQUEUE (queue, &obj, &desc);
+#if defined(COPY_OR_MARK_PARALLEL)
+ GRAY_OBJECT_DEQUEUE_PARALLEL (queue, &obj, &desc);
+#else
+ GRAY_OBJECT_DEQUEUE_SERIAL (queue, &obj, &desc);
+#endif
if (!obj)
return TRUE;
return FALSE;
}
+#undef COPY_OR_MARK_PARALLEL
#undef COPY_OR_MARK_FUNCTION_NAME
#undef COPY_OR_MARK_WITH_EVACUATION
#undef COPY_OR_MARK_CONCURRENT
#define MS_BLOCK_FREE (MS_BLOCK_SIZE - MS_BLOCK_SKIP)
-#define MS_NUM_MARK_WORDS ((MS_BLOCK_SIZE / SGEN_ALLOC_ALIGN + sizeof (mword) * 8 - 1) / (sizeof (mword) * 8))
+#define MS_NUM_MARK_WORDS (MS_BLOCK_SIZE / SGEN_ALLOC_ALIGN + sizeof (guint32) * 8 - 1) / (sizeof (guint32) * 8)
/*
* Blocks progress from one state to the next:
void ** volatile free_list;
MSBlockInfo * volatile next_free;
guint8 * volatile cardtable_mod_union;
- mword mark_words [MS_NUM_MARK_WORDS];
+ guint32 mark_words [MS_NUM_MARK_WORDS];
};
#define MS_BLOCK_FOR_BLOCK_INFO(b) ((char*)(b))
//casting to int is fine since blocks are 32k
#define MS_CALC_MARK_BIT(w,b,o) do { \
int i = ((int)((char*)(o) - MS_BLOCK_DATA_FOR_OBJ ((o)))) >> SGEN_ALLOC_ALIGN_BITS; \
- if (sizeof (mword) == 4) { \
- (w) = i >> 5; \
- (b) = i & 31; \
- } else { \
- (w) = i >> 6; \
- (b) = i & 63; \
- } \
+ (w) = i >> 5; \
+ (b) = i & 31; \
} while (0)
#define MS_MARK_BIT(bl,w,b) ((bl)->mark_words [(w)] & (ONE_P << (b)))
#define MS_SET_MARK_BIT(bl,w,b) ((bl)->mark_words [(w)] |= (ONE_P << (b)))
+#define MS_SET_MARK_BIT_PAR(bl,w,b,first) do { \
+ guint32 tmp_mark_word = (bl)->mark_words [(w)]; \
+ guint32 old_mark_word; \
+ first = FALSE; \
+ while (!(tmp_mark_word & (ONE_P << (b)))) { \
+ old_mark_word = tmp_mark_word; \
+ tmp_mark_word = InterlockedCompareExchange ((volatile gint32*)&(bl)->mark_words [w], old_mark_word | (ONE_P << (b)), old_mark_word); \
+ if (tmp_mark_word == old_mark_word) { \
+ first = TRUE; \
+ break; \
+ } \
+ } \
+ } while (0)
+
#define MS_OBJ_ALLOCED(o,b) (*(void**)(o) && (*(char**)(o) < MS_BLOCK_FOR_BLOCK_INFO (b) || *(char**)(o) >= MS_BLOCK_FOR_BLOCK_INFO (b) + MS_BLOCK_SIZE))
#define BLOCK_TAG(bl) ((bl)->has_references ? BLOCK_TAG_HAS_REFERENCES ((bl)) : (bl))
/* all allocated blocks in the system */
-static SgenArrayList allocated_blocks = SGEN_ARRAY_LIST_INIT (NULL, NULL, NULL, INTERNAL_MEM_PIN_QUEUE);
+static SgenArrayList allocated_blocks = SGEN_ARRAY_LIST_INIT (NULL, sgen_array_list_default_is_slot_set, sgen_array_list_default_cas_setter, INTERNAL_MEM_PIN_QUEUE);
/* non-allocated block free-list */
static void *empty_blocks = NULL;
* thread only ever adds blocks to the free list, so the ABA problem can't occur.
*/
static MSBlockInfo * volatile *free_block_lists [MS_BLOCK_TYPE_MAX];
+static MonoNativeTlsKey worker_block_free_list_key;
static guint64 stat_major_blocks_alloced = 0;
static guint64 stat_major_blocks_freed = 0;
#define FREE_BLOCKS_FROM(lists,p,r) (lists [((p) ? MS_BLOCK_FLAG_PINNED : 0) | ((r) ? MS_BLOCK_FLAG_REFS : 0)])
#define FREE_BLOCKS(p,r) (FREE_BLOCKS_FROM (free_block_lists, (p), (r)))
+#define FREE_BLOCKS_LOCAL(p,r) (FREE_BLOCKS_FROM (((MSBlockInfo***)mono_native_tls_get_value (worker_block_free_list_key)), (p), (r)))
#define MS_BLOCK_OBJ_SIZE_INDEX(s) \
(((s)+7)>>3 < MS_NUM_FAST_BLOCK_OBJ_SIZE_INDEXES ? \
return alloc_obj (vtable, size, FALSE, has_references);
}
+/*
+ * This can only be called by sgen workers. While this is called we assume
+ * that no other thread is accessing the block free lists. The world should
+ * be stopped and the gc thread should be waiting for workers to finish.
+ */
+static GCObject*
+major_alloc_object_par (GCVTable vtable, size_t size, gboolean has_references)
+{
+ int size_index = MS_BLOCK_OBJ_SIZE_INDEX (size);
+ MSBlockInfo * volatile * free_blocks = FREE_BLOCKS (FALSE, has_references);
+ MSBlockInfo **free_blocks_local = FREE_BLOCKS_LOCAL (FALSE, has_references);
+ void *obj;
+
+ if (free_blocks_local [size_index]) {
+get_slot:
+ obj = unlink_slot_from_free_list_uncontested (free_blocks_local, size_index);
+ } else {
+ MSBlockInfo *block;
+get_block:
+ block = free_blocks [size_index];
+ if (!block) {
+ if (G_UNLIKELY (!ms_alloc_block (size_index, FALSE, has_references)))
+ return NULL;
+ goto get_block;
+ } else {
+ MSBlockInfo *next_free = block->next_free;
+ /*
+ * Once a block is removed from the main list, it cannot return on the list until
+ * all the workers are finished and sweep is starting. This means we don't need
+ * to account for ABA problems.
+ */
+ if (SGEN_CAS_PTR ((volatile gpointer *)&free_blocks [size_index], next_free, block) != block)
+ goto get_block;
+ g_assert (block->free_list);
+ block->next_free = free_blocks_local [size_index];
+ free_blocks_local [size_index] = block;
+
+ goto get_slot;
+ }
+ }
+
+ /* FIXME: assumes object layout */
+ *(GCVTable*)obj = vtable;
+
+ /* FIXME is it worth CAS-ing here */
+ total_allocated_major += block_obj_sizes [size_index];
+
+ return (GCObject *)obj;
+}
+
/*
* We're not freeing the block if it's empty. We leave that work for
* the next major collection.
if (!MS_MARK_BIT ((block), __word, __bit)) { \
MS_SET_MARK_BIT ((block), __word, __bit); \
if (sgen_gc_descr_has_references (desc)) \
- GRAY_OBJECT_ENQUEUE ((queue), (obj), (desc)); \
+ GRAY_OBJECT_ENQUEUE_SERIAL ((queue), (obj), (desc)); \
+ binary_protocol_mark ((obj), (gpointer)SGEN_LOAD_VTABLE ((obj)), sgen_safe_object_get_size ((obj))); \
+ INC_NUM_MAJOR_OBJECTS_MARKED (); \
+ } \
+ } while (0)
+#define MS_MARK_OBJECT_AND_ENQUEUE_PAR(obj,desc,block,queue) do { \
+ int __word, __bit; \
+ gboolean first; \
+ MS_CALC_MARK_BIT (__word, __bit, (obj)); \
+ SGEN_ASSERT (9, MS_OBJ_ALLOCED ((obj), (block)), "object %p not allocated", obj); \
+ MS_SET_MARK_BIT_PAR ((block), __word, __bit, first); \
+ if (first) { \
+ if (sgen_gc_descr_has_references (desc)) \
+ GRAY_OBJECT_ENQUEUE_PARALLEL ((queue), (obj), (desc)); \
binary_protocol_mark ((obj), (gpointer)SGEN_LOAD_VTABLE ((obj)), sgen_safe_object_get_size ((obj))); \
INC_NUM_MAJOR_OBJECTS_MARKED (); \
} \
} while (0)
+
+
static void
pin_major_object (GCObject *obj, SgenGrayQueue *queue)
{
MS_MARK_OBJECT_AND_ENQUEUE (obj, sgen_obj_get_descriptor (obj), block, queue);
}
+#define COPY_OR_MARK_PARALLEL
#include "sgen-major-copy-object.h"
static long long
#define DRAIN_GRAY_STACK_FUNCTION_NAME drain_gray_stack_no_evacuation
#include "sgen-marksweep-drain-gray-stack.h"
+#define COPY_OR_MARK_PARALLEL
+#define COPY_OR_MARK_FUNCTION_NAME major_copy_or_mark_object_par_no_evacuation
+#define SCAN_OBJECT_FUNCTION_NAME major_scan_object_par_no_evacuation
+#define DRAIN_GRAY_STACK_FUNCTION_NAME drain_gray_stack_par_no_evacuation
+#include "sgen-marksweep-drain-gray-stack.h"
+
#define COPY_OR_MARK_WITH_EVACUATION
#define COPY_OR_MARK_FUNCTION_NAME major_copy_or_mark_object_with_evacuation
#define SCAN_OBJECT_FUNCTION_NAME major_scan_object_with_evacuation
#define SCAN_PTR_FIELD_FUNCTION_NAME major_scan_ptr_field_with_evacuation
#include "sgen-marksweep-drain-gray-stack.h"
+#define COPY_OR_MARK_PARALLEL
+#define COPY_OR_MARK_WITH_EVACUATION
+#define COPY_OR_MARK_FUNCTION_NAME major_copy_or_mark_object_par_with_evacuation
+#define SCAN_OBJECT_FUNCTION_NAME major_scan_object_par_with_evacuation
+#define SCAN_VTYPE_FUNCTION_NAME major_scan_vtype_par_with_evacuation
+#define DRAIN_GRAY_STACK_FUNCTION_NAME drain_gray_stack_par_with_evacuation
+#define SCAN_PTR_FIELD_FUNCTION_NAME major_scan_ptr_field_par_with_evacuation
+#include "sgen-marksweep-drain-gray-stack.h"
+
#define COPY_OR_MARK_CONCURRENT
#define COPY_OR_MARK_FUNCTION_NAME major_copy_or_mark_object_concurrent_no_evacuation
#define SCAN_OBJECT_FUNCTION_NAME major_scan_object_concurrent_no_evacuation
#define DRAIN_GRAY_STACK_FUNCTION_NAME drain_gray_stack_concurrent_no_evacuation
#include "sgen-marksweep-drain-gray-stack.h"
+#define COPY_OR_MARK_PARALLEL
+#define COPY_OR_MARK_CONCURRENT
+#define COPY_OR_MARK_FUNCTION_NAME major_copy_or_mark_object_concurrent_par_no_evacuation
+#define SCAN_OBJECT_FUNCTION_NAME major_scan_object_concurrent_par_no_evacuation
+#define DRAIN_GRAY_STACK_FUNCTION_NAME drain_gray_stack_concurrent_par_no_evacuation
+#include "sgen-marksweep-drain-gray-stack.h"
+
#define COPY_OR_MARK_CONCURRENT_WITH_EVACUATION
#define COPY_OR_MARK_FUNCTION_NAME major_copy_or_mark_object_concurrent_with_evacuation
#define SCAN_OBJECT_FUNCTION_NAME major_scan_object_concurrent_with_evacuation
#define DRAIN_GRAY_STACK_FUNCTION_NAME drain_gray_stack_concurrent_with_evacuation
#include "sgen-marksweep-drain-gray-stack.h"
+#define COPY_OR_MARK_PARALLEL
+#define COPY_OR_MARK_CONCURRENT_WITH_EVACUATION
+#define COPY_OR_MARK_FUNCTION_NAME major_copy_or_mark_object_concurrent_par_with_evacuation
+#define SCAN_OBJECT_FUNCTION_NAME major_scan_object_concurrent_par_with_evacuation
+#define SCAN_VTYPE_FUNCTION_NAME major_scan_vtype_concurrent_par_with_evacuation
+#define SCAN_PTR_FIELD_FUNCTION_NAME major_scan_ptr_field_concurrent_par_with_evacuation
+#define DRAIN_GRAY_STACK_FUNCTION_NAME drain_gray_stack_concurrent_par_with_evacuation
+#include "sgen-marksweep-drain-gray-stack.h"
+
static inline gboolean
major_is_evacuating (void)
{
return drain_gray_stack_no_evacuation (queue);
}
+static gboolean
+drain_gray_stack_par (SgenGrayQueue *queue)
+{
+ if (major_is_evacuating ())
+ return drain_gray_stack_par_with_evacuation (queue);
+ else
+ return drain_gray_stack_par_no_evacuation (queue);
+}
+
static gboolean
drain_gray_stack_concurrent (SgenGrayQueue *queue)
{
return drain_gray_stack_concurrent_no_evacuation (queue);
}
+static gboolean
+drain_gray_stack_concurrent_par (SgenGrayQueue *queue)
+{
+ if (major_is_evacuating ())
+ return drain_gray_stack_concurrent_par_with_evacuation (queue);
+ else
+ return drain_gray_stack_concurrent_par_no_evacuation (queue);
+}
+
static void
major_copy_or_mark_object_canonical (GCObject **ptr, SgenGrayQueue *queue)
{
major_copy_or_mark_object_concurrent_with_evacuation (ptr, *ptr, queue);
}
+static void
+major_copy_or_mark_object_concurrent_par_canonical (GCObject **ptr, SgenGrayQueue *queue)
+{
+ major_copy_or_mark_object_concurrent_par_with_evacuation (ptr, *ptr, queue);
+}
+
static void
major_copy_or_mark_object_concurrent_finish_canonical (GCObject **ptr, SgenGrayQueue *queue)
{
major_copy_or_mark_object_with_evacuation (ptr, *ptr, queue);
}
+static void
+major_copy_or_mark_object_concurrent_par_finish_canonical (GCObject **ptr, SgenGrayQueue *queue)
+{
+ major_copy_or_mark_object_par_with_evacuation (ptr, *ptr, queue);
+}
+
static void
mark_pinned_objects_in_block (MSBlockInfo *block, size_t first_entry, size_t last_entry, SgenGrayQueue *queue)
{
}
/* reset mark bits */
- memset (block->mark_words, 0, sizeof (mword) * MS_NUM_MARK_WORDS);
+ memset (block->mark_words, 0, sizeof (guint32) * MS_NUM_MARK_WORDS);
/* Reverse free list so that it's in address order */
reversed = NULL;
static volatile size_t num_major_sections_before_sweep;
static volatile size_t num_major_sections_freed_in_sweep;
+static void
+sgen_worker_clear_free_block_lists (WorkerData *worker)
+{
+ int i, j;
+
+ if (!worker->free_block_lists)
+ return;
+
+ for (i = 0; i < MS_BLOCK_TYPE_MAX; i++) {
+ for (j = 0; j < num_block_obj_sizes; j++) {
+ ((MSBlockInfo***) worker->free_block_lists) [i][j] = NULL;
+ }
+ }
+}
+
static void
sweep_start (void)
{
free_blocks [j] = NULL;
}
- sgen_array_list_remove_nulls (&allocated_blocks);
+ sgen_workers_foreach (sgen_worker_clear_free_block_lists);
}
static void sweep_finish (void);
ms_free_block (block);
SGEN_ATOMIC_ADD_P (num_major_sections, -1);
+ SGEN_ATOMIC_ADD_P (num_major_sections_freed_in_sweep, 1);
tagged_block = NULL;
}
* cooperate with the sweep thread to finish sweeping, and they will traverse from
* low to high, to avoid constantly colliding on the same blocks.
*/
- for (block_index = num_blocks; block_index-- > 0;) {
- /*
- * The block might have been freed by another thread doing some checking
- * work.
- */
- if (!ensure_block_is_checked_for_sweeping (block_index, TRUE, NULL))
- ++num_major_sections_freed_in_sweep;
+ for (block_index = allocated_blocks.next_slot; block_index-- > 0;) {
+ ensure_block_is_checked_for_sweeping (block_index, TRUE, NULL);
}
while (!try_set_sweep_state (SWEEP_STATE_COMPACTING, SWEEP_STATE_SWEEPING)) {
sweep_start ();
- SGEN_ASSERT (0, num_major_sections == allocated_blocks.next_slot, "We don't know how many blocks we have?");
-
num_major_sections_before_sweep = num_major_sections;
num_major_sections_freed_in_sweep = 0;
}
static void
-major_scan_card_table (CardTableScanType scan_type, ScanCopyContext ctx)
+major_scan_card_table (CardTableScanType scan_type, ScanCopyContext ctx, int job_index, int job_split_count)
{
MSBlockInfo *block;
gboolean has_references, was_sweeping, skip_scan;
binary_protocol_major_card_table_scan_start (sgen_timestamp (), scan_type & CARDTABLE_SCAN_MOD_UNION);
FOREACH_BLOCK_HAS_REFERENCES_NO_LOCK (block, has_references) {
+ if (__index % job_split_count != job_index)
+ continue;
#ifdef PREFETCH_CARDS
- int prefetch_index = __index + 6;
+ int prefetch_index = __index + 6 * job_split_count;
if (prefetch_index < allocated_blocks.next_slot) {
MSBlockInfo *prefetch_block = BLOCK_UNTAG (*sgen_array_list_get_slot (&allocated_blocks, prefetch_index));
PREFETCH_READ (prefetch_block);
collector->needs_thread_pool = concurrent_mark || concurrent_sweep;
}
+/* We are guaranteed to be called by the worker in question */
+static void
+sgen_worker_init_callback (gpointer worker_untyped)
+{
+ int i;
+ WorkerData *worker = (WorkerData*) worker_untyped;
+ MSBlockInfo ***worker_free_blocks = (MSBlockInfo ***) sgen_alloc_internal_dynamic (sizeof (MSBlockInfo**) * MS_BLOCK_TYPE_MAX, INTERNAL_MEM_MS_TABLES, TRUE);
+
+ for (i = 0; i < MS_BLOCK_TYPE_MAX; i++)
+ worker_free_blocks [i] = (MSBlockInfo **) sgen_alloc_internal_dynamic (sizeof (MSBlockInfo*) * num_block_obj_sizes, INTERNAL_MEM_MS_TABLES, TRUE);
+
+ worker->free_block_lists = worker_free_blocks;
+
+ mono_native_tls_set_value (worker_block_free_list_key, worker_free_blocks);
+}
+
static void
-sgen_marksweep_init_internal (SgenMajorCollector *collector, gboolean is_concurrent)
+sgen_marksweep_init_internal (SgenMajorCollector *collector, gboolean is_concurrent, gboolean is_parallel)
{
int i;
concurrent_mark = is_concurrent;
collector->is_concurrent = is_concurrent;
+ collector->is_parallel = is_parallel;
collector->needs_thread_pool = is_concurrent || concurrent_sweep;
collector->get_and_reset_num_major_objects_marked = major_get_and_reset_num_major_objects_marked;
collector->supports_cardtable = TRUE;
collector->alloc_degraded = major_alloc_degraded;
collector->alloc_object = major_alloc_object;
+ collector->alloc_object_par = major_alloc_object_par;
collector->free_pinned_object = free_pinned_object;
collector->iterate_objects = major_iterate_objects;
collector->free_non_pinned_object = major_free_non_pinned_object;
collector->major_ops_concurrent_finish.scan_vtype = major_scan_vtype_with_evacuation;
collector->major_ops_concurrent_finish.scan_ptr_field = major_scan_ptr_field_with_evacuation;
collector->major_ops_concurrent_finish.drain_gray_stack = drain_gray_stack;
+
+ if (is_parallel) {
+ collector->major_ops_conc_par_start.copy_or_mark_object = major_copy_or_mark_object_concurrent_par_canonical;
+ collector->major_ops_conc_par_start.scan_object = major_scan_object_concurrent_par_with_evacuation;
+ collector->major_ops_conc_par_start.scan_vtype = major_scan_vtype_concurrent_par_with_evacuation;
+ collector->major_ops_conc_par_start.scan_ptr_field = major_scan_ptr_field_concurrent_par_with_evacuation;
+ collector->major_ops_conc_par_start.drain_gray_stack = drain_gray_stack_concurrent_par;
+
+ collector->major_ops_conc_par_finish.copy_or_mark_object = major_copy_or_mark_object_concurrent_par_finish_canonical;
+ collector->major_ops_conc_par_finish.scan_object = major_scan_object_par_with_evacuation;
+ collector->major_ops_conc_par_finish.scan_vtype = major_scan_vtype_par_with_evacuation;
+ collector->major_ops_conc_par_finish.scan_ptr_field = major_scan_ptr_field_par_with_evacuation;
+ collector->major_ops_conc_par_finish.drain_gray_stack = drain_gray_stack_par;
+
+ collector->worker_init_cb = sgen_worker_init_callback;
+
+ mono_native_tls_alloc (&worker_block_free_list_key, NULL);
+ }
}
#ifdef HEAVY_STATISTICS
void
sgen_marksweep_init (SgenMajorCollector *collector)
{
- sgen_marksweep_init_internal (collector, FALSE);
+ sgen_marksweep_init_internal (collector, FALSE, FALSE);
}
void
sgen_marksweep_conc_init (SgenMajorCollector *collector)
{
- sgen_marksweep_init_internal (collector, TRUE);
+ sgen_marksweep_init_internal (collector, TRUE, FALSE);
+}
+
+void
+sgen_marksweep_conc_par_init (SgenMajorCollector *collector)
+{
+ sgen_marksweep_init_internal (collector, TRUE, TRUE);
}
#endif
#undef SERIAL_SCAN_OBJECT
#undef SERIAL_SCAN_VTYPE
#undef SERIAL_SCAN_PTR_FIELD
+#undef SERIAL_DRAIN_GRAY_STACK
#if defined(SGEN_SIMPLE_NURSERY)
#define SERIAL_SCAN_OBJECT simple_nursery_serial_with_concurrent_major_scan_object
#define SERIAL_SCAN_VTYPE simple_nursery_serial_with_concurrent_major_scan_vtype
#define SERIAL_SCAN_PTR_FIELD simple_nursery_serial_with_concurrent_major_scan_ptr_field
+#define SERIAL_DRAIN_GRAY_STACK simple_nursery_serial_with_concurrent_major_drain_gray_stack
#else
#define SERIAL_SCAN_OBJECT simple_nursery_serial_scan_object
#define SERIAL_SCAN_VTYPE simple_nursery_serial_scan_vtype
#define SERIAL_SCAN_PTR_FIELD simple_nursery_serial_scan_ptr_field
+#define SERIAL_DRAIN_GRAY_STACK simple_nursery_serial_drain_gray_stack
#endif
#elif defined (SGEN_SPLIT_NURSERY)
#define SERIAL_SCAN_OBJECT split_nursery_serial_with_concurrent_major_scan_object
#define SERIAL_SCAN_VTYPE split_nursery_serial_with_concurrent_major_scan_vtype
#define SERIAL_SCAN_PTR_FIELD split_nursery_serial_with_concurrent_major_scan_ptr_field
+#define SERIAL_DRAIN_GRAY_STACK split_nursery_serial_with_concurrent_major_drain_gray_stack
#else
#define SERIAL_SCAN_OBJECT split_nursery_serial_scan_object
#define SERIAL_SCAN_VTYPE split_nursery_serial_scan_vtype
#define SERIAL_SCAN_PTR_FIELD split_nursery_serial_scan_ptr_field
+#define SERIAL_DRAIN_GRAY_STACK split_nursery_serial_drain_gray_stack
#endif
#else
HANDLE_PTR (ptr, NULL);
}
+static gboolean
+SERIAL_DRAIN_GRAY_STACK (SgenGrayQueue *queue)
+{
+ for (;;) {
+ GCObject *obj;
+ SgenDescriptor desc;
+
+ GRAY_OBJECT_DEQUEUE_SERIAL (queue, &obj, &desc);
+ if (!obj)
+ return TRUE;
+
+ SERIAL_SCAN_OBJECT (obj, desc, queue);
+ }
+}
+
#define FILL_MINOR_COLLECTOR_SCAN_OBJECT(ops) do { \
(ops)->scan_object = SERIAL_SCAN_OBJECT; \
(ops)->scan_vtype = SERIAL_SCAN_VTYPE; \
(ops)->scan_ptr_field = SERIAL_SCAN_PTR_FIELD; \
+ (ops)->drain_gray_stack = SERIAL_DRAIN_GRAY_STACK; \
} while (0)
if (addr0 < addr1) {
if (unpin_queue)
- GRAY_OBJECT_ENQUEUE (unpin_queue, (GCObject*)addr0, sgen_obj_get_descriptor_safe ((GCObject*)addr0));
+ GRAY_OBJECT_ENQUEUE_SERIAL (unpin_queue, (GCObject*)addr0, sgen_obj_get_descriptor_safe ((GCObject*)addr0));
else
SGEN_UNPIN_OBJECT (addr0);
size = SGEN_ALIGN_UP (sgen_safe_object_get_size ((GCObject*)addr0));
SGEN_ASSERT (5, sgen_ptr_in_nursery (obj), "Can only cement pointers to nursery objects");
if (!hash [i].obj) {
- SGEN_ASSERT (5, !hash [i].count, "Cementing hash inconsistent");
- hash [i].obj = obj;
+ GCObject *old_obj;
+ old_obj = InterlockedCompareExchangePointer ((gpointer*)&hash [i].obj, obj, NULL);
+ /* Check if the slot was occupied by some other object */
+ if (old_obj != NULL && old_obj != obj)
+ return FALSE;
} else if (hash [i].obj != obj) {
return FALSE;
}
if (hash [i].count >= SGEN_CEMENT_THRESHOLD)
return TRUE;
- ++hash [i].count;
- if (hash [i].count == SGEN_CEMENT_THRESHOLD) {
+ if (InterlockedIncrement ((gint32*)&hash [i].count) == SGEN_CEMENT_THRESHOLD) {
SGEN_ASSERT (9, sgen_get_current_collection_generation () >= 0, "We can only cement objects when we're in a collection pause.");
SGEN_ASSERT (9, SGEN_OBJECT_IS_PINNED (obj), "Can only cement pinned objects");
SGEN_CEMENT_OBJECT (obj);
protocol_entry (unsigned char type, gpointer data, int size)
{
int index;
+ gboolean include_worker_index = type != PROTOCOL_ID (binary_protocol_header);
+ int entry_size = size + 1 + (include_worker_index ? 1 : 0); // type + worker_index + size
BinaryProtocolBuffer *buffer;
if (binary_protocol_file == invalid_file_value)
return;
- if (sgen_thread_pool_is_thread_pool_thread (mono_native_thread_id_get ()))
- type |= 0x80;
-
lock_recursive ();
retry:
buffer = binary_protocol_get_buffer (size + 1);
retry_same_buffer:
index = buffer->index;
- if (index + 1 + size > BINARY_PROTOCOL_BUFFER_SIZE)
+ if (index + entry_size > BINARY_PROTOCOL_BUFFER_SIZE)
goto retry;
- if (InterlockedCompareExchange (&buffer->index, index + 1 + size, index) != index)
+ if (InterlockedCompareExchange (&buffer->index, index + entry_size, index) != index)
goto retry_same_buffer;
/* FIXME: if we're interrupted at this point, we have a buffer
entry that contains random data. */
buffer->buffer [index++] = type;
+ /* We should never change the header format */
+ if (include_worker_index) {
+ /*
+ * If the thread is not a worker thread we insert 0, which is interpreted
+ * as gc thread. Worker indexes are 1 based.
+ */
+ buffer->buffer [index++] = (unsigned char) sgen_thread_pool_is_thread_pool_thread (mono_native_thread_id_get ());
+ }
memcpy (buffer->buffer + index, data, size);
index += size;
#include "sgen-gc.h"
#define PROTOCOL_HEADER_CHECK 0xde7ec7ab1ec0de
-#define PROTOCOL_HEADER_VERSION 1
+/*
+ * The version needs to be bumped every time we introduce breaking changes (like
+ * adding new protocol entries or various format changes). The latest protocol grepper
+ * should be able to handle all the previous versions, while an old grepper will
+ * be able to tell if it cannot handle the format.
+ */
+#define PROTOCOL_HEADER_VERSION 2
/* Special indices returned by MATCH_INDEX. */
#define BINARY_PROTOCOL_NO_MATCH (-1)
#define PROTOCOL_PACK_STRUCTS
#if defined(__GNUC__)
-#define PROTOCOL_STRUCT_ATTR __attribute__ ((packed))
+#define PROTOCOL_STRUCT_ATTR __attribute__ ((__packed__))
#else
#define PROTOCOL_STRUCT_ATTR
#endif
#include "mono/utils/mono-threads.h"
#endif
+#define MAX_NUM_THREADS 8
+
static mono_mutex_t lock;
static mono_cond_t work_cond;
static mono_cond_t done_cond;
-static MonoNativeThreadId thread;
+static int threads_num = 0;
+static MonoNativeThreadId threads [MAX_NUM_THREADS];
/* Only accessed with the lock held. */
static SgenPointerQueue job_queue;
static SgenThreadPoolThreadInitFunc thread_init_func;
static SgenThreadPoolIdleJobFunc idle_job_func;
static SgenThreadPoolContinueIdleJobFunc continue_idle_job_func;
+static SgenThreadPoolShouldWorkFunc should_work_func;
static volatile gboolean threadpool_shutdown;
-static volatile gboolean thread_finished;
+static volatile int threads_finished = 0;
enum {
STATE_WAITING,
}
static gboolean
-continue_idle_job (void)
+continue_idle_job (void *thread_data)
{
if (!continue_idle_job_func)
return FALSE;
- return continue_idle_job_func ();
+ return continue_idle_job_func (thread_data);
+}
+
+static gboolean
+should_work (void *thread_data)
+{
+ if (!should_work_func)
+ return TRUE;
+ return should_work_func (thread_data);
}
static mono_native_thread_return_t
mono_os_mutex_lock (&lock);
for (;;) {
+ gboolean do_idle;
+ SgenThreadPoolJob *job;
+
+ if (!should_work (thread_data)) {
+ mono_os_cond_wait (&work_cond, &lock);
+ continue;
+ }
/*
* It's important that we check the continue idle flag with the lock held.
* Suppose we didn't check with the lock held, and the result is FALSE. The
* main thread might then set continue idle and signal us before we can take
* the lock, and we'd lose the signal.
*/
- gboolean do_idle = continue_idle_job ();
- SgenThreadPoolJob *job = get_job_and_set_in_progress ();
+ do_idle = continue_idle_job (thread_data);
+ job = get_job_and_set_in_progress ();
if (!job && !do_idle && !threadpool_shutdown) {
/*
SGEN_ASSERT (0, idle_job_func, "Why do we have idle work when there's no idle job function?");
do {
idle_job_func (thread_data);
- do_idle = continue_idle_job ();
+ do_idle = continue_idle_job (thread_data);
} while (do_idle && !job_queue.next_slot);
mono_os_mutex_lock (&lock);
} else {
SGEN_ASSERT (0, threadpool_shutdown, "Why did we unlock if no jobs and not shutting down?");
mono_os_mutex_lock (&lock);
- thread_finished = TRUE;
+ threads_finished++;
mono_os_cond_signal (&done_cond);
mono_os_mutex_unlock (&lock);
return 0;
}
void
-sgen_thread_pool_init (int num_threads, SgenThreadPoolThreadInitFunc init_func, SgenThreadPoolIdleJobFunc idle_func, SgenThreadPoolContinueIdleJobFunc continue_idle_func, void **thread_datas)
+sgen_thread_pool_init (int num_threads, SgenThreadPoolThreadInitFunc init_func, SgenThreadPoolIdleJobFunc idle_func, SgenThreadPoolContinueIdleJobFunc continue_idle_func, SgenThreadPoolShouldWorkFunc should_work_func_p, void **thread_datas)
{
- SGEN_ASSERT (0, num_threads == 1, "We only support 1 thread pool thread for now.");
+ int i;
+
+ threads_num = (num_threads < MAX_NUM_THREADS) ? num_threads : MAX_NUM_THREADS;
mono_os_mutex_init (&lock);
mono_os_cond_init (&work_cond);
thread_init_func = init_func;
idle_job_func = idle_func;
continue_idle_job_func = continue_idle_func;
+ should_work_func = should_work_func_p;
- mono_native_thread_create (&thread, thread_func, thread_datas ? thread_datas [0] : NULL);
+ for (i = 0; i < threads_num; i++)
+ mono_native_thread_create (&threads [i], thread_func, thread_datas ? thread_datas [i] : NULL);
}
void
sgen_thread_pool_shutdown (void)
{
- if (!thread)
+ if (!threads_num)
return;
mono_os_mutex_lock (&lock);
threadpool_shutdown = TRUE;
- mono_os_cond_signal (&work_cond);
- while (!thread_finished)
+ mono_os_cond_broadcast (&work_cond);
+ while (threads_finished < threads_num)
mono_os_cond_wait (&done_cond, &lock);
mono_os_mutex_unlock (&lock);
mono_os_mutex_lock (&lock);
sgen_pointer_queue_add (&job_queue, job);
- /*
- * FIXME: We could check whether there is a job in progress. If there is, there's
- * no need to signal the condition, at least as long as we have only one thread.
- */
mono_os_cond_signal (&work_cond);
mono_os_mutex_unlock (&lock);
mono_os_mutex_lock (&lock);
- if (continue_idle_job_func ())
- mono_os_cond_signal (&work_cond);
+ if (continue_idle_job_func (NULL))
+ mono_os_cond_broadcast (&work_cond);
mono_os_mutex_unlock (&lock);
}
mono_os_mutex_lock (&lock);
- while (continue_idle_job_func ())
+ while (continue_idle_job_func (NULL))
mono_os_cond_wait (&done_cond, &lock);
mono_os_mutex_unlock (&lock);
mono_os_mutex_unlock (&lock);
}
-gboolean
+/* Return 0 if is not a thread pool thread or the thread number otherwise */
+int
sgen_thread_pool_is_thread_pool_thread (MonoNativeThreadId some_thread)
{
- return some_thread == thread;
+ int i;
+
+ for (i = 0; i < threads_num; i++) {
+ if (some_thread == threads [i])
+ return i + 1;
+ }
+
+ return 0;
}
#endif
typedef void (*SgenThreadPoolThreadInitFunc) (void*);
typedef void (*SgenThreadPoolIdleJobFunc) (void*);
-typedef gboolean (*SgenThreadPoolContinueIdleJobFunc) (void);
+typedef gboolean (*SgenThreadPoolContinueIdleJobFunc) (void*);
+typedef gboolean (*SgenThreadPoolShouldWorkFunc) (void*);
-void sgen_thread_pool_init (int num_threads, SgenThreadPoolThreadInitFunc init_func, SgenThreadPoolIdleJobFunc idle_func, SgenThreadPoolContinueIdleJobFunc continue_idle_func, void **thread_datas);
+void sgen_thread_pool_init (int num_threads, SgenThreadPoolThreadInitFunc init_func, SgenThreadPoolIdleJobFunc idle_func, SgenThreadPoolContinueIdleJobFunc continue_idle_func, SgenThreadPoolShouldWorkFunc should_work_func, void **thread_datas);
void sgen_thread_pool_shutdown (void);
void sgen_thread_pool_wait_for_all_jobs (void);
-gboolean sgen_thread_pool_is_thread_pool_thread (MonoNativeThreadId thread);
+int sgen_thread_pool_is_thread_pool_thread (MonoNativeThreadId thread);
#endif
#include "mono/sgen/sgen-client.h"
static int workers_num;
+static int active_workers_num;
static volatile gboolean forced_stop;
static WorkerData *workers_data;
+static SgenWorkerCallback worker_init_cb;
+
+/*
+ * When using multiple workers, we need to have the last worker
+ * enqueue the preclean jobs (if there are any). This lock ensures
+ * that when the last worker takes it, all the other workers have
+ * gracefully finished, so it can restart them.
+ */
+static mono_mutex_t finished_lock;
+static volatile gboolean workers_finished;
+static int worker_awakenings;
static SgenSectionGrayQueue workers_distribute_gray_queue;
static gboolean workers_distribute_gray_queue_inited;
*
* | from \ to | NOT WORKING | WORKING | WORK ENQUEUED |
* |--------------------+-------------+---------+---------------+
- * | NOT WORKING | - | - | main |
- * | WORKING | worker | - | main |
+ * | NOT WORKING | - | - | main / worker |
+ * | WORKING | worker | - | main / worker |
* | WORK ENQUEUED | - | worker | - |
*
* The WORK ENQUEUED state guarantees that the worker thread will inspect the queue again at
typedef gint32 State;
-static volatile State workers_state;
-
static SgenObjectOperations * volatile idle_func_object_ops;
-static SgenThreadPoolJob * volatile preclean_job;
+static SgenObjectOperations *idle_func_object_ops_par, *idle_func_object_ops_nopar;
+/*
+ * finished_callback is called only when the workers finish work normally (when they
+ * are not forced to finish). The callback is used to enqueue preclean jobs.
+ */
+static volatile SgenWorkersFinishCallback finish_callback;
static guint64 stat_workers_num_finished;
static gboolean
-set_state (State old_state, State new_state)
+set_state (WorkerData *data, State old_state, State new_state)
{
SGEN_ASSERT (0, old_state != new_state, "Why are we transitioning to the same state?");
if (new_state == STATE_NOT_WORKING)
if (new_state == STATE_NOT_WORKING || new_state == STATE_WORKING)
SGEN_ASSERT (6, sgen_thread_pool_is_thread_pool_thread (mono_native_thread_id_get ()), "Only the worker thread is allowed to transition to NOT_WORKING or WORKING");
- return InterlockedCompareExchange (&workers_state, new_state, old_state) == old_state;
+ return InterlockedCompareExchange (&data->state, new_state, old_state) == old_state;
}
static gboolean
static void
sgen_workers_ensure_awake (void)
{
- State old_state;
- gboolean did_set_state;
+ int i;
+ gboolean need_signal = FALSE;
- do {
- old_state = workers_state;
+ /*
+ * All workers are awaken, make sure we reset the parallel context.
+ * We call this function only when starting the workers so nobody is running,
+ * or when the last worker is enqueuing preclean work. In both cases we can't
+ * have a worker working using a nopar context, which means it is safe.
+ */
+ idle_func_object_ops = (active_workers_num > 1) ? idle_func_object_ops_par : idle_func_object_ops_nopar;
+ workers_finished = FALSE;
- if (old_state == STATE_WORK_ENQUEUED)
- break;
+ for (i = 0; i < active_workers_num; i++) {
+ State old_state;
+ gboolean did_set_state;
+
+ do {
+ old_state = workers_data [i].state;
+
+ if (old_state == STATE_WORK_ENQUEUED)
+ break;
- did_set_state = set_state (old_state, STATE_WORK_ENQUEUED);
- } while (!did_set_state);
+ did_set_state = set_state (&workers_data [i], old_state, STATE_WORK_ENQUEUED);
+ } while (!did_set_state);
- if (!state_is_working_or_enqueued (old_state))
+ if (!state_is_working_or_enqueued (old_state))
+ need_signal = TRUE;
+ }
+
+ if (need_signal)
sgen_thread_pool_idle_signal ();
}
worker_try_finish (WorkerData *data)
{
State old_state;
+ int i, working = 0;
++stat_workers_num_finished;
+ mono_os_mutex_lock (&finished_lock);
+
+ for (i = 0; i < active_workers_num; i++) {
+ if (state_is_working_or_enqueued (workers_data [i].state))
+ working++;
+ }
+
+ if (working == 1) {
+ SgenWorkersFinishCallback callback = finish_callback;
+ SGEN_ASSERT (0, idle_func_object_ops == idle_func_object_ops_nopar, "Why are we finishing with parallel context");
+ /* We are the last one left. Enqueue preclean job if we have one and awake everybody */
+ SGEN_ASSERT (0, data->state != STATE_NOT_WORKING, "How did we get from doing idle work to NOT WORKING without setting it ourselves?");
+ if (callback) {
+ finish_callback = NULL;
+ callback ();
+ worker_awakenings = 0;
+ /* Make sure each worker has a chance of seeing the enqueued jobs */
+ sgen_workers_ensure_awake ();
+ SGEN_ASSERT (0, data->state == STATE_WORK_ENQUEUED, "Why did we fail to set our own state to ENQUEUED");
+ goto work_available;
+ }
+ }
+
do {
- old_state = workers_state;
+ old_state = data->state;
SGEN_ASSERT (0, old_state != STATE_NOT_WORKING, "How did we get from doing idle work to NOT WORKING without setting it ourselves?");
if (old_state == STATE_WORK_ENQUEUED)
- return;
+ goto work_available;
SGEN_ASSERT (0, old_state == STATE_WORKING, "What other possibility is there?");
+ } while (!set_state (data, old_state, STATE_NOT_WORKING));
- /* We are the last thread to go to sleep. */
- } while (!set_state (old_state, STATE_NOT_WORKING));
+ /*
+ * If we are second to last to finish, we set the scan context to the non-parallel
+ * version so we can speed up the last worker. This helps us maintain same level
+ * of performance as non-parallel mode even if we fail to distribute work properly.
+ */
+ if (working == 2)
+ idle_func_object_ops = idle_func_object_ops_nopar;
+
+ workers_finished = TRUE;
+ mono_os_mutex_unlock (&finished_lock);
binary_protocol_worker_finish (sgen_timestamp (), forced_stop);
sgen_gray_object_queue_trim_free_list (&data->private_gray_queue);
+ return;
+
+work_available:
+ mono_os_mutex_unlock (&finished_lock);
}
void
sgen_thread_pool_job_enqueue (job);
}
-void
-sgen_workers_wait_for_jobs_finished (void)
-{
- sgen_thread_pool_wait_for_all_jobs ();
- /*
- * If the idle task was never triggered or it finished before the last job did and
- * then didn't get triggered again, we might end up in the situation of having
- * something in the gray queue yet the idle task not working. The easiest way to
- * make sure this doesn't stay that way is to just trigger it again after all jobs
- * have finished.
- */
- sgen_workers_ensure_awake ();
-}
-
static gboolean
workers_get_work (WorkerData *data)
{
if (major->is_concurrent) {
GrayQueueSection *section = sgen_section_gray_queue_dequeue (&workers_distribute_gray_queue);
if (section) {
- sgen_gray_object_enqueue_section (&data->private_gray_queue, section);
+ sgen_gray_object_enqueue_section (&data->private_gray_queue, section, major->is_parallel);
return TRUE;
}
}
return FALSE;
}
+static gboolean
+workers_steal_work (WorkerData *data)
+{
+ SgenMajorCollector *major = sgen_get_major_collector ();
+ GrayQueueSection *section = NULL;
+ int i, current_worker;
+
+ if (!major->is_parallel)
+ return FALSE;
+
+ /* If we're parallel, steal from other workers' private gray queues */
+ g_assert (sgen_gray_object_queue_is_empty (&data->private_gray_queue));
+
+ current_worker = (int) (data - workers_data);
+
+ for (i = 1; i < active_workers_num && !section; i++) {
+ int steal_worker = (current_worker + i) % active_workers_num;
+ if (state_is_working_or_enqueued (workers_data [steal_worker].state))
+ section = sgen_gray_object_steal_section (&workers_data [steal_worker].private_gray_queue);
+ }
+
+ if (section) {
+ sgen_gray_object_enqueue_section (&data->private_gray_queue, section, TRUE);
+ return TRUE;
+ }
+
+ /* Nobody to steal from */
+ g_assert (sgen_gray_object_queue_is_empty (&data->private_gray_queue));
+ return FALSE;
+}
+
static void
concurrent_enqueue_check (GCObject *obj)
{
return;
init_private_gray_queue (data);
+
+ if (worker_init_cb)
+ worker_init_cb (data);
+}
+
+static gboolean
+continue_idle_func (void *data_untyped)
+{
+ if (data_untyped) {
+ WorkerData *data = (WorkerData *)data_untyped;
+ return state_is_working_or_enqueued (data->state);
+ } else {
+ /* Return if any of the threads is working */
+ return !sgen_workers_all_done ();
+ }
}
static gboolean
-continue_idle_func (void)
+should_work_func (void *data_untyped)
{
- return state_is_working_or_enqueued (workers_state);
+ WorkerData *data = (WorkerData*)data_untyped;
+ int current_worker = (int) (data - workers_data);
+
+ return current_worker < active_workers_num;
}
static void
{
WorkerData *data = (WorkerData *)data_untyped;
- SGEN_ASSERT (0, continue_idle_func (), "Why are we called when we're not supposed to work?");
+ SGEN_ASSERT (0, continue_idle_func (data_untyped), "Why are we called when we're not supposed to work?");
SGEN_ASSERT (0, sgen_concurrent_collection_in_progress (), "The worker should only mark in concurrent collections.");
- if (workers_state == STATE_WORK_ENQUEUED) {
- set_state (STATE_WORK_ENQUEUED, STATE_WORKING);
- SGEN_ASSERT (0, workers_state != STATE_NOT_WORKING, "How did we get from WORK ENQUEUED to NOT WORKING?");
+ if (data->state == STATE_WORK_ENQUEUED) {
+ set_state (data, STATE_WORK_ENQUEUED, STATE_WORKING);
+ SGEN_ASSERT (0, data->state != STATE_NOT_WORKING, "How did we get from WORK ENQUEUED to NOT WORKING?");
}
- if (!forced_stop && (!sgen_gray_object_queue_is_empty (&data->private_gray_queue) || workers_get_work (data))) {
+ if (!forced_stop && (!sgen_gray_object_queue_is_empty (&data->private_gray_queue) || workers_get_work (data) || workers_steal_work (data))) {
ScanCopyContext ctx = CONTEXT_FROM_OBJECT_OPERATIONS (idle_func_object_ops, &data->private_gray_queue);
SGEN_ASSERT (0, !sgen_gray_object_queue_is_empty (&data->private_gray_queue), "How is our gray queue empty if we just got work?");
sgen_drain_gray_stack (ctx);
- } else {
- SgenThreadPoolJob *job = preclean_job;
- if (job) {
- sgen_thread_pool_job_enqueue (job);
- preclean_job = NULL;
- } else {
- worker_try_finish (data);
+
+ if (data->private_gray_queue.num_sections > 16 && workers_finished && worker_awakenings < active_workers_num) {
+ /* We bound the number of worker awakenings just to be sure */
+ worker_awakenings++;
+ sgen_workers_ensure_awake ();
}
+ } else {
+ worker_try_finish (data);
}
}
}
void
-sgen_workers_init (int num_workers)
+sgen_workers_init (int num_workers, SgenWorkerCallback callback)
{
int i;
void **workers_data_ptrs = (void **)alloca(num_workers * sizeof(void *));
if (!sgen_get_major_collector ()->is_concurrent) {
- sgen_thread_pool_init (num_workers, thread_pool_init_func, NULL, NULL, NULL);
+ sgen_thread_pool_init (num_workers, thread_pool_init_func, NULL, NULL, NULL, NULL);
return;
}
+ mono_os_mutex_init (&finished_lock);
//g_print ("initing %d workers\n", num_workers);
workers_num = num_workers;
+ active_workers_num = num_workers;
workers_data = (WorkerData *)sgen_alloc_internal_dynamic (sizeof (WorkerData) * num_workers, INTERNAL_MEM_WORKER_DATA, TRUE);
memset (workers_data, 0, sizeof (WorkerData) * num_workers);
init_distribute_gray_queue ();
- for (i = 0; i < workers_num; ++i)
+ for (i = 0; i < num_workers; ++i)
workers_data_ptrs [i] = (void *) &workers_data [i];
- sgen_thread_pool_init (num_workers, thread_pool_init_func, marker_idle_func, continue_idle_func, workers_data_ptrs);
+ worker_init_cb = callback;
+
+ sgen_thread_pool_init (num_workers, thread_pool_init_func, marker_idle_func, continue_idle_func, should_work_func, workers_data_ptrs);
mono_counters_register ("# workers finished", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_workers_num_finished);
}
void
sgen_workers_stop_all_workers (void)
{
- preclean_job = NULL;
+ finish_callback = NULL;
mono_memory_write_barrier ();
forced_stop = TRUE;
sgen_thread_pool_wait_for_all_jobs ();
sgen_thread_pool_idle_wait ();
- SGEN_ASSERT (0, workers_state == STATE_NOT_WORKING, "Can only signal enqueue work when in no work state");
+ SGEN_ASSERT (0, sgen_workers_all_done (), "Can only signal enqueue work when in no work state");
+}
+
+void
+sgen_workers_set_num_active_workers (int num_workers)
+{
+ if (num_workers) {
+ SGEN_ASSERT (0, active_workers_num <= workers_num, "We can't start more workers than we initialized");
+ active_workers_num = num_workers;
+ } else {
+ active_workers_num = workers_num;
+ }
}
void
-sgen_workers_start_all_workers (SgenObjectOperations *object_ops, SgenThreadPoolJob *job)
+sgen_workers_start_all_workers (SgenObjectOperations *object_ops_nopar, SgenObjectOperations *object_ops_par, SgenWorkersFinishCallback callback)
{
+ idle_func_object_ops_par = object_ops_par;
+ idle_func_object_ops_nopar = object_ops_nopar;
forced_stop = FALSE;
- idle_func_object_ops = object_ops;
- preclean_job = job;
+ finish_callback = callback;
+ worker_awakenings = 0;
mono_memory_write_barrier ();
sgen_workers_ensure_awake ();
sgen_thread_pool_wait_for_all_jobs ();
sgen_thread_pool_idle_wait ();
- SGEN_ASSERT (0, workers_state == STATE_NOT_WORKING, "Can only signal enqueue work when in no work state");
+ SGEN_ASSERT (0, sgen_workers_all_done (), "Can only signal enqueue work when in no work state");
/* At this point all the workers have stopped. */
SGEN_ASSERT (0, sgen_section_gray_queue_is_empty (&workers_distribute_gray_queue), "Why is there still work left to do?");
- for (i = 0; i < workers_num; ++i)
+ for (i = 0; i < active_workers_num; ++i)
SGEN_ASSERT (0, sgen_gray_object_queue_is_empty (&workers_data [i].private_gray_queue), "Why is there still work left to do?");
}
if (!sgen_section_gray_queue_is_empty (&workers_distribute_gray_queue))
return TRUE;
- for (i = 0; i < workers_num; ++i) {
+ for (i = 0; i < active_workers_num; ++i) {
if (!sgen_gray_object_queue_is_empty (&workers_data [i].private_gray_queue))
return TRUE;
}
gboolean
sgen_workers_all_done (void)
{
- return workers_state == STATE_NOT_WORKING;
+ int i;
+
+ for (i = 0; i < active_workers_num; i++) {
+ if (state_is_working_or_enqueued (workers_data [i].state))
+ return FALSE;
+ }
+ return TRUE;
}
/* Must only be used for debugging */
gboolean
sgen_workers_are_working (void)
{
- return state_is_working_or_enqueued (workers_state);
+ return !sgen_workers_all_done ();
}
void
}
void
-sgen_workers_take_from_queue_and_awake (SgenGrayQueue *queue)
+sgen_workers_take_from_queue (SgenGrayQueue *queue)
{
- gboolean wake = FALSE;
+ sgen_gray_object_spread (queue, sgen_workers_get_job_split_count ());
for (;;) {
GrayQueueSection *section = sgen_gray_object_dequeue_section (queue);
if (!section)
break;
sgen_section_gray_queue_enqueue (&workers_distribute_gray_queue, section);
- wake = TRUE;
}
- if (wake) {
- SGEN_ASSERT (0, sgen_concurrent_collection_in_progress (), "Why is there work to take when there's no concurrent collection in progress?");
- sgen_workers_ensure_awake ();
- }
+ SGEN_ASSERT (0, !sgen_workers_are_working (), "We should fully populate the distribute gray queue before we start the workers");
+}
+
+SgenObjectOperations*
+sgen_workers_get_idle_func_object_ops (void)
+{
+ return (idle_func_object_ops_par) ? idle_func_object_ops_par : idle_func_object_ops_nopar;
+}
+
+/*
+ * If we have a single worker, splitting into multiple jobs makes no sense. With
+ * more than one worker, we split into a larger number of jobs so that, in case
+ * the work load is uneven, a worker that finished quickly can take up more jobs
+ * than another one.
+ */
+int
+sgen_workers_get_job_split_count (void)
+{
+ return (active_workers_num > 1) ? active_workers_num * 4 : 1;
+}
+
+void
+sgen_workers_foreach (SgenWorkerCallback callback)
+{
+ int i;
+
+ for (i = 0; i < workers_num; i++)
+ callback (&workers_data [i]);
}
#endif
typedef struct _WorkerData WorkerData;
struct _WorkerData {
+ gint32 state;
SgenGrayQueue private_gray_queue; /* only read/written by worker thread */
+ /*
+ * Workers allocate major objects only from here. It has same structure as the
+ * global one. This is normally accessed from the worker_block_free_list_key.
+ * We hold it here so we can clear free lists from all threads before sweep
+ * starts.
+ */
+ gpointer free_block_lists;
};
-void sgen_workers_init (int num_workers);
+typedef void (*SgenWorkersFinishCallback) (void);
+typedef void (*SgenWorkerCallback) (WorkerData *data);
+
+void sgen_workers_init (int num_workers, SgenWorkerCallback callback);
void sgen_workers_stop_all_workers (void);
-void sgen_workers_start_all_workers (SgenObjectOperations *object_ops, SgenThreadPoolJob *finish_job);
+void sgen_workers_set_num_active_workers (int num_workers);
+void sgen_workers_start_all_workers (SgenObjectOperations *object_ops_nopar, SgenObjectOperations *object_ops_par, SgenWorkersFinishCallback finish_job);
void sgen_workers_init_distribute_gray_queue (void);
void sgen_workers_enqueue_job (SgenThreadPoolJob *job, gboolean enqueue);
-void sgen_workers_wait_for_jobs_finished (void);
void sgen_workers_distribute_gray_queue_sections (void);
void sgen_workers_reset_data (void);
void sgen_workers_join (void);
gboolean sgen_workers_all_done (void);
gboolean sgen_workers_are_working (void);
void sgen_workers_assert_gray_queue_is_empty (void);
-void sgen_workers_take_from_queue_and_awake (SgenGrayQueue *queue);
+void sgen_workers_take_from_queue (SgenGrayQueue *queue);
+SgenObjectOperations* sgen_workers_get_idle_func_object_ops (void);
+int sgen_workers_get_job_split_count (void);
+void sgen_workers_foreach (SgenWorkerCallback callback);
#endif
SUBDIRS = assemblyresolve gc-descriptors
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
FEATUREFUL_RUNTIME_TEST =
else
FEATUREFUL_RUNTIME_TEST = test-appdomain-unload
PKG_CONFIG_PATH=$(top_builddir):$(PKG_CONFIG_PATH) \
$(RUNTIME) $(CLASS)/mkbundle.exe
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
PROFILE_MCS_FLAGS = -d:MOBILE,MOBILE_LEGACY,FULL_AOT_DESKTOP
endif
-if INSTALL_TESTING_AOT_HYBRID
+if HYBRID_AOT_TESTS
PROFILE_MCS_FLAGS = -d:MOBILE,MOBILE_LEGACY
endif
ILASM = $(TOOLS_RUNTIME) $(mcs_topdir)/class/lib/build/ilasm.exe
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
TEST_RUNNER = ./test-runner.exe --runtime $(top_builddir)/runtime/mono-wrapper --mono-path "$(CLASS)" --aot-run-flags "$(AOT_RUN_FLAGS)" --aot-build-flags "$(AOT_BUILD_FLAGS)"
else
TEST_RUNNER = ./test-runner.exe --runtime $(top_builddir)/runtime/mono-wrapper --mono-path "$(CLASS)"
PROFILE_DISABLED_TESTS=
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
# Tests which rely on TypeLoadExceptions
# In full-aot mode, these cause the relevant methods to be not AOTed.
PROFILE_DISABLED_TESTS += \
PROFILE_DISABLED_TESTS += \
thread6.exe
+# can't AOT the TestingReferenceAssembly.dll which is a dependency
+# of reference-loader.exe because it contains the [ReferenceAssemblyAttribute]
+# and the runtime errors out with "File does not contain a valid CIL image."
+PROFILE_DISABLED_TESTS += \
+ reference-loader.exe
+
# constraints-load.il:
# Failed to load method 0x6000007 from '..../mono/tests/constraints-load.exe' due to
# Could not resolve type with token 01000002 assembly:mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 type:System.BrokenIComparable`1 member:<none>.
bug-515884.exe
endif
-if INSTALL_TESTING_AOT_HYBRID
+if HYBRID_AOT_TESTS
PROFILE_DISABLED_TESTS += \
bug-80307.exe \
namedmutex-destroy-race.exe
PREREQ_IL_SRC=event-il.il module-cctor.il
PREREQ_CS_SRC=
PREREQ_IL_DLL_SRC=
-PREREQ_CS_DLL_SRC=TestingReferenceAssembly.cs TestingReferenceReferenceAssembly.cs
+PREREQ_CS_DLL_SRC=
PREREQSI_IL=$(PREREQ_IL_SRC:.il=.exe) \
$(PREREQ_IL_DLL_SRC:.il=.dll)
%.exe: %.il
$(ILASM) -out:$@ $<
-if !INSTALL_TESTING_AOT_FULL
-if !INSTALL_TESTING_AOT_HYBRID
+if !FULL_AOT_TESTS
+if !HYBRID_AOT_TESTS
TEST_DRIVER_HARD_KILL_FEATURE=-r:Mono.Posix.dll
endif
endif
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
TEST_DRIVER_DEPEND=TestDriver.dll$(PLATFORM_AOT_SUFFIX)
else
TEST_DRIVER_DEPEND=TestDriver.dll
%.dll: %.cs
$(MCS) -r:System.dll -target:library -out:$@ $<
+reference-loader.exe: reference-loader.cs TestingReferenceAssembly.dll TestingReferenceReferenceAssembly.dll $(TEST_DRIVER_DEPEND)
+ $(MCS) -r:System.dll -r:TestDriver.dll -r:TestingReferenceAssembly.dll -r:TestingReferenceReferenceAssembly.dll $(TEST_DRIVER_HARD_KILL_FEATURE) -out:$@ reference-loader.cs
+
+TestingReferenceAssembly.dll: TestingReferenceAssembly.cs
+ $(MCS) -target:library -out:$@ $<
+
TestingReferenceReferenceAssembly.dll: TestingReferenceReferenceAssembly.cs TestingReferenceAssembly.dll
$(MCS) -r:TestingReferenceAssembly.dll -target:library -out:$@ $<
bug-36848-a.dll$(PLATFORM_AOT_SUFFIX) \
bug-81691-b.dll$(PLATFORM_AOT_SUFFIX) \
bug-327438.2.exe$(PLATFORM_AOT_SUFFIX) \
-bug-81466-lib.dll$(PLATFORM_AOT_SUFFIX) \
-TestingReferenceAssembly.dll$(PLATFORM_AOT_SUFFIX) \
-TestingReferenceReferenceAssembly.dll$(PLATFORM_AOT_SUFFIX)
+bug-81466-lib.dll$(PLATFORM_AOT_SUFFIX)
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
prereqs: $(PREREQSI_IL_AOT) $(PREREQSI_CS_AOT) $(AOT_EXTRA_LIBS)
else
prereqs: $(PREREQSI_IL) $(PREREQSI_CS)
# Precompile the test assemblies in parallel
compile-tests:
$(MAKE) -j4 $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la $(PREREQSI_IL) $(PREREQSI_CS)
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
$(MAKE) $(PREREQSI_IL_AOT) $(PREREQSI_CS_AOT) $(AOT_EXTRA_LIBS)
endif
SGEN_REGULAR_DISABLED_TESTS=
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
SGEN_REGULAR_DISABLED_TESTS += \
sgen-domain-unload.exe \
sgen-domain-unload-2.exe
sgen-regular-tests: $(SGEN_REGULAR_TESTS)
$(MAKE) sgen-regular-tests-ms
$(MAKE) sgen-regular-tests-ms-conc
+ $(MAKE) sgen-regular-tests-ms-conc-par
$(MAKE) sgen-regular-tests-ms-conc-split
$(MAKE) sgen-regular-tests-ms-split
$(MAKE) sgen-regular-tests-ms-conc-split-95
MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="major=marksweep" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --disabled "$(DISABLED_TESTS)" --timeout 900 $(SGEN_REGULAR_TESTS)
sgen-regular-tests-ms-conc: $(SGEN_REGULAR_TESTS) test-runner.exe
MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="major=marksweep-conc" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --disabled "$(DISABLED_TESTS)" --timeout 900 $(SGEN_REGULAR_TESTS)
+sgen-regular-tests-ms-conc-par: $(SGEN_REGULAR_TESTS) test-runner.exe
+ MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="major=marksweep-conc-par" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --disabled "$(DISABLED_TESTS)" --timeout 900 $(SGEN_REGULAR_TESTS)
sgen-regular-tests-ms-conc-split: $(SGEN_REGULAR_TESTS) test-runner.exe
MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="major=marksweep-conc,minor=split" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --disabled "$(DISABLED_TESTS)" --timeout 900 $(SGEN_REGULAR_TESTS)
sgen-regular-tests-ms-split: $(SGEN_REGULAR_TESTS) test-runner.exe
EXTRA_DIST += test-inline-call-stack-library.cs test-inline-call-stack.cs
test-inline-call-stack-library.dll: $(TEST_DRIVER_DEPEND) $(srcdir)/test-inline-call-stack-library.cs
$(MCS) -t:library -out:test-inline-call-stack-library.dll $(srcdir)/test-inline-call-stack-library.cs
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
$(RUNTIME) $(AOT_BUILD_FLAGS) $@
endif
$(MCS) -target:library -out:bug-81673-interface.dll $(srcdir)/bug-81673-interface.cs
$(MCS) -out:bug-81673.exe -r:bug-81673-interface.dll $(srcdir)/bug-81673.cs
$(MCS) -define:WITH_STOP -target:library -out:bug-81673-interface.dll $(srcdir)/bug-81673-interface.cs
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
$(RUNTIME) $(AOT_BUILD_FLAGS) $@
endif
$(MCS) -target:library -out:bug-36848-a.dll $(srcdir)/bug-36848-a.cs
$(MCS) -r:bug-36848-a.dll -out:bug-36848.exe $(srcdir)/bug-36848.cs
$(MCS) -target:library -out:bug-36848-a.dll $(srcdir)/bug-36848-a.cs /define:WITH_STOP
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
$(RUNTIME) $(AOT_BUILD_FLAGS) $@
endif
EXTRA_DIST += bug-81466-lib.il
bug-81466-lib.dll: bug-81466-lib.il
$(ILASM) /dll /output:bug-81466-lib.dll $(srcdir)/bug-81466-lib.il
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
$(RUNTIME) $(AOT_BUILD_FLAGS) $@
endif
bug-81466.exe: bug-81466.il bug-81466-lib.dll
EXTRA_DIST += bug-324535-il.il
bug-324535-il.dll : bug-324535-il.il
$(ILASM) /dll /output:bug-324535-il.dll $(srcdir)/bug-324535-il.il
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
$(RUNTIME) $(AOT_BUILD_FLAGS) $@
endif
bug-324535.exe : bug-324535.cs bug-324535-il.dll
EXTRA_DIST += custom-modifiers.2.cs custom-modifiers-lib.il
custom-modifiers-lib.dll: custom-modifiers-lib.il
$(ILASM) /dll /output:custom-modifiers-lib.dll $(srcdir)/custom-modifiers-lib.il
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
$(RUNTIME) $(AOT_BUILD_FLAGS) $@
endif
custom-modifiers.2.exe: custom-modifiers.2.cs custom-modifiers-lib.dll
EXTRA_DIST += bug-382986-lib.cs
bug-382986-lib.dll: bug-382986-lib.cs
$(MCS) -target:library -out:$@ $(srcdir)/bug-382986-lib.cs
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
$(RUNTIME) $(AOT_BUILD_FLAGS) $@
endif
EXTRA_DIST += generic-unboxing.2.il
generic-unboxing.2.dll : generic-unboxing.2.il
$(ILASM) /dll /output:generic-unboxing.2.dll $(srcdir)/generic-unboxing.2.il
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
$(RUNTIME) $(AOT_BUILD_FLAGS) $@
endif
EXTRA_DIST += generic-boxing.2.il
generic-boxing.2.dll : generic-boxing.2.il generic-unboxing.2.dll
$(ILASM) /dll /output:generic-boxing.2.dll $(srcdir)/generic-boxing.2.il
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
$(RUNTIME) $(AOT_BUILD_FLAGS) $@
endif
EXTRA_DIST += generic-delegate2.2.cs generic-delegate2-lib.2.il
generic-delegate2-lib.2.dll : generic-delegate2-lib.2.il
$(ILASM) /dll /output:$@ $(srcdir)/generic-delegate2-lib.2.il
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
$(RUNTIME) $(AOT_BUILD_FLAGS) $@
endif
generic-delegate2.2.exe : generic-delegate2.2.cs generic-delegate2-lib.2.dll
GSHARED_DISABLED_TESTS=
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
GSHARED_DISABLED_TESTS += \
generic-type-builder.2.exe
endif
if (!StaticConstructor1.gotToEnd) /* the TAE must not land during a .cctor */
Environment.Exit (1);
if (StaticConstructor1.caughtException)
- Environment.Exit (1);
+ Environment.Exit (2);
}
Console.WriteLine ("StaticConstructor1 is viable"); /* a TAE doesn't make a type unusable */
} catch (TypeInitializationException e) {
Console.WriteLine ("StaticConstructor1 not viable");
- Environment.Exit (1);
+ Environment.Exit (3);
}
}
if (Driver.mre2.WaitOne (500)) {
/* We shouldn't reach Driver.mre.Set () in StaticConstructor2.cctor */
- Environment.Exit (1);
+ Environment.Exit (4);
}
thread.Join ();
IsStaticConstructor2Viable ();
Console.WriteLine ("StaticConstructor2 is viable");
/* A regular exception escaping the .cctor makes the type not usable */
- Environment.Exit (1);
+ Environment.Exit (5);
} catch (TypeInitializationException e) {
Console.WriteLine ("StaticConstructor2 not viable");
}
/* Unreachable */
Driver.mre2.Set ();
Console.WriteLine ("StaticConstructor3.StaticConstructor3 (2)");
- Environment.Exit (1);
+ Environment.Exit (6);
}
public static void Init ()
StaticConstructor3.Init ();
Console.WriteLine ("cctor3 didn't throw?!?!");
/* StaticConstructor3 self aborted */
- Environment.Exit (1);
+ Environment.Exit (7);
} catch (ThreadAbortException e) {
Console.WriteLine ("TEST 3: aborted {0}", e);
}
IsStaticConstructor3Viable ();
Console.WriteLine ("StaticConstructor3 is viable");
/* A regular exception escaping the .cctor makes the type not usable */
- Environment.Exit (1);
+ Environment.Exit (8);
} catch (TypeInitializationException e) {
Console.WriteLine ("StaticConstructor3 not viable");
}
new StaticConstructor4 ();
Console.WriteLine ("IsStaticConstructor4Viable: Did it get to the end? {0} Did it catch an exception {1} and end of the finally block {2}", StaticConstructor4.gotToEnd, StaticConstructor4.caughtException, got_to_the_end_of_the_finally);
if (!StaticConstructor4.gotToEnd) /* the TAE must not land during a .cctor */
- Environment.Exit (1);
+ Environment.Exit (9);
if (StaticConstructor4.caughtException)
- Environment.Exit (1);
+ Environment.Exit (10);
}
static void Test4 ()
if (!got_to_the_end_of_the_finally) {
Console.WriteLine ("Did not get to the end of test 4 cctor");
- Environment.Exit (1);
+ Environment.Exit (11);
}
//is StaticConstructor4viable?
Console.WriteLine ("StaticConstructor4 is viable"); /* a TAE doesn't make a type unusable */
} catch (TypeInitializationException e) {
Console.WriteLine ("StaticConstructor4 not viable");
- Environment.Exit (1);
+ Environment.Exit (12);
}
}
+CLASS=$(mcs_topdir)/class/lib/$(DEFAULT_PROFILE)
RUNTIME = $(top_builddir)/runtime/mono-wrapper --debug
-MCS = MONO_PATH=$(mcs_topdir)/class/lib/build $(RUNTIME) $(CSC) -noconfig -nologo -debug:portable -target:library
+TOOLS_RUNTIME = MONO_PATH=$(mcs_topdir)/class/lib/build $(RUNTIME)
-if INSTALL_TESTING_AOT_FULL
-prereq: aot
+MCS = $(TOOLS_RUNTIME) $(CSC) -noconfig -nologo -debug:portable -target:library
+
+if FULL_AOT_TESTS
+prereq: test/asm.dll$(PLATFORM_AOT_SUFFIX)
else
prereq: test/asm.dll
endif
EXTRA_DIST = asm.cs Test.cs TestBase.cs
clean:
- rm -f deps/*.dll test/*.dll
+ rm -rf deps/ test/
-.PHONY: aot
-aot: test/asm.dll
+if FULL_AOT_TESTS
+test/asm.dll$(PLATFORM_AOT_SUFFIX): test/asm.dll
MONO_PATH="deps:$(CLASS)" $(RUNTIME) $(AOT_BUILD_FLAGS) deps/test.dll
MONO_PATH="deps:$(CLASS)" $(RUNTIME) $(AOT_BUILD_FLAGS) deps/TestBase.dll
MONO_PATH="deps:$(CLASS)" $(RUNTIME) $(AOT_BUILD_FLAGS) test/asm.dll
-
+endif
using System;
using System.Linq;
+using System.Runtime.CompilerServices;
class C
{
throw new Exception (String.Format("Exception carried {0} frames along with it when it should have reported four.", frames));
}
+ try {
+ new C ().M1a ();
+ } catch (Exception ex) {
+ int frames = FrameCount (ex);
+ if (frames != 4)
+ throw new Exception (String.Format("Exception carried {0} frames along with it when it should have reported four.", frames));
+ }
+
+ try {
+ new C ().M1b ();
+ } catch (Exception ex) {
+ int frames = FrameCount (ex);
+ if (frames != 3)
+ throw new Exception (String.Format("Exception carried {0} frames along with it when it should have reported three.", frames));
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private void M1a ()
+ {
+ M2a ();
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private void M1b ()
+ {
+ M2b ();
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private void M2a ()
+ {
+ try {
+ M3 ();
+ } catch {
+ throw;
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private void M2b ()
+ {
+ try {
+ M3 ();
+ } catch (Exception ex) {
+ throw ex;
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private void M3 ()
+ {
+ throw new NotImplementedException ();
}
}
CLASS=$(mcs_topdir)/class/lib/$(DEFAULT_PROFILE)
-with_mono_path = MONO_PATH=$(CLASS)
-RUNTIME = $(with_mono_path) $(top_builddir)/runtime/mono-wrapper
-MCS = $(RUNTIME) $(CSC) -unsafe -nowarn:0162 -nowarn:0168 -nowarn:0219 -debug:portable
+TOOLS_RUNTIME = MONO_PATH=$(mcs_topdir)/class/lib/build $(top_builddir)/runtime/mono-wrapper
+MCS = $(TOOLS_RUNTIME) $(CSC) -lib:$(CLASS) -noconfig -unsafe -nowarn:0162 -nowarn:0168 -nowarn:0219 -debug:portable
+
+if INSTALL_TESTING_AOT_FULL
+
+check-local:
+
+else
check-local: test
if [ "$(srcdir)" != "$(builddir)" ]; then cp $^ .; fi
$(srcdir)/gen-descriptor-tests.py >descriptor-tests.cs
+endif
+
EXTRA_DIST = descriptor-tests-driver.cs descriptor-tests-prefix.cs gen-descriptor-tests.py
.DELETE_ON_ERROR:
#if defined(WIN32) && defined (_MSC_VER)
#define LIBTEST_API __declspec(dllexport)
#elif defined(__GNUC__)
-#define LIBTEST_API __attribute__ ((visibility ("default")))
+#define LIBTEST_API __attribute__ ((__visibility__ ("default")))
#else
#define LIBTEST_API
#endif
if (strcmp (s, "ABCD") != 0)
return 1;
- strncpy(s, m, n);
+ memcpy(s, m, n);
s [n] = '\0';
return 0;
}
{
const char m[] = "This is my message. Isn't it nice?";
- strncpy(s, m, n);
+ memcpy(s, m, n);
s [n] = '\0';
return 0;
}
*/
#if defined(__GNUC__) && ((defined(__i386__) && (defined(__linux__) || defined (__APPLE__)) || defined (__FreeBSD__) || defined(__OpenBSD__)) || (defined(__ppc__) && defined(__APPLE__)))
-#define ALIGN(size) __attribute__ ((aligned(size)))
+#define ALIGN(size) __attribute__ ((__aligned__(size)))
#else
#define ALIGN(size)
#endif
size_t strLength = strlen(pReturn);
ret = (char *)(marshal_alloc (sizeof(char)* (strLength + 1)));
- memset(ret, '\0', strLength + 1);
- strncpy(ret, pReturn, strLength);
+ memcpy(ret, pReturn, strLength);
+ ret [strLength] = '\0';
return ret;
}
noinst_LTLIBRARIES = libtestlib.la
libtestlib_la_SOURCES =
-libtestlib_la_LIBADD = ../metadata/libmonoruntimesgen.la ../sgen/libmonosgen.la ../utils/libmonoutils.la ../io-layer/libwapi.la
+libtestlib_la_LIBADD = ../metadata/libmonoruntimesgen.la ../sgen/libmonosgen.la ../utils/libmonoutils.la
test_sgen_qsort_SOURCES = test-sgen-qsort.c
test_sgen_qsort_CFLAGS = $(test_cflags)
}
}
+ free (random_mem);
+ free (reference);
+ free (playground);
+
return 0;
}
mono-signal-handler.h \
mono-conc-hashtable.h \
mono-conc-hashtable.c \
- sha1.h \
- sha1.c \
json.h \
json.c \
networking.c \
checked-build.c \
checked-build.h \
os-event.h \
- refcount.h
+ refcount.h \
+ w32api.h
arch_sources =
* so we have to roll our own...
*/
-gint64 InterlockedCompareExchange64(volatile gint64 *dest, gint64 exch, gint64 comp) __attribute__ ((naked));
+gint64 InterlockedCompareExchange64(volatile gint64 *dest, gint64 exch, gint64 comp) __attribute__ ((__naked__));
gint64
InterlockedCompareExchange64(volatile gint64 *dest, gint64 exch, gint64 comp)
#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-threads.h>
#include <mono/utils/mono-counters.h>
-#include <mono/io-layer/io-layer.h>
#endif
typedef struct {
#include "mono-mmap.h"
#include "mono-counters.h"
#include "dlmalloc.h"
-#include <mono/io-layer/io-layer.h>
#include <mono/metadata/profiler-private.h>
#ifdef HAVE_VALGRIND_MEMCHECK_H
#include <valgrind/memcheck.h>
#include <config.h>
#ifdef __GNUC__
-#define MONO_ATTR_USED __attribute__ ((used))
+#define MONO_ATTR_USED __attribute__ ((__used__))
#else
#define MONO_ATTR_USED
#endif
#ifdef __GNUC__
-#define MONO_ATTR_FORMAT_PRINTF(fmt_pos,arg_pos) __attribute__((format(printf,fmt_pos,arg_pos)))
+#define MONO_ATTR_FORMAT_PRINTF(fmt_pos,arg_pos) __attribute__ ((__format__(__printf__,fmt_pos,arg_pos)))
#else
#define MONO_ATTR_FORMAT_PRINTF(fmt_pos,arg_pos)
#endif
#define MONO_PROFILER_API MONO_API
#ifdef __GNUC__
-#define MONO_ALWAYS_INLINE __attribute__((always_inline))
+#define MONO_ALWAYS_INLINE __attribute__ ((__always_inline__))
#elif defined(_MSC_VER)
#define MONO_ALWAYS_INLINE __forceinline
#else
#endif
#ifdef __GNUC__
-#define MONO_NEVER_INLINE __attribute__((noinline))
+#define MONO_NEVER_INLINE __attribute__ ((__noinline__))
#elif defined(_MSC_VER)
#define MONO_NEVER_INLINE __declspec(noinline)
#else
#endif
#ifdef __GNUC__
-#define MONO_COLD __attribute__((cold))
+#define MONO_COLD __attribute__ ((__cold__))
#else
#define MONO_COLD
#endif
mctx->sc_ir = UCONTEXT_REG_NIP(uc);
mctx->sc_sp = UCONTEXT_REG_Rn(uc, 1);
- memcpy (&mctx->regs, &UCONTEXT_REG_Rn(uc, 13), sizeof (mgreg_t) * MONO_SAVED_GREGS);
- memcpy (&mctx->fregs, &UCONTEXT_REG_FPRn(uc, 14), sizeof (double) * MONO_SAVED_FREGS);
+
+ memcpy (&mctx->regs, &UCONTEXT_REG_Rn(uc, 0), sizeof (mgreg_t) * MONO_MAX_IREGS);
+ memcpy (&mctx->fregs, &UCONTEXT_REG_FPRn(uc, 0), sizeof (double) * MONO_MAX_FREGS);
}
void
{
os_ucontext *uc = sigctx;
+ memcpy (&UCONTEXT_REG_Rn(uc, 0), &mctx->regs, sizeof (mgreg_t) * MONO_MAX_IREGS);
+ memcpy (&UCONTEXT_REG_FPRn(uc, 0), &mctx->fregs, sizeof (double) * MONO_MAX_FREGS);
+
+ /* The valid values for pc and sp are stored here and not in regs array */
UCONTEXT_REG_NIP(uc) = mctx->sc_ir;
UCONTEXT_REG_Rn(uc, 1) = mctx->sc_sp;
- memcpy (&UCONTEXT_REG_Rn(uc, 13), &mctx->regs, sizeof (mgreg_t) * MONO_SAVED_GREGS);
- memcpy (&UCONTEXT_REG_FPRn(uc, 14), &mctx->fregs, sizeof (double) * MONO_SAVED_FREGS);
}
#endif /* #if defined(__i386__) */
#define MONO_CONTEXT_SET_SP(ctx,sp) do { (ctx)->sc_sp = (gulong)sp; } while (0);
#define MONO_CONTEXT_GET_IP(ctx) ((gpointer)((ctx)->sc_ir))
-#define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->regs [ppc_r31-13]))
+#define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->regs [ppc_r31]))
#define MONO_CONTEXT_GET_SP(ctx) ((gpointer)((ctx)->sc_sp))
#define MONO_CONTEXT_GET_CURRENT(ctx) \
#define MONO_CONTEXT_SET_SP(ctx,sp) do { (ctx)->sc_sp = (mgreg_t)sp; } while (0);
#define MONO_CONTEXT_GET_IP(ctx) ((gpointer)((ctx)->sc_ir))
-#define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->regs [ppc_r31-13]))
+#define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->regs [ppc_r31]))
#define MONO_CONTEXT_GET_SP(ctx) ((gpointer)((ctx)->sc_sp))
#define MONO_CONTEXT_GET_CURRENT(ctx) \
size = 0;
} else {
size = counter->size;
- strncpy ((char *) buffer, strval, size - 1);
+ memcpy ((char *) buffer, strval, size - 1);
((char*)buffer)[size - 1] = '\0';
}
}
uint8_t sccm:1; // 142 - Store CPU counter multiple
uint8_t ibm13:1; // 143 - Assigned to IBM
uint8_t x015[14]; // 144-256 Undefined
-} __attribute__ ((packed)) __attribute__ ((aligned(8))) facilityList_t;
+} __attribute__ ((__packed__)) __attribute__ ((__aligned__(8))) facilityList_t;
void
mono_hwcap_arch_init (void)
while (g_ascii_isspace (*s)) s++;
fclose (f);
len = strlen (s);
- strncpy (rbuf, s, MIN (len, blen));
+ memcpy (rbuf, s, MIN (len, blen));
rbuf [MIN (len, blen) - 1] = 0;
if (error)
*error = MONO_PROCESS_ERROR_NONE;
memset (buf, 0, len);
if (sysctl_kinfo_proc (pid, &processi))
- strncpy (buf, processi.kinfo_name_member, len - 1);
+ memcpy (buf, processi.kinfo_name_member, len - 1);
return buf;
#else
#include <stdint.h>
#ifdef __GNUC__
-#define MONO_API_EXPORT __attribute__ ((visibility ("default")))
+#define MONO_API_EXPORT __attribute__ ((__visibility__ ("default")))
#else
#define MONO_API_EXPORT
#endif
#if defined (MONO_INSIDE_RUNTIME)
#if defined (__clang__)
-#define MONO_RT_EXTERNAL_ONLY __attribute__ ((unavailable("The mono runtime must not call this function")))
+#define MONO_RT_EXTERNAL_ONLY __attribute__ ((__unavailable__ ("The mono runtime must not call this function")))
#elif defined (__GNUC__)
-#define MONO_RT_EXTERNAL_ONLY __attribute__ ((error("The mono runtime must not call this function")))
+#define MONO_RT_EXTERNAL_ONLY __attribute__ ((__error__ ("The mono runtime must not call this function")))
#else
#define MONO_RT_EXTERNAL_ONLY
#endif /* __clang__ */
#endif /* MONO_INSIDE_RUNTIME */
#ifdef __GNUC__
-#define _MONO_DEPRECATED __attribute__ ((deprecated))
+#define _MONO_DEPRECATED __attribute__ ((__deprecated__))
#elif defined (_MSC_VER)
#define _MONO_DEPRECATED __declspec (deprecated)
#else
err = errno;
} else {
egd_addr.sun_family = AF_UNIX;
- strncpy (egd_addr.sun_path, path, sizeof (egd_addr.sun_path) - 1);
+ memcpy (egd_addr.sun_path, path, sizeof (egd_addr.sun_path) - 1);
egd_addr.sun_path [sizeof (egd_addr.sun_path) - 1] = '\0';
ret = connect (socket_fd, (struct sockaddr*) &egd_addr, sizeof (egd_addr));
err = errno;
} CHAR64LONG16;
CHAR64LONG16* block;
#ifdef SHA1HANDSOFF
-static unsigned char workspace[64];
+ unsigned char workspace[64];
block = (CHAR64LONG16*)workspace;
memcpy(block, buffer, 64);
#else
#ifdef KRAIT_IT_BUG_WORKAROUND
#define MONO_SIGNAL_HANDLER_FUNC(access, name, arglist) \
static void __krait_ ## name arglist; \
- __attribute__ ((naked)) access void \
+ __attribute__ ((__naked__)) access void \
name arglist \
{ \
asm volatile ( \
"b __krait_" # name \
"\n\t"); \
} \
- static __attribute__((used)) void __krait_ ## name arglist
+ static __attribute__ ((__used__)) void __krait_ ## name arglist
#endif
/* Don't use this */
#include <sys/resource.h>
+static void
+reset_priority (pthread_attr_t *attr)
+{
+ struct sched_param param;
+ gint res;
+ gint policy;
+
+ memset (¶m, 0, sizeof (param));
+
+ res = pthread_attr_getschedpolicy (attr, &policy);
+ if (res != 0)
+ g_error ("%s: pthread_attr_getschedpolicy failed, error: \"%s\" (%d)", __func__, g_strerror (res), res);
+
+#ifdef _POSIX_PRIORITY_SCHEDULING
+ gint max, min;
+
+ /* Necessary to get valid priority range */
+
+ min = sched_get_priority_min (policy);
+ max = sched_get_priority_max (policy);
+
+ if (max > 0 && min >= 0 && max > min)
+ param.sched_priority = (max - min) / 2 + min;
+ else
+#endif
+ {
+ switch (policy) {
+ case SCHED_FIFO:
+ case SCHED_RR:
+ param.sched_priority = 50;
+ break;
+#ifdef SCHED_BATCH
+ case SCHED_BATCH:
+#endif
+ case SCHED_OTHER:
+ param.sched_priority = 0;
+ break;
+ default:
+ g_warning ("%s: unknown policy %d", __func__, policy);
+ return;
+ }
+ }
+
+ res = pthread_attr_setschedparam (attr, ¶m);
+ if (res != 0)
+ g_error ("%s: pthread_attr_setschedparam failed, error: \"%s\" (%d)", __func__, g_strerror (res), res);
+}
+
int
mono_threads_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_data, gsize* const stack_size, MonoNativeThreadId *out_tid)
{
pthread_attr_t attr;
pthread_t thread;
- int policy;
- struct sched_param param;
gint res;
gsize set_stack_size;
- size_t min_size;
+ gsize min_stack_size;
res = pthread_attr_init (&attr);
g_assert (!res);
g_assert (!res);
#endif /* HAVE_PTHREAD_ATTR_SETSTACKSIZE */
- memset (¶m, 0, sizeof (param));
-
- res = pthread_attr_getschedpolicy (&attr, &policy);
- if (res != 0)
- g_error ("%s: pthread_attr_getschedpolicy failed, error: \"%s\" (%d)", g_strerror (res), res);
-
-#ifdef _POSIX_PRIORITY_SCHEDULING
- int max, min;
-
- /* Necessary to get valid priority range */
-
- min = sched_get_priority_min (policy);
- max = sched_get_priority_max (policy);
-
- if (max > 0 && min >= 0 && max > min)
- param.sched_priority = (max - min) / 2 + min;
- else
-#endif
- {
- switch (policy) {
- case SCHED_FIFO:
- case SCHED_RR:
- param.sched_priority = 50;
- break;
-#ifdef SCHED_BATCH
- case SCHED_BATCH:
-#endif
- case SCHED_OTHER:
- param.sched_priority = 0;
- break;
- default:
- g_error ("%s: unknown policy %d", __func__, policy);
- }
- }
-
- res = pthread_attr_setschedparam (&attr, ¶m);
- if (res != 0)
- g_error ("%s: pthread_attr_setschedparam failed, error: \"%s\" (%d)", g_strerror (res), res);
+ reset_priority (&attr);
if (stack_size) {
- res = pthread_attr_getstacksize (&attr, &min_size);
+ res = pthread_attr_getstacksize (&attr, &min_stack_size);
if (res != 0)
g_error ("%s: pthread_attr_getstacksize failed, error: \"%s\" (%d)", g_strerror (res), res);
- else
- *stack_size = min_size;
+
+ *stack_size = min_stack_size;
}
/* Actually start the thread */
} else {
char n [63];
- strncpy (n, name, 63);
- n [62] = '\0';
+ memcpy (n, name, sizeof (n) - 1);
+ n [sizeof (n) - 1] = '\0';
pthread_setname_np (n);
}
#elif defined (__NetBSD__)
} else {
char n [PTHREAD_MAX_NAMELEN_NP];
- strncpy (n, name, PTHREAD_MAX_NAMELEN_NP);
- n [PTHREAD_MAX_NAMELEN_NP - 1] = '\0';
+ memcpy (n, name, sizeof (n) - 1);
+ n [sizeof (n) - 1] = '\0';
pthread_setname_np (tid, "%s", (void*)n);
}
#elif defined (HAVE_PTHREAD_SETNAME_NP)
} else {
char n [16];
- strncpy (n, name, 16);
- n [15] = '\0';
+ memcpy (n, name, sizeof (n) - 1);
+ n [sizeof (n) - 1] = '\0';
pthread_setname_np (tid, n);
}
#endif
#include <mono/utils/mono-threads-coop.h>
#include <mono/utils/mono-threads-debug.h>
#include <mono/utils/os-event.h>
-
-#include <mono/io-layer/io-layer.h>
+#include <mono/utils/w32api.h>
#include <errno.h>
static MonoSemType suspend_semaphore;
static size_t pending_suspends;
+static mono_mutex_t join_mutex;
+
#define mono_thread_info_run_state(info) (((MonoThreadInfo*)info)->thread_state & THREAD_STATE_MASK)
/*warn at 50 ms*/
mono_os_sem_init (&global_suspend_semaphore, 1);
mono_os_sem_init (&suspend_semaphore, 0);
+ mono_os_mutex_init (&join_mutex);
mono_lls_init (&thread_list, NULL);
mono_thread_smr_init ();
{
return mono_threads_platform_yield ();
}
+
static mono_lazy_init_t sleep_init = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED;
static MonoCoopMutex sleep_mutex;
static MonoCoopCond sleep_cond;
else
g_error ("%s: unknown res value %d", __func__, res);
}
+
+/*
+ * mono_threads_join_mutex:
+ *
+ * This mutex is used to avoid races between pthread_create () and pthread_join () on osx, see
+ * https://bugzilla.xamarin.com/show_bug.cgi?id=50529
+ * The code inside the lock should not block.
+ */
+void
+mono_threads_join_lock (void)
+{
+#ifdef TARGET_OSX
+ mono_os_mutex_lock (&join_mutex);
+#endif
+}
+
+void
+mono_threads_join_unlock (void)
+{
+#ifdef TARGET_OSX
+ mono_os_mutex_unlock (&join_mutex);
+#endif
+}
MonoThreadInfoWaitRet
mono_thread_info_wait_multiple_handle (MonoThreadHandle **thread_handles, gsize nhandles, MonoOSEvent *background_change_event, gboolean waitall, guint32 timeout, gboolean alertable);
+void mono_threads_join_lock (void);
+void mono_threads_join_unlock (void);
+
#endif /* __MONO_THREADS_H__ */
#if defined(PIC)
#ifdef PIC_INITIAL_EXEC
-#define MONO_TLS_FAST __attribute__((tls_model("initial-exec")))
+#define MONO_TLS_FAST __attribute__ ((__tls_model__("initial-exec")))
#else
#if defined (__powerpc__)
/* local dynamic requires a call to __tls_get_addr to look up the
For now we will disable this. */
#define MONO_TLS_FAST
#else
-#define MONO_TLS_FAST __attribute__((tls_model("local-dynamic")))
+#define MONO_TLS_FAST __attribute__ ((__tls_model__("local-dynamic")))
#endif
#endif
#else
-#define MONO_TLS_FAST __attribute__((tls_model("local-exec")))
+#define MONO_TLS_FAST __attribute__ ((__tls_model__("local-exec")))
#endif
#define mono_refcount_init(v,destructor) do { mono_refcount_initialize (&(v)->ref, (destructor)); } while (0)
#define mono_refcount_inc(v) (mono_refcount_increment (&(v)->ref),(v))
+#define mono_refcount_tryinc(v) (mono_refcount_tryincrement (&(v)->ref))
#define mono_refcount_dec(v) do { mono_refcount_decrement (&(v)->ref); } while (0)
static inline void
refcount->destructor = destructor;
}
-static inline void
-mono_refcount_increment (MonoRefCount *refcount)
+static inline gboolean
+mono_refcount_tryincrement (MonoRefCount *refcount)
{
guint32 oldref, newref;
do {
oldref = refcount->ref;
if (oldref == 0)
- g_error ("%s: cannot increment a ref with value 0", __func__);
+ return FALSE;
newref = oldref + 1;
} while (InterlockedCompareExchange ((gint32*) &refcount->ref, newref, oldref) != oldref);
+
+ return TRUE;
+}
+
+static inline void
+mono_refcount_increment (MonoRefCount *refcount)
+{
+ if (!mono_refcount_tryincrement (refcount))
+ g_error ("%s: cannot increment a ref with value 0", __func__);
}
static inline void
+++ /dev/null
-/* $OpenBSD: sha1.c,v 1.22 2012/08/27 21:05:43 miod Exp $ */
-
-/*
- * SHA-1 in C
- * By Steve Reid <steve@edmweb.com>
- * 100% Public Domain
- *
- * Test Vectors (from FIPS PUB 180-1)
- * "abc"
- * A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
- * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
- * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
- * A million repetitions of "a"
- * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
- */
-
-#include <sys/param.h>
-#include <string.h>
-#include <stdint.h>
-#include <sha1.h>
-
-#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
-
-/*
- * blk0() and blk() perform the initial expand.
- * I got the idea of expanding during the round function from SSLeay
- */
-#if BYTE_ORDER == LITTLE_ENDIAN
-# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
- |(rol(block->l[i],8)&0x00FF00FF))
-#else
-# define blk0(i) block->l[i]
-#endif
-#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
- ^block->l[(i+2)&15]^block->l[i&15],1))
-
-/*
- * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
- */
-#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
-#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
-#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
-#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
-#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
-
-typedef union {
- guint8 c[64];
- guint32 l[16];
-} CHAR64LONG16;
-
-/*
- * Hash a single 512-bit block. This is the core of the algorithm.
- */
-void
-mono_SHA1Transform(guint32 state[5], const guint8 buffer[SHA1_BLOCK_LENGTH])
-{
- guint32 a, b, c, d, e;
- guint8 workspace[SHA1_BLOCK_LENGTH];
- CHAR64LONG16 *block = (CHAR64LONG16 *)workspace;
-
- (void)memcpy(block, buffer, SHA1_BLOCK_LENGTH);
-
- /* Copy context->state[] to working vars */
- a = state[0];
- b = state[1];
- c = state[2];
- d = state[3];
- e = state[4];
-
- /* 4 rounds of 20 operations each. Loop unrolled. */
- R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
- R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
- R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
- R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
- R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
- R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
- R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
- R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
- R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
- R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
- R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
- R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
- R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
- R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
- R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
- R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
- R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
- R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
- R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
- R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
-
- /* Add the working vars back into context.state[] */
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
- state[4] += e;
-
- /* Wipe variables */
- a = b = c = d = e = 0;
-}
-
-
-/*
- * SHA1Init - Initialize new context
- */
-void
-mono_SHA1Init(SHA1_CTX *context)
-{
-
- /* SHA1 initialization constants */
- context->count = 0;
- context->state[0] = 0x67452301;
- context->state[1] = 0xEFCDAB89;
- context->state[2] = 0x98BADCFE;
- context->state[3] = 0x10325476;
- context->state[4] = 0xC3D2E1F0;
-}
-
-
-/*
- * Run your data through this.
- */
-void
-mono_SHA1Update(SHA1_CTX *context, const guint8 *data, size_t len)
-{
- size_t i, j;
-
- j = (size_t)((context->count >> 3) & 63);
- context->count += (len << 3);
- if ((j + len) > 63) {
- (void)memcpy(&context->buffer[j], data, (i = 64-j));
- mono_SHA1Transform(context->state, context->buffer);
- for ( ; i + 63 < len; i += 64)
- mono_SHA1Transform(context->state, (guint8 *)&data[i]);
- j = 0;
- } else {
- i = 0;
- }
- (void)memcpy(&context->buffer[j], &data[i], len - i);
-}
-
-
-/*
- * Add padding and return the message digest.
- */
-void
-mono_SHA1Pad(SHA1_CTX *context)
-{
- guint8 finalcount[8];
- guint i;
-
- for (i = 0; i < 8; i++) {
- finalcount[i] = (guint8)((context->count >>
- ((7 - (i & 7)) * 8)) & 255); /* Endian independent */
- }
- mono_SHA1Update(context, (guint8 *)"\200", 1);
- while ((context->count & 504) != 448)
- mono_SHA1Update(context, (guint8 *)"\0", 1);
- mono_SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
-}
-
-void
-mono_SHA1Final(guint8 digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context)
-{
- guint i;
-
- mono_SHA1Pad(context);
- if (digest) {
- for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
- digest[i] = (guint8)
- ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
- }
- memset(context, 0, sizeof(*context));
- }
-}
+++ /dev/null
-/* $OpenBSD: sha1.h,v 1.24 2012/12/05 23:19:57 deraadt Exp $ */
-
-/*
- * SHA-1 in C
- * By Steve Reid <steve@edmweb.com>
- * 100% Public Domain
- */
-
-#ifndef _SHA1_H
-#define _SHA1_H
-
-#include <glib.h>
-
-#define SHA1_BLOCK_LENGTH 64
-#define SHA1_DIGEST_LENGTH 20
-#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
-
-typedef struct {
- guint32 state[5];
- guint64 count;
- guint8 buffer[SHA1_BLOCK_LENGTH];
-} SHA1_CTX;
-
-G_BEGIN_DECLS
-void mono_SHA1Init(SHA1_CTX *);
-void mono_SHA1Pad(SHA1_CTX *);
-void mono_SHA1Transform(guint32 [5], const guint8 [SHA1_BLOCK_LENGTH]);
-void mono_SHA1Update(SHA1_CTX *, const guint8 *, size_t);
-void mono_SHA1Final(guint8 [SHA1_DIGEST_LENGTH], SHA1_CTX *);
-char *mono_SHA1End(SHA1_CTX *, char *);
-G_END_DECLS
-
-#define HTONDIGEST(x) do { \
- x[0] = htonl(x[0]); \
- x[1] = htonl(x[1]); \
- x[2] = htonl(x[2]); \
- x[3] = htonl(x[3]); \
- x[4] = htonl(x[4]); } while (0)
-
-#define NTOHDIGEST(x) do { \
- x[0] = ntohl(x[0]); \
- x[1] = ntohl(x[1]); \
- x[2] = ntohl(x[2]); \
- x[3] = ntohl(x[3]); \
- x[4] = ntohl(x[4]); } while (0)
-
-#endif /* _SHA1_H */
/* Modern GCC will optimize the static routine out if unused,
and unused attribute will shut down warnings about it. */
static int VALGRIND_PRINTF(const char *format, ...)
- __attribute__((format(__printf__, 1, 2), __unused__));
+ __attribute__ ((__format__(__printf__, 1, 2), __unused__));
#endif
static int
#if defined(_MSC_VER)
#if defined(__GNUC__) || defined(__INTEL_COMPILER) && !defined(_MSC_VER)
static int VALGRIND_PRINTF_BACKTRACE(const char *format, ...)
- __attribute__((format(__printf__, 1, 2), __unused__));
+ __attribute__ ((__format__(__printf__, 1, 2), __unused__));
#endif
static int
#if defined(_MSC_VER)
--- /dev/null
+
+#ifndef __MONO_UTILS_W32API_H__
+#define __MONO_UTILS_W32API_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef HOST_WIN32
+
+#define WAIT_FAILED ((gint) 0xFFFFFFFF)
+#define WAIT_OBJECT_0 ((gint) 0x00000000)
+#define WAIT_ABANDONED_0 ((gint) 0x00000080)
+#define WAIT_TIMEOUT ((gint) 0x00000102)
+#define WAIT_IO_COMPLETION ((gint) 0x000000C0)
+
+#define WINAPI
+
+typedef guint32 DWORD;
+typedef gboolean BOOL;
+typedef gint32 LONG;
+typedef guint32 ULONG;
+typedef guint UINT;
+
+typedef gpointer HANDLE;
+typedef gpointer HMODULE;
+
+#else
+
+#define __USE_W32_SOCKETS
+#include <winsock2.h>
+#include <windows.h>
+#include <winbase.h>
+/* The mingw version says: /usr/i686-pc-mingw32/sys-root/mingw/include/ws2tcpip.h:38:2: error: #error "ws2tcpip.h is not compatible with winsock.h. Include winsock2.h instead." */
+#ifdef _MSC_VER
+#include <ws2tcpip.h>
+#endif
+#include <psapi.h>
+
+/* Workaround for missing WSAPOLLFD typedef in mingw's winsock2.h
+ * that is required for mswsock.h below. Remove once
+ * http://sourceforge.net/p/mingw/bugs/1980/ is fixed. */
+#if defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION == 4
+typedef struct pollfd {
+ SOCKET fd;
+ short events;
+ short revents;
+} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
+#endif
+
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#include <mswsock.h>
+#endif
+
+#endif /* HOST_WIN32 */
+
+G_END_DECLS
+
+#endif /* __MONO_UTILS_W32API_H__ */
<ClCompile Include="..\mono\mini\mini-cross-helpers.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\mono\mini\mini-exceptions-native-unwinder.c">\r
- <Filter>Source Files</Filter>\r
- </ClCompile>\r
<ClCompile Include="..\mono\mini\mini-x86-gsharedvt.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
<Filter>Resource Files</Filter>\r
</None>\r
</ItemGroup>\r
-</Project>\r
+</Project>
\ No newline at end of file
<ClCompile Include="..\mono\metadata\cominterop.c" />\r
<ClCompile Include="..\mono\metadata\console-win32.c" />\r
<ClCompile Include="..\mono\metadata\property-bag.c" />\r
- <ClCompile Include="..\mono\metadata\socket-io-windows.c" />\r
- <ClCompile Include="..\mono\metadata\file-io-windows.c" />\r
+ <ClCompile Include="..\mono\metadata\w32socket-win32.c" />\r
+ <ClCompile Include="..\mono\metadata\w32file-win32.c" />\r
+ <ClCompile Include="..\mono\metadata\w32error-win32.c" />\r
<ClCompile Include="..\mono\metadata\icall-windows.c" />\r
<ClCompile Include="..\mono\metadata\marshal-windows.c" />\r
<ClCompile Include="..\mono\metadata\mono-security-windows.c" />\r
<ClCompile Include="..\mono\metadata\domain.c" />\r
<ClCompile Include="..\mono\metadata\environment.c" />\r
<ClCompile Include="..\mono\metadata\exception.c" />\r
- <ClCompile Include="..\mono\metadata\file-io.c" />\r
+ <ClCompile Include="..\mono\metadata\w32file.c" />\r
<ClCompile Include="..\mono\metadata\file-mmap-windows.c" />\r
<ClCompile Include="..\mono\metadata\filewatcher.c" />\r
<ClCompile Include="..\mono\metadata\gc-stats.c" />\r
<ClCompile Include="..\mono\metadata\sgen-tarjan-bridge.c" />\r
<ClCompile Include="..\mono\metadata\sgen-toggleref.c" />\r
<ClCompile Include="..\mono\metadata\sgen-stw.c" />\r
- <ClCompile Include="..\mono\metadata\socket-io.c" />\r
+ <ClCompile Include="..\mono\metadata\w32socket.c" />\r
<ClCompile Include="..\mono\metadata\sre.c" />\r
<ClCompile Include="..\mono\metadata\sre-encode.c" />\r
<ClCompile Include="..\mono\metadata\sre-save.c" />\r
<ClInclude Include="..\mono\metadata\dynamic-stream-internals.h" />\r
<ClInclude Include="..\mono\metadata\environment.h" />\r
<ClInclude Include="..\mono\metadata\exception.h" />\r
- <ClInclude Include="..\mono\metadata\file-io-internals.h" />\r
- <ClInclude Include="..\mono\metadata\file-io-windows-internals.h" />\r
- <ClInclude Include="..\mono\metadata\file-io.h" />\r
+ <ClInclude Include="..\mono\metadata\w32file-internals.h" />\r
+ <ClInclude Include="..\mono\metadata\w32file-win32-internals.h" />\r
+ <ClInclude Include="..\mono\metadata\w32file.h" />\r
+ <ClInclude Include="..\mono\metadata\w32error.h" />\r
+ <ClInclude Include="..\mono\utils\w32api.h" />\r
<ClInclude Include="..\mono\metadata\filewatcher.h" />\r
<ClInclude Include="..\mono\metadata\gc-internals.h" />\r
<ClInclude Include="..\mono\metadata\handle.h" />\r
<ClInclude Include="..\mono\metadata\seq-points-data.h" />\r
<ClInclude Include="..\mono\metadata\sgen-bridge-internals.h" />\r
<ClInclude Include="..\mono\metadata\sgen-client-mono.h" />\r
- <ClInclude Include="..\mono\metadata\socket-io-windows-internals.h" />\r
+ <ClInclude Include="..\mono\metadata\w32socket-internals.h" />\r
<ClInclude Include="..\mono\metadata\threadpool-io.h" />\r
<ClInclude Include="..\mono\metadata\threadpool.h" />\r
<ClInclude Include="..\mono\metadata\threadpool-worker.h" />\r
<ClInclude Include="..\mono\metadata\security.h" />\r
<ClInclude Include="..\mono\metadata\sgen-bridge.h" />\r
<ClInclude Include="..\mono\metadata\sgen-toggleref.h" />\r
- <ClInclude Include="..\mono\metadata\socket-io.h" />\r
+ <ClInclude Include="..\mono\metadata\w32socket.h" />\r
<ClInclude Include="..\mono\metadata\sre-internals.h" />\r
<ClInclude Include="..\mono\metadata\string-icalls.h" />\r
<ClInclude Include="..\mono\metadata\sysmath.h" />\r
<ClCompile Include="..\mono\metadata\exception.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\mono\metadata\file-io.c">\r
+ <ClCompile Include="..\mono\metadata\w32file.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
<ClCompile Include="..\mono\metadata\file-mmap-windows.c">\r
<ClCompile Include="..\mono\metadata\seq-points-data.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\mono\metadata\socket-io.c">\r
+ <ClCompile Include="..\mono\metadata\w32socket.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
<ClCompile Include="..\mono\metadata\string-icalls.c">\r
<ClCompile Include="..\mono\metadata\sre-save.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\mono\metadata\socket-io-windows.c">\r
+ <ClCompile Include="..\mono\metadata\w32socket-win32.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\mono\metadata\file-io-windows.c">\r
+ <ClCompile Include="..\mono\metadata\w32file-win32.c">\r
+ <Filter>Source Files</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\mono\metadata\w32error-win32.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
<ClCompile Include="..\mono\metadata\icall-windows.c">\r
<ClInclude Include="..\mono\metadata\exception.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
- <ClInclude Include="..\mono\metadata\file-io.h">\r
+ <ClInclude Include="..\mono\metadata\w32file.h">\r
+ <Filter>Header Files</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="..\mono\metadata\w32error.h">\r
+ <Filter>Header Files</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="..\mono\utils\w32api.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
<ClInclude Include="..\mono\metadata\filewatcher.h">\r
<ClInclude Include="..\mono\metadata\seq-points-data.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
- <ClInclude Include="..\mono\metadata\socket-io.h">\r
+ <ClInclude Include="..\mono\metadata\w32socket.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
<ClInclude Include="..\mono\metadata\string-icalls.h">\r
<ClInclude Include="..\mono\metadata\sre-internals.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
- <ClInclude Include="..\mono\metadata\socket-io-windows-internals.h">\r
+ <ClInclude Include="..\mono\metadata\w32socket-internals.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
<ClInclude Include="..\mono\metadata\coree-internals.h">\r
<ClInclude Include="..\mono\metadata\console-win32-internals.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
- <ClInclude Include="..\mono\metadata\file-io-windows-internals.h">\r
+ <ClInclude Include="..\mono\metadata\w32file-win32-internals.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
- <ClInclude Include="..\mono\metadata\file-io-internals.h">\r
+ <ClInclude Include="..\mono\metadata\w32file-internals.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
<ClInclude Include="..\mono\metadata\icall-internals.h">\r
Mono_Posix_Stdlib_strlen\r
Mono_Posix_Stdlib_tmpfile\r
Mono_Posix_Stdlib_ungetc\r
+Mono_Posix_Syscall_L_ctermid\r
+Mono_Posix_Syscall_L_cuserid\r
+Mono_Posix_Syscall_get_at_fdcwd\r
+Mono_Posix_Syscall_get_utime_now\r
+Mono_Posix_Syscall_get_utime_omit\r
Mono_Posix_ToAccessModes\r
Mono_Posix_ToConfstrName\r
Mono_Posix_ToDirectoryNotifyFlags\r
<ClCompile Include="..\support\crc32.c" />\r
<ClCompile Include="..\support\deflate.c" />\r
<ClCompile Include="..\support\errno.c" />\r
+ <ClCompile Include="..\support\fcntl.c" />\r
<ClCompile Include="..\support\infback.c" />\r
<ClCompile Include="..\support\inffast.c" />\r
<ClCompile Include="..\support\inflate.c" />\r
<ClCompile Include="..\support\stdio.c" />\r
<ClCompile Include="..\support\stdlib.c" />\r
<ClCompile Include="..\support\string.c" />\r
+ <ClCompile Include="..\support\sys-stat.c" />\r
<ClCompile Include="..\support\trees.c" />\r
<ClCompile Include="..\support\uncompr.c" />\r
<ClCompile Include="..\support\zlib-helper.c" />\r
<ClCompile Include="..\support\minizip\ioapi.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
+ <ClCompile Include="..\support\fcntl.c">\r
+ <Filter>Source Files</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\support\sys-stat.c">\r
+ <Filter>Source Files</Filter>\r
+ </ClCompile>\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="..\support\crc32.h">\r
<ClCompile Include="..\mono\metadata\console-win32.c" />\r
<ClCompile Include="..\mono\metadata\domain.c" />\r
<ClCompile Include="..\mono\metadata\environment.c" />\r
- <ClCompile Include="..\mono\metadata\file-io-windows.c" />\r
- <ClCompile Include="..\mono\metadata\file-io.c" />\r
+ <ClCompile Include="..\mono\metadata\w32file-win32.c" />\r
+ <ClCompile Include="..\mono\metadata\w32file.c" />\r
+ <ClCompile Include="..\mono\metadata\w32error-win32.c" />\r
<ClCompile Include="..\mono\metadata\filewatcher.c" />\r
<ClCompile Include="..\mono\metadata\gc.c" />\r
<ClCompile Include="..\mono\metadata\icall-windows.c" />\r
<ClCompile Include="..\mono\metadata\rand.c" />\r
<ClCompile Include="..\mono\metadata\reflection.c" />\r
<ClCompile Include="..\mono\metadata\security-manager.c" />\r
- <ClCompile Include="..\mono\metadata\socket-io.c" />\r
+ <ClCompile Include="..\mono\metadata\w32socket.c" />\r
<ClCompile Include="..\mono\metadata\string-icalls.c" />\r
<ClCompile Include="..\mono\metadata\sysmath.c" />\r
<ClCompile Include="..\mono\metadata\threads.c" />\r
<ClCompile Include="..\mono\metadata\environment.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\mono\metadata\file-io.c">\r
+ <ClCompile Include="..\mono\metadata\w32file.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
<ClCompile Include="..\mono\metadata\filewatcher.c">\r
<ClCompile Include="..\mono\metadata\security-manager.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\mono\metadata\socket-io.c">\r
+ <ClCompile Include="..\mono\metadata\w32socket.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
<ClCompile Include="..\mono\metadata\string-icalls.c">\r
<ClCompile Include="..\mono\metadata\icall-windows.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\mono\metadata\file-io-windows.c">\r
+ <ClCompile Include="..\mono\metadata\w32file-win32.c">\r
+ <Filter>Source Files</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\mono\metadata\w32error-win32.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
</ItemGroup>\r
<root>
<project dir="class/corlib" library="corlib-basic">
<boot>true</boot>
- <flags>/codepage:65001 /nologo /noconfig -unsafe -nostdlib -nowarn:612,618,1635 -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT,HAS_CORLIB_CONTRACTS -d:FEATURE_MACL -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -d:NET_4_0 -d:NET_4_5 -d:MONO -d:WIN_PLATFORM -d:BOOTSTRAP_BASIC -nowarn:1699 -nostdlib -optimize -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT,HAS_CORLIB_CONTRACTS -d:FEATURE_MACL -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -resource:resources/charinfo.nlp -resource:resources/collation.core.bin -resource:resources/collation.tailoring.bin -resource:resources/collation.cjkCHS.bin -resource:resources/collation.cjkCHT.bin -resource:resources/collation.cjkJA.bin -resource:resources/collation.cjkKO.bin -resource:resources/collation.cjkKOlv2.bin -runtimemetadataversion:v4.0.30319</flags>
+ <flags>/codepage:65001 /nologo /noconfig -unsafe -nostdlib -nowarn:612,618,1635 -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT,HAS_CORLIB_CONTRACTS -d:FEATURE_MACL -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -d:NET_4_0 -d:NET_4_5 -d:MONO -d:WIN_PLATFORM -d:BOOTSTRAP_BASIC -nowarn:1699 -nostdlib -optimize -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT,HAS_CORLIB_CONTRACTS -d:FEATURE_MACL -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -resource:resources/charinfo.nlp -resource:resources/collation.core.bin -resource:resources/collation.tailoring.bin -resource:resources/collation.cjkCHS.bin -resource:resources/collation.cjkCHT.bin -resource:resources/collation.cjkJA.bin -resource:resources/collation.cjkKO.bin -resource:resources/collation.cjkKOlv2.bin -runtimemetadataversion:v4.0.30319 -d:MONO_FEATURE_CONSOLE</flags>
<output>mscorlib.dll</output>
<built_sources></built_sources>
<library_output>./../../class/lib/basic/mscorlib.dll</library_output>
<resources></resources>
<response>System.ValueTuple.dll.sources</response>
</project>
+ <project dir="class/Facades/System.Text.Encoding.CodePages" library="Facades_System.Text.Encoding.CodePages-basic">
+ <boot>true</boot>
+ <flags>/codepage:65001 /nologo /noconfig -d:NET_4_0 -d:NET_4_5 -d:MONO -d:WIN_PLATFORM -d:BOOTSTRAP_BASIC -nowarn:1699 -nostdlib -r:./../../../class/lib/basic/mscorlib.dll -optimize /delaysign /keyfile:../../msfinal.pub /nowarn:1616,1699 -r:./../../../class/lib/basic/System.dll</flags>
+ <output>System.Text.Encoding.CodePages.dll</output>
+ <built_sources></built_sources>
+ <library_output>./../../../class/lib/basic/Facades/System.Text.Encoding.CodePages.dll</library_output>
+ <fx_version>4.0</fx_version>
+ <profile>basic</profile>
+ <resources></resources>
+ <response>System.Text.Encoding.CodePages.dll.sources</response>
+ </project>
<project dir="class/corlib" library="corlib-build">
<boot>true</boot>
- <flags>/codepage:65001 /nologo /noconfig /deterministic -unsafe -nostdlib -nowarn:612,618,1635 -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT,HAS_CORLIB_CONTRACTS -d:FEATURE_MACL -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -d:NET_4_0 -d:NET_4_5 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -optimize -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT,HAS_CORLIB_CONTRACTS -d:FEATURE_MACL -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -resource:resources/charinfo.nlp -resource:resources/collation.core.bin -resource:resources/collation.tailoring.bin -resource:resources/collation.cjkCHS.bin -resource:resources/collation.cjkCHT.bin -resource:resources/collation.cjkJA.bin -resource:resources/collation.cjkKO.bin -resource:resources/collation.cjkKOlv2.bin -runtimemetadataversion:v4.0.30319</flags>
+ <flags>/codepage:65001 /nologo /noconfig /deterministic -unsafe -nostdlib -nowarn:612,618,1635 -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT,HAS_CORLIB_CONTRACTS -d:FEATURE_MACL -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -d:NET_4_0 -d:NET_4_5 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -optimize -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT,HAS_CORLIB_CONTRACTS -d:FEATURE_MACL -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -resource:resources/charinfo.nlp -resource:resources/collation.core.bin -resource:resources/collation.tailoring.bin -resource:resources/collation.cjkCHS.bin -resource:resources/collation.cjkCHT.bin -resource:resources/collation.cjkJA.bin -resource:resources/collation.cjkKO.bin -resource:resources/collation.cjkKOlv2.bin -runtimemetadataversion:v4.0.30319 -d:MONO_FEATURE_CONSOLE</flags>
<output>mscorlib.dll</output>
<built_sources></built_sources>
<library_output>./../../class/lib/build/mscorlib.dll</library_output>
<resources></resources>
<response>System.Runtime.InteropServices.RuntimeInformation.dll.sources</response>
</project>
+ <project dir="class/System.IO.Compression" library="System.IO.Compression-build">
+ <boot>false</boot>
+ <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/build/mscorlib.dll -optimize -r:./../../class/lib/build/System.dll</flags>
+ <output>System.IO.Compression.dll</output>
+ <built_sources></built_sources>
+ <library_output>./../../class/lib/build/System.IO.Compression.dll</library_output>
+ <fx_version>4.5</fx_version>
+ <profile>build</profile>
+ <resources></resources>
+ <response>System.IO.Compression.dll.sources</response>
+ </project>
<project dir="class/Mono.Cecil" library="Mono.Cecil-build">
<boot>false</boot>
<flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/build/mscorlib.dll -optimize -keyfile:../mono.snk -d:NET_4_0 /publicsign -r:./../../class/lib/build/System.Core.dll</flags>
<resources></resources>
<response>System.ValueTuple.dll.sources</response>
</project>
+ <project dir="class/Facades/System.Text.Encoding.CodePages" library="Facades_System.Text.Encoding.CodePages-build">
+ <boot>false</boot>
+ <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../../class/lib/build/mscorlib.dll -optimize /delaysign /keyfile:../../msfinal.pub /nowarn:1616,1699 -r:./../../../class/lib/build/System.dll</flags>
+ <output>System.Text.Encoding.CodePages.dll</output>
+ <built_sources></built_sources>
+ <library_output>./../../../class/lib/build/Facades/System.Text.Encoding.CodePages.dll</library_output>
+ <fx_version>4.5</fx_version>
+ <profile>build</profile>
+ <resources></resources>
+ <response>System.Text.Encoding.CodePages.dll.sources</response>
+ </project>
<project dir="tools/gacutil" library="gacutil-build">
<boot></boot>
<flags>/codepage:65001 /nologo /noconfig /deterministic -unsafe -define:NO_SYMBOL_WRITER -d:NET_4_0 -d:NET_4_5 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/build/mscorlib.dll -optimize -r:System -r:Mono.Security -r:System.Security</flags>
</project>
<project dir="class/corlib" library="corlib-net_4_x">
<boot>true</boot>
- <flags>/codepage:65001 /nologo /noconfig /deterministic -unsafe -nostdlib -nowarn:612,618,1635 -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT,HAS_CORLIB_CONTRACTS -d:FEATURE_MACL -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib /debug:portable -optimize -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT,HAS_CORLIB_CONTRACTS -d:FEATURE_MACL -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -resource:resources/charinfo.nlp -resource:resources/collation.core.bin -resource:resources/collation.tailoring.bin -resource:resources/collation.cjkCHS.bin -resource:resources/collation.cjkCHT.bin -resource:resources/collation.cjkJA.bin -resource:resources/collation.cjkKO.bin -resource:resources/collation.cjkKOlv2.bin -runtimemetadataversion:v4.0.30319</flags>
+ <flags>/codepage:65001 /nologo /noconfig /deterministic -unsafe -nostdlib -nowarn:612,618,1635 -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT,HAS_CORLIB_CONTRACTS -d:FEATURE_MACL -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib /debug:portable -optimize -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT,HAS_CORLIB_CONTRACTS -d:FEATURE_MACL -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -resource:resources/charinfo.nlp -resource:resources/collation.core.bin -resource:resources/collation.tailoring.bin -resource:resources/collation.cjkCHS.bin -resource:resources/collation.cjkCHT.bin -resource:resources/collation.cjkJA.bin -resource:resources/collation.cjkKO.bin -resource:resources/collation.cjkKOlv2.bin -runtimemetadataversion:v4.0.30319 -d:MONO_FEATURE_CONSOLE</flags>
<output>mscorlib.dll</output>
<built_sources></built_sources>
<library_output>./../../class/lib/net_4_x/mscorlib.dll</library_output>
</project>
<project dir="class/System.Data" library="System.Data-net_4_x">
<boot>false</boot>
- <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -nowarn:219,414,649 -d:PLATFORM_UNIX -d:USEOFFSET -d:MONO_PARTIAL_DATA_IMPORT -unsafe -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/System.Xml.dll -r:./../../class/lib/net_4_x/System.Core.dll -r:./../../class/lib/net_4_x/System.Numerics.dll -r:./../../class/lib/net_4_x/System.EnterpriseServices.dll -r:./../../class/lib/net_4_x/Mono.Data.Tds.dll -r:./../../class/lib/net_4_x/System.Configuration.dll -r:./../../class/lib/net_4_x/System.Transactions.dll</flags>
+ <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -nowarn:219,414,649 -d:COREFX -d:PLATFORM_UNIX -d:USEOFFSET -d:MONO_PARTIAL_DATA_IMPORT -unsafe -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/System.Xml.dll -r:./../../class/lib/net_4_x/System.Core.dll -r:./../../class/lib/net_4_x/System.Numerics.dll -r:./../../class/lib/net_4_x/System.EnterpriseServices.dll -r:./../../class/lib/net_4_x/Mono.Data.Tds.dll -r:./../../class/lib/net_4_x/System.Configuration.dll -r:./../../class/lib/net_4_x/System.Transactions.dll</flags>
<output>System.Data.dll</output>
<built_sources>gen_OdbcConnection.cs gen_OleDbConnection.cs gen_OdbcParameter.cs gen_OleDbParameter.cs gen_OdbcParameterCollection.cs gen_OleDbParameterCollection.cs</built_sources>
<library_output>./../../class/lib/net_4_x/System.Data.dll</library_output>
</project>
<project dir="class/System.Data" library="System.Data-tests-net_4_x">
<boot>false</boot>
- <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -r:./../../class/lib/net_4_x/System.Data.dll -nowarn:219,414,649 -d:PLATFORM_UNIX -d:USEOFFSET -d:MONO_PARTIAL_DATA_IMPORT -unsafe -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/System.Xml.dll -r:./../../class/lib/net_4_x/System.Core.dll -r:./../../class/lib/net_4_x/System.Numerics.dll -r:./../../class/lib/net_4_x/System.EnterpriseServices.dll -r:./../../class/lib/net_4_x/Mono.Data.Tds.dll -r:./../../class/lib/net_4_x/System.Configuration.dll -r:./../../class/lib/net_4_x/System.Transactions.dll -nowarn:618,169,612,219,168</flags>
+ <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -r:./../../class/lib/net_4_x/System.Data.dll -nowarn:219,414,649 -d:COREFX -d:PLATFORM_UNIX -d:USEOFFSET -d:MONO_PARTIAL_DATA_IMPORT -unsafe -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/System.Xml.dll -r:./../../class/lib/net_4_x/System.Core.dll -r:./../../class/lib/net_4_x/System.Numerics.dll -r:./../../class/lib/net_4_x/System.EnterpriseServices.dll -r:./../../class/lib/net_4_x/Mono.Data.Tds.dll -r:./../../class/lib/net_4_x/System.Configuration.dll -r:./../../class/lib/net_4_x/System.Transactions.dll -nowarn:618,169,612,219,168</flags>
<output>net_4_x_System.Data_test.dll</output>
<built_sources>gen_OdbcConnection.cs gen_OleDbConnection.cs gen_OdbcParameter.cs gen_OleDbParameter.cs gen_OdbcParameterCollection.cs gen_OleDbParameterCollection.cs</built_sources>
<library_output>net_4_x_System.Data_test.dll</library_output>
</project>
<project dir="class/WindowsBase" library="WindowsBase-net_4_x">
<boot>false</boot>
- <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -unsafe -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/System.Xml.dll -r:./../../class/lib/net_4_x/System.Xaml.dll</flags>
+ <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -unsafe -nowarn:67,618 -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/System.Xml.dll -r:./../../class/lib/net_4_x/System.Xaml.dll</flags>
<output>WindowsBase.dll</output>
<built_sources></built_sources>
<library_output>./../../class/lib/net_4_x/WindowsBase.dll</library_output>
</project>
<project dir="class/System.Windows.Forms.DataVisualization" library="System.Windows.Forms.DataVisualization-net_4_x">
<boot>false</boot>
- <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/System.Drawing.dll -r:./../../class/lib/net_4_x/System.Windows.Forms.dll -r:./../../class/lib/net_4_x/System.Core.dll -r:./../../class/lib/net_4_x/System.Data.dll -r:./../../class/lib/net_4_x/System.Xml.dll</flags>
+ <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -nowarn:67 -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/System.Drawing.dll -r:./../../class/lib/net_4_x/System.Windows.Forms.dll -r:./../../class/lib/net_4_x/System.Core.dll -r:./../../class/lib/net_4_x/System.Data.dll -r:./../../class/lib/net_4_x/System.Xml.dll</flags>
<output>System.Windows.Forms.DataVisualization.dll</output>
<built_sources></built_sources>
<library_output>./../../class/lib/net_4_x/System.Windows.Forms.DataVisualization.dll</library_output>
</project>
<project dir="class/System.Windows.Forms.DataVisualization" library="System.Windows.Forms.DataVisualization-tests-net_4_x">
<boot>false</boot>
- <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -r:./../../class/lib/net_4_x/System.Windows.Forms.DataVisualization.dll -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/System.Drawing.dll -r:./../../class/lib/net_4_x/System.Windows.Forms.dll -r:./../../class/lib/net_4_x/System.Core.dll -r:./../../class/lib/net_4_x/System.Data.dll -r:./../../class/lib/net_4_x/System.Xml.dll</flags>
+ <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -r:./../../class/lib/net_4_x/System.Windows.Forms.DataVisualization.dll -nowarn:67 -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/System.Drawing.dll -r:./../../class/lib/net_4_x/System.Windows.Forms.dll -r:./../../class/lib/net_4_x/System.Core.dll -r:./../../class/lib/net_4_x/System.Data.dll -r:./../../class/lib/net_4_x/System.Xml.dll</flags>
<output>net_4_x_System.Windows.Forms.DataVisualization_test.dll</output>
<built_sources></built_sources>
<library_output>net_4_x_System.Windows.Forms.DataVisualization_test.dll</library_output>
</project>
<project dir="class/monodoc" library="monodoc-net_4_x">
<boot>false</boot>
- <flags>/codepage:65001 /nologo /noconfig /deterministic /nowarn:618,612,672,809 /define:LEGACY_MODE -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize /unsafe /nowarn:169,164,162,168,219,618,612 /resource:../../docs/monodoc.xml,monodoc.xml /resource:Resources/base.css,base.css /resource:Resources/ecmaspec-html-css.xsl,ecmaspec-html-css.xsl /resource:Resources/ecmaspec-html.xsl,ecmaspec-html.xsl /resource:Resources/ecmaspec.css,ecmaspec.css /resource:Resources/helper.js,helper.js /resource:Resources/home.html,home.html /resource:Resources/Lminus.gif,Lminus.gif /resource:Resources/Lplus.gif,Lplus.gif /resource:Resources/creativecommons.png,creativecommons.png /resource:Resources/mdoc-html-format.xsl,mdoc-html-format.xsl /resource:Resources/mdoc-html-utils.xsl,mdoc-html-utils.xsl /resource:Resources/mdoc-sections-css.xsl,mdoc-sections-css.xsl /resource:Resources/mdoc-sections.xsl,mdoc-sections.xsl /resource:Resources/mono-ecma-css.xsl,mono-ecma-css.xsl /resource:Resources/mono-ecma-impl.xsl,mono-ecma-impl.xsl /resource:Resources/mono-ecma.css,mono-ecma.css /resource:Resources/mono-ecma.xsl,mono-ecma.xsl /resource:Resources/toc-html.xsl,toc-html.xsl /resource:Resources/images/bc_bg.png,bc_bg.png /resource:Resources/images/bc_separator.png,bc_separator.png /resource:Resources/images/error.png,error.png /resource:Resources/images/hatch.png,hatch.png /resource:Resources/images/headerbg.png,headerbg.png /resource:Resources/images/help.png,help.png /resource:Resources/images/house.png,house.png /resource:Resources/images/members.png,members.png /resource:Resources/images/namespace.png,namespace.png /resource:Resources/images/privclass.png,privclass.png /resource:Resources/images/privdelegate.png,privdelegate.png /resource:Resources/images/privenumeration.png,privenumeration.png /resource:Resources/images/privevent.png,privevent.png /resource:Resources/images/privextension.png,privextension.png /resource:Resources/images/privfield.png,privfield.png /resource:Resources/images/privinterface.png,privinterface.png /resource:Resources/images/privmethod.png,privmethod.png /resource:Resources/images/privproperty.png,privproperty.png /resource:Resources/images/privstructure.png,privstructure.png /resource:Resources/images/protclass.png,protclass.png /resource:Resources/images/protdelegate.png,protdelegate.png /resource:Resources/images/protenumeration.png,protenumeration.png /resource:Resources/images/protevent.png,protevent.png /resource:Resources/images/protextension.png,protextension.png /resource:Resources/images/protfield.png,protfield.png /resource:Resources/images/protinterface.png,protinterface.png /resource:Resources/images/protmethod.png,protmethod.png /resource:Resources/images/protproperty.png,protproperty.png /resource:Resources/images/protstructure.png,protstructure.png /resource:Resources/images/pubclass.png,pubclass.png /resource:Resources/images/pubdelegate.png,pubdelegate.png /resource:Resources/images/pubenumeration.png,pubenumeration.png /resource:Resources/images/pubevent.png,pubevent.png /resource:Resources/images/pubextension.png,pubextension.png /resource:Resources/images/pubfield.png,pubfield.png /resource:Resources/images/pubinterface.png,pubinterface.png /resource:Resources/images/pubmethod.png,pubmethod.png /resource:Resources/images/pubproperty.png,pubproperty.png /resource:Resources/images/pubstructure.png,pubstructure.png /resource:Resources/images/reference.png,reference.png /resource:Resources/images/treebg.png,treebg.png -r:./../../class/lib/net_4_x/ICSharpCode.SharpZipLib.dll -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/System.Core.dll -r:./../../class/lib/net_4_x/System.Xml.dll -r:./../../class/lib/net_4_x/System.Xml.Linq.dll -r:./../../class/lib/net_4_x/System.Configuration.dll</flags>
+ <flags>/codepage:65001 /nologo /noconfig /deterministic /nowarn:618,612,672,809,414,649 /define:LEGACY_MODE -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize /unsafe /nowarn:169,164,162,168,219,618,612 /resource:../../docs/monodoc.xml,monodoc.xml /resource:Resources/base.css,base.css /resource:Resources/ecmaspec-html-css.xsl,ecmaspec-html-css.xsl /resource:Resources/ecmaspec-html.xsl,ecmaspec-html.xsl /resource:Resources/ecmaspec.css,ecmaspec.css /resource:Resources/helper.js,helper.js /resource:Resources/home.html,home.html /resource:Resources/Lminus.gif,Lminus.gif /resource:Resources/Lplus.gif,Lplus.gif /resource:Resources/creativecommons.png,creativecommons.png /resource:Resources/mdoc-html-format.xsl,mdoc-html-format.xsl /resource:Resources/mdoc-html-utils.xsl,mdoc-html-utils.xsl /resource:Resources/mdoc-sections-css.xsl,mdoc-sections-css.xsl /resource:Resources/mdoc-sections.xsl,mdoc-sections.xsl /resource:Resources/mono-ecma-css.xsl,mono-ecma-css.xsl /resource:Resources/mono-ecma-impl.xsl,mono-ecma-impl.xsl /resource:Resources/mono-ecma.css,mono-ecma.css /resource:Resources/mono-ecma.xsl,mono-ecma.xsl /resource:Resources/toc-html.xsl,toc-html.xsl /resource:Resources/images/bc_bg.png,bc_bg.png /resource:Resources/images/bc_separator.png,bc_separator.png /resource:Resources/images/error.png,error.png /resource:Resources/images/hatch.png,hatch.png /resource:Resources/images/headerbg.png,headerbg.png /resource:Resources/images/help.png,help.png /resource:Resources/images/house.png,house.png /resource:Resources/images/members.png,members.png /resource:Resources/images/namespace.png,namespace.png /resource:Resources/images/privclass.png,privclass.png /resource:Resources/images/privdelegate.png,privdelegate.png /resource:Resources/images/privenumeration.png,privenumeration.png /resource:Resources/images/privevent.png,privevent.png /resource:Resources/images/privextension.png,privextension.png /resource:Resources/images/privfield.png,privfield.png /resource:Resources/images/privinterface.png,privinterface.png /resource:Resources/images/privmethod.png,privmethod.png /resource:Resources/images/privproperty.png,privproperty.png /resource:Resources/images/privstructure.png,privstructure.png /resource:Resources/images/protclass.png,protclass.png /resource:Resources/images/protdelegate.png,protdelegate.png /resource:Resources/images/protenumeration.png,protenumeration.png /resource:Resources/images/protevent.png,protevent.png /resource:Resources/images/protextension.png,protextension.png /resource:Resources/images/protfield.png,protfield.png /resource:Resources/images/protinterface.png,protinterface.png /resource:Resources/images/protmethod.png,protmethod.png /resource:Resources/images/protproperty.png,protproperty.png /resource:Resources/images/protstructure.png,protstructure.png /resource:Resources/images/pubclass.png,pubclass.png /resource:Resources/images/pubdelegate.png,pubdelegate.png /resource:Resources/images/pubenumeration.png,pubenumeration.png /resource:Resources/images/pubevent.png,pubevent.png /resource:Resources/images/pubextension.png,pubextension.png /resource:Resources/images/pubfield.png,pubfield.png /resource:Resources/images/pubinterface.png,pubinterface.png /resource:Resources/images/pubmethod.png,pubmethod.png /resource:Resources/images/pubproperty.png,pubproperty.png /resource:Resources/images/pubstructure.png,pubstructure.png /resource:Resources/images/reference.png,reference.png /resource:Resources/images/treebg.png,treebg.png -r:./../../class/lib/net_4_x/ICSharpCode.SharpZipLib.dll -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/System.Core.dll -r:./../../class/lib/net_4_x/System.Xml.dll -r:./../../class/lib/net_4_x/System.Xml.Linq.dll -r:./../../class/lib/net_4_x/System.Configuration.dll</flags>
<output>monodoc.dll</output>
<built_sources></built_sources>
<library_output>./../../class/lib/net_4_x/monodoc.dll</library_output>
</project>
<project dir="class/monodoc" library="monodoc-tests-net_4_x">
<boot>false</boot>
- <flags>/codepage:65001 /nologo /noconfig /deterministic /nowarn:618,612,672,809 /define:LEGACY_MODE -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -r:./../../class/lib/net_4_x/monodoc.dll</flags>
+ <flags>/codepage:65001 /nologo /noconfig /deterministic /nowarn:618,612,672,809,414,649 /define:LEGACY_MODE -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -r:./../../class/lib/net_4_x/monodoc.dll</flags>
<output>net_4_x_monodoc_test.dll</output>
<built_sources></built_sources>
<library_output>net_4_x_monodoc_test.dll</library_output>
</project>
<project dir="class/Facades/System.Runtime.Serialization.Primitives" library="Facades_System.Runtime.Serialization.Primitives-net_4_x">
<boot>false</boot>
- <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize /delaysign /keyfile:../../msfinal.pub /nowarn:1616,1699 -r:./../../../class/lib/net_4_x/System.Runtime.Serialization.dll</flags>
+ <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../../class/lib/net_4_x/mscorlib.dll -optimize /delaysign /keyfile:../../msfinal.pub /nowarn:1616,1699 -r:./../../../class/lib/net_4_x/System.Runtime.Serialization.dll</flags>
<output>System.Runtime.Serialization.Primitives.dll</output>
<built_sources></built_sources>
<library_output>./../../../class/lib/net_4_x/Facades/System.Runtime.Serialization.Primitives.dll</library_output>
</project>
<project dir="class/Facades/System.Threading.Overlapped" library="Facades_System.Threading.Overlapped-net_4_x">
<boot>false</boot>
- <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize /delaysign /keyfile:../../msfinal.pub /nowarn:1616,1699 -unsafe -r:./../../../class/lib/net_4_x/System.dll</flags>
+ <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize /delaysign /keyfile:../../msfinal.pub /nowarn:1616,1699 -unsafe -nowarn:3021 -r:./../../../class/lib/net_4_x/System.dll</flags>
<output>System.Threading.Overlapped.dll</output>
<built_sources></built_sources>
<library_output>./../../../class/lib/net_4_x/Facades/System.Threading.Overlapped.dll</library_output>
<resources></resources>
<response>mdbrebase.exe.sources</response>
</project>
+ <project dir="tools/mdb2ppdb" library="mdb2ppdb-net_4_x">
+ <boot></boot>
+ <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -r:Mono.Cecil -r:Mono.Cecil.Mdb</flags>
+ <output>mdb2ppdb.exe</output>
+ <built_sources></built_sources>
+ <library_output>./../../class/lib/net_4_x/mdb2ppdb.exe</library_output>
+ <fx_version>4.5</fx_version>
+ <profile>net_4_x</profile>
+ <resources></resources>
+ <response>mdb2ppdb.exe.sources</response>
+ </project>
<project dir="tools/ikdasm" library="ikdasm-net_4_x">
<boot></boot>
<flags>/codepage:65001 /nologo /noconfig /deterministic -d:NO_SYMBOL_WRITER -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -r:System -r:System.Core -r:System.Security</flags>
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mdbrebase-net_4_x", "mcs/tools/mdbrebase/mdbrebase-net_4_x.csproj", "{01B02BFF-0DC3-4265-BFAA-EDE405950796}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mdb2ppdb-net_4_x", "mcs/tools/mdb2ppdb/mdb2ppdb-net_4_x.csproj", "{3252021D-F3DE-425F-B4A6-20B2B02EE3A4}"
+EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ikdasm-net_4_x", "mcs/tools/ikdasm/ikdasm-net_4_x.csproj", "{921F19B8-7276-446C-B096-A29AAAB83E12}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mono-symbolicate-net_4_x", "mcs/tools/mono-symbolicate/mono-symbolicate-net_4_x.csproj", "{63E373FB-CE4B-4F7B-A421-5CE8ED7BD851}"
{01B02BFF-0DC3-4265-BFAA-EDE405950796}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01B02BFF-0DC3-4265-BFAA-EDE405950796}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01B02BFF-0DC3-4265-BFAA-EDE405950796}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3252021D-F3DE-425F-B4A6-20B2B02EE3A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3252021D-F3DE-425F-B4A6-20B2B02EE3A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3252021D-F3DE-425F-B4A6-20B2B02EE3A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3252021D-F3DE-425F-B4A6-20B2B02EE3A4}.Release|Any CPU.Build.0 = Release|Any CPU
{921F19B8-7276-446C-B096-A29AAAB83E12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{921F19B8-7276-446C-B096-A29AAAB83E12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{921F19B8-7276-446C-B096-A29AAAB83E12}.Release|Any CPU.ActiveCfg = Release|Any CPU
self.ironpython = os.path.join(
self.workspace, 'ironpython', 'bin') + os.sep
self.sh(
- 'msbuild /p:Configuration=Release /p:OutDir="%{ironruby}" Solutions/Ruby.sln'
+ 'msbuild /p:Configuration=Release /p:OutDir="%{ironruby}" Solutions/Ruby.sln')
self.sh(
'msbuild /p:Configuration=Release /p:OutDir="%{ironpython}" Solutions/IronPython.Mono.sln')
print "Setting up temporary package directory:", tmpdir
# setup metadata
- self.packaging_dir = os.path.join(self.path, "packaging")
+ self.packaging_dir = os.path.join(self.directory, "packaging")
run_shell('rsync -aPq %s/* %s' % (self.packaging_dir, tmpdir), False)
packages_list = string.join(
def run_pkgbuild(self, working_dir, package_type):
print 'Running pkgbuild & productbuild...',
info = self.package_info(package_type)
- output = os.path.join(self.resource_path, info["filename"])
+ output = os.path.join(self.directory, info["filename"])
identifier = "com.xamarin.mono-" + info["type"] + ".pkg"
resources_dir = os.path.join(working_dir, "resources")
distribution_xml = os.path.join(resources_dir, "distribution.xml")
build_profiles += testing_aot_full
endif
+if INSTALL_WINAOT
+build_profiles += winaot
+endif
+
if INSTALL_XAMMAC
build_profiles += xammac xammac_net_4_5
endif
+if INSTALL_ORBIS
+build_profiles += orbis
+endif
+
test_profiles = $(build_profiles)
if BUILD_MCS
PLATFORM_PATH_SEPARATOR = :
endif
-if INSTALL_TESTING_AOT_FULL
+if FULL_AOT_TESTS
# ILASM.exe has features which a testing_aot_full runtime will not support.
# It is invoked with an external mono when used in the runtime.
# We skip it here because otherwise it will fail to verify.
-TESTING_AOT_FULL_FILTER=grep -v ilasm
+FULL_AOT_TESTS_FILTER=grep -v ilasm
else
-TESTING_AOT_FULL_FILTER=echo
+FULL_AOT_TESTS_FILTER=echo
endif
# Compile all assemblies with the verifier turned on. Code must be valid but not verifiable.
# TODO it would be nice to split assemblies without unsafe code to use the verifier with verifiable mode.
# Skip binary_reference_assemblies because they contain metadata only
mcs-compileall: mono-wrapper etc/mono/config
- export verifiable_files=`ls "$(mcs_topdir)/class/lib/$$profile/" | grep -E '\.(dll|exe)$$' | $(TESTING_AOT_FULL_FILTER)` ; \
+ export verifiable_files=`ls "$(mcs_topdir)/class/lib/$$profile/" | grep -E '\.(dll|exe)$$' | $(FULL_AOT_TESTS_FILTER)` ; \
save_MONO_PATH=$$MONO_PATH; mcs_topdir=`cd $(mcs_topdir) && $(cur_dir_cmd)`; ok=:; \
for profile in $(test_profiles); do \
if [ "binary_reference_assemblies" = "$$profile" ]; then \
--- /dev/null
+mdassembler crlf=input
+mdvalidater crlf=input
+monodocer crlf=input
+monodocs2html crlf=input
+monodocs2slashdoc crlf=input
+mono-heapviz crlf=input
+mono-package-runtime crlf=input
+mono-test-install crlf=input
mono-find-requires.in \
peverify.in \
xbuild.in \
- update_submodules \
+ update_submodules.sh \
mcs.in \
csc.in \
dmcs.in \
mono-test-install \
mono-heapviz \
$(MDOC_COMPAT) \
- get-cygwin-deps.sh \
mono-configuration-crypto.in \
submodules/versions.mk \
submodules/versions.py
elif [[ ${CI_TAGS} == *'aot_llvm'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes --with-runtime_preset=aot ";
elif [[ ${CI_TAGS} == *'fullaot'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=fullaot";
elif [[ ${CI_TAGS} == *'hybridaot'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=hybridaot";
+elif [[ ${CI_TAGS} == *'winaot'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=winaot";
elif [[ ${CI_TAGS} == *'aot'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=aot";
elif [[ ${CI_TAGS} == *'bitcode'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=bitcode";
elif [[ ${CI_TAGS} == *'interpreter'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-interpreter=yes";
EXTRA_CONF_FLAGS="$EXTRA_CONF_FLAGS --host=`/usr/bin/dpkg-architecture -qDEB_HOST_GNU_TYPE`"
#force build arch = dpkg arch, sometimes misdetected
mkdir -p ~/.config/.mono/
- wget -qO- https://download.mono-project.com/test/new-certs.tgz| tar zx -C ~/.config/.mono/
+ wget -qO- http://download.mono-project.com/test/new-certs.tgz| tar zx -C ~/.config/.mono/
fi
-
${TESTCMD} --label=configure --timeout=60m --fatal ./autogen.sh $EXTRA_CONF_FLAGS
if [[ ${label} == 'w32' ]];
then
${TESTCMD} --label=make-msvc-sgen --timeout=60m --fatal /cygdrive/c/Program\ Files\ \(x86\)/MSBuild/14.0/Bin/MSBuild.exe /p:PlatformToolset=v140 /p:Platform=${PLATFORM} /p:Configuration=Release /p:MONO_TARGET_GC=sgen msvc/mono.sln
fi
+if [[ ${CI_TAGS} == *'winaot'* ]];
+ then
+ # The AOT compiler on Windows requires Visual Studio's clang.exe and link.exe in $PATH
+ # and we must make sure Visual Studio's link.exe comes before Cygwin's link.exe
+ VC_ROOT="/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC"
+ export PATH="$VC_ROOT/ClangC2/bin/amd64:$VC_ROOT/bin/amd64":$PATH
+fi
+
if [[ ${CI_TAGS} == *'monolite'* ]]; then make get-monolite-latest; fi
make_parallelism=-j4
elif [[ ${CI_TAGS} == *'interpreter'* ]];
then
$(dirname "${BASH_SOURCE[0]}")/run-test-interpreter.sh
+elif [[ ${CI_TAGS} == *'mcs-compiler'* ]];
+ then
+ $(dirname "${BASH_SOURCE[0]}")/run-test-mcs.sh
elif [[ ${CI_TAGS} == *'no-tests'* ]];
then
exit 0
then ${TESTCMD} --label=aot-test --skip;
else ${TESTCMD} --label=aot-test --timeout=30m make -w -C mono/tests -j4 -k test-aot
fi
-${TESTCMD} --label=compile-runtime-tests --timeout=20m make -w -C mono/tests -j4 tests
+${TESTCMD} --label=compile-runtime-tests --timeout=40m make -w -C mono/tests -j4 tests
${TESTCMD} --label=runtime --timeout=160m make -w -C mono/tests -k test-wrench V=1 CI=1 CI_PR=${ghprbPullId}
${TESTCMD} --label=runtime-unit-tests --timeout=5m make -w -C mono/unit-tests -k check
if [[ ${label} == 'debian-8-ppc64el' ]]; then ${TESTCMD} --label=corlib --skip; else ${TESTCMD} --label=corlib --timeout=30m make -w -C mcs/class/corlib run-test; fi
--- /dev/null
+#!/bin/bash -e
+
+${TESTCMD} --label=mcs-tests --timeout=30m make -w -C mcs/tests run-test
+${TESTCMD} --label=mcs-errors --timeout=10m make -w -C mcs/errors run-test
--- /dev/null
+#!/bin/bash -e
+
+if test -n "${MONO_LLVMONLY}";
+then
+${TESTCMD} --label=mini --timeout=25m make -j 4 -w -C mono/mini -k llvmonlycheck
+else
+${TESTCMD} --label=mini --timeout=25m make -j 4 -w -C mono/mini -k fullaotcheck
+fi
+
+${TESTCMD} --label=runtime --timeout=160m make -w -C mono/tests -k test-wrench V=1 CI=1
+${TESTCMD} --label=corlib --timeout=30m make -w -C mcs/class/corlib run-test
+${TESTCMD} --label=verify --timeout=15m make -w -C runtime mcs-compileall
+${TESTCMD} --label=profiler --timeout=30m make -w -C mono/profiler -k check
+${TESTCMD} --label=System --timeout=10m make -w -C mcs/class/System run-test
+${TESTCMD} --label=System.XML --timeout=5m make -w -C mcs/class/System.XML run-test
+${TESTCMD} --label=Mono.Security --timeout=5m make -w -C mcs/class/Mono.Security run-test
+${TESTCMD} --label=System.Data --timeout=5m make -w -C mcs/class/System.Data run-test
+${TESTCMD} --label=System.Web.Services --timeout=5m make -w -C mcs/class/System.Web.Services run-test
+${TESTCMD} --label=I18N.CJK --timeout=5m make -w -C mcs/class/I18N/CJK run-test
+${TESTCMD} --label=I18N.West --timeout=5m make -w -C mcs/class/I18N/West run-test
+${TESTCMD} --label=I18N.MidEast --timeout=5m make -w -C mcs/class/I18N/MidEast run-test
+${TESTCMD} --label=System.Transactions --timeout=5m make -w -C mcs/class/System.Transactions run-test
+${TESTCMD} --label=System.Core --timeout=15m make -w -C mcs/class/System.Core run-test
+${TESTCMD} --label=System.Xml.Linq --timeout=5m make -w -C mcs/class/System.Xml.Linq run-test
+${TESTCMD} --label=System.Runtime.Serialization --timeout=5m make -w -C mcs/class/System.Runtime.Serialization run-test
+${TESTCMD} --label=System.ServiceModel --timeout=15m make -w -C mcs/class/System.ServiceModel run-test
+${TESTCMD} --label=System.ServiceModel.Web --timeout=5m make -w -C mcs/class/System.ServiceModel.Web run-test
+${TESTCMD} --label=System.ComponentModel.DataAnnotations --timeout=5m make -w -C mcs/class/System.ComponentModel.DataAnnotations run-test
+${TESTCMD} --label=Mono.CSharp --timeout=5m make -w -C mcs/class/Mono.CSharp run-test
+${TESTCMD} --label=System.Numerics --timeout=5m make -w -C mcs/class/System.Numerics run-test
+${TESTCMD} --label=System.Net.Http --timeout=5m make -w -C mcs/class/System.Net.Http run-test
+${TESTCMD} --label=System.Json --timeout=5m make -w -C mcs/class/System.Json run-test
+
+rm -fr /tmp/jenkins-temp-aspnet*
#!/bin/sh
-exec @bindir@/mono $MONO_OPTIONS @mono_instdir@/4.5/csc.exe "$@"
+exec @bindir@/mono --gc-params=nursery-size=64m $MONO_OPTIONS @mono_instdir@/4.5/csc.exe "$@"
+++ /dev/null
-#!/bin/bash
-
-#
-# This script will download and install the dependencies needed for compiling
-# mono on cygwin
-#
-
-# Check for required packages
-
-commands="wget unzip automake autoconf libtool make bison"
-
-failed=0
-for i in $commands; do
- if ! which $i > /dev/null 2>&1; then
- echo "You must have the '$i' package installed."
- failed=1
- fi
-done
-
-if [ $failed = 1 ]; then
- exit 1
-fi
-
-dir=cygwin-deps
-mkdir -p $dir
-
-echo -n "Downloading deps... "
-if [ ! -f $dir/gettext-runtime-0.17-1.zip ]; then
- wget -P $dir http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime-0.17-1.zip
-fi
-if [ ! -f $dir/libiconv-1.13-mingw32-dev.tar.gz ]; then
- wget -P $dir http://sourceforge.net/projects/mingw/files/MinGW/libiconv/libiconv-1.13/libiconv-1.13-mingw32-dev.tar.gz/download
-fi
-echo "done."
-
-echo -n "Extracting to cygwin-deps/ ..."
-(cd $dir && for i in *.zip; do unzip -oq $i || exit 1; done) || exit 1
-# This is needed because windows can't use dll's without an x flag.
-chmod a+x $dir/bin/*.dll
-echo "done."
-
-echo -n "Patching PC files... "
-prefix=$PWD/$dir
-find $dir -name "*.pc" > $dir/pc-files
-for i in `cat $dir/pc-files`; do
- (sed -e "s,^prefix=.*,prefix=$prefix,g" < $i > $i.tmp && mv $i.tmp $i) || exit 1
-done
-rm -f $dir/pc-files
-echo "done."
-
-# Create an environment shell file
-rm -f $dir/env.sh
-echo "export PKG_CONFIG_PATH=\"$PWD/$dir/lib/pkgconfig:\$PKG_CONFIG\"" >> $dir/env.sh
-echo "export PATH=\"$PWD/$dir/bin:\$PATH\"" >> $dir/env.sh
-
-echo "Source $dir/env.sh into your environment using:"
-echo ". $dir/env.sh"
-echo "Then run mono's configure."
if (last == NULL){
fprintf (stderr, "Do not know how to invoke the program given [%s]\n", argv [0]);
+ free (nargv);
return 1;
}
len = strlen (last) + strlen (PROFILE_BASE_DIR) + 1;
command = malloc (len);
if (command == NULL){
fprintf (stderr, "Error allocating memory");
+ free (nargv);
return 1;
}
strcpy (command, PROFILE_BASE_DIR);
+++ /dev/null
-SUBMODULE_ERROR='Could not recursively update all git submodules. You may experience compilation problems if some submodules are out of date'
-SUBMODULE_OK='Git submodules updated successfully'
-if test -d .git; then \
- (git submodule update --init --recursive && echo $SUBMODULE_OK) \
- || (git submodule init && git submodule update --recursive && echo $SUBMODULE_OK) \
- || (git submodule init && git submodule update && echo $SUBMODULE_ERROR) \
- || (echo 'Git submodules could not be updated. Compilation will fail') \
-fi
-
--- /dev/null
+#!/bin/sh
+SUBMODULE_ERROR='Could not recursively update all git submodules. You may experience compilation problems if some submodules are out of date'
+SUBMODULE_OK='Git submodules updated successfully'
+if test -d .git; then \
+ (git submodule update --init --recursive && echo $SUBMODULE_OK) \
+ || (git submodule init && git submodule update --recursive && echo $SUBMODULE_OK) \
+ || (git submodule init && git submodule update && echo $SUBMODULE_ERROR) \
+ || (echo 'Git submodules could not be updated. Compilation will fail') \
+fi
+
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <fcntl.h>
#include <errno.h>
+#ifdef HOST_WIN32
+#include <corecrt_io.h>
+#endif
#include "map.h"
#include "mph.h"
G_BEGIN_DECLS
+#ifndef HOST_WIN32
gint32
Mono_Posix_Syscall_fcntl (gint32 fd, gint32 cmd)
{
return r;
}
+#endif
gint32
Mono_Posix_Syscall_open (const char *pathname, gint32 flags)
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
+ if (strm == Z_NULL || strm->state == Z_NULL) return -(1L << 16);
state = (struct inflate_state FAR *)strm->state;
return ((long)(state->back) << 16) +
(state->mode == COPY ? state->length :
int Mono_Posix_FromSeekFlags (short x, short *r)
{
*r = 0;
-#ifdef L_INCR
if (x == Mono_Posix_SeekFlags_L_INCR)
+#ifdef L_INCR
{*r = L_INCR; return 0;}
-#endif /* def L_INCR */
-#ifdef L_SET
+#else /* def L_INCR */
+ {errno = EINVAL; return -1;}
+#endif /* ndef L_INCR */
if (x == Mono_Posix_SeekFlags_L_SET)
+#ifdef L_SET
{*r = L_SET; return 0;}
-#endif /* def L_SET */
-#ifdef L_XTND
+#else /* def L_SET */
+ {errno = EINVAL; return -1;}
+#endif /* ndef L_SET */
if (x == Mono_Posix_SeekFlags_L_XTND)
+#ifdef L_XTND
{*r = L_XTND; return 0;}
-#endif /* def L_XTND */
-#ifdef SEEK_CUR
+#else /* def L_XTND */
+ {errno = EINVAL; return -1;}
+#endif /* ndef L_XTND */
if (x == Mono_Posix_SeekFlags_SEEK_CUR)
+#ifdef SEEK_CUR
{*r = SEEK_CUR; return 0;}
-#endif /* def SEEK_CUR */
-#ifdef SEEK_END
+#else /* def SEEK_CUR */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SEEK_CUR */
if (x == Mono_Posix_SeekFlags_SEEK_END)
+#ifdef SEEK_END
{*r = SEEK_END; return 0;}
-#endif /* def SEEK_END */
-#ifdef SEEK_SET
+#else /* def SEEK_END */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SEEK_END */
if (x == Mono_Posix_SeekFlags_SEEK_SET)
+#ifdef SEEK_SET
{*r = SEEK_SET; return 0;}
-#endif /* def SEEK_SET */
+#else /* def SEEK_SET */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SEEK_SET */
+ if (x == 0)
+ return 0;
errno = EINVAL; return -1;
}
int Mono_Posix_ToSeekFlags (short x, short *r)
{
*r = 0;
+ if (x == 0)
+ return 0;
#ifdef L_INCR
if (x == L_INCR)
{*r = Mono_Posix_SeekFlags_L_INCR; return 0;}
# endif
#endif /* !defined(EOVERFLOW) */
-#if !defined (HOST_WIN32)
-
/*
- * Solaris doesn't define these BSD values, and if they're not present then
- * map.c:Mono_Posix_FromSeekFlags() breaks badly; see:
+ * Solaris/Windows don't define these BSD values, and if they're not present
+ * then map.c:Mono_Posix_FromSeekFlags() breaks badly; see:
* http://bugzilla.gnome.org/show_bug.cgi?id=370081
*/
#define L_XTND SEEK_END
#endif /* ndef L_XTND */
+#if !defined (HOST_WIN32)
+
/*
* OS X doesn't define MAP_ANONYMOUS, but it does define MAP_ANON.
* Alias them to fix: https://bugzilla.xamarin.com/show_bug.cgi?id=3419
G_BEGIN_DECLS
-#ifndef HOST_WIN32
gint32
Mono_Posix_Syscall_L_ctermid (void)
{
+#ifndef HOST_WIN32
return L_ctermid;
+#else
+ return -1;
+#endif
}
gint32
Mono_Posix_Syscall_L_cuserid (void)
{
-#if defined(__APPLE__) || defined (__OpenBSD__)
+#if defined(__APPLE__) || defined (__OpenBSD__) || defined (HOST_WIN32)
return -1;
#else
return L_cuserid;
#endif
}
-#endif /* ndef HOST_WIN32 */
mph_size_t
Mono_Posix_Stdlib_fread (unsigned char *ptr, mph_size_t size, mph_size_t nmemb, void *stream)
#include "mono/metadata/class.h"
#include "mono/metadata/object.h"
#include "mono/metadata/tabledefs.h"
-#include "mono/io-layer/wapi.h"
typedef struct {
const char *fname;
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <fcntl.h>
#include <errno.h>
to->st_gid = from->st_gid;
to->st_rdev = from->st_rdev;
to->st_size = from->st_size;
+#ifndef HOST_WIN32
to->st_blksize = from->st_blksize;
to->st_blocks = from->st_blocks;
+#endif
to->st_atime = from->st_atime_;
to->st_mtime = from->st_mtime_;
to->st_ctime = from->st_ctime_;
to->st_gid = from->st_gid;
to->st_rdev = from->st_rdev;
to->st_size = from->st_size;
+#ifndef HOST_WIN32
to->st_blksize = from->st_blksize;
to->st_blocks = from->st_blocks;
+#endif
to->st_atime_ = from->st_atime;
to->st_mtime_ = from->st_mtime;
to->st_ctime_ = from->st_ctime;
return r;
}
+#ifndef HOST_WIN32
gint32
Mono_Posix_Syscall_lstat (const char *file_name, struct Mono_Posix_Stat *buf)
{
r = -1;
return r;
}
+#endif
#ifdef HAVE_FSTATAT
gint32
}
#endif
+#ifndef HOST_WIN32
gint32
Mono_Posix_Syscall_mknod (const char *pathname, guint32 mode, mph_dev_t dev)
{
return -1;
return mknod (pathname, mode, dev);
}
+#endif
#ifdef HAVE_MKNODAT
gint32
#endif
}
+#if defined(HAVE_FUTIMENS) || defined(HAVE_UTIMENSAT)
static inline struct timespec*
copy_utimens (struct timespec* to, struct Mono_Posix_Timespec *from)
{
return NULL;
}
+#endif
#ifdef HAVE_FUTIMENS
gint32
else
static_libs= \
$(top_builddir)/mono/metadata/libmonoruntimesgen-static.la \
- $(top_builddir)/mono/io-layer/libwapi.la \
$(top_builddir)/mono/utils/libmonoutils.la \
$(GLIB_LIBS) $(LIBICONV) \
$(LIBGC_STATIC_LIBS)
--- /dev/null
+SOURCES = \
+ nuget-hash-extractor.cs
+
+nuget-hash-extractor.exe: $(SOURCES)
+ mcs /r:System.Xml.Linq /r:System.IO.Compression -o:nuget-hash-extractor.exe $(SOURCES)
+
+download:
+ echo "Downloading all the nugets"; \
+ ./download.sh
+
+run: nuget-hash-extractor.exe
+ mono nuget-hash-extractor.exe nugets
+.PHONY: download run
--- /dev/null
+mkdir nugets
+
+#System.Runtime.InteropServices.RuntimeInformation
+wget https://www.nuget.org/api/v2/package/System.Runtime.InteropServices.RuntimeInformation/4.3.0 -O nugets/system.runtime.interopservices.runtimeinformation.4.3.0.nupkg
+wget https://www.nuget.org/api/v2/package/System.Runtime.InteropServices.RuntimeInformation/4.0.0 -O nugets/system.runtime.interopservices.runtimeinformation.4.0.0.nupkg
+
+#System.Globalization.Extensions
+wget https://www.nuget.org/api/v2/package/System.Globalization.Extensions/4.3.0 -O nugets/system.globalization.extensions.4.3.0.nupkg
+wget https://www.nuget.org/api/v2/package/System.Globalization.Extensions/4.0.1 -O nugets/system.globalization.extensions.4.0.1.nupkg
+wget https://www.nuget.org/api/v2/package/System.Globalization.Extensions/4.0.0 -O nugets/system.globalization.extensions.4.0.0.nupkg
+
+#System.IO.Compression
+wget https://www.nuget.org/api/v2/package/System.IO.Compression/4.3.0 -O nugets/system.io.compression.4.3.0.nupkg
+wget https://www.nuget.org/api/v2/package/System.IO.Compression/4.1.0 -O nugets/system.io.compression.4.1.0.nupkg
+wget https://www.nuget.org/api/v2/package/System.IO.Compression/4.0.0 -O nugets/system.io.compression.4.0.0.nupkg
+
+#System.Net.Http
+wget https://www.nuget.org/api/v2/package/System.Net.Http/4.3.0 -O nugets/system.net.http.4.3.0.nupkg
+wget https://www.nuget.org/api/v2/package/System.Net.Http/4.1.1 -O nugets/system.net.http.4.1.1.nupkg
+wget https://www.nuget.org/api/v2/package/System.Net.Http/4.1.0 -O nugets/system.net.http.4.1.0.nupkg
+wget https://www.nuget.org/api/v2/package/System.Net.Http/4.0.0 -O nugets/system.net.http.4.0.0.nupkg
+
+#System.Text.Encoding.CodePages
+wget https://www.nuget.org/api/v2/package/System.Text.Encoding.CodePages/4.3.0 -O nugets/system.text.encoding.codepages.4.3.0.nupkg
+wget https://www.nuget.org/api/v2/package/System.Text.Encoding.CodePages/4.0.1 -O nugets/system.text.encoding.codepages.4.0.1.nupkg
+wget https://www.nuget.org/api/v2/package/System.Text.Encoding.CodePages/4.0.0 -O nugets/system.text.encoding.codepages.4.0.0.nupkg
+
+#System.Reflection.DispatchProxy
+wget https://www.nuget.org/api/v2/package/System.Reflection.DispatchProxy/4.3.0 -O nugets/system.reflection.dispatchproxy.4.3.0.nupkg
+wget https://www.nuget.org/api/v2/package/System.Reflection.DispatchProxy/4.0.1 -O nugets/system.reflection.dispatchproxy.4.0.1.nupkg
+wget https://www.nuget.org/api/v2/package/System.Reflection.DispatchProxy/4.0.0 -O nugets/system.reflection.dispatchproxy.4.0.0.nupkg
+
+#System.ValueTuple
+wget https://www.nuget.org/api/v2/package/System.ValueTuple/4.3.0 -O nugets/system.valuetuple.4.3.0.nupkg
+
+#System.Security.Cryptography.OpenSsl when .net 4.6.2 + 1 is out
\ No newline at end of file
--- /dev/null
+using System;
+using System.Xml.Linq;
+using System.Linq;
+using System.IO;
+using System.IO.Compression;
+using System.Reflection;
+
+class Driver {
+ static ZipArchiveEntry FindSpecFile (ZipArchive zip) {
+ foreach (var entry in zip.Entries) {
+ if (entry.Name.EndsWith (".nuspec"))
+ return entry;
+ }
+ throw new Exception ("Could not find nuspec file");
+ }
+
+ static void DumpNuget (string nupkg) {
+ var zip = new ZipArchive(new FileStream (nupkg, FileMode.Open));
+
+ var nuspec = FindSpecFile (zip);
+ var l = XElement.Load (new StreamReader (nuspec.Open ()));
+ var version = (from el in l.Descendants() where el.Name.LocalName == "version" select el.Value).FirstOrDefault ();
+
+ //
+ // Logic copied from https://github.com/NuGet/NuGet.Client/blob/4cccb13833ad29d6a0bcff055460d964f1b49cfe/src/NuGet.Core/NuGet.Frameworks/DefaultFrameworkMappings.cs#L385
+ //
+ var entries = from e in zip.Entries where e.FullName.StartsWith ("lib/net4") && e.Name.EndsWith (".dll") select e;
+ if (!entries.Any ()) {
+ entries = from e in zip.Entries where e.FullName.StartsWith ("lib/netstandard1") && e.Name.EndsWith (".dll") select e;
+ }
+
+ foreach (var et in entries) {
+ LoadAndDump (et, version);
+ }
+ }
+ static void Main (string[] args) {
+ foreach (var f in Directory.GetFiles (args [0], "*.nupkg")) {
+ DumpNuget (f);
+ }
+ }
+
+ static byte[] StreamToArray (Stream s) {
+ using(var ms = new MemoryStream ()) {
+ s.CopyTo (ms);
+ return ms.ToArray ();
+ }
+ }
+
+ static int domain_id = 1;
+ static void LoadAndDump (ZipArchiveEntry entry, string version) {
+ // Console.WriteLine ("Dumping {0}", entry);
+ var data = StreamToArray (entry.Open ());
+ AppDomain ad = AppDomain.CreateDomain ("parse_" + ++domain_id);
+ DoParse p = (DoParse)ad.CreateInstanceAndUnwrap (typeof (DoParse).Assembly.FullName, typeof (DoParse).FullName);
+ p.ParseAssembly (data, version, entry.Name, entry.FullName);
+ AppDomain.Unload (ad);
+ }
+}
+
+class DoParse : MarshalByRefObject {
+ static int Hash (string str) {
+ int h = 5381;
+ for (int i = 0; i < str.Length; ++i)
+ h = ((h << 5) + h) ^ str[i];
+ return h;
+ }
+ static string FileToEnum (string name) {
+ switch (name) {
+ case "System.Runtime.InteropServices.RuntimeInformation.dll": return "SYS_RT_INTEROP_RUNTIME_INFO";
+ case "System.Globalization.Extensions.dll": return "SYS_GLOBALIZATION_EXT";
+ case "System.IO.Compression.dll": return "SYS_IO_COMPRESSION";
+ case "System.Net.Http.dll": return "SYS_NET_HTTP";
+ case "System.Text.Encoding.CodePages.dll": return "SYS_TEXT_ENC_CODEPAGES";
+ case "System.Reflection.DispatchProxy.dll": return "SYS_REF_DISP_PROXY";
+ case "System.ValueTuple.dll": return "SYS_VALUE_TUPLE";
+ default: throw new Exception ($"No idea what to do with {name}");
+ }
+ }
+
+ static string FileToMoniker (string p) {
+ var parts = p.Split (Path.DirectorySeparatorChar);
+ return parts[parts.Length - 2];
+ }
+
+ public void ParseAssembly (byte[] data, string version, string name, string fullname) {
+ var a = Assembly.ReflectionOnlyLoad (data);
+ var m = a.GetModules ()[0];
+ var id = m.ModuleVersionId.ToString ().ToUpper ();
+ var hash_code = Hash (id).ToString ("X");
+ var str = FileToEnum (name);
+
+ string ver_str = version + " " + FileToMoniker (fullname);
+ Console.WriteLine ($"IGNORED_ASSEMBLY (0x{hash_code}, {str}, \"{id}\", \"{ver_str}\"),");
+ }
+}
\ No newline at end of file
pedump_LDADD = \
$(top_builddir)/mono/metadata/libmonoruntimesgen-static.la \
$(top_builddir)/mono/sgen/libmonosgen-static.la \
- $(top_builddir)/mono/io-layer/libwapi.la \
$(top_builddir)/mono/utils/libmonoutils.la \
$(LLVM_LIBS) \
$(LLVM_LDFLAGS) \
#include "sgen-entry-stream.h"
#include "sgen-grep-binprot.h"
+static int file_version = 0;
+
#ifdef BINPROT_HAS_HEADER
#define PACKED_SUFFIX p
#else
#define MAX_ENTRY_SIZE (1 << 10)
static int
-read_entry (EntryStream *stream, void *data)
+read_entry (EntryStream *stream, void *data, unsigned char *windex)
{
unsigned char type;
ssize_t size;
if (read_stream (stream, &type, 1) <= 0)
return SGEN_PROTOCOL_EOF;
+
+ if (windex) {
+ if (file_version >= 2) {
+ if (read_stream (stream, windex, 1) <= 0)
+ return SGEN_PROTOCOL_EOF;
+ } else {
+ *windex = !!(WORKER (type));
+ }
+ }
+
switch (TYPE (type)) {
#define BEGIN_PROTOCOL_ENTRY0(method) \
}
}
-#define WORKER_PREFIX(t) (WORKER ((t)) ? "w" : " ")
-
enum { NO_COLOR = -1 };
typedef struct {
}
static void
-print_entry (int type, void *data, int num_nums, int *match_indices, gboolean color_output)
+print_entry (int type, void *data, int num_nums, int *match_indices, gboolean color_output, unsigned char worker_index)
{
const char *always_prefix = is_always_match (type) ? " " : "";
- printf ("%s%s ", WORKER_PREFIX (type), always_prefix);
+ if (worker_index)
+ printf ("w%-2d%s ", worker_index, always_prefix);
+ else
+ printf (" %s ", always_prefix);
switch (TYPE (type)) {
{
#ifdef BINPROT_HAS_HEADER
char data [MAX_ENTRY_SIZE];
- int type = read_entry (stream, data);
+ int type = read_entry (stream, data, NULL);
if (type == SGEN_PROTOCOL_EOF)
return FALSE;
if (type == PROTOCOL_ID (binary_protocol_header)) {
PROTOCOL_STRUCT (binary_protocol_header) * str = (PROTOCOL_STRUCT (binary_protocol_header) *) data;
- if (str->check == PROTOCOL_HEADER_CHECK && str->ptr_size == BINPROT_SIZEOF_VOID_P)
+ if (str->check == PROTOCOL_HEADER_CHECK && str->ptr_size == BINPROT_SIZEOF_VOID_P) {
+ if (str->version > PROTOCOL_HEADER_VERSION) {
+ fprintf (stderr, "The file contains a newer version %d. We support up to %d. Please update.\n", str->version, PROTOCOL_HEADER_VERSION);
+ exit (1);
+ }
+ file_version = str->version;
return TRUE;
+ }
}
return FALSE;
#else
gboolean dump_all, gboolean pause_times, gboolean color_output, unsigned long long first_entry_to_consider)
{
int type;
+ unsigned char worker_index;
void *data = g_malloc0 (MAX_ENTRY_SIZE);
int i;
gboolean pause_times_stopped = FALSE;
return FALSE;
entry_index = 0;
- while ((type = read_entry (stream, data)) != SGEN_PROTOCOL_EOF) {
+ while ((type = read_entry (stream, data, &worker_index)) != SGEN_PROTOCOL_EOF) {
if (entry_index < first_entry_to_consider)
goto next_entry;
if (pause_times) {
if (dump_all)
printf (match ? "* " : " ");
if (match || dump_all)
- print_entry (type, data, num_nums, match_indices, color_output);
+ print_entry (type, data, num_nums, match_indices, color_output, worker_index);
}
next_entry:
++entry_index;