pcsc-lite 1.6.4
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 4974 2010-06-01 09:43:47Z rousseau $
00010  */
00011 
00012 #ifndef __misc_h__
00013 #define __misc_h__
00014 
00015 #ifdef __cplusplus
00016 extern "C"
00017 {
00018 #endif
00019 
00020 /*
00021  * Declare the function as internal to the library: the function name is
00022  * not exported and can't be used by a program linked to the library
00023  *
00024  * see http://gcc.gnu.org/onlinedocs/gcc-3.3.5/gcc/Function-Attributes.html#Function-Attributes
00025  * see http://www.nedprod.com/programs/gccvisibility.html
00026  */
00027 #if defined __GNUC__ && (! defined (__sun)) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
00028 #define INTERNAL __attribute__ ((visibility("hidden")))
00029 #define PCSC_API __attribute__ ((visibility("default")))
00030 #elif (! defined __GNUC__ ) && defined (__sun) 
00031 /* http://wikis.sun.com/display/SunStudio/Macros+for+Shared+Library+Symbol+Visibility */
00032 #define INTERNAL __hidden
00033 #define PCSC_API __global
00034 #else
00035 #define INTERNAL
00036 #define PCSC_API
00037 #endif
00038 #define EXTERNAL PCSC_API
00039 
00040 #if defined __GNUC__
00041 
00042 /* GNU Compiler Collection (GCC) */
00043 #define CONSTRUCTOR __attribute__ ((constructor))
00044 #define DESTRUCTOR __attribute__ ((destructor))
00045 
00046 #else
00047 
00048 /* SUN C compiler does not use __attribute__ but #pragma init (function)
00049  * We can't use a # inside a #define so it is not possible to use
00050  * #define CONSTRUCTOR_DECLARATION(x) #pragma init (x)
00051  * The #pragma is used directly where needed */
00052 
00053 /* any other */
00054 #define CONSTRUCTOR
00055 #define DESTRUCTOR
00056 
00057 #endif
00058 
00059 #ifndef min
00060 #define min(a,b) (((a) < (b)) ? (a) : (b))
00061 #endif
00062 
00063 #ifdef __cplusplus
00064 }
00065 #endif
00066 
00067 #endif /* __misc_h__ */