From 7cf0c877b3a5ab33f3c28a20f58f6a2cbf257a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Matellanes?= Date: Wed, 15 Oct 2014 16:46:01 +0200 Subject: [PATCH] msvcrt: Added _ftelli64_nolock implementation. --- dlls/msvcr100/msvcr100.spec | 2 +- dlls/msvcr110/msvcr110.spec | 2 +- dlls/msvcr80/msvcr80.spec | 2 +- dlls/msvcr90/msvcr90.spec | 2 +- dlls/msvcrt/file.c | 24 ++++++++++++++++-------- dlls/msvcrt/msvcrt.h | 1 + include/msvcrt/stdio.h | 1 + 7 files changed, 22 insertions(+), 12 deletions(-) diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index 406e9e74089..2425f72052a 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -850,7 +850,7 @@ @ cdecl _fstat64i32(long ptr) MSVCRT__fstat64i32 @ stub _ftell_nolock @ cdecl -ret64 _ftelli64(ptr) MSVCRT__ftelli64 -@ stub _ftelli64_nolock +@ cdecl -ret64 _ftelli64_nolock(ptr) MSVCRT__ftelli64_nolock @ cdecl _ftime32(ptr) MSVCRT__ftime32 @ cdecl _ftime32_s(ptr) MSVCRT__ftime32_s @ cdecl _ftime64(ptr) MSVCRT__ftime64 diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec index 0c62d69fd5b..9fa1ac4d5d1 100644 --- a/dlls/msvcr110/msvcr110.spec +++ b/dlls/msvcr110/msvcr110.spec @@ -1198,7 +1198,7 @@ @ cdecl _fstat64i32(long ptr) MSVCRT__fstat64i32 @ stub _ftell_nolock @ cdecl -ret64 _ftelli64(ptr) MSVCRT__ftelli64 -@ stub _ftelli64_nolock +@ cdecl -ret64 _ftelli64_nolock(ptr) MSVCRT__ftelli64_nolock @ cdecl _ftime32(ptr) MSVCRT__ftime32 @ cdecl _ftime32_s(ptr) MSVCRT__ftime32_s @ cdecl _ftime64(ptr) MSVCRT__ftime64 diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index 7123a06c9e8..334921b87c2 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -517,7 +517,7 @@ @ cdecl _fstat64i32(long ptr) MSVCRT__fstat64i32 @ stub _ftell_nolock @ cdecl -ret64 _ftelli64(ptr) MSVCRT__ftelli64 -@ stub _ftelli64_nolock +@ cdecl -ret64 _ftelli64_nolock(ptr) MSVCRT__ftelli64_nolock @ cdecl _ftime32(ptr) MSVCRT__ftime32 @ cdecl _ftime32_s(ptr) MSVCRT__ftime32_s @ cdecl _ftime64(ptr) MSVCRT__ftime64 diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index 41ce18324c3..1cbb339cd30 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -499,7 +499,7 @@ @ cdecl _fstat64i32(long ptr) MSVCRT__fstat64i32 @ stub _ftell_nolock @ cdecl -ret64 _ftelli64(ptr) MSVCRT__ftelli64 -@ stub _ftelli64_nolock +@ cdecl -ret64 _ftelli64_nolock(ptr) MSVCRT__ftelli64_nolock @ cdecl _ftime32(ptr) MSVCRT__ftime32 @ cdecl _ftime32_s(ptr) MSVCRT__ftime32_s @ cdecl _ftime64(ptr) MSVCRT__ftime64 diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 9a0effd4bbb..43f80550972 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -4226,14 +4226,25 @@ int CDECL MSVCRT_fsetpos(MSVCRT_FILE* file, MSVCRT_fpos_t *pos) */ __int64 CDECL MSVCRT__ftelli64(MSVCRT_FILE* file) { - __int64 pos; + __int64 ret; MSVCRT__lock_file(file); + ret = MSVCRT__ftelli64_nolock(file); + MSVCRT__unlock_file(file); + + return ret; +} + +/********************************************************************* + * _ftelli64_nolock (MSVCRT.@) + */ +__int64 CDECL MSVCRT__ftelli64_nolock(MSVCRT_FILE* file) +{ + __int64 pos; + pos = _telli64(file->_file); - if(pos == -1) { - MSVCRT__unlock_file(file); + if(pos == -1) return -1; - } if(file->_flag & (MSVCRT__IOMYBUF | MSVCRT__USERBUF)) { if(file->_flag & MSVCRT__IOWRT) { pos += file->_ptr - file->_base; @@ -4258,10 +4269,8 @@ __int64 CDECL MSVCRT__ftelli64(MSVCRT_FILE* file) } else { char *p; - if(MSVCRT__lseeki64(file->_file, pos, SEEK_SET) != pos) { - MSVCRT__unlock_file(file); + if(MSVCRT__lseeki64(file->_file, pos, SEEK_SET) != pos) return -1; - } pos -= file->_bufsiz; pos += file->_ptr - file->_base; @@ -4277,7 +4286,6 @@ __int64 CDECL MSVCRT__ftelli64(MSVCRT_FILE* file) } } - MSVCRT__unlock_file(file); return pos; } diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index b5cf8b7bd3f..41f36320caa 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -920,6 +920,7 @@ int __cdecl MSVCRT_ungetc(int,MSVCRT_FILE*); MSVCRT_wint_t __cdecl MSVCRT_fgetwc(MSVCRT_FILE*); MSVCRT_wint_t __cdecl MSVCRT_ungetwc(MSVCRT_wint_t,MSVCRT_FILE*); __int64 __cdecl MSVCRT__ftelli64(MSVCRT_FILE* file); +__int64 __cdecl MSVCRT__ftelli64_nolock(MSVCRT_FILE*); void __cdecl MSVCRT__exit(int); void __cdecl MSVCRT_abort(void); MSVCRT_ulong* __cdecl MSVCRT___doserrno(void); diff --git a/include/msvcrt/stdio.h b/include/msvcrt/stdio.h index 0170d2eef31..90fc3f7db60 100644 --- a/include/msvcrt/stdio.h +++ b/include/msvcrt/stdio.h @@ -130,6 +130,7 @@ int __cdecl _vsprintf_p_l(char*,size_t,const char*,_locale_t,__ms_va_list); size_t __cdecl _fread_nolock(void*,size_t,size_t,FILE*); size_t __cdecl _fwrite_nolock(const void*,size_t,size_t,FILE*); int __cdecl _fclose_nolock(FILE*); +__int64 __cdecl _ftelli64_nolock(FILE*); void __cdecl clearerr(FILE*); int __cdecl fclose(FILE*);