1 /**************************************************************************/
2 /* ---------------------------------------------------------------------- */
3 /* Copyright (C) 2006 - 2008 FRESCOR consortium partners: */
5 /* Universidad de Cantabria, SPAIN */
6 /* University of York, UK */
7 /* Scuola Superiore Sant'Anna, ITALY */
8 /* Kaiserslautern University, GERMANY */
9 /* Univ. Politécnica Valencia, SPAIN */
10 /* Czech Technical University in Prague, CZECH REPUBLIC */
12 /* Thales Communication S.A. FRANCE */
13 /* Visual Tools S.A. SPAIN */
14 /* Rapita Systems Ltd UK */
17 /* See http://www.frescor.org for a link to partners' websites */
19 /* FRESCOR project (FP6/2005/IST/5-034026) is funded */
20 /* in part by the European Union Sixth Framework Programme */
21 /* The European Union is not liable of any use that may be */
22 /* made of this code. */
25 /* This file is part of FORB (Frescor Object Request Broker) */
27 /* FORB is free software; you can redistribute it and/or modify it */
28 /* under terms of the GNU General Public License as published by the */
29 /* Free Software Foundation; either version 2, or (at your option) any */
30 /* later version. FORB is distributed in the hope that it will be */
31 /* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
32 /* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
33 /* General Public License for more details. You should have received a */
34 /* copy of the GNU General Public License along with FORB; see file */
35 /* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
36 /* Cambridge, MA 02139, USA. */
38 /* As a special exception, including FORB header files in a file, */
39 /* instantiating FORB generics or templates, or linking other files */
40 /* with FORB objects to produce an executable application, does not */
41 /* by itself cause the resulting executable application to be covered */
42 /* by the GNU General Public License. This exception does not */
43 /* however invalidate any other reasons why the executable file might be */
44 /* covered by the GNU Public License. */
45 /**************************************************************************/
48 #define BASIC_TYPES_H 1
58 typedef int16_t CORBA_short;
59 typedef int32_t CORBA_long;
60 typedef int64_t CORBA_long_long;
61 typedef uint16_t CORBA_unsigned_short;
62 typedef uint32_t CORBA_unsigned_long;
63 typedef uint64_t CORBA_unsigned_long_long;
64 typedef float CORBA_float;
65 typedef double CORBA_double;
66 typedef char CORBA_char;
67 typedef int16_t CORBA_wchar;
68 typedef uint8_t CORBA_boolean;
69 typedef uint8_t CORBA_octet;
70 typedef double CORBA_long_double;
76 typedef CORBA_char *CORBA_string;
77 typedef CORBA_wchar *CORBA_wstring;
79 #define CORBA_sequence_get_release(seq) ((seq)->_release)
81 * CORBA_sequence_set_release can be used to set the state of the release flag.
85 * @param val The value of the release flag. If the flag is set to
86 * TRUE, the sequence effectively "owns" the storage pointed to by
87 * _buffer; if FALSE, the programmer is responsible for the storage
90 #define CORBA_sequence_set_release(seq, val) ((seq)->_release = (val))
93 __forb_sequence_alloc_buf_internal(void *seq, size_t seq_size,
94 void **buf_pptr, CORBA_unsigned_long *maximum_ptr,
95 CORBA_unsigned_long num_elements, size_t elem_size);
97 /** @name Sequence helper macros */
103 * @param num_elements
105 * @return CORBA_TRUE if the allocation was sucessfull, CORBA_FALSE if wasn't.
107 #define forb_sequence_alloc_buf(seq, num_elements) \
108 __forb_sequence_alloc_buf_internal((seq), sizeof(*(seq)), \
109 (void**)&(seq)->_buffer, &(seq)->_maximum, \
110 (num_elements), sizeof(*(seq)->_buffer))
112 #define forb_sequence_alloc(seq, num_elements) do { \
113 (seq) = forb_malloc(sizeof(*(seq))); \
114 memset((seq), 0, sizeof(*(seq))); \
115 forb_sequence_alloc_buf((seq), (num_elements)); \
118 static inline void forb_no_destructor() {}
120 #define forb_sequence_free_buf(seq, elem_destructor) do { \
121 if (CORBA_sequence_get_release(seq)) { \
122 CORBA_unsigned_long i; \
123 for (i=0; i<(seq)->_length; i++) { \
124 elem_destructor(&(seq)->_buffer[i]); \
126 forb_free((seq)->_buffer); \
130 #define forb_sequence_free(seq, elem_destructor) do { \
131 forb_sequence_free_buf((seq), (elem_destructor)); \
135 #define forb_sequence_elem(seq, index) ((seq)->_buffer[(index)])
137 #define forb_sequence_length(seq) ((seq)->_length)
138 #define forb_sequence_allocated(seq) ((seq)->_maximum)
139 #define forb_sequence_ensure_allocated(seq, num) \
141 (forb_sequence_allocated(seq) < (num)) ? \
142 (forb_sequence_allocated(seq) = (num), \
143 realloc((seq)->_buffer, (num)*sizeof(*(seq)->_buffer))) : \
146 #define forb_sequence_foreach(seq, elemptr) \
147 for ((elemptr)=&forb_sequence_elem((seq), 0); \
148 (elemptr)<&forb_sequence_elem((seq), forb_sequence_length(seq)); \