Blame src/misc.h

Packit Service aee942
/*
Packit Service aee942
 * This handles GCC attributes
Packit Service aee942
 *
Packit Service aee942
 * MUSCLE SmartCard Development ( http://pcsclite.alioth.debian.org/pcsclite.html )
Packit Service aee942
 *
Packit Service aee942
 * Copyright (C) 2005-2010
Packit Service aee942
 *  Ludovic Rousseau <ludovic.rousseau@free.fr>
Packit Service aee942
 *
Packit Service aee942
Redistribution and use in source and binary forms, with or without
Packit Service aee942
modification, are permitted provided that the following conditions
Packit Service aee942
are met:
Packit Service aee942
Packit Service aee942
1. Redistributions of source code must retain the above copyright
Packit Service aee942
   notice, this list of conditions and the following disclaimer.
Packit Service aee942
2. Redistributions in binary form must reproduce the above copyright
Packit Service aee942
   notice, this list of conditions and the following disclaimer in the
Packit Service aee942
   documentation and/or other materials provided with the distribution.
Packit Service aee942
3. The name of the author may not be used to endorse or promote products
Packit Service aee942
   derived from this software without specific prior written permission.
Packit Service aee942
Packit Service aee942
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
Packit Service aee942
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
Packit Service aee942
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
Packit Service aee942
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
Packit Service aee942
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
Packit Service aee942
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit Service aee942
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit Service aee942
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit Service aee942
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
Packit Service aee942
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit Service aee942
 */
Packit Service aee942
Packit Service aee942
#ifndef __misc_h__
Packit Service aee942
#define __misc_h__
Packit Service aee942
Packit Service aee942
/*
Packit Service aee942
 * Declare the function as internal to the library: the function name is
Packit Service aee942
 * not exported and can't be used by a program linked to the library
Packit Service aee942
 *
Packit Service aee942
 * see http://gcc.gnu.org/onlinedocs/gcc-3.3.5/gcc/Function-Attributes.html#Function-Attributes
Packit Service aee942
 * see http://www.nedprod.com/programs/gccvisibility.html
Packit Service aee942
 */
Packit Service aee942
#if defined(__GNUC__) && \
Packit Service aee942
	(__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) || \
Packit Service aee942
	defined(__SUNPRO_C) && __SUNPRO_C >= 0x590
Packit Service aee942
#define INTERNAL __attribute__ ((visibility("hidden")))
Packit Service aee942
#define PCSC_API __attribute__ ((visibility("default")))
Packit Service aee942
#elif defined(__SUNPRO_C) && __SUNPRO_C >= 0x550
Packit Service aee942
/* http://wikis.sun.com/display/SunStudio/Macros+for+Shared+Library+Symbol+Visibility */
Packit Service aee942
#define INTERNAL __hidden
Packit Service aee942
#define PCSC_API __global
Packit Service aee942
#else
Packit Service aee942
#define INTERNAL
Packit Service aee942
#define PCSC_API
Packit Service aee942
#endif
Packit Service aee942
#define EXTERNAL PCSC_API
Packit Service aee942
Packit Service aee942
#if defined __GNUC__
Packit Service aee942
Packit Service aee942
/* GNU Compiler Collection (GCC) */
Packit Service aee942
#define CONSTRUCTOR __attribute__ ((constructor))
Packit Service aee942
#define DESTRUCTOR __attribute__ ((destructor))
Packit Service aee942
Packit Service aee942
#else
Packit Service aee942
Packit Service aee942
/* SUN C compiler does not use __attribute__ but #pragma init (function)
Packit Service aee942
 * We can't use a # inside a #define so it is not possible to use
Packit Service aee942
 * #define CONSTRUCTOR_DECLARATION(x) #pragma init (x)
Packit Service aee942
 * The #pragma is used directly where needed */
Packit Service aee942
Packit Service aee942
/* any other */
Packit Service aee942
#define CONSTRUCTOR
Packit Service aee942
#define DESTRUCTOR
Packit Service aee942
Packit Service aee942
#endif
Packit Service aee942
Packit Service aee942
#ifndef min
Packit Service aee942
#define min(a,b) (((a) < (b)) ? (a) : (b))
Packit Service aee942
#endif
Packit Service aee942
Packit Service aee942
#ifndef COUNT_OF
Packit Service aee942
#define COUNT_OF(arr) (sizeof(arr)/sizeof(arr[0]))
Packit Service aee942
#endif
Packit Service aee942
Packit Service aee942
#endif /* __misc_h__ */