Rearrange and fixup abstraction layer

- Replace os_result by dds_retcode_t and move DDS return code defines down.
  Eliminates the need to convert between different return code types.

- Move dds_time_t down and remove os_time.
  Eliminates the need to convert between different time representations and
  reduces code duplication.

- Remove use of Microsoft source-code annotation language (SAL).
  SAL annotations are Microsoft specific and not very well documented. This
  makes it very difficult for contributers to write.

- Rearrange the abstraction layer to be feature-based. The previous layout
  falsely assumed that the operating system dictates which implementation is
  best suited. For general purpose operating systems this is mostly true, but
  embedded targets require a slightly different approach and may not even offer
  all features. The new layout makes it possible to mix-and-match feature
  implementations and allows for features to not be implemented at all.

- Replace the os prefix by ddsrt to avoid name collisions.

- Remove various portions of unused and unwanted code.

- Export thread names on all supported platforms.

- Return native thread identifier on POSIX compatible platforms.

- Add timed wait for condition variables that takes an absolute time.

- Remove system abstraction for errno. The os_getErrno and os_setErrno were
  incorrect. Functions that might fail now simply return a DDS return code
  instead.

- Remove thread-specific memory abstraction. os_threadMemGet and accompanying
  functions were a mess and their use has been eliminated by other changes in
  this commit.

- Replace attribute (re)defines by ddsrt_ prefixed equivalents to avoid name
  collisions and problems with faulty __nonnull__ attributes.

Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
This commit is contained in:
Jeroen Koekkoek 2019-01-18 14:10:19 +01:00
parent 318968f40f
commit cd6742ee12
439 changed files with 22117 additions and 28782 deletions

View file

@ -9,12 +9,14 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "ddsc/dds.h"
#include "os/os.h"
#include "dds/dds.h"
#include "RoundTrip.h"
#include "CUnit/Test.h"
#include "CUnit/Theory.h"
#include "dds/ddsrt/misc.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"
/**************************************************************************************************
*
* Test fixtures
@ -38,9 +40,9 @@ static char*
create_topic_name(const char *prefix, char *name, size_t size)
{
/* Get semi random g_topic name. */
os_procId pid = os_getpid();
uintmax_t tid = os_threadIdToInteger(os_threadIdSelf());
(void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid);
ddsrt_pid_t pid = ddsrt_getpid();
ddsrt_tid_t tid = ddsrt_gettid();
(void) snprintf(name, size, "%s_pid%"PRIdPID"_tid%"PRIdTID"", prefix, pid, tid);
return name;
}
@ -102,9 +104,9 @@ CU_Test(ddsc_topic_create, invalid_qos, .init=ddsc_topic_init, .fini=ddsc_topic_
{
dds_entity_t topic;
dds_qos_t *qos = dds_create_qos();
OS_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
DDSRT_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
dds_qset_lifespan(qos, DDS_SECS(-1));
OS_WARNING_MSVC_OFF(28020);
DDSRT_WARNING_MSVC_OFF(28020);
topic = dds_create_topic(g_participant, &RoundTripModule_DataType_desc, "inconsistent", qos, NULL);
CU_ASSERT_EQUAL_FATAL(dds_err_nr(topic), DDS_RETCODE_INCONSISTENT_POLICY);
dds_delete_qos(qos);
@ -164,9 +166,9 @@ CU_Test(ddsc_topic_create, recreate, .init=ddsc_topic_init, .fini=ddsc_topic_fin
CU_Test(ddsc_topic_create, desc_null, .init=ddsc_topic_init, .fini=ddsc_topic_fini)
{
dds_entity_t topic;
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
topic = dds_create_topic (g_participant, NULL, "desc_null", NULL, NULL);
OS_WARNING_MSVC_ON(6387);
DDSRT_WARNING_MSVC_ON(6387);
CU_ASSERT_EQUAL_FATAL(dds_err_nr(topic), DDS_RETCODE_BAD_PARAMETER);
}
/*************************************************************************************************/
@ -219,9 +221,9 @@ CU_Test(ddsc_topic_find, non_participants, .init=ddsc_topic_init, .fini=ddsc_top
CU_Test(ddsc_topic_find, null, .init=ddsc_topic_init, .fini=ddsc_topic_fini)
{
dds_entity_t topic;
OS_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
DDSRT_WARNING_MSVC_OFF(6387); /* Disable SAL warning on intentional misuse of the API */
topic = dds_find_topic(g_participant, NULL);
OS_WARNING_MSVC_ON(6387);
DDSRT_WARNING_MSVC_ON(6387);
CU_ASSERT_EQUAL_FATAL(dds_err_nr(topic), DDS_RETCODE_BAD_PARAMETER);
}
/*************************************************************************************************/
@ -411,9 +413,9 @@ CU_Test(ddsc_topic_set_qos, valid, .init=ddsc_topic_init, .fini=ddsc_topic_fini)
CU_Test(ddsc_topic_set_qos, inconsistent, .init=ddsc_topic_init, .fini=ddsc_topic_fini)
{
dds_return_t ret;
OS_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
DDSRT_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
dds_qset_lifespan(g_qos, DDS_SECS(-1));
OS_WARNING_MSVC_ON(28020);
DDSRT_WARNING_MSVC_ON(28020);
ret = dds_set_qos(g_topicRtmDataType, g_qos);
CU_ASSERT_EQUAL_FATAL(dds_err_nr(ret), DDS_RETCODE_INCONSISTENT_POLICY);
}