mar_cpg.h 3.0 KB

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