xref: /illumos-gate/usr/src/uts/common/sys/va_list.h (revision ba3594ba)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
237c478bd9Sstevel@tonic-gate /*	  All Rights Reserved	*/
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
27*ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
28*ba3594baSGarrett D'Amore  *
297c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
307c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifndef	_SYS_VA_LIST_H
347c478bd9Sstevel@tonic-gate #define	_SYS_VA_LIST_H
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate /*
377c478bd9Sstevel@tonic-gate  * An application should not include this header directly.  Instead it
387c478bd9Sstevel@tonic-gate  * should be included only through the inclusion of other Sun headers.
397c478bd9Sstevel@tonic-gate  *
407c478bd9Sstevel@tonic-gate  * The purpose of this header is to provide the type definitions for
417c478bd9Sstevel@tonic-gate  * the va_list argument used by a number of printf and printf like
427c478bd9Sstevel@tonic-gate  * functions. The headers that define these various function prototypes
437c478bd9Sstevel@tonic-gate  * #include this header directly. These include but are not necessarily
447c478bd9Sstevel@tonic-gate  * limited to <stdio.h>, <stdio_iso.h>, <wchar_iso.h>, <strlog.h> and
457c478bd9Sstevel@tonic-gate  * <syslog.h>. The type definitions included in this header are for
467c478bd9Sstevel@tonic-gate  * the benefit of consumers of va_list.
477c478bd9Sstevel@tonic-gate  *
487c478bd9Sstevel@tonic-gate  * Any application that accepts variable argument lists must as documented,
497c478bd9Sstevel@tonic-gate  * include either <varargs.h> or the preferred <stdarg.h>. Doing so will
507c478bd9Sstevel@tonic-gate  * pull in the appropriate compiler protocols defined in <sys/va_impl.h>
517c478bd9Sstevel@tonic-gate  * which is in turn is included by <varargs.h> and <stdarg.h>. See comments
527c478bd9Sstevel@tonic-gate  * in <sys/va_impl.h> for more detailed information regarding implementation
537c478bd9Sstevel@tonic-gate  * and compiler specific protocols.
547c478bd9Sstevel@tonic-gate  */
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  * The common definitions exported by this header or compilers using
587c478bd9Sstevel@tonic-gate  * this header are:
597c478bd9Sstevel@tonic-gate  *
607c478bd9Sstevel@tonic-gate  * the identifier __builtin_va_alist for the variable list pseudo parameter
617c478bd9Sstevel@tonic-gate  * the type __va_alist_type for the variable list pseudo parameter
627c478bd9Sstevel@tonic-gate  * the type __va_list defining the type of the variable list iterator
637c478bd9Sstevel@tonic-gate  *
647c478bd9Sstevel@tonic-gate  * The feature macros (e.g. __BUILTIN_VA_STRUCT) and compiler macros
657c478bd9Sstevel@tonic-gate  * (__GNUC__) and processor macros (e.g. __amd64) are intended to be
667c478bd9Sstevel@tonic-gate  * defined by the compilation system, not the user of the system.
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 	/* sys/isa_defs needed for _LP64. */
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
727c478bd9Sstevel@tonic-gate extern "C" {
737c478bd9Sstevel@tonic-gate #endif
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate #if defined(_LP64)
767c478bd9Sstevel@tonic-gate #define	__va_alist_type long
777c478bd9Sstevel@tonic-gate #else
787c478bd9Sstevel@tonic-gate #define	__va_alist_type int
797c478bd9Sstevel@tonic-gate #endif
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate #define	__va_void(expr)	((void)expr)
827c478bd9Sstevel@tonic-gate #define	__va_ptr_base	void
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate #if defined(__BUILTIN_VA_STRUCT) && !defined(__lint)	/* -------- protocol */
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate #if defined(__amd64)	/* processor */
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate typedef struct __va_list_element {
897c478bd9Sstevel@tonic-gate 	unsigned int __va_gp_offset;
907c478bd9Sstevel@tonic-gate 	unsigned int __va_fp_offset;
917c478bd9Sstevel@tonic-gate 	void *__va_overflow_arg_area;
927c478bd9Sstevel@tonic-gate 	void *__va_reg_sve_area;
937c478bd9Sstevel@tonic-gate } __va_list[1];
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate /* Other ISA __va_list structures added here under #elif */
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate #else	/* processor */
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate #error("No __va_list structure defined for ISA")
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate #endif	/* processor */
1027c478bd9Sstevel@tonic-gate 
103135e56f2SRichard Lowe #elif (defined(__GNUC__) && ((__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || \
1047c478bd9Sstevel@tonic-gate 	(__GNUC__ >= 3))) && !defined(__lint)	/* ---------------- protocol */
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate #define	__GNUC_VA_LIST
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate typedef __builtin_va_list __gnuc_va_list;
1097c478bd9Sstevel@tonic-gate /*
1107c478bd9Sstevel@tonic-gate  * XX64 This seems unnecessary .. but is needed because vcmn_err is
1117c478bd9Sstevel@tonic-gate  *	defined with __va_list instead of plain old va_list.
1127c478bd9Sstevel@tonic-gate  *	Perhaps that should be fixed!
1137c478bd9Sstevel@tonic-gate  */
1147c478bd9Sstevel@tonic-gate typedef	__builtin_va_list __va_list;
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate #else  /* default */				/* ---------------- protocol */
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate typedef __va_ptr_base *__va_list;
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate #endif  /* -------------------------------------------------------- protocol */
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1237c478bd9Sstevel@tonic-gate }
1247c478bd9Sstevel@tonic-gate #endif
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate #endif	/* _SYS_VA_LIST_H */
127