Commit graph

29 commits

Author SHA1 Message Date
Erik Boasson
32b683bf37 Enable "missing prototypes" warning for gcc, clang
Missing prototypes for exported functions cause a really huge issue on
Windows.  Enabling the "missing prototypes" warning makes it much easier
to catch this problem.  Naturally, any warnings caused by this have been
fixed.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-06-13 12:54:35 +02:00
Erik Boasson
a4d8aba4f9 Add limited support for QoS changes
This commit adds support for changing all mutable QoS except those that
affect reader/writer matching (i.e., deadline, latency budget and
partition).  This is simply because the recalculation of the matches
hasn't been implemented yet, it is not a fundamental limitation.

Implementing this basically forced fixing up a bunch of inconsistencies
in handling QoS in entity creation.  A silly multi-process ping-pong
test built on changing the value of user data has been added.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-06-13 12:54:35 +02:00
Erik Boasson
3322fc086d Table-driven parameter list handling
The old parameter list parsing was a mess of custom code with tons of
duplicated checks, even though parameter list parsing really is a fairly
straightforward affair.  This commit changes it to a mostly table-driven
implementation, where the vast majority of the settings are handled by a
generic deserializer and the irregular ones (like reliability, locators)
are handled by custom functions.  The crazy ones (IPv4 address and port
rely on additional state and are completely special-cased).

Given these tables, the serialization, finalisation, validation,
merging, unalias'ing can all be handled by a very small amount of custom
code and an appropriately defined generic function for the common cases.
This also makes it possible to have all QoS validation in place, and so
removes the need for the specialized implementations for the various
entity kinds in the upper layer.

QoS inapplicable to an entity were previously ignored, allowing one to
have invalid values set in a QoS object when creating an entity,
provided that the invalid values are irrelevant to that entity.  Whether
this is a good thing or not is debatable, but certainly it is a good
thing to avoid copying in inapplicable QoS settings.  That in turn means
the behaviour of the API can remain the same.

It does turn out that the code used to return "inconsistent QoS" also
for invalid values.  That has now been rectified, and it returns
"inconsistent QoS" or "bad parameter" as appropriate.  Tests have been
updated accordingly.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-06-10 10:45:53 +02:00
Erik Boasson
ffbf3d7843 Avoid implementation defined types, e.g. unsigned
There are some cases where "int" or "unsigend" actually makes sense, but
in a large number of cases it is really supposed to be either a 32-bit
integer, or, in some cases, at least a 32-bit integer.  It is much to be
preferred to be clear about this.

Another reason is that at least some embedded platforms define, e.g.,
int32_t as "long" instead of "int".  For the ones I am aware of the
"int" and "long" are actually the same 32-bit integer, but that
distinction can cause trouble with printf format specifications.  So
again a good reason to be consistent in avoiding the
implementation-defined ones.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-06-10 10:42:52 +02:00
Erik Boasson
13480616e0 Consistent code formatting for the core code
Code formatting was quite a mess (different indentation, completely
different ideas on where opening braces should go, spacing in various
places, early out versus single return or goto-based error handling,
&c.).  This commit cleans it up.

A few doxygen comment fixes allowed turning on Clang's warnings for
doxygen comments, so those are no enabled by default as least on
Xcode-based builds.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-06-10 10:42:52 +02:00
Erik Boasson
19aec98b8a Clean up return code types
* Remove dds_return_t / dds_retcode_t distinction (now there is only
  dds_return_t and all error codes are always negative)

* Remove Q_ERR_... error codes and replace them by DDS_RETCODE_...
  ones so that there is only one set of error codes

* Replace a whole bunch "int" return types that were used to return
  Q_ERR_... codes by "dds_return_t" return types

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-06-10 10:42:52 +02:00
Erik Boasson
7fbe49c267 Fix broken check for multi-process support
With the introduction of FreeRTOS support, the requirement that the
underlying platform supports multiple processes became untenable, and
therefore the code for dealing with multiple processes is now
automatically detected via some CMake code and then effectuated in the
sources via a macro (DDSRT_HAVE_MULTI_PROCESS).  Unfortunately, a typo
resulted in all platforms being treated as if without support for
multiple processes.  Fortunately, at this stage the only consequence was
the disabling of the first few multi-process tests.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-29 13:20:37 +02:00
Erik Boasson
35fcc013af use clock_gettime on macOS >= 10.12
Since macOS 10.12, the POSIX clock_gettime interface with various
different clocks is supported on macOS, so use those when building for
10.12 or newer.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-24 07:48:45 +02:00
Erik Boasson
a6d92aac8c config input handling improvements
This commit changes a few things in the config handling:

* When reading the configuration from multiple sources, a source can now
  override settings already set by a preceding source for settings that
  are not lists.  Previously, trying to change the value of a setting in a
  subsequence file would be considered an error, just like trying to set
  the value of a particular setting multiple times in a single
  configuration file.

* A configuration fragment in CYCLONEDDS_URI now no longer requires the
  CycloneDDS top-level tag to be specified.  If it is missing it will be
  assumed.  This is only true for configuration fragments contained in
  CYCLONEDDS_URI, not for data read from a file.

