X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=includes%2Fstdarg.h;h=1ebf3fba289823ce3da1f37cad3e0b130ce835ee;hp=62d0e404e36dbc80d1e0fdfb51e6f7edc04836ff;hb=da0f3f353d417fed71f358a48d5d5394145e460d;hpb=1d9d92ba957a0b8307c9a65c35867fde68e6533b diff --git a/includes/stdarg.h b/includes/stdarg.h index 62d0e40..1ebf3fb 100644 --- a/includes/stdarg.h +++ b/includes/stdarg.h @@ -1,80 +1,27 @@ -/* ---------------------------------------------------------------------------- - * $Id$ - * ---------------------------------------------------------------------------- - * Public Domain C Library - http://pdclib.sourceforge.net - * This code is Public Domain. Use, modify, and redistribute at will. - * ---------------------------------------------------------------------------- - * Variable arguments - * ---------------------------------------------------------------------------- - * This header is part of a freestanding implementation - * --------------------------------------------------------------------------*/ +/* Variable arguments -#ifndef _STDARG_H -#define _STDARG_H _STDARG_H + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ -/* TODO: This code was contributed by Michael Moody, who added: - * "As always with my code it's not guaranteed bug-free (In fact I know for a - * fact it won't work properly on certain archs)." - * Code assumes that: - * - arguments are passed on the stack; - * - arguments are alligned to pointer size. - */ +#ifndef _PDCLIB_STDARG_H +#define _PDCLIB_STDARG_H _PDCLIB_STDARG_H +#include "_PDCLIB_aux.h" +#include "_PDCLIB_config.h" -/* ---------------------------------------------------------------------------- - * TYPEDEFS - * --------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" { +#endif -typedef char * va_list; +typedef _PDCLIB_va_list va_list; -/* ---------------------------------------------------------------------------- - * MACROS - * --------------------------------------------------------------------------*/ +#define va_arg( ap, type ) _PDCLIB_va_arg( ap, type ) +#define va_copy( dest, src ) _PDCLIB_va_copy( dest, src ) +#define va_end( ap ) _PDCLIB_va_end( ap ) +#define va_start( ap, parmN ) _PDCLIB_va_start( ap, parmN ) -/** Returns the size of 'type' rounded up to the nearest multiple of the size - * of a pointer. This macro is just here for clarity. - */ -#define __va_round(type) \ - ( \ - (sizeof(type) + sizeof(void *) - 1) & ~(sizeof(void *) - 1) \ - ) +#ifdef __cplusplus +} +#endif -/** Initialises ap for use by va_arg by setting ap to point at the first - * argument in the ellipsis. parmN is the last known parameter in the function - * definition (ie the one before the ellipsis). - */ -#define va_start(ap, parmN) \ - ( \ - (ap) = (char *)&parmN + (__va_round(parmN)) \ - , \ - (void)0 \ - ) - -/** Returns the next argument, assumed variable type is 'type', in the - * ellipsis. - */ -#define va_arg(ap, type) \ - ( \ - (ap) += (__va_round(type)) \ - , \ - (*(type*)((ap) - (__va_round(type)))) \ - ) - -/** Cleans up ap. - */ -#define va_end(ap) \ - ( \ - (ap) = (void *)0 \ - , \ - (void)0 \ - ) - -/** Makes the va_list dest be a copy of the va_list src. - */ -#define va_copy(dest, src) \ - ( \ - (dest) = (src) \ - , \ - (void)0 \ - ) - -#endif /* _STDARG_H */ +#endif