Pacification of native compiler on OpenIndiana

* constness in ternary expressions
* removal of OS_MAX_INTEGER
* inclusion of dds/ddsrt/attributes.h everywhere DDS_EXPORT inline
  occurs
* _POSIX_PTHREAD_SEMANTICS in ddsperf

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2019-07-07 11:33:11 +02:00 committed by eboasson
parent c9f04ee5bd
commit 7190bb3d3e
6 changed files with 26 additions and 31 deletions

View file

@ -17,6 +17,10 @@
#include <stdbool.h>
#include "dds/export.h"
/* DDS_EXPORT inline i.c.w. __attributes__((visibility...)) and some compilers: */
#include "dds/ddsrt/attributes.h"
#include "dds/ddsi/q_rtps.h"
#if defined (__cplusplus)

View file

@ -1714,7 +1714,10 @@ int builtins_dqueue_handler (const struct nn_rsample_info *sampleinfo, const str
goto done_upd_deliv;
}
timestamp = (sampleinfo->timestamp.v != NN_WCTIME_INVALID.v) ? sampleinfo->timestamp : now ();
if (sampleinfo->timestamp.v != NN_WCTIME_INVALID.v)
timestamp = sampleinfo->timestamp;
else
timestamp = now ();
switch (srcguid.entityid.u)
{
case NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_WRITER:

View file

@ -52,23 +52,6 @@ extern "C" {
# define DDSRT_WARNING_MSVC_ON(x)
#endif
/**
* @brief Calculate maximum value of an integer type
*
* A somewhat complex, but efficient way to calculate the maximum value of an
* integer type at compile time.
*
* For unsigned numerical types the first part up to XOR is enough. The second
* part is to make up for signed numerical types.
*/
#define DDSRT_MAX_INTEGER(T) \
((T)(((T)~0) ^ ((T)!((T)~0 > 0) << (CHAR_BIT * sizeof(T) - 1))))
/**
* @brief Calculate minimum value of an integer type
*/
#define DDSRT_MIN_INTEGER(T) \
((-DDSRT_MAX_INTEGER(T)) - 1)
/**
* @brief Macro to disable unused argument warnings
*/

View file

@ -17,6 +17,7 @@
#include "dds/ddsrt/misc.h"
#include "dds/ddsrt/sockets.h"
#include "dds/ddsrt/time.h"
#include "dds/ddsrt/static_assert.h"
#if defined(__cplusplus)
extern "C" {
@ -29,9 +30,6 @@ typedef long ddsrt_tv_usec_t;
typedef time_t ddsrt_tv_sec_t;
#endif
#define DDSRT_TIME_T_MAX \
(DDSRT_MAX_INTEGER(ddsrt_tv_sec_t))
/**
* @brief Convert a relative time to a timeval rounding up.
*
@ -51,19 +49,21 @@ ddsrt_duration_to_timeval_ceil(dds_duration_t reltime, struct timeval *tv)
return NULL;
} else if (reltime > 0) {
dds_duration_t max_nsecs;
if (DDSRT_TIME_T_MAX == INT32_MAX) {
DDSRT_STATIC_ASSERT (CHAR_BIT * sizeof (ddsrt_tv_sec_t) == 32 || CHAR_BIT * sizeof (ddsrt_tv_sec_t) == 64);
if (CHAR_BIT * sizeof (ddsrt_tv_sec_t) == 32)
max_nsecs = INT32_MAX * DDS_NSECS_IN_SEC;
} else {
assert(DDSRT_TIME_T_MAX == INT64_MAX);
max_nsecs = DDSRT_TIME_T_MAX / DDS_NSECS_IN_SEC;
}
else
max_nsecs = INT64_MAX / DDS_NSECS_IN_SEC;
if (reltime < (max_nsecs - DDS_NSECS_IN_USEC - 1)) {
reltime += (DDS_NSECS_IN_USEC - 1);
tv->tv_sec = (ddsrt_tv_sec_t)(reltime / DDS_NSECS_IN_SEC);
tv->tv_usec = (int)((reltime % DDS_NSECS_IN_SEC) / DDS_NSECS_IN_USEC);
} else {
tv->tv_sec = DDSRT_TIME_T_MAX;
if (CHAR_BIT * sizeof (ddsrt_tv_sec_t) == 32)
tv->tv_sec = (ddsrt_tv_sec_t) INT32_MAX;
else
tv->tv_sec = (ddsrt_tv_sec_t) INT64_MAX;
tv->tv_usec = 999999;
}
} else {

View file

@ -36,8 +36,13 @@ CU_Test(ddsrt_select, duration_to_timeval)
{
struct timeval tv, *tvptr;
dds_duration_t nsecs_max;
dds_duration_t secs_max = DDSRT_MAX_INTEGER(ddsrt_tv_sec_t);
dds_duration_t usecs_max = 999999;
dds_duration_t secs_max;
DDSRT_STATIC_ASSERT (CHAR_BIT * sizeof (ddsrt_tv_sec_t) == 32 || CHAR_BIT * sizeof (ddsrt_tv_sec_t) == 64);
if (CHAR_BIT * sizeof (ddsrt_tv_sec_t) == 32)
secs_max = INT32_MAX;
else
secs_max = INT64_MAX;
if (DDS_INFINITY > secs_max) {
CU_ASSERT_EQUAL_FATAL(secs_max, INT32_MAX);

View file

@ -27,9 +27,9 @@ char str_xllmin[99], str_xllmax[99];
/* Really test with the maximum values supported on a platform, not some
made up number. */
long long llmin = DDSRT_MIN_INTEGER(long long);
long long llmax = DDSRT_MAX_INTEGER(long long);
unsigned long long ullmax = DDSRT_MAX_INTEGER(unsigned long long);
long long llmin = INT64_MIN;
long long llmax = INT64_MAX;
unsigned long long ullmax = UINT64_MAX;
CU_Init(ddsrt_strtoll)
{