* A configuration fragment in CYCLONEDDS_URI no longer requires that all
  elements are properly closed: a missing close tag is treated as-if it
  is the end of the fragment and any elements are implicitly closed.
  Again this does not apply to files.

* The configuration dump now lists explicitly which sources affected
  each setting, with a default value indicated by an empty set.

The result of the latter two is that one can almost pretend that it is a
sane format instead of XML.  For example, if one would like to override
tracing settings, one could just write:

  CYCLONEDDS_URI="$CYCLONEDDS_URI,<Tracing><Verbosity>finest"

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-24 07:48:45 +02:00
Jeroen Koekkoek
aa2715f4fe Add support for FreeRTOS and lwIP (#166)
Add support for FreeRTOS and lwIP

Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2019-05-23 14:27:56 +02:00
Erik Boasson
5ca66f5bda Allow closing config elems with </> if from envvar
The Cyclone DDS configuration is in principle an XML document, but it is
possible to write configuration fragments directly in the CYCLONEDDS_URI
environment variable.  In that case, it is quite annoying to have to
enter the full closing tags all the time, and so it now allows closing
elements with a simple </> when not reading them from a file.

While it would be trivial to also allow this when reading the
configuration from a file, it seems that promulgating invalid XML would
be bad form ... and besides, in that case editors can help keep
everything in order.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-05 20:46:50 +08:00
Erik Boasson
b8e4b2a49b don't modify input string in XML parser
The XML parser has two modes: it can parse a file or parse a
caller-owned string.  In the former case, it owns its buffer and shifts
the contents to make room for more data read in from the file.  This
shifting may not happen when parsing a string.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-05-05 20:46:50 +08:00
Erik Boasson
b686ba858c make internal header files more C++ friendly
Generally one doesn't need to include any internal header files in an
application, but the (unstable) interface for application-defined sample
representation and serialization does require including some.  It turns
out a keyword clash had to be resolved (typename => type_name) and that
a whole bunch of them were missing the #ifdef __cplusplus / extern "C"
bit.

It further turned out that one had to pull in nearly all of the type
definitions, including some typedefs that are illegal in C++, e.g.,

  typedef struct os_sockWaitset *os_sockWaitset;

C++ is right to forbid this, but Cyclone's header files were wrong to
force inclusion of so much irrelevant stuff.  This commit leaves these
typedefs in place, but eliminates a few header file inclusions to avoid
the problem.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-04-29 11:15:41 +02:00
Martin Bremmer
7a705eabf0 Removed expand_envvars.h
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-04-25 13:29:11 +02:00
Martin Bremmer
e9f6ec6f48 Be sure to not trigger the SIGCHLD
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-04-24 15:13:30 +02:00
Martin Bremmer
44ce20ebe0 Fixed proc compile warning.
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-04-24 15:00:37 +02:00
Martin Bremmer
973ae87e17 Moved expand_envvars.
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-04-24 15:00:37 +02:00
Martin Bremmer
17f9c361ea Multi Process Testing framework
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-04-24 14:46:46 +02:00
Martin Bremmer
0269774a60 Rudimentary process management.
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-04-24 14:46:46 +02:00
Erik Boasson
9c1a739559 suppress EHOSTUNREACH and EHOSTDOWN errors in log
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-04-24 14:09:30 +02:00
Erik Boasson
6c171a890d move util library into ddsrt
As was the plan with the introduction of ddsrt; this includes renaming
the identifiers to match the capitalization style and removes old junk.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-04-24 14:09:30 +02:00
Erik Boasson
31b8baa03b block signals in ddsrt_thread_create
Signal handling in multi-threaded processes is bad enough at the best of
times, and as we don't really use any signals in the Cyclone code, it
makes more sense to create all threads with most signals blocked.  That
way an application that wants to handle signals using sigwait() need not
block all signals prior to creating a participant.

Note that instead of blocking all signals, we block all except SIGXCPU.
The reason is that the liveliness monitoring and stack trace dumping
code currently relies on that signal.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-04-24 14:09:30 +02:00
Erik Boasson
c92820677d enable printf format checking for dds_log
Also remove superfluous parameters in a TRACE statement and fix a format
specification in pong.c.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-04-21 16:05:06 +02:00
Erik Boasson
6e87841ea5 move MT19937 random generator to ddsrt
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-04-21 16:05:06 +02:00
Jeroen Koekkoek
3bdd2a140d Move md5 from ddsi to ddsrt
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2019-04-11 10:04:06 +02:00
Jeroen Koekkoek
63a5c87baf Fix format strings and signatures for fixed size integers
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2019-04-11 10:04:06 +02:00
Martin Bremmer
20880016e3 Cleanup log tests.
Signed-off-by: Martin Bremmer <martin.bremmer@adlinktech.com>
2019-03-28 09:43:24 +01:00
Erik Boasson
fcb6b935ea support for building/running on OpenIndiana
Signed-off-by: Erik Boasson <eb@ilities.com>
2019-03-23 15:40:29 +01:00
Jeroen Koekkoek
cd6742ee12 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>
2019-03-22 15:19:09 +01:00