Patch from Samuel Serapion ("encoded", samdwise51 at gmail dot com):

- fix prototypes of _findfirst, _findnext, _findclose, _findfirsti64, _findnexti64 _wfindfirst, _wfindnext, _wfindfirst64, _wfindnext64, strndup, 
- fix a number of pointer to int casts

svn path=/branches/ros-amd64-bringup/; revision=34717
This commit is contained in:
Timo Kreuzer 2008-07-24 00:20:01 +00:00
parent 31e3f10a45
commit 8a9b9256be
8 changed files with 42 additions and 58 deletions

View file

@ -129,10 +129,10 @@ extern "C" {
* _findclose calls. _findnext also returns -1 if no match could be found,
* and 0 if a match was found. Call _findclose when you are finished.
*/
/* FIXME: Should these all use intptr_t, as per recent MSDN docs? */
_CRTIMP long __cdecl __MINGW_NOTHROW _findfirst (const char*, struct _finddata_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW _findnext (long, struct _finddata_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW _findclose (long);
_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findfirst (const char*, struct _finddata_t*);
_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findnext (intptr_t, struct _finddata_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW _findclose (intptr_t);
_CRTIMP int __cdecl __MINGW_NOTHROW _chdir (const char*);
_CRTIMP char* __cdecl __MINGW_NOTHROW _getcwd (char*, int);
@ -143,8 +143,8 @@ _CRTIMP int __cdecl __MINGW_NOTHROW _chmod (const char*, int);
#ifdef __MSVCRT__
_CRTIMP __int64 __cdecl __MINGW_NOTHROW _filelengthi64(int);
_CRTIMP long __cdecl __MINGW_NOTHROW _findfirsti64(const char*, struct _finddatai64_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW _findnexti64(long, struct _finddatai64_t*);
_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findfirsti64(const char*, struct _finddatai64_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW _findnexti64(intptr_t, struct _finddatai64_t*);
_CRTIMP __int64 __cdecl __MINGW_NOTHROW _lseeki64(int, __int64, int);
_CRTIMP __int64 __cdecl __MINGW_NOTHROW _telli64(int);
/* These require newer versions of msvcrt.dll (6.1 or higher). */
@ -259,14 +259,14 @@ _CRTIMP int __cdecl __MINGW_NOTHROW _write (int, const void*, unsigned int);
_CRTIMP int __cdecl __MINGW_NOTHROW _waccess(const wchar_t*, int);
_CRTIMP int __cdecl __MINGW_NOTHROW _wchmod(const wchar_t*, int);
_CRTIMP int __cdecl __MINGW_NOTHROW _wcreat(const wchar_t*, int);
_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirst(const wchar_t*, struct _wfinddata_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW _wfindnext(long, struct _wfinddata_t *);
_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindfirst(const wchar_t*, struct _wfinddata_t*);
_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindnext(intptr_t, struct _wfinddata_t *);
_CRTIMP int __cdecl __MINGW_NOTHROW _wunlink(const wchar_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW _wopen(const wchar_t*, int, ...);
_CRTIMP int __cdecl __MINGW_NOTHROW _wsopen(const wchar_t*, int, int, ...);
_CRTIMP wchar_t * __cdecl __MINGW_NOTHROW _wmktemp(wchar_t*);
_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW _wfindnexti64(long, struct _wfinddatai64_t*);
_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW _wfindnexti64(intptr_t, struct _wfinddatai64_t*);
#if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindfirst64(const wchar_t*, struct __wfinddata64_t*);
_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindnext64(intptr_t, struct __wfinddata64_t*);

View file

@ -23,6 +23,7 @@
#include <stdarg.h>
#include <sys/types.h>
#include <stdint.h>
#include <windef.h>
#include <winbase.h>
@ -131,9 +132,9 @@ WINE_LDT_EXTERN struct __wine_ldt_copy
/* helper functions to manipulate the LDT_ENTRY structure */
inline static void wine_ldt_set_base( LDT_ENTRY *ent, const void *base )
{
ent->BaseLow = (WORD)(unsigned long)base;
ent->HighWord.Bits.BaseMid = (BYTE)((unsigned long)base >> 16);
ent->HighWord.Bits.BaseHi = (BYTE)((unsigned long)base >> 24);
ent->BaseLow = (WORD)(intptr_t)base;
ent->HighWord.Bits.BaseMid = (BYTE)((intptr_t)base >> 16);
ent->HighWord.Bits.BaseHi = (BYTE)((intptr_t)base >> 24);
}
inline static void wine_ldt_set_limit( LDT_ENTRY *ent, unsigned int limit )
{
@ -144,8 +145,8 @@ inline static void wine_ldt_set_limit( LDT_ENTRY *ent, unsigned int limit )
inline static void *wine_ldt_get_base( const LDT_ENTRY *ent )
{
return (void *)(ent->BaseLow |
(unsigned long)ent->HighWord.Bits.BaseMid << 16 |
(unsigned long)ent->HighWord.Bits.BaseHi << 24);
(intptr_t)ent->HighWord.Bits.BaseMid << 16 |
(intptr_t)ent->HighWord.Bits.BaseHi << 24);
}
inline static unsigned int wine_ldt_get_limit( const LDT_ENTRY *ent )
{

View file

@ -13,6 +13,7 @@
/* Needed for the atexit prototype. */
#include <stdlib.h>
#include <stddef.h>
typedef void (*func_ptr) (void);
extern func_ptr __CTOR_LIST__[];
@ -37,8 +38,8 @@ __do_global_dtors (void)
void
__do_global_ctors (void)
{
unsigned long nptrs = (unsigned long) __CTOR_LIST__[0];
unsigned i;
unsigned long nptrs = (unsigned long) (ptrdiff_t) __CTOR_LIST__[0];
unsigned long i;
/*
* If the first entry in the constructor list is -1 then the list
@ -47,8 +48,7 @@ __do_global_ctors (void)
*/
if (nptrs == -1)
{
for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++)
;
for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++);
}
/*
@ -77,3 +77,4 @@ __main (void)
}
}

View file

@ -28,12 +28,12 @@ runtime_pseudo_reloc;
static void
do_pseudo_reloc (void* start, void* end, void* base)
{
DWORD reloc_target;
ptrdiff_t reloc_target;
runtime_pseudo_reloc* r;
for (r = (runtime_pseudo_reloc*) start; r < (runtime_pseudo_reloc*) end; r++)
{
reloc_target = (DWORD) base + r->target;
*((DWORD*) reloc_target) += r->addend;
reloc_target = (ptrdiff_t) base + r->target;
*((ptrdiff_t*) reloc_target) += r->addend;
}
}

View file

@ -24,7 +24,7 @@ extern wchar_t **__winitenv;
extern HANDLE hHeap;
char* strndup(char* name, int len)
char* strndup(char* name, size_t len)
{
char *s = malloc(len + 1);
if (s != NULL)
@ -35,7 +35,7 @@ char* strndup(char* name, int len)
return s;
}
wchar_t* wcsndup(wchar_t* name, int len)
wchar_t* wcsndup(wchar_t* name, size_t len)
{
wchar_t *s = malloc((len + 1) * sizeof(wchar_t));
if (s != NULL)
@ -362,3 +362,4 @@ wchar_t*** __p___wargv(void)
return &__wargv;
}

View file

@ -1,12 +1,11 @@
#include <search.h>
#include <stdlib.h>
#include <search.h>
/*
* @implemented
*/
void *_lfind(const void *key, const void *base, size_t *nelp,
size_t width, int (*compar)(const void *, const void *))
void *_lfind(const void *key, const void *base, unsigned int *nelp,
unsigned int width, int (*compar)(const void *, const void *))
{
char* char_base = (char*)base;
unsigned int i;
@ -19,3 +18,4 @@ void *_lfind(const void *key, const void *base, size_t *nelp,
return NULL;
}

View file

@ -1,11 +1,11 @@
#include <search.h>
#include <stdlib.h>
#include <string.h>
#include <search.h>
/*
* @implemented
*/
void *_lsearch(const void *key, void *base, size_t *nelp, size_t width,
void *_lsearch(const void *key, void *base, unsigned int *nelp, unsigned int width,
int (*compar)(const void *, const void *))
{
void *ret_find = _lfind(key,base,nelp,width,compar);
@ -19,3 +19,4 @@ void *_lsearch(const void *key, void *base, size_t *nelp, size_t width,
return base;
}

View file

@ -4,17 +4,13 @@
/*
* @implemented
*/
#if defined(_UNICODE) || !(__MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3)
long
#else
int
#endif
intptr_t
_tfindfirst(const _TCHAR* _name, struct _tfinddata_t* result)
{
WIN32_FIND_DATA FindFileData;
long hFindFile;
hFindFile = (long)FindFirstFile(_name, &FindFileData);
hFindFile = (intptr_t)FindFirstFile(_name, &FindFileData);
if (hFindFile == -1) {
_dosmaperr(GetLastError());
return -1;
@ -33,13 +29,7 @@ _tfindfirst(const _TCHAR* _name, struct _tfinddata_t* result)
/*
* @implemented
*/
int _tfindnext(
#if defined(_UNICODE) || !(__MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3)
long handle,
#else
int handle,
#endif
struct _tfinddata_t* result)
intptr_t _tfindnext(intptr_t handle, struct _tfinddata_t* result)
{
WIN32_FIND_DATA FindFileData;
@ -62,12 +52,12 @@ int _tfindnext(
/*
* @implemented
*/
long _tfindfirsti64(const _TCHAR *_name, struct _tfinddatai64_t *result)
intptr_t _tfindfirsti64(const _TCHAR *_name, struct _tfinddatai64_t *result)
{
WIN32_FIND_DATA FindFileData;
long hFindFile;
hFindFile = (long)FindFirstFile(_name, &FindFileData);
hFindFile = (intptr_t)FindFirstFile(_name, &FindFileData);
if (hFindFile == -1)
{
_dosmaperr(GetLastError());
@ -85,14 +75,10 @@ long _tfindfirsti64(const _TCHAR *_name, struct _tfinddatai64_t *result)
return hFindFile;
}
//_CRTIMP long __cdecl _findfirsti64(const char*, struct _finddatai64_t*);
//_CRTIMP int __cdecl _findnexti64(long, struct _finddatai64_t*);
/*
* @implemented
*/
int _tfindnexti64(long handle, struct _tfinddatai64_t *result)
int _tfindnexti64(intptr_t handle, struct _tfinddatai64_t *result)
{
WIN32_FIND_DATA FindFileData;
@ -119,15 +105,9 @@ int _tfindnexti64(long handle, struct _tfinddatai64_t *result)
/*
* @implemented
*/
int _findclose(
#if __MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3
int handle
#else
long handle
#endif
)
int _findclose(intptr_t handle)
{
if (!FindClose((void*)handle)) {
if (!FindClose((HANDLE)handle)) {
_dosmaperr(GetLastError());
return -1;
}