[PATCH 1/3] Add rtems_filesystem_make_dev_t_from_pointer()

Nick Withers nick.withers at anu.edu.au
Wed Feb 4 23:53:20 UTC 2015


On Wed, 2015-02-04 at 19:14 +0100, Sebastian Huber wrote:
> On 02/04/2015 05:36 PM, Daniel Gutson wrote:
> > On Wed, Feb 4, 2015 at 1:27 PM, Gedare Bloom<gedare at gwu.edu>  wrote:
> >> >
> >> >On Wed, Feb 4, 2015 at 11:16 AM, Daniel Gutson
> >> ><daniel.gutson at tallertechnologies.com>  wrote:
> >>> > >Hi Sebastian,
> >>> > >
> >>> > >On Wed, Feb 4, 2015 at 10:46 AM, Sebastian Huber
> >>> > ><sebastian.huber at embedded-brains.de>  wrote:
> >>>> > >>
> >>>> > >>---
> >>>> > >>  cpukit/libcsupport/include/rtems/libio.h | 10 ++++++++++
> >>>> > >>  1 file changed, 10 insertions(+)
> >>>> > >>
> >>>> > >>diff --git a/cpukit/libcsupport/include/rtems/libio.h
> >>>> > >>b/cpukit/libcsupport/include/rtems/libio.h
> >>>> > >>index a4607de..998cd30 100644
> >>>> > >>--- a/cpukit/libcsupport/include/rtems/libio.h
> >>>> > >>+++ b/cpukit/libcsupport/include/rtems/libio.h
> >>>> > >>@@ -1442,6 +1442,16 @@ static inline dev_t rtems_filesystem_make_dev_t(
> >>>> > >>    return temp.device;
> >>>> > >>  }
> >>>> > >>
> >>>> > >>+static inline dev_t rtems_filesystem_make_dev_t_from_pointer(
> >>>> > >>+  const void *pointer
> >>>> > >>+)
> >>>> > >>+{
> >>>> > >>+  uint64_t one = 1;
> >>>> > >>+  uint64_t temp = (one << 63) | (((uintptr_t) pointer) >> 1);
> >>> > >
> >>> > >
> >>> > >Sorry the irrelevant detail, but may I ask why not
> >>> > >
> >>> > >     (((uint64_t)1) << 63) ...
> >>> > >
> >>> > >?
> >>> > >
> >> >Or (1UL << 63)
> > It could be 1ULL, but AFAIK it is platform-dependent, so I preferred
> > the explicit cast.
> >
> 
> Yes, 1UL is wrong. Nice would be UINT64_C(1), but this is not available 
> in all C++ versions. I change it to the cast, but I don't think it 
> really matters.

Since we're on the topic...

((uint64_t) 1U << 63)

is my preferred scheme, and makes no assumptions about widths (well,
other than uint64_t :-P).

Just my $AU0.02 :-)
--
Nick Withers

Embedded Systems Programmer
Department of Nuclear Physics
Research School of Physics and Engineering
The Australian National University





More information about the devel mailing list