[io-layer] Remove status.h, types.h, timefuncs.h and macros.h (#4069)
authorLudovic Henry <ludovic@xamarin.com>
Fri, 2 Dec 2016 15:33:22 +0000 (10:33 -0500)
committerGitHub <noreply@github.com>
Fri, 2 Dec 2016 15:33:22 +0000 (10:33 -0500)
* [io-layer] Remove status.h

* [io-layer] Remove types.h

* [io-layer] Remove timefuncs.h

* [io-layer] Remove macros.h

13 files changed:
mono/io-layer/Makefile.am
mono/io-layer/io.c
mono/io-layer/io.h
mono/io-layer/macros.h [deleted file]
mono/io-layer/status.h [deleted file]
mono/io-layer/timefuncs.c [deleted file]
mono/io-layer/timefuncs.h [deleted file]
mono/io-layer/types.h [deleted file]
mono/io-layer/uglify.h
mono/io-layer/wapi.h
mono/metadata/w32process-unix.c
mono/metadata/w32process.c
mono/utils/networking-windows.c

index 31fa343ed5bac58abdcb6ddc7f9a34e62a129877..2240cf753d79aba9f5edf1e02a2f850b5d433263 100644 (file)
@@ -16,13 +16,9 @@ OTHER_H = \
        io-trace.h      \
        io-layer.h      \
        io-portability.h        \
-       macros.h        \
        messages.h      \
        security.h      \
        sockets.h       \
-       status.h        \
-       timefuncs.h     \
-       types.h         \
        uglify.h        \
        versioninfo.h   \
        wapi.h          \
@@ -38,7 +34,6 @@ OTHER_SRC = \
        io-private.h            \
        io-layer.h              \
        locking.c               \
-       macros.h                \
        messages.c              \
        messages.h              \
        posix.c                 \
@@ -48,10 +43,6 @@ OTHER_SRC = \
        sockets.h               \
        socket-private.h        \
        socket-wrappers.h       \
-       status.h                \
-       timefuncs.c             \
-       timefuncs.h             \
-       types.h                 \
        uglify.h                \
        versioninfo.c           \
        versioninfo.h           \
index 70a374557dd3a9a16f32956790699accd6efdfb7..05d554a12c0c621abf4b44aabf6239d36781301b 100644 (file)
@@ -39,7 +39,6 @@
 #include <mono/io-layer/wapi.h>
 #include <mono/io-layer/wapi-private.h>
 #include <mono/io-layer/io-private.h>
-#include <mono/io-layer/timefuncs.h>
 #include <mono/io-layer/io-portability.h>
 #include <mono/io-layer/io-trace.h>
 #include <mono/utils/strenc.h>
 static GHashTable *file_share_hash;
 static mono_mutex_t file_share_mutex;
 
+static void
+time_t_to_filetime (time_t timeval, WapiFileTime *filetime)
+{
+       guint64 ticks;
+       
+       ticks = ((guint64)timeval * 10000000) + 116444736000000000ULL;
+       filetime->dwLowDateTime = ticks & 0xFFFFFFFF;
+       filetime->dwHighDateTime = ticks >> 32;
+}
+
 static void
 _wapi_handle_share_release (_WapiFileShare *share_info)
 {
@@ -2992,9 +3001,9 @@ retry:
        find_data->dwFileAttributes = _wapi_stat_to_file_attributes (utf8_filename, &buf, &linkbuf);
 #endif
 
-       _wapi_time_t_to_filetime (create_time, &find_data->ftCreationTime);
-       _wapi_time_t_to_filetime (buf.st_atime, &find_data->ftLastAccessTime);
-       _wapi_time_t_to_filetime (buf.st_mtime, &find_data->ftLastWriteTime);
+       time_t_to_filetime (create_time, &find_data->ftCreationTime);
+       time_t_to_filetime (buf.st_atime, &find_data->ftLastAccessTime);
+       time_t_to_filetime (buf.st_mtime, &find_data->ftLastWriteTime);
 
        if (find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
                find_data->nFileSizeHigh = 0;
@@ -3301,9 +3310,9 @@ gboolean GetFileAttributesEx (const gunichar2 *name, WapiGetFileExInfoLevels lev
 
        g_free (utf8_name);
 
-       _wapi_time_t_to_filetime (create_time, &data->ftCreationTime);
-       _wapi_time_t_to_filetime (buf.st_atime, &data->ftLastAccessTime);
-       _wapi_time_t_to_filetime (buf.st_mtime, &data->ftLastWriteTime);
+       time_t_to_filetime (create_time, &data->ftCreationTime);
+       time_t_to_filetime (buf.st_atime, &data->ftLastAccessTime);
+       time_t_to_filetime (buf.st_mtime, &data->ftLastWriteTime);
 
        if (data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
                data->nFileSizeHigh = 0;
@@ -3998,9 +4007,9 @@ GetLogicalDriveStrings_Mtab (guint32 len, gunichar2 *buf)
 #endif
 
 #if defined(HAVE_STATVFS) || defined(HAVE_STATFS)
-gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, WapiULargeInteger *free_bytes_avail,
-                           WapiULargeInteger *total_number_of_bytes,
-                           WapiULargeInteger *total_number_of_free_bytes)
+gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, ULARGE_INTEGER *free_bytes_avail,
+                           ULARGE_INTEGER *total_number_of_bytes,
+                           ULARGE_INTEGER *total_number_of_free_bytes)
 {
 #ifdef HAVE_STATVFS
        struct statvfs fsstat;
@@ -4081,9 +4090,9 @@ gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, WapiULargeInteger *free_
        return(TRUE);
 }
 #else
-gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, WapiULargeInteger *free_bytes_avail,
-                           WapiULargeInteger *total_number_of_bytes,
-                           WapiULargeInteger *total_number_of_free_bytes)
+gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, ULARGE_INTEGER *free_bytes_avail,
+                           ULARGE_INTEGER *total_number_of_bytes,
+                           ULARGE_INTEGER *total_number_of_free_bytes)
 {
        if (free_bytes_avail != NULL) {
                free_bytes_avail->QuadPart = (guint64) -1;
index 5321bcd7c4459da7642a1dd34fbe00d936c6e6c6..6e518b60e4596bb7be514d12a7a90f3db8ff39df 100644 (file)
@@ -13,7 +13,6 @@
 #include <stdlib.h>
 
 #include "mono/io-layer/wapi.h"
-#include "mono/io-layer/timefuncs.h"
 
 G_BEGIN_DECLS
 
@@ -134,6 +133,16 @@ typedef struct
        guint16 wMilliseconds;
 } WapiSystemTime;
 
+typedef struct {
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+       guint32 dwHighDateTime;
+       guint32 dwLowDateTime;
+#else
+       guint32 dwLowDateTime;
+       guint32 dwHighDateTime;
+#endif
+} WapiFileTime;
+
 typedef struct
 {
        guint32 dwFileAttributes;
@@ -158,6 +167,14 @@ typedef struct
        guint32 nFileSizeLow;
 } WapiFileAttributesData;
 
+typedef union {
+       struct {
+               guint32 LowPart;
+               guint32 HighPart;
+       } u;
+       guint64 QuadPart;
+} ULARGE_INTEGER;
+
 #define INVALID_SET_FILE_POINTER ((guint32)-1)
 #define INVALID_FILE_SIZE ((guint32)0xFFFFFFFF)
 #define INVALID_FILE_ATTRIBUTES ((guint32)-1)
@@ -211,9 +228,9 @@ extern gboolean SetCurrentDirectory (const gunichar2 *path);
 extern gboolean CreatePipe (gpointer *readpipe, gpointer *writepipe,
                            WapiSecurityAttributes *security, guint32 size);
 extern gint32 GetLogicalDriveStrings (guint32 len, gunichar2 *buf);
-extern gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, WapiULargeInteger *free_bytes_avail,
-                                  WapiULargeInteger *total_number_of_bytes,
-                                  WapiULargeInteger *total_number_of_free_bytes);
+extern gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, ULARGE_INTEGER *free_bytes_avail,
+                                  ULARGE_INTEGER *total_number_of_bytes,
+                                  ULARGE_INTEGER *total_number_of_free_bytes);
 extern guint32 GetDriveType(const gunichar2 *root_path_name);
 extern gboolean LockFile (gpointer handle, guint32 offset_low,
                          guint32 offset_high, guint32 length_low,
diff --git a/mono/io-layer/macros.h b/mono/io-layer/macros.h
deleted file mode 100644 (file)
index f2fd8a4..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * macros.h:  Useful macros
- *
- * Author:
- *     Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_MACROS_H_
-#define _WAPI_MACROS_H_
-
-#include <glib.h>
-
-#if defined(__native_client__)
-#include <mono/metadata/nacl-stub.h>
-#endif
-
-#define MAKEWORD(low, high) ((guint16)(((guint8)(low)) | \
-                                      ((guint16)((guint8)(high))) << 8))
-#define MAKELONG(low, high) ((guint32)(((guint16)(low)) | \
-                                      ((guint32)((guint16)(high))) << 16))
-#define LOWORD(i32) ((guint16)((i32) & 0xFFFF))
-#define HIWORD(i32) ((guint16)(((guint32)(i32) >> 16) & 0xFFFF))
-#define LOBYTE(i16) ((guint8)((i16) & 0xFF))
-#define HIBYTE(i16) ((guint8)(((guint16)(i16) >> 8) & 0xFF))
-
-#endif /* _WAPI_MACROS_H_ */
diff --git a/mono/io-layer/status.h b/mono/io-layer/status.h
deleted file mode 100644 (file)
index ce18369..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * status.h:  Status return codes
- *
- * Author:
- *     Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_STATUS_H_
-#define _WAPI_STATUS_H_
-
-typedef enum {
-       STATUS_WAIT_0                   = (int) 0x00000000,
-       STATUS_ABANDONED_WAIT_0         = (int) 0x00000080,
-       STATUS_USER_APC                 = (int) 0x000000C0,
-       STATUS_TIMEOUT                  = (int) 0x00000102,
-       STATUS_PENDING                  = (int) 0x00000103,
-       STATUS_SEGMENT_NOTIFICATION     = (int) 0x40000005,
-       STATUS_GUARD_PAGE_VIOLATION     = (int) 0x80000001,
-       STATUS_DATATYPE_MISALIGNMENT    = (int) 0x80000002,
-       STATUS_BREAKPOINT               = (int) 0x80000003,
-       STATUS_SINGLE_STEP              = (int) 0x80000004,
-       STATUS_ACCESS_VIOLATION         = (int) 0xC0000005,
-       STATUS_IN_PAGE_ERROR            = (int) 0xC0000006,
-       STATUS_NO_MEMORY                = (int) 0xC0000017,
-       STATUS_ILLEGAL_INSTRUCTION      = (int) 0xC000001D,
-       STATUS_NONCONTINUABLE_EXCEPTION = (int) 0xC0000025,
-       STATUS_INVALID_DISPOSITION      = (int) 0xC0000026,
-       STATUS_ARRAY_BOUNDS_EXCEEDED    = (int) 0xC000008C,
-       STATUS_FLOAT_DENORMAL_OPERAND   = (int) 0xC000008D,
-       STATUS_FLOAT_DIVIDE_BY_ZERO     = (int) 0xC000008E,
-       STATUS_FLOAT_INEXACT_RESULT     = (int) 0xC000008F,
-       STATUS_FLOAT_INVALID_OPERATION  = (int) 0xC0000090,
-       STATUS_FLOAT_OVERFLOW           = (int) 0xC0000091,
-       STATUS_FLOAT_STACK_CHECK        = (int) 0xC0000092,
-       STATUS_FLOAT_UNDERFLOW          = (int) 0xC0000093,
-       STATUS_INTEGER_DIVIDE_BY_ZERO   = (int) 0xC0000094,
-       STATUS_INTEGER_UNDERFLOW        = (int) 0xC0000095,
-       STATUS_PRIVILEGED_INSTRUCTION   = (int) 0xC0000096,
-       STATUS_STACK_OVERFLOW           = (int) 0xC00000FD,
-       STATUS_CONTROL_C_EXIT           = (int) 0xC000013A
-} WapiStatus;
-
-#endif /* _WAPI_STATUS_H_ */
diff --git a/mono/io-layer/timefuncs.c b/mono/io-layer/timefuncs.c
deleted file mode 100644 (file)
index 7ec8e4a..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * timefuncs.c:  performance timer and other time functions
- *
- * Author:
- *     Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#include <config.h>
-#include <glib.h>
-#include <sys/time.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <mono/io-layer/wapi.h>
-#include <mono/io-layer/timefuncs.h>
-#include "mono/utils/mono-time.h"
-
-#undef DEBUG
-
-void _wapi_time_t_to_filetime (time_t timeval, WapiFileTime *filetime)
-{
-       guint64 ticks;
-       
-       ticks = ((guint64)timeval * 10000000) + 116444736000000000ULL;
-       filetime->dwLowDateTime = ticks & 0xFFFFFFFF;
-       filetime->dwHighDateTime = ticks >> 32;
-}
diff --git a/mono/io-layer/timefuncs.h b/mono/io-layer/timefuncs.h
deleted file mode 100644 (file)
index 2b43396..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * timefuncs.h:  performance timer and other time functions
- *
- * Author:
- *     Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_TIME_H_
-#define _WAPI_TIME_H_
-
-#include <glib.h>
-
-#include <sys/time.h>
-
-#include "mono/io-layer/wapi.h"
-
-G_BEGIN_DECLS
-
-/* The typical idiom for this struct is to cast it to and from 64bit
- * ints, hence the endian switch.
- */
-typedef struct 
-{
-#if G_BYTE_ORDER == G_BIG_ENDIAN
-       guint32 dwHighDateTime;
-       guint32 dwLowDateTime;
-#else
-       guint32 dwLowDateTime;
-       guint32 dwHighDateTime;
-#endif
-} WapiFileTime;
-
-extern void _wapi_time_t_to_filetime (time_t timeval, WapiFileTime *filetime);
-
-G_END_DECLS
-#endif /* _WAPI_TIME_H_ */
diff --git a/mono/io-layer/types.h b/mono/io-layer/types.h
deleted file mode 100644 (file)
index 68576c8..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * types.h:  Generic type definitions
- *
- * Author:
- *     Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_TYPES_H_
-#define _WAPI_TYPES_H_
-
-#include <glib.h>
-
-typedef union {
-       struct {
-               guint32 LowPart;
-               gint32 HighPart;
-       } u;
-       guint64 QuadPart;
-} WapiLargeInteger;
-
-typedef union {
-       struct {
-               guint32 LowPart;
-               guint32 HighPart;
-       } u;
-       guint64 QuadPart;
-} WapiULargeInteger;
-
-#endif /* _WAPI_TYPES_H_ */
index ff5a53c21bdeda2c285f75e1796d9b4ffdb4fab2..7848a9a0e97a251723c8d0608da4951411394c0b 100644 (file)
@@ -58,10 +58,6 @@ typedef WapiWSAData WSADATA;
 typedef WapiWSAData *LDWSADATA;
 typedef WapiWSABuf WSABUF;
 typedef WapiWSABuf *LPWSABUF;
