diff --git a/src/coreclr/scripts/genEventPipe.py b/src/coreclr/scripts/genEventPipe.py index 527180028a9fb..2f3bd00be0a35 100644 --- a/src/coreclr/scripts/genEventPipe.py +++ b/src/coreclr/scripts/genEventPipe.py @@ -1107,7 +1107,9 @@ def getMonoEventPipeImplFilePrefix(): #if WCHAR_MAX == 0xFFFF provider_name_utf8 = g_utf16_to_utf8 ((const gunichar2 *)provider_name, -1, NULL, NULL, NULL); #else - provider_name_utf8 = g_ucs4_to_utf8 ((const gunichar *)provider_name, -1, NULL, NULL, NULL); + gunichar2 *provider_name_utf16 = g_ucs4_to_utf16 ((const gunichar *)provider_name, -1, NULL, NULL, NULL); + provider_name_utf8 = g_utf16_to_utf8 (provider_name_utf16, -1, NULL, NULL, NULL); + g_free (provider_name_utf16); #endif ep_return_null_if_nok (provider_name_utf8 != NULL); diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index e43b6fb079d12..6909e62fcf0bd 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -16,6 +16,18 @@ if (MSVC) if(EXISTS ${CLR_SOURCELINK_FILE_PATH}) add_link_options("/sourcelink:${CLR_SOURCELINK_FILE_PATH}") endif() + + # FIXME This is all questionable but the logs are flooded and nothing else is fixing them. + add_compile_options($<$:/wd4090>) # W1: const problem + add_compile_options($<$:/wd4100>) # W4: unreferenced formal parameter + add_compile_options($<$:/wd4152>) # W4: nonstandard extension, function/data pointer conversion in expression + add_compile_options($<$:/wd4201>) # W4: nonstandard extension used: nameless struct/union + add_compile_options($<$:/wd4210>) # W4: nonstandard extension used: function given file scope + add_compile_options($<$:/wd4245>) # W4: signed/unsigned mismatch + add_compile_options($<$:/wd4389>) # W4: signed/unsigned mismatch + add_compile_options($<$:/wd4505>) # W4: unreferenced function with internal linkage has been removed + add_compile_options($<$:/wd4702>) # W4: unreachable code + add_compile_options($<$:/wd4706>) # W4: assignment within conditional expression endif(MSVC) set(CROSS_ROOTFS $ENV{ROOTFS_DIR}) @@ -76,7 +88,6 @@ if(ENABLE_MINIMAL) endif() set(DISABLE_COM 1) -set(DISABLE_DLLMAP 1) # Dependencies between options if(ENABLE_INTERP_LIB) @@ -102,7 +113,6 @@ if(GCC) set(USE_GCC_ATOMIC_OPS 1) endif() -set(HAVE_CLASSIC_WINAPI_SUPPORT 1) set(HAVE_MOVING_COLLECTOR 1) set(HAVE_CONC_GC_AS_DEFAULT 1) set(MONO_INSIDE_RUNTIME 1) @@ -796,7 +806,6 @@ if(HOST_WIN32) set(EGLIB_PATHSEP "\\\\") set(EGLIB_SEARCHSEP ";") set(EGLIB_OS "WIN32") - set(EGLIB_PIDTYPE "void *") if(HOST_AMD64 OR HOST_ARM64) set(EGLIB_GSIZE_FORMAT "\"Iu\"") else() @@ -814,7 +823,6 @@ else() set(EGLIB_PATHSEP "/") set(EGLIB_SEARCHSEP ":") set(EGLIB_OS "UNIX") - set(EGLIB_PIDTYPE "int") set(EGLIB_GSIZE_FORMAT "\"zu\"") endif() diff --git a/src/mono/cmake/config.h.in b/src/mono/cmake/config.h.in index 087398f7a6348..41286766d7bc4 100644 --- a/src/mono/cmake/config.h.in +++ b/src/mono/cmake/config.h.in @@ -3,18 +3,6 @@ #ifdef _MSC_VER -// FIXME This is all questionable but the logs are flooded and nothing else is fixing them. -#pragma warning(disable:4090) // W1: const problem -#pragma warning(disable:4100) // W4: unreferenced formal parameter -#pragma warning(disable:4152) // W4: nonstandard extension, function/data pointer conversion in expression -#pragma warning(disable:4201) // W4: nonstandard extension used: nameless struct/union -#pragma warning(disable:4210) // W4: nonstandard extension used: function given file scope -#pragma warning(disable:4245) // W4: signed/unsigned mismatch -#pragma warning(disable:4389) // W4: signed/unsigned mismatch -#pragma warning(disable:4505) // W4: unreferenced function with internal linkage has been removed -#pragma warning(disable:4702) // W4: unreachable code -#pragma warning(disable:4706) // W4: assignment within conditional expression - #include #if _WIN32_WINNT < 0x0601 @@ -30,13 +18,13 @@ #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) #define HAVE_CLASSIC_WINAPI_SUPPORT 1 - #define HAVE_UWP_WINAPI_SUPPORT 0 + #define HAVE_APP_WINAPI_SUPPORT 0 #elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) #define HAVE_CLASSIC_WINAPI_SUPPORT 0 - #define HAVE_UWP_WINAPI_SUPPORT 1 + #define HAVE_APP_WINAPI_SUPPORT 1 #else #define HAVE_CLASSIC_WINAPI_SUPPORT 0 - #define HAVE_UWP_WINAPI_SUPPORT 0 + #define HAVE_APP_WINAPI_SUPPORT 0 #ifndef HAVE_EXTERN_DEFINED_WINAPI_SUPPORT #error Unsupported WINAPI family #endif @@ -105,12 +93,6 @@ /* Target Platform is Linux (musl libc)*/ #cmakedefine TARGET_LINUX_MUSL 1 -/* Use classic Windows API support */ -#cmakedefine HAVE_CLASSIC_WINAPI_SUPPORT 1 - -/* Don't use UWP Windows API support */ -#cmakedefine HAVE_UWP_WINAPI_SUPPORT 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_TYPES_H 1 @@ -135,21 +117,12 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYSLOG_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_FILIO_H 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_SOCKIO_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_NETDB_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_UTIME_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_UTIME_H 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SEMAPHORE_H 1 @@ -210,9 +183,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UNWIND_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_USER_H 1 - /* Use static ICU */ #cmakedefine STATIC_ICU 1 @@ -308,9 +278,6 @@ /* Disable sockets */ #cmakedefine DISABLE_SOCKETS 1 -/* Disables use of DllMaps in MonoVM */ -#cmakedefine DISABLE_DLLMAP 1 - /* Disable Threads */ #cmakedefine DISABLE_THREADS 1 @@ -323,9 +290,6 @@ /* Define to 1 if you have the `sigaction' function. */ #cmakedefine HAVE_SIGACTION 1 -/* Define to 1 if you have the `kill' function. */ -#cmakedefine HAVE_KILL 1 - /* CLOCK_MONOTONIC */ #cmakedefine HAVE_CLOCK_MONOTONIC 1 @@ -365,9 +329,6 @@ /* Define to 1 if you have the `madvise' function. */ #cmakedefine HAVE_MADVISE 1 -/* Define to 1 if you have the `getrusage' function. */ -#cmakedefine HAVE_GETRUSAGE 1 - /* Define to 1 if you have the `dladdr' function. */ #cmakedefine HAVE_DLADDR 1 @@ -380,39 +341,18 @@ /* Define to 1 if you have the `prctl' function. */ #cmakedefine HAVE_PRCTL 1 -/* Define to 1 if you have the `nl_langinfo' function. */ -#cmakedefine HAVE_NL_LANGINFO 1 - /* sched_getaffinity */ #cmakedefine HAVE_SCHED_GETAFFINITY 1 /* sched_setaffinity */ #cmakedefine HAVE_SCHED_SETAFFINITY 1 -/* Define to 1 if you have the `chmod' function. */ -#cmakedefine HAVE_CHMOD 1 - /* Define to 1 if you have the `lstat' function. */ #cmakedefine HAVE_LSTAT 1 -/* Define to 1 if you have the `getdtablesize' function. */ -#cmakedefine HAVE_GETDTABLESIZE 1 - /* Define to 1 if you have the `ftruncate' function. */ #cmakedefine HAVE_FTRUNCATE 1 -/* Define to 1 if you have the `msync' function. */ -#cmakedefine HAVE_MSYNC 1 - -/* Define to 1 if you have the `getpeername' function. */ -#cmakedefine HAVE_GETPEERNAME 1 - -/* Define to 1 if you have the `utime' function. */ -#cmakedefine HAVE_UTIME 1 - -/* Define to 1 if you have the `utimes' function. */ -#cmakedefine HAVE_UTIMES 1 - /* Define to 1 if you have the `openlog' function. */ #cmakedefine HAVE_OPENLOG 1 @@ -443,24 +383,6 @@ /* Have gethostbyname */ #cmakedefine HAVE_GETHOSTBYNAME 1 -/* Have getprotobyname */ -#cmakedefine HAVE_GETPROTOBYNAME 1 - -/* Have getprotobyname_r */ -#cmakedefine HAVE_GETPROTOBYNAME_R 1 - -/* Have getnameinfo */ -#cmakedefine HAVE_GETNAMEINFO 1 - -/* Have inet_ntop */ -#cmakedefine HAVE_INET_NTOP 1 - -/* Have inet_pton */ -#cmakedefine HAVE_INET_PTON 1 - -/* Define to 1 if you have the `inet_aton' function. */ -#cmakedefine HAVE_INET_ATON 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_PTHREAD_H 1 @@ -523,54 +445,30 @@ /* sockaddr_in6 has sin6_len */ #cmakedefine HAVE_SOCKADDR_IN6_SIN_LEN 1 -/* Have getifaddrs */ -#cmakedefine HAVE_GETIFADDRS 1 - -/* Have access */ -#cmakedefine HAVE_ACCESS 1 - /* Have getpid */ #cmakedefine HAVE_GETPID 1 /* Have mktemp */ #cmakedefine HAVE_MKTEMP 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_STATVFS_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_STATFS_H 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_MMAN_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_MOUNT_H 1 -/* Define to 1 if you have the `getfsstat' function. */ -#cmakedefine HAVE_GETFSSTAT 1 - /* Define to 1 if you have the `mremap' function. */ #cmakedefine HAVE_MREMAP 1 -/* Define to 1 if you have the `posix_fadvise' function. */ -#cmakedefine HAVE_POSIX_FADVISE 1 - /* Define to 1 if you have the `vsnprintf' function. */ #cmakedefine HAVE_VSNPRINTF 1 -/* struct statfs */ -#cmakedefine HAVE_STATFS 1 - -/* Define to 1 if you have the `statvfs' function. */ -#cmakedefine HAVE_STATVFS 1 - /* Define to 1 if you have the `setpgid' function. */ #cmakedefine HAVE_SETPGID 1 /* Define to 1 if you have the `system' function. */ #ifdef _MSC_VER -#if HAVE_WINAPI_FAMILY_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#if HAVE_CLASSIC_WINAPI_SUPPORT #cmakedefine HAVE_SYSTEM 1 #endif #else @@ -580,15 +478,6 @@ /* Define to 1 if you have the `fork' function. */ #cmakedefine HAVE_FORK 1 -/* Define to 1 if you have the `execv' function. */ -#cmakedefine HAVE_EXECV 1 - -/* Define to 1 if you have the `execve' function. */ -#cmakedefine HAVE_EXECVE 1 - -/* Define to 1 if you have the `waitpid' function. */ -#cmakedefine HAVE_WAITPID 1 - /* Define to 1 if you have the `localtime_r' function. */ #cmakedefine HAVE_LOCALTIME_R 1 @@ -609,18 +498,6 @@ /* Define to 1 if the system has the type `struct sockaddr_in6'. */ #cmakedefine HAVE_STRUCT_SOCKADDR_IN6 1 -/* Define to 1 if the system has the type `struct stat'. */ -#cmakedefine HAVE_STRUCT_STAT 1 - -/* Define to 1 if the system has the type `struct timeval'. */ -#cmakedefine HAVE_STRUCT_TIMEVAL 1 - -/* Define to 1 if `st_atim' is a member of `struct stat'. */ -#cmakedefine HAVE_STRUCT_STAT_ST_ATIM 1 - -/* Define to 1 if `st_atimespec' is a member of `struct stat'. */ -#cmakedefine HAVE_STRUCT_STAT_ST_ATIMESPEC 1 - /* Define to 1 if `super_class' is a member of `struct objc_super'. */ #cmakedefine HAVE_OBJC_SUPER_SUPER_CLASS 1 @@ -807,15 +684,9 @@ /* Defaults to concurrent GC */ #cmakedefine HAVE_CONC_GC_AS_DEFAULT 1 -/* Define to 1 if you have the `stpcpy' function. */ -#cmakedefine HAVE_STPCPY 1 - /* Define to 1 if you have the `strtok_r' function. */ #cmakedefine HAVE_STRTOK_R 1 -/* Define to 1 if you have the `rewinddir' function. */ -#cmakedefine HAVE_REWINDDIR 1 - /* Define to 1 if you have the `vasprintf' function. */ #cmakedefine HAVE_VASPRINTF 1 diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index 013783129c995..e213783fa28b1 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -65,25 +65,25 @@ function(ac_check_type type suffix includes) endfunction() ac_check_headers ( - sys/types.h sys/stat.h sys/filio.h sys/sockio.h sys/utime.h sys/un.h sys/syscall.h sys/uio.h sys/param.h + sys/types.h sys/stat.h sys/sockio.h sys/un.h sys/syscall.h sys/uio.h sys/param.h sys/prctl.h sys/socket.h sys/utsname.h sys/select.h sys/poll.h sys/wait.h sys/resource.h - sys/ioctl.h sys/errno.h sys/statvfs.h sys/statfs.h sys/mman.h sys/mount.h sys/time.h sys/random.h - strings.h stdint.h unistd.h signal.h setjmp.h syslog.h netdb.h utime.h semaphore.h alloca.h ucontext.h pwd.h elf.h + sys/ioctl.h sys/errno.h sys/mman.h sys/mount.h sys/time.h sys/random.h + strings.h stdint.h unistd.h signal.h setjmp.h syslog.h netdb.h semaphore.h alloca.h ucontext.h pwd.h elf.h gnu/lib-names.h netinet/tcp.h netinet/in.h link.h arpa/inet.h unwind.h poll.h wchar.h android/legacy_signal_inlines.h execinfo.h pthread.h pthread_np.h net/if.h dirent.h CommonCrypto/CommonDigest.h dlfcn.h getopt.h pwd.h alloca.h /usr/include/malloc.h) ac_check_funcs ( - sigaction kill clock_nanosleep backtrace_symbols mkstemp mmap - getrusage dladdr sysconf getrlimit prctl nl_langinfo - sched_getaffinity sched_setaffinity chmod lstat getdtablesize ftruncate msync - getpeername utime utimes openlog closelog atexit popen strerror_r inet_pton inet_aton - poll getfsstat mremap posix_fadvise vsnprintf statfs statvfs setpgid system - fork execv execve waitpid localtime_r mkdtemp getrandom getentropy execvp strlcpy stpcpy strtok_r rewinddir - vasprintf strndup getprotobyname getprotobyname_r getaddrinfo mach_absolute_time - gethrtime read_real_time gethostbyname gethostbyname2 getnameinfo getifaddrs - access inet_ntop Qp2getifaddrs getpid mktemp) + sigaction clock_nanosleep backtrace_symbols mkstemp mmap + dladdr sysconf getrlimit prctl + sched_getaffinity sched_setaffinity lstat ftruncate + openlog closelog atexit popen strerror_r + poll mremap vsnprintf setpgid system + fork localtime_r mkdtemp getrandom getentropy execvp strlcpy strtok_r + vasprintf strndup getaddrinfo mach_absolute_time + gethrtime read_real_time gethostbyname gethostbyname2 + getpid mktemp) if (HOST_LINUX OR HOST_BROWSER OR HOST_WASI) # sysctl is deprecated on Linux and doesn't work on Browser @@ -92,18 +92,6 @@ else () check_include_files("sys/types.h;sys/sysctl.h" HAVE_SYS_SYSCTL_H) endif() -if (HOST_WASI) - # sysctl is deprecated on Linux and doesn't work on WASI - set(HAVE_GETRUSAGE 0) -endif() - -check_include_files("sys/types.h;sys/user.h" HAVE_SYS_USER_H) - -if(HOST_IOS OR HOST_TVOS OR HOST_MACCAT) - # getentropy isn't allowed in the AppStore: https://github.com/rust-lang/rust/issues/102643 - set(HAVE_GETENTROPY 0) -endif() - if(NOT DISABLE_THREADS) find_package(Threads) endif() @@ -127,7 +115,6 @@ check_symbol_exists(pthread_jit_write_protect_np "pthread.h" HAVE_PTHREAD_JIT_WR check_symbol_exists(getauxval sys/auxv.h HAVE_GETAUXVAL) ac_check_type("struct sockaddr_in6" sockaddr_in6 "netinet/in.h") -ac_check_type("struct timeval" timeval "sys/time.h;sys/types.h;utime.h") ac_check_type("socklen_t" socklen_t "sys/types.h;sys/socket.h") ac_check_type("struct ip_mreqn" ip_mreqn "netinet/in.h") ac_check_type("struct ip_mreq" ip_mreq "netinet/in.h") @@ -135,8 +122,6 @@ ac_check_type("clockid_t" clockid_t "sys/types.h") check_struct_has_member("struct sockaddr_in" sin_len "netinet/in.h" HAVE_SOCKADDR_IN_SIN_LEN) check_struct_has_member("struct sockaddr_in6" sin6_len "netinet/in.h" HAVE_SOCKADDR_IN6_SIN_LEN) -check_struct_has_member("struct stat" st_atim "sys/types.h;sys/stat.h;unistd.h" HAVE_STRUCT_STAT_ST_ATIM) -check_struct_has_member("struct stat" st_atimespec "sys/types.h;sys/stat.h;unistd.h" HAVE_STRUCT_STAT_ST_ATIMESPEC) if (HOST_DARWIN) check_struct_has_member("struct objc_super" super_class "objc/runtime.h;objc/message.h" HAVE_OBJC_SUPER_SUPER_CLASS) @@ -235,36 +220,32 @@ if (TARGET_RISCV32 OR TARGET_RISCV64) endif() endif() +# +# Override checks +# + if(HOST_WIN32) # checking for this doesn't work for some reason, hardcode result set(HAVE_WINTERNL_H 1) - set(HAVE_CRYPT_RNG 1) set(HAVE_GETADDRINFO 1) - set(HAVE_GETNAMEINFO 1) - set(HAVE_GETPROTOBYNAME 1) - set(HAVE_INET_NTOP 1) - set(HAVE_INET_PTON 1) set(HAVE_STRUCT_SOCKADDR_IN6 1) set(HAVE_STRTOK_R 1) set(HAVE_EXECVP 0) -elseif(HOST_IOS OR HOST_TVOS) +elseif(HOST_IOS OR HOST_TVOS OR HOST_MACCAT) set(HAVE_SYSTEM 0) - set(HAVE_SYS_USER_H 0) + # getentropy isn't allowed in the AppStore: https://github.com/rust-lang/rust/issues/102643 + set(HAVE_GETENTROPY 0) if(HOST_TVOS) set(HAVE_PTHREAD_KILL 0) - set(HAVE_KILL 0) set(HAVE_SIGACTION 0) set(HAVE_FORK 0) - set(HAVE_EXECV 0) - set(HAVE_EXECVE 0) set(HAVE_EXECVP 0) endif() -elseif(HOST_MACCAT) - set(HAVE_SYSTEM 0) elseif(HOST_BROWSER) set(HAVE_FORK 0) + # wasm does have strtok_r even though cmake fails to find it + set(HAVE_STRTOK_R 1) elseif(HOST_SOLARIS) - set(HAVE_GETPROTOBYNAME 1) set(HAVE_NETINET_TCP_H 1) set(HAVE_GETADDRINFO 1) elseif(HOST_WASI) @@ -276,10 +257,10 @@ elseif(HOST_WASI) set(HAVE_NETINET_TCP_H 0) set(HAVE_ARPA_INET_H 0) set(HAVE_MKDTEMP 0) - set(HAVE_EXECVE 0) set(HAVE_FORK 0) + # wasm does have strtok_r even though cmake fails to find it + set(HAVE_STRTOK_R 1) set(HAVE_GETRLIMIT 0) - set(HAVE_GETDTABLESIZE 0) set(HAVE_MKSTEMP 0) set(HAVE_BACKTRACE_SYMBOLS 0) set(HAVE_GETPID 0) @@ -288,16 +269,9 @@ elseif(HOST_WASI) set(HAVE_READ_REAL_TIME 0) set(HAVE_SCHED_GETAFFINITY 0) set(HAVE_SCHED_SETAFFINITY 0) - set(HAVE_GETIFADDRS 0) set(HAVE_GETADDRINFO 0) set(HAVE_GETHOSTBYNAME 0) set(HAVE_GETHOSTBYNAME2 0) - set(HAVE_GETPROTOBYNAME 0) - set(HAVE_GETNAMEINFO 0) - set(HAVE_INET_NTOP 0) - set(HAVE_SYS_ICU 0) set(HAVE_EXECVP 0) set(HAVE_MMAP 1) - set(DISABLE_PROFILER 1) - set(ENABLE_INTERP_LIB 1) endif() diff --git a/src/mono/cmake/eglib-config.h.cmake.in b/src/mono/cmake/eglib-config.h.cmake.in index 556474fbfc1f4..5a70babc77a3a 100644 --- a/src/mono/cmake/eglib-config.h.cmake.in +++ b/src/mono/cmake/eglib-config.h.cmake.in @@ -13,7 +13,6 @@ /* FIXME: what should this be ?*/ #define X_OK 4 /* This is really read */ -#define WNOHANG 1 #define F_SETFD 1 #define FD_CLOEXEC 1 @@ -25,11 +24,6 @@ #define strtok_r strtok_s #undef G_HAVE_UNISTD_H -#undef G_HAVE_SYS_TIME_H -#undef G_HAVE_SYS_WAIT_H -#undef G_HAVE_PWD_H -#undef G_HAVE_STRNDUP -#define G_HAVE_GETOPT_H 1 #else @@ -73,7 +67,6 @@ typedef @EGLIB_GSIZE@ gsize; typedef @EGLIB_GSSIZE@ gssize; -typedef @EGLIB_PIDTYPE@ GPid; #ifdef _MSC_VER typedef int pid_t; diff --git a/src/mono/cmake/options.cmake b/src/mono/cmake/options.cmake index 4a1db314d468b..e5921ac358f5f 100644 --- a/src/mono/cmake/options.cmake +++ b/src/mono/cmake/options.cmake @@ -3,16 +3,11 @@ # option (DISABLE_AOT "Disable AOT Compiler") -option (DISABLE_PROFILER "Disable default profiler support") -option (DISABLE_DECIMAL "Disable System.Decimal support") -option (DISABLE_PINVOKE "Disable P/Invoke support") option (DISABLE_DEBUG "Disable runtime debugging support") option (DISABLE_REFLECTION_EMIT "Disable reflection emit support") -option (DISABLE_LARGE_CODE "Disable support for huge assemblies") option (DISABLE_LOGGING "Disable support debug logging") option (DISABLE_COM "Disable COM support") option (DISABLE_SSA "Disable advanced SSA JIT optimizations") -option (DISABLE_GENERICS "Disable generics support") option (DISABLE_JIT "Disable the JIT, only full-aot mode or interpreter will be supported by the runtime.") option (DISABLE_INTERPRETER "Disable the interpreter.") option (DISABLE_SIMD "Disable SIMD intrinsics related optimizations.") @@ -24,11 +19,9 @@ option (DISABLE_SGEN_SPLIT_NURSERY "Disable minor=split support in SGEN.") option (DISABLE_SGEN_GC_BRIDGE "Disable gc bridge support in SGEN.") option (DISABLE_SGEN_DEBUG_HELPERS "Disable debug helpers in SGEN.") option (DISABLE_SOCKETS "Disable sockets") -option (DISABLE_DLLMAP "Disables use of DllMaps in MonoVM") option (DISABLE_THREADS "Disable Threads") option (DISABLE_SGEN_TOGGLEREF "Disable toggleref support in SGEN") option (DISABLE_SGEN_BINARY_PROTOCOL "Disable binary protocol logging in SGEN") -option (DISABLE_PROCESSES "Disable process support") option (DISABLE_EVENTPIPE "Disable EventPipe support") option (DISABLE_EXECUTABLES "Disable the build of the runtime executables") option (DISABLE_ICALL_TABLES "Enable separate icall table library") diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index 967ea555f9690..f61b3dc09e172 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -27,6 +27,8 @@ set(${MONO_DEBUGGER_COMPONENT_NAME}-sources ${MONO_COMPONENT_PATH}/debugger.h ${MONO_COMPONENT_PATH}/debugger-networking.c ${MONO_COMPONENT_PATH}/debugger-networking.h + ${MONO_COMPONENT_PATH}/debugger-poll.c + ${MONO_COMPONENT_PATH}/debugger-poll.h ${MONO_COMPONENT_PATH}/debugger-agent.c ${MONO_COMPONENT_PATH}/debugger-agent.h ${MONO_COMPONENT_PATH}/debugger-engine.c diff --git a/src/mono/mono/component/debugger-agent.c b/src/mono/mono/component/debugger-agent.c index e5fd65378515a..27eaf5700f15b 100644 --- a/src/mono/mono/component/debugger-agent.c +++ b/src/mono/mono/component/debugger-agent.c @@ -85,17 +85,17 @@ #include #include #include -#include #include -#include "debugger-agent.h" -#include "debugger-networking.h" +#include +#include +#include #include #include #include #include #include -#include "debugger-engine.h" +#include #include #include #include @@ -173,7 +173,6 @@ typedef struct { gboolean onuncaught; GSList *onthrow; int timeout; - char *launch; gboolean embedding; gboolean defer; int keepalive; @@ -661,7 +660,7 @@ debugger_agent_parse_options (char *options) } else if (strncmp (arg, "timeout=", 8) == 0) { agent_config.timeout = atoi (arg + 8); } else if (strncmp (arg, "launch=", 7) == 0) { - agent_config.launch = g_strdup (arg + 7); + // no longer supported } else if (strncmp (arg, "embedding=", 10) == 0) { agent_config.embedding = atoi (arg + 10) == 1; } else if (strncmp (arg, "keepalive=", 10) == 0) { @@ -856,30 +855,6 @@ finish_agent_init (gboolean on_startup) if (mono_atomic_cas_i32 (&agent_inited, 1, 0) == 1) return; - if (agent_config.launch) { - - // FIXME: Generated address - // FIXME: Races with transport_connect () - -#ifdef G_OS_WIN32 - // Nothing. FIXME? g_spawn_async_with_pipes is easy enough to provide for Windows if needed. -#elif !HAVE_G_SPAWN - PRINT_ERROR_MSG ("g_spawn_async_with_pipes not supported on this platform\n"); - exit (1); -#else - char *argv [ ] = { - agent_config.launch, - agent_config.transport, - agent_config.address, - NULL - }; - int res = g_spawn_async_with_pipes (NULL, argv, NULL, (GSpawnFlags)0, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - if (!res) { - PRINT_ERROR_MSG ("Failed to execute '%s'.\n", agent_config.launch); - exit (1); - } -#endif - } #ifndef HOST_WASI transport_connect (agent_config.address); #else diff --git a/src/mono/mono/utils/mono-poll.c b/src/mono/mono/component/debugger-poll.c similarity index 99% rename from src/mono/mono/utils/mono-poll.c rename to src/mono/mono/component/debugger-poll.c index 5c5c2c6f30bcd..b914c7bdde05e 100644 --- a/src/mono/mono/utils/mono-poll.c +++ b/src/mono/mono/component/debugger-poll.c @@ -9,7 +9,7 @@ #include #endif -#include "mono-poll.h" +#include "debugger-poll.h" #include #include diff --git a/src/mono/mono/utils/mono-poll.h b/src/mono/mono/component/debugger-poll.h similarity index 90% rename from src/mono/mono/utils/mono-poll.h rename to src/mono/mono/component/debugger-poll.h index 4293cf884cd44..17f1d13befe01 100644 --- a/src/mono/mono/utils/mono-poll.h +++ b/src/mono/mono/component/debugger-poll.h @@ -2,8 +2,8 @@ * \file */ -#ifndef MONO_POLL_H -#define MONO_POLL_H +#ifndef __MONO_DEBUGGER_POLL_H__ +#define __MONO_DEBUGGER_POLL_H__ #include @@ -57,5 +57,5 @@ mono_poll_can_add (mono_pollfd *ufds, unsigned int nfds, int fd); MONO_API int mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout); -#endif /* MONO_POLL_H */ +#endif /* __MONO_DEBUGGER_POLL_H__ */ diff --git a/src/mono/mono/eglib/CMakeLists.txt b/src/mono/mono/eglib/CMakeLists.txt index 09cf32eaa81ad..26b6427d6dbf1 100644 --- a/src/mono/mono/eglib/CMakeLists.txt +++ b/src/mono/mono/eglib/CMakeLists.txt @@ -1,12 +1,18 @@ project(eglib C) set(eglib_win32_sources - gdate-win32.c gdir-win32.c gfile-win32.c gmisc-win32.c - gmodule-win32.c gtimer-win32.c) + gdate-win32.c + gfile-win32.c + gmisc-win32.c + gmodule-win32.c + gtimer-win32.c) set(eglib_unix_sources - gdate-unix.c gdir-unix.c gfile-unix.c gmisc-unix.c - gmodule-unix.c gtimer-unix.c) + gdate-unix.c + gfile-unix.c + gmisc-unix.c + gmodule-unix.c + gtimer-unix.c) if(HOST_WIN32) set(eglib_platform_sources ${eglib_win32_sources}) @@ -30,7 +36,6 @@ set(eglib_common_sources glist.c gqueue.c gpath.c - gspawn.c gfile.c gfile-posix.c gutf8.c diff --git a/src/mono/mono/eglib/eglib-remap.h b/src/mono/mono/eglib/eglib-remap.h index f3238030e5059..5fc770dfa9732 100644 --- a/src/mono/mono/eglib/eglib-remap.h +++ b/src/mono/mono/eglib/eglib-remap.h @@ -29,11 +29,6 @@ #define g_clear_error monoeg_g_clear_error #define g_convert_error_quark monoeg_g_convert_error_quark #define g_fixed_buffer_custom_allocator monoeg_g_fixed_buffer_custom_allocator -#define g_dir_close monoeg_g_dir_close -#define g_dir_open monoeg_g_dir_open -#define g_dir_read_name monoeg_g_dir_read_name -#define g_dir_rewind monoeg_g_dir_rewind -#define g_mkdir_with_parents monoeg_g_mkdir_with_parents #define g_direct_equal monoeg_g_direct_equal #define g_direct_hash monoeg_g_direct_hash #define g_ensure_directory_exists monoeg_g_ensure_directory_exists @@ -43,14 +38,11 @@ #define g_file_error_quark monoeg_g_file_error_quark #define g_file_error_from_errno monoeg_g_file_error_from_errno #define g_file_get_contents monoeg_g_file_get_contents -#define g_file_set_contents monoeg_g_file_set_contents #define g_file_open_tmp monoeg_g_file_open_tmp #define g_file_test monoeg_g_file_test -#define g_find_program_in_path monoeg_g_find_program_in_path #define g_fprintf monoeg_g_fprintf #define g_free monoeg_g_free #define g_get_current_dir monoeg_g_get_current_dir -#define g_get_current_time monoeg_g_get_current_time #define g_get_tmp_dir monoeg_g_get_tmp_dir #define g_getenv monoeg_g_getenv #define g_hasenv monoeg_g_hasenv @@ -101,6 +93,7 @@ #define g_list_reverse monoeg_g_list_reverse #define g_list_sort monoeg_g_list_sort #define g_log monoeg_g_log +#define g_log_disabled monoeg_g_log_disabled #define g_log_set_always_fatal monoeg_g_log_set_always_fatal #define g_log_set_fatal_mask monoeg_g_log_set_fatal_mask #define g_logv monoeg_g_logv @@ -109,7 +102,6 @@ #define g_mem_get_vtable monoeg_g_mem_get_vtable #define g_mkdtemp monoeg_g_mkdtemp #define g_module_address monoeg_g_module_address -#define g_module_build_path monoeg_g_module_build_path #define g_module_close monoeg_g_module_close #define g_module_error monoeg_g_module_error #define g_module_open monoeg_g_module_open @@ -174,9 +166,7 @@ #define g_slist_sort monoeg_g_slist_sort #define g_snprintf monoeg_g_snprintf #define g_spaced_primes_closest monoeg_g_spaced_primes_closest -#define g_spawn_async_with_pipes monoeg_g_spawn_async_with_pipes #define g_sprintf monoeg_g_sprintf -#define g_stpcpy monoeg_g_stpcpy #define g_str_equal monoeg_g_str_equal #define g_str_has_prefix monoeg_g_str_has_prefix #define g_str_has_suffix monoeg_g_str_has_suffix @@ -193,7 +183,6 @@ #define g_string_append monoeg_g_string_append #define g_string_append_c monoeg_g_string_append_c #define g_string_append_len monoeg_g_string_append_len -#define g_string_append_unichar monoeg_g_string_append_unichar #define g_string_append_printf monoeg_g_string_append_printf #define g_string_append_vprintf monoeg_g_string_append_vprintf #define g_string_free monoeg_g_string_free @@ -203,8 +192,6 @@ #define g_string_set_size monoeg_g_string_set_size #define g_string_sized_new monoeg_g_string_sized_new #define g_string_truncate monoeg_g_string_truncate -#define g_strjoin monoeg_g_strjoin -#define g_strjoinv monoeg_g_strjoinv #define g_strlcpy monoeg_g_strlcpy #define g_strndup monoeg_g_strndup #define g_strnfill monoeg_g_strnfill @@ -218,25 +205,20 @@ #define g_timer_new monoeg_g_timer_new #define g_timer_start monoeg_g_timer_start #define g_timer_stop monoeg_g_timer_stop -#define g_trailingBytesForUTF8 monoeg_g_trailingBytesForUTF8 -#define g_ucs4_to_utf8 monoeg_g_ucs4_to_utf8 #define g_ucs4_to_utf16 monoeg_g_ucs4_to_utf16 #define g_usleep monoeg_g_usleep #define g_utf16_to_ucs4 monoeg_g_utf16_to_ucs4 #define g_utf16_to_utf8 monoeg_g_utf16_to_utf8 +#define g_utf16le_to_utf8 monoeg_gg_utf16le_to_utf8 #define g_utf16_to_utf8_custom_alloc monoeg_g_utf16_to_utf8_custom_alloc -#define g_utf16_ascii_equal monoeg_g_utf16_ascii_equal -#define g_utf16_asciiz_equal monoeg_g_utf16_asciiz_equal #define g_utf8_jump_table monoeg_g_utf8_jump_table -#define g_utf8_get_char monoeg_g_utf8_get_char #define g_utf8_strlen monoeg_g_utf8_strlen #define g_utf8_to_utf16 monoeg_g_utf8_to_utf16 +#define g_utf8_to_utf16le monoeg_g_utf8_to_utf16le +#define g_wtf8_to_utf16 monoeg_g_wtf8_to_utf16 #define g_utf8_to_utf16_custom_alloc monoeg_g_utf8_to_utf16_custom_alloc +#define g_utf8_to_utf16le_custom_alloc monoeg_g_utf8_to_utf16le_custom_alloc #define g_utf8_validate monoeg_g_utf8_validate -#define g_unichar_to_utf8 monoeg_g_unichar_to_utf8 -#define g_utf8_offset_to_pointer monoeg_g_utf8_offset_to_pointer -#define g_utf8_pointer_to_offset monoeg_g_utf8_pointer_to_offset -#define g_utf8_to_ucs4_fast monoeg_g_utf8_to_ucs4_fast #define g_vasprintf monoeg_g_vasprintf #define g_assertion_disable_global monoeg_assertion_disable_global #define g_assert_abort monoeg_assert_abort @@ -249,15 +231,12 @@ #define g_try_malloc monoeg_try_malloc #define g_try_realloc monoeg_try_realloc #define g_strdup monoeg_strdup -#define g_ucs4_to_utf16_len monoeg_ucs4_to_utf16_len -#define g_utf16_to_ucs4_len monoeg_utf16_to_ucs4_len #define g_utf16_len monoeg_utf16_len #define g_ascii_strcasecmp monoeg_ascii_strcasecmp #define g_ascii_strup monoeg_ascii_strup #define g_ascii_toupper monoeg_ascii_toupper #define g_unichar_to_utf16 monoeg_unichar_to_utf16 -#define g_utf8_get_char_validated monoeg_utf8_get_char_validated #define g_utf8_to_ucs4 monoeg_utf8_to_ucs4 diff --git a/src/mono/mono/eglib/gdate-unix.c b/src/mono/mono/eglib/gdate-unix.c index 9a98e66304576..7730b5566a70c 100644 --- a/src/mono/mono/eglib/gdate-unix.c +++ b/src/mono/mono/eglib/gdate-unix.c @@ -32,17 +32,6 @@ #include #include -void -g_get_current_time (GTimeVal *result) -{ - struct timeval tv; - - g_return_if_fail (result != NULL); - gettimeofday (&tv, NULL); - result->tv_sec = tv.tv_sec; - result->tv_usec = tv.tv_usec; -} - void g_usleep (gulong microseconds) { diff --git a/src/mono/mono/eglib/gdate-win32.c b/src/mono/mono/eglib/gdate-win32.c index b86894201fdfb..b031288888980 100644 --- a/src/mono/mono/eglib/gdate-win32.c +++ b/src/mono/mono/eglib/gdate-win32.c @@ -31,18 +31,6 @@ #include -void -g_get_current_time (GTimeVal *result) -{ - long int l; - - g_return_if_fail (result != NULL); - l = GetTickCount(); - - result->tv_sec = l / 1000; - result->tv_usec = (l % 1000) * 1000; -} - void g_usleep (gulong microseconds) { diff --git a/src/mono/mono/eglib/gdir-unix.c b/src/mono/mono/eglib/gdir-unix.c deleted file mode 100644 index 2ce5569c4be09..0000000000000 --- a/src/mono/mono/eglib/gdir-unix.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Directory utility functions. - * - * Author: - * Gonzalo Paniagua Javier (gonzalo@novell.com) - * - * (C) 2006 Novell, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -#include "config.h" -#include -#include -#include -#include -#include "../utils/mono-errno.h" -#include -#include -#include -#include - -struct _GDir { - DIR *dir; -#ifndef HAVE_REWINDDIR - char *path; -#endif -}; - -GDir * -g_dir_open (const gchar *path, guint flags, GError **gerror) -{ - GDir *dir; - - g_return_val_if_fail (path != NULL, NULL); - g_return_val_if_fail (gerror == NULL || *gerror == NULL, NULL); - - (void) flags; /* this is not used */ - dir = g_new (GDir, 1); - dir->dir = opendir (path); - if (dir->dir == NULL) { - if (gerror) { - gint err = errno; - *gerror = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), strerror (err)); - } - g_free (dir); - return NULL; - } -#ifndef HAVE_REWINDDIR - dir->path = g_strdup (path); -#endif - return dir; -} - -const gchar * -g_dir_read_name (GDir *dir) -{ - struct dirent *entry; - - g_return_val_if_fail (dir != NULL && dir->dir != NULL, NULL); - do { - entry = readdir (dir->dir); - if (entry == NULL) - return NULL; - } while ((strcmp (entry->d_name, ".") == 0) || (strcmp (entry->d_name, "..") == 0)); - - return entry->d_name; -} - -void -g_dir_rewind (GDir *dir) -{ - g_return_if_fail (dir != NULL && dir->dir != NULL); -#ifndef HAVE_REWINDDIR - closedir (dir->dir); - dir->dir = opendir (dir->path); -#else - rewinddir (dir->dir); -#endif -} - -void -g_dir_close (GDir *dir) -{ - g_return_if_fail (dir != NULL && dir->dir != 0); - closedir (dir->dir); -#ifndef HAVE_REWINDDIR - g_free (dir->path); -#endif - dir->dir = NULL; - g_free (dir); -} - -int -g_mkdir_with_parents (const gchar *pathname, int mode) -{ - char *path, *d; - int rv; - - if (!pathname || *pathname == '\0') { - mono_set_errno (EINVAL); - return -1; - } - - d = path = g_strdup (pathname); - if (*d == '/') - d++; - - while (TRUE) { - if (*d == '/' || *d == '\0') { - char orig = *d; - *d = '\0'; - rv = mkdir (path, (mode_t)mode); - if (rv == -1 && errno != EEXIST) { - g_free (path); - return -1; - } - - *d++ = orig; - while (orig == '/' && *d == '/') - d++; - if (orig == '\0') - break; - } else { - d++; - } - } - - g_free (path); - - return 0; -} diff --git a/src/mono/mono/eglib/gdir-win32.c b/src/mono/mono/eglib/gdir-win32.c deleted file mode 100644 index 30004642361fd..0000000000000 --- a/src/mono/mono/eglib/gdir-win32.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Directory utility functions. - * - * Author: - * Gonzalo Paniagua Javier (gonzalo@novell.com) - * - * (C) 2006 Novell, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -#include "config.h" -#include -#include -#include -#include -#include -#include -#include - -#include - -struct _GDir { - HANDLE handle; - gchar* current; - gchar* next; -}; - -GDir * -g_dir_open (const gchar *path, guint flags, GError **gerror) -{ - GDir *dir; - gunichar2* path_utf16; - gunichar2* path_utf16_search; - WIN32_FIND_DATAW find_data; - - g_return_val_if_fail (path != NULL, NULL); - g_return_val_if_fail (gerror == NULL || *gerror == NULL, NULL); - - dir = g_new0 (GDir, 1); - path_utf16 = u8to16 (path); - path_utf16_search = g_malloc ((wcslen(path_utf16) + 3)*sizeof(gunichar2)); - wcscpy (path_utf16_search, path_utf16); - wcscat (path_utf16_search, L"\\*"); - - dir->handle = FindFirstFileW (path_utf16_search, &find_data); - if (dir->handle == INVALID_HANDLE_VALUE) { - if (gerror) { - gint err = errno; - *gerror = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), strerror (err)); - } - g_free (path_utf16_search); - g_free (path_utf16); - g_free (dir); - return NULL; - } - g_free (path_utf16_search); - g_free (path_utf16); - - while ((wcscmp (find_data.cFileName, L".") == 0) || (wcscmp (find_data.cFileName, L"..") == 0)) { - if (!FindNextFileW (dir->handle, &find_data)) { - if (gerror) { - gint err = errno; - *gerror = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), strerror (err)); - } - g_free (dir); - return NULL; - } - } - - dir->current = NULL; - dir->next = u16to8 (find_data.cFileName); - return dir; -} - -const gchar * -g_dir_read_name (GDir *dir) -{ - WIN32_FIND_DATAW find_data; - - g_return_val_if_fail (dir != NULL && dir->handle != 0, NULL); - - if (dir->current) - g_free (dir->current); - dir->current = NULL; - - dir->current = dir->next; - - if (!dir->current) - return NULL; - - dir->next = NULL; - - do { - if (!FindNextFileW (dir->handle, &find_data)) { - dir->next = NULL; - return dir->current; - } - } while ((wcscmp (find_data.cFileName, L".") == 0) || (wcscmp (find_data.cFileName, L"..") == 0)); - - dir->next = u16to8 (find_data.cFileName); - return dir->current; -} - -void -g_dir_rewind (GDir *dir) -{ -} - -void -g_dir_close (GDir *dir) -{ - g_return_if_fail (dir != NULL && dir->handle != 0); - - if (dir->current) - g_free (dir->current); - dir->current = NULL; - if (dir->next) - g_free (dir->next); - dir->next = NULL; - FindClose (dir->handle); - dir->handle = 0; - g_free (dir); -} - - diff --git a/src/mono/mono/eglib/gfile.c b/src/mono/mono/eglib/gfile.c index e4c5d4ede1533..6dac38dc52fbf 100644 --- a/src/mono/mono/eglib/gfile.c +++ b/src/mono/mono/eglib/gfile.c @@ -104,54 +104,3 @@ g_file_error_from_errno (gint err_no) return G_FILE_ERROR_FAILED; } } - -#ifdef G_OS_WIN32 -#define TMP_FILE_FORMAT "%.*s%s.tmp" -#else -#define TMP_FILE_FORMAT "%.*s.%s~" -#endif - -gboolean -g_file_set_contents (const gchar *filename, const gchar *contents, gssize length, GError **err) -{ - const char *name; - char *path; - FILE *fp; - - if (!(name = strrchr (filename, G_DIR_SEPARATOR))) - name = filename; - else - name++; - - path = g_strdup_printf (TMP_FILE_FORMAT, (int)(name - filename), filename, name); - if (!(fp = fopen (path, "wb"))) { - g_set_error (err, G_FILE_ERROR, g_file_error_from_errno (errno), "%s", g_strerror (errno)); - g_free (path); - return FALSE; - } - - if (length < 0) - length = strlen (contents); - - if (fwrite (contents, 1, length, fp) < GSSIZE_TO_SIZE(length)) { - g_set_error (err, G_FILE_ERROR, g_file_error_from_errno (ferror (fp)), "%s", g_strerror (ferror (fp))); - g_unlink (path); - g_free (path); - fclose (fp); - - return FALSE; - } - - fclose (fp); - - if (g_rename (path, filename) != 0) { - g_set_error (err, G_FILE_ERROR, g_file_error_from_errno (errno), "%s", g_strerror (errno)); - g_unlink (path); - g_free (path); - return FALSE; - } - - g_free (path); - - return TRUE; -} diff --git a/src/mono/mono/eglib/giconv.c b/src/mono/mono/eglib/giconv.c index 0a079fba22068..76743ed5c47c1 100644 --- a/src/mono/mono/eglib/giconv.c +++ b/src/mono/mono/eglib/giconv.c @@ -121,65 +121,6 @@ write_uint16_endian (unsigned char *outptr, uint16_t c, unsigned endian) outptr[1] = c & 0xff; } -static FORCE_INLINE (int) -decode_utf8 (char *inbuf, size_t inleft, gunichar *outchar) -{ - unsigned char *inptr = (unsigned char *) inbuf; - gunichar u; - size_t n; - - u = *inptr; - - if (u < 0x80) { - /* simple ascii case */ - *outchar = u; - return 1; - } else if (u < 0xc2) { - mono_set_errno (EILSEQ); - return -1; - } else if (u < 0xe0) { - u &= 0x1f; - n = 2; - } else if (u < 0xf0) { - u &= 0x0f; - n = 3; - } else if (u < 0xf8) { - u &= 0x07; - n = 4; - } else if (u < 0xfc) { - u &= 0x03; - n = 5; - } else if (u < 0xfe) { - u &= 0x01; - n = 6; - } else { - mono_set_errno (EILSEQ); - return -1; - } - - if (n > inleft) { - mono_set_errno (EINVAL); - return -1; - } - -#if UNROLL_DECODE_UTF8 - switch (n) { - case 6: u = (u << 6) | (*++inptr ^ 0x80); - case 5: u = (u << 6) | (*++inptr ^ 0x80); - case 4: u = (u << 6) | (*++inptr ^ 0x80); - case 3: u = (u << 6) | (*++inptr ^ 0x80); - case 2: u = (u << 6) | (*++inptr ^ 0x80); - } -#else - for (size_t i = 1; i < n; i++) - u = (u << 6) | (*++inptr ^ 0x80); -#endif - - *outchar = u; - - return GSIZE_TO_INT(n); -} - static gpointer error_quark = (gpointer)"ConvertError"; gpointer @@ -188,52 +129,6 @@ g_convert_error_quark (void) return error_quark; } -/** - * An explanation of the conversion can be found at: - * http://home.tiscali.nl/t876506/utf8tbl.html - * - **/ -gint -g_unichar_to_utf8 (gunichar c, gchar *outbuf) -{ - int base, n, i; - - if (c < 0x80) { - base = 0; - n = 1; - } else if (c < 0x800) { - base = 192; - n = 2; - } else if (c < 0x10000) { - base = 224; - n = 3; - } else if (c < 0x200000) { - base = 240; - n = 4; - } else if (c < 0x4000000) { - base = 248; - n = 5; - } else if (c < 0x80000000) { - base = 252; - n = 6; - } else { - return -1; - } - - if (outbuf != NULL) { - for (i = n - 1; i > 0; i--) { - /* mask off 6 bits worth and add 128 */ - outbuf[i] = (c & 0x3f) | 0x80; - c >>= 6; - } - - /* first character has a different base */ - outbuf[0] = GUNICHAR_TO_CHAR (c | base); - } - - return n; -} - static FORCE_INLINE (int) g_unichar_to_utf16_endian (gunichar c, gunichar2 *outbuf, unsigned endian) { @@ -288,33 +183,6 @@ g_unichar_to_utf16le (gunichar c, gunichar2 *outbuf) return g_unichar_to_utf16_endian (c, outbuf, G_LITTLE_ENDIAN); } -gunichar * -g_utf8_to_ucs4_fast (const gchar *str, glong len, glong *items_written) -{ - gunichar *outbuf, *outptr; - char *inptr; - glong n, i; - - g_return_val_if_fail (str != NULL, NULL); - - n = g_utf8_strlen (str, len); - - if (items_written) - *items_written = n; - - outptr = outbuf = g_malloc ((n + 1) * sizeof (gunichar)); - inptr = (char *) str; - - for (i = 0; i < n; i++) { - *outptr++ = g_utf8_get_char (inptr); - inptr = g_utf8_next_char (inptr); - } - - *outptr = 0; - - return outbuf; -} - static FORCE_INLINE (void) map_error(GError **err) { @@ -325,7 +193,7 @@ map_error(GError **err) } } -static gunichar2 * +static FORCE_INLINE (gunichar2 *) g_utf8_to_utf16_impl (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err, int flags, bool treatAsLE) { errno = 0; @@ -359,7 +227,7 @@ g_utf8_to_utf16_impl (const gchar *str, glong len, glong *items_read, glong *ite return lpDestStr; } -static gunichar2 * +static FORCE_INLINE (gunichar2 *) g_utf8_to_utf16le_custom_alloc_impl (const gchar *str, glong len, glong *items_read, glong *items_written, GCustomAllocator custom_alloc_func, gpointer custom_alloc_data, GError **err, bool treatAsLE) { guint flags = 0; @@ -408,7 +276,7 @@ g_utf8_to_utf16le (const gchar *str, glong len, glong *items_read, glong *items_ } gunichar2 * -eg_wtf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err) +g_wtf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err) { return g_utf8_to_utf16_impl (str, len, items_read, items_written, err, 0, false); } @@ -425,79 +293,7 @@ g_utf8_to_utf16le_custom_alloc (const gchar *str, glong len, glong *items_read, return g_utf8_to_utf16le_custom_alloc_impl (str, len, items_read, items_written, custom_alloc_func, custom_alloc_data, err, true); } -gunichar * -g_utf8_to_ucs4 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err) -{ - gunichar *outbuf, *outptr; - size_t outlen = 0; - size_t inleft; - char *inptr; - gunichar c; - int n; - - g_return_val_if_fail (str != NULL, NULL); - - if (len < 0) - len = (glong)strlen (str); - - inptr = (char *) str; - inleft = len; - - while (inleft > 0) { - if ((n = decode_utf8 (inptr, inleft, &c)) < 0) { - if (errno == EILSEQ) { - g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, - "Illegal byte sequence encountered in the input."); - } else if (items_read) { - /* partial input is ok if we can let our caller know... */ - break; - } else { - g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT, - "Partial byte sequence encountered in the input."); - } - - if (items_read) - *items_read = GPTRDIFF_TO_LONG (inptr - str); - - if (items_written) - *items_written = 0; - - return NULL; - } else if (c == 0) - break; - - outlen += 4; - inleft -= n; - inptr += n; - } - - if (items_written) - *items_written = (glong)(outlen / 4); - - if (items_read) - *items_read = GPTRDIFF_TO_LONG (inptr - str); - - outptr = outbuf = g_malloc (outlen + 4); - inptr = (char *) str; - inleft = len; - - while (inleft > 0) { - if ((n = decode_utf8 (inptr, inleft, &c)) < 0) - break; - else if (c == 0) - break; - - *outptr++ = c; - inleft -= n; - inptr += n; - } - - *outptr = 0; - - return outbuf; -} - -static gchar * +static FORCE_INLINE (gchar *) g_utf16_to_utf8_impl (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **err, bool treatAsLE) { guint flags = 0; @@ -663,68 +459,6 @@ g_utf16_to_ucs4 (const gunichar2 *str, glong len, glong *items_read, glong *item return outbuf; } -gchar * -g_ucs4_to_utf8 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **err) -{ - char *outbuf, *outptr; - size_t outlen = 0; - glong i; - int n; - - g_return_val_if_fail (str != NULL, NULL); - - if (len < 0) { - for (i = 0; str[i] != 0; i++) { - if ((n = g_unichar_to_utf8 (str[i], NULL)) < 0) { - g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, - "Illegal byte sequence encountered in the input."); - - if (items_written) - *items_written = 0; - - if (items_read) - *items_read = i; - - return NULL; - } - - outlen += n; - } - } else { - for (i = 0; i < len && str[i] != 0; i++) { - if ((n = g_unichar_to_utf8 (str[i], NULL)) < 0) { - g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, - "Illegal byte sequence encountered in the input."); - - if (items_written) - *items_written = 0; - - if (items_read) - *items_read = i; - - return NULL; - } - - outlen += n; - } - } - - len = i; - - outptr = outbuf = g_malloc (outlen + 1); - for (i = 0; i < len; i++) - outptr += g_unichar_to_utf8 (str[i], outptr); - *outptr = 0; - - if (items_written) - *items_written = (glong)outlen; - - if (items_read) - *items_read = i; - - return outbuf; -} - gunichar2 * g_ucs4_to_utf16 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **err) { diff --git a/src/mono/mono/eglib/glib.h b/src/mono/mono/eglib/glib.h index 72dba137e18b6..b2f4b8a8697b3 100644 --- a/src/mono/mono/eglib/glib.h +++ b/src/mono/mono/eglib/glib.h @@ -301,11 +301,6 @@ typedef struct { void g_mem_set_vtable (GMemVTable* vtable); void g_mem_get_vtable (GMemVTable* vtable); -struct _GMemChunk { - guint alloc_size; -}; - -typedef struct _GMemChunk GMemChunk; /* * Misc. */ @@ -356,8 +351,6 @@ gchar *g_strreverse (gchar *str); gboolean g_str_has_prefix (const gchar *str, const gchar *prefix); gboolean g_str_has_suffix (const gchar *str, const gchar *suffix); guint g_strv_length (gchar **str_array); -gchar *g_strjoin (const gchar *separator, ...); -gchar *g_strjoinv (const gchar *separator, gchar **str_array); gchar *g_strchug (gchar *str); gchar *g_strchomp (gchar *str); gchar *g_strnfill (gsize length, gchar fill_char); @@ -376,7 +369,6 @@ gint g_vasprintf (gchar **ret, const gchar *fmt, va_list ap); #define g_vsnprintf vsnprintf gsize g_strlcpy (gchar *dest, const gchar *src, gsize dest_size); -gchar *g_stpcpy (gchar *dest, const char *src); gchar g_ascii_tolower (gchar c); @@ -391,34 +383,6 @@ gint g_ascii_xdigit_value (gchar c); #define g_ascii_isalpha(c) (isalpha (c) != 0) #define g_ascii_isprint(c) (isprint (c) != 0) #define g_ascii_isxdigit(c) (isxdigit (c) != 0) -gboolean g_utf16_ascii_equal (const gunichar2 *utf16, size_t ulen, const char *ascii, size_t alen); -gboolean g_utf16_asciiz_equal (const gunichar2 *utf16, const char *ascii); - -static inline -gboolean g_ascii_equal (const char *s1, gsize len1, const char *s2, gsize len2) -{ - return len1 == len2 && (s1 == s2 || memcmp (s1, s2, len1) == 0); -} - -static inline -gboolean g_asciiz_equal (const char *s1, const char *s2) -{ - return s1 == s2 || strcmp (s1, s2) == 0; -} - -static inline -gboolean -g_ascii_equal_caseinsensitive (const char *s1, gsize len1, const char *s2, gsize len2) -{ - return len1 == len2 && (s1 == s2 || g_ascii_strncasecmp (s1, s2, len1) == 0); -} - -static inline -gboolean -g_asciiz_equal_caseinsensitive (const char *s1, const char *s2) -{ - return s1 == s2 || g_ascii_strcasecmp (s1, s2) == 0; -} /* FIXME: g_strcasecmp supports utf8 unicode stuff */ #ifdef _MSC_VER @@ -427,11 +391,9 @@ g_asciiz_equal_caseinsensitive (const char *s1, const char *s2) #define g_strstrip(a) g_strchug (g_strchomp (a)) #else #define g_strcasecmp strcasecmp -#define g_ascii_strtoull strtoull #define g_strncasecmp strncasecmp #define g_strstrip(a) g_strchug (g_strchomp (a)) #endif -#define g_ascii_strdup strdup /* * String type @@ -451,7 +413,6 @@ GString *g_string_append (GString *string, const gchar *val); void g_string_printf (GString *string, const gchar *format, ...) G_ATTR_FORMAT_PRINTF(2, 3); void g_string_append_printf (GString *string, const gchar *format, ...) G_ATTR_FORMAT_PRINTF(2, 3); void g_string_append_vprintf (GString *string, const gchar *format, va_list args); -GString *g_string_append_unichar (GString *string, gunichar c); GString *g_string_append_c (GString *string, gchar c); GString *g_string_append (GString *string, const gchar *val); GString *g_string_append_len (GString *string, const gchar *val, gssize len); @@ -879,18 +840,14 @@ typedef enum { G_CONVERT_ERROR_NO_MEMORY } GConvertError; -gint g_unichar_to_utf8 (gunichar c, gchar *outbuf); -gunichar *g_utf8_to_ucs4_fast (const gchar *str, glong len, glong *items_written); -gunichar *g_utf8_to_ucs4 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err); G_EXTERN_C // Used by libtest, at least. gunichar2 *g_utf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err); gunichar2 *g_utf8_to_utf16le (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err); -gunichar2 *eg_wtf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err); +gunichar2 *g_wtf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err); G_EXTERN_C // Used by libtest, at least. gchar *g_utf16_to_utf8 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **err); gchar *g_utf16le_to_utf8 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **err); gunichar *g_utf16_to_ucs4 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **err); -gchar *g_ucs4_to_utf8 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **err); gunichar2 *g_ucs4_to_utf16 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **err); size_t g_utf16_len (const gunichar2 *); @@ -924,7 +881,6 @@ gchar *g_build_path (const gchar *separator, const gchar *first_eleme #define g_build_filename(x, ...) g_build_path(G_DIR_SEPARATOR_S, x, __VA_ARGS__) gchar *g_path_get_dirname (const gchar *filename); gchar *g_path_get_basename (const char *filename); -gchar *g_find_program_in_path (const gchar *program); gchar *g_get_current_dir (void); gboolean g_path_is_absolute (const char *filename); @@ -932,40 +888,6 @@ const gchar *g_get_tmp_dir (void); gboolean g_ensure_directory_exists (const gchar *filename); -#ifndef G_OS_WIN32 // Spawn could be implemented but is not. - -int eg_getdtablesize (void); - -#if !defined (HAVE_FORK) || !defined (HAVE_EXECVE) - -#define HAVE_G_SPAWN 0 - -#else - -#define HAVE_G_SPAWN 1 - - -/* - * Spawn - */ -typedef enum { - G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1, - G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1, - G_SPAWN_SEARCH_PATH = 1 << 2, - G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3, - G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4, - G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5, - G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6 -} GSpawnFlags; - -typedef void (*GSpawnChildSetupFunc) (gpointer user_data); - -gboolean g_spawn_async_with_pipes (const gchar *working_directory, gchar **argv, gchar **envp, GSpawnFlags flags, GSpawnChildSetupFunc child_setup, - gpointer user_data, GPid *child_pid, gint *standard_input, gint *standard_output, gint *standard_error, GError **gerror); - -#endif -#endif - /* * Timer */ @@ -980,12 +902,6 @@ void g_timer_start (GTimer *timer); /* * Date and time */ -typedef struct { - glong tv_sec; - glong tv_usec; -} GTimeVal; - -void g_get_current_time (GTimeVal *result); void g_usleep (gulong microseconds); /* @@ -1034,7 +950,6 @@ typedef enum { G_ENUM_FUNCTIONS (GFileTest) -gboolean g_file_set_contents (const gchar *filename, const gchar *contents, gssize length, GError **gerror); gboolean g_file_get_contents (const gchar *filename, gchar **contents, gsize *length, GError **gerror); GFileError g_file_error_from_errno (gint err_no); gint g_file_open_tmp (const gchar *tmpl, gchar **name_used, GError **gerror); @@ -1045,18 +960,6 @@ gboolean g_file_test (const gchar *filename, GFileTest test); #else #define g_open open #endif -#define g_rename rename -#define g_stat stat -#ifdef G_OS_WIN32 -#define g_access _access -#else -#define g_access access -#endif -#ifdef G_OS_WIN32 -#define g_mktemp _mktemp -#else -#define g_mktemp mktemp -#endif #ifdef G_OS_WIN32 #define g_unlink _unlink #else @@ -1073,14 +976,6 @@ gboolean g_file_test (const gchar *filename, GFileTest test); #define g_read(fd, buffer, buffer_size) (int)read(fd, buffer, buffer_size) #endif -#define g_fopen fopen -#define g_lstat lstat -#define g_rmdir rmdir -#define g_mkstemp mkstemp -#define g_ascii_isdigit isdigit -#define g_ascii_strtod strtod -#define g_ascii_isalnum isalnum - gchar *g_mkdtemp (gchar *tmpl); /* @@ -1151,37 +1046,26 @@ g_async_safe_printf (gchar const *format, ...) return ret; } -/* - * Directory - */ -typedef struct _GDir GDir; -GDir *g_dir_open (const gchar *path, guint flags, GError **gerror); -const gchar *g_dir_read_name (GDir *dir); -void g_dir_rewind (GDir *dir); -void g_dir_close (GDir *dir); - -int g_mkdir_with_parents (const gchar *pathname, int mode); -#define g_mkdir mkdir - /* * Unicode manipulation */ extern const guchar g_utf8_jump_table[256]; gboolean g_utf8_validate (const gchar *str, gssize max_len, const gchar **end); -gunichar g_utf8_get_char_validated (const gchar *str, gssize max_len); -#define g_utf8_next_char(p) ((p) + g_utf8_jump_table[(guchar)(*p)]) -gunichar g_utf8_get_char (const gchar *src); glong g_utf8_strlen (const gchar *str, gssize max); -gchar *g_utf8_offset_to_pointer (const gchar *str, glong offset); -glong g_utf8_pointer_to_offset (const gchar *str, const gchar *pos); /* - * priorities + * Clock Nanosleep */ -#define G_PRIORITY_DEFAULT 0 -#define G_PRIORITY_DEFAULT_IDLE 200 +#ifdef HAVE_CLOCK_NANOSLEEP +gint +g_clock_nanosleep (clockid_t clockid, gint flags, const struct timespec *request, struct timespec *remain); +#endif + +/* + * Misc + */ #define GUINT16_SWAP_LE_BE_CONSTANT(x) ((((guint16) x) >> 8) | ((((guint16) x) << 8))) #define GUINT16_SWAP_LE_BE(x) ((guint16) (((guint16) x) >> 8) | ((((guint16)(x)) & 0xff) << 8)) @@ -1249,28 +1133,6 @@ glong g_utf8_pointer_to_offset (const gchar *str, const gchar *pos); #define G_UNSUPPORTED_API "%s:%d: '%s' not supported.", __FILE__, __LINE__ #define g_unsupported_api(name) G_STMT_START { g_debug (G_UNSUPPORTED_API, name); } G_STMT_END -#if _WIN32 -// g_free the result -// No MAX_PATH limit. -gboolean -mono_get_module_filename (gpointer mod, gunichar2 **pstr, guint32 *plength); - -// g_free the result -// No MAX_PATH limit. -gboolean -mono_get_module_filename_ex (gpointer process, gpointer mod, gunichar2 **pstr, guint32 *plength); - -// g_free the result -// No MAX_PATH limit. -gboolean -mono_get_module_basename (gpointer process, gpointer mod, gunichar2 **pstr, guint32 *plength); - -// g_free the result -// No MAX_PATH limit. -gboolean -mono_get_current_directory (gunichar2 **pstr, guint32 *plength); -#endif - G_END_DECLS // FIXME: There is more extern C than there should be. static inline diff --git a/src/mono/mono/eglib/gmodule-unix.c b/src/mono/mono/eglib/gmodule-unix.c index bd5cc2648d80e..cfe550ea83f84 100644 --- a/src/mono/mono/eglib/gmodule-unix.c +++ b/src/mono/mono/eglib/gmodule-unix.c @@ -315,20 +315,3 @@ g_module_close (GModule *module) return FALSE; } #endif - -gchar * -g_module_build_path (const gchar *directory, const gchar *module_name) -{ - const char *lib_prefix = ""; - - if (module_name == NULL) - return NULL; - - if (strncmp (module_name, "lib", 3) != 0) - lib_prefix = LIBPREFIX; - - if (directory && *directory) - return g_strdup_printf ("%s/%s%s" LIBSUFFIX, directory, lib_prefix, module_name); - return g_strdup_printf ("%s%s" LIBSUFFIX, lib_prefix, module_name); -} - diff --git a/src/mono/mono/eglib/gmodule-win32.c b/src/mono/mono/eglib/gmodule-win32.c index 18084b24577a6..ec3613c57ed8a 100644 --- a/src/mono/mono/eglib/gmodule-win32.c +++ b/src/mono/mono/eglib/gmodule-win32.c @@ -251,193 +251,3 @@ g_module_close (GModule *module) g_free (module); return (main_module ? 1 : (0 == FreeLibrary (handle))); } - -gchar * -g_module_build_path (const gchar *directory, const gchar *module_name) -{ - const char *lib_prefix = ""; - - if (module_name == NULL) - return NULL; - - if (strncmp (module_name, "lib", 3) != 0) - lib_prefix = LIBPREFIX; - - if (directory && *directory){ - - return g_strdup_printf ("%s/%s%s" LIBSUFFIX, directory, lib_prefix, module_name); - } - return g_strdup_printf ("%s%s" LIBSUFFIX, lib_prefix, module_name); -} - -// This is not about GModule but is still a close fit. -// This is not named "g_" but that should be ok. -// g_free the result -// No MAX_PATH limit. -// -// Prefer mono_get_module_filename over mono_get_module_filename_ex and mono_get_module_basename. -// Prefer not-ex, not-base. -// -gboolean -mono_get_module_filename (gpointer mod, gunichar2 **pstr, guint32 *plength) -{ - gunichar2 *str = NULL; - guint32 capacity = MAX_PATH; // tunable - guint32 length = 0; - gboolean success = FALSE; - - while (TRUE) - { - length = 0; - if (capacity > (1 << 24)) - break; - str = g_new (gunichar2, capacity); - if (!str) - break; - length = GetModuleFileNameW ((HMODULE)mod, str, capacity); - success = length && length < (capacity - 1); // This function does not truncate, but - 1 anyway. - if (success) - break; - g_free (str); // error or too small - str = NULL; - if (!length) // error - break; - capacity *= 2; - } - *pstr = str; - *plength = length; - return success; -} - -// This is not about GModule but is still a close fit. -// This is not named "g_" but that should be ok. -// g_free the result -// No MAX_PATH limit. -// -// Prefer mono_get_module_filename over mono_get_module_filename_ex and mono_get_module_basename. -// Prefer not-ex, not-base. -// -#if HAVE_API_SUPPORT_WIN32_GET_MODULE_FILE_NAME_EX -gboolean -mono_get_module_filename_ex (gpointer process, gpointer mod, gunichar2 **pstr, guint32 *plength) -{ - gunichar2 *str = NULL; - guint32 capacity = MAX_PATH; // tunable - guint32 length = 0; - gboolean success = FALSE; - - while (TRUE) - { - length = 0; - if (capacity > (1 << 24)) - break; - str = g_new (gunichar2, capacity); - if (!str) - break; - length = GetModuleFileNameExW (process, (HMODULE)mod, str, capacity); - success = length && length < (capacity - 1); // This function truncates, thus the - 1. - if (success) - break; - g_free (str); // error or too small - str = NULL; - if (!length) // error - break; - capacity *= 2; - } - *pstr = str; - *plength = length; - return success; -} -#elif !HAVE_EXTERN_DEFINED_WIN32_GET_MODULE_FILE_NAME_EX -gboolean -mono_get_module_filename_ex (gpointer process, gpointer mod, gunichar2 **pstr, guint32 *plength) -{ - g_unsupported_api ("GetModuleFileNameEx"); - SetLastError (ERROR_NOT_SUPPORTED); - return FALSE; -} -#endif /* HAVE_API_SUPPORT_WIN32_GET_MODULE_FILE_NAME_EX */ - -// This is not about GModule but is still a close fit. -// This is not named "g_" but that should be ok. -// g_free the result -// No MAX_PATH limit. -// -// Prefer mono_get_module_filename over mono_get_module_filename_ex and mono_get_module_basename. -// Prefer not-ex, not-base. -// -#if HAVE_API_SUPPORT_WIN32_GET_MODULE_BASE_NAME -gboolean -mono_get_module_basename (gpointer process, gpointer mod, gunichar2 **pstr, guint32 *plength) -{ - gunichar2 *str = NULL; - guint32 capacity = MAX_PATH; // tunable - guint32 length = 0; - gboolean success = FALSE; - - while (TRUE) - { - length = 0; - if (capacity > (1 << 24)) - break; - str = g_new (gunichar2, capacity); - if (!str) - break; - length = GetModuleBaseNameW (process, (HMODULE)mod, str, capacity); - success = length && length < (capacity - 1); // This function truncates, thus the - 1. - if (success) - break; - g_free (str); // error or too small - str = NULL; - if (!length) // error - break; - capacity *= 2; - } - *pstr = str; - *plength = length; - return success; -} -#elif !HAVE_EXTERN_DEFINED_WIN32_GET_MODULE_BASE_NAME -gboolean -mono_get_module_basename (gpointer process, gpointer mod, gunichar2 **pstr, guint32 *plength) -{ - g_unsupported_api ("GetModuleBaseName"); - SetLastError (ERROR_NOT_SUPPORTED); - return FALSE; -} -#endif /* HAVE_API_SUPPORT_WIN32_GET_MODULE_BASE_NAME */ - -// g_free the result -// No MAX_PATH limit. -gboolean -mono_get_current_directory (gunichar2 **pstr, guint32 *plength) -{ - gunichar2 *str = NULL; - guint32 capacity = MAX_PATH; // tunable - guint32 length = 0; - gboolean success = FALSE; - - while (TRUE) - { - length = 0; - if (capacity > (1 << 24)) - break; - str = g_new (gunichar2, capacity); - if (!str) - break; - // Call in loop, not just twice, in case another thread is changing it. - // Result is transient in currentness and validity (can get deleted or become a file). - length = GetCurrentDirectoryW (capacity, str); - success = length && length < (capacity - 1); - if (success) - break; - g_free (str); // error or too small - str = NULL; - if (!length) // error - break; - capacity *= 2; - } - *pstr = str; - *plength = length; - return success; -} diff --git a/src/mono/mono/eglib/gmodule.h b/src/mono/mono/eglib/gmodule.h index ea53976b407d3..49dbdec22ec7d 100644 --- a/src/mono/mono/eglib/gmodule.h +++ b/src/mono/mono/eglib/gmodule.h @@ -36,7 +36,6 @@ gboolean g_module_address (void *addr, char *file_name, size_t file_name_len, size_t sym_name_len, void **sym_addr); const gchar *g_module_error (void); gboolean g_module_close (GModule *module); -gchar * g_module_build_path (const gchar *directory, const gchar *module_name); extern char *gmodule_libprefix; extern char *gmodule_libsuffix; diff --git a/src/mono/mono/eglib/gpath.c b/src/mono/mono/eglib/gpath.c index 39c7df7ef1105..96e39c3588ddd 100644 --- a/src/mono/mono/eglib/gpath.c +++ b/src/mono/mono/eglib/gpath.c @@ -160,8 +160,7 @@ g_path_get_basename (const char *filename) return g_strdup (&r[1]); } -//wasm does have strtok_r even though autoconf fails to find -#if !defined (HAVE_STRTOK_R) && !defined (HOST_WASM) +#if !defined (HAVE_STRTOK_R) // This is from BSD's strtok_r char * @@ -215,78 +214,6 @@ strtok_r(char *s, const char *delim, char **last) } #endif -gchar * -g_find_program_in_path (const gchar *program) -{ - char *p; - char *x, *l; - gchar *curdir = NULL; - char *save = NULL; -#ifdef G_OS_WIN32 - char *program_exe; - static char const * const suffix_list[5] = {".exe",".cmd",".bat",".com",NULL}; - int listx; - gboolean hasSuffix; -#endif - - g_return_val_if_fail (program != NULL, NULL); - x = p = g_getenv ("PATH"); - - if (x == NULL || *x == '\0') { - curdir = g_get_current_dir (); - x = curdir; - } - -#ifdef G_OS_WIN32 - /* see if program already has a suffix */ - listx = 0; - hasSuffix = FALSE; - while (!hasSuffix && suffix_list[listx]) { - hasSuffix = g_str_has_suffix(program,suffix_list[listx++]); - } -#endif - - while ((l = strtok_r (x, G_SEARCHPATH_SEPARATOR_S, &save)) != NULL){ - char *probe_path; - - x = NULL; - probe_path = g_build_path (G_DIR_SEPARATOR_S, l, program, NULL); -#ifdef HAVE_ACCESS - if (g_access (probe_path, X_OK) == 0){ /* FIXME: on windows this is just a read permissions test */ - g_free (curdir); - g_free (p); - return probe_path; - } -#endif - g_free (probe_path); - -#ifdef G_OS_WIN32 - /* check for program with a suffix attached */ - if (!hasSuffix) { - listx = 0; - while (suffix_list[listx]) { - program_exe = g_strjoin (NULL, program, suffix_list [listx], (const char*)NULL); - probe_path = g_build_path (G_DIR_SEPARATOR_S, l, program_exe, (const char*)NULL); -#ifdef HAVE_ACCESS - if (g_access (probe_path, X_OK) == 0){ /* FIXME: on windows this is just a read permissions test */ - g_free (curdir); - g_free (p); - g_free (program_exe); - return probe_path; - } -#endif - listx++; - g_free (probe_path); - g_free (program_exe); - } - } -#endif - } - g_free (curdir); - g_free (p); - return NULL; -} - gboolean g_ensure_directory_exists (const gchar *filename) { diff --git a/src/mono/mono/eglib/gspawn.c b/src/mono/mono/eglib/gspawn.c deleted file mode 100644 index 58f620d1c910e..0000000000000 --- a/src/mono/mono/eglib/gspawn.c +++ /dev/null @@ -1,446 +0,0 @@ -/* - * Spawning processes. - * - * Author: - * Gonzalo Paniagua Javier (gonzalo@novell.com - * - * (C) 2006 Novell, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -#include -#include -#include -#include -#include -#include - -#include - -#ifdef HAVE_UNISTD_H -#ifndef __USE_GNU -#define __USE_GNU -#endif -#include -#endif - -#ifdef HAVE_SYS_SELECT_H -#include -#endif - -#ifdef HAVE_SYS_TIME_H -#include -#endif - -#ifdef HAVE_SYS_WAIT_H -#include -#endif - -#ifdef HAVE_SYS_RESOURCE_H -# include -#endif - -#ifdef G_OS_WIN32 -#include -#include -#define open _open -#define close _close -#define read _read -#define write _write -/* windows pipe api details: http://msdn2.microsoft.com/en-us/library/edze9h7e(VS.80).aspx */ -#define pipe(x) _pipe(x, 256, 0) -#endif - -#if HAVE_G_SPAWN - -#define set_error(msg, ...) do { if (gerror != NULL) *gerror = g_error_new (G_LOG_DOMAIN, 1, msg, __VA_ARGS__); } while (0) -#define set_error_cond(cond,msg, ...) do { if ((cond) && gerror != NULL) *gerror = g_error_new (G_LOG_DOMAIN, 1, msg, __VA_ARGS__); } while (0) -#define set_error_status(status,msg, ...) do { if (gerror != NULL) *gerror = g_error_new (G_LOG_DOMAIN, status, msg, __VA_ARGS__); } while (0) -#define NO_INTR(var,cmd) do { (var) = (cmd); } while ((var) == -1 && errno == EINTR) - -static void -mono_close_pipe (int p [2]) -{ - close (p [0]); - close (p [1]); -} - -#if defined(__APPLE__) -#if defined (TARGET_OSX) -/* Apple defines this in crt_externs.h but doesn't provide that header for - * arm-apple-darwin9. We'll manually define the symbol on Apple as it does - * in fact exist on all implementations (so far) - */ -G_BEGIN_DECLS -gchar ***_NSGetEnviron(void); -G_END_DECLS -#define environ (*_NSGetEnviron()) -#else -static char *mono_environ[1] = { NULL }; -#define environ mono_environ -#endif /* defined (TARGET_OSX) */ -#elif defined(_MSC_VER) -/* MS defines this in stdlib.h */ -#else -G_BEGIN_DECLS -extern char **environ; -G_END_DECLS -#endif - -static int -safe_read (int fd, gchar *buffer, gint count, GError **gerror) -{ - int res; - - NO_INTR (res, read (fd, buffer, count)); - set_error_cond (res == -1, "%s", "Error reading from pipe."); - return res; -} - -static int -read_pipes (int outfd, gchar **out_str, int errfd, gchar **err_str, GError **gerror) -{ - fd_set rfds; - int res; - gboolean out_closed; - gboolean err_closed; - GString *out = NULL; - GString *err = NULL; - gchar *buffer = NULL; - gint nread; - - out_closed = (outfd < 0); - err_closed = (errfd < 0); - if (out_str) { - *out_str = NULL; - out = g_string_new (""); - } - - if (err_str) { - *err_str = NULL; - err = g_string_new (""); - } - - do { - if (out_closed && err_closed) - break; - - FD_ZERO (&rfds); - if (!out_closed && outfd >= 0) - FD_SET (outfd, &rfds); - if (!err_closed && errfd >= 0) - FD_SET (errfd, &rfds); - - res = select (MAX (outfd, errfd) + 1, &rfds, NULL, NULL, NULL); - if (res > 0) { - if (buffer == NULL) - buffer = g_malloc (1024); - if (!out_closed && FD_ISSET (outfd, &rfds)) { - nread = safe_read (outfd, buffer, 1024, gerror); - if (nread < 0) { - close (errfd); - close (outfd); - return -1; - } - g_string_append_len (out, buffer, nread); - if (nread <= 0) { - out_closed = TRUE; - close (outfd); - } - } - - if (!err_closed && FD_ISSET (errfd, &rfds)) { - nread = safe_read (errfd, buffer, 1024, gerror); - if (nread < 0) { - close (errfd); - close (outfd); - return -1; - } - g_string_append_len (err, buffer, nread); - if (nread <= 0) { - err_closed = TRUE; - close (errfd); - } - } - } - } while (res > 0 || (res == -1 && errno == EINTR)); - - g_free (buffer); - if (out_str) - *out_str = g_string_free (out, FALSE); - - if (err_str) - *err_str = g_string_free (err, FALSE); - - return 0; -} - -static gboolean -create_pipe (int *fds, GError **gerror) -{ - if (pipe (fds) == -1) { - set_error ("%s", "Error creating pipe."); - return FALSE; - } - return TRUE; -} - -static int -write_all (int fd, const void *vbuf, size_t n) -{ - const char *buf = (const char *) vbuf; - size_t nwritten = 0; - int w; - - do { - do { - w = write (fd, buf + nwritten, n - nwritten); - } while (w == -1 && errno == EINTR); - - if (w == -1) - return -1; - - nwritten += w; - } while (nwritten < n); - - return nwritten; -} - -#endif // HAVE_G_SPAWN - -#if !defined(G_OS_WIN32) && defined(HAVE_GETDTABLESIZE) -int -eg_getdtablesize (void) -{ -#ifdef HAVE_GETRLIMIT - struct rlimit limit; - int res; - - res = getrlimit (RLIMIT_NOFILE, &limit); - g_assert (res == 0); - return limit.rlim_cur; -#else - return getdtablesize (); -#endif -} -#else -int -eg_getdtablesize (void) -{ - g_error ("Should not be called"); -} -#endif - -#if HAVE_G_SPAWN - -/* - * This is the only use we have in mono/metadata -!g_spawn_async_with_pipes (NULL, (char**)addr_argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &child_pid, &ch_in, &ch_out, NULL, NULL) -*/ -gboolean -g_spawn_async_with_pipes (const gchar *working_directory, - gchar **argv, - gchar **envp, - GSpawnFlags flags, - GSpawnChildSetupFunc child_setup, - gpointer user_data, - GPid *child_pid, - gint *standard_input, - gint *standard_output, - gint *standard_error, - GError **gerror) -{ - pid_t pid; - int info_pipe [2]; - int in_pipe [2] = { -1, -1 }; - int out_pipe [2] = { -1, -1 }; - int err_pipe [2] = { -1, -1 }; - int status; - - g_return_val_if_fail (argv != NULL, FALSE); /* Only mandatory arg */ - - if (!create_pipe (info_pipe, gerror)) - return FALSE; - - if (standard_output && !create_pipe (out_pipe, gerror)) { - mono_close_pipe (info_pipe); - return FALSE; - } - - if (standard_error && !create_pipe (err_pipe, gerror)) { - mono_close_pipe (info_pipe); - mono_close_pipe (out_pipe); - return FALSE; - } - - if (standard_input && !create_pipe (in_pipe, gerror)) { - mono_close_pipe (info_pipe); - mono_close_pipe (out_pipe); - mono_close_pipe (err_pipe); - return FALSE; - } - - pid = fork (); - if (pid == -1) { - mono_close_pipe (info_pipe); - mono_close_pipe (out_pipe); - mono_close_pipe (err_pipe); - mono_close_pipe (in_pipe); - set_error ("%s", "Error in fork ()"); - return FALSE; - } - - if (pid == 0) { - /* No zombie left behind */ - if ((flags & G_SPAWN_DO_NOT_REAP_CHILD) == 0) { - pid = fork (); - } - - if (pid != 0) { - exit (pid == -1 ? 1 : 0); - } else { - gint i; - int fd; - gchar *arg0; - gchar **actual_args; - gint unused; - - close (info_pipe [0]); - close (in_pipe [1]); - close (out_pipe [0]); - close (err_pipe [0]); - - /* when exec* succeeds, we want to close this fd, which will return - * a 0 read on the parent. We're not supposed to keep it open forever. - * If exec fails, we still can write the error to it before closing. - */ - fcntl (info_pipe [1], F_SETFD, FD_CLOEXEC); - - if ((flags & G_SPAWN_DO_NOT_REAP_CHILD) == 0) { - pid = getpid (); - NO_INTR (unused, write_all (info_pipe [1], &pid, sizeof (pid_t))); - } - - if (working_directory && chdir (working_directory) == -1) { - int err = errno; - NO_INTR (unused, write_all (info_pipe [1], &err, sizeof (int))); - exit (0); - } - - if (standard_output) { - dup2 (out_pipe [1], STDOUT_FILENO); - } else if ((flags & G_SPAWN_STDOUT_TO_DEV_NULL) != 0) { - fd = open ("/dev/null", O_WRONLY); - dup2 (fd, STDOUT_FILENO); - } - - if (standard_error) { - dup2 (err_pipe [1], STDERR_FILENO); - } else if ((flags & G_SPAWN_STDERR_TO_DEV_NULL) != 0) { - fd = open ("/dev/null", O_WRONLY); - dup2 (fd, STDERR_FILENO); - } - - if (standard_input) { - dup2 (in_pipe [0], STDIN_FILENO); - } else if ((flags & G_SPAWN_CHILD_INHERITS_STDIN) == 0) { - fd = open ("/dev/null", O_RDONLY); - dup2 (fd, STDIN_FILENO); - } - - if ((flags & G_SPAWN_LEAVE_DESCRIPTORS_OPEN) != 0) { - for (i = eg_getdtablesize () - 1; i >= 3; i--) - close (i); - } - - actual_args = ((flags & G_SPAWN_FILE_AND_ARGV_ZERO) == 0) ? argv : argv + 1; - if (envp == NULL) - envp = environ; - - if (child_setup) - child_setup (user_data); - - arg0 = argv [0]; - if (!g_path_is_absolute (arg0) || (flags & G_SPAWN_SEARCH_PATH) != 0) { - arg0 = g_find_program_in_path (argv [0]); - if (arg0 == NULL) { - int err = ENOENT; - write_all (info_pipe [1], &err, sizeof (int)); - exit (0); - } - } - - execve (arg0, actual_args, envp); - int const err = errno; - write_all (info_pipe [1], &err, sizeof (int)); - exit (0); - } - } else if ((flags & G_SPAWN_DO_NOT_REAP_CHILD) == 0) { - int w; - /* Wait for the first child if two are created */ - NO_INTR (w, waitpid (pid, &status, 0)); - if (status == 1 || w == -1) { - mono_close_pipe (info_pipe); - mono_close_pipe (out_pipe); - mono_close_pipe (err_pipe); - mono_close_pipe (in_pipe); - set_error ("Error in fork (): %d", status); - return FALSE; - } - } - close (info_pipe [1]); - close (in_pipe [0]); - close (out_pipe [1]); - close (err_pipe [1]); - - if ((flags & G_SPAWN_DO_NOT_REAP_CHILD) == 0) { - int x; - NO_INTR (x, read (info_pipe [0], &pid, sizeof (pid_t))); /* if we read < sizeof (pid_t)... */ - } - - if (child_pid) { - *child_pid = pid; - } - - if (read (info_pipe [0], &status, sizeof (int)) != 0) { - close (info_pipe [0]); - close (in_pipe [0]); - close (out_pipe [1]); - close (err_pipe [1]); - set_error_status (status, "Error in exec (%d -> %s)", status, strerror (status)); - return FALSE; - } - - close (info_pipe [0]); - if (standard_input) - *standard_input = in_pipe [1]; - if (standard_output) - *standard_output = out_pipe [0]; - if (standard_error) - *standard_error = err_pipe [0]; - return TRUE; -} - -#endif // HAVE_G_SPAWN - -#define MONO_EMPTY_SOURCE_FILE(x) extern const char mono_quash_linker_empty_file_warning_ ## x; \ - const char mono_quash_linker_empty_file_warning_ ## x = 0; - -MONO_EMPTY_SOURCE_FILE (gspawn); diff --git a/src/mono/mono/eglib/gstr.c b/src/mono/mono/eglib/gstr.c index 94fe9f81e7297..6ae0eb6b668ba 100644 --- a/src/mono/mono/eglib/gstr.c +++ b/src/mono/mono/eglib/gstr.c @@ -503,81 +503,6 @@ g_strreverse (gchar *str) return str; } -gchar * -g_strjoin (const gchar *separator, ...) -{ - va_list args; - char *res, *s, *r; - size_t len, slen; - - if (separator != NULL) - slen = strlen (separator); - else - slen = 0; - - len = 0; - va_start (args, separator); - for (s = va_arg (args, char *); s != NULL; s = va_arg (args, char *)){ - len += strlen (s); - len += slen; - } - va_end (args); - - if (len == 0) - return g_strdup (""); - - /* Remove the last separator */ - if (slen > 0 && len > 0) - len -= slen; - - res = (char*)g_malloc (len + 1); - va_start (args, separator); - s = va_arg (args, char *); - r = g_stpcpy (res, s); - for (s = va_arg (args, char *); s != NULL; s = va_arg (args, char *)){ - if (separator != NULL) - r = g_stpcpy (r, separator); - r = g_stpcpy (r, s); - } - va_end (args); - - return res; -} - -gchar * -g_strjoinv (const gchar *separator, gchar **str_array) -{ - char *res, *r; - size_t slen, len, i; - - if (separator != NULL) - slen = strlen (separator); - else - slen = 0; - - len = 0; - for (i = 0; str_array [i] != NULL; i++){ - len += strlen (str_array [i]); - len += slen; - } - - if (len == 0) - return g_strdup (""); - - if (slen > 0 && len > 0) - len -= slen; - - res = g_malloc (len + 1); - r = g_stpcpy (res, str_array [0]); - for (i = 1; str_array [i] != NULL; i++){ - if (separator != NULL) - r = g_stpcpy (r, separator); - r = g_stpcpy (r, str_array [i]); - } - - return res; -} - gchar * g_strchug (gchar *str) { @@ -771,34 +696,6 @@ g_ascii_strcasecmp (const gchar *s1, const gchar *s2) return g_ascii_charcmp (0, *s2); } -gboolean -g_utf16_ascii_equal (const gunichar2 *utf16, size_t ulen, const char *ascii, size_t alen) -{ - size_t i; - if (ulen != alen) - return FALSE; - for (i = 0; i < ulen; ++i) { - if (utf16[i] != ascii[i]) - return FALSE; - } - return TRUE; -} - -gboolean -g_utf16_asciiz_equal (const gunichar2 *utf16, const char *ascii) -// z for zero means null terminated -{ - while (1) - { - char a = *ascii++; - gunichar2 u = *utf16++; - if (a != u) - return FALSE; - if (a == 0) - return TRUE; - } -} - void g_strdelimit (gchar *string, gchar delimiter, gchar new_delimiter) { @@ -847,24 +744,6 @@ g_strlcpy (gchar *dest, const gchar *src, gsize dest_size) #endif } -gchar * -g_stpcpy (gchar *dest, const char *src) -{ - g_return_val_if_fail (dest != NULL, dest); - g_return_val_if_fail (src != NULL, dest); - -#if HAVE_STPCPY - return stpcpy (dest, src); -#else - while (*src) - *dest++ = *src++; - - *dest = '\0'; - - return dest; -#endif -} - gint g_ascii_xdigit_value (gchar c) { diff --git a/src/mono/mono/eglib/gstring.c b/src/mono/mono/eglib/gstring.c index de3f0658de4c6..37ef990f9fd4a 100644 --- a/src/mono/mono/eglib/gstring.c +++ b/src/mono/mono/eglib/gstring.c @@ -133,20 +133,6 @@ g_string_append_c (GString *string, gchar c) return string; } -GString * -g_string_append_unichar (GString *string, gunichar c) -{ - gchar utf8[6]; - gint len; - - g_return_val_if_fail (string != NULL, NULL); - - if ((len = g_unichar_to_utf8 (c, utf8)) <= 0) - return string; - - return g_string_append_len (string, utf8, len); -} - void g_string_append_printf (GString *string, const gchar *format, ...) { diff --git a/src/mono/mono/eglib/gutf8.c b/src/mono/mono/eglib/gutf8.c index 965a69f42e655..569d55fa3bd66 100644 --- a/src/mono/mono/eglib/gutf8.c +++ b/src/mono/mono/eglib/gutf8.c @@ -145,57 +145,6 @@ g_utf8_validate (const gchar *str, gssize max_len, const gchar **end) return valid; } -gunichar -g_utf8_get_char_validated (const gchar *str, gssize max_len) -{ - unsigned char *inptr = (unsigned char *) str; - gunichar u = *inptr; - int n, i; - - if (max_len == 0) - return -2; - - if (u < 0x80) { - /* simple ascii case */ - return u; - } else if (u < 0xc2) { - return -1; - } else if (u < 0xe0) { - u &= 0x1f; - n = 2; - } else if (u < 0xf0) { - u &= 0x0f; - n = 3; - } else if (u < 0xf8) { - u &= 0x07; - n = 4; - } else if (u < 0xfc) { - u &= 0x03; - n = 5; - } else if (u < 0xfe) { - u &= 0x01; - n = 6; - } else { - return -1; - } - - if (max_len > 0) { - if (!utf8_validate (inptr, MIN (max_len, n))) - return -1; - - if (max_len < n) - return -2; - } else { - if (!utf8_validate (inptr, n)) - return -1; - } - - for (i = 1; i < n; i++) - u = (u << 6) | (*++inptr ^ 0x80); - - return u; -} - glong g_utf8_strlen (const gchar *str, gssize max_len) { @@ -224,100 +173,3 @@ g_utf8_strlen (const gchar *str, gssize max_len) return len; } - -gunichar -g_utf8_get_char (const gchar *src) -{ - unsigned char *inptr = (unsigned char *) src; - gunichar u = *inptr; - int n, i; - - if (u < 0x80) { - /* simple ascii case */ - return u; - } else if (u < 0xe0) { - u &= 0x1f; - n = 2; - } else if (u < 0xf0) { - u &= 0x0f; - n = 3; - } else if (u < 0xf8) { - u &= 0x07; - n = 4; - } else if (u < 0xfc) { - u &= 0x03; - n = 5; - } else { - u &= 0x01; - n = 6; - } - - for (i = 1; i < n; i++) - u = (u << 6) | (*++inptr ^ 0x80); - - return u; -} - -gchar * -g_utf8_offset_to_pointer (const gchar *str, glong offset) -{ - const gchar *p = str; - - if (offset > 0) { - do { - p = g_utf8_next_char (p); - offset --; - } while (offset > 0); - } - else if (offset < 0) { - const gchar *jump = str; - do { - // since the minimum size of a character is 1 - // we know we can step back at least offset bytes - jump = jump + offset; - - // if we land in the middle of a character - // walk to the beginning - while ((*jump & 0xc0) == 0x80) - jump --; - - // count how many characters we've actually walked - // by going forward - p = jump; - do { - p = g_utf8_next_char (p); - offset ++; - } while (p < jump); - - } while (offset < 0); - } - - return (gchar *)p; -} - -glong -g_utf8_pointer_to_offset (const gchar *str, const gchar *pos) -{ - const gchar *inptr, *inend; - glong offset = 0; - glong sign = 1; - - if (pos == str) - return 0; - - if (str < pos) { - inptr = str; - inend = pos; - } else { - inptr = pos; - inend = str; - sign = -1; - } - - do { - inptr = g_utf8_next_char (inptr); - offset++; - } while (inptr < inend); - - return offset * sign; -} diff --git a/src/mono/mono/eglib/test/dir.c b/src/mono/mono/eglib/test/dir.c deleted file mode 100644 index a3af1dffadb9b..0000000000000 --- a/src/mono/mono/eglib/test/dir.c +++ /dev/null @@ -1,64 +0,0 @@ -#include -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#ifdef G_OS_UNIX -#include -#endif -#include "test.h" - -/* This test is just to be used with valgrind */ -static RESULT -test_dir (void) -{ - GDir *dir; - GError *gerror; - const gchar *name; - - /* - dir = g_dir_open (NULL, 0, NULL); - */ - dir = g_dir_open ("", 0, NULL); - if (dir != NULL) - return FAILED ("1 Should be an error"); - - dir = g_dir_open ("", 9, NULL); - if (dir != NULL) - return FAILED ("2 Should be an error"); - - gerror = NULL; - dir = g_dir_open (".ljasdslakjd", 9, &gerror); - if (dir != NULL) - return FAILED ("3 opendir should fail"); - if (gerror == NULL) - return FAILED ("4 got no error"); - g_error_free (gerror); - gerror = NULL; - dir = g_dir_open (g_get_tmp_dir (), 9, &gerror); - if (dir == NULL) - return FAILED ("5 opendir should succeed"); - if (gerror != NULL) - return FAILED ("6 got an error"); - name = NULL; - name = g_dir_read_name (dir); - if (name == NULL) - return FAILED ("7 didn't read a file name"); - while ((name = g_dir_read_name (dir)) != NULL) { - if (strcmp (name, ".") == 0) - return FAILED (". directory found"); - if (strcmp (name, "..") == 0) - return FAILED (".. directory found"); - } - g_dir_close (dir); - return OK; -} - -static Test dir_tests [] = { - {"g_dir_*", test_dir}, - {NULL, NULL} -}; - -DEFINE_TEST_GROUP_INIT(dir_tests_init, dir_tests) diff --git a/src/mono/mono/eglib/test/driver.c b/src/mono/mono/eglib/test/driver.c index 8c5781f179789..21e1b2e7ec961 100644 --- a/src/mono/mono/eglib/test/driver.c +++ b/src/mono/mono/eglib/test/driver.c @@ -137,9 +137,6 @@ gint main(gint argc, gchar **argv) case 'h': print_help(argv[0]); return 1; - case 't': - report_time = TRUE; - break; case 'i': iterations = atoi(optarg); break; @@ -220,7 +217,7 @@ gint main(gint argc, gchar **argv) } passed = run_group(&(test_groups[j]), - iterations, quiet, report_time, tests); + iterations, quiet, tests); if (tests != NULL) { g_free(tests); diff --git a/src/mono/mono/eglib/test/module.c b/src/mono/mono/eglib/test/module.c index 332b1b547d1cc..ae6314fa45148 100644 --- a/src/mono/mono/eglib/test/module.c +++ b/src/mono/mono/eglib/test/module.c @@ -67,100 +67,8 @@ test_module_symbol_null (void) return OK; } -static RESULT -test_module_get_module_filename (void) -{ -#if _WIN32 - const HMODULE mods [ ] = {NULL, LoadLibraryW (L"msvcrt.dll"), (HMODULE)(gssize)-1 }; - - for (int i = 0; i < G_N_ELEMENTS (mods); ++i) { - const HMODULE mod = mods [i]; - for (int j = 0; j <= 2; ++j) { - wchar_t* str = { 0 }; - guint32 length = { 0 }; - wchar_t buf2 [999] = { 0 }; - wchar_t buf3 [2] = { 0 }; - gboolean success = { 0 }; - guint32 length2 = { 0 }; - gboolean success2 = { 0 }; - guint32 length3 = { 0 }; - gboolean success3 = { 0 }; - - switch (j) { - case 0: - success = mono_get_module_filename (mod, &str, &length); - length2 = GetModuleFileNameW (mod, buf2, G_N_ELEMENTS (buf2)); // large buf - length3 = GetModuleFileNameW (mod, buf3, 1); // small buf - break; - case 1: - success = mono_get_module_filename_ex (GetCurrentProcess (), mods [i], &str, &length); - length2 = GetModuleFileNameExW (GetCurrentProcess (), mod, buf2, G_N_ELEMENTS (buf2)); // large buf - length3 = GetModuleFileNameExW (GetCurrentProcess (), mod, buf3, 1); // small buf - break; - case 2: - success = mono_get_module_basename (GetCurrentProcess (), mod, &str, &length); - length2 = GetModuleBaseNameW (GetCurrentProcess (), mod, buf2, G_N_ELEMENTS (buf2)); // large buf - length3 = GetModuleBaseNameW (GetCurrentProcess (), mod, buf3, 1); // small buf - break; - } - success2 = length2 && length2 < G_N_ELEMENTS (buf2); - success3 = length3 == 1; - printf ("j:%d s:%X s2:%X s3:%X l:%u l2:%u l3:%u str:%X b2:%X b3:%X\n", - j, - success, success2, success3, - length, length2, length3, - str ? str [0] : 0, buf2 [0], buf3 [0]); - g_assert (success == success2); - g_assert (success == success3 || j > 0); - g_assert (!success || str [0] == buf2 [0]); - //g_assert (!success || str [0] == buf3 [0]); - g_assert (length3 == 0 || length3 == 1); - g_assert (length == (success2 ? wcslen (buf2) :0)); - g_assert (!success || !wcscmp (str, buf2)); - g_assert (!success || str); - if (success) - printf ("%p %ls %ls %d %d\n", mod, str, buf2, length, length2); - else - printf ("!%p %u\n", str, (guint)length); - g_free (str); - } - } -#endif - return OK; -} - -static RESULT -test_get_current_directory (void) -{ -#if _WIN32 - wchar_t* str = { 0 }; - guint32 length = { 0 }; - gboolean success = mono_get_current_directory (&str, &length); - wchar_t buf2 [999] = { 0 }; - const int length2 = GetCurrentDirectoryW (G_N_ELEMENTS (buf2), buf2); - const gboolean success2 = length2 && length2 < G_N_ELEMENTS (buf2); - wchar_t buf3 [2] = { 0 }; - const int length3 = GetCurrentDirectoryW (G_N_ELEMENTS (buf3), buf3); - const gboolean success3 = length3 > 0; - printf ("s:%X s2:%X s3:%X str:%X b2:%X b3:%X\n", success, success2, success3, str ? str [0] : 0, buf2 [0], buf3 [0]); - g_assert (length == length2); - g_assert (success == success2); - g_assert (success == success3); - g_assert (!success || !wcscmp (str, buf2)); - g_assert (!success || str); - if (success) - printf ("%ls\n%ls\n", str, buf2); - else - printf ("!%p %u\n", str, (guint)length); - g_free (str); -#endif - return OK; -} - static Test module_tests [] = { {"g_module_symbol_null", test_module_symbol_null}, - {"module_get_module_filename", test_module_get_module_filename}, - {"get_current_directory", test_get_current_directory}, {NULL, NULL} }; diff --git a/src/mono/mono/eglib/test/path.c b/src/mono/mono/eglib/test/path.c index 53f9e46dd12d5..f626a7666e0af 100644 --- a/src/mono/mono/eglib/test/path.c +++ b/src/mono/mono/eglib/test/path.c @@ -248,50 +248,6 @@ test_basename (void) return OK; } -static gchar * -test_ppath (void) -{ - char *s; -#ifdef G_OS_WIN32 - const gchar *searchfor = "explorer.exe"; -#else - const gchar *searchfor = "ls"; -#endif - s = g_find_program_in_path (searchfor); - if (s == NULL) - return FAILED ("No %s on this system?", searchfor); - g_free (s); - return OK; -} - -static gchar * -test_ppath2 (void) -{ - char *s; - const char *path = g_getenv ("PATH"); -#ifdef G_OS_WIN32 - const gchar *searchfor = "test_eglib.exe"; -#else - const gchar *searchfor = "test-eglib"; -#endif - - g_setenv ("PATH", "", TRUE); - s = g_find_program_in_path ("ls"); - if (s != NULL) { - g_setenv ("PATH", path, TRUE); - return FAILED ("Found something interesting here: %s", s); - } - g_free (s); - s = g_find_program_in_path (searchfor); - if (s == NULL) { - g_setenv ("PATH", path, TRUE); - return FAILED ("It should find '%s' in the current directory.", searchfor); - } - g_free (s); - g_setenv ("PATH", path, TRUE); - return OK; -} - #ifndef DISABLE_FILESYSTEM_TESTS static gchar * test_cwd (void) @@ -345,8 +301,6 @@ static Test path_tests [] = { {"g_buildpath", test_buildpath}, {"g_path_get_dirname", test_dirname}, {"g_path_get_basename", test_basename}, - {"g_find_program_in_path", test_ppath}, - {"g_find_program_in_path2", test_ppath2}, {"test_cwd", test_cwd }, {"test_misc", test_misc }, {NULL, NULL} diff --git a/src/mono/mono/eglib/test/spawn.c b/src/mono/mono/eglib/test/spawn.c deleted file mode 100644 index 805a580fd0516..0000000000000 --- a/src/mono/mono/eglib/test/spawn.c +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#include "test.h" - -#ifdef G_OS_WIN32 -#include -#define read _read -#define close _close -#endif - -static RESULT -test_spawn_async (void) -{ -#if HAVE_G_SPAWN - /* -gboolean -g_spawn_async_with_pipes (const gchar *working_directory, - gchar **argv, - gchar **envp, - GSpawnFlags flags, - GSpawnChildSetupFunc child_setup, - gpointer user_data, - GPid *child_pid, - gint *standard_input, - gint *standard_output, - gint *standard_error, - GError **gerror) */ - char *argv [15]; - int stdout_fd = -1; - char buffer [512]; - GPid child_pid = 0; - - memset (argv, 0, 15 * sizeof (char *)); - argv [0] = (char*)"ls"; - if (!g_spawn_async_with_pipes (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &child_pid, NULL, &stdout_fd, NULL, NULL)) - return FAILED ("1 Failed to run ls"); - if (child_pid == 0) - return FAILED ("2 child pid not returned"); - if (stdout_fd == -1) - return FAILED ("3 out fd is -1"); - - while (read (stdout_fd, buffer, 512) > 0); - close (stdout_fd); -#endif - return OK; -} - -static Test spawn_tests [] = { - {"g_spawn_async_with_pipes", test_spawn_async}, - {NULL, NULL} -}; - -DEFINE_TEST_GROUP_INIT(spawn_tests_init, spawn_tests) diff --git a/src/mono/mono/eglib/test/string-util.c b/src/mono/mono/eglib/test/string-util.c index e42302f435b6e..6fd5bd5495ee2 100644 --- a/src/mono/mono/eglib/test/string-util.c +++ b/src/mono/mono/eglib/test/string-util.c @@ -339,39 +339,6 @@ test_strreverse (void) return res; } -static RESULT -test_strjoin (void) -{ - char *s; - - s = g_strjoin (NULL, "a", "b", (const char*)NULL); - if (strcmp (s, "ab") != 0) - return FAILED ("Join of two strings with no separator fails"); - g_free (s); - - s = g_strjoin ("", "a", "b", (const char*)NULL); - if (strcmp (s, "ab") != 0) - return FAILED ("Join of two strings with empty separator fails"); - g_free (s); - - s = g_strjoin ("-", "a", "b", (const char*)NULL); - if (strcmp (s, "a-b") != 0) - return FAILED ("Join of two strings with separator fails"); - g_free (s); - - s = g_strjoin ("-", "aaaa", "bbbb", "cccc", "dddd", (const char*)NULL); - if (strcmp (s, "aaaa-bbbb-cccc-dddd") != 0) - return FAILED ("Join of multiple strings fails"); - g_free (s); - - s = g_strjoin ("-", (const char*)NULL); - if (s == NULL || (strcmp (s, "") != 0)) - return FAILED ("Failed to join empty arguments"); - g_free (s); - - return OK; -} - static RESULT test_strchug (void) { @@ -602,7 +569,6 @@ static Test strutil_tests [] = { {"g_strsplit", test_split}, {"g_strsplit_set", test_split_set}, {"g_strreverse", test_strreverse}, - {"g_strjoin", test_strjoin}, {"g_strchug", test_strchug}, {"g_strchomp", test_strchomp}, {"g_strstrip", test_strstrip}, diff --git a/src/mono/mono/eglib/test/test.c b/src/mono/mono/eglib/test/test.c index f9947d7e52360..4d33e40d0511e 100644 --- a/src/mono/mono/eglib/test/test.c +++ b/src/mono/mono/eglib/test/test.c @@ -36,9 +36,6 @@ #include #include #include -#ifdef HAVE_SYS_TIME_H -#include -#endif #ifdef G_OS_WIN32 #include #endif @@ -64,11 +61,10 @@ run_test(const Test *test, char **result_out) gboolean run_group(const Group *group, gint iterations, gboolean quiet, - gboolean time, const char *tests_to_run_s) + const char *tests_to_run_s) { Test *tests = group->handler(); gint passed = 0, total = 0; - gdouble start_time_group, start_time_test; gchar **tests_to_run = NULL; if(!quiet) { @@ -83,8 +79,6 @@ run_group(const Group *group, gint iterations, gboolean quiet, tests_to_run = eg_strsplit(tests_to_run_s, ",", -1); } - start_time_group = get_timestamp(); - for(gint i = 0; tests[i].name != NULL; i++) { gchar *result = (char*)""; gboolean iter_pass, run; @@ -112,8 +106,6 @@ run_group(const Group *group, gint iterations, gboolean quiet, printf(" %s: ", tests[i].name); } - start_time_test = get_timestamp(); - for(gint j = 0; j < iterations; j++) { iter_pass = run_test(&(tests[i]), &result); if(!iter_pass) { @@ -124,11 +116,7 @@ run_group(const Group *group, gint iterations, gboolean quiet, if(iter_pass) { passed++; if(!quiet) { - if(time) { - printf("OK (%g)\n", get_timestamp() - start_time_test); - } else { - printf("OK\n"); - } + printf("OK\n"); } } else { if(!quiet) { @@ -147,12 +135,7 @@ run_group(const Group *group, gint iterations, gboolean quiet, if(!quiet) { gdouble pass_percentage = ((gdouble)passed / (gdouble)total) * 100.0; - if(time) { - printf(" %d / %d (%g%%, %g)\n", passed, total, - pass_percentage, get_timestamp() - start_time_group); - } else { - printf(" %d / %d (%g%%)\n", passed, total, pass_percentage); - } + printf(" %d / %d (%g%%)\n", passed, total, pass_percentage); } if(tests_to_run != NULL) { @@ -188,15 +171,6 @@ FAILED(const gchar *format, ...) #endif } -gdouble -get_timestamp (void) -{ - /* FIXME: We should use g_get_current_time here */ - GTimeVal res; - g_get_current_time (&res); - return res.tv_sec + (1.e-6) * res.tv_usec; -} - /* * Duplicating code here from EGlib to avoid g_strsplit skew between * EGLib and GLib diff --git a/src/mono/mono/eglib/test/test.h b/src/mono/mono/eglib/test/test.h index d807e6c0839ce..46808fada4b87 100644 --- a/src/mono/mono/eglib/test/test.h +++ b/src/mono/mono/eglib/test/test.h @@ -62,7 +62,7 @@ struct _Group { }; gboolean run_group(const Group *group, gint iterations, gboolean quiet, - gboolean time, const char *tests); + const char *tests); #undef FAILED RESULT FAILED(const gchar *format, ...); gdouble get_timestamp (void); diff --git a/src/mono/mono/eglib/test/utf8.c b/src/mono/mono/eglib/test/utf8.c index 5602bbcbcb720..e4487bc5561b4 100644 --- a/src/mono/mono/eglib/test/utf8.c +++ b/src/mono/mono/eglib/test/utf8.c @@ -575,65 +575,6 @@ test_utf8_strlen (void) return OK; } -static RESULT -test_utf8_get_char (void) -{ - gchar word1 [] = {0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,0xF1, 0x82, 0x82, 0x82,'\0'}; //Valid, len = 5 - - gunichar value = g_utf8_get_char (&word1 [0]); - if (value != 0x82UL) - return FAILED ("Expected value of 0x82, but was %x", value); - value = g_utf8_get_char (&word1 [2]); - if (value != 0x45UL) - return FAILED ("Expected value of 0x45, but was %x", value); - value = g_utf8_get_char (&word1 [3]); - if (value != 0x1043UL) - return FAILED ("Expected value of 0x1043, but was %x", value); - value = g_utf8_get_char (&word1 [6]); - if (value != 0x58UL) - return FAILED ("Expected value of 0x58, but was %x", value); - value = g_utf8_get_char (&word1 [7]); - if (value != 0x42082UL) - return FAILED ("Expected value of 0x42082, but was %x", value); - - return OK; -} - -static RESULT -test_utf8_next_char (void) -{ - gchar word1 [] = {0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,0xF1, 0x82, 0x82, 0x82,'\0'}; //Valid, len = 5 - gchar word2 [] = {0xF1, 0x82, 0x82, 0x82,0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,'\0'}; //Valid, len = 5 - gchar word1ExpectedValues [] = {0xC2, 0x45,0xE1, 0x58, 0xF1}; - gchar word2ExpectedValues [] = {0xF1, 0xC2, 0x45, 0xE1, 0x58}; - - gchar* ptr = word1; - gint count = 0; - //Test word1 - while (*ptr != 0) { - if (count > 4) - return FAILED ("Word1 has gone past its expected length"); - if (*ptr != word1ExpectedValues[count]) - return FAILED ("Word1 has an incorrect next_char at index %i", count); - ptr = g_utf8_next_char (ptr); - count++; - } - - //Test word2 - count = 0; - ptr = word2; - while (*ptr != 0) { - if (count > 4) - return FAILED ("Word2 has gone past its expected length"); - if (*ptr != word2ExpectedValues[count]) - return FAILED ("Word2 has an incorrect next_char at index %i", count); - ptr = g_utf8_next_char (ptr); - count++; - } - - return OK; -} - static RESULT test_utf8_validate (void) { @@ -704,8 +645,6 @@ static Test utf8_tests [] = { {"g_ucs4_to_utf16", test_ucs4_to_utf16 }, {"g_utf16_to_ucs4", test_utf16_to_ucs4 }, {"g_utf8_strlen", test_utf8_strlen }, - {"g_utf8_get_char", test_utf8_get_char }, - {"g_utf8_next_char", test_utf8_next_char }, {"g_utf8_validate", test_utf8_validate }, {NULL, NULL} }; diff --git a/src/mono/mono/eventpipe/ds-rt-mono.h b/src/mono/mono/eventpipe/ds-rt-mono.h index a1a8c42e4db85..66e39b7078c4a 100644 --- a/src/mono/mono/eventpipe/ds-rt-mono.h +++ b/src/mono/mono/eventpipe/ds-rt-mono.h @@ -260,7 +260,9 @@ ds_rt_server_log_pause_message (void) #if WCHAR_MAX == 0xFFFF wchar_t* ports_wcs = ports ? (wchar_t *)g_utf8_to_utf16 ((const gchar *)ports, -1, NULL, NULL, NULL) : NULL; #else - wchar_t* ports_wcs = ports ? (wchar_t *)g_utf8_to_ucs4 ((const gchar *)ports, -1, NULL, NULL, NULL) : NULL; + gunichar2 *ports_utf16 = g_utf8_to_utf16 ((const gchar *)ports, -1, NULL, NULL, NULL); + wchar_t* ports_wcs = (wchar_t *)g_utf16_to_ucs4 (ports_utf16, -1, NULL, NULL, NULL); + g_free (ports_utf16); #endif uint32_t port_suspended = ds_rt_config_value_get_default_port_suspend (); diff --git a/src/mono/mono/eventpipe/ep-rt-mono.c b/src/mono/mono/eventpipe/ep-rt-mono.c index de9d2e8671c07..9b9f9e34c4bce 100644 --- a/src/mono/mono/eventpipe/ep-rt-mono.c +++ b/src/mono/mono/eventpipe/ep-rt-mono.c @@ -394,7 +394,6 @@ ep_rt_mono_system_timestamp_get (void) #else #include #include -#include #include #if HAVE_SYS_TIME_H diff --git a/src/mono/mono/metadata/appdomain.c b/src/mono/mono/metadata/appdomain.c index 44c8cf3de8c5b..dca28130a68c9 100644 --- a/src/mono/mono/metadata/appdomain.c +++ b/src/mono/mono/metadata/appdomain.c @@ -26,13 +26,6 @@ #ifdef HAVE_UNISTD_H #include #endif -#ifdef HAVE_UTIME_H -#include -#else -#ifdef HAVE_SYS_UTIME_H -#include -#endif -#endif #include #include @@ -56,10 +49,8 @@ #include #include #include -#include #include #include -#include #include #include #include diff --git a/src/mono/mono/metadata/assembly.c b/src/mono/mono/metadata/assembly.c index 4ba8463c68518..fe0a851603eea 100644 --- a/src/mono/mono/metadata/assembly.c +++ b/src/mono/mono/metadata/assembly.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include diff --git a/src/mono/mono/metadata/cominterop.c b/src/mono/mono/metadata/cominterop.c index d28c6802842df..e8b44578c38ba 100644 --- a/src/mono/mono/metadata/cominterop.c +++ b/src/mono/mono/metadata/cominterop.c @@ -36,7 +36,6 @@ #include "mono/metadata/threads-types.h" #include "mono/metadata/string-icalls.h" #include "mono/metadata/attrdefs.h" -#include "mono/utils/strenc.h" #include "mono/utils/atomic.h" #include "mono/utils/mono-error.h" #include "mono/utils/mono-error-internals.h" @@ -2846,6 +2845,30 @@ cominterop_ccw_get_ids_of_names (MonoCCWInterface* ccwe, gpointer riid, return result; } + +/** + * unicode_to_external: + * \param uni a UTF-16 string to convert to an external representation. + * Turns NULL-terminated UTF-16 into UTF-8. If the conversion doesn't + * work, then NULL is returned. + * Callers must free the returned string. + */ +static gchar * +unicode_to_external (const gunichar2 *uni) +{ + gchar *utf8; + GError *gerr = NULL; + + utf8 = g_utf16_to_utf8 (uni, -1, NULL, NULL, &gerr); + if (utf8 == NULL) { + mono_error_set_argument (err, "uni", gerr->message); + g_error_free (gerr); + return NULL; + } + + return(utf8); +} + static int STDCALL cominterop_ccw_get_ids_of_names_impl (MonoCCWInterface* ccwe, gpointer riid, gunichar2** rgszNames, guint32 cNames, @@ -2876,7 +2899,7 @@ cominterop_ccw_get_ids_of_names_impl (MonoCCWInterface* ccwe, gpointer riid, mono_thread_attach_external_native_thread (mono_get_root_domain (), FALSE); for (i=0; i < cNames; i++) { - methodname = mono_unicode_to_external (rgszNames[i]); + methodname = unicode_to_external (rgszNames[i]); method = mono_class_get_method_from_name_checked(klass, methodname, -1, 0, error); if (method && is_ok (error)) { diff --git a/src/mono/mono/metadata/coree.c b/src/mono/mono/metadata/coree.c index 37c94daf32fdb..98cb499281f2c 100644 --- a/src/mono/mono/metadata/coree.c +++ b/src/mono/mono/metadata/coree.c @@ -33,8 +33,10 @@ #include "coree-internals.h" #include -gchar* -mono_get_module_file_name (HMODULE module_handle) +#if HAVE_API_SUPPORT_WIN32_COREE + +static gchar* +get_module_file_name (HMODULE module_handle) { gunichar2* file_name; gchar* file_name_utf8; @@ -68,7 +70,6 @@ mono_get_module_file_name (HMODULE module_handle) HMODULE coree_module_handle = NULL; static gboolean init_from_coree = FALSE; -#if HAVE_API_SUPPORT_WIN32_COREE #include /* Entry point called by LdrLoadDll of ntdll.dll after _CorValidateImage. */ @@ -85,7 +86,7 @@ BOOL STDMETHODCALLTYPE _CorDllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpRes case DLL_PROCESS_ATTACH: DisableThreadLibraryCalls (hInst); - file_name = mono_get_module_file_name (hInst); + file_name = get_module_file_name (hInst); if (mono_get_root_domain ()) { image = mono_image_open_from_module_handle (alc, hInst, mono_path_resolve_symlinks (file_name), TRUE, NULL); @@ -130,7 +131,7 @@ BOOL STDMETHODCALLTYPE _CorDllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpRes if (lpReserved != NULL) /* The process is terminating. */ return TRUE; - file_name = mono_get_module_file_name (hInst); + file_name = get_module_file_name (hInst); image = mono_image_loaded_internal (alc, file_name); if (image) mono_image_close (image); @@ -158,7 +159,7 @@ __int32 STDMETHODCALLTYPE _CorExeMain(void) gchar** argv; int i; - file_name = mono_get_module_file_name (NULL); + file_name = get_module_file_name (NULL); init_from_coree = TRUE; domain = mono_runtime_load (file_name); diff --git a/src/mono/mono/metadata/coree.h b/src/mono/mono/metadata/coree.h index b61f82ef02d97..fc25a321e682a 100644 --- a/src/mono/mono/metadata/coree.h +++ b/src/mono/mono/metadata/coree.h @@ -41,7 +41,6 @@ extern HMODULE coree_module_handle; HMODULE WINAPI MonoLoadImage(LPCWSTR FileName); STDAPI MonoFixupExe(HMODULE ModuleHandle); -gchar* mono_get_module_file_name (HMODULE module_handle); void mono_load_coree (const char* file_name); void mono_fixup_exe_image (MonoImage* image); diff --git a/src/mono/mono/metadata/loader-internals.h b/src/mono/mono/metadata/loader-internals.h index 994d7d96c2642..3d055c5b6e9b3 100644 --- a/src/mono/mono/metadata/loader-internals.h +++ b/src/mono/mono/metadata/loader-internals.h @@ -40,17 +40,6 @@ struct _MonoBundledSatelliteAssembly { unsigned int size; }; -#ifndef DISABLE_DLLMAP -typedef struct _MonoDllMap MonoDllMap; -struct _MonoDllMap { - char *dll; - char *target; - char *func; - char *target_func; - MonoDllMap *next; -}; -#endif - typedef struct { GHashTable *delegate_invoke_cache; GHashTable *delegate_invoke_virtual_cache; @@ -212,14 +201,6 @@ mono_global_loader_data_unlock (void); gpointer mono_lookup_pinvoke_call_internal (MonoMethod *method, MonoError *error); -#ifndef DISABLE_DLLMAP -void -mono_dllmap_insert_internal (MonoImage *assembly, const char *dll, const char *func, const char *tdll, const char *tfunc); - -void -mono_global_dllmap_cleanup (void); -#endif - void mono_global_loader_cache_init (void); diff --git a/src/mono/mono/metadata/metadata-internals.h b/src/mono/mono/metadata/metadata-internals.h index 47890b0a6bd05..b0d1858f7148e 100644 --- a/src/mono/mono/metadata/metadata-internals.h +++ b/src/mono/mono/metadata/metadata-internals.h @@ -467,11 +467,6 @@ struct _MonoImage { */ void *user_info; -#ifndef DISABLE_DLLMAP - /* dll map entries */ - MonoDllMap *dll_map; -#endif - /* interfaces IDs from this image */ /* protected by the classes lock */ MonoBitSet *interface_bitset; diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index 0dd97c1e64a67..6692736251330 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -51,10 +51,6 @@ static GHashTable *native_library_module_blocklist; extern const void *GlobalizationResolveDllImport (const char *name); #endif -#ifndef DISABLE_DLLMAP -static MonoDllMap *global_dll_map; -#endif - static GHashTable *global_module_map; // should only be accessed with the global loader data lock static MonoDl *internal_module; // used when pinvoking `__Internal` @@ -67,207 +63,10 @@ GENERATE_TRY_GET_CLASS_WITH_CACHE (appdomain_unloaded_exception, "System", "AppD GENERATE_GET_CLASS_WITH_CACHE (native_library, "System.Runtime.InteropServices", "NativeLibrary"); static GENERATE_TRY_GET_CLASS_WITH_CACHE (dllimportsearchpath_attribute, "System.Runtime.InteropServices", "DefaultDllImportSearchPathsAttribute"); -#ifndef DISABLE_DLLMAP -/* - * LOCKING: Assumes the relevant lock is held. - * For the global DllMap, this is `global_loader_data_mutex`, and for images it's their internal lock. - */ -static gboolean -mono_dllmap_lookup_list (MonoDllMap *dll_map, const char *dll, const char* func, const char **rdll, const char **rfunc) { - gboolean found = FALSE; - - *rdll = dll; - *rfunc = func; - - if (!dll_map) - goto exit; - - /* - * we use the first entry we find that matches, since entries from - * the config file are prepended to the list and we document that the - * later entries win. - */ - for (; dll_map; dll_map = dll_map->next) { - // Check case-insensitively when the dll name is prefixed with 'i:' - gboolean case_insensitive_match = strncmp (dll_map->dll, "i:", 2) == 0 && g_ascii_strcasecmp (dll_map->dll + 2, dll) == 0; - gboolean case_sensitive_match = strcmp (dll_map->dll, dll) == 0; - if (!(case_insensitive_match || case_sensitive_match)) - continue; - - if (!found && dll_map->target) { - *rdll = dll_map->target; - found = TRUE; - /* we don't quit here, because we could find a full - * entry that also matches the function, which takes priority. - */ - } - if (dll_map->func && strcmp (dll_map->func, func) == 0) { - *rdll = dll_map->target; - *rfunc = dll_map->target_func; - break; - } - } - -exit: - return found; -} - -/* - * The locking and GC state transitions here are wonky due to the fact the image lock is a coop lock - * and the global loader data lock is an OS lock. - */ -static gboolean -mono_dllmap_lookup (MonoImage *assembly, const char *dll, const char* func, const char **rdll, const char **rfunc) -{ - gboolean res; - - MONO_REQ_GC_UNSAFE_MODE; - - if (assembly && assembly->dll_map) { - mono_image_lock (assembly); - res = mono_dllmap_lookup_list (assembly->dll_map, dll, func, rdll, rfunc); - mono_image_unlock (assembly); - if (res) - goto leave; - } - - MONO_ENTER_GC_SAFE; - - mono_global_loader_data_lock (); - res = mono_dllmap_lookup_list (global_dll_map, dll, func, rdll, rfunc); - mono_global_loader_data_unlock (); - - MONO_EXIT_GC_SAFE; - -leave: - *rdll = g_strdup (*rdll); - *rfunc = g_strdup (*rfunc); - - return res; -} - -static void -dllmap_insert_global (const char *dll, const char *func, const char *tdll, const char *tfunc) -{ - MonoDllMap *entry; - - entry = (MonoDllMap *)g_malloc0 (sizeof (MonoDllMap)); - entry->dll = dll? g_strdup (dll): NULL; - entry->target = tdll? g_strdup (tdll): NULL; - entry->func = func? g_strdup (func): NULL; - entry->target_func = tfunc? g_strdup (tfunc): (func? g_strdup (func): NULL); - - // No transition here because this is early in startup - mono_global_loader_data_lock (); - entry->next = global_dll_map; - global_dll_map = entry; - mono_global_loader_data_unlock (); - -} - -static void -dllmap_insert_image (MonoImage *assembly, const char *dll, const char *func, const char *tdll, const char *tfunc) -{ - MonoDllMap *entry; - g_assert (assembly != NULL); - - MONO_REQ_GC_UNSAFE_MODE; - - entry = (MonoDllMap *)mono_image_alloc0 (assembly, sizeof (MonoDllMap)); - entry->dll = dll? mono_image_strdup (assembly, dll): NULL; - entry->target = tdll? mono_image_strdup (assembly, tdll): NULL; - entry->func = func? mono_image_strdup (assembly, func): NULL; - entry->target_func = tfunc? mono_image_strdup (assembly, tfunc): (func? mono_image_strdup (assembly, func): NULL); - - mono_image_lock (assembly); - entry->next = assembly->dll_map; - assembly->dll_map = entry; - mono_image_unlock (assembly); -} - -/* - * LOCKING: Assumes the relevant lock is held. - * For the global DllMap, this is `global_loader_data_mutex`, and for images it's their internal lock. - */ -static void -free_dllmap (MonoDllMap *map) -{ - while (map) { - MonoDllMap *next = map->next; - - g_free (map->dll); - g_free (map->target); - g_free (map->func); - g_free (map->target_func); - g_free (map); - map = next; - } -} - -void -mono_dllmap_insert_internal (MonoImage *assembly, const char *dll, const char *func, const char *tdll, const char *tfunc) -{ - mono_loader_init (); - // The locking in here is _really_ wonky, and I'm not convinced this function should exist. - // I've split it into an internal version to offer flexibility in the future. - if (!assembly) - dllmap_insert_global (dll, func, tdll, tfunc); - else - dllmap_insert_image (assembly, dll, func, tdll, tfunc); -} - -void -mono_global_dllmap_cleanup (void) -{ - // No need for a transition here since the thread is already detached from the runtime - mono_global_loader_data_lock (); - - free_dllmap (global_dll_map); - global_dll_map = NULL; - - // We don't care about freeing native_library_module_map on netcore because of the expedited shutdown. - - mono_global_loader_data_unlock (); -} -#endif - -/** - * mono_dllmap_insert: - * \param assembly if NULL, this is a global mapping, otherwise the remapping of the dynamic library will only apply to the specified assembly - * \param dll The name of the external library, as it would be found in the \c DllImport declaration. If prefixed with i: the matching of the library name is done without case sensitivity - * \param func if not null, the mapping will only applied to the named function (the value of EntryPoint) - * \param tdll The name of the library to map the specified \p dll if it matches. - * \param tfunc The name of the function that replaces the invocation. If NULL, it is replaced with a copy of \p func. - * - * LOCKING: Acquires the image lock, or the loader data lock if an image is not passed. - * - * This function is used to programatically add \c DllImport remapping in either - * a specific assembly, or as a global remapping. This is done by remapping - * references in a \c DllImport attribute from the \p dll library name into the \p tdll - * name. If the \p dll name contains the prefix i:, the comparison of the - * library name is done without case sensitivity. - * - * If you pass \p func, this is the name of the \c EntryPoint in a \c DllImport if specified - * or the name of the function as determined by \c DllImport. If you pass \p func, you - * must also pass \p tfunc which is the name of the target function to invoke on a match. - * - * Example: - * - * mono_dllmap_insert (NULL, "i:libdemo.dll", NULL, relocated_demo_path, NULL); - * - * The above will remap \c DllImport statements for \c libdemo.dll and \c LIBDEMO.DLL to - * the contents of \c relocated_demo_path for all assemblies in the Mono process. - * - * NOTE: This can be called before the runtime is initialized. - */ void mono_dllmap_insert (MonoImage *assembly, const char *dll, const char *func, const char *tdll, const char *tfunc) { -#ifndef DISABLE_DLLMAP - mono_dllmap_insert_internal (assembly, dll, func, tdll, tfunc); -#else g_assert_not_reached (); -#endif } void @@ -1062,13 +861,8 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou orig_scope = mono_metadata_string_heap (image, scope_token); } -#ifndef DISABLE_DLLMAP - // FIXME: The dllmap remaps System.Native to mono-native - mono_dllmap_lookup (image, orig_scope, orig_import, &new_scope, &new_import); -#else new_scope = g_strdup (orig_scope); new_import = g_strdup (orig_import); -#endif error_scope = new_scope; diff --git a/src/mono/mono/metadata/object.c b/src/mono/mono/metadata/object.c index 0b79c0d713b67..898f6df0eaa77 100644 --- a/src/mono/mono/metadata/object.c +++ b/src/mono/mono/metadata/object.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -4115,6 +4114,31 @@ free_main_args (void) main_args = NULL; } + /** + * utf8_from_external: + * \param in pointer to the string buffer. + * Tries to turn a NULL-terminated string into UTF8. + * + * First, see if it's valid UTF-8, in which case there's nothing more + * to be done. If the conversion doesn't succeed, return NULL. + * + * Callers must free the returned string if not NULL. + */ +static gchar * +utf8_from_external (const gchar *in) +{ + if (in == NULL) { + return NULL; + } + + if (g_utf8_validate (in, -1, NULL)) { + return g_strdup (in); + } + + return NULL; +} + + /** * mono_runtime_set_main_args: * \param argc number of arguments from the command line @@ -4135,7 +4159,7 @@ mono_runtime_set_main_args (int argc, char* argv[]) for (i = 0; i < argc; ++i) { gchar *utf8_arg; - utf8_arg = mono_utf8_from_external (argv[i]); + utf8_arg = utf8_from_external (argv[i]); if (utf8_arg == NULL) { g_print ("\nCannot determine the text encoding for argument %d (%s).\n", i, argv [i]); exit (-1); @@ -4178,7 +4202,7 @@ prepare_run_main (MonoMethod *method, int argc, char *argv[]) basename, (const char*)NULL); - utf8_fullpath = mono_utf8_from_external (fullpath); + utf8_fullpath = utf8_from_external (fullpath); if(utf8_fullpath == NULL) { /* Printing the arg text will cause glib to * whinge about "Invalid UTF-8", but at least @@ -4192,7 +4216,7 @@ prepare_run_main (MonoMethod *method, int argc, char *argv[]) g_free (fullpath); g_free (basename); } else { - utf8_fullpath = mono_utf8_from_external (argv[0]); + utf8_fullpath = utf8_from_external (argv[0]); if(utf8_fullpath == NULL) { g_print ("\nCannot determine the text encoding for the assembly location: %s\n", argv[0]); exit (-1); @@ -4204,7 +4228,7 @@ prepare_run_main (MonoMethod *method, int argc, char *argv[]) for (i = 1; i < argc; ++i) { gchar *utf8_arg; - utf8_arg=mono_utf8_from_external (argv[i]); + utf8_arg=utf8_from_external (argv[i]); if(utf8_arg==NULL) { /* Ditto the comment about Invalid UTF-8 here */ g_print ("\nCannot determine the text encoding for argument %d (%s).\n", i, argv[i]); @@ -4233,7 +4257,7 @@ prepare_run_main (MonoMethod *method, int argc, char *argv[]) * we've checked all these args for the * main_args array. */ - gchar *str = mono_utf8_from_external (argv [i]); + gchar *str = utf8_from_external (argv [i]); MonoString *arg = mono_string_new_checked (str, error); mono_error_assert_ok (error); mono_array_setref_internal (args, i, arg); @@ -6472,7 +6496,7 @@ mono_string_new_wtf8_len_checked (const char *text, guint length, MonoError *err gunichar2 *ut = NULL; glong items_written; - ut = eg_wtf8_to_utf16 (text, length, NULL, &items_written, &eg_error); + ut = g_wtf8_to_utf16 (text, length, NULL, &items_written, &eg_error); if (!eg_error) o = mono_string_new_utf16_checked (ut, items_written, error); diff --git a/src/mono/mono/mini/graph.c b/src/mono/mono/mini/graph.c index 1fffe4c833b7d..0ebc434c3e29b 100644 --- a/src/mono/mono/mini/graph.c +++ b/src/mono/mono/mini/graph.c @@ -200,7 +200,6 @@ mono_draw_graph (MonoCompile *cfg, MonoGraphOptions draw_options) { #ifdef HAVE_SYSTEM char *com; -#endif const char *fn; FILE *fp; @@ -224,7 +223,6 @@ mono_draw_graph (MonoCompile *cfg, MonoGraphOptions draw_options) fclose (fp); -#ifdef HAVE_SYSTEM //com = g_strdup_printf ("dot %s -Tpng -o %s.png; eog %s.png", fn, fn, fn); com = g_strdup_printf ("dot %s -Tps -o %s.ps;gv %s.ps", fn, fn, fn); int _i G_GNUC_UNUSED; diff --git a/src/mono/mono/mini/mini-posix.c b/src/mono/mono/mini/mini-posix.c index be8f83d396872..6b1621bdaa058 100644 --- a/src/mono/mono/mini/mini-posix.c +++ b/src/mono/mono/mini/mini-posix.c @@ -885,23 +885,15 @@ mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_ } #endif /* !MONO_CROSS_COMPILE */ -static gchar *gdb_path; -static gchar *lldb_path; - void mono_init_native_crash_info (void) { - gdb_path = g_find_program_in_path ("gdb"); - lldb_path = g_find_program_in_path ("lldb"); } static gboolean native_stack_with_gdb (pid_t crashed_pid, const char **argv, int commands, char* commands_filename) { - if (!gdb_path) - return FALSE; - - argv [0] = gdb_path; + argv [0] = "gdb"; argv [1] = "-batch"; argv [2] = "-x"; argv [3] = commands_filename; @@ -926,10 +918,7 @@ native_stack_with_gdb (pid_t crashed_pid, const char **argv, int commands, char* static gboolean native_stack_with_lldb (pid_t crashed_pid, const char **argv, int commands, char* commands_filename) { - if (!lldb_path) - return FALSE; - - argv [0] = lldb_path; + argv [0] = "lldb"; argv [1] = "--batch"; argv [2] = "--source"; argv [3] = commands_filename; @@ -955,7 +944,7 @@ native_stack_with_lldb (pid_t crashed_pid, const char **argv, int commands, char void mono_gdb_render_native_backtraces (pid_t crashed_pid) { -#ifdef HAVE_EXECV +#ifdef HAVE_EXECVP const char *argv [10]; memset (argv, 0, sizeof (char*) * 10); @@ -993,12 +982,12 @@ mono_gdb_render_native_backtraces (pid_t crashed_pid) exec: close (commands_handle); - execv (argv [0], (char**)argv); + execvp (argv [0], (char**)argv); _exit (-1); #else g_async_safe_printf ("mono_gdb_render_native_backtraces not supported on this platform\n"); -#endif // HAVE_EXECV +#endif // HAVE_EXECVP } #if !defined (__MACH__) diff --git a/src/mono/mono/mini/mini-wasm.c b/src/mono/mono/mini/mini-wasm.c index 21174bec0d860..6230c1ede105f 100644 --- a/src/mono/mono/mini/mini-wasm.c +++ b/src/mono/mono/mini/mini-wasm.c @@ -675,12 +675,6 @@ sigsuspend(const sigset_t *sigmask) return 0; } -int -getdtablesize (void) -{ - return 256; //random constant that is the fd limit -} - int inotify_init (void) { diff --git a/src/mono/mono/unit-tests/test-mono-embed.c b/src/mono/mono/unit-tests/test-mono-embed.c deleted file mode 100644 index d93daacc36c33..0000000000000 --- a/src/mono/mono/unit-tests/test-mono-embed.c +++ /dev/null @@ -1,7 +0,0 @@ -/* - * test-mono-embed.c: Unit test for embed mono. - */ - -#define _TESTCASE_ -#include -#include diff --git a/src/mono/mono/utils/CMakeLists.txt b/src/mono/mono/utils/CMakeLists.txt index 0932797e5b83c..1934240dc44ae 100644 --- a/src/mono/mono/utils/CMakeLists.txt +++ b/src/mono/mono/utils/CMakeLists.txt @@ -71,7 +71,6 @@ set(utils_common_sources mono-flight-recorder.c mono-os-wait.h mono-coop-mutex.h - mono-once.h mono-lazy-init.h mono-proclib.c mono-proclib.h @@ -79,16 +78,10 @@ set(utils_common_sources mono-string.h mono-time.c mono-time.h - strenc-internals.h - strenc.h - strenc.c - mono-uri.c - mono-poll.c mono-path.c mono-os-semaphore.h mono-coop-semaphore.h mono-sigcontext.h - mono-stdlib.c mono-property-hash.h mono-property-hash.c freebsd-dwarf.h @@ -102,9 +95,6 @@ set(utils_common_sources mono-machine.h mono-math.h mono-path.h - mono-poll.h - mono-uri.h - mono-stdlib.h valgrind.h mach-support.h memcheck.h diff --git a/src/mono/mono/utils/mono-dl-darwin.c b/src/mono/mono/utils/mono-dl-darwin.c index 7a8b6bc62c329..75a316b6c3dba 100644 --- a/src/mono/mono/utils/mono-dl-darwin.c +++ b/src/mono/mono/utils/mono-dl-darwin.c @@ -14,7 +14,6 @@ #if defined (TARGET_MACH) #include "mono/utils/mono-dl.h" -#include "mono/utils/mono-embed.h" #include "mono/utils/mono-path.h" #include diff --git a/src/mono/mono/utils/mono-dl-posix.c b/src/mono/mono/utils/mono-dl-posix.c index e6cf8f547e3f6..0da305efeea93 100644 --- a/src/mono/mono/utils/mono-dl-posix.c +++ b/src/mono/mono/utils/mono-dl-posix.c @@ -18,7 +18,6 @@ #if defined(_POSIX_VERSION) && !defined (HOST_WASM) #include "mono/utils/mono-dl.h" -#include "mono/utils/mono-embed.h" #include "mono/utils/mono-path.h" #include diff --git a/src/mono/mono/utils/mono-dl-wasm.c b/src/mono/mono/utils/mono-dl-wasm.c index 1cb20a7b2806b..e601c3f9610ce 100644 --- a/src/mono/mono/utils/mono-dl-wasm.c +++ b/src/mono/mono/utils/mono-dl-wasm.c @@ -5,7 +5,6 @@ #if defined (HOST_WASM) #include "mono/utils/mono-dl.h" -#include "mono/utils/mono-embed.h" #include "mono/utils/mono-path.h" #include diff --git a/src/mono/mono/utils/mono-dl-windows.c b/src/mono/mono/utils/mono-dl-windows.c index acaa72425630c..1febc741f4e59 100644 --- a/src/mono/mono/utils/mono-dl-windows.c +++ b/src/mono/mono/utils/mono-dl-windows.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include diff --git a/src/mono/mono/utils/mono-dl.c b/src/mono/mono/utils/mono-dl.c index 5c613688aef5b..b772f869d31b6 100644 --- a/src/mono/mono/utils/mono-dl.c +++ b/src/mono/mono/utils/mono-dl.c @@ -12,7 +12,6 @@ #include "config.h" #include "mono/utils/mono-compiler.h" #include "mono/utils/mono-dl.h" -#include "mono/utils/mono-embed.h" #include "mono/utils/mono-path.h" #include "mono/utils/mono-threads-api.h" #include "mono/utils/mono-error-internals.h" diff --git a/src/mono/mono/utils/mono-embed.c b/src/mono/mono/utils/mono-embed.c deleted file mode 100644 index fa89d37166e6a..0000000000000 --- a/src/mono/mono/utils/mono-embed.c +++ /dev/null @@ -1,99 +0,0 @@ -/** - * \file - * Example code APIs to register a libraries using - * mono_dl_fallback_register. Real implementations should instead - * use a binary search for implementing the dl_mapping_open and - * dl_mapping_symbol methods here. - * - * Author: - * Mono Team (http://www.mono-project.com) - * - * Copyright 2001-2004 Ximian, Inc. - * Copyright 2004-2010 Novell, Inc. - * - * Licensed under the MIT license. See LICENSE file in the project root for full license information. - */ -#include "config.h" -#include "mono/utils/mono-dl.h" -#include "mono/utils/mono-embed.h" - -#include -#include -#include -#include -#include - -static GHashTable *mono_dls; - -static void * -dl_mapping_open (const char *file, int flags, char **err, void *user_data) -{ - MonoDlMapping *mappings; - - if (mono_dls == NULL){ - *err = g_strdup ("Library not registered"); - return NULL; - } - - mappings = (MonoDlMapping *) g_hash_table_lookup (mono_dls, file); - *err = g_strdup (mappings == NULL ? "File not registered" : ""); - return mappings; -} - -static void * -dl_mapping_symbol (void *handle, const char *symbol, char **err, void *user_data) -{ - MonoDlMapping *mappings = (MonoDlMapping *) handle; - - for (;mappings->name; mappings++){ - if (strcmp (symbol, mappings->name) == 0){ - *err = g_strdup (""); - return mappings->addr; - } - } - *err = g_strdup ("Symbol not found"); - return NULL; -} - -/** - * mono_dl_register_library: - * \param name Library name, this is the name used by the DllImport as the external library name - * \param mappings the mappings to register for P/Invoke. - * - * The mappings registered using this function are used as fallbacks if the dynamic linker - * fails, or if the platform doesn't have a dynamic linker. - * - * \p mappings is a pointer to the first element of an array of - * \c MonoDlMapping values. The list must be terminated with both - * the \c name and \c addr fields set to NULL. - * - * This is typically used like this: - * MonoDlMapping sample_library_mappings [] = { - * { "CallMe", CallMe }, - * { NULL, NULL } - * }; - * - * ... - * main () - * { - * ... - * mono_dl_register_library ("sample", sample_library_mappings); - * ... - * } - * - * Then the C# code can use this P/Invoke signature: - * - * [DllImport ("sample")] - * extern static int CallMe (int f); - */ -void -mono_dl_register_library (const char *name, MonoDlMapping *mappings) -{ - if (mono_dls == NULL){ - mono_dls = g_hash_table_new (g_str_hash, g_str_equal); - mono_dl_fallback_register (dl_mapping_open, dl_mapping_symbol, NULL, NULL); - } - - g_hash_table_insert (mono_dls, g_strdup (name), mappings); -} - diff --git a/src/mono/mono/utils/mono-embed.h b/src/mono/mono/utils/mono-embed.h deleted file mode 100644 index f4934a47a2de7..0000000000000 --- a/src/mono/mono/utils/mono-embed.h +++ /dev/null @@ -1,20 +0,0 @@ -/** - * \file - */ - -#ifndef __MONO_EMBED_H__ -#define __MONO_EMBED_H__ - -#include - -/* - * This is a fallback for platform symbol loading functionality. - */ -typedef struct { - const char *name; - void *addr; -} MonoDlMapping; - -MONO_API void mono_dl_register_library (const char *name, MonoDlMapping *mappings); - -#endif /* __MONO_EMBED_H__ */ diff --git a/src/mono/mono/utils/mono-once.h b/src/mono/mono/utils/mono-once.h deleted file mode 100644 index 754ae7dd6cc75..0000000000000 --- a/src/mono/mono/utils/mono-once.h +++ /dev/null @@ -1,20 +0,0 @@ -/** - * \file - */ - -#ifndef __MONO_ONCE_H__ -#define __MONO_ONCE_H__ - -#include "mono-lazy-init.h" - -typedef mono_lazy_init_t mono_once_t; - -#define MONO_ONCE_INIT MONO_LAZY_INIT_STATUS_NOT_INITIALIZED - -static inline void -mono_once (mono_once_t *once, void (*once_init) (void)) -{ - mono_lazy_initialize (once, once_init); -} - -#endif /* __MONO_ONCE_H__ */ diff --git a/src/mono/mono/utils/mono-path.c b/src/mono/mono/utils/mono-path.c index 5717bee22568a..4632a74556c3b 100644 --- a/src/mono/mono/utils/mono-path.c +++ b/src/mono/mono/utils/mono-path.c @@ -32,9 +32,6 @@ /* Resolves '..' and '.' references in a path. If the path provided is relative, * it will be relative to the current directory */ -/* For Native Client, the above is not true. Since there is no getcwd we fill */ -/* in the file being passed in relative to '.' and don't resolve it */ - /* There are a couple of tests for this method in mono/test/mono-path.cs */ gchar * mono_path_canonicalize (const char *path) @@ -176,161 +173,3 @@ mono_path_resolve_symlinks (const char *path) return p; #endif } - -static gboolean -mono_path_char_is_separator (char ch) -{ -#ifdef HOST_WIN32 - return ch == '/' || ch == '\\'; -#else - return ch == '/'; -#endif -} - -static gboolean -mono_path_contains_separator (const char *path, size_t length) -{ - for (size_t i = 0; i < length; ++i) { - if (mono_path_char_is_separator (path [i])) - return TRUE; - } - return FALSE; -} - -static void -mono_path_remove_trailing_path_separators (const char *path, size_t *length) -{ - size_t i = *length; - while (i > 0 && mono_path_char_is_separator (path [i - 1])) - i -= 1; - *length = i; -} - -#ifdef HOST_WIN32 - -static gboolean -mono_path_char_is_lowercase (char ch) -{ - return ch >= 'a' && ch <= 'z'; -} - -// Version-specific unichar2 upcase tables are stored per-volume at NTFS format-time. -// This is just a subset. -static char -mono_path_char_upcase (char a) -{ - return mono_path_char_is_lowercase (a) ? (char)(a - 'a' + 'A') : a; -} - -static gboolean -mono_path_char_equal (char a, char b) -{ - return a == b - || mono_path_char_upcase (a) == mono_path_char_upcase (b) - || (mono_path_char_is_separator (a) && mono_path_char_is_separator (b)); -} - -#endif - -static gboolean -mono_path_equal (const char *a, const char *b, size_t length) -{ -#ifdef HOST_WIN32 - size_t i = 0; - for (i = 0; i < length && mono_path_char_equal (a [i], b [i]); ++i) { - // nothing - } - return i == length; -#else - return memcmp (a, b, length) == 0; -#endif -} - -static size_t -mono_path_path_separator_length (const char *a, size_t length) -{ - size_t i = 0; - while (i < length && mono_path_char_is_separator (a [i])) - ++i; - return i; -} - -/** - * mono_path_filename_in_basedir: - * - * Return \c TRUE if \p filename is "immediately" in \p basedir - * - * Both paths should be absolute and be mostly normalized. - * If the file is in a subdirectory of \p basedir, returns \c FALSE. - * This function doesn't touch a filesystem, it looks solely at path names. - * - * In fact, filename might not be absolute, in which case, FALSE. - * Ditto basedir. - * - * To belabor the intent: - * /1/2/3 is considered to be in /1/2 - * /1/2/3/4 is not considered be in /1/2 - * - * Besides a "slash sensitive" prefix match, also check for - * additional slashes. - * - * "Slash sensitive" prefix match means: - * /a/b is a prefix of /a/b/ - * /a/b is not a prefix of /a/bc - * /a/b is maybe a prefix of /a/b - * The string being checked against must either end, or continue with a path separator. - * "Normal" prefix matching would be true for both. - * - * This function also considers runs of slashes to be equivalent to single slashes, - * which is generally Windows behavior, except at the start of a path. - */ -gboolean -mono_path_filename_in_basedir (const char *filename, const char *basedir) -{ - g_assert (filename); - g_assert (basedir); - - size_t filename_length = strlen (filename); - size_t basedir_length = strlen (basedir); - - if (!mono_path_contains_separator (filename, filename_length)) - return FALSE; - if (!mono_path_contains_separator (basedir, basedir_length)) - return FALSE; - //g_assertf (mono_path_contains_separator (filename, filename_length), "filename:%s basedir:%s", filename, basedir); - //g_assertf (mono_path_contains_separator (basedir, basedir_length), "filename:%s basedir:%s", filename, basedir); - - mono_path_remove_trailing_path_separators (filename, &filename_length); - mono_path_remove_trailing_path_separators (basedir, &basedir_length); - - // basedir_length can be 0 at this point and that is ok. - - if (!filename_length - || filename_length <= basedir_length - || (basedir_length && !mono_path_equal (filename, basedir, basedir_length))) - return FALSE; - - // /foo/1 is in /foo. - // /foo//1 is in /foo. - // /foo/1/ is in /foo. - // /foo//1/ is in /foo. - // /foo//1// is in /foo. - - // /foo is not in /foo. - // /foo/ is not in /foo. - // /foob is not in /foo. - // /foo/1/2 is not in /foo. - - // Skip basedir's length within filename. - const char *after_base = &filename [basedir_length]; - size_t after_base_length = filename_length - basedir_length; - - // Skip any number of slashes. - size_t skip_separators = mono_path_path_separator_length (after_base, after_base_length); - after_base += skip_separators; - after_base_length -= skip_separators; - - // There must been at least one slash, and then after any non-slashes, - // there must not be any more slashes. - return skip_separators && !mono_path_contains_separator (after_base, after_base_length); -} diff --git a/src/mono/mono/utils/mono-path.h b/src/mono/mono/utils/mono-path.h index 085307e6588c6..75b9c3c512468 100644 --- a/src/mono/mono/utils/mono-path.h +++ b/src/mono/mono/utils/mono-path.h @@ -10,7 +10,6 @@ MONO_API gchar *mono_path_resolve_symlinks (const char *path); MONO_API gchar *mono_path_canonicalize (const char *path); -gboolean mono_path_filename_in_basedir (const char *filename, const char *basedir); #endif /* __MONO_PATH_H */ diff --git a/src/mono/mono/utils/mono-stdlib.c b/src/mono/mono/utils/mono-stdlib.c deleted file mode 100644 index def3b078f064a..0000000000000 --- a/src/mono/mono/utils/mono-stdlib.c +++ /dev/null @@ -1,71 +0,0 @@ -/** - * \file - * stdlib replacement functions. - * - * Authors: - * Gonzalo Paniagua Javier (gonzalo@novell.com) - * - * (C) 2006 Novell, Inc. http://www.novell.com - * - */ -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#include "mono-stdlib.h" - -#ifndef HAVE_MKSTEMP -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -int -mono_mkstemp (char *templ) -{ - int ret; - int count = 27; /* Windows doc. */ - char *t; - size_t len; - - len = strlen (templ); - do { - t = g_mktemp (templ); - - if (t == NULL) { - mono_set_errno (EINVAL); - return -1; - } - - if (*templ == '\0') { - return -1; - } - - ret = g_open (templ, O_RDWR | O_BINARY | O_CREAT | O_EXCL, 0600); - if (ret == -1) { - if (errno != EEXIST) - return -1; - memcpy (templ + len - 6, "XXXXXX", 6); - } else { - break; - } - - } while (count-- > 0); - - return ret; -} - -#else - -#include - -MONO_EMPTY_SOURCE_FILE (mono_stdlib); - -#endif - diff --git a/src/mono/mono/utils/mono-stdlib.h b/src/mono/mono/utils/mono-stdlib.h deleted file mode 100644 index 64793b223b846..0000000000000 --- a/src/mono/mono/utils/mono-stdlib.h +++ /dev/null @@ -1,20 +0,0 @@ -/** - * \file - */ - -#ifndef __MONO_FILE_H -#define __MONO_FILE_H - -#ifdef HAVE_MKSTEMP -#include -#define mono_mkstemp(a) mkstemp(a) -#else -int mono_mkstemp (char *templ); -#endif - -#if HOST_WASI -char *mktemp (char *); -#endif - -#endif /* __MONO_FILE_H */ - diff --git a/src/mono/mono/utils/mono-threads-posix.c b/src/mono/mono/utils/mono-threads-posix.c index a70691d01e8fe..23c1e4f3056aa 100644 --- a/src/mono/mono/utils/mono-threads-posix.c +++ b/src/mono/mono/utils/mono-threads-posix.c @@ -180,18 +180,7 @@ mono_threads_pthread_kill (MonoThreadInfo *info, int signum) redo: #endif -#ifdef USE_TKILL_ON_ANDROID - { - int old_errno = errno; - - result = tkill (info->native_handle, signum); - - if (result < 0) { - result = errno; - mono_set_errno (old_errno); - } - } -#elif defined (HAVE_PTHREAD_KILL) +#if defined (HAVE_PTHREAD_KILL) result = pthread_kill (mono_thread_info_get_tid (info), signum); #else result = -1; diff --git a/src/mono/mono/utils/mono-uri.c b/src/mono/mono/utils/mono-uri.c deleted file mode 100644 index 9f7b551a1d7c1..0000000000000 --- a/src/mono/mono/utils/mono-uri.c +++ /dev/null @@ -1,51 +0,0 @@ -/** - * \file - * Simple routine used to escape uris. - * - * Author: - * Miguel de Icaza (miguel@novell.com) - * - * (C) 2006 Ximian, Inc. - * - */ -#include "mono-uri.h" - -gchar * -mono_escape_uri_string (const gchar *string) -{ - GString *str = g_string_new (""); - char *ret; - int c; - - while ((c = (guchar) *string) != 0){ - if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '-' && c <= ':') || (c >= '&' && c <= '*')) - g_string_append_c (str, (gchar)c); - else if (c == '!' || c == '=' || c == '?' || c == '_' || c == '~') - g_string_append_c (str, (gchar)c); - else { - g_string_append_c (str, '%'); - g_string_append_c (str, "0123456789ABCDEF" [c >> 4]); - g_string_append_c (str, "0123456789ABCDEF" [c & 0xf]); - } - string++; - } - ret = str->str; - g_string_free (str, FALSE); - return ret; -} - -#if TEST -int main () -{ - char *s = g_malloc (256); - int i = 0; - - s [255] = 0; - - for (i = 1; i < 256; i++) - s [i-1] = i; - - if (strcmp (mono_escape_uri_string (s), "%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20!%22%23%24%25&'()*%2B%2C-./0123456789:%3B%3C=%3E?%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF") != 0) - printf ("Failed test\n"); -} -#endif diff --git a/src/mono/mono/utils/mono-uri.h b/src/mono/mono/utils/mono-uri.h deleted file mode 100644 index 3cbc85e6c0219..0000000000000 --- a/src/mono/mono/utils/mono-uri.h +++ /dev/null @@ -1,13 +0,0 @@ -/** - * \file - */ - -#ifndef __MONO_URI_H -#define __MONO_URI_H -#include -#include - -MONO_API gchar * mono_escape_uri_string (const gchar *string); - -#endif /* __MONO_URI_H */ - diff --git a/src/mono/mono/utils/strenc-internals.h b/src/mono/mono/utils/strenc-internals.h deleted file mode 100644 index c15990c07c59f..0000000000000 --- a/src/mono/mono/utils/strenc-internals.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _MONO_STRENC_INTERNALS_H_ -#define _MONO_STRENC_INTERNALS_H_ - -#include -#include - -gchar *mono_unicode_to_external_checked (const gunichar2 *uni, MonoError *err); - -#endif /* _MONO_STRENC_INTERNALS_H_ */ diff --git a/src/mono/mono/utils/strenc.c b/src/mono/mono/utils/strenc.c deleted file mode 100644 index d210c8bba66a3..0000000000000 --- a/src/mono/mono/utils/strenc.c +++ /dev/null @@ -1,268 +0,0 @@ -/** - * \file - * string encoding conversions - * - * Author: - * Dick Porter (dick@ximian.com) - * - * (C) 2003 Ximian, Inc. - */ - -#include -#include -#include - -#include "strenc.h" -#include "strenc-internals.h" -#include -#include "mono-error-internals.h" - -static const char trailingBytesForUTF8[256] = { - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,0,0 -}; - -/** - * mono_unicode_from_external: - * \param in pointers to the buffer. - * \param bytes number of bytes in the string. - * Tries to turn a NULL-terminated string into UTF-16. - * - * First, see if it's valid UTF-8, in which case just turn it directly - * into UTF-16. If the conversion doesn't succeed, return NULL. - * - * Callers must free the returned string if not NULL. \p bytes holds the number - * of bytes in the returned string, not including the terminator. - */ -gunichar2 *mono_unicode_from_external (const gchar *in, gsize *bytes) -{ - if(in==NULL) { - return(NULL); - } - - if(g_utf8_validate (in, -1, NULL)) { - glong items_written; - gunichar2 *unires=g_utf8_to_utf16 (in, -1, NULL, &items_written, NULL); - items_written *= 2; - *bytes = items_written; - return(unires); - } - - return(NULL); -} - -/** - * mono_utf8_from_external: - * \param in pointer to the string buffer. - * Tries to turn a NULL-terminated string into UTF8. - * - * First, see if it's valid UTF-8, in which case there's nothing more - * to be done. If the conversion doesn't succeed, return NULL. - * - * Callers must free the returned string if not NULL. - * - * This function is identical to \c mono_unicode_from_external, apart - * from returning UTF-8 not UTF-16; it's handy in a few places to work - * in UTF-8. - */ -gchar *mono_utf8_from_external (const gchar *in) -{ - if(in==NULL) { - return(NULL); - } - - if(g_utf8_validate (in, -1, NULL)) { - return(g_strdup (in)); - } - - return(NULL); -} - -/** - * mono_unicode_to_external: - * \param uni a UTF-16 string to convert to an external representation. - * Turns NULL-terminated UTF-16 into UTF-8. If the conversion doesn't - * work, then NULL is returned. - * Callers must free the returned string. - */ -gchar *mono_unicode_to_external (const gunichar2 *uni) -{ - return mono_unicode_to_external_checked (uni, NULL); -} - -gchar *mono_unicode_to_external_checked (const gunichar2 *uni, MonoError *err) -{ - gchar *utf8; - GError *gerr = NULL; - - utf8=g_utf16_to_utf8 (uni, -1, NULL, NULL, &gerr); - if (utf8 == NULL) { - mono_error_set_argument (err, "uni", gerr->message); - g_error_free (gerr); - return NULL; - } - - return(utf8); -} - -/** - * mono_utf8_validate_and_len - * \param source Pointer to putative UTF-8 encoded string. - * Checks \p source for being valid UTF-8. \p utf is assumed to be - * null-terminated. - * \returns TRUE if \p source is valid. - * \p oEnd will equal the null terminator at the end of the string if valid. - * if not valid, it will equal the first charater of the invalid sequence. - * \p oLength will equal the length to \p oEnd - **/ -gboolean -mono_utf8_validate_and_len (const gchar *source, glong* oLength, const gchar** oEnd) -{ - gboolean retVal = TRUE; - gboolean lastRet = TRUE; - guchar* ptr = (guchar*) source; - guchar* srcPtr; - guint length; - guchar a; - *oLength = 0; - while (*ptr != 0) { - length = trailingBytesForUTF8 [*ptr] + 1; - srcPtr = (guchar*) ptr + length; - switch (length) { - default: retVal = FALSE; - /* Everything else falls through when "TRUE"... */ - case 4: if ((a = (*--srcPtr)) < (guchar) 0x80 || a > (guchar) 0xBF) retVal = FALSE; - if ((a == (guchar) 0xBF || a == (guchar) 0xBE) && *(srcPtr-1) == (guchar) 0xBF) { - if (*(srcPtr-2) == (guchar) 0x8F || *(srcPtr-2) == (guchar) 0x9F || - *(srcPtr-2) == (guchar) 0xAF || *(srcPtr-2) == (guchar) 0xBF) - retVal = FALSE; - } - case 3: if ((a = (*--srcPtr)) < (guchar) 0x80 || a > (guchar) 0xBF) retVal = FALSE; - case 2: if ((a = (*--srcPtr)) < (guchar) 0x80 || a > (guchar) 0xBF) retVal = FALSE; - - switch (*ptr) { - /* no fall-through in this inner switch */ - case 0xE0: if (a < (guchar) 0xA0) retVal = FALSE; break; - case 0xED: if (a > (guchar) 0x9F) retVal = FALSE; break; - case 0xEF: { - if (a == (guchar)0xB7 && (*(srcPtr+1) > (guchar) 0x8F && *(srcPtr+1) < 0xB0)) retVal = FALSE; - else if (a == (guchar)0xBF && (*(srcPtr+1) == (guchar) 0xBE || *(srcPtr+1) == 0xBF)) retVal = FALSE; - break; - } - case 0xF0: if (a < (guchar) 0x90) retVal = FALSE; break; - case 0xF4: if (a > (guchar) 0x8F) retVal = FALSE; break; - default: if (a < (guchar) 0x80) retVal = FALSE; - } - - case 1: if (*ptr >= (guchar ) 0x80 && *ptr < (guchar) 0xC2) retVal = FALSE; - } - if (*ptr > (guchar) 0xF4) - retVal = FALSE; - //If the string is invalid, set the end to the invalid byte. - if (!retVal && lastRet) { - if (oEnd != NULL) - *oEnd = (gchar*) ptr; - lastRet = FALSE; - } - ptr += length; - (*oLength)++; - } - if (retVal && oEnd != NULL) - *oEnd = (gchar*) ptr; - return retVal; -} - - -/** - * mono_utf8_validate_and_len_with_bounds - * \param source: Pointer to putative UTF-8 encoded string. - * \param max_bytes: Max number of bytes that can be decoded. - * - * Checks \p source for being valid UTF-8. \p utf is assumed to be - * null-terminated. - * - * This function returns FALSE if it needs to decode characters beyond \p max_bytes. - * - * \returns TRUE if \p source is valid. - * \p oEnd will equal the null terminator at the end of the string if valid. - * if not valid, it will equal the first charater of the invalid sequence. - * \p oLength will equal the length to \p oEnd - **/ -gboolean -mono_utf8_validate_and_len_with_bounds (const gchar *source, glong max_bytes, glong* oLength, const gchar** oEnd) -{ - gboolean retVal = TRUE; - gboolean lastRet = TRUE; - guchar* ptr = (guchar*) source; - guchar *end = ptr + max_bytes; - guchar* srcPtr; - guint length; - guchar a; - *oLength = 0; - - if (max_bytes < 1) { - if (oEnd) - *oEnd = (gchar*) ptr; - return FALSE; - } - - while (*ptr != 0) { - length = trailingBytesForUTF8 [*ptr] + 1; - srcPtr = (guchar*) ptr + length; - - /* since *ptr is not zero we must ensure that we can decode the current char + the byte after - srcPtr points to the first byte after the current char.*/ - if (srcPtr >= end) { - retVal = FALSE; - break; - } - switch (length) { - default: retVal = FALSE; - /* Everything else falls through when "TRUE"... */ - case 4: if ((a = (*--srcPtr)) < (guchar) 0x80 || a > (guchar) 0xBF) retVal = FALSE; - if ((a == (guchar) 0xBF || a == (guchar) 0xBE) && *(srcPtr-1) == (guchar) 0xBF) { - if (*(srcPtr-2) == (guchar) 0x8F || *(srcPtr-2) == (guchar) 0x9F || - *(srcPtr-2) == (guchar) 0xAF || *(srcPtr-2) == (guchar) 0xBF) - retVal = FALSE; - } - case 3: if ((a = (*--srcPtr)) < (guchar) 0x80 || a > (guchar) 0xBF) retVal = FALSE; - case 2: if ((a = (*--srcPtr)) < (guchar) 0x80 || a > (guchar) 0xBF) retVal = FALSE; - - switch (*ptr) { - /* no fall-through in this inner switch */ - case 0xE0: if (a < (guchar) 0xA0) retVal = FALSE; break; - case 0xED: if (a > (guchar) 0x9F) retVal = FALSE; break; - case 0xEF: { - if (a == (guchar)0xB7 && (*(srcPtr+1) > (guchar) 0x8F && *(srcPtr+1) < 0xB0)) retVal = FALSE; - else if (a == (guchar)0xBF && (*(srcPtr+1) == (guchar) 0xBE || *(srcPtr+1) == 0xBF)) retVal = FALSE; - break; - } - case 0xF0: if (a < (guchar) 0x90) retVal = FALSE; break; - case 0xF4: if (a > (guchar) 0x8F) retVal = FALSE; break; - default: if (a < (guchar) 0x80) retVal = FALSE; - } - - case 1: if (*ptr >= (guchar ) 0x80 && *ptr < (guchar) 0xC2) retVal = FALSE; - } - if (*ptr > (guchar) 0xF4) - retVal = FALSE; - //If the string is invalid, set the end to the invalid byte. - if (!retVal && lastRet) { - if (oEnd != NULL) - *oEnd = (gchar*) ptr; - lastRet = FALSE; - } - ptr += length; - (*oLength)++; - } - if (retVal && oEnd != NULL) - *oEnd = (gchar*) ptr; - return retVal; -} - diff --git a/src/mono/mono/utils/strenc.h b/src/mono/mono/utils/strenc.h deleted file mode 100644 index 0f999531242a3..0000000000000 --- a/src/mono/mono/utils/strenc.h +++ /dev/null @@ -1,23 +0,0 @@ -/** - * \file - * string encoding conversions - * - * Author: - * Dick Porter (dick@ximian.com) - * - * (C) 2003 Ximian, Inc. - */ - -#ifndef _MONO_STRENC_H_ -#define _MONO_STRENC_H_ 1 - -#include -#include - -MONO_API gunichar2 *mono_unicode_from_external (const gchar *in, gsize *bytes); -MONO_API gchar *mono_utf8_from_external (const gchar *in); -MONO_API gchar *mono_unicode_to_external (const gunichar2 *uni); -MONO_API gboolean mono_utf8_validate_and_len (const gchar *source, glong* oLength, const gchar** oEnd); -MONO_API gboolean mono_utf8_validate_and_len_with_bounds (const gchar *source, glong max_bytes, glong* oLength, const gchar** oEnd); - -#endif /* _MONO_STRENC_H_ */ diff --git a/src/mono/mono/utils/w32subset.h b/src/mono/mono/utils/w32subset.h index 3eae2fa9565b9..82a335817a9a0 100644 --- a/src/mono/mono/utils/w32subset.h +++ b/src/mono/mono/utils/w32subset.h @@ -21,7 +21,7 @@ #ifndef HAVE_API_SUPPORT_WIN32_CANCEL_IO #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \ - G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) + G_HAVE_API_SUPPORT(HAVE_APP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_CANCEL_IO 1 #else #define HAVE_API_SUPPORT_WIN32_CANCEL_IO 0 @@ -30,7 +30,7 @@ #ifndef HAVE_API_SUPPORT_WIN32_CANCEL_IO_EX #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \ - G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) + G_HAVE_API_SUPPORT(HAVE_APP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_CANCEL_IO_EX 1 #else #define HAVE_API_SUPPORT_WIN32_CANCEL_IO_EX 0 @@ -71,7 +71,7 @@ #ifndef HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \ - G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) + G_HAVE_API_SUPPORT(HAVE_APP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE 1 #else #define HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE 0 @@ -80,7 +80,7 @@ #ifndef HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE_EX #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \ - G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) + G_HAVE_API_SUPPORT(HAVE_APP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE_EX 1 #else #define HAVE_API_SUPPORT_WIN32_CREATE_SEMAPHORE_EX 0 @@ -104,7 +104,7 @@ #endif #ifndef HAVE_API_SUPPORT_WIN32_FILE_MAPPING_FROM_APP -#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) +#if G_HAVE_API_SUPPORT(HAVE_APP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_FILE_MAPPING_FROM_APP 1 #else #define HAVE_API_SUPPORT_WIN32_FILE_MAPPING_FROM_APP 0 @@ -113,7 +113,7 @@ #ifndef HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \ - G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) + G_HAVE_API_SUPPORT(HAVE_APP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE 1 #else #define HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE 0 @@ -122,7 +122,7 @@ #ifndef HAVE_API_SUPPORT_WIN32_GET_MODULE_BASE_NAME #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \ - G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) + G_HAVE_API_SUPPORT(HAVE_APP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_GET_MODULE_BASE_NAME 1 #else #define HAVE_API_SUPPORT_WIN32_GET_MODULE_BASE_NAME 0 @@ -131,7 +131,7 @@ #ifndef HAVE_API_SUPPORT_WIN32_GET_MODULE_FILE_NAME_EX #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \ - G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) + G_HAVE_API_SUPPORT(HAVE_APP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_GET_MODULE_FILE_NAME_EX 1 #else #define HAVE_API_SUPPORT_WIN32_GET_MODULE_FILE_NAME_EX 0 @@ -171,7 +171,7 @@ #endif #ifndef HAVE_API_SUPPORT_WIN32_LOAD_PACKAGED_LIBRARY -#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) +#if G_HAVE_API_SUPPORT(HAVE_APP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_LOAD_PACKAGED_LIBRARY 1 #else #define HAVE_API_SUPPORT_WIN32_LOAD_PACKAGED_LIBRARY 0 @@ -180,7 +180,7 @@ #ifndef HAVE_API_SUPPORT_WIN32_LOCAL_ALLOC_FREE #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \ - G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) + G_HAVE_API_SUPPORT(HAVE_APP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_LOCAL_ALLOC_FREE 1 #else #define HAVE_API_SUPPORT_WIN32_LOCAL_ALLOC_FREE 0 @@ -189,7 +189,7 @@ #ifndef HAVE_API_SUPPORT_WIN32_OPEN_THREAD #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \ - G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) + G_HAVE_API_SUPPORT(HAVE_APP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_OPEN_THREAD 1 #else #define HAVE_API_SUPPORT_WIN32_OPEN_THREAD 0 @@ -214,7 +214,7 @@ #ifndef HAVE_API_SUPPORT_WIN32_SET_ERROR_MODE #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || \ - G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) + G_HAVE_API_SUPPORT(HAVE_APP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_SET_ERROR_MODE 1 #else #define HAVE_API_SUPPORT_WIN32_SET_ERROR_MODE 0 @@ -230,7 +230,7 @@ #endif #ifndef HAVE_API_SUPPORT_WIN32_SET_THREAD_DESCRIPTION -#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) +#if G_HAVE_API_SUPPORT(HAVE_APP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_SET_THREAD_DESCRIPTION 1 #else #define HAVE_API_SUPPORT_WIN32_SET_THREAD_DESCRIPTION 0