Skip to content
Browse files

This commit was manufactured by cvs2svn to create tag 'MONO_1_0_3'.

svn path=/tags/MONO_1_0_3/mono/; revision=34825
  • Loading branch information...
16 parents 26c7b44 + 3e535bd + de4717d + e185d54 + 99a49e2 + 06aeb1a + e297e11 + a76eee5 + 7cebe70 + 2cf6798 + 152ab7f + 254baa7 + 05e78aa + e51d417 + c5f92ee + 643ff4c commit 13f4c1a27734a2815a42d3f8826dedfee4744fd1 nobody committed Oct 8, 2004
Showing with 2,825 additions and 1,525 deletions.
  1. +34 −0 ChangeLog
  2. +102 −10 configure.in
  3. +0 −246 doc/pending-classes.in
  4. +1 −0 mono/dis/get.c
  5. +6 −0 mono/interpreter/ChangeLog
  6. +1 −1 mono/interpreter/interp.c
  7. +10 −0 mono/interpreter/mintops.h
  8. +113 −0 mono/io-layer/ChangeLog
  9. +35 −27 mono/io-layer/daemon.c
  10. +8 −0 mono/io-layer/error.c
  11. +80 −0 mono/io-layer/handles-private.h
  12. +141 −25 mono/io-layer/handles.c
  13. +1 −5 mono/io-layer/io-private.h
  14. +564 −131 mono/io-layer/io.c
  15. +18 −2 mono/io-layer/mutexes.c
  16. +1 −1 mono/io-layer/socket-private.h
  17. +174 −207 mono/io-layer/sockets.c
  18. +9 −3 mono/io-layer/threads.c
  19. +2 −0 mono/io-layer/timed-thread.c
  20. +9 −3 mono/io-layer/wait.c
  21. +15 −1 mono/io-layer/wapi-private.h
  22. +214 −1 mono/metadata/ChangeLog
  23. +34 −12 mono/metadata/appdomain.c
  24. +12 −2 mono/metadata/assembly.c
  25. +1 −1 mono/metadata/class.c
  26. +227 −223 mono/metadata/culture-info-tables.h
  27. +29 −8 mono/metadata/debug-mono-symfile.c
  28. +9 −4 mono/metadata/filewatcher.c
  29. +60 −12 mono/metadata/gc.c
  30. +17 −4 mono/metadata/image.c
  31. +54 −16 mono/metadata/loader.c
  32. +12 −10 mono/metadata/locales.c
  33. +184 −71 mono/metadata/marshal.c
  34. +55 −51 mono/metadata/metadata.c
  35. +49 −17 mono/metadata/mono-debug.c
  36. +25 −14 mono/metadata/object.c
  37. +6 −0 mono/metadata/object.h
  38. +4 −2 mono/metadata/process.c
  39. +45 −3 mono/metadata/reflection.c
  40. +1 −0 mono/metadata/reflection.h
  41. +51 −1 mono/metadata/socket-io.c
  42. +14 −1 mono/metadata/socket-io.h
  43. +35 −10 mono/metadata/threadpool.c
  44. +0 −5 mono/metadata/threads.c
  45. +69 −0 mono/mini/ChangeLog
  46. +6 −0 mono/mini/basic-long.cs
  47. +2 −0 mono/mini/cpu-g4.md
  48. +2 −0 mono/mini/cpu-pentium.md
  49. +2 −0 mono/mini/cpu-s390.md
  50. +2 −0 mono/mini/cpu-sparc.md
  51. +3 −3 mono/mini/exceptions-x86.c
  52. +19 −4 mono/mini/inssel-long32.brg
  53. +10 −10 mono/mini/inssel-ppc.brg
  54. +2 −0 mono/mini/inssel-x86.brg
  55. +8 −1 mono/mini/inssel.brg
  56. +2 −0 mono/mini/mini-ops.h
  57. +23 −8 mono/mini/mini-ppc.c
  58. +4 −0 mono/mini/mini-s390.c
  59. +3 −0 mono/mini/mini-sparc.c
  60. +4 −0 mono/mini/mini-x86.c
  61. +77 −25 mono/mini/mini.c
  62. +1 −0 mono/mini/mini.h
  63. +6 −0 mono/tests/ChangeLog
  64. +1 −0 mono/tests/Makefile.am
  65. +40 −0 mono/tests/libtest.c
  66. +18 −0 mono/tests/pinvoke2.cs
  67. +14 −0 mono/tests/pinvoke3.cs
  68. +26 −0 mono/tests/typeof-ptr.cs
  69. +6 −0 tools/locale-builder/supp/ChangeLog
  70. +12 −0 tools/locale-builder/supp/pt.xml
  71. +1 −1 tools/locale-builder/supp/pt_BR.xml
  72. +0 −246 web/pending-classes.in
  73. +0 −1 web/web/masterinfos/.cvsignore
  74. +0 −96 web/web/masterinfos/Makefile