-typedef WapiLargeInteger LARGE_INTEGER;
-typedef WapiLargeInteger *PLARGE_INTEGER;
-typedef WapiULargeInteger ULARGE_INTEGER;
-typedef WapiULargeInteger *PULARGE_INTEGER;
 typedef WapiFindData WIN32_FIND_DATA;
 typedef WapiFindData *LPWIN32_FIND_DATA;
 typedef WapiFileAttributesData WIN32_FILE_ATTRIBUTE_DATA;
index 8a7ef1f77daa6a2600f919220a45bc2b0c268cb2..769eaf1c80b6d2dc2ff9f6928639908348514aff 100644 (file)
 #include <sys/types.h>
 
 #include <mono/io-layer/wapi-remap.h>
-#include <mono/io-layer/types.h>
-#include <mono/io-layer/macros.h>
 #include <mono/io-layer/io.h>
 #include <mono/io-layer/error.h>
 #include <mono/io-layer/messages.h>
 #include <mono/io-layer/security.h>
 #include <mono/io-layer/sockets.h>
-#include <mono/io-layer/status.h>
-#include <mono/io-layer/timefuncs.h>
 #include <mono/io-layer/versioninfo.h>
 
 G_BEGIN_DECLS
 
-#define WAIT_FAILED            0xFFFFFFFF
-#define WAIT_OBJECT_0          ((STATUS_WAIT_0) +0)
-#define WAIT_ABANDONED         ((STATUS_ABANDONED_WAIT_0) +0)
-#define WAIT_ABANDONED_0       ((STATUS_ABANDONED_WAIT_0) +0)
-#define WAIT_TIMEOUT           STATUS_TIMEOUT
-#define WAIT_IO_COMPLETION     STATUS_USER_APC
+#define WAIT_FAILED        ((int) 0xFFFFFFFF)
+#define WAIT_OBJECT_0      ((int) 0x00000000)
+#define WAIT_ABANDONED_0   ((int) 0x00000080)
+#define WAIT_TIMEOUT       ((int) 0x00000102)
+#define WAIT_IO_COMPLETION ((int) 0x000000C0)
 
 void
 wapi_init (void);
