Skip to content

Commit

Permalink
KWIML 2017-09-21 (7db8b884)
Browse files Browse the repository at this point in the history
Code extracted from:

    https://gitlab.kitware.com/utils/kwiml.git

at commit 7db8b88453f6987bdc45e489274b777fbb0888d1 (master).
  • Loading branch information
kwrobot authored and jcfr committed Sep 21, 2017
1 parent 9aefaec commit 5ba4d7e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Copyright.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Kitware Information Macro Library
Copyright 2010-2016 Kitware, Inc.
Copyright 2010-2017 Kitware, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
17 changes: 14 additions & 3 deletions include/kwiml/abi.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*============================================================================
Kitware Information Macro Library
Copyright 2010-2016 Kitware, Inc.
Copyright 2010-2017 Kitware, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -484,9 +484,16 @@ suppression macro KWIML_ABI_NO_VERIFY was defined.

#if defined(_MSC_VER)
# pragma warning (push)
# pragma warning (disable:4309) /* static_cast trunction of constant value */
# pragma warning (disable:4310) /* cast truncates constant value */
#endif

#ifdef __cplusplus
#define KWIML_ABI_private_STATIC_CAST(t,v) static_cast<t>(v)
#else
#define KWIML_ABI_private_STATIC_CAST(t,v) (t)(v)
#endif

#define KWIML_ABI_private_VERIFY(n, x, y) KWIML_ABI_private_VERIFY_0(KWIML_ABI_private_VERSION, n, x, y)
#define KWIML_ABI_private_VERIFY_0(V, n, x, y) KWIML_ABI_private_VERIFY_1(V, n, x, y)
#define KWIML_ABI_private_VERIFY_1(V, n, x, y) extern int (*n##_v##V)[x]; extern int (*n##_v##V)[y]
Expand Down Expand Up @@ -535,9 +542,11 @@ KWIML_ABI_private_VERIFY_DIFF(KWIML_ABI___INT64_NOT_LONG_LONG, __int64, long lon
#endif

#if defined(KWIML_ABI_CHAR_IS_UNSIGNED)
KWIML_ABI_private_VERIFY_BOOL(KWIML_ABI_CHAR_IS_UNSIGNED, (char)0x80 > 0);
KWIML_ABI_private_VERIFY_BOOL(KWIML_ABI_CHAR_IS_UNSIGNED,
KWIML_ABI_private_STATIC_CAST(char, 0x80) > 0);
#elif defined(KWIML_ABI_CHAR_IS_SIGNED)
KWIML_ABI_private_VERIFY_BOOL(KWIML_ABI_CHAR_IS_SIGNED, (char)0x80 < 0);
KWIML_ABI_private_VERIFY_BOOL(KWIML_ABI_CHAR_IS_SIGNED,
KWIML_ABI_private_STATIC_CAST(char, 0x80) < 0);
#endif

#undef KWIML_ABI_private_VERIFY_DIFF
Expand All @@ -557,6 +566,8 @@ KWIML_ABI_private_VERIFY_BOOL(KWIML_ABI_CHAR_IS_SIGNED, (char)0x80 < 0);
#undef KWIML_ABI_private_VERIFY_0
#undef KWIML_ABI_private_VERIFY

#undef KWIML_ABI_private_STATIC_CAST

#if defined(_MSC_VER)
# pragma warning (pop)
#endif
Expand Down
15 changes: 13 additions & 2 deletions include/kwiml/int.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*============================================================================
Kitware Information Macro Library
Copyright 2010-2016 Kitware, Inc.
Copyright 2010-2017 Kitware, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -1003,16 +1003,25 @@ An includer may test the following macros after inclusion:

#if defined(_MSC_VER)
# pragma warning (push)
# pragma warning (disable:4309) /* static_cast trunction of constant value */
# pragma warning (disable:4310) /* cast truncates constant value */
#endif

#ifdef __cplusplus
#define KWIML_INT_private_STATIC_CAST(t,v) static_cast<t>(v)
#else
#define KWIML_INT_private_STATIC_CAST(t,v) (t)(v)
#endif

#define KWIML_INT_private_VERIFY(n, x, y) KWIML_INT_private_VERIFY_0(KWIML_INT_private_VERSION, n, x, y)
#define KWIML_INT_private_VERIFY_0(V, n, x, y) KWIML_INT_private_VERIFY_1(V, n, x, y)
#define KWIML_INT_private_VERIFY_1(V, n, x, y) extern int (*n##_v##V)[x]; extern int (*n##_v##V)[y]

#define KWIML_INT_private_VERIFY_BOOL(m, b) KWIML_INT_private_VERIFY(KWIML_INT_detail_VERIFY_##m, 2, (b)?2:3)
#define KWIML_INT_private_VERIFY_TYPE(t, s) KWIML_INT_private_VERIFY(KWIML_INT_detail_VERIFY_##t, s, sizeof(t))
#define KWIML_INT_private_VERIFY_SIGN(t, u, o) KWIML_INT_private_VERIFY_BOOL(SIGN_##t, (t)((u)1 << ((sizeof(t)<<3)-1)) o 0)
#define KWIML_INT_private_VERIFY_SIGN(t, u, o) \
KWIML_INT_private_VERIFY_BOOL(SIGN_##t, KWIML_INT_private_STATIC_CAST( \
t, KWIML_INT_private_STATIC_CAST(u, 1) << ((sizeof(t)<<3)-1)) o 0)

KWIML_INT_private_VERIFY_TYPE(KWIML_INT_int8_t, 1);
KWIML_INT_private_VERIFY_TYPE(KWIML_INT_uint8_t, 1);
Expand Down Expand Up @@ -1060,6 +1069,8 @@ KWIML_INT_private_VERIFY_SIGN(KWIML_INT_uintptr_t, KWIML_INT_uintptr_t, >);
#undef KWIML_INT_private_VERIFY_0
#undef KWIML_INT_private_VERIFY

#undef KWIML_INT_private_STATIC_CAST

#if defined(_MSC_VER)
# pragma warning (pop)
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/version.h.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*============================================================================
Kitware Information Macro Library
Copyright 2010-2016 Kitware, Inc.
Copyright 2010-2017 Kitware, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
5 changes: 4 additions & 1 deletion test/test_int_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@

#if defined(_MSC_VER)
# pragma warning (push)
# pragma warning (disable:4309) /* static_cast trunction of constant value */
# pragma warning (disable:4310) /* cast truncates constant value */
#endif

#ifdef __cplusplus
# define LANG "C++ "
# define STATIC_CAST(t,v) static_cast<t>(v)
#else
# define LANG "C "
# define STATIC_CAST(t,v) (t)(v)
#endif

#define VALUE(T, U) (T)((U)0xab << ((sizeof(T)-1)<<3))
#define VALUE(T, U) STATIC_CAST(T, STATIC_CAST(U, 0xab) << ((sizeof(T)-1)<<3))

#define TEST_C_(C, V, PRI, T, U) \
{ \
Expand Down

0 comments on commit 5ba4d7e

Please sign in to comment.