You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Branko Čibej <br...@wandisco.com> on 2014/11/03 15:41:47 UTC

Re: svn commit: r1628093 - in /subversion/trunk/subversion/libsvn_fs_fs: index.c structure-indexes

On 28.09.2014 19:56, stefan2@apache.org wrote:
> Author: stefan2
> Date: Sun Sep 28 17:56:01 2014
> New Revision: 1628093
>
> URL: http://svn.apache.org/r1628093
> Log:
> Support FSFS format 7 commits in load balanced mixed-architecture clusters.

> +/* Write VALUE to the PROTO_INDEX file, using SCRATCH_POOL for temporary
> + * allocations.
> + *
> + * The point of this function is to ensure an architecture-independent
> + * proto-index file format.  All data is written as unsigned 64 bits ints
> + * in little endian byte order.  64 bits is the largest portable integer
> + * we have and unsigned values have well-defined conversions in C.
> + */
> +static svn_error_t *
> +write_uint64_to_proto_index(apr_file_t *proto_index,
> +                            apr_uint64_t value,
> +                            apr_pool_t *scratch_pool)
> +{
> +  apr_byte_t buffer[sizeof(value)];
> +  int i;
> +  apr_size_t written;
> +
> +  /* Split VALUE into 8 bytes using LE ordering. */
> +  for (i = 0; i < sizeof(buffer); ++i)
> +    {
> +      /* Unsigned conversions are well-defined ... */
> +      buffer[i] = (apr_byte_t)value;
> +      value >>= CHAR_BIT;

Does APR guarantee that sizeof(apr_byte_t) == CHAR_BIT?

-- Brane

Re: svn commit: r1628093 - in /subversion/trunk/subversion/libsvn_fs_fs: index.c structure-indexes

Posted by Branko Čibej <br...@wandisco.com>.
On 03.11.2014 16:16, Stefan Fuhrmann wrote:
> On Mon, Nov 3, 2014 at 3:41 PM, Branko Čibej <brane@wandisco.com
> <ma...@wandisco.com>> wrote:
>
>     On 28.09.2014 19:56, stefan2@apache.org
>     <ma...@apache.org> wrote:
>     > Author: stefan2
>     > Date: Sun Sep 28 17:56:01 2014
>     > New Revision: 1628093
>     >
>     > URL: http://svn.apache.org/r1628093
>     > Log:
>     > Support FSFS format 7 commits in load balanced
>     mixed-architecture clusters.
>
>     > +/* Write VALUE to the PROTO_INDEX file, using SCRATCH_POOL for
>     temporary
>     > + * allocations.
>     > + *
>     > + * The point of this function is to ensure an
>     architecture-independent
>     > + * proto-index file format.  All data is written as unsigned 64
>     bits ints
>     > + * in little endian byte order.  64 bits is the largest
>     portable integer
>     > + * we have and unsigned values have well-defined conversions in C.
>     > + */
>     > +static svn_error_t *
>     > +write_uint64_to_proto_index(apr_file_t *proto_index,
>     > +                            apr_uint64_t value,
>     > +                            apr_pool_t *scratch_pool)
>     > +{
>     > +  apr_byte_t buffer[sizeof(value)];
>     > +  int i;
>     > +  apr_size_t written;
>     > +
>     > +  /* Split VALUE into 8 bytes using LE ordering. */
>     > +  for (i = 0; i < sizeof(buffer); ++i)
>     > +    {
>     > +      /* Unsigned conversions are well-defined ... */
>     > +      buffer[i] = (apr_byte_t)value;
>     > +      value >>= CHAR_BIT;
>
>     Does APR guarantee that sizeof(apr_byte_t) == CHAR_BIT?
>
>
> No. It guarantees that sizeof(apr_byte_t) == 1
> (you probably meant to say that).

Meh, yes I did ...

> APR.H on all
> platform defines it as 'unsigned char' - as opposed
> to apr_uint16_t and friends, which could be anything.

Ack, looks OK then.

-- Brane


Re: svn commit: r1628093 - in /subversion/trunk/subversion/libsvn_fs_fs: index.c structure-indexes

Posted by Stefan Fuhrmann <st...@wandisco.com>.
On Mon, Nov 3, 2014 at 3:41 PM, Branko Čibej <br...@wandisco.com> wrote:

> On 28.09.2014 19:56, stefan2@apache.org wrote:
> > Author: stefan2
> > Date: Sun Sep 28 17:56:01 2014
> > New Revision: 1628093
> >
> > URL: http://svn.apache.org/r1628093
> > Log:
> > Support FSFS format 7 commits in load balanced mixed-architecture
> clusters.
>
> > +/* Write VALUE to the PROTO_INDEX file, using SCRATCH_POOL for temporary
> > + * allocations.
> > + *
> > + * The point of this function is to ensure an architecture-independent
> > + * proto-index file format.  All data is written as unsigned 64 bits
> ints
> > + * in little endian byte order.  64 bits is the largest portable integer
> > + * we have and unsigned values have well-defined conversions in C.
> > + */
> > +static svn_error_t *
> > +write_uint64_to_proto_index(apr_file_t *proto_index,
> > +                            apr_uint64_t value,
> > +                            apr_pool_t *scratch_pool)
> > +{
> > +  apr_byte_t buffer[sizeof(value)];
> > +  int i;
> > +  apr_size_t written;
> > +
> > +  /* Split VALUE into 8 bytes using LE ordering. */
> > +  for (i = 0; i < sizeof(buffer); ++i)
> > +    {
> > +      /* Unsigned conversions are well-defined ... */
> > +      buffer[i] = (apr_byte_t)value;
> > +      value >>= CHAR_BIT;
>
> Does APR guarantee that sizeof(apr_byte_t) == CHAR_BIT?
>

No. It guarantees that sizeof(apr_byte_t) == 1
(you probably meant to say that). APR.H on all
platform defines it as 'unsigned char' - as opposed
to apr_uint16_t and friends, which could be anything.

-- Stefan^2.