root / Whitix / branches / network / include / stdarg.h

Revision 1, 1.4 kB (checked in by mtw07, 11 months ago)

Initial import of projects.

Line 
1/*  This file is part of Whitix.
2 *
3 *  Whitix is free software; you can redistribute it and/or modify
4 *  it under the terms of the GNU General Public License as published by
5 *  the Free Software Foundation; either version 2 of the License, or
6 *  (at your option) any later version.
7 *
8 *  Whitix is distributed in the hope that it will be useful,
9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 *  GNU General Public License for more details.
12 *
13 *  You should have received a copy of the GNU General Public License
14 *  along with Whitix; if not, write to the Free Software
15 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
16 *
17 */
18
19#ifndef STDARG_H
20#define STDARG_H
21
22typedef unsigned char* va_list;
23
24/* Just get the memory location after the last argument */
25#define va_start(list,lastArg) \
26        (list=((va_list)&(lastArg)+va_size(lastArg)));
27
28/* Must be the other way round because of the comma operator */
29#define va_arg(list,type) \
30        (list+=__va_rounded_size(type), \
31        *((type*)(list-__va_rounded_size(type))))
32
33/* Stacks are int-aligned */
34#define __va_rounded_size(type) \
35        (((sizeof(type)+sizeof(int)-1)/sizeof(int))*sizeof(int))
36
37#define va_size(type) \
38        ((sizeof(type)+sizeof(int)-1) \
39        & ~(sizeof(int)-1))
40
41/* Just for a certain cleanliness */
42#define va_end(list)
43
44#endif
Note: See TracBrowser for help on using the browser.