View
34 ChangeLog
@@ -1,3 +1,37 @@
+2004-09-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * configure.in: added check for kqueue. Patch from Geoff Norton
+ in HEAD.
+
+2004-08-17 Dick Porter <dick@ximian.com>
+
+ * configure.in: Correct intl library for FreeBSD and OpenBSD.
+ Fixes bug 62884, patch by Tom McLaughlin (tmclaugh@sdf.lonestar.org).
+
+2004-07-27 John Merryweather Cooper <john_m_cooper@yahoo.com>
+ * configure.in: Disable __thread test (TLS) for FreeBSD as
+ it succeeds on FreeBSD 5.x when it should fail. Fix pthread
+ library detection for FreeBSD 4.x since pthread is embedded
+ in libc_r on this platform. Fix some typos in my host
+ regexes for freebsd.
+
+2004-07-23 Dick Porter <dick@ximian.com>
+
+ * configure.in: Changes for FreeBSD thread support by John
+ Merryweather Cooper <john_m_cooper@yahoo.com>.
+
+2004-07-03 Zoltan Varga <vargaz@freemail.hu>
+
+ * configure.in: Add --with-tls option to replace the misnamed
+ --with-nptl option.
+
+2004-06-30 Zoltan Varga <vargaz@freemail.hu>
+
+ * configure.in: Fix trunc check + add SPARC64 defines.
+
+ * marshal.c (mono_marshal_get_managed_wrapper): Handle returning
+ delegates from a delegate. Fixes #61033.
+
2004-06-29 Jackson Harper <jackson@ximian.com>
* man/gacutil.1: Update man with new command line options.
View
112 configure.in
@@ -1,7 +1,7 @@
AC_INIT(README)
AC_CANONICAL_SYSTEM
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(mono,1.0)
+AM_INIT_AUTOMAKE(mono,1.0.3)
AM_MAINTAINER_MODE
AC_PROG_LN_S
@@ -67,7 +67,62 @@ case "$host" in
libdl=
libgc_threads=no
;;
- *-*-*freebsd*|*-*-*openbsd*)
+# these flags will work for all versions of -STABLE
+#
+ *-*-*freebsd4*)
+ platform_win32=no
+ if test "x$PTHREAD_CFLAGS" = "x"; then
+ CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS"
+ libmono_cflags="-D_THREAD_SAFE"
+ else
+ CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
+ libmono_cflags="$PTHREAD_CFLAGS"
+ fi
+ if test "x$PTHREAD_LIBS" = "x"; then
+ LDFLAGS="$LDFLAGS -pthread"
+ libmono_ldflags="-pthread"
+ else
+ LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
+ libmono_ldflags="$PTHREAD_LIBS"
+ fi
+ need_link_unlink=yes
+ AC_DEFINE(PTHREAD_POINTER_ID)
+ libdl=
+ libgc_threads=pthreads
+# TLS isn't implemented at all on -STABLE
+ with_nptl=no
+ with_tls=pthread
+ ;;
+# older versions of -CURRENT will break with these flags but testing
+# indicates these older versions won't run Mono anyway
+#
+ *-*-*freebsd5*)
+ platform_win32=no
+ if test "x$PTHREAD_CFLAGS" = "x"; then
+ CPPFLAGS="$CPPFLAGS -DGC_FREEBSD_THREADS"
+ libmono_cflags=
+ else
+ CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
+ libmono_cflags="$PTHREAD_CFLAGS"
+ fi
+ if test "x$PTHREAD_LIBS" = "x"; then
+ LDFLAGS="$LDFLAGS -lpthread"
+ libmono_ldflags="-lpthread"
+ else
+ LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
+ libmono_ldflags="$PTHREAD_LIBS"
+ fi
+ need_link_unlink=yes
+ AC_DEFINE(PTHREAD_POINTER_ID)
+ libdl=
+ libgc_threads=pthreads
+# TLS is only partially implemented on -CURRENT (compiler support
+# but NOT library support)
+#
+ with_nptl=no
+ with_tls=pthread
+ ;;
+ *-*-*openbsd*)
platform_win32=no
CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS"
libmono_cflags="-D_THREAD_SAFE"
@@ -248,9 +303,21 @@ AC_ARG_WITH(gc, [ --with-gc=boehm,included,none],[gc=$with_gc],[gc=$gc_default]
# Enable support for fast thread-local storage
# Some systems have broken support, so we allow to disable it.
-# This is misnamed: __thread support has no relation to NPTL,
-# but people already use it...
-AC_ARG_WITH(nptl, [ --with-nptl=yes,no enable/disable support for __thread support],[],[with_nptl=yes])
+AC_ARG_WITH(tls, [ --with-tls=__thread,pthread select Thread Local Storage implementation],[],[with_tls=__thread])
+
+# Kept for compatibility
+AC_ARG_WITH(nptl, [ --with-nptl=yes,no deprecated, use --with-tls instead],[],[with_nptl=default])
+
+if test "x$with_nptl" != "xdefault"; then
+ if test "x$with_nptl" = "xyes"; then
+ AC_MSG_WARN([--with-nptl=yes is deprecated, use --with-tls=__thread option instead.])
+ with_tls=__thread
+ fi
+ if test "x$with_nptl" = "xno"; then
+ AC_MSG_WARN([--with-nptl=no is deprecated, use --with-tls=pthread option instead.])
+ with_tls=pthread
+ fi
+fi
# Enable support for using sigaltstack for SIGSEGV and stack overflow handling
# This does not work on some platforms (bug #55253)
@@ -399,6 +466,7 @@ if test x$platform_win32 = xno; then
AC_CHECK_FUNCS(getpwuid_r)
AC_CHECK_FUNCS(getresuid)
AC_CHECK_FUNCS(setresuid)
+ AC_CHECK_FUNCS(kqueue)
dnl ******************************************************************
dnl *** Check for large file support ***
@@ -641,7 +709,17 @@ if test x$platform_win32 = xno; then
dnl *****************************
dnl *** Checks for libpthread ***
dnl *****************************
- AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
+# on FreeBSD -STABLE, the pthreads functions all reside in libc_r
+# and libpthread does not exist
+#
+ case "${host}" in
+ *-*-*freebsd4*)
+ AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
+ ;;
+ *)
+ AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
+ ;;
+ esac
AC_CHECK_HEADERS(pthread.h)
AC_CHECK_FUNCS(pthread_mutex_timedlock)
AC_CHECK_FUNCS(pthread_getattr_np pthread_attr_get_np)
@@ -662,7 +740,7 @@ if test x$platform_win32 = xno; then
dnl *** Checks for working __thread ***
dnl ***********************************
AC_MSG_CHECKING(for working __thread)
- if test "x$with_nptl" != "xyes"; then
+ if test "x$with_tls" != "x__thread"; then
AC_MSG_RESULT(disabled)
else
AC_TRY_RUN([
@@ -954,8 +1032,9 @@ ac_cv_c_socklen_t=yes
])
AC_CHECK_FUNCS(trunc, , AC_MSG_CHECKING(for trunc in math.h)
+ # Simply calling trunc (0.0) is no good since gcc will optimize the call away
AC_TRY_LINK([#include <math.h>],
- [ trunc(0.0); ],
+ [ static void *p = &trunc; ],
[
AC_DEFINE(HAVE_TRUNC)
AC_MSG_RESULT(yes)
@@ -1096,7 +1175,11 @@ case "$host" in
JIT_SUPPORTED=no
;;
sparc*-*-*)
- TARGET=SPARC;
+ if test "x$ac_cv_sizeof_void_p" = "x8"; then
+ TARGET=SPARC64
+ else
+ TARGET=SPARC
+ fi
arch_target=sparc;
JIT_SUPPORTED=yes
ACCESS_UNALIGNED="no"
@@ -1184,6 +1267,14 @@ case "$host" in
LIBC="libc.so.12"
INTL="libintl.so.0"
;;
+ *-*-*freebsd*)
+ LIBC="libc.so"
+ INTL="libintl.so"
+ ;;
+ *-*-*openbsd*)
+ LIBC="libc.so"
+ INTL="libintl.so"
+ ;;
esac
AC_SUBST(libsuffix)
@@ -1227,6 +1318,7 @@ AM_CONDITIONAL(INSTALL_2_0, test x$PREVIEW = xyes)
AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
+AM_CONDITIONAL(SPARC64, test x$TARGET = xSPARC64)
AM_CONDITIONAL(X86, test x$TARGET = xX86)
AM_CONDITIONAL(AMD64, test x$TARGET = xAMD64)
AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
@@ -1299,7 +1391,7 @@ echo "
GC: $gc
ICU: $enable_icu
- __thread: $with_nptl
+ TLS: $with_tls
SIGALTSTACK: $with_sigaltstack
Engine: $jit_status
2.0 Alpha: $PREVIEW
View
246 doc/pending-classes.in
@@ -1,246 +0,0 @@
-System.Object
-System.Exception
-System.ValueType
-System.Delegate
-System.MulticastDelegate
-System.Enum
-System.Activator
-System.ArgIterator
-System.__ComObject
-System.TypedReference
-System.Security.AllowPartiallyTrustedCallersAttribute
-System.Runtime.Serialization.Formatter
-System.Runtime.Serialization.FormatterConverter
-System.Runtime.Serialization.FormatterServices
-System.Runtime.Serialization.ObjectIDGenerator
-System.Runtime.Serialization.ObjectManager
-System.Reflection.ModuleResolveEventHandler
-System.Reflection.Pointer
-System.Globalization.CompareInfo
-System.Globalization.HebrewCalendar
-System.Globalization.HijriCalendar
-System.Globalization.JapaneseCalendar
-System.Globalization.KoreanCalendar
-System.Globalization.SortKey
-System.Globalization.StringInfo
-System.Globalization.TaiwanCalendar
-System.Globalization.TextElementEnumerator
-System.Globalization.TextInfo
-System.Globalization.ThaiBuddhistCalendar
-System.IO.IsolatedStorage.IsolatedStorageFile
-System.Reflection.Emit.MethodRental
-System.Runtime.CompilerServices.AccessedThroughPropertyAttribute
-System.Runtime.CompilerServices.CallConvCdecl
-System.Runtime.CompilerServices.CallConvStdcall
-System.Runtime.CompilerServices.CallConvThiscall
-System.Runtime.CompilerServices.CallConvFastcall
-System.Runtime.CompilerServices.CustomConstantAttribute
-System.Runtime.CompilerServices.DateTimeConstantAttribute
-System.Runtime.CompilerServices.DiscardableAttribute
-System.Runtime.CompilerServices.DecimalConstantAttribute
-System.Runtime.CompilerServices.CompilationRelaxationsAttribute
-System.Runtime.CompilerServices.CompilerGlobalScopeAttribute
-System.Runtime.CompilerServices.IDispatchConstantAttribute
-System.Runtime.CompilerServices.IsVolatile
-System.Runtime.CompilerServices.IUnknownConstantAttribute
-System.Runtime.CompilerServices.RequiredAttributeAttribute
-System.Runtime.InteropServices.ArrayWithOffset
-System.Runtime.InteropServices.DispIdAttribute
-System.Runtime.InteropServices.ClassInterfaceType
-System.Runtime.InteropServices.ClassInterfaceAttribute
-System.Runtime.InteropServices.ComVisibleAttribute
-System.Runtime.InteropServices.LCIDConversionAttribute
-System.Runtime.InteropServices.ComRegisterFunctionAttribute
-System.Runtime.InteropServices.ComUnregisterFunctionAttribute
-System.Runtime.InteropServices.ProgIdAttribute
-System.Runtime.InteropServices.ImportedFromTypeLibAttribute
-System.Runtime.InteropServices.IDispatchImplType
-System.Runtime.InteropServices.IDispatchImplAttribute
-System.Runtime.InteropServices.ComSourceInterfacesAttribute
-System.Runtime.InteropServices.ComConversionLossAttribute
-System.Runtime.InteropServices.TypeLibTypeFlags
-System.Runtime.InteropServices.TypeLibFuncFlags
-System.Runtime.InteropServices.TypeLibVarFlags
-System.Runtime.InteropServices.TypeLibTypeAttribute
-System.Runtime.InteropServices.TypeLibFuncAttribute
-System.Runtime.InteropServices.TypeLibVarAttribute
-System.Runtime.InteropServices.ComImportAttribute
-System.Runtime.InteropServices.PreserveSigAttribute
-System.Runtime.InteropServices.ComAliasNameAttribute
-System.Runtime.InteropServices.AutomationProxyAttribute
-System.Runtime.InteropServices.PrimaryInteropAssemblyAttribute
-System.Runtime.InteropServices.CoClassAttribute
-System.Runtime.InteropServices.ComEventInterfaceAttribute
-System.Runtime.InteropServices.COMException
-System.Runtime.InteropServices.ComMemberType
-System.Runtime.InteropServices.CurrencyWrapper
-System.Runtime.InteropServices.DispatchWrapper
-System.Runtime.InteropServices.ErrorWrapper
-System.Runtime.InteropServices.ExtensibleClassFactory
-System.Runtime.InteropServices.HandleRef
-System.Runtime.InteropServices.InvalidComObjectException
-System.Runtime.InteropServices.InvalidOleVariantTypeException
-System.Runtime.InteropServices.TypeLibImporterFlags
-System.Runtime.InteropServices.ExporterEventKind
-System.Runtime.InteropServices.ITypeLibExporterNotifySink
-System.Runtime.InteropServices.ITypeLibConverter
-System.Runtime.InteropServices.MarshalDirectiveException
-System.Runtime.InteropServices.ObjectCreationDelegate
-System.Runtime.InteropServices.RuntimeEnvironment
-System.Runtime.InteropServices.RegistrationServices
-System.Runtime.InteropServices.SafeArrayRankMismatchException
-System.Runtime.InteropServices.SafeArrayTypeMismatchException
-System.Runtime.InteropServices.SEHException
-System.Runtime.InteropServices.TypeLibConverter
-System.Runtime.InteropServices.BIND_OPTS
-System.Runtime.InteropServices.UCOMIBindCtx
-System.Runtime.InteropServices.UCOMIConnectionPointContainer
-System.Runtime.InteropServices.UCOMIConnectionPoint
-System.Runtime.InteropServices.UCOMIEnumMoniker
-System.Runtime.InteropServices.CONNECTDATA
-System.Runtime.InteropServices.UCOMIEnumConnections
-System.Runtime.InteropServices.UCOMIEnumConnectionPoints
-System.Runtime.InteropServices.UCOMIEnumString
-System.Runtime.InteropServices.UCOMIEnumVARIANT
-System.Runtime.InteropServices.FILETIME
-System.Runtime.InteropServices.UCOMIMoniker
-System.Runtime.InteropServices.UCOMIPersistFile
-System.Runtime.InteropServices.UCOMIRunningObjectTable
-System.Runtime.InteropServices.STATSTG
-System.Runtime.InteropServices.UCOMIStream
-System.Runtime.InteropServices.DESCKIND
-System.Runtime.InteropServices.BINDPTR
-System.Runtime.InteropServices.UCOMITypeComp
-System.Runtime.InteropServices.TYPEKIND
-System.Runtime.InteropServices.TYPEFLAGS
-System.Runtime.InteropServices.IMPLTYPEFLAGS
-System.Runtime.InteropServices.TYPEATTR
-System.Runtime.InteropServices.FUNCDESC
-System.Runtime.InteropServices.IDLFLAG
-System.Runtime.InteropServices.IDLDESC
-System.Runtime.InteropServices.PARAMFLAG
-System.Runtime.InteropServices.PARAMDESC
-System.Runtime.InteropServices.TYPEDESC
-System.Runtime.InteropServices.ELEMDESC
-System.Runtime.InteropServices.VARDESC
-System.Runtime.InteropServices.DISPPARAMS
-System.Runtime.InteropServices.EXCEPINFO
-System.Runtime.InteropServices.FUNCKIND
-System.Runtime.InteropServices.INVOKEKIND
-System.Runtime.InteropServices.CALLCONV
-System.Runtime.InteropServices.FUNCFLAGS
-System.Runtime.InteropServices.VARFLAGS
-System.Runtime.InteropServices.UCOMITypeInfo
-System.Runtime.InteropServices.SYSKIND
-System.Runtime.InteropServices.LIBFLAGS
-System.Runtime.InteropServices.TYPELIBATTR
-System.Runtime.InteropServices.UCOMITypeLib
-System.Runtime.InteropServices.UnknownWrapper
-System.Runtime.Remoting.IObjectHandle
-System.Runtime.Remoting.IRemotingTypeInfo
-System.Runtime.Remoting.IChannelInfo
-System.Runtime.Remoting.IEnvoyInfo
-System.Runtime.Remoting.RemotingConfiguration
-System.Runtime.Remoting.TypeEntry
-System.Runtime.Remoting.ActivatedClientTypeEntry
-System.Runtime.Remoting.ActivatedServiceTypeEntry
-System.Runtime.Remoting.WellKnownClientTypeEntry
-System.Runtime.Remoting.WellKnownServiceTypeEntry
-System.Runtime.Remoting.RemotingException
-System.Runtime.Remoting.ServerException
-System.Runtime.Remoting.RemotingTimeoutException
-System.Runtime.Remoting.RemotingServices
-System.Runtime.Remoting.InternalRemotingServices
-System.Runtime.Remoting.SoapServices
-System.Runtime.Remoting.Activation.UrlAttribute
-System.Runtime.Remoting.Messaging.IMessageSink
-System.Runtime.Remoting.Messaging.AsyncResult
-System.Runtime.Remoting.Messaging.CallContext
-System.Runtime.Remoting.Messaging.ILogicalThreadAffinative
-System.Runtime.Remoting.Messaging.InternalMessageWrapper
-System.Runtime.Remoting.Messaging.IMethodCallMessage
-System.Runtime.Remoting.Messaging.MethodCallMessageWrapper
-System.Runtime.Remoting.Messaging.HeaderHandler
-System.Runtime.Remoting.Messaging.IMessageCtrl
-System.Runtime.Remoting.Messaging.IRemotingFormatter
-System.Runtime.Remoting.Messaging.ReturnMessage
-System.Runtime.Remoting.Messaging.MethodCall
-System.Runtime.Remoting.Messaging.ConstructionCall
-System.Runtime.Remoting.Messaging.MethodResponse
-System.Runtime.Remoting.Messaging.ConstructionResponse
-System.Runtime.Remoting.Messaging.MethodReturnMessageWrapper
-System.Runtime.Remoting.Messaging.OneWayAttribute
-System.Runtime.Remoting.Messaging.MessageSurrogateFilter
-System.Runtime.Remoting.Messaging.RemotingSurrogateSelector
-System.Runtime.Remoting.Contexts.CrossContextDelegate
-System.Runtime.Remoting.Contexts.ContextProperty
-System.Runtime.Remoting.Contexts.IContextPropertyActivator
-System.Runtime.Remoting.Contexts.IContributeClientContextSink
-System.Runtime.Remoting.Contexts.IContributeDynamicSink
-System.Runtime.Remoting.Contexts.IContributeEnvoySink
-System.Runtime.Remoting.Contexts.IContributeObjectSink
-System.Runtime.Remoting.Contexts.IContributeServerContextSink
-System.Runtime.Serialization.Formatters.InternalRM
-System.Runtime.Serialization.Formatters.InternalST
-System.Runtime.Serialization.Formatters.SoapMessage
-System.Runtime.Serialization.Formatters.SoapFault
-System.Runtime.Serialization.Formatters.ServerFault
-System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
-System.Security.Cryptography.CryptoConfig
-System.Security.Cryptography.KeyedHashAlgorithm
-System.Security.Cryptography.HMACSHA1
-System.Security.Cryptography.MACTripleDES
-System.Security.Cryptography.MaskGenerationMethod
-System.Security.Cryptography.PasswordDeriveBytes
-System.Security.Cryptography.PKCS1MaskGenerationMethod
-System.Security.Cryptography.RC2
-System.Security.Cryptography.RC2CryptoServiceProvider
-System.Security.Cryptography.RSACryptoServiceProvider
-System.Security.Cryptography.RSAOAEPKeyExchangeDeformatter
-System.Security.Cryptography.RSAOAEPKeyExchangeFormatter
-System.Security.Cryptography.RSAPKCS1KeyExchangeDeformatter
-System.Security.Cryptography.RSAPKCS1KeyExchangeFormatter
-System.Security.Cryptography.RSAPKCS1SignatureDeformatter
-System.Security.Cryptography.RSAPKCS1SignatureFormatter
-System.Security.Cryptography.SHA1Managed
-System.Security.Cryptography.TripleDES
-System.Security.Cryptography.TripleDESCryptoServiceProvider
-System.Security.Permissions.EnvironmentPermission
-System.Security.Permissions.FileDialogPermission
-System.Security.Permissions.IsolatedStorageFilePermission
-System.Security.Permissions.PrincipalPermissionAttribute
-System.Security.Permissions.SecurityPermissionAttribute
-System.Security.Permissions.PublisherIdentityPermissionAttribute
-System.Security.Permissions.PublisherIdentityPermission
-System.Security.Permissions.ReflectionPermission
-System.Security.Permissions.RegistryPermission
-System.Security.Permissions.PrincipalPermission
-System.Security.Permissions.SiteIdentityPermission
-System.Security.Permissions.StrongNameIdentityPermission
-System.Security.Permissions.StrongNamePublicKeyBlob
-System.Security.Permissions.UIPermission
-System.Security.Permissions.UrlIdentityPermission
-System.Security.Permissions.ZoneIdentityPermission
-System.Security.Policy.ApplicationDirectory
-System.Security.Policy.ApplicationDirectoryMembershipCondition
-System.Security.Policy.FirstMatchCodeGroup
-System.Security.Policy.Hash
-System.Security.Policy.HashMembershipCondition
-System.Security.Policy.NetCodeGroup
-System.Security.Policy.PermissionRequestEvidence
-System.Security.Policy.Publisher
-System.Security.Policy.PublisherMembershipCondition
-System.Security.Policy.Site
-System.Security.Policy.SiteMembershipCondition
-System.Security.Policy.StrongName
-System.Security.Policy.StrongNameMembershipCondition
-System.Security.Policy.UnionCodeGroup
-System.Security.Policy.Url
-System.Security.Policy.UrlMembershipCondition
-System.Security.Policy.Zone
-System.Security.Policy.ZoneMembershipCondition
-System.Security.Principal.WindowsIdentity
-System.Security.Principal.WindowsImpersonationContext
-System.Security.Principal.WindowsPrincipal
-System.Threading.CompressedStack
-
View
1 mono/dis/get.c
@@ -197,6 +197,7 @@ get_typespec (MonoImage *m, guint32 idx)
if (s)
g_string_append (res, s);
}
+ g_string_append (res, "*");
break;
case MONO_TYPE_FNPTR:
View
6 mono/interpreter/ChangeLog
@@ -1,3 +1,9 @@
+2004-07-05 Zoltan Varga <vargaz@freemail.hu>
+
+ * mintops.h: Applied patch from Marcin Krzyzanowski (krzak@pld-linux.org). Add support for unaligned access on little endian machines.
+
+ * interp.c:Applied patch from Marcin Krzyzanowski (krzak@pld-linux.org). Fix crash seen on amd64.
+
2004-06-24 David Waite <mass@akuma.org>
* interp.c: change to C90-style comments from C99/C++-style
View
2 mono/interpreter/interp.c
@@ -1164,7 +1164,7 @@ interp_mono_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoOb
}
}
- if (method->klass->valuetype)
+ if (method->klass->valuetype && obj)
/* Unbox the instance, since valuetype methods expect an interior pointer. */
obj = mono_object_unbox (obj);
View
10 mono/interpreter/mintops.h
@@ -1,6 +1,8 @@
#ifndef __INTERPRETER_MINTOPS_H
#define __INTERPRETER_MINTOPS_H
+#include <glib.h>
+
typedef enum
{
MintOpNoArgs,
@@ -29,11 +31,19 @@ enum {
#undef OPDEF
#if NO_UNALIGNED_ACCESS
+# if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define READ32(x) (((guint16 *)(x)) [0] | ((guint16 *)(x)) [1] << 16)
+#define READ64(x) ((guint64)((guint16 *)(x)) [0] | \
+ (guint64)((guint16 *)(x)) [1] << 16 | \
+ (guint64)((guint16 *)(x)) [2] << 32 | \
+ (guint64)((guint16 *)(x)) [3] << 48)
+# else
#define READ32(x) (((guint16 *)(x)) [0] << 16 | ((guint16 *)(x)) [1])
#define READ64(x) ((guint64)((guint16 *)(x)) [0] << 48 | \
(guint64)((guint16 *)(x)) [1] << 32 | \
(guint64)((guint16 *)(x)) [2] << 16 | \
(guint64)((guint16 *)(x)) [3])
+# endif
#else /* unaligned access OK */
#define READ32(x) (*(guint32 *)(x))
#define READ64(x) (*(guint64 *)(x))
View
113 mono/io-layer/ChangeLog
@@ -1,3 +1,116 @@
+2004-09-28 Dick Porter <dick@ximian.com>
+
+ * io.c (pipe_close_private): Fix one small typo in the last change
+ that totally hosed process creation with redirected pipes.
+
+2004-09-24 Dick Porter <dick@ximian.com>
+
+ * wapi-private.h:
+ * sockets.c:
+ * socket-private.h:
+ * io.c:
+ * io-private.h:
+ * handles-private.h: Cope when a file descriptor is reused while
+ the handle that thought it owned it is still referenced, instead
+ of asserting. Probably fixes bug 66479, though we've been unable
+ to reproduce it.
+
+2004-09-09 Dick Porter <dick@ximian.com>
+
+ * error.c:
+ * io.c: Set error codes everywhere.
+
+2004-09-06 Dick Porter <dick@ximian.com>
+
+ * handles.c (_wapi_handle_unref): Reset the private record's type
+ (_wapi_handle_process_fork): Fix long-standing bug in checking
+ handle return values. Also do the required bookkeeping with the
+ new process's handles.
+
+ * daemon.c: When creating a new process's handles, check whether
+ the shared space needs to be increased
+
+2004-08-19 Dick Porter <dick@ximian.com>
+
+ * handles.c (_wapi_handle_count_signalled_handles): Fix thinko
+ introduced with the fd offset stuff: unlock handles properly when
+ backing off. Fixes the monologue hang at exit.
+
+2004-08-18 Dick Porter <dick@ximian.com>
+
+ * sockets.c:
+ * io.c: Check that new fds fit in the table, return error if not
+
+ * daemon.c (_wapi_daemon_main):
+ * handles.c (shared_init): Have all processes agree on a size for
+ the fd table.
+
+2004-08-17 Dick Porter <dick@ximian.com>
+
+ * daemon.c (process_new):
+ * handles.c (_wapi_handle_new_internal): Cope when the space
+ reserved for file descriptors is larger than the shared segment
+ size. Fixes the crash reported when running mono under gdb on
+ macosx.
+
+2004-08-16 Dick Porter <dick@ximian.com>
+
+ * sockets.c:
+ * io.c:
+ * handles-private.h (_wapi_handle_fd_offset_to_handle): Improve
+ error checking with passed-in file descriptors.
+
+2004-08-11 Dick Porter <dick@ximian.com>
+
+ * sockets.c:
+ * io.c: Returned handle values are the file descriptor the handle
+ encapsulates
+
+ * handles.c:
+ * handles-private.h:
+ * daemon.c: Reserve the range of handles that can have the same
+ values as file descriptors. These won't be used, but the values
+ will be used as file, console, pipe or socket handles. The fd to
+ handle mapping is done internally and is invisible to users.
+ Fixes bug 61828.
+
+ * wapi-private.h (_WAPI_HANDLE_VERSION): Increment, because we now
+ reserve a chunk of handle space.
+
+2004-07-22 Dick Porter <dick@ximian.com>
+
+ * timed-thread.c:
+ * threads.c: Move the destruction of the internal thread data to
+ after the thread has been joined. Fixes bug 61418.
+
+2004-07-14 Dick Porter <dick@ximian.com>
+
+ * wait.c (test_and_own): When not waiting for all handles to
+ become signalled, only own and return the lowest. All the
+ documentation suggests that the old way was correct, but
+ experimentation shows it actually works like this. Patch by
+ S�bastien Robitaille
+ (sebastien.robitaille@croesus.com), fixes bug 61511.
+
+2004-07-08 Dick Porter <dick@ximian.com>
+
+ * io.c (file_seek): If there is a high 32bit offset part, make
+ sure the low part isn't sign-extended. Set error codes when
+ returning failure. Fixes bug 61131.
+
+2004-07-06 Dick Porter <dick@ximian.com>
+
+ * io.c (file_setfiletime): Check for underflow when converting to
+ time_t values. Set error codes when returning failure. Fixes bug
+ 60970.
+
+2004-07-05 Dick Porter <dick@ximian.com>
+
+ * mutexes.c (mutex_ops_init): Make the named mutex mutex sharable.
+
+ * daemon.c (unref_handle): Only destroy a handle if all processes
+ have released it, not just the current one. Fixes bug 60887.
+
2004-06-24 Dick Porter <dick@ximian.com>
* mutexes.c: Indicate when a named mutex was reused
View
62 mono/io-layer/daemon.c
@@ -340,16 +340,14 @@ static gboolean unref_handle (ChannelData *channel_data, guint32 handle)
channel_data->open_handles[handle]);
#endif
- if(channel_data->open_handles[handle]==0) {
- /* This client has released the handle */
- destroy=TRUE;
- }
-
- if(_wapi_shared_data[segment]->handles[idx].ref==0) {
+ if (_wapi_shared_data[segment]->handles[idx].ref == 0) {
gboolean was_file;
dev_t device = 0;
ino_t inode = 0;
+ /* This client has released the handle */
+ destroy=TRUE;
+
if (channel_data->open_handles[handle]!=0) {
g_warning (G_GNUC_PRETTY_FUNCTION ": per-process open_handles mismatch, set to %d, should be 0",
channel_data->open_handles[handle]);
@@ -832,23 +830,11 @@ static void send_reply (GIOChannel *channel, WapiHandleResponse *resp)
_wapi_daemon_response (g_io_channel_unix_get_fd (channel), resp);
}
-/*
- * process_new:
- * @channel: The client making the request
- * @channel_data: Our data for this channel
- * @type: type to init handle to
- *
- * Find a free handle and initialize it to 'type', increase refcnt and
- * send back a reply to the client.
- */
-static void process_new (GIOChannel *channel, ChannelData *channel_data,
- WapiHandleType type)
+static guint32 new_handle_with_shared_check (WapiHandleType type)
{
- guint32 handle;
- WapiHandleResponse resp={0};
-
- handle=_wapi_handle_new_internal (type);
- if(handle==0) {
+ guint32 handle = 0;
+
+ while ((handle = _wapi_handle_new_internal (type)) == 0) {
/* Try and allocate a new shared segment, and have
* another go
*/
@@ -873,15 +859,34 @@ static void process_new (GIOChannel *channel, ChannelData *channel_data,
channels[i].open_handles=_wapi_g_renew0 (channels[i].open_handles, old_len, new_len);
}
}
-
- handle=_wapi_handle_new_internal (type);
} else {
/* Map failed. Just return 0 meaning "out of
* handles"
*/
+ break;
}
}
+ return(handle);
+}
+
+/*
+ * process_new:
+ * @channel: The client making the request
+ * @channel_data: Our data for this channel
+ * @type: type to init handle to
+ *
+ * Find a free handle and initialize it to 'type', increase refcnt and
+ * send back a reply to the client.
+ */
+static void process_new (GIOChannel *channel, ChannelData *channel_data,
+ WapiHandleType type)
+{
+ guint32 handle;
+ WapiHandleResponse resp={0};
+
+ handle = new_handle_with_shared_check (type);
+
/* handle might still be set to 0. This is handled at the
* client end
*/
@@ -1066,11 +1071,11 @@ static void process_process_fork (GIOChannel *channel, ChannelData *channel_data
* client must check if either handle is 0 and take
* appropriate error handling action.
*/
- process_handle=_wapi_handle_new_internal (WAPI_HANDLE_PROCESS);
+ process_handle = new_handle_with_shared_check (WAPI_HANDLE_PROCESS);
ref_handle (daemon_channel_data, process_handle);
ref_handle (channel_data, process_handle);
- thread_handle=_wapi_handle_new_internal (WAPI_HANDLE_THREAD);
+ thread_handle = new_handle_with_shared_check (WAPI_HANDLE_THREAD);
ref_handle (daemon_channel_data, thread_handle);
ref_handle (channel_data, thread_handle);
@@ -1248,7 +1253,7 @@ static void process_process_fork (GIOChannel *channel, ChannelData *channel_data
resp.u.process_fork.pid=pid;
}
-
+
resp.u.process_fork.process_handle=process_handle;
resp.u.process_fork.thread_handle=thread_handle;
@@ -1493,6 +1498,9 @@ void _wapi_daemon_main(gpointer data, gpointer scratch)
/* Note that we've got the starting segment already */
_wapi_shared_data[0]->num_segments=1;
_wapi_shm_mapped_segments=1;
+
+ _wapi_fd_offset_table_size=getdtablesize ();
+ _wapi_shared_data[0]->fd_offset_table_size = _wapi_fd_offset_table_size;
startup ();
View
8 mono/io-layer/error.c
@@ -194,6 +194,14 @@ _wapi_get_win32_file_error (gint err)
ret = ERROR_NOT_SUPPORTED;
break;
+ case EBADF:
+ ret = ERROR_INVALID_HANDLE;
+ break;
+
+ case EIO:
+ ret = ERROR_INVALID_HANDLE;
+ break;
+
default:
g_message ("Unknown errno: %s\n", strerror (err));
ret = ERROR_GEN_FAILURE;
View
80 mono/io-layer/handles-private.h
@@ -28,6 +28,9 @@ extern struct _WapiHandlePrivate_list **_wapi_private_data;
extern pthread_mutex_t _wapi_shared_mutex;
extern guint32 _wapi_shm_mapped_segments;
+extern guint32 _wapi_fd_offset_table_size;
+extern gpointer *_wapi_fd_offset_table;
+
extern guint32 _wapi_handle_new_internal (WapiHandleType type);
extern gpointer _wapi_handle_new (WapiHandleType type);
extern gboolean _wapi_lookup_handle (gpointer handle, WapiHandleType type,
@@ -220,11 +223,38 @@ static inline guint32 _wapi_handle_index (guint32 segment, guint32 idx)
return((segment*_WAPI_HANDLES_PER_SEGMENT)+idx);
}
+static inline gpointer _wapi_handle_fd_offset_to_handle (gpointer fd_handle)
+{
+ int fd = GPOINTER_TO_INT (fd_handle);
+ gpointer handle;
+
+ if (fd >= _wapi_fd_offset_table_size) {
+ return(NULL);
+ }
+
+ handle = _wapi_fd_offset_table[fd];
+
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ return(NULL);
+ }
+
+#ifdef DEBUG
+ g_message (G_GNUC_PRETTY_FUNCTION ": Returning fd offset %d of %p", fd,
+ handle);
+#endif
+
+ return(handle);
+}
+
static inline WapiHandleType _wapi_handle_type (gpointer handle)
{
guint32 idx;
guint32 segment;
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
+
_wapi_handle_segment (handle, &segment, &idx);
if(segment>=_wapi_shm_mapped_segments)
@@ -233,6 +263,48 @@ static inline WapiHandleType _wapi_handle_type (gpointer handle)
return(_wapi_handle_get_shared_segment (segment)->handles[idx].type);
}
+static inline void _wapi_handle_fd_offset_store (int fd, gpointer handle)
+{
+ g_assert (fd < _wapi_fd_offset_table_size);
+
+ if (_wapi_fd_offset_table[fd] != NULL && handle != NULL) {
+ gpointer oldhandle = _wapi_fd_offset_table[fd];
+ struct _WapiHandlePrivate *private_handle;
+ guint32 idx;
+ guint32 segment;
+
+#ifdef DEBUG
+ g_message (G_GNUC_PRETTY_FUNCTION
+ ": Reassigning fd offset %d from %p", fd,
+ oldhandle);
+#endif
+
+ /* The WapiFDMapped struct at the head of the private
+ * handle data means we don't need to do a full
+ * lookup, and we don't need to know the handle type.
+ */
+ g_assert (_wapi_handle_type (oldhandle) == WAPI_HANDLE_FILE ||
+ _wapi_handle_type (oldhandle) == WAPI_HANDLE_CONSOLE ||
+ _wapi_handle_type (oldhandle) == WAPI_HANDLE_PIPE ||
+ _wapi_handle_type (oldhandle) == WAPI_HANDLE_SOCKET);
+
+ _wapi_handle_segment (oldhandle, &segment, &idx);
+ _wapi_handle_ensure_mapped (segment);
+
+ private_handle=&_wapi_handle_get_private_segment(segment)->handles[idx];
+ ((WapiFDMapped *)(&private_handle->u))->assigned = FALSE;
+ }
+
+ g_assert (GPOINTER_TO_UINT (handle) >= _wapi_fd_offset_table_size || handle==NULL);
+
+#ifdef DEBUG
+ g_message (G_GNUC_PRETTY_FUNCTION ": Assigning fd offset %d to %p", fd,
+ handle);
+#endif
+
+ _wapi_fd_offset_table[fd]=handle;
+}
+
static inline void _wapi_handle_set_signal_state (gpointer handle,
gboolean state,
gboolean broadcast)
@@ -242,6 +314,8 @@ static inline void _wapi_handle_set_signal_state (gpointer handle,
struct _WapiHandleShared *shared_handle;
int thr_ret;
+ g_assert (GPOINTER_TO_UINT (handle) >= _wapi_fd_offset_table_size);
+
_wapi_handle_segment (handle, &segment, &idx);
shared_handle=&_wapi_handle_get_shared_segment (segment)->handles[idx];
@@ -317,6 +391,8 @@ static inline gboolean _wapi_handle_issignalled (gpointer handle)
guint32 idx;
guint32 segment;
+ g_assert (GPOINTER_TO_UINT (handle) >= _wapi_fd_offset_table_size);
+
_wapi_handle_segment (handle, &segment, &idx);
return(_wapi_handle_get_shared_segment (segment)->handles[idx].signalled);
@@ -352,6 +428,8 @@ static inline int _wapi_handle_lock_handle (gpointer handle)
guint32 idx;
guint32 segment;
+ g_assert (GPOINTER_TO_UINT (handle) >= _wapi_fd_offset_table_size);
+
#ifdef DEBUG
g_message (G_GNUC_PRETTY_FUNCTION ": locking handle %p", handle);
#endif
@@ -369,6 +447,8 @@ static inline int _wapi_handle_unlock_handle (gpointer handle)
guint32 segment;
int ret;
+ g_assert (GPOINTER_TO_UINT (handle) >= _wapi_fd_offset_table_size);
+
#ifdef DEBUG
g_message (G_GNUC_PRETTY_FUNCTION ": unlocking handle %p", handle);
#endif
View
166 mono/io-layer/handles.c
@@ -77,6 +77,9 @@ pthread_mutex_t _wapi_shared_mutex=PTHREAD_MUTEX_INITIALIZER;
*/
guint32 _wapi_shm_mapped_segments;
+guint32 _wapi_fd_offset_table_size;
+gpointer *_wapi_fd_offset_table=NULL;
+
static void shared_init (void)
{
struct sockaddr_un shared_socket_address;
@@ -86,7 +89,7 @@ static void shared_init (void)
_wapi_shared_data=g_new0 (struct _WapiHandleShared_list *, 1);
_wapi_private_data=g_new0 (struct _WapiHandlePrivate_list *, 1);
-
+
attach_again:
#ifndef DISABLE_SHARED_HANDLES
@@ -146,6 +149,9 @@ static void shared_init (void)
goto attach_again;
}
+ } else {
+ _wapi_fd_offset_table_size = _wapi_shared_data[0]->fd_offset_table_size;
+ _wapi_fd_offset_table=g_new0 (gpointer, _wapi_fd_offset_table_size);
}
}
@@ -158,6 +164,10 @@ static void shared_init (void)
_wapi_shared_data[0]->num_segments=1;
_wapi_shared_scratch=g_new0 (struct _WapiHandleScratch, 1);
+
+ _wapi_fd_offset_table_size=getdtablesize ();
+ _wapi_fd_offset_table=g_new0 (gpointer,
+ _wapi_fd_offset_table_size);
}
_wapi_private_data[0]=g_new0 (struct _WapiHandlePrivate_list, 1);
_wapi_shm_mapped_segments=1;
@@ -240,6 +250,7 @@ guint32 _wapi_handle_new_internal (WapiHandleType type)
guint32 i, j;
static guint32 last=1;
int thr_ret;
+ guint32 num_segments = _wapi_handle_get_shared_segment (0)->num_segments;
/* A linear scan should be fast enough. Start from the last
* allocation, assuming that handles are allocated more often
@@ -250,17 +261,28 @@ guint32 _wapi_handle_new_internal (WapiHandleType type)
#endif
again:
_wapi_handle_segment (GUINT_TO_POINTER (last), &segment, &idx);
- for(i=segment; i<_wapi_handle_get_shared_segment (0)->num_segments;
- i++) {
+ for(i=segment; i < num_segments; i++) {
if(i!=segment) {
idx=0;
}
for(j=idx; j<_WAPI_HANDLES_PER_SEGMENT; j++) {
struct _WapiHandleShared *shared;
- /* Make sure we dont try and assign handle 0 */
- if (i==0 && j==0) {
+ /* Make sure we dont try and assign the
+ * handles that would clash with fds
+ */
+ if ((i * _WAPI_HANDLES_PER_SEGMENT + j) < _wapi_fd_offset_table_size) {
+ i = _wapi_fd_offset_table_size / _WAPI_HANDLES_PER_SEGMENT;
+ j = _wapi_fd_offset_table_size - (i * _WAPI_HANDLES_PER_SEGMENT);
+
+ if (i >= num_segments) {
+ /* Need to get the caller to
+ * add more shared segments
+ */
+ return(0);
+ }
+
continue;
}
@@ -314,7 +336,7 @@ gpointer _wapi_handle_new (WapiHandleType type)
int thr_ret;
mono_once (&shared_init_once, shared_init);
-
+
again:
if(shared==TRUE) {
new.type=WapiHandleRequestType_New;
@@ -336,16 +358,14 @@ gpointer _wapi_handle_new (WapiHandleType type)
thr_ret = pthread_mutex_lock (&scan_mutex);
g_assert (thr_ret == 0);
- handle_idx=_wapi_handle_new_internal (type);
- if(handle_idx==0) {
+ while ((handle_idx = _wapi_handle_new_internal (type)) == 0) {
/* Try and get a new segment, and have another go */
segment=_wapi_handle_get_shared_segment (0)->num_segments;
_wapi_handle_ensure_mapped (segment);
if(_wapi_handle_get_shared_segment (segment)!=NULL) {
/* Got a new segment */
_wapi_handle_get_shared_segment (0)->num_segments++;
- handle_idx=_wapi_handle_new_internal (type);
} else {
/* Map failed. Just return 0 meaning
* "out of handles"
@@ -361,6 +381,9 @@ gpointer _wapi_handle_new (WapiHandleType type)
pthread_cleanup_pop (0);
}
+ /* Make sure we left the space for fd mappings */
+ g_assert (handle_idx >= _wapi_fd_offset_table_size);
+
if(handle_idx==0) {
g_warning (G_GNUC_PRETTY_FUNCTION ": Ran out of handles!");
@@ -414,6 +437,8 @@ gboolean _wapi_lookup_handle (gpointer handle, WapiHandleType type,
guint32 idx;
guint32 segment;
+ g_assert (GPOINTER_TO_UINT (handle) >= _wapi_fd_offset_table_size);
+
_wapi_handle_segment (handle, &segment, &idx);
_wapi_handle_ensure_mapped (segment);
@@ -592,6 +617,8 @@ gpointer _wapi_search_handle_namespace (WapiHandleType type,
void _wapi_handle_ref (gpointer handle)
{
+ g_assert (GPOINTER_TO_UINT (handle) >= _wapi_fd_offset_table_size);
+
if(shared==TRUE) {
WapiHandleRequest req={0};
WapiHandleResponse resp={0};
@@ -628,6 +655,8 @@ void _wapi_handle_unref (gpointer handle)
gboolean destroy = FALSE;
int thr_ret;
+ g_assert (GPOINTER_TO_UINT (handle) >= _wapi_fd_offset_table_size);
+
_wapi_handle_segment (handle, &segment, &idx);
if(shared==TRUE) {
@@ -676,6 +705,7 @@ void _wapi_handle_unref (gpointer handle)
_wapi_handle_ops_close_private (handle);
_wapi_handle_get_shared_segment (segment)->handles[idx].type=WAPI_HANDLE_UNUSED;
+ _wapi_handle_get_private_segment (segment)->handles[idx].type=WAPI_HANDLE_UNUSED;
/* Destroy the mutex and cond var. We hope nobody
* tried to grab them between the handle unlock and
@@ -1180,6 +1210,10 @@ gboolean _wapi_handle_test_capabilities (gpointer handle,
guint32 idx, segment;
WapiHandleType type;
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
+
_wapi_handle_segment (handle, &segment, &idx);
type=_wapi_handle_get_shared_segment (segment)->handles[idx].type;
@@ -1197,6 +1231,10 @@ void _wapi_handle_ops_close_shared (gpointer handle)
guint32 idx, segment;
WapiHandleType type;
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
+
_wapi_handle_segment (handle, &segment, &idx);
type=_wapi_handle_get_shared_segment (segment)->handles[idx].type;
@@ -1211,6 +1249,10 @@ void _wapi_handle_ops_close_private (gpointer handle)
guint32 idx, segment;
WapiHandleType type;
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
+
_wapi_handle_segment (handle, &segment, &idx);
type=_wapi_handle_get_shared_segment (segment)->handles[idx].type;
@@ -1232,6 +1274,10 @@ void _wapi_handle_ops_signal (gpointer handle)
guint32 idx, segment;
WapiHandleType type;
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
+
_wapi_handle_segment (handle, &segment, &idx);
type=_wapi_handle_get_shared_segment (segment)->handles[idx].type;
@@ -1246,6 +1292,10 @@ void _wapi_handle_ops_own (gpointer handle)
guint32 idx, segment;
WapiHandleType type;
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
+
_wapi_handle_segment (handle, &segment, &idx);
type=_wapi_handle_get_shared_segment (segment)->handles[idx].type;
@@ -1260,6 +1310,10 @@ gboolean _wapi_handle_ops_isowned (gpointer handle)
guint32 idx, segment;
WapiHandleType type;
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
+
_wapi_handle_segment (handle, &segment, &idx);
type=_wapi_handle_get_shared_segment (segment)->handles[idx].type;
@@ -1284,6 +1338,14 @@ gboolean _wapi_handle_ops_isowned (gpointer handle)
*/
gboolean CloseHandle(gpointer handle)
{
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
+
+ if (handle == NULL) {
+ return(FALSE);
+ }
+
_wapi_handle_unref (handle);
return(TRUE);
@@ -1303,12 +1365,17 @@ gboolean _wapi_handle_count_signalled_handles (guint32 numhandles,
again:
for(i=0; i<numhandles; i++) {
guint32 idx, segment;
+ gpointer handle = handles[i];
+
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
- _wapi_handle_segment (handles[i], &segment, &idx);
+ _wapi_handle_segment (handle, &segment, &idx);
#ifdef DEBUG
g_message (G_GNUC_PRETTY_FUNCTION ": attempting to lock %p",
- handles[i]);
+ handle);
#endif
ret=mono_mutex_trylock (&_wapi_handle_get_shared_segment (segment)->handles[idx].signal_mutex);
@@ -1317,11 +1384,17 @@ gboolean _wapi_handle_count_signalled_handles (guint32 numhandles,
struct timespec sleepytime;
#ifdef DEBUG
- g_message (G_GNUC_PRETTY_FUNCTION ": attempt failed for %p", handles[i]);
+ g_message (G_GNUC_PRETTY_FUNCTION ": attempt failed for %p: %s", handle, strerror (ret));
#endif
while(i--) {
- _wapi_handle_segment (handles[i], &segment, &idx);
+ handle = handles[i];
+
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
+
+ _wapi_handle_segment (handle, &segment, &idx);
thr_ret = mono_mutex_unlock (&_wapi_handle_get_shared_segment (segment)->handles[idx].signal_mutex);
g_assert (thr_ret == 0);
}
@@ -1359,24 +1432,29 @@ gboolean _wapi_handle_count_signalled_handles (guint32 numhandles,
for(i=0; i<numhandles; i++) {
guint32 idx, segment;
-
- _wapi_handle_ref (handles[i]);
+ gpointer handle = handles[i];
+
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
+
+ _wapi_handle_ref (handle);
- _wapi_handle_segment (handles[i], &segment, &idx);
+ _wapi_handle_segment (handle, &segment, &idx);
#ifdef DEBUG
g_message (G_GNUC_PRETTY_FUNCTION ": Checking handle %p",
- handles[i]);
+ handle);
#endif
- if(((_wapi_handle_test_capabilities (handles[i], WAPI_HANDLE_CAP_OWN)==TRUE) &&
- (_wapi_handle_ops_isowned (handles[i])==TRUE)) ||
+ if(((_wapi_handle_test_capabilities (handle, WAPI_HANDLE_CAP_OWN)==TRUE) &&
+ (_wapi_handle_ops_isowned (handle)==TRUE)) ||
(_wapi_handle_get_shared_segment (segment)->handles[idx].signalled==TRUE)) {
count++;
#ifdef DEBUG
g_message (G_GNUC_PRETTY_FUNCTION
- ": Handle %p signalled", handles[i]);
+ ": Handle %p signalled", handle);
#endif
if(*lowest>i) {
*lowest=i;
@@ -1412,18 +1490,23 @@ void _wapi_handle_unlock_handles (guint32 numhandles, gpointer *handles)
for(i=0; i<numhandles; i++) {
guint32 idx, segment;
-
- _wapi_handle_segment (handles[i], &segment, &idx);
+ gpointer handle = handles[i];
+
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
+
+ _wapi_handle_segment (handle, &segment, &idx);
#ifdef DEBUG
g_message (G_GNUC_PRETTY_FUNCTION ": unlocking handle %p",
- handles[i]);
+ handle);
#endif
thr_ret = mono_mutex_unlock (&_wapi_handle_get_shared_segment (segment)->handles[idx].signal_mutex);
g_assert (thr_ret == 0);
- _wapi_handle_unref (handles[i]);
+ _wapi_handle_unref (handle);
}
}
@@ -1495,6 +1578,10 @@ int _wapi_handle_wait_signal_handle (gpointer handle)
#if defined(_POSIX_THREAD_PROCESS_SHARED) && _POSIX_THREAD_PROCESS_SHARED != -1
guint32 idx, segment;
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
+
_wapi_handle_segment (handle, &segment, &idx);
return(mono_cond_wait (&_wapi_handle_get_shared_segment (segment)->handles[idx].signal_cond,
@@ -1504,6 +1591,10 @@ int _wapi_handle_wait_signal_handle (gpointer handle)
struct timespec fake_timeout;
int ret;
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
+
_wapi_handle_segment (handle, &segment, &idx);
_wapi_calc_timeout (&fake_timeout, 100);
@@ -1524,6 +1615,10 @@ int _wapi_handle_timedwait_signal_handle (gpointer handle,
#if defined(_POSIX_THREAD_PROCESS_SHARED) && _POSIX_THREAD_PROCESS_SHARED != -1
guint32 idx, segment;
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
+
_wapi_handle_segment (handle, &segment, &idx);
return(mono_cond_timedwait (&_wapi_handle_get_shared_segment (segment)->handles[idx].signal_cond,
@@ -1534,6 +1629,10 @@ int _wapi_handle_timedwait_signal_handle (gpointer handle,
struct timespec fake_timeout;
int ret;
+ if (GPOINTER_TO_UINT (handle) < _wapi_fd_offset_table_size) {
+ handle = _wapi_handle_fd_offset_to_handle (handle);
+ }
+
_wapi_handle_segment (handle, &segment, &idx);
_wapi_calc_timeout (&fake_timeout, 100);
@@ -1609,9 +1708,26 @@ gboolean _wapi_handle_process_fork (guint32 cmd, guint32 env, guint32 dir,
* exec_errno will be set, and the handle will be
* signalled immediately.
*/
- if(process_handle==0 || thread_handle==0) {
+ if(*process_handle==0 || *thread_handle==0) {
return(FALSE);
} else {
+ /* This call returns new handles, so we need to do
+ * a little bookkeeping
+ */
+ if (_wapi_private_data != NULL) {
+ guint32 segment, idx;
+
+ _wapi_handle_segment (*process_handle,
+ &segment, &idx);
+ _wapi_handle_ensure_mapped (segment);
+ _wapi_handle_get_private_segment (segment)->handles[idx].type = WAPI_HANDLE_PROCESS;
+
+ _wapi_handle_segment (*thread_handle,
+ &segment, &idx);
+ _wapi_handle_ensure_mapped (segment);
+ _wapi_handle_get_private_segment (segment)->handles[idx].type = WAPI_HANDLE_THREAD;
+ }
+
return(TRUE);
}
} else {
View
6 mono/io-layer/io-private.h
@@ -34,13 +34,9 @@ struct _WapiHandle_file
ino_t inode;
};
-/* The boolean is for distinguishing between a zeroed struct being not
- * as yet assigned, and one containing a valid fd 0
- */
struct _WapiHandlePrivate_file
{
- int fd;
- gboolean assigned;
+ WapiFDMapped fd_mapped;
gboolean async;
WapiOverlappedCB callback;
};
View
695 mono/io-layer/io.c
@@ -236,6 +236,7 @@ static void file_close_shared (gpointer handle)
if(ok==FALSE) {
g_warning (G_GNUC_PRETTY_FUNCTION
": error looking up file handle %p", handle);
+ SetLastError (ERROR_INVALID_HANDLE);
return;
}
@@ -263,15 +264,21 @@ static void file_close_private (gpointer handle)
if(ok==FALSE) {
g_warning (G_GNUC_PRETTY_FUNCTION
": error looking up file handle %p", handle);
+ SetLastError (ERROR_INVALID_HANDLE);
return;
}
+ if (file_private_handle->fd_mapped.assigned) {
#ifdef DEBUG
- g_message(G_GNUC_PRETTY_FUNCTION ": closing file handle %p with fd %d",
- handle, file_private_handle->fd);
+ g_message(G_GNUC_PRETTY_FUNCTION ": closing file handle %p with fd %d",
+ handle, file_private_handle->fd_mapped.fd);
#endif
- close(file_private_handle->fd);
+ /* Blank out the mapping, to make catching errors easier */
+ _wapi_handle_fd_offset_store (file_private_handle->fd_mapped.fd, NULL);
+
+ close(file_private_handle->fd_mapped.fd);
+ }
}
static WapiFileType file_getfiletype(void)
@@ -326,6 +333,12 @@ static gboolean file_read(gpointer handle, gpointer buffer,
if(ok==FALSE) {
g_warning (G_GNUC_PRETTY_FUNCTION
": error looking up file handle %p", handle);
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ if (file_private_handle->fd_mapped.assigned == FALSE) {
+ SetLastError (ERROR_INVALID_HANDLE);
return(FALSE);
}
@@ -336,15 +349,17 @@ static gboolean file_read(gpointer handle, gpointer buffer,
if(!(file_handle->fileaccess&GENERIC_READ) &&
!(file_handle->fileaccess&GENERIC_ALL)) {
#ifdef DEBUG
- g_message(G_GNUC_PRETTY_FUNCTION": handle %p fd %d doesn't have GENERIC_READ access: %u", handle, file_private_handle->fd, file_handle->fileaccess);
+ g_message(G_GNUC_PRETTY_FUNCTION": handle %p fd %d doesn't have GENERIC_READ access: %u", handle, file_private_handle->fd_mapped.fd, file_handle->fileaccess);
#endif
+ SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
if (file_private_handle->async == FALSE) {
do {
- ret=read(file_private_handle->fd, buffer, numbytes);
+ ret=read(file_private_handle->fd_mapped.fd, buffer,
+ numbytes);
}
while (ret==-1 && errno==EINTR && !_wapi_thread_cur_apc_pending());
@@ -354,7 +369,8 @@ static gboolean file_read(gpointer handle, gpointer buffer,
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
": read of handle %p fd %d error: %s", handle,
- file_private_handle->fd, strerror(err));
+ file_private_handle->fd_mapped.fd,
+ strerror(err));
#endif
SetLastError (_wapi_get_win32_file_error (err));
return(FALSE);
@@ -377,7 +393,7 @@ static gboolean file_read(gpointer handle, gpointer buffer,
}
{
- int fd = file_private_handle->fd;
+ int fd = file_private_handle->fd_mapped.fd;
struct aiocb *aio;
int result;
notifier_data_t *ndata;
@@ -441,6 +457,12 @@ static gboolean file_write(gpointer handle, gconstpointer buffer,
if(ok==FALSE) {
g_warning (G_GNUC_PRETTY_FUNCTION
": error looking up file handle %p", handle);
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ if (file_private_handle->fd_mapped.assigned == FALSE) {
+ SetLastError (ERROR_INVALID_HANDLE);
return(FALSE);
}
@@ -451,9 +473,10 @@ static gboolean file_write(gpointer handle, gconstpointer buffer,
if(!(file_handle->fileaccess&GENERIC_WRITE) &&
!(file_handle->fileaccess&GENERIC_ALL)) {
#ifdef DEBUG
- g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_WRITE access: %u", handle, file_private_handle->fd, file_handle->fileaccess);
+ g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_WRITE access: %u", handle, file_private_handle->fd_mapped.fd, file_handle->fileaccess);
#endif
+ SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
@@ -464,37 +487,40 @@ static gboolean file_write(gpointer handle, gconstpointer buffer,
* because we only do advisory locking on POSIX
* systems
*/
- current_pos = lseek (file_private_handle->fd, (off_t)0,
- SEEK_CUR);
+ current_pos = lseek (file_private_handle->fd_mapped.fd,
+ (off_t)0, SEEK_CUR);
if (current_pos == -1) {
#ifdef DEBUG
- g_message (G_GNUC_PRETTY_FUNCTION ": handle %p fd %d lseek failed: %s", handle, file_private_handle->fd, strerror (errno));
+ g_message (G_GNUC_PRETTY_FUNCTION ": handle %p fd %d lseek failed: %s", handle, file_private_handle->fd_mapped.fd, strerror (errno));
#endif
_wapi_set_last_error_from_errno ();
return(FALSE);
}
- if (_wapi_lock_file_region (file_private_handle->fd,
+ if (_wapi_lock_file_region (file_private_handle->fd_mapped.fd,
current_pos, numbytes) == FALSE) {
/* The error has already been set */
return(FALSE);
}
do {
- ret=write(file_private_handle->fd, buffer, numbytes);
+ ret=write(file_private_handle->fd_mapped.fd, buffer,
+ numbytes);
}
while (ret==-1 && errno==EINTR && !_wapi_thread_cur_apc_pending());
- _wapi_unlock_file_region (file_private_handle->fd, current_pos,
- numbytes);
+ _wapi_unlock_file_region (file_private_handle->fd_mapped.fd,
+ current_pos, numbytes);
if(ret==-1) {
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
": write of handle %p fd %d error: %s", handle,
- file_private_handle->fd, strerror(errno));
+ file_private_handle->fd_mapped.fd,
+ strerror(errno));
#endif
+ _wapi_set_last_error_from_errno ();
return(FALSE);
}
if(byteswritten!=NULL) {
@@ -513,7 +539,7 @@ static gboolean file_write(gpointer handle, gconstpointer buffer,
}
{
- int fd = file_private_handle->fd;
+ int fd = file_private_handle->fd_mapped.fd;
struct aiocb *aio;
int result;
notifier_data_t *ndata;
@@ -575,26 +601,34 @@ static gboolean file_flush(gpointer handle)
if(ok==FALSE) {
g_warning (G_GNUC_PRETTY_FUNCTION
": error looking up file handle %p", handle);
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ if (file_private_handle->fd_mapped.assigned == FALSE) {
+ SetLastError (ERROR_INVALID_HANDLE);
return(FALSE);
}
if(!(file_handle->fileaccess&GENERIC_WRITE) &&
!(file_handle->fileaccess&GENERIC_ALL)) {
#ifdef DEBUG
- g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_WRITE access: %u", handle, file_private_handle->fd, file_handle->fileaccess);
+ g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_WRITE access: %u", handle, file_private_handle->fd_mapped.fd, file_handle->fileaccess);
#endif
+ SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
- ret=fsync(file_private_handle->fd);
+ ret=fsync(file_private_handle->fd_mapped.fd);
if (ret==-1) {
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
- ": write of handle %p fd %d error: %s", handle,
- file_private_handle->fd, strerror(errno));
+ ": fsync of handle %p fd %d error: %s", handle,
+ file_private_handle->fd_mapped.fd, strerror(errno));
#endif
+ _wapi_set_last_error_from_errno ();
return(FALSE);
}
@@ -617,16 +651,23 @@ static guint32 file_seek(gpointer handle, gint32 movedistance,
if(ok==FALSE) {
g_warning (G_GNUC_PRETTY_FUNCTION
": error looking up file handle %p", handle);
+ SetLastError (ERROR_INVALID_HANDLE);
return(INVALID_SET_FILE_POINTER);
}
+
+ if (file_private_handle->fd_mapped.assigned == FALSE) {
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
if(!(file_handle->fileaccess&GENERIC_READ) &&
!(file_handle->fileaccess&GENERIC_WRITE) &&
!(file_handle->fileaccess&GENERIC_ALL)) {
#ifdef DEBUG
- g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_READ or GENERIC_WRITE access: %u", handle, file_private_handle->fd, file_handle->fileaccess);
+ g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_READ or GENERIC_WRITE access: %u", handle, file_private_handle->fd_mapped.fd, file_handle->fileaccess);
#endif
+ SetLastError (ERROR_ACCESS_DENIED);
return(INVALID_SET_FILE_POINTER);
}
@@ -646,6 +687,7 @@ static guint32 file_seek(gpointer handle, gint32 movedistance,
method);
#endif
+ SetLastError (ERROR_INVALID_PARAMETER);
return(INVALID_SET_FILE_POINTER);
}
@@ -658,7 +700,7 @@ static guint32 file_seek(gpointer handle, gint32 movedistance,
movedistance);
#endif
} else {
- offset=((gint64) *highmovedistance << 32) | movedistance;
+ offset=((gint64) *highmovedistance << 32) | (unsigned long)movedistance;
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION ": setting offset to %lld 0x%llx (high %d 0x%x, low %d 0x%x)", offset, offset, *highmovedistance, *highmovedistance, movedistance, movedistance);
@@ -672,22 +714,24 @@ static guint32 file_seek(gpointer handle, gint32 movedistance,
#ifdef HAVE_LARGE_FILE_SUPPORT
g_message(G_GNUC_PRETTY_FUNCTION
": moving handle %p fd %d by %lld bytes from %d", handle,
- file_private_handle->fd, offset, whence);
+ file_private_handle->fd_mapped.fd, offset, whence);
#else
g_message(G_GNUC_PRETTY_FUNCTION
": moving handle %p fd %d by %ld bytes from %d", handle,
- file_private_handle->fd, offset, whence);
+ file_private_handle->fd_mapped.fd, offset, whence);
#endif
#endif
- newpos=lseek(file_private_handle->fd, offset, whence);
+ newpos=lseek(file_private_handle->fd_mapped.fd, offset, whence);
if(newpos==-1) {
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
": lseek on handle %p fd %d returned error %s",
- handle, file_private_handle->fd, strerror(errno));
+ handle, file_private_handle->fd_mapped.fd,
+ strerror(errno));
#endif
+ _wapi_set_last_error_from_errno ();
return(INVALID_SET_FILE_POINTER);
}
@@ -715,7 +759,7 @@ static guint32 file_seek(gpointer handle, gint32 movedistance,
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
": move of handle %p fd %d returning %d/%d", handle,
- file_private_handle->fd, ret,
+ file_private_handle->fd_mapped.fd, ret,
highmovedistance==NULL?0:*highmovedistance);
#endif
@@ -737,15 +781,22 @@ static gboolean file_setendoffile(gpointer handle)
if(ok==FALSE) {
g_warning (G_GNUC_PRETTY_FUNCTION
": error looking up file handle %p", handle);
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ if (file_private_handle->fd_mapped.assigned == FALSE) {
+ SetLastError (ERROR_INVALID_HANDLE);
return(FALSE);
}
if(!(file_handle->fileaccess&GENERIC_WRITE) &&
!(file_handle->fileaccess&GENERIC_ALL)) {
#ifdef DEBUG
- g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_WRITE access: %u", handle, file_private_handle->fd, file_handle->fileaccess);
+ g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_WRITE access: %u", handle, file_private_handle->fd_mapped.fd, file_handle->fileaccess);
#endif
+ SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
@@ -755,44 +806,47 @@ static gboolean file_setendoffile(gpointer handle)
* than the length, truncate the file.
*/
- ret=fstat(file_private_handle->fd, &statbuf);
+ ret=fstat(file_private_handle->fd_mapped.fd, &statbuf);
if(ret==-1) {
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
": handle %p fd %d fstat failed: %s", handle,
- file_private_handle->fd, strerror(errno));
+ file_private_handle->fd_mapped.fd, strerror(errno));
#endif
+ _wapi_set_last_error_from_errno ();
return(FALSE);
}
size=statbuf.st_size;
- pos=lseek(file_private_handle->fd, (off_t)0, SEEK_CUR);
+ pos=lseek(file_private_handle->fd_mapped.fd, (off_t)0, SEEK_CUR);
if(pos==-1) {
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
": handle %p fd %d lseek failed: %s", handle,
- file_private_handle->fd, strerror(errno));
+ file_private_handle->fd_mapped.fd, strerror(errno));
#endif
+ _wapi_set_last_error_from_errno ();
return(FALSE);
}
if(pos>size) {
/* extend */
do {
- ret=write(file_private_handle->fd, "", 1);
+ ret=write(file_private_handle->fd_mapped.fd, "", 1);
}
while (ret==-1 && errno==EINTR && !_wapi_thread_cur_apc_pending());
if(ret==-1) {
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
": handle %p fd %d extend write failed: %s",
- handle, file_private_handle->fd,
+ handle, file_private_handle->fd_mapped.fd,
strerror(errno));
#endif
+ _wapi_set_last_error_from_errno ();
return(FALSE);
}
}
@@ -801,17 +855,18 @@ static gboolean file_setendoffile(gpointer handle)
* byte to the end of the file
*/
do {
- ret=ftruncate(file_private_handle->fd, pos);
+ ret=ftruncate(file_private_handle->fd_mapped.fd, pos);
}
while (ret==-1 && errno==EINTR && !_wapi_thread_cur_apc_pending());
if(ret==-1) {
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
": handle %p fd %d ftruncate failed: %s", handle,
- file_private_handle->fd, strerror(errno));
+ file_private_handle->fd_mapped.fd, strerror(errno));
#endif
+ _wapi_set_last_error_from_errno ();
return(FALSE);
}
@@ -833,27 +888,35 @@ static guint32 file_getfilesize(gpointer handle, guint32 *highsize)
if(ok==FALSE) {
g_warning (G_GNUC_PRETTY_FUNCTION
": error looking up file handle %p", handle);
+ SetLastError (ERROR_INVALID_HANDLE);
return(INVALID_FILE_SIZE);
}
+
+ if (file_private_handle->fd_mapped.assigned == FALSE) {
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
if(!(file_handle->fileaccess&GENERIC_READ) &&
!(file_handle->fileaccess&GENERIC_WRITE) &&
!(file_handle->fileaccess&GENERIC_ALL)) {
#ifdef DEBUG
- g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_READ or GENERIC_WRITE access: %u", handle, file_private_handle->fd, file_handle->fileaccess);
+ g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_READ or GENERIC_WRITE access: %u", handle, file_private_handle->fd_mapped.fd, file_handle->fileaccess);
#endif
+ SetLastError (ERROR_ACCESS_DENIED);
return(INVALID_FILE_SIZE);
}
- ret=fstat(file_private_handle->fd, &statbuf);
+ ret=fstat(file_private_handle->fd_mapped.fd, &statbuf);
if(ret==-1) {
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
": handle %p fd %d fstat failed: %s", handle,
- file_private_handle->fd, strerror(errno));
+ file_private_handle->fd_mapped.fd, strerror(errno));
#endif
+ _wapi_set_last_error_from_errno ();
return(INVALID_FILE_SIZE);
}
@@ -895,26 +958,34 @@ static gboolean file_getfiletime(gpointer handle, WapiFileTime *create_time,
if(ok==FALSE) {
g_warning (G_GNUC_PRETTY_FUNCTION
": error looking up file handle %p", handle);
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ if (file_private_handle->fd_mapped.assigned == FALSE) {
+ SetLastError (ERROR_INVALID_HANDLE);
return(FALSE);
}
if(!(file_handle->fileaccess&GENERIC_READ) &&
!(file_handle->fileaccess&GENERIC_ALL)) {
#ifdef DEBUG
- g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_READ access: %u", handle, file_private_handle->fd, file_handle->fileaccess);
+ g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_READ access: %u", handle, file_private_handle->fd_mapped.fd, file_handle->fileaccess);
#endif
+ SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
- ret=fstat(file_private_handle->fd, &statbuf);
+ ret=fstat(file_private_handle->fd_mapped.fd, &statbuf);
if(ret==-1) {
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
": handle %p fd %d fstat failed: %s", handle,
- file_private_handle->fd, strerror(errno));
+ file_private_handle->fd_mapped.fd, strerror(errno));
#endif
+ _wapi_set_last_error_from_errno ();
return(FALSE);
}
@@ -986,45 +1057,66 @@ static gboolean file_setfiletime(gpointer handle,
if(ok==FALSE) {
g_warning (G_GNUC_PRETTY_FUNCTION
": error looking up file handle %p", handle);
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ if (file_private_handle->fd_mapped.assigned == FALSE) {
+ SetLastError (ERROR_INVALID_HANDLE);
return(FALSE);
}
if(!(file_handle->fileaccess&GENERIC_WRITE) &&
!(file_handle->fileaccess&GENERIC_ALL)) {
#ifdef DEBUG
- g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_WRITE access: %u", handle, file_private_handle->fd, file_handle->fileaccess);
+ g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_WRITE access: %u", handle, file_private_handle->fd_mapped.fd, file_handle->fileaccess);
#endif
+ SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
if(file_handle->filename==0) {
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
": handle %p fd %d unknown filename", handle,
- file_private_handle->fd);
+ file_private_handle->fd_mapped.fd);
#endif
+ 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(file_private_handle->fd, &statbuf);
+ ret=fstat(file_private_handle->fd_mapped.fd, &statbuf);
if(ret==-1) {
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
": handle %p fd %d fstat failed: %s", handle,
- file_private_handle->fd, strerror(errno));
+ file_private_handle->fd_mapped.fd, strerror(errno));
#endif
+ 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) {
+#ifdef DEBUG
+ g_message (G_GNUC_PRETTY_FUNCTION
+ ": attempt to set access time too early");
+#endif
+ SetLastError (ERROR_INVALID_PARAMETER);
+ return(FALSE);
+ }
+
utbuf.actime=(access_ticks - 116444736000000000ULL) / 10000000;
} else {
utbuf.actime=statbuf.st_atime;
@@ -1033,6 +1125,18 @@ static gboolean file_setfiletime(gpointer handle,
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) {
+#ifdef DEBUG
+ g_message (G_GNUC_PRETTY_FUNCTION
+ ": attempt to set write time too early");
+#endif
+ SetLastError (ERROR_INVALID_PARAMETER);
+ return(FALSE);
+ }
+
utbuf.modtime=(write_ticks - 116444736000000000ULL) / 10000000;
} else {
utbuf.modtime=statbuf.st_mtime;
@@ -1051,10 +1155,12 @@ static gboolean file_setfiletime(gpointer handle,
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
": handle %p [%s] fd %d utime failed: %s", handle,
- name, file_private_handle->fd, strerror(errno));
+ name, file_private_handle->fd_mapped.fd,
+ strerror(errno));
#endif
g_free (name);
+ SetLastError (ERROR_INVALID_PARAMETER);
return(FALSE);
}
@@ -1073,6 +1179,7 @@ static void console_close_shared (gpointer handle)
if(ok==FALSE) {
g_warning (G_GNUC_PRETTY_FUNCTION
": error looking up console handle %p", handle);
+ SetLastError (ERROR_INVALID_HANDLE);
return;
}
@@ -1100,16 +1207,22 @@ static void console_close_private (gpointer handle)
if(ok==FALSE) {
g_warning (G_GNUC_PRETTY_FUNCTION
": error looking up console handle %p", handle);
+ SetLastError (ERROR_INVALID_HANDLE);
return;
}
+ if (console_private_handle->fd_mapped.assigned == TRUE) {
#ifdef DEBUG
- g_message(G_GNUC_PRETTY_FUNCTION
- ": closing console handle %p with fd %d", handle,
- console_private_handle->fd);
+ g_message(G_GNUC_PRETTY_FUNCTION
+ ": closing console handle %p with fd %d", handle,
+ console_private_handle->fd_mapped.fd);
#endif
- close(console_private_handle->fd);
+ /* Blank out the mapping, to make catching errors easier */
+ _wapi_handle_fd_offset_store (console_private_handle->fd_mapped.fd, NULL);
+
+ close(console_private_handle->fd_mapped.fd);
+ }
}
static WapiFileType console_getfiletype(void)
@@ -1132,6 +1245,12 @@ static gboolean console_read(gpointer handle, gpointer buffer,
if(ok==FALSE) {
g_warning (G_GNUC_PRETTY_FUNCTION
": error looking up console handle %p", handle);
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ if (console_private_handle->fd_mapped.assigned == FALSE) {
+ SetLastError (ERROR_INVALID_HANDLE);
return(FALSE);
}
@@ -1142,24 +1261,28 @@ static gboolean console_read(gpointer handle, gpointer buffer,
if(!(console_handle->fileaccess&GENERIC_READ) &&
!(console_handle->fileaccess&GENERIC_ALL)) {
#ifdef DEBUG
- g_message(G_GNUC_PRETTY_FUNCTION": handle %p fd %d doesn't have GENERIC_READ access: %u", handle, console_private_handle->fd, console_handle->fileaccess);
+ g_message(G_GNUC_PRETTY_FUNCTION": handle %p fd %d doesn't have GENERIC_READ access: %u", handle, console_private_handle->fd_mapped.fd, console_handle->fileaccess);
#endif
+ SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
do {
- ret=read(console_private_handle->fd, buffer, numbytes);
+ ret=read(console_private_handle->fd_mapped.fd, buffer,
+ numbytes);
}
while (ret==-1 && errno==EINTR && !_wapi_thread_cur_apc_pending());
if(ret==-1) {
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
": read of handle %p fd %d error: %s", handle,
- console_private_handle->fd, strerror(errno));
+ console_private_handle->fd_mapped.fd,
+ strerror(errno));
#endif
+ _wapi_set_last_error_from_errno ();
return(FALSE);
}
@@ -1185,6 +1308,12 @@ static gboolean console_write(gpointer handle, gconstpointer buffer,
if(ok==FALSE) {
g_warning (G_GNUC_PRETTY_FUNCTION
": error looking up console handle %p", handle);
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ if (console_private_handle->fd_mapped.assigned == FALSE) {
+ SetLastError (ERROR_INVALID_HANDLE);
return(FALSE);
}
@@ -1195,24 +1324,28 @@ static gboolean console_write(gpointer handle, gconstpointer buffer,
if(!(console_handle->fileaccess&GENERIC_WRITE) &&
!(console_handle->fileaccess&GENERIC_ALL)) {
#ifdef DEBUG
- g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_WRITE access: %u", handle, console_private_handle->fd, console_handle->fileaccess);
+ g_message(G_GNUC_PRETTY_FUNCTION ": handle %p fd %d doesn't have GENERIC_WRITE access: %u", handle, console_private_handle->fd_mapped.fd, console_handle->fileaccess);
#endif
+ SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
do {
- ret=write(console_private_handle->fd, buffer, numbytes);
+ ret=write(console_private_handle->fd_mapped.fd, buffer,
+ numbytes);
}
while (ret==-1 && errno==EINTR && !_wapi_thread_cur_apc_pending());
if(ret==-1) {
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION
": write of handle %p fd %d error: %s", handle,
- console_private_handle->fd, strerror(errno));
+ console_private_handle->fd_mapped.fd,
+ strerror(errno));
#endif
+ _wapi_set_last_error_from_errno ();
return(FALSE);
}
if(byteswritten!=NULL) {