octave-maintainers
[Top][All Lists]
Advanced

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

Re: union structures for 64 bit octave


From: David Bateman
Subject: Re: union structures for 64 bit octave
Date: Mon, 30 May 2005 17:35:39 +0200
User-agent: Mozilla Thunderbird 0.8 (X11/20040923)

Clinton Chee wrote:

Hi All,

In the process of checking some 64 bit octave code, I found the use of
some union structures (see below). I've checked the code and don't think
the int in these union structures need to be changed to octave_idx_type.
Can someone confirm this?


in src/unwind-prot.cc

 union
   {
     bool *ptr_to_bool;
     int *ptr_to_int;
     void *gen_ptr;
     void **ptr_to_gen_ptr;
   };

 union
   {
     bool bool_value;
     int int_value;
     const std::string *str_value;
     void *gen_ptr_value;
   };


Does unwind_protect protect octave_idx_type variables? That is the real question. If so then the type index should be added to the enum var_type and the unions about should become

 union
   {
     bool *ptr_to_bool;
     int *ptr_to_int;
     octave_idx_type *ptr_to_index;
     void *gen_ptr;
     void **ptr_to_gen_ptr;
   };

 union
   {
     bool bool_value;
     int int_value;
     octave_idx_type index_value;
     const std::string *str_value;
     void *gen_ptr_value;
   };

You'd then need to add the function

saved_variable::saved_variable (octave_idx_type *p, int v)
{
 type_tag = index;
 ptr_to_index = p;
 index_value = v;
 size = sizeof (octave_idx_type);  // Is this necessary?
}

void
unwind_protect::save_index (octave_idx_type *ptr, octave_idx_type value)
{
 saved_variable *s = new saved_variable (ptr, value);
 add (saved_variable::restore, s);
}

and modify the function

void
saved_variable::restore_value (void)
{
 switch (type_tag)
   {
   case boolean:
     *ptr_to_bool = bool_value;
     break;

   case integer:
     *ptr_to_int = int_value;
     break;

   case index:
      *ptr_to_index = index_value;
       break;

which will allow you to protect octave_idx_type variable... Its probably worth doing this for later use, since its such to be needed eventually, even if it isn't needed now..

in src/ov.h

 union
   {
     octave_value *rep;      // The real representation.
     int count;              // A reference count.
   };

You'd have to have 2^31 octave_value's all point to the same representation for count to need to be changed... I don't think is a problem..


Thanks
Clinton




--
David Bateman                                address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax) 91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary



reply via email to

[Prev in Thread] Current Thread [Next in Thread]