mar_cpg.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) 2006-2008 Red Hat, Inc.
  3. * Author: Patrick Caulfield (pcaulfie@redhat.com)
  4. *
  5. * All rights reserved.
  6. *
  7. * This software licensed under BSD license, the text of which follows:
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions are met:
  11. *
  12. * - Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. * - Redistributions in binary form must reproduce the above copyright notice,
  15. * this list of conditions and the following disclaimer in the documentation
  16. * and/or other materials provided with the distribution.
  17. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  18. * contributors may be used to endorse or promote products derived from this
  19. * software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  25. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  26. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  27. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  28. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  29. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  30. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  31. * THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #ifndef MAR_CPG_H_DEFINED
  34. #define MAR_CPG_H_DEFINED
  35. #include "cpg.h"
  36. #include "swab.h"
  37. typedef struct {
  38. uint32_t length __attribute__((aligned(8)));
  39. char value[CPG_MAX_NAME_LENGTH] __attribute__((aligned(8)));
  40. } mar_cpg_name_t;
  41. static inline void swab_mar_cpg_name_t (mar_cpg_name_t *to_swab)
  42. {
  43. swab_mar_uint32_t (&to_swab->length);
  44. }
  45. static inline void marshall_from_mar_cpg_name_t (
  46. struct cpg_name *dest,
  47. mar_cpg_name_t *src)
  48. {
  49. dest->length = src->length;
  50. memcpy (&dest->value, &src->value, CPG_MAX_NAME_LENGTH);
  51. }
  52. static inline void marshall_to_mar_cpg_name_t (
  53. mar_cpg_name_t *dest,
  54. struct cpg_name *src)
  55. {
  56. dest->length = src->length;
  57. memcpy (&dest->value, &src->value, CPG_MAX_NAME_LENGTH);
  58. }
  59. typedef struct {
  60. mar_uint32_t nodeid __attribute__((aligned(8)));
  61. mar_uint32_t pid __attribute__((aligned(8)));
  62. mar_uint32_t reason __attribute__((aligned(8)));
  63. } mar_cpg_address_t;
  64. static inline void marshall_from_mar_cpg_address_t (
  65. struct cpg_address *dest,
  66. mar_cpg_address_t *src)
  67. {
  68. dest->nodeid = src->nodeid;
  69. dest->pid = src->pid;
  70. dest->reason = src->reason;
  71. }
  72. static inline void marshall_to_mar_cpg_address_t (
  73. mar_cpg_address_t *dest,
  74. struct cpg_address *src)
  75. {
  76. dest->nodeid = src->nodeid;
  77. dest->pid = src->pid;
  78. dest->reason = src->reason;
  79. }
  80. #endif /* MAR_CPG_H_DEFINED */