diff options
author | Christopher Faylor <me@cgf.cx> | 2000-02-17 19:38:33 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-02-17 19:38:33 +0000 |
commit | 1fd5e000ace55b323124c7e556a7a864b972a5c4 (patch) | |
tree | dc4fcf1e5e22a040716ef92c496b8d94959b2baa /winsup/mingw/include/varargs.h | |
parent | 369d8a8fd5e887eca547bf34bccfdf755c9e5397 (diff) | |
download | cygnal-1fd5e000ace55b323124c7e556a7a864b972a5c4.tar.gz cygnal-1fd5e000ace55b323124c7e556a7a864b972a5c4.tar.bz2 cygnal-1fd5e000ace55b323124c7e556a7a864b972a5c4.zip |
import winsup-2000-02-17 snapshot
Diffstat (limited to 'winsup/mingw/include/varargs.h')
-rw-r--r-- | winsup/mingw/include/varargs.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/winsup/mingw/include/varargs.h b/winsup/mingw/include/varargs.h new file mode 100644 index 000000000..48e203b24 --- /dev/null +++ b/winsup/mingw/include/varargs.h @@ -0,0 +1,98 @@ +/* + * varargs.h + * + * Old, non-ANSI facilities for stepping through a list of function + * arguments of an unknown number and type. + * TODO: Has not been tested. Essentially it copies the GCC version. + * + * NOTE: I believe GCC supplies a version of this header as well (in + * addition to stdarg.h and others). The GCC version is more + * complex, to deal with many alternate systems, but it is + * probably more trustworthy overall. It would probably be + * better to use the GCC version. + * + * NOTE: These are incompatible with the versions in stdarg.h and should + * NOT be mixed! All new code should use the ANSI compatible versions. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp> + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _VARARGS_H_ +#define _VARARGS_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * I was told that Win NT likes this. + */ +#ifndef _VA_LIST_DEFINED +#define _VA_LIST_DEFINED +#endif + +#ifndef RC_INVOKED + +#ifndef _VA_LIST +#define _VA_LIST +typedef char* va_list; +#endif + +/* + * Amount of space required in an argument list (ie. the stack) for an + * argument of type t. + */ +#define __va_argsiz(t) \ + (((sizeof(t) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) + +#define va_alist __builtin_va_alist + +/* + * Used in old style argument lists IIRC. The ellipsis forces the compiler + * to realize this is a vararg function. + */ +#define va_dcl int __builtin_va_alist; ... + +#define va_start(ap) \ + ((ap) = ((va_list) &__builtin_va_alist)) +#define va_end(ap) ((void)0) + + +/* + * Increment ap to the next argument in the list while returing a + * pointer to what ap pointed to first, which is of type t. + * + * We cast to void* and then to t* because this avoids a warning about + * increasing the alignment requirement. + */ + +#define va_arg(ap, t) \ + (((ap) = (ap) + __va_argsiz(t)), \ + *((t*) (void*) ((ap) - __va_argsiz(t)))) + + +#endif /* Not RC_INVOKED */ + +#endif /* Not _VARARGS_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + |