comparison dw.h @ 2132:42f8ad7a89e8

Added DW_POINTER_TO_(U)LONGLONG and DW_(U)LONGLONG_TO_POINTER macros. This allows casting with intermediate (u)intptr_t cast to avoid compiler warnings on different systems. Use these macros where necessary in the code. Might need to check the compiler supports LONG LONG... since some compilers we support might not, like old versions of VisualAge C and Watcom.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 04 Jul 2020 17:51:46 +0000
parents 663467f6eee4
children d9720d48d61e
comparison
equal deleted inserted replaced
2131:fc29c4c2d386 2132:42f8ad7a89e8
1510 */ 1510 */
1511 #define DW_INT_TO_POINTER(a) ((void *)(intptr_t)a) 1511 #define DW_INT_TO_POINTER(a) ((void *)(intptr_t)a)
1512 #define DW_POINTER_TO_INT(a) ((int)(intptr_t)a) 1512 #define DW_POINTER_TO_INT(a) ((int)(intptr_t)a)
1513 #define DW_UINT_TO_POINTER(a) ((void *)(uintptr_t)a) 1513 #define DW_UINT_TO_POINTER(a) ((void *)(uintptr_t)a)
1514 #define DW_POINTER_TO_UINT(a) ((unsigned int)(uintptr_t)a) 1514 #define DW_POINTER_TO_UINT(a) ((unsigned int)(uintptr_t)a)
1515 #define DW_LONGLONG_TO_POINTER(a) ((void *)(intptr_t)a)
1516 #define DW_POINTER_TO_LONGLONG(a) ((long long)(intptr_t)a)
1517 #define DW_ULONGLONG_TO_POINTER(a) ((void *)(uintptr_t)a)
1518 #define DW_POINTER_TO_ULONGLONG(a) ((unsigned long long)(uintptr_t)a)
1515 #elif ULONG_MAX > UINT_MAX 1519 #elif ULONG_MAX > UINT_MAX
1516 /* If no intptr_t... ULONG is often bigger than UINT */ 1520 /* If no intptr_t... ULONG is often bigger than UINT */
1517 #define DW_INT_TO_POINTER(a) ((void *)(long)a) 1521 #define DW_INT_TO_POINTER(a) ((void *)(long)a)
1518 #define DW_POINTER_TO_INT(a) ((int)(long)a) 1522 #define DW_POINTER_TO_INT(a) ((int)(long)a)
1519 #define DW_UINT_TO_POINTER(a) ((void *)(unsigned long)a) 1523 #define DW_UINT_TO_POINTER(a) ((void *)(unsigned long)a)
1522 /* Otherwise just fall back to standard casts */ 1526 /* Otherwise just fall back to standard casts */
1523 #define DW_INT_TO_POINTER(a) ((void *)a) 1527 #define DW_INT_TO_POINTER(a) ((void *)a)
1524 #define DW_POINTER_TO_INT(a) ((int)a) 1528 #define DW_POINTER_TO_INT(a) ((int)a)
1525 #define DW_UINT_TO_POINTER(a) ((void *)a) 1529 #define DW_UINT_TO_POINTER(a) ((void *)a)
1526 #define DW_POINTER_TO_UINT(a) ((unsigned int)a) 1530 #define DW_POINTER_TO_UINT(a) ((unsigned int)a)
1531 #endif
1532 #ifndef DW_LONGLONG_TO_POINTER
1533 #define DW_LONGLONG_TO_POINTER(a) ((void *)a)
1534 #define DW_POINTER_TO_LONGLONG(a) ((long long)a)
1535 #define DW_ULONGLONG_TO_POINTER(a) ((void *)a)
1536 #define DW_POINTER_TO_ULONGLONG(a) ((unsigned long long)a)
1527 #endif 1537 #endif
1528 #define DW_POINTER(a) ((void *)a) 1538 #define DW_POINTER(a) ((void *)a)
1529 1539
1530 #ifndef DW_FCF_COMPOSITED 1540 #ifndef DW_FCF_COMPOSITED
1531 #define DW_FCF_COMPOSITED 0 1541 #define DW_FCF_COMPOSITED 0