bo.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. #include <ip.h>
  12. void
  13. hnputv(void *p, uint64_t v)
  14. {
  15. uint8_t *a;
  16. a = p;
  17. a[0] = v>>56;
  18. a[1] = v>>48;
  19. a[2] = v>>40;
  20. a[3] = v>>32;
  21. a[4] = v>>24;
  22. a[5] = v>>16;
  23. a[6] = v>>8;
  24. a[7] = v;
  25. }
  26. void
  27. hnputl(void *p, uint v)
  28. {
  29. uint8_t *a;
  30. a = p;
  31. a[0] = v>>24;
  32. a[1] = v>>16;
  33. a[2] = v>>8;
  34. a[3] = v;
  35. }
  36. void
  37. hnputs(void *p, uint16_t v)
  38. {
  39. uint8_t *a;
  40. a = p;
  41. a[0] = v>>8;
  42. a[1] = v;
  43. }
  44. uint64_t
  45. nhgetv(void *p)
  46. {
  47. uint8_t *a;
  48. uint64_t v;
  49. a = p;
  50. v = (uint64_t)a[0]<<56;
  51. v |= (uint64_t)a[1]<<48;
  52. v |= (uint64_t)a[2]<<40;
  53. v |= (uint64_t)a[3]<<32;
  54. v |= a[4]<<24;
  55. v |= a[5]<<16;
  56. v |= a[6]<<8;
  57. v |= a[7]<<0;
  58. return v;
  59. }
  60. uint
  61. nhgetl(void *p)
  62. {
  63. uint8_t *a;
  64. a = p;
  65. return (a[0]<<24)|(a[1]<<16)|(a[2]<<8)|(a[3]<<0);
  66. }
  67. uint16_t
  68. nhgets(void *p)
  69. {
  70. uint8_t *a;
  71. a = p;
  72. return (a[0]<<8)|(a[1]<<0);
  73. }