-- v3: msvcrt: Return proper errno for _aligned_msize
From: Bartosz Kosiorek gang65@poczta.onet.pl
--- dlls/msvcr100/tests/msvcr100.c | 22 +++++++++++++++++++++- dlls/msvcrt/file.c | 30 +++++++++++++++--------------- dlls/msvcrt/heap.c | 9 ++++++--- tools/make_specfiles | 13 +++++++++++++ 4 files changed, 55 insertions(+), 19 deletions(-)
diff --git a/dlls/msvcr100/tests/msvcr100.c b/dlls/msvcr100/tests/msvcr100.c index 7bde5c7935d..090d64589cc 100644 --- a/dlls/msvcr100/tests/msvcr100.c +++ b/dlls/msvcr100/tests/msvcr100.c @@ -175,6 +175,7 @@ struct SchedulerVtbl { };
static int* (__cdecl *p_errno)(void); +static int (__cdecl *p_get_errno)(int *); static int (__cdecl *p_wmemcpy_s)(wchar_t *dest, size_t numberOfElements, const wchar_t *src, size_t count); static int (__cdecl *p_wmemmove_s)(wchar_t *dest, size_t numberOfElements, const wchar_t *src, size_t count); static FILE* (__cdecl *p_fopen)(const char*,const char*); @@ -259,6 +260,7 @@ static BOOL init(void) }
SET(p_errno, "_errno"); + SET(p_get_errno, "_get_errno"); SET(p_set_invalid_parameter_handler, "_set_invalid_parameter_handler"); SET(p_wmemcpy_s, "wmemcpy_s"); SET(p_wmemmove_s, "wmemmove_s"); @@ -640,6 +642,13 @@ static void test__aligned_msize(void) { void *mem; int ret; + errno_t err; + + ret = p__aligned_msize(NULL, 16, 7); + ok(ret == -1, "_aligned_msize returned %d\n", ret); + ret = p_get_errno(&err); + ok(ret == 0, "Expected _get_errno to return 0, got %d\n", ret); + ok(err == EINVAL, "Expected output variable to be EINVAL, got %d\n", err);
mem = p__aligned_offset_malloc(23, 16, 7); ret = p__aligned_msize(mem, 16, 7); @@ -650,8 +659,19 @@ static void test__aligned_msize(void) ok(ret == 28, "_aligned_msize returned %d\n", ret); ret = p__aligned_msize(mem, 1, 7); ok(ret == 39-sizeof(void*), "_aligned_msize returned %d\n", ret); + + /* Test different Offset values */ + ret = p__aligned_msize(mem, 8, 14); + ok(ret == 32, "_aligned_msize returned %d\n", ret); + ret = p__aligned_msize(mem, 8, 8); + ok(ret == 32, "_aligned_msize returned %d\n", ret); + ret = p__aligned_msize(mem, 8, 7); // 31 + ok(ret == 32, "_aligned_msize returned %d\n", ret); // 31 + ret = p__aligned_msize(mem, 8, 5); + ok(ret == 32, "_aligned_msize returned %d\n", ret); ret = p__aligned_msize(mem, 8, 0); - todo_wine ok(ret == 32, "_aligned_msize returned %d\n", ret); + ok(ret == 32, "_aligned_msize returned %d\n", ret); + p__aligned_free(mem);
mem = p__aligned_offset_malloc(3, 16, 0); diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 58a607e3bbe..e355ec8537d 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -1126,7 +1126,7 @@ static int msvcrt_flush_all_buffers(int mask) if (file->_flag) { if(file->_flag & mask) { - fflush(file); + fflush(file); num_flushed++; } } @@ -3160,7 +3160,7 @@ int CDECL _stat64(const char* path, struct _stat64 * buf) /* FIXME: rdev isn't drive num, despite what the docs say-what is it? Bon 011120: This FIXME seems incorrect Also a letter as first char isn't enough to be classified - as a drive letter + as a drive letter */ if (isalpha(*path)&& (*(path+1)==':')) buf->st_dev = buf->st_rdev = _toupper_l(*path, NULL) - 'A'; /* drive num */ @@ -3906,7 +3906,7 @@ char * CDECL fgets(char *s, int size, FILE* file) char * buf_start = s;
TRACE(":file(%p) fd (%d) str (%p) len (%d)\n", - file,file->_file,s,size); + file, file->_file, s, size);
_lock_file(file);
@@ -4430,22 +4430,22 @@ size_t CDECL _fread_nolock(void *ptr, size_t size, size_t nmemb, FILE* file) size_t pread=0;
if(!rcnt) - return 0; + return 0;
/* first buffered data */ if(file->_cnt>0) { - int pcnt= (rcnt>file->_cnt)? file->_cnt:rcnt; - memcpy(ptr, file->_ptr, pcnt); - file->_cnt -= pcnt; - file->_ptr += pcnt; - read += pcnt ; - rcnt -= pcnt ; - ptr = (char*)ptr + pcnt; + int pcnt= (rcnt>file->_cnt)? file->_cnt:rcnt; + memcpy(ptr, file->_ptr, pcnt); + file->_cnt -= pcnt; + file->_ptr += pcnt; + read += pcnt ; + rcnt -= pcnt ; + ptr = (char*)ptr + pcnt; } else if(!(file->_flag & _IOREAD )) { - if(file->_flag & _IORW) { - file->_flag |= _IOREAD; - } else { - return 0; + if(file->_flag & _IORW) { + file->_flag |= _IOREAD; + } else { + return 0; } }
diff --git a/dlls/msvcrt/heap.c b/dlls/msvcrt/heap.c index bf06c37e2c5..e38ade7f557 100644 --- a/dlls/msvcrt/heap.c +++ b/dlls/msvcrt/heap.c @@ -48,7 +48,7 @@ typedef int (CDECL *MSVCRT_new_handler_func)(size_t size); static MSVCRT_new_handler_func MSVCRT_new_handler; static LONG MSVCRT_new_mode;
-/* FIXME - According to documentation it should be 8*1024, at runtime it returns 16 */ +/* FIXME - According to documentation it should be 8*1024, at runtime it returns 16 */ static unsigned int MSVCRT_amblksiz = 16; /* FIXME - According to documentation it should be 480 bytes, at runtime default is 0 */ static size_t MSVCRT_sbh_threshold = 0; @@ -370,13 +370,16 @@ size_t CDECL _aligned_msize(void *p, size_t alignment, size_t offset) { void **alloc_ptr;
- if(!MSVCRT_CHECK_PMT(p)) return -1; + if(!MSVCRT_CHECK_PMT(p)) + return -1;
if(alignment < sizeof(void*)) alignment = sizeof(void*);
alloc_ptr = SAVED_PTR(p); - return _msize(*alloc_ptr)-alignment-sizeof(void*); + // return _msize(*alloc_ptr) + (offset & 7) - alignment - sizeof(void*); + // memblock = ALIGN_PTR(temp, alignment, offset); + return _msize(*alloc_ptr) - alignment - sizeof(void*); } #endif
diff --git a/tools/make_specfiles b/tools/make_specfiles index 3c4c40544b8..7016d8e388b 100755 --- a/tools/make_specfiles +++ b/tools/make_specfiles @@ -31,6 +31,13 @@ my @dll_groups = "msvcirt", "msvcrt40", "msvcrt20", + "msvcr70", + "msvcr71", + "msvcr80", + "msvcr90", + "msvcr100", + "msvcr110", + "msvcr120", ], [ "msvcrt", @@ -45,6 +52,12 @@ my @dll_groups = "msvcp60", ], [ + "msvcr70", + "msvcr71", + "msvcr80", + "msvcr90", + "msvcr100", + "msvcr110", "msvcr120", "msvcr120_app", "concrt140",
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=139382
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w7u_adm (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w7u_el (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w8 (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w8adm (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w864 (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w10pro64 (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w10pro64_en_AE_u8 (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w11pro64 (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w864 (64 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w10pro64 (64 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w10pro64_ar (64 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w10pro64_ja (64 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w10pro64_zh_CN (64 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w11pro64_amd (64 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== debian11 (32 bit report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11 (32 bit ar:MA report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11 (32 bit de report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11 (32 bit fr report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11 (32 bit he:IL report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11 (32 bit hi:IN report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11 (32 bit ja:JP report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11 (32 bit zh:CN report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11b (32 bit WoW report) ===
msvcr100: Unhandled exception: 0xc0000417 in wow64 32-bit code (0x76fb2207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11b (64 bit WoW report) ===
msvcr100: Unhandled exception: 0xc0000417 in 64-bit code (0x006fffff483a77). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31