Eigenstate: myrddin-dev mailing list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

castto


It seems that 'castto' in Go way is much more readable and compact:

  /* myrdin */
  j0  = (c[0] castto(uint32))
  j0 |= (c[1] castto(uint32)) << 8
  j0 |= (c[2] castto(uint32)) << 16
  j0 |= (c[3] castto(uint32)) << 24

  // Go
  j0  = uint32(c[0])
  j0 |= uint32(c[1]) << 8
  j0 |= uint32(c[2]) << 16
  j0 |= uint32(c[3]) << 24

  /* myrdin */
  out[0] = x0 castto(byte)
  out[1] = (x0 >> 8) castto(byte)
  out[2] = (x0 >> 16) castto(byte)
  out[3] = (x0 >> 24)    castto(byte)

  // Go
  out[0] = byte(x0)
  out[1] = byte(x0 >> 8)
  out[2] = byte(x0 >> 16)
  out[3] = byte(x0 >> 24)

btw. code from libcrypto/chacha20.myr... still incomplete :)

Daniel

Follow-Ups:
Re: casttoOri Bernstein <ori@xxxxxxxxxxxxxx>
Re: casttoOri Bernstein <ori@xxxxxxxxxxxxxx>