index 7ae000b1bd56162c07511c0381adf0a737b6bc37..cdefb2f6fbc84cc509598bc38729c57b0dbffd1c 100644 (file)
@@ -159,8 +159,8 @@ typedef struct {
        pid_t id;
        guint32 exitstatus;
        gpointer main_thread;
-       WapiFileTime create_time;
-       WapiFileTime exit_time;
+       guint64 create_time;
+       guint64 exit_time;
        char *proc_name;
        size_t min_working_set;
        size_t max_working_set;
@@ -329,7 +329,8 @@ process_wait (gpointer handle, guint32 timeout, gboolean *alerted)
                process_handle->exitstatus = 128 + WTERMSIG (status);
        else
                process_handle->exitstatus = WEXITSTATUS (status);
-       _wapi_time_t_to_filetime (time (NULL), &process_handle->exit_time);
+
+       process_handle->exit_time = mono_100ns_datetime ();
 
        process_handle->exited = TRUE;
 
@@ -454,7 +455,7 @@ process_set_defaults (MonoW32HandleProcess *process_handle)
        process_handle->min_working_set = 204800;
        process_handle->max_working_set = 1413120;
 
-       _wapi_time_t_to_filetime (time (NULL), &process_handle->create_time);
+       process_handle->create_time = mono_100ns_datetime ();
 }
 
 static void
