Merge 34717 from ros-amd64-bringup branch:

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

svn path=/trunk/; revision=35695
This commit is contained in:
Timo Kreuzer 2008-08-27 03:59:24 +00:00
parent 9a1009363b
commit 57164f6854
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, * _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. * 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 intptr_t __cdecl __MINGW_NOTHROW _findfirst (const char*, struct _finddata_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW _findnext (long, struct _finddata_t*); _CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findnext (intptr_t, struct _finddata_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW _findclose (long); _CRTIMP int __cdecl __MINGW_NOTHROW _findclose (intptr_t);
_CRTIMP int __cdecl __MINGW_NOTHROW _chdir (const char*); _CRTIMP int __cdecl __MINGW_NOTHROW _chdir (const char*);
_CRTIMP char* __cdecl __MINGW_NOTHROW _getcwd (char*, int); _CRTIMP char* __cdecl __MINGW_NOTHROW _getcwd (char*, int);
@ -143,8 +143,8 @@ _CRTIMP int __cdecl __MINGW_NOTHROW _chmod (const char*, int);
#ifdef __MSVCRT__ #ifdef __MSVCRT__
_CRTIMP __int64 __cdecl __MINGW_NOTHROW _filelengthi64(int); _CRTIMP __int64 __cdecl __MINGW_NOTHROW _filelengthi64(int);
_CRTIMP long __cdecl __MINGW_NOTHROW _findfirsti64(const char*, struct _finddatai64_t*); _CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findfirsti64(const char*, struct _finddatai64_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW _findnexti64(long, 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 _lseeki64(int, __int64, int);
_CRTIMP __int64 __cdecl __MINGW_NOTHROW _telli64(int); _CRTIMP __int64 __cdecl __MINGW_NOTHROW _telli64(int);
/* These require newer versions of msvcrt.dll (6.1 or higher). */ /* 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 _waccess(const wchar_t*, int);
_CRTIMP int __cdecl __MINGW_NOTHROW _wchmod(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 int __cdecl __MINGW_NOTHROW _wcreat(const wchar_t*, int);
_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirst(const wchar_t*, struct _wfinddata_t*); _CRTIMP intptr_t __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 _wfindnext(intptr_t, struct _wfinddata_t *);
_CRTIMP int __cdecl __MINGW_NOTHROW _wunlink(const wchar_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 _wopen(const wchar_t*, int, ...);
_CRTIMP int __cdecl __MINGW_NOTHROW _wsopen(const wchar_t*, int, int, ...); _CRTIMP int __cdecl __MINGW_NOTHROW _wsopen(const wchar_t*, int, int, ...);
_CRTIMP wchar_t * __cdecl __MINGW_NOTHROW _wmktemp(wchar_t*); _CRTIMP wchar_t * __cdecl __MINGW_NOTHROW _wmktemp(wchar_t*);
_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*); _CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW _wfindnexti64(long, struct _wfinddatai64_t*); _CRTIMP int __cdecl __MINGW_NOTHROW _wfindnexti64(intptr_t, struct _wfinddatai64_t*);
#if __MSVCRT_VERSION__ >= 0x0601 #if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindfirst64(const wchar_t*, struct __wfinddata64_t*); _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*); _CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindnext64(intptr_t, struct __wfinddata64_t*);

View file

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

View file

@ -13,6 +13,7 @@
/* Needed for the atexit prototype. */ /* Needed for the atexit prototype. */
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h>
typedef void (*func_ptr) (void); typedef void (*func_ptr) (void);
extern func_ptr __CTOR_LIST__[]; extern func_ptr __CTOR_LIST__[];
@ -37,8 +38,8 @@ __do_global_dtors (void)
void void
__do_global_ctors (void) __do_global_ctors (void)
{ {
unsigned long nptrs = (unsigned long) __CTOR_LIST__[0]; unsigned long nptrs = (unsigned long) (ptrdiff_t) __CTOR_LIST__[0];
unsigned i; unsigned long i;
/* /*
* If the first entry in the constructor list is -1 then the list * If the first entry in the constructor list is -1 then the list
@ -47,8 +48,7 @@ __do_global_ctors (void)
*/ */
if (nptrs == -1) 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 static void
do_pseudo_reloc (void* start, void* end, void* base) do_pseudo_reloc (void* start, void* end, void* base)
{ {
DWORD reloc_target; ptrdiff_t reloc_target;
runtime_pseudo_reloc* r; runtime_pseudo_reloc* r;
for (r = (runtime_pseudo_reloc*) start; r < (runtime_pseudo_reloc*) end; r++) for (r = (runtime_pseudo_reloc*) start; r < (runtime_pseudo_reloc*) end; r++)
{ {
reloc_target = (DWORD) base + r->target; reloc_target = (ptrdiff_t) base + r->target;
*((DWORD*) reloc_target) += r->addend; *((ptrdiff_t*) reloc_target) += r->addend;
} }
} }

View file

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

View file

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

View file

@ -1,11 +1,11 @@
#include <search.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <search.h>
/* /*
* @implemented * @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 *)) int (*compar)(const void *, const void *))
{ {
void *ret_find = _lfind(key,base,nelp,width,compar); 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; return base;
} }

View file

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