aboutsummaryrefslogtreecommitdiffstats
path: root/include/stdarg.h
blob: 0f6306d6b120a46b920549bfb69062abbf25f857 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/**
 * slibc — Yet another C library
 * Copyright © 2015  Mattias Andrée (maandree@member.fsf.org)
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef _STDARG_H
# ifndef __ONLY_va_list
#  define _STDARG_H
# endif
#include <slibc/version.h>
#include <slibc/features.h>

#if !defined(_SLIBC_SUPPRESS_WARNINGS)
# if !defined(__C89__)
#  warning "<stdargs.h> requires that C89 or newer revision is used."
# elif !defined(__C99__)
#  warning "'va_copy' was introduced to <stdargs.h> in C99."
# endif
#endif


#include <bits/stdarg.h>


/* If <bits/stdarg.h> does not define what is required,
 * fall back to compiler-builtin definitions. */



/**
 * State of variadic argument-reading.
 * 
 * @etymology  (V)ariadic (a)rguments-subsystem: argument-(list).
 * 
 * @since  Always.
 */
#ifndef __DEFINED_va_list
# define __DEFINED_va_list
typedef __builtin_va_list va_list;
#endif



#ifndef __ONLY_va_list



/**
 * Prologue to using a variadic arguments.
 * 
 * @etymology  (V)ariadic (a)rguments-subsystem: (start) of use.
 * 
 * @param  state:va_list    The state of the variadic argument-reading.
 * @param  last:identifier  The the last non-variadic argument.
 * 
 * @since  Always.
 */
#ifndef va_start
# ifndef __PORTABLE
#  define va_start(state, last)  __builtin_va_start(state, last)
# else
#  define va_start(state, last)  { __builtin_va_start(state, last)
# endif
#endif

/**
 * Epilogue to using a variadic arguments.
 * 
 * @etymology  (V)ariadic (a)rguments-subsystem: (end) of use.
 * 
 * @param  state:va_list  The state of the variadic argument-reading.
 * 
 * @since  Always.
 */
#ifndef va_end
# ifndef __PORTABLE
#  define va_end(state)  __builtin_va_end(state)
# else
#  define va_end(state)  } __builtin_va_end(state)
# endif
#endif

/**
 * Get the next variadic argument.
 * 
 * @etymology  (V)ariadic (a)rguments-subsystem: get (arg)ument.
 * 
 * @param   state:va_list    The state of the variadic argument-reading.
 * @param   type:identifier  The data type used in the called to the function,
 *                           must match exactly. Arguments smaller than `int`
 *                           are promoted in the cal, thus you must not use a
 *                           type smaller than `int`, lest bad things will happen.
 * @return  :`type`          The next argument.
 * 
 * @since  Always.
 */
#ifndef va_arg
# define va_arg(state, type)  __builtin_va_arg(state, type)
#endif

/**
 * Copy a state of variadic argument-reading.
 * 
 * @etymology  (V)ariadic (a)rguments-subsystem: (copy) list.
 * 
 * @param  destination:va_list  The copy if `source`.
 * @param  source:va_list       The state of the variadic argument-reading.
 * 
 * @since  Always.
 */
#ifndef va_copy
# define va_copy(destination, source)  __builtin_va_copy(destination, source)
#endif



#endif

#endif