home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / linux / backup / star-1.3.1.tar.gz / star-1.3.1.tar / star-1.3.1 / include / vadefs.h < prev    next >
C/C++ Source or Header  |  1999-11-27  |  3KB  |  109 lines

  1. /* @(#)vadefs.h    1.4 99/11/27 Copyright 1998 J. Schilling */
  2. /*
  3.  *    Generic header for users of var args ...
  4.  *
  5.  *    Includes a default definition for va_copy()
  6.  *    and some magic know how about the SVr4 Power PC var args ABI
  7.  *    to create a __va_arg_list() macro.
  8.  *
  9.  *    Copyright (c) 1998 J. Schilling
  10.  */
  11. /*
  12.  * This program is free software; you can redistribute it and/or modify
  13.  * it under the terms of the GNU General Public License as published by
  14.  * the Free Software Foundation; either version 2, or (at your option)
  15.  * any later version.
  16.  *
  17.  * This program is distributed in the hope that it will be useful,
  18.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20.  * GNU General Public License for more details.
  21.  *
  22.  * You should have received a copy of the GNU General Public License
  23.  * along with this program; see the file COPYING.  If not, write to
  24.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  */
  26.  
  27. #ifndef    _VADEFS_H
  28. #define    _VADEFS_H
  29.  
  30. #ifndef    _MCONFIG_H
  31. #include <mconfig.h>
  32. #endif
  33.  
  34. #ifdef    PROTOTYPES
  35. /*
  36.  * For ANSI C-compilers prefer stdarg.h
  37.  */
  38. #    ifdef    HAVE_STDARG_H
  39. #        include <stdarg.h>
  40. #    else
  41. #        include <varargs.h>
  42. #    endif
  43. #else
  44. /*
  45.  * For K&R C-compilers prefer varargs.h
  46.  */
  47. #    ifdef    HAVE_VARARGS_H
  48. #        include <varargs.h>
  49. #    else
  50. #        include <stdarg.h>
  51. #    endif
  52. #endif
  53.  
  54. #if (defined(__linux__) || defined(__linux) || defined(sun)) && \
  55.         (defined(__ppc) || defined(__PPC) || defined(powerpc) || defined(__powerpc__))
  56.  
  57. #    ifndef    VA_LIST_IS_ARRAY
  58. #    define    VA_LIST_IS_ARRAY
  59. #    endif
  60. #endif
  61.  
  62.  
  63. /*
  64.  * __va_copy() is used by GCC 2.8 or newer until va_copy() becomes
  65.  * a final ISO standard.
  66.  */
  67. #if !defined(va_copy) && !defined(HAVE_VA_COPY)
  68. #    if    defined(__va_copy)
  69. #        define    va_copy(to, from)    __va_copy(to, from)
  70. #    endif
  71. #endif
  72.  
  73. /*
  74.  * va_copy() is a Solaris extension to provide a portable way to perform a
  75.  * variable argument list "bookmarking" function.
  76.  * If it is not available via stdarg.h, use a simple assignement for backward
  77.  * compatibility.
  78.  */
  79. #if !defined(va_copy) && !defined(HAVE_VA_COPY)
  80. #ifdef    VA_LIST_IS_ARRAY
  81. #    define    va_copy(to, from)    ((to)[0] = (from)[0])
  82. #else
  83. #    define    va_copy(to, from)    ((to) = (from))
  84. #endif
  85. #endif
  86.  
  87. /*
  88.  * I don't know any portable way to get an arbitrary
  89.  * C object from a var arg list so I use a
  90.  * system-specific routine __va_arg_list() that knows
  91.  * if 'va_list' is an array. You will not be able to
  92.  * assign the value of __va_arg_list() but it works
  93.  * to be used as an argument of a function.
  94.  * It is a requirement for recursive printf to be able
  95.  * to use this function argument. If your system
  96.  * defines va_list to be an array you need to know this
  97.  * via autoconf or another mechanism.
  98.  * It would be nice to have something like
  99.  * __va_arg_list() in stdarg.h
  100.  */
  101.  
  102. #ifdef    VA_LIST_IS_ARRAY
  103. #    define    __va_arg_list(list)    va_arg(list, void *)
  104. #else
  105. #    define    __va_arg_list(list)    va_arg(list, va_list)
  106. #endif
  107.  
  108. #endif    /* _VADEFS_H */
  109.