3 /* gras/datadesc.h - Describing the data you want to exchange */
5 /* Authors: Martin Quinson */
6 /* Copyright (C) 2003 the OURAGAN project. */
8 /* This program is free software; you can redistribute it and/or modify it
9 under the terms of the license (GNU LGPL) which comes with this package. */
11 #ifndef GRAS_DATADESC_H
12 #define GRAS_DATADESC_H
14 #include <stddef.h> /* offsetof() */
15 #include <sys/types.h> /* size_t */
19 /*! C++ users need love */
22 # define BEGIN_DECL extern "C" {
28 /*! C++ users need love */
36 /* End of cruft for C++ */
41 * Basic types we can embeed in DataDescriptors.
44 {CHAR_TYPE, DOUBLE_TYPE, FLOAT_TYPE, INT_TYPE, LONG_TYPE, SHORT_TYPE,
45 UNSIGNED_INT_TYPE, UNSIGNED_LONG_TYPE, UNSIGNED_SHORT_TYPE, STRUCT_TYPE}
47 #define SIMPLE_TYPE_COUNT 9
49 /*! \brief Describe a collection of data.
51 ** A description of a collection of #type# data. #repetitions# is used only
52 ** for arrays; it contains the number of elements. #offset# is used only for
53 ** struct members in host format; it contains the offset of the member from the
54 ** beginning of the struct, taking into account internal padding added by the
55 ** compiler for alignment purposes. #members#, #length#, and #tailPadding# are
56 ** used only for STRUCT_TYPE data; the #length#-long array #members# describes
57 ** the members of the nested struct, and #tailPadding# indicates how many
58 ** padding bytes the compiler adds to the end of the structure.
61 typedef struct DataDescriptorStruct {
65 /*@null@*/ struct DataDescriptorStruct *members;
69 /** DataDescriptor for an array */
70 #define SIMPLE_DATA(type,repetitions) \
71 {type, repetitions, 0, NULL, 0, 0}
72 /** DataDescriptor for an structure member */
73 #define SIMPLE_MEMBER(type,repetitions,offset) \
74 {type, repetitions, offset, NULL, 0, 0}
75 /** DataDescriptor for padding bytes */
76 #define PAD_BYTES(structType,lastMember,memberType,repetitions) \
77 sizeof(structType) - offsetof(structType, lastMember) - \
78 sizeof(memberType) * repetitions
82 #endif /* GRAS_DATADESC_H */