Repository navigation
xdr upstream readable #4762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
smoe
wants to merge
3
commits into
LinuxCNC:master
Choose a base branch
from
smoe:codex/xdr-upstream-readable
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
xdr upstream readable #4762
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* Fixed-width XDR names used by cms_xup.cc but missing from some system | ||
| RPC/XDR implementations. Prefer declared native routines; fill only gaps. | ||
| HAVE_DECL_* come from the included config.h. | ||
|
|
||
| License: LGPL Version 2 or later */ | ||
| #ifndef LIBNML_CMS_NML_XDR_COMPAT_H | ||
| #define LIBNML_CMS_NML_XDR_COMPAT_H | ||
|
|
||
| #include "config.h" | ||
| #include <rpc/rpc.h> | ||
| #include <stdint.h> | ||
|
|
||
| /* An undefined HAVE_DECL_* would read as 0 below and mask a native routine. */ | ||
| #if !defined(HAVE_DECL_XDR_INT8_T) || !defined(HAVE_DECL_XDR_UINT8_T) || \ | ||
| !defined(HAVE_DECL_XDR_UINT16_T) || !defined(HAVE_DECL_XDR_UINT32_T) || \ | ||
| !defined(HAVE_DECL_XDR_UINT64_T) | ||
| #error "XDR declaration results are missing (HAVE_DECL_XDR_*)" | ||
| #endif | ||
|
|
||
| /* Alternate unsigned names with the same 4/8-byte XDR encodings. */ | ||
| #if !HAVE_DECL_XDR_UINT16_T | ||
| #define xdr_uint16_t xdr_u_int16_t | ||
| #endif | ||
| #if !HAVE_DECL_XDR_UINT32_T | ||
| #define xdr_uint32_t xdr_u_int32_t | ||
| #endif | ||
| #if !HAVE_DECL_XDR_UINT64_T | ||
| #define xdr_uint64_t xdr_u_int64_t | ||
| #endif | ||
|
|
||
| /* One 32-bit XDR word; decode narrows without range checks, as in | ||
| glibc/libtirpc. Failed decodes leave *p unchanged. */ | ||
| #if !HAVE_DECL_XDR_INT8_T | ||
| static inline bool_t nml_xdr_int8_t(XDR *xdrs, int8_t *p) | ||
| { | ||
| int32_t t; | ||
| switch (xdrs->x_op) { | ||
| case XDR_ENCODE: | ||
| t = *p; | ||
| return (xdr_int32_t)(xdrs, &t); | ||
| case XDR_DECODE: | ||
| if (!(xdr_int32_t)(xdrs, &t)) | ||
| return FALSE; | ||
| *p = (int8_t) t; | ||
| return TRUE; | ||
| case XDR_FREE: | ||
| return TRUE; | ||
| } | ||
| return FALSE; | ||
| } | ||
| #define xdr_int8_t nml_xdr_int8_t | ||
| #endif | ||
|
|
||
| #if !HAVE_DECL_XDR_UINT8_T | ||
| static inline bool_t nml_xdr_uint8_t(XDR *xdrs, uint8_t *p) | ||
| { | ||
| uint32_t t; | ||
| switch (xdrs->x_op) { | ||
| case XDR_ENCODE: | ||
| t = *p; | ||
| return (xdr_u_int32_t)(xdrs, &t); | ||
| case XDR_DECODE: | ||
| if (!(xdr_u_int32_t)(xdrs, &t)) | ||
| return FALSE; | ||
| *p = (uint8_t) t; | ||
| return TRUE; | ||
| case XDR_FREE: | ||
| return TRUE; | ||
| } | ||
| return FALSE; | ||
| } | ||
| #define xdr_uint8_t nml_xdr_uint8_t | ||
| #endif | ||
|
|
||
| #endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an assumption that
xdr_int16_t,xdr_int32_tandxdr_int64_texist unconditionally, while the unsigned versions is tested for. But not for the 8-bit version.What are the guarantees that, for example,
xdr_int64_texists. The 64-bit version is also likely to be missing with old lib versions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I am not with you. There is no assumption that every RPC library provides these functions. AC_CHECK_DECLS selects the available adaptations; the following AC_LINK_IFELSE requires the signed 16-, 32- and 64-bit routines. An older library missing one will fail configure. NML already uses these routines unconditionally. Will add a respective comment.