- Implement _onexit.

- Port __dllonexit from Wine.
- Fix vsscanf stream initialization.

svn path=/trunk/; revision=12364
This commit is contained in:
Filip Navara 2004-12-27 16:43:49 +00:00
parent 691f45eb54
commit 5848acdc90
4 changed files with 46 additions and 27 deletions

View file

@ -18,22 +18,3 @@ void _initterm(void (*fStart[])(void), void (*fEnd[])(void))
i++;
}
}
typedef int (* _onexit_t)(void);
/*
* @unimplemented
*/
_onexit_t __dllonexit(_onexit_t func, void (** fStart[])(void), void (** fEnd[])(void))
{
return 0;
}
/*
* @unimplemented
*/
_onexit_t _onexit(_onexit_t x)
{
return x;
}

View file

@ -13,7 +13,7 @@ vsprintf(char *str, const char *fmt, va_list ap)
FILE f;
int len;
f._flag = _IOWRT|_IOSTRG|_IOBINARY;;
f._flag = _IOWRT|_IOSTRG|_IOBINARY;
f._ptr = str;
f._cnt = INT_MAX;
f._file = -1;

View file

@ -39,7 +39,7 @@ int __vsscanf(const char *s,const char *format,va_list arg)
memset((void *) &f, 0, sizeof (f));
f._flag = _IOREAD;
f._flag = _IOREAD|_IOSTRG|_IOBINARY;
f._ptr = (char *)s;
f._base = (char *)s;
f._bufsiz = strlen(s);

View file

@ -2,20 +2,58 @@
#include <msvcrt/stdlib.h>
#include <msvcrt/internal/atexit.h>
typedef int (* _onexit_t)(void);
/*
* @implemented
*
* Ported from WINE
* Copyright (C) 2000 Jon Griffiths
*/
_onexit_t __dllonexit(_onexit_t func, _onexit_t **start, _onexit_t **end)
{
_onexit_t *tmp;
int len;
if (!start || !*start || !end || !*end)
return NULL;
len = (*end - *start);
if (++len <= 0)
return NULL;
tmp = (_onexit_t *)realloc(*start, len * sizeof(tmp));
if (!tmp)
return NULL;
*start = tmp;
*end = tmp + len;
tmp[len - 1] = func;
return func;
}
/*
* @implemented
*/
int
atexit(void (*a)(void))
_onexit_t _onexit(_onexit_t a)
{
struct __atexit *ap;
if (a == 0)
return -1;
return NULL;
ap = (struct __atexit *)malloc(sizeof(struct __atexit));
if (!ap)
return -1;
return NULL;
ap->__next = __atexit_ptr;
ap->__function = a;
ap->__function = (void (*)(void))a;
__atexit_ptr = ap;
return 0;
return a;
}
/*
* @implemented
*/
int atexit(void (*a)(void))
{
return _onexit((_onexit_t)a) == (_onexit_t)a ? 0 : -1;
}