This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

bug report


This is a result I obtained while trying to use stat();
Please see attached file if You are interested.

 L-zr
// following result was obtained
// note that the file is edited and line no's does NOT match

ebcw241{ebcblaz}: g++ -o dr DR.cxx
DR.cxx: In function `int main()':
DR.cxx:313: warning: invalid use of type decl `typedef long int off_t' as expression
DR.cxx:313: Internal compiler error 40.
DR.cxx:313: Please submit a full bug report to `egcs-bugs@cygnus.com'.
ebcw241{ebcblaz}: 

ebcw241{ebcblaz}: g++ -v
 gcc -v
Reading specs from /usr/local/gnu/gcc/sun5/lib/gcc-lib/sparc-sun-solaris2.3/2.7.0/specs
gcc version 2.7.0

// please searc for 'bug' and You will find the code 
// that induced this result !!!

//******************************************************************************
//
// Component = DR - prototype simple loader function (user mode)
// Module    = DR.cxx
//
// Synopsis  = A very first Lynx loader
// 
//******************************************************************************
//==============================================================================
// Temporary INCLUDES and MACROS (DEBUG only)
//==============================================================================
#define DEBUG
#include <stdlib.h>

#define TRUE 1
#define FALSE 0

//==============================================================================
// INCLUDES
//==============================================================================
//------------------------------------------------------------------------------
// I/O stream system calls 
//------------------------------------------------------------------------------
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <errno.h>

//------------------------------------------------------------------------------
// File handling system calls 
//------------------------------------------------------------------------------
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

//------------------------------------------------------------------------------
// String manipulation system calls 
//------------------------------------------------------------------------------
#include <string.h>

//------------------------------------------------------------------------------
// Marshal
//------------------------------------------------------------------------------
// #include "marshal.h"

//------------------------------------------------------------------------------
// REREQ
//------------------------------------------------------------------------------
// #include "REREQ.h"

//------------------------------------------------------------------------------
// DR specific 
//------------------------------------------------------------------------------
#include "DR.h"

//==============================================================================
// MACROS
//==============================================================================
#define INL_PATH "/INL/"


//==============================================================================
// Temporary typedefs and declarations.
//==============================================================================
typedef char 		unitName_t[8];
typedef pid_t		BRT_Entry_t;
typedef BRT_Entry_t	BRT_Table_t[1024];


// typedef
// struct GETNEXTUNIT_s
// {
//    uint32	header;
//    uint16	unit;
   
// } GETNEXTUNIT_t;

// typedef
// struct GETNEXTUNITRET_s
// {
//    uint32	header;
//    uint16	unit;
//    uint8	type;
   
// } GETNEXTUNITRET_t;


unitName_t		unitNameArr[1024];
BRT_Table_t		BRT;
		
//==============================================================================
// Temporary functions
//==============================================================================
//------------------------------------------------------------------------------
// Old PRP system call interface
//------------------------------------------------------------------------------
static void
getNextUnit(unsigned int unit)
{   
   for (; unit < 1024; unit++)
   {
      if (BRT[unit] != 0) return;
   }
   
   unit = 0;
}

//------------------------------------------------------------------------------
// System table handling
//------------------------------------------------------------------------------
// buildUnitNameArr
// ----------------
// This function initilizes a table which stores all unit names. This table
// is indexed using unit ID (old PLEX PU no).
//
// This function is a really temporary solution. This information is supposed 
// to be retrieved from some kind of PIB/DST information from the loadable.
//------------------------------------------------------------------------------
void
buildUnitNameArr()
{
   unitName_t *unitPtr;
   
   //***************************************************************************
   // Initialize the table with empty strings.
   //***************************************************************************
   for (unitPtr = &unitNameArr[0]; unitPtr <= &unitNameArr[1023]; unitPtr++)
   {
      strcpy((char*)unitPtr, "");
   }
   
   //***************************************************************************
   // Initialize the positions really used.
   //***************************************************************************
   strcpy((char*)unitNameArr[4], "RER");
   
   strcpy((char*)unitNameArr[10], "PROC1.P");
   strcpy((char*)unitNameArr[11], "PROC2.P");
   strcpy((char*)unitNameArr[12], "PROC3.P");
   strcpy((char*)unitNameArr[13], "PROC4.P");
   strcpy((char*)unitNameArr[14], "PROC5.P");
   strcpy((char*)unitNameArr[15], "PROC6.P");
   
//   strcpy((char*)unitNameArr[PRP], "PRP");
}

//------------------------------------------------------------------------------
// initialize_BRT
// ----------------
// This function initilizes BRT with Lynx identification of the unit.
//------------------------------------------------------------------------------
static void
initialize_BRT()
{
   BRT_Entry_t* unitPtr;
   
   for (unitPtr = &BRT[0]; unitPtr <= &BRT[1023]; unitPtr++)
   {
      *unitPtr = 0;
   }
}

//------------------------------------------------------------------------------
// getUnitID
// ---------
//------------------------------------------------------------------------------
static void
getUnitID(
   char* unit, 
   int len, 
   char* uID, 
   int* l_uID) 
{ 
   bool  match = false;
   
   char *cp1, *cp2;
   
   for(int step=0; (step < 1024) && (!match); step++ ) 
   {
      
      if (unitNameArr[step] != "")
      {
         cp1   = unit;
         cp2   = (char*)unitNameArr[step];
         match = true;
         
         for(int i = 0; i < len; i++, cp1++, cp2++)
         {
            if (*cp1 != *cp2)
            {
               match = match && false; 
               break;        
            }
         }
      
         if (match)
         {
            //---------------------------------------------------------------------
            // The uID is going to be passed as argv[0] and contain the two
            // bytes of unit no terminated with a null.
            //---------------------------------------------------------------------
            *(uID)     = step / 0x100;
            
            if ( *(uID) )
            {
               *(uID + 1) = step % 0x100;
               *(uID + 2) = 0;
            }
            else
            {
               *(uID)     = step % 0x100;
               *(uID + 1) = 0;
            }
            
            *(l_uID)   = step;
            
         }
      }
      
   }
}


//==============================================================================
// This is an embedded load actor, DR, which in it's main thread loads all
// actors to be executed in user mode.
//
// Right now it only loads the SEH actor (hard coded), but later will load 
// all actors specified in the NECPUF file at the INL directory.
//==============================================================================
main()
{
    //==========================================================================
    // Declarations
    //==========================================================================
    int 	result;
    char*	argv[2];
    char	fileName[80];
    char	pathName[80];
    char*	unitNamePtr;
    int		unitNameLength;    
    char	unitID[2];
    int		localUnitID;
    
    int		ownSiteID;
    int		ownUnitID = 0;
    
//    ifstream	necpuf("/INL/NECPUF", ios::in);

    FILE* necpuf;
    
    
//    uint32	REREQ_ID;
    
//    KnUniqueId  RER_PortUi;
    
//    KnUniqueId  receivePortUi;
//    int		receivePortLi;
//    KnMsgDesc   recMsgDesc;       // Message descriptor for ipcReceive
//    KnMsgDesc   replyMsgDesc;       // Message descriptor for ipcReply
    
//    KnIpcDest   ipcDestAddress;    	// The address for the IPC
//    KnMsgDesc   sendMsgDesc;       // Message descriptor for ipcSend
    
//    am_cred_t	actorCred, testCred, tCred;
    
//    long	envValue;
//    unsigned int		size;
    
//    GETNEXTUNIT_t	GETNEXTUNIT;
//    GETNEXTUNITRET_t	GETNEXTUNITRET;
    
//    uint16		unit;

    //==========================================================================
    cout << "MD LOADER is started " << endl;
        
    //--------------------------------------------------------------------------
    // TEMPORARY: build unit array
    //--------------------------------------------------------------------------
    buildUnitNameArr();
    
    FILE *configLoc;
    char necpufFileSpec[80]; 
    if (configLoc = fopen("CONFIGLOC", "r"))
    {
       fgets(necpufFileSpec, 79, configLoc);
       fclose(configLoc);
    }
    else
    {
       cout << "MD LOADER: failed to open NECPUFLOC file: " << endl;
       return 0;
    }
   
    { // prepare path and file
    char *cP;
    if (cP = strrchr(necpufFileSpec,'/'))
     *(++cP) = '\0';
    
    strcat(necpufFileSpec,"NECPUF");
    }
  
// bug bug bug bug 
// bug bug bug bug   below these lines
// bug bug bug bug    
  
    {// find filesize
    struct stat fStat;
    if (stat(necpufFileSpec, &fStat))
    {
       cout << "MD LOADER: " << necpufFileSpec << " not found" << endl;
    } 
     
    cout << fStat.off_t << endl;  // <-- error code appeared after adding this
    
// bug bug bug bug  
// bug bug bug bug   above these lines
// bug bug bug bug         
         
    return 0;
  
    if (!(necpuf = fopen(necpufFileSpec, "r")))
    {
       cout << "MD LOADER: failed to open NECPUF file: " << necpufFileSpec << endl;
       return 0;
    }
      
              
    while ( fgets(fileName, 79, necpuf) )
    {
       //-----------------------------------------------------------------------
       // Create file path
       //-----------------------------------------------------------------------
       
       // ebcblaz: removed, path is included in NECPUF file
       //strcpy(pathName, INL_PATH);
       //strcat(pathName, fileName);
       strcpy(pathName,"");

#ifdef DEBUG       
       cout << "MD LOADER: pathName is " << pathName << endl;
       cout << "MD LOADER: fileName is " << fileName << endl;

       getchar();       
#endif

       //-----------------------------------------------------------------------
       // Here, the program file should be opened, and information would be
       // retrieved from the PIB.
       //
       // Since we don't have any build chain yet, the temporary solutions
       // is to create the program name from the file name of the .P-file. The
       // program unit number is obtained from a temporary translation table,
       // which is the MD_Units.h.
       //-----------------------------------------------------------------------
       //unitNamePtr = strtok(fileName, ".");
       
       {  // remove end of line
          char *cP;
          if (cP = strstr(fileName,"\n"))
             *cP = '\0';
       }        
       
       if (unitNamePtr = strrchr(fileName,'/'))
          unitNamePtr++;
       else
          unitNamePtr = fileName;
          
       
       
       getUnitID(unitNamePtr, strlen(unitNamePtr), (char*) unitID, &localUnitID);
                  
       BRT[localUnitID] = getpid();
       
       cout << "MD LOADER: loading from NECPUF ... unit is " << unitNamePtr << 
                " unit no is " << localUnitID << endl;
       
       
       //--------------------------------------------------------------------------
       // Perform the afexecve system call (load and start the main thread of
       // the "unit").
       //--------------------------------------------------------------------------
       if (fork() == 0)
       {
          //-----------------------------------------------------------------------
          // Now  we  are the new process. Let's call main(...). The exec call
          // never returns.
          //
          // Either we set the process characteristics here, before the execve
          // call, or in the glue main() function.
          //-----------------------------------------------------------------------
         
          cout << "Fork successful!" << endl;
          fclose(necpuf);
          argv[0] = unitID;
          argv[1] = 0;

          // LOJJA BOOKMARK: Det nya programmet kör aldrig igång (man får inga
          // utskrifter). Kolla varför!!!!!
          
          //if (execv((char*) &fileName, argv) )
          {
          //   cout << "New program exec failed ...." << endl;
          }
          exit(0);
       }

    }
   
    }
     
    fclose(necpuf);
        
#ifdef DEBUG
    cout << "MD LOADER: NECPUF loading successfull ... " << endl;
#endif

    //--------------------------------------------------------------------------
    // Send REREQ to RER to initiate LIM start after initial load
    //--------------------------------------------------------------------------
    // result = uiLocalSite(&ownSiteID);
#ifdef DEBUG
    // if (result < 0)
    // {
    //    cout << "MD LOADER ERROR: site id could not be obtained, " << endl;
    // }
    // else
    // {
    //    cout << "MD LOADER: Site # = " << (void*)ownSiteID << endl;
    // }
#endif
#ifdef RPC_TEST
    // result = uiBuild(&RER_PortUi, K_UIPORT,ownSiteID, 0x101, REREQ_LEVEL);
#else
    // result = uiBuild(&RER_PortUi, K_UIPORT,ownSiteID, RER, REREQ_LEVEL);
#endif

#ifdef DEBUG
    // if (result < 0)
    // {
    //    cout << "MD LOADER ERROR: port id could not be built for RER " << endl;
    // }
    // else
    // {
    //    cout << "MD LOADER - RER port ID is " << (void*)RER_PortUi.uiHead << " : " << (void*)RER_PortUi.uiTail << endl;
    // }
#endif
    
    // ipcDestAddress.target = RER_PortUi;
    
    // REREQ_ID = REREQ_SN;
    
    // sendMsgDesc.bodySize = 4;
    // sendMsgDesc.bodyAddr = (VmAddr)&REREQ_ID;
    // sendMsgDesc.flags = 0;
    // sendMsgDesc.annexAddr = (VmAddr) 0;
    
    // result = ipcSend(&sendMsgDesc, K_DEFAULTPORT, &ipcDestAddress);
    
#ifdef DEBUG
    // if (result < 0)
    // {
    //    cout << "MD LOADER ERROR: IPC could not be sent to RER " << endl;
    // }
#endif
   //--------------------------------------------------------------------------
   // Wait for "getnextunit" (temporary solution) ...
   //--------------------------------------------------------------------------
   // Build the thread IPC reception port UID.
   //--------------------------------------------------------------------------
   // cout << "MD LOADER: building thread reception port... " 
   //      << endl;

   // result = uiBuild(&receivePortUi,
   //                 K_UIPORT, 
   //                 ownSiteID, 
   //                 ownUnitID,
   //                 B_LEVEL);
    

   //--------------------------------------------------------------------------
   // Declare an IPC reception port.
   //--------------------------------------------------------------------------
   // receivePortLi = portDeclare(K_MYACTOR, &receivePortUi);
    
   // recMsgDesc.flags     = 0;	
   // recMsgDesc.bodySize  = sizeof(GETNEXTUNIT);
   // recMsgDesc.bodyAddr  = (VmAddr) &GETNEXTUNIT;
   // recMsgDesc.annexAddr = (VmAddr)0;
        
   // do
   // {
#ifdef DEBUG
   //    cout << "MD LOADER: waiting for RPC ..." << endl;
#endif
   //    result = ipcReceive(&recMsgDesc, &receivePortLi, -1);
       
#ifdef DEBUG
   //    cout << "MD LOADER: received GETNEXTUNIT ... " << endl;
#endif
              
   //    unit = GETNEXTUNIT.unit;
#ifdef DEBUG
   //    cout << "MD LOADER: input unit is " << (void*)unit << endl;
#endif
   //    getNextUnit(unit);
       
#ifdef DEBUG
   //    cout << "MD LOADER: output unit is " << (void*)unit << endl;
#endif
       // Assign IPC "PLEX" header, ie signal number
         //--------------------------------------------------------------------------
   //    GETNEXTUNITRET.header = 0;		
   //    GETNEXTUNITRET.unit   = unit;			
   //    GETNEXTUNITRET.type   = 0;	
         
       //--------------------------------------------------------------------------
       // Prepare the request message descriptor for the RPC call.
       //--------------------------------------------------------------------------
   //    replyMsgDesc.bodySize = 7;
   //    replyMsgDesc.bodyAddr  = (VmAddr) &GETNEXTUNITRET;
   //    replyMsgDesc.flags     = 0;
   //    replyMsgDesc.annexAddr = (VmAddr) 0;			// No annex information

   //    result = ipcReply(&replyMsgDesc);
         
#ifdef DEBUG
   //    if (result < 0)
   //    {
   //       cout << "MD LOADER: RPC reply ERROR " << endl;
   //    }
#endif 
   // } while (TRUE);


   return 0;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]