Re: ALIGNOF_CORBA_* defines



You wrote:
> Hi Wim,

> #define ALIGNOF_CORBA_BOOLEAN 1
> > ...
> > #define ALIGNOF_CORBA_DOUBLE 4

> These alignment constants are those used internaly by the compiler
> to layout C structures, they differ per architecture so - for example for
> the following structure:
>
> typedef struct {
> char   a;
> double b;
> int    c;
> } MyStruct;

That means that if I picture marshalling as:

Marshalling
------------
C - struct:      --(1)---->  Independent  ------(2)-->  GIOP message
                             representation.
e.g:
  {
    char a;                  a char `a'                 GIOP message
    double b;                and a double `b'           laying out the
  }                                                     struct.


The ALIGNOF_CORBA_* are only used in step (1).
And a different set of ALIGNMENT numbers, namely the
GIOP specification alignment, is used for step (2).

Now I have two questions:
(I do not understand the ORBit code very well,
So am I probably just confused).


A)
	The function

	static guint8
	oidl_get_tree_alignment (IDL_tree tree)

	in the file orbit-idl-passes.c  (in orbit-idl-compiler)
	uses the #define ALIGNOF_CORBA.
	
	And at first glance it seems that this is used in
		oidl_pass_set_alignment_datum
	and I think that the data computed in this function
	is used for the alignment in the GIOPMessage.
	
	But I would be happy if I am wrong on this.



B)
	It seems that marshalling and demarshalling code is
	incompatible:
	
	Here follow two excerpts from the IDL generated code;
	First the marshalling code in the skeleton
	and than the corresponding demarshalling code in the stub.

	The call I am talking about is defined by:

-------- IDL file ----------------
	interface Echo {
       		 Echo echoString(in string astring, out double anum);
	};
----------------------------------

	The incompatibility I see is the following:
	
	the alignment of double that get marshalled
	is done in the send_buffer.  If you examine
	the function
		giop_message_buffer_do_alignment
	you will see that it will align the data
	with respect to the begining of the
	GIOPMessage.

	However the demarshalling code
	uses ALING_ADRESS on the pointer _ORBIT_curptr,
	which does not align with respect to the
	GIOPMessage, but aligns the absolute adress.

	This seems to go wrong when a
	double is demarshalled in the case that
	the GIOPMessage buffer itself is not
	aligned on a 8 byte boundary.



--------------- Marshalling --------------------
/* this is an exceprt from a skeleton, it
   follows almost directly the actual call into
   user code
*/
....
if (ev->_major == CORBA_NO_EXCEPTION)
	{
	ORBit_marshal_object(_ORBIT_send_buffer, _ORBIT_retval);
	giop_message_buffer_do_alignment
		(GIOP_MESSAGE_BUFFER(_ORBIT_send_buffer), 8);
	giop_message_buffer_append_mem
		(GIOP_MESSAGE_BUFFER(_ORBIT_send_buffer),
		&(anum),
		sizeof(anum));
	} else
...
-----------------------------------------------------------	

--------------- Demarshalling ----------------------
/* This is the corresponding demarshalling in the
   calling stub.
*/
...
	GIOP_RECV_BUFFER(_ORBIT_recv_buffer)->cur = _ORBIT_curptr;
	_ORBIT_retval = ORBit_demarshal_object
		(_ORBIT_recv_buffer, 	
		GIOP_MESSAGE_BUFFER
			(_ORBIT_recv_buffer)->connection->orb_data);

	_ORBIT_curptr = GIOP_RECV_BUFFER(_ORBIT_recv_buffer)->cur;
	_ORBIT_curptr = ALIGN_ADDRESS(_ORBIT_curptr, 8);
	(*anum) = *((CORBA_double*)_ORBIT_curptr);
....
------------------------------------------------------



=========================================================
=========================================================


Wim Oudshoorn.







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]