1 /*
2  * Copyright (C) by Argonne National Laboratory
3  *     See COPYRIGHT in top-level directory
4  */
5 
6 #ifndef MPIR_TYPE_DEFS_H_INCLUDED
7 #define MPIR_TYPE_DEFS_H_INCLUDED
8 
9 #include "mpichconf.h"
10 
11 /* Basic typedefs */
12 #ifdef HAVE_SYS_BITYPES_H
13 #include <sys/bitypes.h>
14 #endif
15 
16 /* inttypes.h is supposed to include stdint.h but this is here as
17    belt-and-suspenders for platforms that aren't fully compliant */
18 #ifdef HAVE_INTTYPES_H
19 #include <inttypes.h>
20 #endif
21 
22 /* stdint.h gives us fixed-width C99 types like int16_t, among others */
23 #ifdef HAVE_STDINT_H
24 #include <stdint.h>
25 #endif
26 
27 /* stdbool.h gives us the C boolean type */
28 #ifdef HAVE_STDBOOL_H
29 #include <stdbool.h>
30 #endif
31 
32 /* complex.h gives us the C complex type */
33 #ifdef HAVE_COMPLEX_H
34 #include <complex.h>
35 #endif
36 
37 #ifdef HAVE_WINDOWS_H
38 #include <winsock2.h>
39 #include <windows.h>
40 #else
41 #ifndef BOOL
42 #define BOOL int
43 #endif
44 #endif
45 
46 #include "mpl.h"
47 
48 /* Use the MPIR_PtrToXXX macros to convert pointers to and from integer types */
49 
50 /* The Microsoft compiler will not allow casting of different sized types
51  * without
52  * printing a compiler warning.  Using these macros allows compiler specific
53  * type casting and avoids the warning output.  These macros should only be used
54  * in code that can handle loss of bits.
55  */
56 
57 /* PtrToAint converts a pointer to an MPI_Aint type, truncating bits if necessary */
58 #ifdef HAVE_PTRTOAINT
59 #define MPIR_Ptr_to_aint(a) ((MPI_Aint)(INT_PTR) (a))
60 #else
61 /* An MPI_Aint may be *larger* than a pointer.  By using 2 casts, we can
62    keep some compilers from complaining about converting a pointer to an
63    integer of a different size */
64 #define MPIR_Ptr_to_aint(a) ((MPI_Aint)(uintptr_t)(a))
65 #endif
66 
67 /* AintToPtr converts an MPI_Aint to a pointer type, extending bits if necessary */
68 #ifdef HAVE_AINTTOPTR
69 #define MPIR_Aint_to_ptr(a) ((VOID *)(INT_PTR)((MPI_Aint)a))
70 #else
71 #define MPIR_Aint_to_ptr(a) (void*)(a)
72 #endif
73 
74 #endif /* MPIR_TYPE_DEFS_H_INCLUDED */
75