@@ -2305,13 +2306,6 @@ ticks_to_processtime (guint64 ticks, ProcessTime *processtime)
        processtime->highDateTime = ticks >> 32;
 }
 
-static void
-wapifiletime_to_processtime (WapiFileTime wapi_filetime, ProcessTime *processtime)
-{
-       processtime->lowDateTime = wapi_filetime.dwLowDateTime;
-       processtime->highDateTime = wapi_filetime.dwHighDateTime;
-}
-
 MonoBoolean
 ves_icall_Microsoft_Win32_NativeMethods_GetProcessTimes (gpointer handle, gint64 *creation_time, gint64 *exit_time, gint64 *kernel_time, gint64 *user_time)
 {
@@ -2352,12 +2346,12 @@ ves_icall_Microsoft_Win32_NativeMethods_GetProcessTimes (gpointer handle, gint64
                return FALSE;
        }
 
-       wapifiletime_to_processtime (process_handle->create_time, creation_processtime);
+       ticks_to_processtime (process_handle->create_time, creation_processtime);
 
        /* A process handle is only signalled if the process has
         * exited, otherwise exit_processtime isn't set */
        if (mono_w32handle_issignalled (handle))
-               wapifiletime_to_processtime (process_handle->exit_time, exit_processtime);
+               ticks_to_processtime (process_handle->exit_time, exit_processtime);
 
 #ifdef HAVE_GETRUSAGE
        if (process_handle->id == getpid ()) {
index 614168ed5873dd3a486656513b5c2dfb2b87f41f..9d78484d0c6c2a9fec9b56f54b7f4ad40de128c0 100644 (file)
@@ -313,7 +313,12 @@ mono_w32process_get_fileversion (MonoObject *filever, gunichar2 *filename, MonoE
                        }
 
                        if (VerQueryValue (data, query, (gpointer *)&ffi, &ffi_size)) {
-                               LOGDEBUG (g_message ("%s: recording assembly: FileName [%s] FileVersionInfo [%d.%d.%d.%d]", __func__, g_utf16_to_utf8 (filename, -1, NULL, NULL, NULL), HIWORD (ffi->dwFileVersionMS), LOWORD (ffi->dwFileVersionMS), HIWORD (ffi->dwFileVersionLS), LOWORD (ffi->dwFileVersionLS)));
+                               #define LOWORD(i32) ((guint16)((i32) & 0xFFFF))
+                               #define HIWORD(i32) ((guint16)(((guint32)(i32) >> 16) & 0xFFFF))
+
+                               LOGDEBUG (g_message ("%s: recording assembly: FileName [%s] FileVersionInfo [%d.%d.%d.%d]",
+                                       __func__, g_utf16_to_utf8 (filename, -1, NULL, NULL, NULL), HIWORD (ffi->dwFileVersionMS),
+                                               LOWORD (ffi->dwFileVersionMS), HIWORD (ffi->dwFileVersionLS), LOWORD (ffi->dwFileVersionLS)));
 
                                process_set_field_int (filever, "filemajorpart", HIWORD (ffi->dwFileVersionMS));
                                process_set_field_int (filever, "fileminorpart", LOWORD (ffi->dwFileVersionMS));
@@ -330,6 +335,9 @@ mono_w32process_get_fileversion (MonoObject *filever, gunichar2 *filename, MonoE
                                process_set_field_bool (filever, "ispatched", ((ffi->dwFileFlags & ffi->dwFileFlagsMask) & VS_FF_PATCHED) != 0);
                                process_set_field_bool (filever, "isprivatebuild", ((ffi->dwFileFlags & ffi->dwFileFlagsMask) & VS_FF_PRIVATEBUILD) != 0);
                                process_set_field_bool (filever, "isspecialbuild", ((ffi->dwFileFlags & ffi->dwFileFlagsMask) & VS_FF_SPECIALBUILD) != 0);
+
+                               #undef LOWORD
+                               #undef HIWORD
                        }
                        g_free (query);
 
index ea9edff0a30df111fcad50b67c5e3275e0e3984e..fa61d263cdec4a0fd96c1dad14586c4cebe47035 100644 (file)
@@ -22,7 +22,7 @@ mono_networking_init (void)
        WSADATA wsadata;
        int err;
 
-       err = WSAStartup (MAKEWORD (2,0), &wsadata);
+       err = WSAStartup (2 /* 2.0 */, &wsadata);
        if(err)
                g_error ("%s: Couldn't initialise networking", __func__);
 }