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

Bug fixes for CMU Monarch extensions (Solaris 2.7)



Dear ns-users,
	I've been working through the Monarch CMU extensions of ns, 
on a Sun Ultra 5 running Solaris 2.7 over the last week or so.

I've been using 'purify' on this platform and I'd like to report the
following set of changes.  This is just a summary. If you want any 
more details, please send me an email.

It's interesting to note, that most of the 'DSDV' bus errors have now
disappeared, as previously mentioned for Solaris.

I can not tie it down to any one bug, but I've re-written a couple of
sections to do with memory re-allocation and pointer re-assignment.

I must apologise, if these 'changes' have been notified to you all 
before, as I've only been working with the CMU Monarch extensions
for a short time.

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

Changes to CMU Monarch's ns extension code.

Stephen McCann : December 1999

Compiler  : gcc
Op System : Solaris 2.7

C++ compilation fixes
=====================

adhockey-slaver.cc
------------------

//SM - Comment out, as suggested in CMU Monarch's FAQ
//sin.sin_len = sizeof(sin);

//SM - Add this missing type definition
typedef unsigned int u_int32_t;

config.h
--------

//SM - remove signed
typedef char int8_t; 

debug.h
-------

//SM - Add this missing type definition
typedef unsigned int u_int32_t;

tora/tora.cc
------------

//SM - Set 'index' to id. Guess ? Seems to work
int index=atoi(argv[1]);

//SM - Add 'td->' to index. 'tn->' would crash at this point
trace("T %.9f _%d_ received `CLR` from non-neighbor %d",
        CURRENT_TIME, td->index, ih->src_);
                                        
random.cc
---------

//SM Change from 'int' to 'void'
 
#if defined(sun)
extern "C" void srandom(...);
#endif

rng.cc
------

//SM - Change from 'struct timezone *' to 'void*'
int gettimeofday(struct timeval*, void*);
        
C++ link fixes
==============

adhockey-slaver.cc
------------------

// SM - Patch to get this to link
#define inet_aton(a,n) *((unsigned int*)(n))=inet_addr(a)

Memory mistakes
===============

imep/imep_spec.h
----------------

//SM - Solaris 2.7 needs these structures to be 32 bit aligned, so
imep_object
//     needs sorting out, and I've added some padding to it. It's now ok

struct imep_object {
        u_int16_t       o_length;
        // The IMEP spec uses the first bit to determine if this field
        // is 8 or 16 bits.  I fix its length at 16 bits to keep
        // things simple.
//
// SM - See comment above
//
        u_int16_t       solaris_padding;  // My extra 2 bytes of
padding.
        char            o_data[0];
};

dsdv/rtable.cc
--------------

//
// SM Poor assignment of pointers. Rewrite
//

/*
  if (elts == maxelts) {
    rtable_ent *tmp = rtab;
    maxelts *= 2;
    rtab = new rtable_ent[maxelts];
    bcopy(tmp, rtab, elts*sizeof(rtable_ent));
    delete tmp;
  }
*/
  
  if (elts == maxelts) {
    maxelts *= 2;
    rtable_ent *tmp = new rtable_ent[maxelts];
    bcopy(rtab, tmp, elts*sizeof(rtable_ent));
    delete rtab;
    rtab = tmp;
  }

trace.h
-------

//SM - define some constants for the output string lengths
#define MAX_TRACE_OUTPUT 512

trace.cc
--------

/*
 * tack on a newline (temporarily) instead
 * of doing two writes
 */
// 
// SM - Sort out the memory overwites for full buffers
//
                if (n + 1 >= MAX_TRACE_OUTPUT)
                {
                        char* tmp = new char[n+2];
                        strcpy(tmp,wrk_);
                        tmp[n] = '\n';
                        tmp[n+1] = 0;
                        Tcl_Write(channel_, tmp, n + 1);
                        Tcl_Flush(channel_);
                        delete tmp;
                }
                else
                {
                        wrk_[n] = '\n';
                        wrk_[n + 1] = 0;
                        Tcl_Write(channel_, wrk_, n + 1);
                        Tcl_Flush(channel_);
                        wrk_[n] = 0;
                }
...and similar code in the NAM section

Niceties
========

dsdv/rtable.cc
--------------

// SM - Why not 256, it's a bit more efficient !
//      Stops the reallocation of so much memory.
  maxelts = 256;