Skip to content

xdr upstream readable - #4762

Open
smoe wants to merge 2 commits into
LinuxCNC:masterfrom
smoe:codex/xdr-upstream-readable
Open

smoe wants to merge 2 commits into
LinuxCNC:masterfrom
smoe:codex/xdr-upstream-readable

Conversation

@smoe

@smoe smoe commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Hello,

Some (as I find) good news: My MacBook could eventually build some of our binaries. We are about four smaller patches away from it. All dependencies are installable via https://brew.sh. Changes are almost exclusively to the Makefiles or (like here) to the configuration.

I admit that I had used Codex to generate these changes. But I have also looked through them and think that they are good. I hope that you embrace these additions, less because of my Mac, more so because of other variants of Linux and why not also prepare for BSD.

NML’s XDR updater is bundled with LinuxCNC, but its serialization routines
come from the system RPC/XDR implementation. The later configure usability
check currently tests get_myaddress, which NML does not call, rather than
the fixed-width XDR interfaces it needs.

This series makes two focused changes:

  • Check the fixed-width integer and memory-stream interfaces already used
    by NML, giving an earlier diagnostic for missing declarations or symbols.
  • Provide small compatibility adapters where equivalent native primitives
    exist but the required fixed-width names are missing, as on the tested
    macOS SDK.

Declared native routines remain preferred. Signedness and wire encodings
are unchanged. The existing RPC header discovery and TI-RPC fallback,
including its get_myaddress library-symbol check, remain unchanged.

smoe added 2 commits November 1, 2026 23:44
NML's CMS_XDR_UPDATER (libnml/cms/cms_xup.cc) serializes through the
system RPC/XDR implementation, but the later usability probe calls
get_myaddress, which NML does not use.

Probe the fixed-width integer filters, xdrmem_create and stream position
and destroy macros that cms_xup.cc already uses. This is expected to be
neutral on working Linux configurations and diagnoses missing declarations
or symbols in config.log before building NML. The probe only compiles
and links; char, bytes, vector, float and double filters are not covered.

Calls use parenthesized names so an undeclared function is an error even
where older C compilers would implicitly declare a plain call. Stream
operation macros remain unparenthesized so they can expand.

The earlier rpc/rpc.h and libtirpc discovery is unchanged, including its
get_myaddress library-symbol check.
Some system RPC/XDR implementations do not declare every fixed-width
filter CMS_XDR_UPDATER uses. The tested macOS SDK omits xdr_int8_t,
xdr_uint8_t and xdr_uint{16,32,64}_t, while providing the corresponding
unsigned xdr_u_int{16,32,64}_t primitives.

Check the five names with AC_CHECK_DECLS. For names not declared,
libnml/cms/nml_xdr_compat.h maps unsigned 16/32/64-bit routines to their
xdr_u_intN_t equivalents, with the same 4/8-byte encodings. The signed and
unsigned 8-bit adapters send one 32-bit XDR word, matching glibc/libtirpc:
decoding narrows without a range check, leaves the destination unchanged
on failure, and XDR_FREE is a no-op.

Declared native routines are always used. Where all five names are
declared, the header only includes rpc/rpc.h and stdint.h. config.h gains
five HAVE_DECL_* results, which cms_xup.cc includes before the header.
The configure probe uses the same compatibility header.

Mark the new header LGPL Version 2, matching the neighboring CMS files.
Comment thread src/configure.ac
AC_MSG_CHECKING([for usable fixed-width RPC/XDR routines])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <rpc/rpc.h>
#include "libnml/cms/nml_xdr_compat.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this fail because config.h is not included?
This looks like a chicken-and-egg problem because config.h is generated by configure but you need it here for a test in configure. Besides, including from the source tree is not a "nice" thing to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants