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,22 +9,28 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "ddsc/dds.h"
#include <stdlib.h>
#include "dds/dds.h"
#include "CUnit/Test.h"
#include "os/os.h"
#include "config_env.h"
#include "ddsc/ddsc_project.h"
#include "dds/version.h"
#include "dds/ddsrt/cdtors.h"
#include "dds/ddsrt/environ.h"
#include "dds/ddsrt/heap.h"
#define FORCE_ENV
#define URI_VARIABLE DDSC_PROJECT_NAME_NOSPACE_CAPS"_URI"
#define URI_VARIABLE DDS_PROJECT_NAME_NOSPACE_CAPS"_URI"
#define MAX_PARTICIPANTS_VARIABLE "MAX_PARTICIPANTS"
static void config__check_env(
_In_z_ const char * env_variable,
_In_z_ const char * expected_value)
const char * env_variable,
const char * expected_value)
{
const char * env_uri = os_getenv(env_variable);
char * env_uri = NULL;
ddsrt_getenv(env_variable, &env_uri);
#if 0
const char * const env_not_set = "Environment variable '%s' isn't set. This needs to be set to '%s' for this test to run.";
const char * const env_not_as_expected = "Environment variable '%s' has an unexpected value: '%s' (expected: '%s')";
@ -43,17 +49,10 @@ static void config__check_env(
}
if ( !env_ok ) {
os_result r;
char *envstr;
size_t len = strlen(env_variable) + strlen("=") + strlen(expected_value) + 1;
dds_retcode_t r;
envstr = os_malloc(len);
(void)snprintf(envstr, len, "%s=%s", env_variable, expected_value);
r = os_putenv(envstr);
CU_ASSERT_EQUAL_FATAL(r, os_resultSuccess);
os_free(envstr);
r = ddsrt_setenv(env_variable, expected_value);
CU_ASSERT_EQUAL_FATAL(r, DDS_RETCODE_OK);
}
}
#else
@ -63,7 +62,7 @@ static void config__check_env(
}
CU_Test(ddsc_config, simple_udp, .init = os_osInit, .fini = os_osExit) {
CU_Test(ddsc_config, simple_udp, .init = ddsrt_init, .fini = ddsrt_fini) {
dds_entity_t participant;