Merge pull request #3678 from mono/seq-read
authorRodrigo Kumpera <kumpera@users.noreply.github.com>
Wed, 16 Nov 2016 18:15:41 +0000 (10:15 -0800)
committerGitHub <noreply@github.com>
Wed, 16 Nov 2016 18:15:41 +0000 (10:15 -0800)
[IO] Implement FileOptions.SequentialScan for Mac/BSD

1  2 
mono/io-layer/io.c

diff --combined mono/io-layer/io.c
index c0f25fcd98a69d89a4ab5d7aea386caadc62481c,7efbfde591785b65ce45b968411813db261d0018..70a374557dd3a9a16f32956790699accd6efdfb7
  #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-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>
  #include <mono/utils/mono-once.h>
  #include <mono/utils/mono-logger-internals.h>
 -#include <mono/utils/w32handle.h>
 +#include <mono/metadata/w32handle.h>
  
  /*
   * If SHM is disabled, this will point to a hash of _WapiFileShare structures, otherwise
@@@ -1764,7 -1764,12 +1764,12 @@@ gpointer CreateFile(const gunichar2 *na
        if (attrs & FILE_FLAG_RANDOM_ACCESS)
                posix_fadvise (fd, 0, 0, POSIX_FADV_RANDOM);
  #endif
-       
+ #ifdef F_RDAHEAD
+       if (attrs & FILE_FLAG_SEQUENTIAL_SCAN)
+               fcntl(fd, F_RDAHEAD, 1);
+ #endif
  #ifndef S_ISFIFO
  #define S_ISFIFO(m) ((m & S_IFIFO) != 0)
  #endif
@@@ -2913,6 -2918,7 +2918,6 @@@ gboolean FindNextFile (gpointer handle
        gunichar2 *utf16_basename;
        time_t create_time;
        glong bytes;
 -      int thr_ret;
        gboolean ret = FALSE;
        
        ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FIND,
                return(FALSE);
        }
  
 -      thr_ret = mono_w32handle_lock_handle (handle);
 -      g_assert (thr_ret == 0);
 +      mono_w32handle_lock_handle (handle);
        
  retry:
        if (find_handle->count >= find_handle->num) {
        g_free (utf16_basename);
  
  cleanup:
 -      thr_ret = mono_w32handle_unlock_handle (handle);
 -      g_assert (thr_ret == 0);
 +      mono_w32handle_unlock_handle (handle);
        
        return(ret);
  }
@@@ -3047,6 -3055,7 +3052,6 @@@ gboolean FindClose (gpointer handle
  {
        struct _WapiHandle_find *find_handle;
        gboolean ok;
 -      int thr_ret;
  
        if (handle == NULL) {
                SetLastError (ERROR_INVALID_HANDLE);
                return(FALSE);
        }
  
 -      thr_ret = mono_w32handle_lock_handle (handle);
 -      g_assert (thr_ret == 0);
 +      mono_w32handle_lock_handle (handle);
        
        g_strfreev (find_handle->namelist);
        g_free (find_handle->dir_part);
  
 -      thr_ret = mono_w32handle_unlock_handle (handle);
 -      g_assert (thr_ret == 0);
 +      mono_w32handle_unlock_handle (handle);
        
        mono_w32handle_unref (handle);