Thread View: gnu.g++.bug
1 messages
1 total messages
Started by Dirk Grunwald
Wed, 18 Oct 1989 20:32
bug in latest (10/17) g++.xtar.Z
Author: Dirk Grunwald
Date: Wed, 18 Oct 1989 20:32
Date: Wed, 18 Oct 1989 20:32
1845 lines
51682 bytes
51682 bytes
configuration: g++.xtar.Z of evening 10/17 compiled by gcc.c with several
destation patches
symptoms: following file causes compiler to drop core with message...
g++ -I. -I../Src -O -c ../Src/MonitorSimMux.cc
In file included from ../Src/MonitorSimMux.cc:7:
../Src/MonitorSimMux.h:23: Segmentation violation
g++: Program cc1plus got fatal signal 11.
--------------------expanded file MonitorSimMux.cc--------------------
# 1 "../Src/MonitorSimMux.cc"
# 1 "../Src/MonitorSimMux.h" 1
#pragma once
# 1 "../Src/MultiSimMux.h" 1
#pragma once
# 1 "../Src/SimulationMultiplexor.h" 1
#pragma once
# 1 "../Src/CpuMultiplexor.h" 1
#pragma once
# 1 "./AwesimeConfig.h" 1
#pragma once
# 11 "../Src/CpuMultiplexor.h" 2
# 1 "./HardwareContext.h" 1
#pragma once
# 1 "/usr/local/Gnu/lib/g++-include/stream.h" 1
#pragma once
# 1 "/usr/local/Gnu/lib/g++-include/File.h" 1
#pragma once
# 1 "/usr/local/Gnu/lib/g++-include/builtin.h" 1
#pragma once
typedef void (*one_arg_error_handler_t)(const char*);
typedef void (*two_arg_error_handler_t)(const char*, const char*);
# 1 "/usr/local/Gnu/lib/g++-include/stddef.h" 1
#pragma once
typedef unsigned char wchar_t;
# 40 "/usr/local/Gnu/lib/g++-include/builtin.h" 2
# 1 "/usr/local/Gnu/lib/g++-include/std.h" 1
#pragma once
extern "C" {
void volatile _exit(int);
void volatile abort(void);
int access(const char*, int);
int acct(const char*);
unsigned alarm(unsigned);
double atof(const char*);
int atoi(const char*);
long atol(const char*);
int bcmp(const void*, const void*, int);
void bcopy(const void*, void*, int);
int bind(int, void*, int);
int brk(void*);
int bsearch (const void *, const void *, unsigned long,
unsigned long, auto int (*ptf)(const void*, const void*));
void bzero(void*, int);
void* calloc(unsigned, unsigned);
void cfree(void*);
int chdir(const char*);
int chmod(const char*, int);
int chown(const char*, int, int);
long clock(void);
int close(int);
int creat(const char*, unsigned long int);
char* crypt(const char*, const char*);
char* ctermid(char*);
char* cuserid(char*);
double drand48(void);
int dup(int);
int dup2(int, int);
int dysize(int);
char* ecvt(double, int, int*, int*);
char* encrypt(char*, int);
double erand(short*);
int execl(const char*, const char *, ...);
int execle(const char*, const char *, ...);
int execlp(const char*, const char*, ...);
int exect(const char*, const char**, char**);
int execv(const char*, const char**);
int execve(const char*, const char**, char**);
int execvp(const char*, const char**);
void volatile exit(int);
int fchmod(int, int);
int fchown(int, int, int);
int fcntl(int, int, ...);
char* fcvt(double, int, int*, int*);
int ffs(int);
int flock(int, int);
int fork(void);
void free(void*);
int fsync(int);
long ftok(const char*, int);
int ftruncate(int, unsigned long);
char* gcvt(double, int, char*);
char* getcwd(char*, int);
int getdomainname(char*, int);
int getdtablesize(void);
int getegid(void);
char* getenv(const char*);
int geteuid(void);
int getgid(void);
int getgroups(int, int*);
long gethostid(void);
int gethostname(char*, int);
char* getlogin(void);
int getopt(int, char**, char*);
int getpagesize(void);
char* getpass(const char*);
int getpgrp(void);
int getpid(void);
int getppid(void);
int getpriority(int, int);
int getpw(int, char*);
unsigned getuid(void);
char* getwd(char*);
char* index(const char*, int);
char* initstate(unsigned, char*, int);
int ioctl(int, int, char*);
int isatty(int);
long jrand48(short*);
int kill(int, int);
int killpg(int, int);
void lcong48(short*);
int link(const char*, const char*);
int listen(int, int);
int lock(int, int, long);
long lrand48(void);
long lseek(int, long, int);
void* malloc(unsigned);
void* memalign(unsigned, unsigned);
void* memccpy(void*, const void*, int, int);
void* memchr(const void*, int, int);
int memcmp(const void*, const void*, int);
void* memcpy(void*, const void*, int);
void* memset(void*, int, int);
int mkdir(const char*, int);
int mknod(const char*, int, int);
int mkstemp(char*);
char* mktemp(char*);
long mrand48(void);
int nice(int);
long nrand48(short*);
int open(const char*, int, ...);
void pause(void);
void perror(const char*);
int pipe(int*);
void profil(char*, int, int, int);
int psignal(unsigned, char*);
int ptrace(int, int, int, int);
int putenv(const char*);
int qsort(void*, int, unsigned, auto (*ptf)(void*,void*));
int rand(void);
long random(void);
int read(int, void*, unsigned);
int readlink(const char*, char*, int);
void* realloc(void*, unsigned);
int rename(const char*, const char*);
char* rindex(const char*, int);
int rmdir(const char*);
void* sbrk(int);
short* seed48(short*);
int send(int, char*, int, int);
int setgid(int);
int sethostname(char*, int);
int setkey(const char*);
int setpgrp(int, int);
int setpriority(int, int, int);
int setregid(int, int);
int setreuid(int, int);
char* setstate(char*);
int setuid(int);
int sigblock(int);
int siginterrupt(int, int);
int sigpause(int);
int sigsetmask(int);
unsigned sleep(unsigned);
int socket(int, int, int);
int srand(int);
void srand48(long);
void srandom(int);
int stime(long*);
char* strcat(char*, const char*);
char* strchr(const char*, int);
int strcmp(const char*, const char*);
char* strcpy(char*, const char*);
int strcspn(const char*, const char*);
char* strdup(const char*);
int strlen(const char*);
char* strncat(char*, const char*, int);
int strncmp(const char*, const char*, int);
char* strncpy(char*, const char*, int);
char* strpbrk(const char*, const char*);
char* strrchr(const char*, int);
int strspn(const char*, const char*);
double strtod(const char*, char**);
char* strtok(char*, const char*);
long strtol(const char*, char**, int);
void swab(void*, void*, int);
int symlink(const char*, const char*);
int syscall(int, ...);
int system(const char*);
char* tempnam(char*, char*);
int tgetent(char*, char*);
int tgetnum(char*);
int tgetflag(char*);
char* tgetstr(char *, char **);
char* tgoto(char*, int, int);
long time(long*);
char* tmpnam(char*);
int tputs(char *, int, auto int (*)());
int truncate(const char*, unsigned long);
char* ttyname(int);
int ttyslot(void);
unsigned ualarm(unsigned, unsigned);
long ulimit(int, long);
int umask(int);
int unlink(const char*);
unsigned usleep(unsigned);
int vadvise(int);
void* valloc(unsigned);
int vfork(void);
int vhangup(void);
int wait(int*);
int write(int, const void*, unsigned);
}
extern char** environ;
extern volatile int errno;
extern char* sys_errlist[];
extern int sys_nerr;
extern char* optarg;
extern int opterr;
extern int optind;
extern "C" void* alloca(unsigned long);
# 41 "/usr/local/Gnu/lib/g++-include/builtin.h" 2
# 1 "/usr/local/Gnu/lib/g++-include/math.h" 1
#pragma once
# 57 "/usr/local/Gnu/lib/g++-include/math.h"
extern "C" {
double acos(double);
double acosh(double);
double asin(double);
double asinh(double);
double atan(double);
double atan2(double, double);
double atanh(double);
double cbrt(double);
double ceil(double);
double copysign(double,double);
double cos(double);
double cosh(double);
double drem(double,double);
double erf(double);
double erfc(double);
double exp(double);
double expm1(double);
double fabs(double);
double finite(double);
double floor(double);
double frexp(double, int*);
double gamma(double);
double hypot(double,double);
double infnan(int);
int isinf(double);
int isnan(double);
double j0(double);
double j1(double);
double jn(int, double);
double ldexp(double, int);
double lgamma(double);
double log(double);
double log10(double);
double log1p(double);
double logb(double);
double modf(double, double*);
double pow(double, double);
double rint(double);
double scalb(double, int);
double sin(double);
double sinh(double);
double sqrt(double);
double tan(double);
double tanh(double);
double y0(double);
double y1(double);
double yn(int, double);
}
struct libm_exception
{
int type;
char* name;
double arg1, arg2, retval;
};
extern "C" int matherr(libm_exception*);
# 1 "/usr/local/Gnu/lib/g++-include/values.h" 1
#pragma once
# 126 "/usr/local/Gnu/lib/g++-include/values.h"
# 134 "/usr/local/Gnu/lib/g++-include/math.h" 2
# 42 "/usr/local/Gnu/lib/g++-include/builtin.h" 2
long abs(long);
double abs(double);
void clearbit(long&, long);
void setbit(long&, long);
int testbit(long, long);
int even(long);
long gcd(long, long);
long lg(long);
long lcm(long, long);
int odd(long);
double pow(double, long);
long pow(long, long);
int sign(long);
int sign(double);
long sqr(long);
double sqr(double);
long sqrt(long);
double start_timer();
double return_elapsed_time(double);
char* itoa(long x, int base = 10, int width = 0);
char* itoa(unsigned long x, int base = 10, int width = 0);
char* hex(long x, int width = 0);
char* hex(unsigned long x, int width = 0);
char* oct(long x, int width = 0);
char* oct(unsigned long x, int width = 0);
char* dec(long x, int width = 0);
char* dec(unsigned long x, int width = 0);
char* form(const char* fmt ...);
char* chr(char ch);
char* str(const char* s, int width = 0);
unsigned int hashpjw(const char*);
unsigned int multiplicativehash(int);
unsigned int foldhash(double);
extern void default_one_arg_error_handler(const char*);
extern void default_two_arg_error_handler(const char*, const char*);
extern two_arg_error_handler_t lib_error_handler;
extern two_arg_error_handler_t
set_lib_error_handler(two_arg_error_handler_t f);
inline double abs(double _arg)
{
return (_arg < 0.0)? -_arg : _arg;
}
inline long abs(long _arg)
{
return (_arg < 0)? -_arg : _arg;
}
inline int sign(long _arg)
{
return (_arg == 0) ? 0 : ( (_arg > 0) ? 1 : -1 );
}
inline int sign(double _arg)
{
return (_arg == 0.0) ? 0 : ( (_arg > 0.0) ? 1 : -1 );
}
inline long sqr(long _arg)
{
return _arg * _arg;
}
inline double sqr(double _arg)
{
return _arg * _arg;
}
inline int even(long _arg)
{
return !(_arg & 1);
}
inline int odd(long _arg)
{
return (_arg & 1);
}
inline long lcm(long _x, long _y)
{
return _x / gcd(_x, _y) * _y;
}
inline void setbit(long& _x, long _b)
{
_x |= (1 << _b);
}
inline void clearbit(long& _x, long _b)
{
_x &= ~(1 << _b);
}
inline int testbit(long _x, long _b)
{
return ((_x & (1 << _b)) != 0);
}
# 28 "/usr/local/Gnu/lib/g++-include/File.h" 2
# 1 "/usr/local/Gnu/lib/g++-include/stdio.h" 1
#pragma once
# 74 "/usr/local/Gnu/lib/g++-include/stdio.h"
# 96 "/usr/local/Gnu/lib/g++-include/stdio.h"
extern struct _iobuf {
int _cnt;
char* _ptr;
char* _base;
int _bufsiz;
short _flag;
char _file;
} _iob[];
extern "C" {
int _doprnt(const char*, void*, struct _iobuf *);
int _doscan( struct _iobuf *, const char*, ...);
int _filbuf( struct _iobuf *);
int _flsbuf(unsigned, struct _iobuf *);
int fclose( struct _iobuf *);
struct _iobuf * fdopen(int, const char*);
int fflush( struct _iobuf *);
int fgetc( struct _iobuf *);
char* fgets(char*, int, struct _iobuf *);
struct _iobuf * fopen(const char*, const char*);
int fprintf( struct _iobuf *, const char* ...);
int fputc(int, struct _iobuf *);
int fputs(const char*, struct _iobuf *);
int fread(void*, int, int, struct _iobuf *);
struct _iobuf * freopen(const char*, const char*, struct _iobuf *);
int fscanf( struct _iobuf *, const char* ...);
int fseek( struct _iobuf *, long, int);
long ftell( struct _iobuf *);
int fwrite(const void*, int, int, struct _iobuf *);
char* gets(char*);
int getw( struct _iobuf *);
int pclose( struct _iobuf *);
struct _iobuf * popen(const char*, const char*);
int printf(const char* ...);
void puts(const char*);
int putw(int, struct _iobuf *);
int rewind( struct _iobuf *);
int scanf(const char* ...);
void setbuf( struct _iobuf *, char*);
void setbuffer( struct _iobuf *, char*, int);
void setlinebuf( struct _iobuf *);
void setvbuf( struct _iobuf *, char*, int, int);
int sscanf(char*, const char* ...);
struct _iobuf * tmpfile();
int ungetc(int, struct _iobuf *);
int vfprintf( struct _iobuf *, const char*, ...);
int vprintf(const char*, ... );
char* sprintf(char*, const char* ...);
char* vsprintf(char*, const char*, ...);
}
# 29 "/usr/local/Gnu/lib/g++-include/File.h" 2
enum io_mode
{
io_readonly = 0,
io_writeonly = 1,
io_readwrite = 2,
io_appendonly = 3,
io_append = 4,
};
enum access_mode
{
a_createonly = 0,
a_create = 1,
a_useonly = 2,
a_use = 3,
};
enum state_value
{
_good = 0,
_eof = 1,
_fail = 2,
_bad = 4
};
class Filebuf;
class File
{
friend class Filebuf;
protected:
struct _iobuf * fp;
char* nm;
char rw;
state_value state;
long stat;
void initialize();
void reinitialize(const char*);
char *readline (int chunk_number, char terminator);
public:
File();
File(const char* filename, io_mode m, access_mode a);
File(const char* filename, const char* m);
File(int filedesc, io_mode m);
File( struct _iobuf * fileptr);
File(int sz, char* buf, io_mode m);
~File();
File& open(const char* filename, io_mode m, access_mode a);
File& open(const char* filename, const char* m);
File& open(int filedesc, io_mode m);
File& open( struct _iobuf * fileptr);
File& close();
File& remove();
int filedesc();
const char* name();
void setname(const char* newname);
int iocount();
operator struct _iobuf *();
int rdstate();
int eof();
int fail();
int bad();
int good();
int readable();
int writable();
int is_open();
operator void*();
void error();
void clear(state_value f = 0);
File& failif(int cond);
void check_state();
File& get(char& c);
File& put(char c);
File& unget(char c);
File& putback(char c);
File& put(const char* s);
File& get (char* s, int n, char terminator = '\n');
File& getline(char* s, int n, char terminator = '\n');
File& gets (char **s, char terminator = '\n');
File& read(void* x, int sz, int n);
File& write(void* x, int sz, int n);
File& form(const char* ...);
File& scan(const char* ...);
File& flush();
File& flush(char ch);
int fill();
File& seek(long pos, int seek_mode=0);
long tell();
File& setbuf(int buffer_kind);
File& setbuf(int size, char* buf);
File& raw();
};
extern void verbose_File_error_handler(char*);
extern void quiet_File_error_handler(char*);
extern void fatal_File_error_handler(char*);
extern one_arg_error_handler_t File_error_handler;
extern one_arg_error_handler_t set_File_error_handler(one_arg_error_handler_t);
inline int File::filedesc()
{
return ((fp)->_file) ;
}
inline const char* File::name()
{
return nm;
}
inline int File::iocount()
{
return stat;
}
inline File::operator struct _iobuf *()
{
return fp;
}
inline int File::readable()
{
if (fp != 0) { if ( (((fp)->_flag& 00020 )!=0) ) state |= _eof; if ( (((fp)->_flag& 00040 )!=0) ) state |= _bad;}
return (state == _good && (rw & 01));
}
inline int File::writable()
{
if (fp != 0 && (((fp)->_flag& 00040 )!=0) ) state |= _bad;
return ((state & (_fail|_bad)) == 0 && (rw & 02));
}
inline int File::is_open()
{
return (fp != 0);
}
inline void File::clear(state_value flag = 0)
{
state = flag;
}
inline File& File::raw()
{
return this->File::setbuf( 00004 );
}
inline void File::check_state()
{
if (fp != 0)
{
if ( (((fp)->_flag& 00020 )!=0) )
state |= _eof;
else
state &= ~_eof;
if ( (((fp)->_flag& 00040 )!=0) )
state |= _bad;
}
}
inline File& File::failif(int cond)
{
if (cond) state |= _fail; return *this;
}
inline File& File::get(char& c)
{
if (readable())
{
int ch = (--(fp)->_cnt>=0?(int)(*(unsigned char*)(fp)->_ptr++):_filbuf(fp)) ;
c = ch;
failif (ch == (-1) );
}
return *this;
}
inline File& File::put(char c)
{
return failif (!writable() || (--( fp)->_cnt>=0? ((int)((unsigned char)((*( fp)->_ptr++=(unsigned)(c))))):_flsbuf((unsigned)(c), fp)) == (-1) );
}
inline File& File::unget(char c)
{
return failif(!is_open() || !(rw & 01) || ungetc(c, fp) == (-1) );
}
inline File& File::putback(char c)
{
return failif (!is_open() || !(rw & 01) || ungetc(c, fp) == (-1) );
}
inline File& File::read(void* x, int sz, int n)
{
return failif (!readable() || (stat = fread(x, sz, n, fp)) != n);
}
inline File& File::write(void* x, int sz, int n)
{
return failif (!writable() || (stat = fwrite(x, sz, n, fp)) != n);
}
inline File& File::flush()
{
return failif(!is_open() || fflush(fp) == (-1) );
}
inline File& File::flush(char ch)
{
return failif(!is_open() || _flsbuf(ch, fp) == (-1) );
}
inline int File::fill()
{
failif(!is_open() || (stat = _filbuf(fp)) == (-1) );
return stat;
}
inline File& File::seek(long pos, int seek_mode = 0)
{
return failif (!is_open() || fseek(fp, pos, seek_mode) < 0);
}
inline long File::tell()
{
failif (!is_open() || ((stat = ftell(fp)) < 0));
return stat;
}
inline int File::rdstate()
{
check_state(); return state;
}
inline File::operator void*()
{
check_state(); return (state & (_bad|_fail))? 0 : this ;
}
inline int File::eof()
{
check_state(); return state & _eof;
}
inline int File::fail()
{
check_state(); return state & _fail;
}
inline int File::bad()
{
check_state(); return state & _bad;
}
inline int File::good()
{
check_state(); return rdstate() == _good;
}
# 34 "/usr/local/Gnu/lib/g++-include/stream.h" 2
# 1 "/usr/local/Gnu/lib/g++-include/streambuf.h" 1
#pragma once
enum open_mode
{
input=0,
output=1,
append=2
};
class streambuf
{
public:
char* base;
char* pptr;
char* gptr;
char* eptr;
char alloc;
streambuf();
streambuf(char* buf, int buflen);
virtual ~streambuf();
int doallocate();
int allocate();
virtual int overflow(int c = (-1) );
virtual int underflow();
int sgetc();
int snextc();
void stossc();
void sputback(char);
int sputc(int c = (-1) );
virtual streambuf* setbuf(char* buf, int buflen, int preloaded_count = 0);
int sputs(const char* s);
int sputsn(const char* s, int len);
virtual const char* name();
virtual streambuf* open(const char* name, open_mode m);
virtual streambuf* open(const char* filename, io_mode m, access_mode a);
virtual streambuf* open(const char* filename, const char* m);
virtual streambuf* open(int filedesc, io_mode m);
virtual streambuf* open( struct _iobuf * fileptr);
virtual int is_open();
virtual int close();
virtual void error();
};
class filebuf: public streambuf
{
public:
int fd;
char opened;
int overflow(int c = (-1) );
int underflow();
filebuf();
filebuf(int newfd);
filebuf(int newfd, char* buf, int buflen);
~filebuf();
streambuf* open(const char* name, open_mode m);
int is_open();
int close();
};
class Filebuf: public streambuf
{
public:
File* Fp;
void init_streambuf_ptrs();
int overflow(int c = (-1) );
int underflow();
Filebuf();
Filebuf(const char* filename, io_mode m, access_mode a);
Filebuf(const char* filename, const char* m);
Filebuf(int filedesc, io_mode m);
Filebuf( struct _iobuf * fileptr);
~Filebuf();
const char* name();
streambuf* setbuf(char* buf, int buflen, int preloaded_count = 0);
streambuf* open(const char* filename, io_mode m, access_mode a);
streambuf* open(const char* filename, const char* m);
streambuf* open(int filedesc, io_mode m);
streambuf* open( struct _iobuf * fileptr);
int is_open();
int close();
void error();
};
inline int streambuf::allocate()
{
return (base == 0)? doallocate() : 0;
}
inline int streambuf::sgetc()
{
return (gptr >= pptr)? underflow() : int(*gptr);
}
inline int streambuf::snextc()
{
++gptr;
return (gptr >= pptr)? underflow() : int(*gptr);
}
inline void streambuf::stossc()
{
if (gptr >= pptr) underflow(); else gptr++;
}
inline void streambuf::sputback(char ch)
{
if (gptr > base) *--gptr = ch;
}
inline int streambuf::sputc(int ch = (-1) )
{
return (pptr < eptr)? (*pptr++ = (char)(ch)) : overflow(ch);
}
# 35 "/usr/local/Gnu/lib/g++-include/stream.h" 2
class whitespace
{
char filler;
};
class istream;
class ostream
{
friend class istream;
protected:
streambuf* bp;
state_value state;
char ownbuf;
public:
ostream(const char* filename, io_mode m, access_mode a);
ostream(const char* filename, const char* m);
ostream(int filedesc, io_mode m);
ostream( struct _iobuf * fileptr);
ostream(int sz, char* buf);
ostream(int filedesc, char* buf, int buflen);
ostream(int filedesc);
ostream(streambuf* s);
~ostream();
ostream& open(const char* filename, io_mode m, access_mode a);
ostream& open(const char* filename, const char* m);
ostream& open(int filedesc, io_mode m);
ostream& open( struct _iobuf * fileptr);
ostream& open(const char* filenam, open_mode m);
ostream& close();
ostream& flush();
int rdstate();
int eof();
int fail();
int bad();
int good();
int readable();
int writable();
int is_open();
operator void*();
int operator !();
const char* name();
char* bufptr();
void error();
void clear(state_value f = 0);
ostream& failif(int cond);
ostream& put(char c);
ostream& put(const char* s);
ostream& put(const char* s, int slen);
ostream& form(const char* fmt,...);
ostream& operator << (short n);
ostream& operator << (unsigned short n);
ostream& operator << (int n);
ostream& operator << (unsigned int n);
ostream& operator << (long n);
ostream& operator << (unsigned long n);
ostream& operator << (float n);
ostream& operator << (double n);
ostream& operator << (const char* s);
ostream& operator << (char c);
};
class istream
{
friend void eatwhite(istream& s);
protected:
streambuf* bp;
state_value state;
ostream* tied_to;
char skipws;
char ownbuf;
void _flush();
char* readline (int chunk_number, char terminator);
public:
istream(const char* filename, io_mode m, access_mode a,
int sk=1, ostream* t = 0);
istream(const char* filename, const char* m,
int sk=1, ostream* t = 0);
istream(int filedesc, io_mode m, int sk=1, ostream* t = 0);
istream( struct _iobuf * fileptr, int sk=1, ostream* t = 0);
istream(int sz, char* buf, int sk=1, ostream* t = 0);
istream(int filedesc, int sk=1, ostream* t = 0);
istream(int filedesc, char* buf, int buflen,
int sk=1, ostream* t = 0);
istream(streambuf* s, int sk=1, ostream* t = 0);
~istream();
istream& open(const char* filename, io_mode m, access_mode a);
istream& open(const char* filename, const char* m);
istream& open(int filedesc, io_mode m);
istream& open( struct _iobuf * fileptr);
istream& open(const char* filenam, open_mode m);
istream& close();
ostream* tie(ostream* s);
int skip(int);
int rdstate();
int eof();
int fail();
int bad();
int good();
int readable();
int writable();
int is_open();
operator void*();
int operator !();
const char* name();
char* bufptr();
void error();
void clear(state_value f = 0);
istream& failif(int cond);
istream& get(char& c);
istream& unget(char c);
istream& putback(char c);
istream& get (char* s, int n, char terminator = '\n');
istream& getline(char* s, int n, char terminator = '\n');
istream& gets (char **s, char terminator = '\n');
istream& operator >> (char& c);
istream& operator >> (short& n);
istream& operator >> (unsigned short& n);
istream& operator >> (int& n);
istream& operator >> (unsigned int& n);
istream& operator >> (long& n);
istream& operator >> (unsigned long& n);
istream& operator >> (float& n);
istream& operator >> (double& n);
istream& operator >> (char* s);
istream& operator >> (whitespace& w);
};
extern istream cin;
extern ostream cout;
extern ostream cerr;
extern whitespace WS;
inline void ostream::clear(state_value flag = _good)
{
state = flag;
}
inline int ostream::rdstate()
{
return int(state);
}
inline int ostream::good()
{
return state == _good;
}
inline int ostream::eof()
{
return int(state) & int(_eof);
}
inline int ostream::fail()
{
return int(state) & int(_fail);
}
inline int ostream::bad()
{
return int(state) & int(_bad);
}
inline ostream::operator void*()
{
return (state == _good)? this : 0;
}
inline int ostream::operator !()
{
return (state != _good);
}
inline ostream& ostream::failif(int cond)
{
if (cond) state |= _fail; return *this;
}
inline int ostream::is_open()
{
return bp->is_open();
}
inline int ostream::readable()
{
return 0;
}
inline int ostream::writable()
{
return (bp != 0) && (state == _good);
}
inline char* ostream::bufptr()
{
return bp->base;
}
inline ostream& ostream::flush()
{
bp->overflow(); return *this;
}
inline ostream& ostream::close()
{
bp->overflow(); bp->close(); return *this;
}
inline ostream& ostream::put(char ch)
{
return failif((state != _good) || bp->sputc(ch) == (-1) );
}
inline ostream& ostream::operator << (char ch)
{
return failif((state != _good) || bp->sputc(ch) == (-1) );
}
inline ostream& ostream::put(const char* s)
{
return failif((state != _good) || bp->sputs(s) == (-1) );
}
inline ostream& ostream::put(const char* s, int len)
{
return failif((state != _good) || bp->sputsn(s, len) == (-1) );
}
inline ostream& ostream::operator << (const char* s)
{
return failif((state != _good) || bp->sputs(s) == (-1) );
}
inline void istream::clear(state_value flag = _good)
{
state = flag;
}
inline int istream::rdstate()
{
return int(state);
}
inline int istream::good()
{
return state == _good;
}
inline int istream::eof()
{
return int(state) & int(_eof);
}
inline int istream::fail()
{
return int(state) & int(_fail);
}
inline int istream::bad()
{
return int(state) & int(_bad);
}
inline istream::operator void*()
{
return (state == _good)? this : 0;
}
inline int istream::operator !()
{
return (state != _good);
}
inline istream& istream::failif(int cond)
{
if (cond) state |= _fail; return *this;
}
inline int istream::is_open()
{
return bp->is_open();
}
inline int istream::readable()
{
return (bp != 0) && (bp->is_open()) && (state == _good);
}
inline int istream::writable()
{
return 0;
}
inline void istream::_flush()
{
if(tied_to != 0) tied_to->flush();
}
inline char* istream::bufptr()
{
return bp->base;
}
inline istream& istream::close()
{
bp->close(); return *this;
}
inline int istream::skip(int sk)
{
int was = skipws; skipws = sk; return was;
}
inline ostream* istream::tie(ostream* s)
{
ostream* was = tied_to; tied_to = s; return was;
}
inline istream& istream::unget(char c)
{
bp->sputback(c); return *this;
}
inline istream& istream::putback(char c)
{
bp->sputback(c); return *this;
}
inline void eatwhite(istream& s)
{
s >> WS;
}
# 11 "./HardwareContext.h" 2
# 1 "../Src/assert.h" 1
#pragma once
# 1 "../Src/Generic.h" 1
#pragma once
# 55 "../Src/Generic.h"
# 29 "../Src/assert.h" 2
# 1 "../Src/Pragma.h" 1
#pragma once
# 30 "../Src/assert.h" 2
extern const int SubClassResponsibility;
void _assert(const char *, const char *, const int);
void _assert2(const char *, const char *, const int, const char *);
# 12 "./HardwareContext.h" 2
extern const long MagicStackMarker;
typedef void (*voidFuncP)();
class CpuMultiplexor;
class SingleCpuMux;
class MultiCpuMux;
class SimulationMultiplexor;
typedef long HardwareContextQuad;
class HardwareContext {
HardwareContextQuad sp;
HardwareContextQuad fp;
void** stackBase;
void** stackEnd;
unsigned stackMax;
unsigned stackSize;
void **stackMallocAt;
long *stackCheck;
unsigned checkStackLimits;
friend class Thread;
friend class CpuMultiplexor;
friend class SingleCpuMux;
friend class MultiCpuMux;
friend class SimulationMultiplexor;
void switchContext(HardwareContext *to);
void magicSwitchTo(HardwareContext *to);
void **getSp();
void **mallocAt();
void buildReturnFrame(void * returnThis, voidFuncP returnAddress);
void stackOverflow();
HardwareContext(int checked, unsigned stackSize);
public:
HardwareContext();
long maxStackDepth();
void checkStack(int overage = 0);
void classPrintOn(ostream& strm);
};
inline
HardwareContext::HardwareContext()
{
int NotReached = 0;
{ if (( NotReached )) ; else _assert( "NotReached", "./HardwareContext.h",76); } ;
}
inline ostream&
operator<<(ostream& strm, HardwareContext& ob)
{
ob.classPrintOn(strm);
return strm;
}
inline void **
HardwareContext::getSp()
{
register int theStackPointer asm("sp");
return( (void **) theStackPointer );
}
inline void
HardwareContext::checkStack(int overage)
{
unsigned depth = stackBase - getSp() + overage;
if (stackMax < depth) {
stackMax = depth;
}
if ( stackMax >= stackSize || *stackCheck != MagicStackMarker ) {
stackOverflow();
}
}
# 12 "../Src/CpuMultiplexor.h" 2
# 1 "../Src/CpuMuxExceptions.h" 1
#pragma once
# 1 "../Src/ExceptionClass.h" 1
#pragma once
class ExceptionClass {
public:
ExceptionClass();
virtual void handleException();
};
inline ExceptionClass::ExceptionClass()
{
}
# 11 "../Src/CpuMuxExceptions.h" 2
class ReserveByException;
class ExceptionReserve : public ExceptionClass {
ReserveByException *toReserve;
public:
ExceptionReserve();
ReserveByException *reserve();
void reserve(ReserveByException *);
virtual void handleException();
};
inline
ExceptionReserve::ExceptionReserve()
{
}
inline ReserveByException *
ExceptionReserve::reserve()
{
return(toReserve);
}
inline void
ExceptionReserve::reserve(ReserveByException *r)
{
toReserve = r;
}
class Thread;
class ExceptionTerminate : public ExceptionClass {
void **stackOfDeadThread;
public:
ExceptionTerminate();
void terminate(void **);
virtual void handleException();
};
inline
ExceptionTerminate::ExceptionTerminate()
{
}
inline void
ExceptionTerminate::terminate(void **r)
{
stackOfDeadThread = r;
}
class ExceptionReschedule : public ExceptionClass {
public:
ExceptionReschedule();
virtual void handleException();
};
inline
ExceptionReschedule::ExceptionReschedule()
{
}
class ExceptionIveSuspended : public ExceptionClass {
public:
ExceptionIveSuspended();
virtual void handleException();
};
inline
ExceptionIveSuspended::ExceptionIveSuspended()
{
}
# 13 "../Src/CpuMultiplexor.h" 2
# 1 "../Src/SpinLock.h" 1
#pragma once
static const unsigned char SpinLockFree = '\x00';
class SpinLock {
unsigned char state;
public:
inline SpinLock();
inline ~SpinLock();
void reserve();
int reserveNoBlock();
void release();
};
static inline
SpinLock::SpinLock()
{
state = SpinLockFree;
}
static inline
SpinLock::~SpinLock()
{
{ if ((state == SpinLockFree)) ; else _assert( "state == SpinLockFree", "../Src/SpinLock.h",42); } ;
}
# 74 "../Src/SpinLock.h"
static inline void
SpinLock::reserve()
{
{ if ((state == SpinLockFree)) ; else _assert( "state == SpinLockFree", "../Src/SpinLock.h",81); } ;
state = ~SpinLockFree;
}
static inline int
SpinLock::reserveNoBlock()
{
{ if ((state == SpinLockFree)) ; else _assert( "state == SpinLockFree", "../Src/SpinLock.h",91); } ;
state = ~SpinLockFree;
return( 1 );
}
inline void
SpinLock::release()
{
{ if ((state != SpinLockFree)) ; else _assert( "state != SpinLockFree", "../Src/SpinLock.h",101); } ;
state = SpinLockFree;
}
# 14 "../Src/CpuMultiplexor.h" 2
# 1 "../Src/ThreadContainer.h" 1
#pragma once
# 1 "../Src/Awesime.h" 1
#pragma once
# 1 "/usr/local/Gnu/lib/g++-include/bool.h" 1
#pragma once
enum bool { FALSE = 0, TRUE = 1 };
# 27 "../Src/Awesime.h" 2
class Awesime;
typedef Awesime *AwesimePtr;
typedef void *VoidPtr;
class Awesime {
protected:
int debugFlag;
public :
Awesime(bool xdebug = 0);
virtual bool debug();
virtual bool debug(bool x);
virtual void classPrintOn(ostream& s);
virtual void subClassResponsibility(char *name = "");
};
static inline
Awesime::Awesime(bool xdebug)
{
debugFlag = xdebug;
}
inline ostream&
operator<<(ostream& strm, Awesime& ob)
{
ob.classPrintOn(strm);
return strm;
}
# 11 "../Src/ThreadContainer.h" 2
class Thread;
class ThreadContainer : public Awesime {
public :
inline ThreadContainer(bool xdebug = 0) : (xdebug) {}
virtual void add( Thread* );
virtual void add( double when, Thread* );
virtual void add( int when, Thread* );
virtual Thread* remove();
virtual Thread* remove(Thread* toRemove);
virtual bool isEmpty();
virtual unsigned size();
};
# 20 "../Src/CpuMultiplexor.h" 2
class Thread;
class ReserveByException;
class AwesimeHeap;
class SpinLock;
class SpinFetchAndOp;
class CpuMultiplexor;
extern int CpuMultiplexors;
extern CpuMultiplexor *ThisCpu;
extern int CpuMuxDebugFlag;
extern SpinLock CpuCerrLock;
class CpuMultiplexor {
protected:
friend class SimulationMultiplexor;
friend class SingleSimMux;
friend class MultiSimMux;
friend class MonitorSimMux;
Thread *currentThread;
HardwareContext systemContext;
ThreadContainer *myCurrentEvents;
SpinLock *myCurrentEventsLock;
int *myCurrentEventsCounter;
int iYam;
int pid;
char nameSpace[128];
char *pNameTemplate;
char *pName;
int *terminated;
int enabled;
virtual Thread *remove();
virtual void allocateEventStructures(int,int);
virtual void deallocateEventStructures();
void addUnlocked(Thread *);
friend class ExceptionReserve;
friend class ExceptionTerminate;
friend class ExceptionReschedule;
friend class ExceptionIveSuspended;
friend class ExceptionRelocate;
friend class ExceptionEnrollDismissCpu;
ExceptionClass *raisedBy;
ExceptionReserve reserveException;
ExceptionTerminate terminateException;
ExceptionReschedule rescheduleException;
ExceptionIveSuspended iveSuspendedException;
public:
void raise(ExceptionClass *);
void reserveByException( ReserveByException * );
void threadTerminateException( void ** );
void flick();
public:
CpuMultiplexor(int debug = 0);
virtual ~CpuMultiplexor();
virtual void fireItUp(int Cpus = 1, unsigned shared = (4196 * 500));
virtual void warmThePot(int);
virtual void stirItAround();
virtual void coolItDown();
virtual void terminateAll();
virtual void add(Thread *);
Thread * CurrentThread();
void debug(int newdebug);
int debug();
char *name();
int cpuId();
};
static inline int
CpuMultiplexor::cpuId()
{
return( iYam );
}
static inline char *
CpuMultiplexor::name()
{
return(pName);
}
static inline Thread *
CpuMultiplexor::CurrentThread()
{
return( currentThread );
}
static inline void
CpuMultiplexor::addUnlocked(Thread *who)
{
myCurrentEvents -> add( who );
}
# 1 "../Src/Thread.h" 1
#pragma once
enum ThreadState { SUSPENDED, RUNNING, RUNNABLE, ZOMBIED, TERMINATED };
static const double NullTime = -1;
typedef int ThreadPriority;
class CpuMultiplexor;
class SingleCpuMux;
class MultiCpuMux;
class SimulationMultiplexor;
class Thread : public Awesime {
friend class CpuMultiplexor;
friend class SingleCpuMux;
friend class MultiCpuMux;
friend class SimulationMultiplexor;
HardwareContext pContext;
ThreadState threadState;
ThreadPriority threadPriority;
short cpuAffinity;
ThreadContainer suspendedOn;
void startOff();
void makeTerminated();
char* threadName;
protected:
void name(char *);
void state(ThreadState s);
void makeRunnable();
virtual void main();
public:
Thread(char* name ="", unsigned stacksize = 1010,
ThreadPriority priority = 0,
bool debug = 0, int checkStack = 1);
virtual ~Thread();
const HardwareContext * context();
char* name();
ThreadState state();
long maxStackDepth();
void checkStack();
void priority(ThreadPriority newPriority);
ThreadPriority priority();
virtual void classPrintOn(ostream& strm);
};
inline char*
Thread::name()
{
return threadName;
}
inline void
Thread::name(char *name)
{
threadName = name;
}
inline void
Thread::state(ThreadState s)
{
threadState = s;
}
inline ThreadState
Thread::state()
{
return threadState;
}
inline long
Thread::maxStackDepth()
{
return( pContext.maxStackDepth() );
}
inline void
Thread::checkStack()
{
pContext.checkStack();
}
inline ThreadPriority
Thread::priority()
{
return(threadPriority);
};
inline void
Thread::priority(ThreadPriority newPriority)
{
threadPriority = newPriority;
}
# 166 "../Src/CpuMultiplexor.h" 2
static inline void
CpuMultiplexor::raise(ExceptionClass *by)
{
raisedBy = by;
currentThread -> pContext.switchContext( &systemContext );
}
static inline void
CpuMultiplexor::reserveByException( ReserveByException *sem )
{
reserveException.reserve(sem);
raise( &reserveException );
}
static inline void
CpuMultiplexor::threadTerminateException( void **killMe )
{
terminateException.terminate( killMe );
raise( &terminateException );
}
static inline void
CpuMultiplexor::flick()
{
currentThread -> cpuAffinity = -1;
raise( &rescheduleException );
}
static inline Thread *
CurrentThread()
{
return( ThisCpu -> CurrentThread() );
}
static inline void
CheckCurrentStack()
{
CurrentThread() -> checkStack();
}
extern ThreadContainer *AllocateHardwareCurrentEventsStructure();
# 11 "../Src/SimulationMultiplexor.h" 2
extern double CurrentSimulatedTime;
extern const double NullTime;
class TimeSchedulerPQ;
class SimulationMultiplexor {
protected:
TimeSchedulerPQ *myPendingEvents;
virtual int advanceTime();
virtual void allocateEventStructures(int,int);
virtual void deallocateEventStructures();
public:
SimulationMultiplexor(int debug = 0);
~SimulationMultiplexor();
virtual void addAt(Thread *, double);
virtual void addWithDelay(Thread *, double);
virtual void hold( double time );
virtual void await( double time );
};
extern SimulationMultiplexor *ThisSimulationMultiplexor;
static inline double simulatedClock() {
return( CurrentSimulatedTime );
}
static inline void await(double till)
{
if ( till > CurrentSimulatedTime ) {
ThisSimulationMultiplexor -> await(till);
}
}
static inline void hold(double holdFor)
{
ThisSimulationMultiplexor -> await( CurrentSimulatedTime + holdFor );
}
# 11 "../Src/MultiSimMux.h" 2
# 1 "../Src/MultiCpuMux.h" 1
#pragma once
# 1 "../Src/MultiCpuMuxExceptions.h" 1
#pragma once
class ExceptionRelocate : public ExceptionClass {
int newCpu;
public:
ExceptionRelocate();
void cpu(int = -1);
virtual void handleException();
};
inline
ExceptionRelocate::ExceptionRelocate()
{
}
inline void
ExceptionRelocate::cpu(int c)
{
newCpu = c;
}
class ExceptionEnrollDismissCpu : public ExceptionClass {
int enrollOrDismiss;
public:
void enroll();
void dismiss();
virtual void handleException();
};
inline void
ExceptionEnrollDismissCpu::enroll()
{
enrollOrDismiss = 1;
}
inline void
ExceptionEnrollDismissCpu::dismiss()
{
enrollOrDismiss = 0;
}
# 12 "../Src/MultiCpuMux.h" 2
extern int CpuMultiplexors;
extern CpuMultiplexor *ThisCpu;
extern int CpuMuxDebugFlag;
extern SpinLock CpuCerrLock;
class MultiCpuMux : public CpuMultiplexor {
friend class MultiSimMux;
protected:
SpinFetchAndOp *globalCurrentEventsCounter;
int oldGeneration;
void allocateLocalEventStructures(int,int);
virtual void allocateEventStructures(int,int);
virtual void deallocateEventStructures();
virtual void addToAnother(int, Thread *);
virtual Thread *remove();
friend class ExceptionRelocate;
ExceptionRelocate relocateException;
friend class ExceptionEnrollDismissCpu;
ExceptionEnrollDismissCpu enrollDismissCpuException;
public:
MultiCpuMux(int debug = 0);
virtual ~MultiCpuMux();
virtual void fireItUp(int Cpus = 1, unsigned shared = (4196 * 500));
virtual void warmThePot(int);
virtual void stirItAround();
virtual void coolItDown();
virtual void enrollCpu();
virtual void dismissCpu();
virtual void add(Thread *);
};
# 12 "../Src/MultiSimMux.h" 2
extern double CurrentSimulatedTime;
extern const double NullTime;
class SpinBarrier;
class TimeSchedulerPQ;
class MultiSimMux : public SimulationMultiplexor, public MultiCpuMux {
protected:
SpinLock *myPendingEventsLock;
SpinBarrier *cpuBarrier;
virtual int advanceTime();
void allocateLocalEventStructures(int,int);
virtual void allocateEventStructures(int,int);
virtual void deallocateEventStructures();
public:
MultiSimMux(int debug = 0, int barrierMaxLoops = 0);
virtual void fireItUp(int Cpus = 1, unsigned shared = (4196 * 500));
virtual void warmThePot(int);
virtual void stirItAround();
virtual void coolItDown();
};
# 11 "../Src/MonitorSimMux.h" 2
class Statistic;
class MonitorSimMux : public MultiSimMux {
public:
MonitorSimMux(int debug = 0, int maxloops = 0);
virtual void stirItAround();
virtual void coolItDown();
Statistic *threadsPerTick();
};
extern MonitorSimMux *ThisMonitorSimMux;
# 7 "../Src/MonitorSimMux.cc" 2
# 1 "../Src/SpinBarrier.h" 1
#pragma once
class SpinBarrier : SpinLock {
short pHeight;
volatile short pCount;
volatile short generation;
short pLoops;
int pMaxLoops;
public:
SpinBarrier( int h, int loops = 0 , int max = 0 );
~SpinBarrier();
int rendezvous();
void lowerBarrier();
int height();
void height(int h);
int loops();
void loops(int h);
int maxLoops();
void maxLoops(int h);
int count();
};
inline
SpinBarrier::SpinBarrier( int h, int l, int m )
{
pHeight = h;
pLoops = l;
pMaxLoops = m;
pCount = 0;
}
inline int
SpinBarrier::height()
{
return(pHeight);
}
inline int
SpinBarrier::loops()
{
return(pLoops);
}
inline void
SpinBarrier::loops(int h)
{
pLoops = h;
}
inline int
SpinBarrier::maxLoops()
{
return(pMaxLoops);
}
inline void
SpinBarrier::maxLoops(int h)
{
pMaxLoops = h;
}
inline int
SpinBarrier::count()
{
return(pCount);
}
inline
SpinBarrier::~SpinBarrier()
{
{ if (( pCount == 0 )) ; else _assert( "pCount == 0", "../Src/SpinBarrier.h",108); } ;
}
inline int
SpinBarrier::rendezvous()
{
{ if (( (pCount+1) == pHeight )) ; else _assert( "(pCount+1) == pHeight", "../Src/SpinBarrier.h",115); } ;
generation++;
pCount = 0;
return(1);
}
inline void
SpinBarrier::lowerBarrier()
{
generation++;
pCount = 0;
}
# 8 "../Src/MonitorSimMux.cc" 2
# 1 "../Src/Statistic.h" 1
#pragma once
# 1 "../Src/SampleStatistic.h" 1
#pragma once
class SampleStatistic {
protected:
int n;
double x;
double x2;
double minValue, maxValue;
double tval(double, int);
public :
SampleStatistic();
virtual void reset();
virtual void operator+=(double);
virtual int samples();
virtual double mean();
virtual double stdDev();
virtual double var();
virtual double min();
virtual double max();
virtual double sum();
virtual double confidence(int p_percentage);
virtual double confidence(double p_value);
void error(char* msg);
};
static inline
SampleStatistic::SampleStatistic()
{
reset();
}
# 72 "../Src/SampleStatistic.h"
# 11 "../Src/Statistic.h" 2
class Statistic : public SampleStatistic {
public:
virtual void classPrintOn(ostream&);
};
inline ostream&
operator<<(ostream& strm, Statistic& ob)
{
ob.classPrintOn(strm);
return strm;
}
# 9 "../Src/MonitorSimMux.cc" 2
# 1 "../Src/SpinFetchAndOp.h" 1
#pragma once
class SpinFetchAndOp : public SpinLock {
int data;
public:
SpinFetchAndOp(int);
void set(int);
int add(int);
int unlockedAdd(int);
int value();
};
inline
SpinFetchAndOp::SpinFetchAndOp(int d)
{
data = d;
}
inline void
SpinFetchAndOp::set(int d)
{
data = d ;
}
static inline int SpinFetchAndOp::add(int d)
{
int was = data;
data += d;
return(was);
}
inline int
SpinFetchAndOp::unlockedAdd(int d)
{
int was = data;
data += d;
return(was);
}
inline int
SpinFetchAndOp::value()
{
return(data);
}
# 10 "../Src/MonitorSimMux.cc" 2
static SpinLock statsLock;
static Statistic ThreadsPerTick;
static int threadsThisTick[1 ];
extern int CpuMuxDebugFlag;
MonitorSimMux *ThisMonitorSimMux;
MonitorSimMux::MonitorSimMux(int debug, int maxloops) : (debug, maxloops)
{
CpuMultiplexor::pNameTemplate = "MonitorSimMux";
ThisMonitorSimMux = this;
sprintf(CpuMultiplexor::nameSpace, "[%s-%d] ",
CpuMultiplexor::pNameTemplate, CpuMultiplexor::iYam);
CpuMultiplexor::pName = CpuMultiplexor::nameSpace;
}
void
MonitorSimMux::stirItAround()
{
while( ! *MultiSimMux::terminated )
{
MultiSimMux::stirItAround();
if (CpuMuxDebugFlag) {
CpuCerrLock.reserve();
cerr << name() << "Finished with current batch, advance time\n";
CpuCerrLock.release();
}
int added = advanceTime();
threadsThisTick[MultiSimMux::iYam] += added;
cpuBarrier -> rendezvous();
if (MultiSimMux::iYam == 0) {
int total = 0;
for (int i = 0 ; i < CpuMultiplexors; i++ ) {
total += threadsThisTick[i];
threadsThisTick[i] = 0;
}
double dtotal = double(total);
ThreadsPerTick += dtotal;
}
}
}
void
MonitorSimMux::coolItDown()
{
MultiSimMux::coolItDown();
CpuCerrLock.reserve();
cerr << name() << "Statistics for threads per tick\n";
cerr << name() << ThreadsPerTick << "\n";
cerr << name() << "Min = " << ThreadsPerTick.min() << "\n";
cerr << name() << "Max = " << ThreadsPerTick.max() << "\n";
CpuCerrLock.release();
}
Statistic *
MonitorSimMux::threadsPerTick()
{
return (&ThreadsPerTick);
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads