pcsc-lite  1.8.8
misc.h
1 /*
2  * This handles GCC attributes
3  *
4  * MUSCLE SmartCard Development ( http://www.linuxnet.com )
5  *
6  * Copyright (C) 2005-2010
7  * Ludovic Rousseau <ludovic.rousseau@free.fr>
8  *
9  * $Id: misc.h 5434 2010-12-08 14:13:21Z rousseau $
10  */
11 
12 #ifndef __misc_h__
13 #define __misc_h__
14 
15 /*
16  * Declare the function as internal to the library: the function name is
17  * not exported and can't be used by a program linked to the library
18  *
19  * see http://gcc.gnu.org/onlinedocs/gcc-3.3.5/gcc/Function-Attributes.html#Function-Attributes
20  * see http://www.nedprod.com/programs/gccvisibility.html
21  */
22 #if defined __GNUC__ && (! defined (__sun)) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
23 #define INTERNAL __attribute__ ((visibility("hidden")))
24 #define PCSC_API __attribute__ ((visibility("default")))
25 #elif (! defined __GNUC__ ) && defined (__sun)
26 /* http://wikis.sun.com/display/SunStudio/Macros+for+Shared+Library+Symbol+Visibility */
27 #define INTERNAL __hidden
28 #define PCSC_API __global
29 #else
30 #define INTERNAL
31 #define PCSC_API
32 #endif
33 #define EXTERNAL PCSC_API
34 
35 #if defined __GNUC__
36 
37 /* GNU Compiler Collection (GCC) */
38 #define CONSTRUCTOR __attribute__ ((constructor))
39 #define DESTRUCTOR __attribute__ ((destructor))
40 
41 #else
42 
43 /* SUN C compiler does not use __attribute__ but #pragma init (function)
44  * We can't use a # inside a #define so it is not possible to use
45  * #define CONSTRUCTOR_DECLARATION(x) #pragma init (x)
46  * The #pragma is used directly where needed */
47 
48 /* any other */
49 #define CONSTRUCTOR
50 #define DESTRUCTOR
51 
52 #endif
53 
54 #ifndef min
55 #define min(a,b) (((a) < (b)) ? (a) : (b))
56 #endif
57 
58 #endif /* __misc_h__ */