Squashed 'src/machinetalk/proto/' content from commit 88a29ea

git-subtree-dir: src/machinetalk/proto
git-subtree-split: 88a29ea4dc9ed42612cb30722519adf34c0bc4d8
Merge commit '902d093fb0f040e95eee334536b73db6097e7a7c' as 'src/machinetalk/proto'
tests/build/header-sanity: skip generated C++ protobuf headers

those are named '*.h' but are actually C++ includes
docs/highlight: support protobuf highlighting
shmdrv api: be more resilient when opening the driver

sometimes udev can take a while to get its act together, so be patient
rtapi/bitops: add atomic add_and_fetch primitives
rtapi: spin out integer types into separate include file
rtapi: hexdump library function
rtapi/ringbuffer: introduce multframe ring buffer API

This matches the format and terminology of zeroMQ frames and messages.
Used to support uniform end-to-end messaging of zeroMQ message streams
to and from RT components.

(c) Pavel Shramove 2014, MIT license.
rtapi: introduce rtapi_next_handle()

This provides a unique integer ID for all sorts of objects. This ID is needed
to distinguish objects in the remote case where it is ineffcient to use
strings.

Using addresses as ID's will not work in the general case since these
will not necessarily be unique over an instance lifetime, due to
reclamation of memory of destroyed objects.

The id counter is updated with an atomic operation, and resides
in the global segment.

Replaces the current muted-protected next_module_id() method.
rtapi/shmem: improve error message
rtapi/support: set pid tag for logging early

this avoids the case where a log message is tagged with pid -1 in the
startup phase.
ulapi_autoload: reduce log noise
ulapi_main: printf warning correction for size type
rtapi/xenomai: improve error messages
rtapi/shmem: API change to retrieve shm segment size

An omission, but a consequential one.
rtapi/app: introduce procfs thread creation API

This enables rtapi_app to create RT threads for kernel threads flavors
without the need of the threads module, and more felxible.

rtapi_compat.c: fix default xenomai flavor selection logic

no point in choosing xenomai-kernel over xenomai-user
rtapi_app: rework as a flavor-independent RT demon, offering a zmq/protobuf RPC API

This commit folds all processing of RT components regardless of thread
flavor (kernel or userland) into interaction with a single demon,
rtapi_app.

Interaction with rtapi_app changes from the arcane unix domain socket
interface to use zeroMQ/protobuf interaction; for a description of
message formats see the rtapi_message.proto file. Also, rtapi_app is
assumed to be a demon proper, i.e. started upon realtime start.

For userland thread flavors, the flow is unchanged - RT components are
handled with dlopen() and entry points called via dlsym(). Also,
userland RT threads run in the context of rtapi_app.

For kernel thread flavors, rtapi_app just calls the module helper to
insmod the appropriate kernel module as directed by rtapi.ini. Kernel
threads remain in-kernel; however a newthread() interface is
introduced which works identically for userland and kernel threads, in
principle obsoleting the threads module.

In the userland RT threads case, newthread just starts a thread
through the appropriate HAL library API.  For kernel threads, a
procfs-based API is used, but the differences are hidden to the using
code - which is expected to use the rtapi_message API.

Shutdown:
rtapi_app records a module loading order, and on shutdown
unloads modules in reverse loading order. This was so far unspecified
behavior.

Background timer:
There is a background periodic timer which checks
fro rtapi_msgd (needed for logging), and potentially other periodic
tasks. See s_handle_timer(), which runs in a non-RT context.

Sockets use:

Since using code for the rtapi_app RPC interface is (for
now) assumed to run on the RT host, and for security considerations,
no remote socket API is offered. Instead, zeroMQ unix domain sockets
are used (ipc://...). The socket path name is derived from the
instance UUID, so any client is assumed to connect to
"ipc://<dir>/<rtapi_instance>.rtapi.<uuid>" (see ZMQIPC_FORMAT). This
affetcs primarily halcmd, and the new RTAPI cython bindings.

The "_rtapi" service currently is not announced via zeroconf, as deriving
the IPC URI from the (known) UUID is trivial.

UUID:
The instance UUID designates a running RT instance, and enables
disntinguishing several instances when instances are announced with
mDNS/zeroconf. The instance UUID necessarily ahs to be unique, and is
retrieved from the ini file specified in getenv(MACHINEKIT_INI), which
defaults to /etc/linuxcnc/machinekit.ini.
rtapi: adjust Submakefile

build rtapi_app for all flavors now

all module loading / unloading now goes through rtapi_app regardless
of userland/kernel threads flavors
rtapi_msgd: support zeroconf, improve shutdown, signal handling

The instance identifier from MKUIID/$MACHINEKIT_INI is now held in the global
segment, automatically exporting it to all of HAL/RTAPI. Additionally,
demons like keep a per-process uuid which is also announced via zeroconf,
enabling clients to detect a demon restart (the instance UUID does not change,
however the per-process UUID changes).

announce the log service via zeroconf if REMOTE=1 in $MACHINEKIT_INI.
This is a zeroMQ publish URI, so arbitrary processes may subscribe to
log messages.

Unique ID counter changed to use atomic operations, and not collide with
rtapi module ID's (preparing for https://github.com/machinekit/machinekit/issues/114).

signal handling generally moves to signalfd() and synchronous handling in
the inner event loop, except those signals which cannot be trapped by signalfd().
See the setup_signals() library function which is used by several demons.

msgd now continues to run a bit after shutdown detected so log messages
can be collected during the shutdown phase - otherwise hard to diagnose
shutdown issues if logging stops early.

option config + default handling is still a mess thanks to braindead ini
files and no library support for options/default merging.