pcsc-lite 1.7.2
misc.h
00001 /*
00002  * This handles GCC attributes
00003  *
00004  * MUSCLE SmartCard Development ( http://www.linuxnet.com )
00005  *
00006  * Copyright (C) 2005-2010
00007  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
00008  *
00009  * $Id: misc.h 5434 2010-12-08 14:13:21Z rousseau $
00010  */
00011 
00012 #ifndef __misc_h__
00013 #define __misc_h__
00014 
00015 /*
00016  * Declare the function as internal to the library: the function name is
00017  * not exported and can't be used by a program linked to the library
00018  *
00019  * see http://gcc.gnu.org/onlinedocs/gcc-3.3.5/gcc/Function-Attributes.html#Function-Attributes
00020  * see http://www.nedprod.com/programs/gccvisibility.html
00021  */
00022 #if defined __GNUC__ && (! defined (__sun)) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
00023 #define INTERNAL __attribute__ ((visibility("hidden")))
00024 #define PCSC_API __attribute__ ((visibility("default")))
00025 #elif (! defined __GNUC__ ) && defined (__sun)
00026 /* http://wikis.sun.com/display/SunStudio/Macros+for+Shared+Library+Symbol+Visibility */
00027 #define INTERNAL __hidden
00028 #define PCSC_API __global
00029 #else
00030 #define INTERNAL
00031 #define PCSC_API
00032 #endif
00033 #define EXTERNAL PCSC_API
00034 
00035 #if defined __GNUC__
00036 
00037 /* GNU Compiler Collection (GCC) */
00038 #define CONSTRUCTOR __attribute__ ((constructor))
00039 #define DESTRUCTOR __attribute__ ((destructor))
00040 
00041 #else
00042 
00043 /* SUN C compiler does not use __attribute__ but #pragma init (function)
00044  * We can't use a # inside a #define so it is not possible to use
00045  * #define CONSTRUCTOR_DECLARATION(x) #pragma init (x)
00046  * The #pragma is used directly where needed */
00047 
00048 /* any other */
00049 #define CONSTRUCTOR
00050 #define DESTRUCTOR
00051 
00052 #endif
00053 
00054 #ifndef min
00055 #define min(a,b) (((a) < (b)) ? (a) : (b))
00056 #endif
00057 
00058 #endif /* __misc_h__ */