Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.misc > #5007

Re: The 8-Byte Two-Step

From Bob Eager <news0002@eager.cx>
Newsgroups comp.misc
Subject Re: The 8-Byte Two-Step
Date 2014-09-20 21:14 +0000
Message-ID <c86928Fkug2U4@mid.individual.net> (permalink)
References <01T8OImfoeUtayhTm1xJJ0vS@dont-email.me>

Show all headers | View raw


On Sat, 20 Sep 2014 20:41:29 +0000, Rich wrote:

> http://zinascii.com/2014/the-8-byte-two-step.html
> 
>    While studying the Illumos queue implementation I came across a line
>    of code that left me quite perplexed.
> 
>    #define MQ_ALIGNSIZE 8 /* 64-bit alignment */ ... temp =
>    (mqhp->mq_maxsz + MQ_ALIGNSIZE - 1) & ~(MQ_ALIGNSIZE - 1);
> 
>    I knew it had something to do with alignment on a 64-bit boundary,
>    but just how the hell was it doing it? Why is it subtracting one from
>    the alignment size? Why is it negating the expression on the right?
>    Why is it adding to the max message size? What the hell is going on?
> 
>    At first I attempted to derive the pattern in my head but kept losing
>    my place; forced to start over multiple times. After placing my pride
>    on the bookshelf next to me, I wrote some C to help decode the
>    mystery. The program breaks the expression into its three parts,
>    printing the base-2 representation of each step. Here are some test
>    runs with different sizes:
> 
>    ...

Standard bit of code. I can't remember when I didn't know that one!



-- 
Using UNIX since v6 (1975)...

Use the BIG mirror service in the UK:
 http://www.mirrorservice.org

Back to comp.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

The 8-Byte Two-Step Rich <rich@example.invalid> - 2014-09-20 20:41 +0000
  Re: The 8-Byte Two-Step Bob Eager <news0002@eager.cx> - 2014-09-20 21:14 +0000
    Re: The 8-Byte Two-Step Marko Rauhamaa <marko@pacujo.net> - 2014-09-21 00:48 +0300
      Re: The 8-Byte Two-Step Bob Eager <news0002@eager.cx> - 2014-09-21 08:27 +0000
        Re: The 8-Byte Two-Step Marko Rauhamaa <marko@pacujo.net> - 2014-09-21 14:14 +0300
          Re: The 8-Byte Two-Step Marko Rauhamaa <marko@pacujo.net> - 2014-09-23 11:19 +0300
          Re: The 8-Byte Two-Step Christian Neukirchen <chneukirchen@gmail.com> - 2014-09-23 18:26 +0200
      Re: The 8-Byte Two-Step mm0fmf <none@mailinator.com> - 2014-09-21 20:45 +0100
  Re: The 8-Byte Two-Step Sylvia Else <sylvia@not.at.this.address> - 2014-09-21 13:42 +1000

csiph-web