Article View: gnu.g++.bug
Article #11internal error--insn does not satisfy its constraints
From: David Fox
Date: Thu, 29 Oct 1992 10:37
Date: Thu, 29 Oct 1992 10:37
2142 lines
59093 bytes
59093 bytes
This file causes the error mentioned in the subject line
at line 1979 when run with the optimizer. Version is 2.2.2,
the cpu is a sun4, the OS is SunOS 2.1.
class ostream; class streambuf; class backupbuf;
extern "C" int __underflow(streambuf*);
extern "C" int __overflow(streambuf*, int);
typedef long streamoff;
typedef long streampos;
typedef unsigned long __fmtflags;
struct _ios_fields {
streambuf *_strbuf;
ostream* _tie;
int _width;
unsigned long _flags;
char _fill;
__fmtflags _state;
unsigned short _precision;
};
class ios : public _ios_fields {
public:
typedef __fmtflags fmtflags;
enum io_state {
goodbit = 0 ,
eofbit = 1 ,
failbit = 2 ,
badbit = 4 };
enum open_mode {
in = 1 ,
out = 2 ,
ate = 4 ,
app = 8 ,
trunc = 16 ,
nocreate = 32 ,
noreplace = 64 };
enum seek_dir { beg, cur, end};
enum { skipws=01, left=02, right=04, internal=010,
dec=020, oct=040, hex=0100,
showbase=0200, showpoint=0400, uppercase=01000, showpos=02000,
scientific=04000, fixed=0100000, unitbuf=020000, stdio=040000,
dont_close=0x80000000
};
ostream* tie() const { return _tie; }
ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; }
char fill() const { return _fill; }
char fill(char newf) { char oldf = _fill; _fill = newf; return oldf; }
fmtflags flags() const { return _flags; }
fmtflags flags(fmtflags new_val) {
fmtflags old_val = _flags; _flags = new_val; return old_val; }
int precision() const { return _precision; }
int precision(int newp) {
unsigned short oldp = _precision; _precision = (unsigned short)newp;
return oldp; }
fmtflags setf(fmtflags val) {
fmtflags oldbits = _flags;
_flags |= val; return oldbits; }
fmtflags setf(fmtflags val, fmtflags mask) {
fmtflags oldbits = _flags;
_flags = (_flags & ~mask) | (val & mask); return oldbits; }
fmtflags unsetf(fmtflags mask) {
fmtflags oldbits = _flags & mask;
_flags &= ~mask; return oldbits; }
int width() const { return _width; }
int width(int val) { int save = _width; _width = val; return save; }
static const unsigned long basefield;
static const unsigned long adjustfield;
static const unsigned long floatfield;
streambuf* rdbuf() const { return _strbuf; }
void clear(int state = 0) { _state = state; }
void set(int flag) { _state |= flag; }
int good() const { return _state == 0; }
int eof() const { return _state & ios::eofbit; }
int fail() const { return _state & (ios::badbit|ios::failbit); }
int bad() const { return _state & ios::badbit; }
int rdstate() const { return _state; }
operator void*() const { return fail() ? (void*)0 : (void*)this; }
int operator!() const { return fail(); }
protected:
ios(streambuf*sb) { _strbuf=sb; _state=0; _width=0; _fill=' ';
_flags=ios::skipws; _precision=6; }
};
typedef ios::seek_dir _seek_dir;
class streammarker {
friend class streambuf;
friend int __underflow(streambuf*);
struct streammarker *_next;
streambuf *_sbuf;
streampos _spos;
void set_streampos(streampos sp) { _spos = sp; }
void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); }
int _pos;
public:
streammarker(streambuf *sb);
~streammarker();
int saving() { return _spos == -2; }
int delta(streammarker&);
int delta();
};
struct __streambuf {
int _flags;
char* _gptr;
char* _egptr;
char* _eback;
char* _pbase;
char* _pptr;
char* _epptr;
char* _base;
char* _ebuf;
struct streambuf *_chain;
friend class streammarker;
char *_other_gbase;
char *_aux_limit;
char *_other_egptr;
streammarker *_markers;
unsigned short _cur_column;
char _unused;
char _shortbuf[1];
};
extern unsigned __adjust_column(unsigned start, const char *line, int count);
struct streambuf : private __streambuf {
friend class ios;
friend class istream;
friend class ostream;
friend class streammarker;
friend int __underflow(streambuf*);
protected:
static streambuf* _list_all;
streambuf*& xchain() { return _chain; }
void _un_link();
void _link_in();
char* gptr() const { return _gptr; }
char* pptr() const { return _pptr; }
char* egptr() const { return _egptr; }
char* epptr() const { return _epptr; }
char* pbase() const { return _pbase; }
char* eback() const { return _eback; }
char* ebuf() const { return _ebuf; }
char* base() const { return _base; }
void xput_char(char c) { *_pptr++ = c; }
int xflags() { return _flags; }
int xflags(int f) { int fl = _flags; _flags = f; return fl; }
void xsetflags(int f) { _flags |= f; }
void xsetflags(int f, int mask) { _flags = (_flags & ~mask) | (f & mask); }
void gbump(int n) { _gptr += n; }
void pbump(int n) { _pptr += n; }
void setb(char* b, char* eb, int a=0);
void setp(char* p, char* ep) { _pbase=_pptr=p; _epptr=ep; }
void setg(char* eb, char* g, char *eg) { _eback=eb; _gptr=g; _egptr=eg; }
char *shortbuf() { return _shortbuf; }
int in_backup() { return _flags & 0x100 ; }
char *Gbase() { return in_backup() ? _other_gbase : _eback; }
char *eGptr() { return in_backup() ? _other_egptr : _egptr; }
char *Bbase() { return in_backup() ? _eback : _other_gbase; }
char *Bptr() { return _aux_limit; }
char *eBptr() { return in_backup() ? _egptr : _other_egptr; }
char *Nbase() { return _other_gbase; }
char *eNptr() { return _other_egptr; }
int have_backup() { return _other_gbase != ((void*)0) ; }
int have_markers() { return _markers != ((void*)0) ; }
int _least_marker();
void switch_to_main_get_area();
void switch_to_backup_area();
void free_backup_area();
void unsave_markers();
int put_mode() { return _flags & 0x800 ; }
int switch_to_get_mode();
streambuf(int flags=0);
public:
static int flush_all();
static void flush_all_linebuffered();
virtual int underflow() = 0;
virtual int overflow(int c = (-1) ) = 0;
virtual int doallocate();
virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);
int seekmark(streammarker& mark, int delta = 0);
int sputbackc(char c);
int sungetc();
virtual ~streambuf();
int unbuffered() { return _flags & 2 ? 1 : 0; }
int linebuffered() { return _flags & 0x200 ? 1 : 0; }
void unbuffered(int i)
{ if (i) _flags |= 2 ; else _flags &= ~2 ; }
void linebuffered(int i)
{ if (i) _flags |= 0x200 ; else _flags &= ~0x200 ; }
int allocate() {
if (base() || unbuffered()) return 0;
else return doallocate(); }
void allocbuf() { if (base() == ((void*)0) ) doallocbuf(); }
void doallocbuf();
virtual int sync();
virtual int pbackfail(int c);
virtual int ungetfail();
virtual streambuf* setbuf(char* p, int len);
int in_avail() { return _egptr - _gptr; }
int out_waiting() { return _pptr - _pbase; }
virtual int sputn(const char* s, int n);
virtual int sgetn(char* s, int n);
int ignore(int);
virtual int get_column();
virtual int set_column(int);
long sgetline(char* buf, int n, char delim, int putback_delim);
int sbumpc() {
if (_gptr >= _egptr && __underflow(this) == (-1) ) return (-1) ;
else return *(unsigned char*)_gptr++; }
int sgetc() {
if (_gptr >= _egptr && __underflow(this) == (-1) ) return (-1) ;
else return *(unsigned char*)_gptr; }
int snextc() {
if (++_gptr >= _egptr && __underflow(this) == (-1) ) return (-1) ;
else return *(unsigned char*)_gptr; }
int sputc(int c) {
if (_pptr >= _epptr) return __overflow(this, (unsigned char)c);
return *_pptr++ = c, (unsigned char)c; }
void stossc() { if (_gptr < _egptr) _gptr++; }
int vscan(char const *fmt0, char * ap);
int vform(char const *fmt0, char * ap);
};
class backupbuf : public streambuf {
friend class streammarker;
protected:
backupbuf(int flags=0) : streambuf(flags|0x4000 ) { }
public:
virtual int pbackfail(int c);
virtual int underflow();
virtual int overflow(int c = (-1) );
};
struct __file_fields {
short _fileno;
int _blksize;
long _offset;
};
class filebuf : public backupbuf {
protected:
struct __file_fields _fb;
void init();
public:
filebuf();
filebuf(int fd);
filebuf(int fd, char* p, int len);
~filebuf();
filebuf* attach(int fd);
filebuf* open(const char *filename, const char *mode);
filebuf* open(const char *filename, int mode, int prot = 0664);
virtual int underflow();
virtual int overflow(int c = (-1) );
int is_open() { return _fb._fileno >= 0; }
int fd() { return is_open() ? _fb._fileno : (-1) ; }
filebuf* close();
virtual int doallocate();
virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
int sputn(const char* s, int n);
int sgetn(char* s, int n);
virtual int sync();
protected:
int is_reading() { return eback() != egptr(); }
char* cur_ptr() { return is_reading() ? gptr() : pptr(); }
char* file_ptr() { return eGptr(); }
int do_flush();
virtual int sys_read(char* buf, int size);
virtual long sys_seek(long , _seek_dir);
virtual int sys_write(const void*, long);
virtual int sys_stat(void*);
virtual int sys_close();
};
class istream; class ostream;
typedef ios& (*__manip)(ios&);
typedef istream& (*__imanip)(istream&);
typedef ostream& (*__omanip)(ostream&);
extern istream& ws(istream& ins);
extern ostream& flush(ostream& outs);
extern ostream& endl(ostream& outs);
extern ostream& ends(ostream& outs);
class ostream : public ios
{
void do_osfx();
public:
ostream();
ostream(streambuf* sb, ostream* tied=((void*)0) );
~ostream();
int opfx() { if (!good()) return 0; if (_tie) _tie->flush(); return 1; }
void osfx() { if (flags() & (ios::unitbuf|ios::stdio))
do_osfx(); }
streambuf* ostreambuf() const { return _strbuf; }
ostream& flush();
ostream& put(char c) { _strbuf->sputc(c); return *this; }
ostream& write(const char *s, int n);
ostream& write(const unsigned char *s, int n) { return write((char*)s, n);}
ostream& write(const signed char *s, int n) { return write((char*)s, n);}
ostream& write(const void *s, int n) { return write((char*)s, n);}
ostream& seekp(streampos);
ostream& seekp(streamoff, _seek_dir);
streampos tellp();
ostream& form(const char *format ...);
ostream& vform(const char *format, char * args);
};
extern ostream& operator<<(ostream&, char c);
inline ostream& operator<<(ostream& os, unsigned char c)
{ return os << (char)c; }
extern ostream& operator<<(ostream &os, signed char c) { return os << (char)c;}
extern ostream& operator<<(ostream&, const char *s);
inline ostream& operator<<(ostream& os, const unsigned char *s)
{ return os << (const char*)s; }
inline ostream& operator<<(ostream& os, const signed char *s)
{ return os << (const char*)s; }
extern ostream& operator<<(ostream&, void *p);
extern ostream& operator<<(ostream&, int n);
extern ostream& operator<<(ostream&, long n);
extern ostream& operator<<(ostream&, unsigned int n);
extern ostream& operator<<(ostream&, unsigned long n);
inline ostream& operator<<(ostream& os, short n) {return os << (int)n;}
inline ostream& operator<<(ostream& os, unsigned short n)
{return os << (unsigned int)n;}
extern ostream& operator<<(ostream&, float n);
extern ostream& operator<<(ostream&, double n);
inline ostream& operator<<(ostream& os, __omanip func) { return (*func)(os); }
inline ostream& operator<<(ostream& os, __manip func) {(*func)(os); return os;}
extern ostream& operator<<(ostream&, streambuf*);
class istream : public ios
{
int _gcount;
int _skip_ws();
public:
istream();
istream(streambuf* sb, ostream*tied=((void*)0) );
~istream();
streambuf* istreambuf() const { return _strbuf; }
istream& get(char& c);
istream& get(unsigned char& c) { return get((char&)c); }
istream& get(signed char& c) { return get((char&)c); }
istream& read(char *ptr, int n);
istream& read(unsigned char *ptr, int n) { return read((char*)ptr, n); }
istream& read(signed char *ptr, int n) { return read((char*)ptr, n); }
istream& read(void *ptr, int n) { return read((char*)ptr, n); }
istream& getline(char* ptr, int len, char delim = '\n');
istream& get(char* ptr, int len, char delim = '\n');
istream& get(streambuf& sb, char delim = '\n');
istream& gets(char **s, char delim = '\n');
int ipfx(int need) {
if (!good()) { set(ios::failbit); return 0; }
if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush();
if (!need && (flags() & ios::skipws)) return _skip_ws();
return 1;
}
int ipfx0() {
if (!good()) { set(ios::failbit); return 0; }
if (_tie) _tie->flush();
if (flags() & ios::skipws) return _skip_ws();
return 1;
}
int ipfx1() {
if (!good()) { set(ios::failbit); return 0; }
if (_tie && rdbuf()->in_avail() == 0) _tie->flush();
return 1;
}
int get() { if (!ipfx1()) return (-1) ;
int ch = _strbuf->sbumpc();
if (ch == (-1) ) set(ios::eofbit);
return ch; }
int peek() { if (!ipfx1()) return (-1) ;
int ch = _strbuf->sgetc();
if (ch == (-1) ) set(ios::eofbit);
return ch; }
int gcount() { return _gcount; }
istream& ignore(int n=1, int delim = (-1) );
istream& seekg(streampos);
istream& seekg(streamoff, _seek_dir);
streampos tellg();
istream& putback(char ch) {
if (good() && _strbuf->sputbackc(ch) == (-1) ) clear(ios::badbit);
return *this;}
istream& unget() {
if (good() && _strbuf->sungetc() == (-1) ) clear(ios::badbit);
return *this;}
istream& scan(const char *format ...);
istream& vscan(const char *format, char * args);
};
extern istream& operator>>(istream&, char*);
inline istream& operator>>(istream& is, unsigned char* p)
{ return is >> (char*)p; }
inline istream& operator>>(istream& is, signed char*p) {return is >> (char*)p;}
extern istream& operator>>(istream&, char& c);
extern istream& operator>>(istream& s, unsigned char& c) {return s>>(char&)c;}
extern istream& operator>>(istream& s, signed char& c) {return s >> (char&)c;}
extern istream& operator>>(istream&, int&);
extern istream& operator>>(istream&, long&);
extern istream& operator>>(istream&, short&);
extern istream& operator>>(istream&, unsigned int&);
extern istream& operator>>(istream&, unsigned long&);
extern istream& operator>>(istream&, unsigned short&);
extern istream& operator>>(istream&, float&);
extern istream& operator>>(istream&, double&);
inline istream& operator>>(istream& is, __manip func) {(*func)(is); return is;}
inline istream& operator>>(istream& is, __imanip func) { return (*func)(is); }
extern istream& operator>>(istream&, streambuf*);
class iostream : public ios {
int _gcount;
public:
iostream();
iostream(streambuf* sb, ostream*tied=((void*)0) );
operator istream&() { return *(istream*)this; }
operator ostream&() { return *(ostream*)this; }
~iostream();
istream& get(char& c) { return ((istream*)this)->get(c); }
istream& get(unsigned char& c) { return ((istream*)this)->get((char&)c); }
istream& get(signed char& c) { return ((istream*)this)->get((char&)c); }
istream& read(char *ptr, int n) { return ((istream*)this)->read(ptr, n); }
istream& read(unsigned char *ptr, int n)
{ return ((istream*)this)->read((char*)ptr, n); }
istream& read(signed char *ptr, int n)
{ return ((istream*)this)->read((char*)ptr, n); }
istream& read(void *ptr, int n)
{ return ((istream*)this)->read((char*)ptr, n); }
istream& getline(char* ptr, int len, char delim = '\n')
{ return ((istream*)this)->getline(ptr, len, delim); }
istream& get(char* ptr, int len, char delim = '\n')
{ return ((istream*)this)->get(ptr, len, delim); }
istream& gets(char **s, char delim = '\n')
{ return ((istream*)this)->gets(s, delim); }
istream& ignore(int n=1, int delim = (-1) )
{ return ((istream*)this)->ignore(n, delim); }
int ipfx(int need) { return ((istream*)this)->ipfx(need); }
int ipfx0() { return ((istream*)this)->ipfx0(); }
int ipfx1() { return ((istream*)this)->ipfx1(); }
int get() { return _strbuf->sbumpc(); }
int peek() { return ipfx1() ? _strbuf->sgetc() : (-1) ; }
int gcount() { return _gcount; }
istream& putback(char ch) { return ((istream*)this)->putback(ch); }
istream& unget() { return ((istream*)this)->unget(); }
istream& seekg(streampos pos) { return ((istream*)this)->seekg(pos); }
istream& seekg(streamoff off, _seek_dir dir)
{ return ((istream*)this)->seekg(off, dir); }
streampos tellg() { return ((istream*)this)->tellg(); }
istream& scan(const char *format ...);
istream& vscan(const char *format, char * args)
{ return ((istream*)this)->vscan(format, args); }
int opfx() { return ((ostream*)this)->opfx(); }
void osfx() { ((ostream*)this)->osfx(); }
ostream& flush() { return ((ostream*)this)->flush(); }
ostream& put(char c) { return ((ostream*)this)->put(c); }
ostream& write(const char *s, int n)
{ return ((ostream*)this)->write(s, n); }
ostream& write(const unsigned char *s, int n)
{ return ((ostream*)this)->write((char*)s, n); }
ostream& write(const signed char *s, int n)
{ return ((ostream*)this)->write((char*)s, n); }
ostream& write(const void *s, int n)
{ return ((ostream*)this)->write((char*)s, n); }
ostream& form(const char *format ...);
ostream& vform(const char *format, char * args)
{ return ((ostream*)this)->vform(format, args); }
ostream& seekp(streampos pos) { return ((ostream*)this)->seekp(pos); }
ostream& seekp(streamoff off, _seek_dir dir)
{ return ((ostream*)this)->seekp(off, dir); }
streampos tellp() { return ((ostream*)this)->tellp(); }
};
extern istream cin;
extern ostream cout, cerr, clog;
struct Iostream_init { } ;
inline ios& dec(ios& i)
{ i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; }
inline ios& hex(ios& i)
{ i.setf(ios::hex, ios::dec|ios::hex|ios::oct); return i; }
inline ios& oct(ios& i)
{ i.setf(ios::oct, ios::dec|ios::hex|ios::oct); return i; }
extern "C" {
extern "C" {
extern struct _iobuf {
int _cnt;
unsigned char *_ptr;
unsigned char *_base;
int _bufsiz;
short _flag;
char _file;
} _iob[];
extern struct _iobuf *__hide_fopen ();
extern struct _iobuf *__hide_fdopen ();
extern struct _iobuf *__hide_freopen ();
extern struct _iobuf *__hide_popen ();
extern struct _iobuf *tmpfile();
extern long __hide_ftell ();
extern char *fgets();
extern char *gets();
extern char *__hide_sprintf ();
extern char *ctermid();
extern char *cuserid();
extern char *__hide_tempnam ();
extern char *tmpnam();
}
extern "C" {
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 *);
void perror(const char*);
struct _iobuf * popen(const char*, const char*);
int printf(const char* ...);
int 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);
int setlinebuf(struct _iobuf *);
int setvbuf(struct _iobuf *, char*, int, int );
int sscanf(char*, const char* ...);
struct _iobuf * tmpfile();
int ungetc(int, struct _iobuf *);
int vfprintf (...) ;
int vprintf (...) ;
char* sprintf (...) ;
char* vsprintf (...) ;
extern int _filbuf (...) ;
extern int _flsbuf (...) ;
}
extern "C" {
extern void __eprintf (const char *, const char *, int, const char *);
}
}
extern "C" {
typedef int ptrdiff_t;
typedef int int ;
typedef short unsigned int wchar_t;
}
extern "C" {
int abs(int);
void volatile abort(void);
double atof(const char*);
int atoi(const char*);
long atol(const char*);
int atexit(auto void (*p) (void));
int bsearch (const void *, const void *, int ,
int , auto int (*ptf)(const void*, const void*));
void* calloc(int , int );
void cfree(void*);
void volatile exit(int);
char* fcvt(double, int, int*, int*);
void free(void*);
char* getenv(const char*);
int getopt(int, const char**, const char*);
int getpw(int, char*);
char* gcvt(double, int, char*);
char* ecvt(double, int, int*, int*);
extern char** environ;
long labs(long);
void* malloc(int );
int malloc_usable_size(void*);
int putenv(const char*);
extern char* optarg;
extern int opterr;
extern int optind;
void qsort(void*, int , int , auto int (*ptf)(void*,void*));
int rand(void);
void* realloc(void*, int );
int setkey(const char*);
int srand(unsigned int);
double strtod(const char*, char**);
long strtol(const char*, char**, int);
unsigned long stroul(const char**, int);
int system(const char*);
long random(void);
void srandom(int);
char* setstate(char*);
char* initstate(unsigned, char*, int);
double drand48(void);
void lcong48(short*);
long jrand48(short*);
long lrand48(void);
long mrand48(void);
long nrand48(short*);
short* seed48(short*);
void srand48(long);
char* ctermid(char*);
char* cuserid(char*);
char* tempnam(const char*, const char*);
char* tmpnam(char*);
}
extern "C" {
char* strcat(char*, const char*);
char* strchr(const char*, int);
int strcmp(const char*, const char*);
int strcoll(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*);
char* strstr(const char*, const char *);
char* strtok(char*, const char*);
int strxfrm(char*, const char*, int );
char* index(const char*, int);
char* rindex(const char*, int);
}
extern "C" {
void* memalign (...) ;
void* memccpy (...) ;
void* memchr (...) ;
int memcmp (...) ;
void* memcpy (...) ;
void* memmove (...) ;
void* memset (...) ;
int ffs (...) ;
int getpagesize (...) ;
void* valloc (...) ;
void bcopy (...) ;
int bcmp (...) ;
void bzero (...) ;
}
extern "C" {
extern "C"
{
typedef int sigset_t;
typedef unsigned int speed_t;
typedef unsigned long tcflag_t;
typedef unsigned char cc_t;
typedef int pid_t;
typedef unsigned short mode_t;
typedef short nlink_t;
typedef long clock_t;
typedef long time_t;
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef struct _physadr_t { int r[1]; } *physadr_t;
typedef struct label_t {
int val[2];
} label_t;
typedef struct _quad_t { long val[2]; } quad_t;
typedef long daddr_t;
typedef char * caddr_t;
typedef unsigned long ino_t;
typedef short dev_t;
typedef long off_t;
typedef unsigned short uid_t;
typedef unsigned short gid_t;
typedef long key_t;
typedef char * addr_t;
typedef long fd_mask;
typedef struct fd_set {
fd_mask fds_bits[(((256 )+(( (sizeof (fd_mask) * 8 ) )-1))/( (sizeof (fd_mask) * 8 ) )) ];
} fd_set;
}
extern void _exit( );
extern int access( );
extern unsigned alarm( );
extern int chdir( );
extern int __hide_chmod ( );
extern int chown( );
extern int close( );
extern char *ctermid( );
extern char *cuserid( );
extern int dup( );
extern int dup2( );
extern int __hide_execl ( );
extern int __hide_execle ( );
extern int __hide_execlp ( );
extern int execv( );
extern int execve( );
extern int execvp( );
extern pid_t fork( );
extern long fpathconf( );
extern char *getcwd( );
extern gid_t getegid( );
extern uid_t geteuid( );
extern gid_t getgid( );
extern int getgroups( );
extern char *getlogin( );
extern pid_t getpgrp( );
extern pid_t getpid( );
extern pid_t getppid( );
extern uid_t getuid( );
extern int isatty( );
extern int link( );
extern off_t lseek( );
extern long pathconf( );
extern int pause( );
extern int pipe( );
extern int read( );
extern int rmdir( );
extern int setgid( );
extern int setpgid( );
extern pid_t setsid( );
extern int setuid( );
extern unsigned sleep( );
extern long sysconf( );
extern pid_t tcgetpgrp( );
extern int tcsetpgrp( );
extern char *ttyname( );
extern int unlink( );
extern int write( );
extern void volatile _exit(int);
extern unsigned alarm (...) ;
extern int brk (...) ;
extern int chdir (...) ;
extern int chmod (...) ;
extern int chown (...) ;
extern int close (...) ;
extern char* crypt (...) ;
extern int dup (...) ;
extern int dup2 (...) ;
extern char* encrypt (...) ;
extern int execl (...) ;
extern int execle (...) ;
extern int execlp (...) ;
extern int exect (...) ;
extern int execv (...) ;
extern int execve (...) ;
extern int execvp (...) ;
extern int fchown (...) ;
extern int fork (...) ;
extern int fsync (...) ;
extern int ftruncate (...) ;
extern char* getcwd (...) ;
extern int getdomainname (...) ;
extern int getdtablesize (...) ;
extern int getgroups (...) ;
extern unsigned short geteuid (...) ;
extern unsigned short getegid (...) ;
extern unsigned short getgid (...) ;
extern long gethostid (...) ;
extern int gethostname (...) ;
extern int getpgrp (...) ;
extern int getpid (...) ;
extern int getppid (...) ;
extern char* getlogin (...) ;
extern char* getpass (...) ;
extern unsigned short getuid (...) ;
extern int ioctl (...) ;
extern int isatty (...) ;
extern int link (...) ;
extern int mkstemp (...) ;
extern char* mktemp (...) ;
extern int nice (...) ;
extern int pause (...) ;
extern int pipe (...) ;
extern int readlink (...) ;
extern int rename (...) ;
extern int rmdir (...) ;
extern void* sbrk (...) ;
extern int syscall (...) ;
extern int setgid (...) ;
extern int sethostname (...) ;
extern int setpgrp (...) ;
extern int setregid (...) ;
extern int setreuid (...) ;
extern int setuid (...) ;
extern unsigned sleep (...) ;
extern void swab (...) ;
extern int symlink (...) ;
extern int truncate (...) ;
extern char* ttyname (...) ;
extern int ttyslot (...) ;
extern int unlink (...) ;
extern int vfork (...) ;
extern int vadvise (...) ;
extern int vhangup (...) ;
extern long lseek (...) ;
extern int read (...) ;
extern int write (...) ;
extern int access (...) ;
extern int flock (...) ;
}
extern "C" {
extern int errno;
extern char* sys_errlist[];
extern int sys_nerr;
extern int errno;
void perror(const char*);
char* strerr(int);
}
extern "C" {
struct flock {
short l_type;
short l_whence;
long l_start;
long l_len;
short l_pid;
short l_xxx;
};
struct eflock {
short l_type;
short l_whence;
long l_start;
long l_len;
short l_pid;
short l_xxx;
long l_rpid;
long l_rsys;
};
extern "C"
{
struct stat {
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
short st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
off_t st_size;
time_t st_atime;
int st_spare1;
time_t st_mtime;
int st_spare2;
time_t st_ctime;
int st_spare3;
long st_blksize;
long st_blocks;
long st_spare4[2];
};
int __hide_chmod ( );
int fstat( );
int mkdir( );
int mkfifo( );
int stat( );
mode_t umask( );
extern int chmod (...) ;
extern int stat (...) ;
extern int lstat (...) ;
extern int fstat (...) ;
}
int __hide_open ( );
int __hide_creat ( );
int __hide_fcntl ( );
int fcntl(int, int, ...);
int creat (...) ;
int open (...) ;
}
extern "C" {
int strcasecmp (...) ;
}
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 fmod(double, 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);
double aint(double);
double anint(double);
int irint(double);
int nint(double);
}
struct libm_exception
{
int type;
char* name;
double arg1, arg2, retval;
};
extern "C" int matherr(libm_exception*);
typedef void (*one_arg_error_handler_t)(const char*);
typedef void (*two_arg_error_handler_t)(const char*, const char*);
long gcd(long, long);
long lg(unsigned long);
double pow(double, long);
long pow(long, long);
double start_timer();
double return_elapsed_time(double last_time = 0.0);
char* dtoa(double x, char cvt = 'g', int width = 0, int prec = 6);
char* chr(char ch, int width = 0);
char* str(const char* s, int width = 0);
unsigned int hashpjw(const char*);
unsigned int multiplicativehash(int);
unsigned int foldhash(double);
extern volatile void default_one_arg_error_handler(const char*);
extern volatile 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);
double abs(double arg);
float abs(float arg);
short abs(short arg);
long abs(long arg);
int sign(long arg);
int sign(double arg);
long sqr(long arg);
double sqr(double arg);
int even(long arg);
int odd(long arg);
long lcm(long x, long y);
void setbit(long& x, long b);
void clearbit(long& x, long b);
int testbit(long x, long b);
inline double abs(double arg)
{
return (arg < 0.0)? -arg : arg;
}
inline float abs(float arg)
{
return (arg < 0.0)? -arg : arg;
}
inline short abs(short arg)
{
return (arg < 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);
}
typedef unsigned boolean;
static const boolean false = 0;
static const boolean true = 1;
inline void pointless_defs_h_2()
{
boolean b;
b = true;
b = false;
}
typedef unsigned Alignment;
static const Alignment TopLeft = 0;
static const Alignment TopCenter = 1;
static const Alignment TopRight = 2;
static const Alignment CenterLeft = 3;
static const Alignment Center = 4;
static const Alignment CenterRight = 5;
static const Alignment BottomLeft = 6;
static const Alignment BottomCenter = 7;
static const Alignment BottomRight = 8;
static const Alignment Left = 9;
static const Alignment Right = 10;
static const Alignment Top = 11;
static const Alignment Bottom = 12;
static const Alignment HorizCenter = 13;
static const Alignment VertCenter = 14;
inline void pointless_defs_h()
{
Alignment a;
a = TopLeft;
a = TopCenter;
a = TopRight;
a = CenterLeft;
a = Center;
a = CenterRight;
a = BottomLeft;
a = BottomCenter;
a = BottomRight;
a = Left;
a = Right;
a = Top;
a = Bottom;
a = HorizCenter;
a = VertCenter;
}
enum TextStyle {
Plain = 0x0,
Boldface = 0x1,
Underlined = 0x2,
Reversed = 0x4,
Outlined = 0x8
};
typedef int Coord;
extern double inch, inches, cm, point, points;
static const int pixels = 1;
inline int round (double x) { return x > 0 ? int(x+0.5) : -int(-x+0.5); }
typedef unsigned char Byte;
static const int LgBitsPerByte = 3;
static const int BitsPerByte = 1 << LgBitsPerByte;
static const int ExpBitsPerByte = 1 << BitsPerByte;
static const int AlignmentBits = BitsPerByte * 2;
static const int ModBitOfByte = (BitsPerByte - 1);
static const Byte ByteMask = ExpBitsPerByte - 1;
inline Byte ByteBitMask(int n) {return 1 << (BitsPerByte - n - 1);}
inline int BitNumToByteNum(int bit) {return bit >> LgBitsPerByte;}
inline Byte RightMask(int num) {return (1 << num) - 1;}
inline Byte LeftMask(int num) {return RightMask(num) << (8 - num);}
extern Byte *magnify[5][BitsPerByte][ExpBitsPerByte];
extern char leftbit[ExpBitsPerByte];
extern char rightbit[ExpBitsPerByte];
extern Byte zoomdown[ExpBitsPerByte];
typedef unsigned char RasterOp;
static const RasterOp DST = 0xa;
static const RasterOp SRC = 0xc;
static const RasterOp SET = 0xf;
static const RasterOp CLR = 0x0;
inline RasterOp NOT(RasterOp op) {return op ^ SET;}
inline void DoRasterOp(RasterOp op, Byte &dst, Byte src, Byte mask)
{
switch (op) {
case 0x0: dst &= ~mask; break;
case 0x1: dst = (dst&~mask) | ((~dst&~src)&mask); break;
case 0x2: dst &= ~(src&mask); break;
case 0x3: dst = (dst&~mask) | (~src&mask); break;
case 0x4: dst = (dst&~mask) | ((~dst&src)&mask); break;
case 0x5: dst ^= mask; break;
case 0x6: dst ^= (src&mask); break;
case 0x7: dst = (dst&~mask) | ((~dst|~src)&mask); break;
case 0x8: dst &= src|~mask; break;
case 0x9: dst = ~(dst ^ (src|~mask)); break;
case 0xa: break;
case 0xb: dst |= ~(src|~mask); break;
case 0xc: dst = (dst&~mask) | (src&mask); break;
case 0xd: dst = (dst&~mask) | ((~dst|src)&mask); break;
case 0xe: dst |= src&mask; break;
case 0xf: dst |= mask; break;
}
}
inline void DoRasterOp(RasterOp op, Byte &dst, Byte src)
{
switch (op) {
case 0x0: dst = 0x0; break;
case 0x1: dst = ~dst & ~src; break;
case 0x2: dst &= ~src; break;
case 0x3: dst = ~src; break;
case 0x4: dst = ~dst & src; break;
case 0x5: dst ^= 0xff; break;
case 0x6: dst ^= src; break;
case 0x7: dst = ~dst | ~src; break;
case 0x8: dst &= src; break;
case 0x9: dst = ~(dst ^ src); break;
case 0xa: break;
case 0xb: dst |= ~src; break;
case 0xc: dst = src; break;
case 0xd: dst = ~dst | src; break;
case 0xe: dst |= src; break;
case 0xf: dst = 0xff; break;
}
}
class PointSet;
class PadFont;
typedef int PadColor;
class PixRect {
private:
Byte *_memory;
Byte _ownerp;
Byte _depth;
int _skip;
int _voffset;
int _hoffset;
int _width;
int _height;
Byte _leftmask;
Byte _rightmask;
public:
PixRect(int width, int height, int depth);
PixRect(int width, int height, int depth, Byte *memory);
PixRect(PixRect &, int x, int y, int w, int h);
~PixRect();
void InitMasks(int hoffset);
int Width() {return _width;}
int Height() {return _height;}
int Depth() {return _depth;}
Byte *Data() {return _memory;}
int Skip() {return _skip;}
int Align() {return AlignmentBits;}
PadColor Get(int x, int y);
void Put(int x, int y, PadColor v);
virtual void Line(int x1, int y1, int x2, int y2,
RasterOp op, PadColor color);
void PolyPoint(PointSet &p, RasterOp op, PadColor color);
void Point(int x, int y, RasterOp op, PadColor color);
void Box(int l, int b, int r, int t, RasterOp op, PadColor val);
void Text(int x, int y, RasterOp op, PadColor color,
PadFont &font, const char *str);
void Rop(int dx, int dy,
int w, int h,
RasterOp op,
int z,
PixRect &src,
int sx, int sy,
int xo, int yo);
void Stencil(int dx, int dy,
int w, int h,
RasterOp op,
int z,
PixRect &st,
int stx, int sty,
PixRect &src,
int sx, int sy,
int xo, int yo);
void ReplRop(int dx, int dy,
int w, int h,
RasterOp op,
int z,
PixRect &src,
int sx, int sy,
int xo, int yo);
void Rop(int dx, int dy,
int w, int h,
RasterOp op,
PadColor color);
boolean Bounds(int &l, int &b, int &r, int &t);
Byte *PixelAddress(int x, int y);
int PixelOffset(int x, int y);
friend class ostream &operator<<(ostream &s, PixRect &p);
private:
void DoRop(Byte *dp,
int dh,
Byte lmask,
Byte rmask,
int bytes,
int z,
int s,
RasterOp op,
int shift,
Byte *buf,
Byte *bp,
Byte *sp,
int sskip,
int sbytes,
int ssbytes,
int yo);
void DoRop(int dh,
Byte *dp,
int bytes,
Byte lmask,
Byte rmask,
RasterOp op,
PadColor color);
void Scale(Byte *sp,
Byte *buf,
int z,
int s,
int sbytes,
int shift,
int ssbytes);
void RopSrcRow(Byte *&dp0,
int skip,
Byte lmask,
Byte rmask,
int fullbytes,
RasterOp op,
Byte *bp0,
int rows);
void DestInfo(int dx0,
int dy0,
int dw,
RasterOp op,
Byte *&dp,
int &doff,
Byte &lmask,
Byte &rmask,
int &fullbytes);
boolean RowBounds(int y, int &l, int &r);
};
inline Byte *PixRect::PixelAddress(int x, int y)
{
((void) ((x >= 0 && x < _width) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "PixRect.h", 160, "x >= 0 && x < _width"), 0) )) ;
((void) ((y >= 0 && y < _height) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "PixRect.h", 161, "y >= 0 && y < _height"), 0) )) ;
return (_memory +
(_voffset + y) * _skip +
(_hoffset + x) * _depth / BitsPerByte);
}
inline int PixRect::PixelOffset(int x, int )
{
return ((_hoffset + x) * _depth) % BitsPerByte;
}
inline int AlignRowLength(int bits)
{
return ((bits + AlignmentBits - 1)
/ AlignmentBits * (AlignmentBits / BitsPerByte));
}
inline PadColor PixRect::Get(int x, int y)
{
Byte *p = PixelAddress(x, y);
int shift = BitsPerByte - PixelOffset(x, y) - _depth;
Byte mask = ((1 << _depth) - 1) << shift;
return ((*p) & mask) >> shift;
}
inline void PixRect::Put(int x, int y, PadColor v)
{
Byte *p = PixelAddress(x, y);
int shift = BitsPerByte - PixelOffset(x, y) - _depth;
Byte mask = ((1 << _depth) - 1) << shift;
*p = (*p & ~mask) | (v << shift);
}
inline void PixRect::Point(int x, int y, RasterOp op, PadColor color)
{
Byte *p = PixelAddress(x, y);
int shift = BitsPerByte - PixelOffset(x, y) - _depth;
Byte mask = ((1 << _depth) - 1) << shift;
DoRasterOp(op, *p, color << shift, mask);
}
inline void PixRect::InitMasks(int hoffset)
{
_leftmask = RightMask(BitsPerByte - (hoffset % BitsPerByte));
_rightmask = LeftMask(((hoffset + _width - 1) % BitsPerByte) + 1);
if (hoffset + _width < BitsPerByte) {
_leftmask &= _rightmask;
_rightmask = _leftmask;
}
}
inline PixRect::PixRect(int width, int height, int depth)
{
_width = width;
_height = height;
_depth = depth;
_ownerp = true;
_skip = AlignRowLength(width * depth);
_memory = new Byte[_skip * height];
_voffset = _hoffset = 0;
InitMasks(0);
}
inline PixRect::PixRect(int width, int height, int depth, Byte *memory)
{
_width = width;
_height = height;
_depth = depth;
_ownerp = true;
_skip = AlignRowLength(width * depth);
_memory = memory;
_voffset = _hoffset = 0;
InitMasks(0);
}
inline PixRect::PixRect(PixRect &parent, int x, int y, int w, int h)
{
((void) ((x + w <= parent._width) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "PixRect.h", 251, "x + w <= parent._width"), 0) )) ;
((void) ((y + h <= parent._height) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "PixRect.h", 252, "y + h <= parent._height"), 0) )) ;
_memory = parent._memory;
_voffset = parent._voffset + y;
_hoffset = parent._hoffset + x;
_width = w;
_depth = parent._depth;
_height = h;
_skip = parent._skip;
_ownerp = false;
InitMasks(_hoffset);
}
inline PixRect::~PixRect()
{
if (_ownerp) delete _memory;
}
inline char min(char a, char b) { return (a < b)?a:b;}
inline signed char min(signed char a, signed char b) { return (a < b)?a:b;}
inline unsigned char min(unsigned char a, unsigned char b) {return (a<b)?a:b;}
inline short min(short a, short b) {return (a < b) ?a:b;}
inline unsigned short min(unsigned short a, unsigned short b) {return (a < b)?a:b;}
inline int min(int a, int b) {return (a < b)?a:b;}
inline unsigned int min(unsigned int a, unsigned int b) {return (a < b)?a:b;}
inline long min(long a, long b) {return (a < b)?a:b;}
inline unsigned long min(unsigned long a, unsigned long b) {return (a<b)?a:b;}
inline float min(float a, float b) {return (a < b)?a:b;}
inline double min(double a, double b) {return (a < b)?a:b;}
inline char max(char a, char b) { return (a > b)?a:b;}
inline signed char max(signed char a, signed char b) {return (a > b)?a:b;}
inline unsigned char max(unsigned char a, unsigned char b) {return (a>b)?a:b;}
inline short max(short a, short b) {return (a > b) ?a:b;}
inline unsigned short max(unsigned short a, unsigned short b) {return (a > b)?a:b;}
inline int max(int a, int b) {return (a > b)?a:b;}
inline unsigned int max(unsigned int a, unsigned int b) {return (a > b)?a:b;}
inline long max(long a, long b) {return (a > b)?a:b;}
inline unsigned long max(unsigned long a, unsigned long b) {return (a>b)?a:b;}
inline float max(float a, float b) {return (a > b)?a:b;}
inline double max(double a, double b) {return (a > b)?a:b;}
extern char* form(const char*, ...);
extern char* dec(long, int=0);
extern char* dec(int, int=0);
extern char* dec(unsigned long, int=0);
extern char* dec(unsigned int, int=0);
extern char* hex(long, int=0);
extern char* hex(int, int=0);
extern char* hex(unsigned long, int=0);
extern char* hex(unsigned int, int=0);
extern char* oct(long, int=0);
extern char* oct(int, int=0);
extern char* oct(unsigned long, int=0);
extern char* oct(unsigned int, int=0);
inline istream& WS(istream& str) { return ws(str); }
struct mallinfo {
int arena;
int ordblks;
int smblks;
int hblks;
int hblkhd;
int usmblks;
int fsmblks;
int uordblks;
int fordblks;
int keepcost;
int mxfast;
int nlblks;
int grain;
int uordbytes;
int allocated;
int treeoverhead;
};
typedef char * malloc_t;
template <class T>
class Array {
private:
T *t_v;
int t_cnt;
int t_max;
protected:
void Extend(int n)
{((void) ((t_max > 0) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "../templates/Array.h", 24, "t_max > 0"), 0) )) ;
while (t_max <= n) t_max += t_max;
t_v = (T*)realloc(t_v, t_max * sizeof(T));}
public:
Array() : t_v((T*)malloc(sizeof(T))), t_max(1), t_cnt(0) {}
Array(int n) : t_v((T*)malloc(sizeof(T) * n)), t_max(n), t_cnt(0) {}
~Array() {delete t_v;}
const T &operator[](int n) const
{return t_v[n];}
void Set(int n, T x);
void Insert(int n, T x);
void Push(T x);
const T &First() const
{return t_v[0];}
T &Pop()
{t_cnt--; return t_v[t_cnt];}
const T &Top() const
{return t_v[t_cnt-1];}
void Reset()
{t_cnt = 0;}
int Empty() const
{return t_cnt == 0;}
int Count() const
{return t_cnt;}
friend ostream &operator<<(ostream &s, Array &v)
{
s << "cnt=" << v.Count() << ", ";
for (int i = 0; i < v.Count(); i++) s << v[i] << " "; return s;
}
};
template<class T> void Array<T>::Push(T x)
{
Extend(t_cnt);
t_v[t_cnt] = x;
t_cnt++;
}
template<class T> void Array<T>::Set(int n, T x)
{
if (n >= t_max) Extend(n);
if (n >= t_cnt) t_cnt = n+1;
t_v[n] = x;
}
template<class T> void Array<T>::Insert(int n, T x)
{
t_cnt += 1;
if (n >= t_max) Extend(t_cnt + 1);
bcopy(&t_v[n], &t_v[n+1], (t_cnt - n) * sizeof(T));
t_v[n] = x;
}
class PointRep {
private:
int _x;
int _y;
public:
PointRep(int x, int y) : _x(x), _y(y) {}
int x() {return _x;}
int y() {return _y;}
};
class PointSet {
friend class PadImage;
private:
int _count;
int _xmin;
int _xmax;
int _ymin;
int _ymax;
Array<PointRep> _points;
public:
PointSet()
: _count(0),
_xmin( (~ (1 << ( (8 * (int)sizeof(int)) - 1)) ) ), _ymin( (~ (1 << ( (8 * (int)sizeof(int)) - 1)) ) ),
_xmax(- (~ (1 << ( (8 * (int)sizeof(int)) - 1)) ) ), _ymax(- (~ (1 << ( (8 * (int)sizeof(int)) - 1)) ) ) {}
~PointSet() {}
void add(int x, int y);
int x(int n) {return _points[n].x();}
int y(int n) {return _points[n].y();}
int xmin() {return _xmin;}
int xmax() {return _xmax;}
int ymin() {return _ymin;}
int ymax() {return _ymax;}
int count() {return _count;}
const PointRep *points() {return &_points[0];}
void reset() {_count = 0;
_xmin = _ymin = (~ (1 << ( (8 * (int)sizeof(int)) - 1)) ) ;
_xmax = _ymax = - (~ (1 << ( (8 * (int)sizeof(int)) - 1)) ) ;}
};
inline void PixRect::Scale(Byte *sp, Byte *buf, int z, int s,
int sbytes, int shift, int ssbytes)
{
memset(buf, '\0', ssbytes);
while (sbytes--) {
Byte *p = magnify[z][shift][*sp++];
for (int i = 0; i <= s; i++)
*buf++ |= *p++;
buf--;
}
}
inline void PixRect::RopSrcRow(Byte *&dp0, int skip, Byte lmask, Byte rmask,
int bytes, RasterOp op, Byte *bp0,
int rows)
{
while (rows--) {
Byte *dp = dp0;
Byte *bp = bp0;
DoRasterOp(op, *dp++, *bp++, lmask);
for (int i = 2; i < bytes; i++)
DoRasterOp(op, *dp++, *bp++);
DoRasterOp(op, *dp, *bp, rmask);
dp0 += skip;
}
}
inline void
PixRect::DoRop(Byte *dp, int dh, Byte lmask, Byte rmask, int bytes,
int z, int s, RasterOp op, int shift, Byte *buf, Byte *bp,
Byte *sp, int sskip, int sbytes, int ssbytes, int yo)
{
int rows = min(s - yo, dh);
Scale(sp, buf, z, s, sbytes, shift, ssbytes);
RopSrcRow(dp, _skip, lmask, rmask, bytes, op, bp, rows);
dh -= rows;
sp += sskip;
while (dh >= s) {
Scale(sp, buf, z, s, sbytes, shift, ssbytes);
RopSrcRow(dp, _skip, lmask, rmask, bytes, op, bp, s);
dh -= s;
sp += sskip;
}
if (dh) {
Scale(sp, buf, z, s, sbytes, shift, ssbytes);
RopSrcRow(dp, _skip, lmask, rmask, bytes, op, bp, dh);
}
}
inline void PixRect::DestInfo(int dx0, int dy0, int dw, RasterOp op,
Byte *&dp, int &doff,
Byte &lmask, Byte &rmask, int &bytes)
{
dp = PixelAddress(dx0, dy0);
doff = PixelOffset(dx0, dy0);
if (op == (SRC|DST) || op == DST || op == (SRC^DST) || op == (DST&~SRC))
lmask = rmask = ByteMask;
else {
lmask = RightMask(((BitsPerByte - doff * _depth - 1) % BitsPerByte) + 1);
rmask = LeftMask((((doff + dw) * _depth - 1) % BitsPerByte) + 1);
}
bytes = ((dw + doff) * _depth + BitsPerByte - 1) / BitsPerByte;
if (bytes == 1) lmask &= rmask;
}
void PixRect::Rop(int dx0, int dy0,
int dw, int dh,
RasterOp op,
int z,
PixRect &src,
int sx0, int sy0,
int xo, int yo)
{
((void) ((_depth == src._depth) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "PixRect.C", 93, "_depth == src._depth"), 0) )) ;
if (z > 4) {
int sy = sy0;
int dy = dy0;
int dH = dh;
int dh1 = min((1 << z) - yo, dH);
while (dH > 0) {
int sx = sx0;
int dx = dx0;
int dW = dw;
int dw1 = min((1 << z) - xo, dW);
while (dW > 0) {
Rop(dx, dy, dw1, dh1, op, src.Get(sx, sy));
sx += 1;
dx += dw1;
dW -= dw1;
dw1 = 1 << z;
if (dw1 > dW) dw1 = dW;
}
sy += 1;
dy += dh1;
dH -= dh1;
dh1 = 1 << z;
if (dh1 > dH) dh1 = dH;
}
}
else if (z >= 0) {
int s = 1 << z;
int sbytes = ((dw + xo) * _depth + (src.PixelOffset(sx0, sy0) << z) +
(BitsPerByte << z) - 1) >> (z + LgBitsPerByte);
int ssbytes = (sbytes << z) + 1;
Byte *buf = (Byte*)__builtin_alloca(ssbytes) ;
Byte *sp = src.PixelAddress(sx0, sy0);
int soff = PixelOffset(sx0, sy0);
Byte *dp, lmask, rmask;
int doff, bytes;
DestInfo(dx0, dy0, dw, op,
dp, doff, lmask, rmask, bytes);
int shift = doff - (soff << z) - xo;
while (shift < 0) shift += BitsPerByte;
Byte *bp = &buf[(shift + (soff << z) + xo) / BitsPerByte];
if (lmask == ByteMask && rmask == ByteMask) {
DoRop(dp, dh, ByteMask, ByteMask, bytes,
z, s, op, shift, buf, bp,
sp, src._skip, sbytes, ssbytes, yo);
}
else
DoRop(dp, dh, lmask, rmask, bytes,
z, s, op, shift, buf, bp,
sp, src._skip, sbytes, ssbytes, yo);
}
else if (z == -1) {
int soff = PixelOffset(sx0, sy0);
int doff = PixelOffset(dx0, dy0);
((void) ((soff == 0 && doff == 0) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "PixRect.C", 162, "soff == 0 && doff == 0"), 0) )) ;
Byte *dp0 = PixelAddress(dx0, dy0);
Byte *sp0 = src.PixelAddress(sx0, sy0);
if (_depth == 1) {
int dbytes = (dw + BitsPerByte - 1) / BitsPerByte;
int sbytes = dbytes * 2;
for (int y = 0; y < dh; y++) {
Byte *sp = sp0;
Byte *dp = dp0;
for (int x = 0; x < dbytes; x++) {
Byte mask;
*dp = zoomdown[*sp++] << 4;
*dp++ |= zoomdown[*sp++];
}
dp0 += _skip;
sp0 += src._skip * 2;
}
}
else {
int dbytes = dw * _depth / BitsPerByte;
for (int y = 0; y < dh; y++) {
Byte *sp = sp0;
Byte *dp = dp0;
for (int x = 0; x < dbytes; x++) {
*dp++ = *sp++;
sp++;
}
dp0 += _skip;
sp0 += src._skip * 2;
}
}
}
else {
((void) ((0) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "PixRect.C", 196, "0"), 0) )) ;
}
}
inline void PixRect::DoRop(int dh, Byte *dp, int bytes,
Byte lmask, Byte rmask,
RasterOp op, PadColor value)
{
Byte src = 0;
for (int i = BitsPerByte / _depth; i >= 0; i--) {
src |= value;
value <<= _depth;
}
while (dh--) {
Byte *p = dp;
DoRasterOp(op, *p++, src, lmask);
for (i = 2; i < bytes; i++)
DoRasterOp(op, *p++, src);
DoRasterOp(op, *p, src, rmask);
dp += _skip;
}
}
void PixRect::Rop(int dx0, int dy0,
int dw, int dh,
RasterOp op,
PadColor value)
{
Byte *dp, lmask, rmask;
int doff, bytes;
DestInfo(dx0, dy0, dw, op,
dp, doff, lmask, rmask, bytes);
switch (op) {
case CLR:
DoRop(dh, dp, bytes, lmask, rmask, CLR, value); break;
case (SRC|DST):
DoRop(dh, dp, bytes, ByteMask, ByteMask, SRC|DST, value); break;
case DST:
DoRop(dh, dp, bytes, ByteMask, ByteMask, DST, value); break;
case (SRC^DST):
DoRop(dh, dp, bytes, ByteMask, ByteMask, SRC^DST, value); break;
// This is the case that causes the crash
case (DST&~SRC):
DoRop(dh, dp, bytes, ByteMask, ByteMask, DST&~SRC, value); break;
default:
DoRop(dh, dp, bytes, lmask, rmask, op, value); break;
}
}
void PixRect::ReplRop(int dx0, int dy0,
int dw, int dh,
RasterOp op,
int z,
PixRect &src,
int sx0, int sy0,
int xo0, int yo0)
{
if (z >= 0) {
int sy = sy0;
int yo = yo0;
int dy = dy0;
int dH = dh;
int sh1 = src.Height() - sy0;
int dh1 = min(dh, (sh1 << z) - yo);
while (dH > 0) {
int sx = sx0;
int xo = xo0;
int dx = dx0;
int dW = dw;
int sw1 = src.Width() - sx0;
int dw1 = min(dw, (sw1 << z) - xo0);
while (dW > 0) {
Rop(dx, dy, dw1, dh1, op, z, src, sx, sy, xo, yo);
sx = 0;
xo = 0;
dx += dw1;
dW -= dw1;
dw1 = min(dW, src.Width() << z);
}
sy = 0;
yo = 0;
dy += dh1;
dH -= dh1;
dh1 = min(dH, src.Height() << z);
}
}
else
((void) ((0) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "PixRect.C", 286, "0"), 0) )) ;
}
void PixRect::Stencil(int dx, int dy,
int w, int h,
RasterOp op,
int z,
PixRect &st,
int stx, int sty,
PixRect &src,
int sx, int sy,
int xo, int yo)
{
((void) ((0) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "PixRect.C", 299, "0"), 0) )) ;
}
void PixRect::PolyPoint(PointSet &p, RasterOp op, PadColor color)
{
for (int i = 0; i < p.count(); i++)
Point(p.x(i), p.y(i), op, color);
}
void PixRect::Box(int l, int b, int r, int t, RasterOp op, int val)
{
Line(l, b, l, t, op, val);
Line(l, t, r, t, op, val);
Line(r, t, r, b, op, val);
Line(r, b, l, b, op, val);
}
void PixRect::Text(int x, int y, RasterOp op, PadColor color,
PadFont &font, const char *str)
{
}
void PixRect::Line(int x1, int y1, int x2, int y2, RasterOp op, PadColor color)
{
}
inline boolean PixRect::RowBounds(int y, int &l, int &r)
{
int po = PixelOffset(0, y);
Byte *lp = PixelAddress(0, y);
Byte *rp = PixelAddress(_width-1, y);
Byte lb = (*lp) ? (*lp & _leftmask) : 0;
Byte rb = (*rp) ? (*rp & _rightmask) : 0;
if (lb) l = leftbit[lb] - po;
else if (lp == rp) return false;
else {
int x = BitsPerByte - po;
for (Byte *p = lp + 1; p < rp; p++) {
if (*p) {
l = x + leftbit[*p];
break;
}
x += BitsPerByte;
}
if (p == rp) {
if (rb)
l = x + leftbit[rb];
else
return false;
}
}
int x = (rp - lp) * BitsPerByte - po;
if (rb) r = x + rightbit[rb];
else {
x -= BitsPerByte;
for (Byte *p = rp-1; p > lp; p--) {
if (*p) {
r = x + rightbit[*p];
break;
}
x -= BitsPerByte;
}
if (p == lp)
r = x + rightbit[lb];
}
return true;
}
boolean PixRect::Bounds(int &l, int &b, int &r, int &t)
{
int rowl, rowr;
r = t = -1;
l = _width;
for (b = 0; b < _height; b++)
if (RowBounds(b, l, r)) break;
if (b == _height) return false;
for (t = _height - 1;; t--)
if (RowBounds(t, rowl, rowr)) break;
l = min(l, rowl);
r = min(r, rowr);
for (int y = b+1; y < t; y++) {
RowBounds(y, rowl, rowr);
l = min(l, rowl);
r = max(r, rowr);
}
return true;
}
class ostream &operator<<(ostream &s, PixRect &p)
{
s << "PixRect " << &p << ":\n";
s << " size: (" << p._width << "x" << p._height << "x" << (int)p._depth << ")\n";
s << " offset: (" << p._hoffset << " " << p._voffset << ")";
s << ", ownerp = " << (int)p._ownerp << "\n";
for (int y = 0; y < p._height; y++) {
s << " ";
for (int x = 0; x < p._width; x++)
s << " " << p.Get(x, y);
s << "\n";
}
return s;
}
Technical Details
Message-ID:
<9210292037.AA01124@GRAPHICS.CS.NYU.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!ogicse!uwm.edu!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!graphics.cs.nyu.edu!foxShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!uwm.edu!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!graphics.cs.nyu.edu!fox From: fox@graphics.cs.nyu.edu (David Fox) Newsgroups: gnu.g++.bug Subject: internal error--insn does not satisfy its constraints Message-ID: <9210292037.AA01124@GRAPHICS.CS.NYU.EDU> Date: 29 Oct 92 10:37:23 GMT Article-I.D.: GRAPHICS.9210292037.AA01124 Sender: gnulists@ai.mit.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 2142 Approved: bug-g++@prep.ai.mit.edu