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]

internal error 892


g++ -Wall -g -I/home/local/include    -c tapeIO.cc -o tapeIO.o
tapeIO.cc:66: Internal compiler error 892.
tapeIO.cc:66: Please submit a full bug report to `egcs-bugs@cygnus.com'.
make: *** [tapeIO.o] Error 1
30% 
30% g++ -v
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
31% 
31% uname -a
Linux blues.atd.ucar.edu 2.0.34 #1 Fri May 8 16:05:57 EDT 1998 i686 unknown
Redhat 5.1

.h & .cc file enclosed below.  Let me know if you need more info.  Fails
on Solaris 2.5.1 with same version compiler.

--Chris

/*
-------------------------------------------------------------------------
OBJECT NAME:	tapeIO.h

FULL NAME:	Tape IO class

ENTRY POINTS:	

DESCRIPTION:	

COPYRIGHT:	University Corporation for Atmospheric Research, 1998
-------------------------------------------------------------------------
*/

#ifndef TAPEDRIVE_H
#define TAPEDRIVE_H

#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/mtio.h>

#define RECORDSIZE	0x8000

#ifndef ERR
#define ERR		(-1)
#endif

#ifndef OK
#define OK		0
#endif

/* -------------------------------------------------------------------- */
class TapeDrive
{
public:
	TapeDrive(char fileName[]);
	TapeDrive(int fd);	// Assign open file descriptor
	~TapeDrive();

  int	Stat(struct mtget *);
  long	Seek(long recNum);
  int	Read(char record[]);
  void	Close();

private:
  int	tape_fd;
  long	CurrentPR;

};

#endif


/*
-------------------------------------------------------------------------
OBJECT NAME:	tapeIO.cc

FULL NAME:	Tape IO procedures.

TYPE:		C++

ENTRY POINTS:	Seek(long RecordNumber)
		Read(char *Buffer)
		Stat()
		Close()

DESCRIPTION:	man tapeIO

INPUT:		

OUTPUT:		ERR/OK

REFERENCES:	open, read, close, ioctl

REFERENCED BY:	none
-------------------------------------------------------------------------
*/

#include "tapeIO.h"

#include <fcntl.h>
#include <memory.h>
#include <unistd.h>

#include <cerrno>
#include <cstring>
#include <cstdio>


/* -------------------------------------------------------------------- */
TapeDrive::TapeDrive(char fileName[])
{
  if ((tape_fd = open(fileName, O_RDONLY)) == ERR)
    {
    fprintf(stderr, "TapeDrive: can't open %s\n", fileName);
    Stat(NULL);
    }
  else
    {
    Seek(0L);
    CurrentPR = 0;
    }

}	/* END OPEN */

/* -------------------------------------------------------------------- */
TapeDrive::TapeDrive(int fd)
{
  struct mtget	stat;

  tape_fd = fd;
  Stat(&stat);
  CurrentPR = stat.mt_blkno;

}	/* END ASSIGN */

/* -------------------------------------------------------------------- */
TapeDrive::~TapeDrive(char *name)
{
  Close();

}	/* END DESTRUCTOR */

/* -------------------------------------------------------------------- */
int TapeDrive::Read(char record[])
{
  int		rc;
  struct mtget	stat1, stat2;

  if (tape_fd == ERR)
    return(ERR);

  Stat(&stat1);

  if ((rc = read(tape_fd, record, RECORDSIZE)) == ERR)
    {
    fprintf(stderr, "TapeRead: read error, errno = %d\n", errno);
    Stat(NULL);
    return(ERR);
    }

  if (rc == 0)
    {
    Stat(&stat2);

    if (stat2.mt_fileno == stat1.mt_fileno)
      {
      struct mtop	op;

      op.mt_op = MTBSF;	/* Skip back to prev file */
      op.mt_count = 1;
      ioctl(tape_fd, MTIOCTOP, &op);
      }
    }
  else
    ++CurrentPR;

  return(rc);

}	/* END READ */

/* -------------------------------------------------------------------- */
long TapeDrive::Seek(long start_rec)
{
  struct mtop	tape_op;

  if (tape_fd == ERR)
    return(ERR);

  /* Some attempted optimization.  Assuming Rewind is faster than seeks.
   * If the distance to the new rec is less than the distance from BOT
   * to new rec, then rewind tape first.
   */
  if (start_rec == 0 || (start_rec+5) < CurrentPR / 2)
    {
    printf("Rewinding tape....");

    tape_op.mt_op   = MTREW;
    tape_op.mt_count= 1;

    if (ioctl(tape_fd, MTIOCTOP, &tape_op) == ERR)
      {
      fprintf(stderr, " rewind failed.\n");
      Stat(NULL);
      return(ERR);
      }

    printf("\n");
    tape_op.mt_count = start_rec;
    }
  else
    tape_op.mt_count = start_rec - CurrentPR;

  if (start_rec != 0)
    {
    printf("Skipping %ld records.\n", (long)tape_op.mt_count);
    tape_op.mt_op = MTFSR;

    if (ioctl(tape_fd, MTIOCTOP, &tape_op) == ERR)
      {
      fprintf(stderr, "TapeSeek: seek failed.\n");
      Stat(NULL);
      return(ERR);
      }
    }

  CurrentPR = start_rec;
  Stat(NULL);

  return(CurrentPR);

}	/* END TAPESEEK */

/* -------------------------------------------------------------------- */
void TapeDrive::Close()
{
  if (tape_fd != ERR)
    {
    close(tape_fd);
    tape_fd = ERR;
    }

}	/* END CLOSE */

/* -------------------------------------------------------------------- */
int TapeDrive::Stat(struct mtget *their_stat)
{
  int		rc;
  struct mtget	stat;

  if (tape_fd == ERR)
    return(ERR);

  if ((rc = ioctl(tape_fd, MTIOCGET, &stat)) == ERR)
    {
    fprintf(stderr, "TapeStat: ioctl failed.\n");
    return(ERR);
    }


  if (their_stat)
    memcpy(their_stat, &stat, sizeof(struct mtget));
  else
    {
    printf("TapeStat: CurrentPR=%ld, ", CurrentPR);
    printf("ioctl=%d, dsreg=%ld, erreg=%ld, fileno=%ld, blkno=%ld\n",
	rc, (long)stat.mt_dsreg, (long)stat.mt_erreg, (long)stat.mt_fileno,
	(long)stat.mt_blkno);
    }

  return(OK);

}	/* END STAT */

/* END TAPEIO.CC */


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