Skip to content

posemath: drop the dead knobs and give it its own directory - #4387

Open
grandixximo wants to merge 2 commits into
LinuxCNC:masterfrom
grandixximo:posemath-cleanup
Open

posemath: drop the dead knobs and give it its own directory#4387
grandixximo wants to merge 2 commits into
LinuxCNC:masterfrom
grandixximo:posemath-cleanup

Conversation

@grandixximo

Copy link
Copy Markdown
Contributor

Following on from the review discussion in #4375, where the posemath headers came up and the answer was that the code has been misplaced in libnml for some time. This is the first two steps of the five I sketched there, and the two that stand on their own.

A. Drop the knobs that are never turned.

USE_CONST, USE_CCONST and USE_REF are defined unconditionally at the top of the header and select PM_CONST, PM_CCONST and PM_REF. Every declaration in the file is written through that indirection, so reading a signature means resolving three macros to find out that they mean const, const and &. The macros are substituted out.

INCLUDE_POSEMATH_COPY_CONSTRUCTORS is guarded by #if __cplusplus < 201103L, and the tree builds as C++20, so its 13 blocks in each file have not been compiled in a long time. PM_LOOSE_NAMESPACE is defined nowhere. Four #if 0 blocks go with them.

What stays is the one deliberate poison macro for pmCartNorm(), which exists to make a use fail to compile rather than to be compiled out.

No behaviour change: the preprocessor already resolved every one of these the same way on every build in the tree. 338 lines out, 50 in.

B. Move it out of libnml.

git mv src/libnml/posemath src/libposemath. posemath includes nothing from NML and uses nothing from it; the only edge between them runs the other way, in cms_pm.cc. The move is the sources plus the paths that named the old location: the Submakefile prefixes, SRCHEADERS and the per-module object lists in src/Makefile, two USE_TOPDIR includes in tpcomp.comp, and the debian/copyright stanza. libposemath gets its own SUBDIRS entry rather than one buried in the libnml group. All eight source files are detected as pure renames.

Testing.

Configured --with-realtime=uspace and built clean, no errors and no warnings.

libposemath.so.0 exports the same 390 symbols before and after, byte identical lists from nm -D --defined-only. That is the evidence that A changes nothing: it is a large diff that the compiler cannot tell apart from the original.

include/ holds the same 38 headers with the same names, so the installed surface is untouched by the move.

scripts/runtests over blendmath, realtime-math, interp, ccomp and matrixkins: 90 run, 90 successful, 0 failed, 1 skipped, 0 shmem errors.

All nine kinematics modules that link a posemath object load under halrun: genser, scara, puma, genhex, penta, 5axis, three21, rotarydelta, triv.

What comes next, separately.

C splits the header by language behind the existing umbrella, D folds emcpos.h and emcpose.h into one header beside posemath, and E takes gomath.h, gotypes.h and sincos.h off the exported list. Those are written and tested but want their own review, since each changes what the tree installs.

Comment thread src/hal/components/tpcomp.comp
Comment thread src/libposemath/posemath.h
Comment thread src/libposemath/Submakefile
@grandixximo

Copy link
Copy Markdown
Contributor Author

Need me to rebase here? I have the follow up ready, do we need to run this trough weekly meeting?

Comment thread src/libnml/posemath/posemath.h
@BsAtHome

Copy link
Copy Markdown
Contributor

Rebase would be nice to see if there is any change that altered behaviour.

posemath.h carries four switches that have only ever had one setting, and
they hide what the declarations actually say.

USE_CONST, USE_CCONST and USE_REF are defined unconditionally a few lines
above the blocks that test them, so PM_CONST and PM_CCONST are always
const and PM_REF is always a reference.  Spelling them out turns
declarations like

    PM_CARTESIAN(PM_CONST PM_SPHERICAL PM_REF s);

into what they have always meant:

    PM_CARTESIAN(const PM_SPHERICAL & s);

INCLUDE_POSEMATH_COPY_CONSTRUCTORS is guarded by __cplusplus < 201103L, so
it is never defined in a tree built as C++20.  The comment beside it
already explains that the compiler generates better copy constructors than
the ones it hides, and every one of them has been dead code since the move
to C++11.

PM_LOOSE_NAMESPACE would typedef VECTOR, MATRIX, POSE and friends into the
global namespace.  Nothing defines it.

The remaining #if 0 blocks go too: the norm() declarations and their
definitions, and a note about a call being ambiguous on g++ 2.8 and 2.9.
The deliberate poison macro for pmCartNorm() stays, since it is there to
turn a use into a compile error rather than to be compiled out.

No behaviour change: the preprocessor already resolved all of this the same
way on every build.
posemath is not part of NML and never has been.  It includes nothing from
libnml, uses none of its types, and builds into its own shared library,
libposemath.so.  The only edge between them runs the other way: cms_pm.cc
includes <posemath.h> to serialise the classes.

Sitting inside libnml/ made it look like an NML component, which is
misleading for anyone reading the tree and awkward for anything that wants
to depend on the maths without the messaging.

Pure move.  The files are unchanged, and what follows is the paths that
named the old location: the Submakefile's own prefixes, the SRCHEADERS
entries and per-module object lists in src/Makefile, the two USE_TOPDIR
includes in tpcomp.comp, and the copyright stanza in debian/.

SUBDIRS gains libposemath as an entry of its own rather than one buried in
the libnml group, since that grouping was the thing being corrected.
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