From alkis at cs.uiuc.edu Mon Feb 2 01:31:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon Feb 2 01:31:02 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <200402020730.BAA14512@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.37 -> 1.38 --- Log message: Create an object for tracking physical register usage. This will look much better when I get rid of the reserved registers. --- Diffs of the changes: (+116 -106) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.37 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.38 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.37 Sun Feb 1 14:13:26 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Mon Feb 2 01:30:36 2004 @@ -35,6 +35,69 @@ Statistic<> numPeep ("ra-linearscan", "Number of identity moves eliminated"); + class PhysRegTracker { + private: + const MRegisterInfo* mri_; + std::vector reserved_; + std::vector regUse_; + + public: + PhysRegTracker(MachineFunction* mf) + : mri_(mf ? mf->getTarget().getRegisterInfo() : NULL) { + if (mri_) { + reserved_.assign(mri_->getNumRegs(), false); + regUse_.assign(mri_->getNumRegs(), 0); + } + } + + PhysRegTracker(const PhysRegTracker& rhs) + : mri_(rhs.mri_), + reserved_(rhs.reserved_), + regUse_(rhs.regUse_) { + } + + const PhysRegTracker& operator=(const PhysRegTracker& rhs) { + mri_ = rhs.mri_; + reserved_ = rhs.reserved_; + regUse_ = rhs.regUse_; + return *this; + } + + void reservePhysReg(unsigned physReg) { + reserved_[physReg] = true; + } + + void addPhysRegUse(unsigned physReg) { + ++regUse_[physReg]; + for (const unsigned* as = mri_->getAliasSet(physReg); *as; ++as) { + physReg = *as; + ++regUse_[physReg]; + } + } + + void delPhysRegUse(unsigned physReg) { + assert(regUse_[physReg] != 0); + --regUse_[physReg]; + for (const unsigned* as = mri_->getAliasSet(physReg); *as; ++as) { + physReg = *as; + assert(regUse_[physReg] != 0); + --regUse_[physReg]; + } + } + + bool isPhysRegReserved(unsigned physReg) const { + return reserved_[physReg]; + } + + bool isPhysRegAvail(unsigned physReg) const { + return regUse_[physReg] == 0 && !isPhysRegReserved(physReg); + } + + bool isReservedPhysRegAvail(unsigned physReg) const { + return regUse_[physReg] == 0 && isPhysRegReserved(physReg); + } + }; + class RA : public MachineFunctionPass { private: MachineFunction* mf_; @@ -50,11 +113,7 @@ Regs tempUseOperands_; Regs tempDefOperands_; - typedef std::vector RegMask; - RegMask reserved_; - - unsigned regUse_[MRegisterInfo::FirstVirtualRegister]; - unsigned regUseBackup_[MRegisterInfo::FirstVirtualRegister]; + PhysRegTracker prt_; typedef std::map Virt2PhysMap; Virt2PhysMap v2pMap_; @@ -65,6 +124,11 @@ int instrAdded_; public: + RA() + : prt_(NULL) { + + } + virtual const char* getPassName() const { return "Linear Scan Register Allocator"; } @@ -97,7 +161,8 @@ /// interval. Currently we spill the interval with the last /// end point in the active and inactive lists and the current /// interval - void assignStackSlotAtInterval(IntervalPtrs::value_type cur); + void assignStackSlotAtInterval(IntervalPtrs::value_type cur, + const PhysRegTracker& backupPtr); /// /// register handling helpers @@ -108,14 +173,6 @@ /// 0 unsigned getFreePhysReg(IntervalPtrs::value_type cur); - /// physRegAvailable - returns true if the specifed physical - /// register is available - bool physRegAvailable(unsigned physReg); - - /// tempPhysRegAvailable - returns true if the specifed - /// temporary physical register is available - bool tempPhysRegAvailable(unsigned physReg); - /// getFreeTempPhysReg - return a free temprorary physical /// register for this virtual register if we have one (should /// never return 0) @@ -146,19 +203,9 @@ /// an assigned stack slot void loadVirt2PhysReg(unsigned virtReg, unsigned physReg); - void markPhysRegFree(unsigned physReg); - void markPhysRegNotFree(unsigned physReg); - - void backupRegUse() { - memcpy(regUseBackup_, regUse_, sizeof(regUseBackup_)); - } - - void restoreRegUse() { - memcpy(regUse_, regUseBackup_, sizeof(regUseBackup_)); - } - void printVirtRegAssignment() const { std::cerr << "register assignment:\n"; + for (Virt2PhysMap::const_iterator i = v2pMap_.begin(), e = v2pMap_.end(); i != e; ++i) { assert(i->second != 0); @@ -187,20 +234,20 @@ } } - void printFreeRegs(const char* const str, - const TargetRegisterClass* rc) const { - if (str) std::cerr << str << ':'; - for (TargetRegisterClass::iterator i = - rc->allocation_order_begin(*mf_); - i != rc->allocation_order_end(*mf_); ++i) { - unsigned reg = *i; - if (!regUse_[reg]) { - std::cerr << ' ' << mri_->getName(reg); - if (reserved_[reg]) std::cerr << "*"; - } - } - std::cerr << '\n'; - } +// void printFreeRegs(const char* const str, +// const TargetRegisterClass* rc) const { +// if (str) std::cerr << str << ':'; +// for (TargetRegisterClass::iterator i = +// rc->allocation_order_begin(*mf_); +// i != rc->allocation_order_end(*mf_); ++i) { +// unsigned reg = *i; +// if (!regUse_[reg]) { +// std::cerr << ' ' << mri_->getName(reg); +// if (reserved_[reg]) std::cerr << "*"; +// } +// } +// std::cerr << '\n'; +// } }; } @@ -220,10 +267,9 @@ tm_ = &fn.getTarget(); mri_ = tm_->getRegisterInfo(); li_ = &getAnalysis(); - initIntervalSets(li_->getIntervals()); + prt_ = PhysRegTracker(mf_); - memset(regUse_, 0, sizeof(regUse_)); - memset(regUseBackup_, 0, sizeof(regUseBackup_)); + initIntervalSets(li_->getIntervals()); // FIXME: this will work only for the X86 backend. I need to // device an algorthm to select the minimal (considering register @@ -234,15 +280,14 @@ // R16: CX, DI, // R32: ECX, EDI, // RFP: FP5, FP6 - reserved_.assign(MRegisterInfo::FirstVirtualRegister, false); - reserved_[ 8] = true; /* CH */ - reserved_[ 9] = true; /* CL */ - reserved_[10] = true; /* CX */ - reserved_[12] = true; /* DI */ - reserved_[18] = true; /* ECX */ - reserved_[19] = true; /* EDI */ - reserved_[28] = true; /* FP5 */ - reserved_[29] = true; /* FP6 */ + prt_.reservePhysReg( 8); /* CH */ + prt_.reservePhysReg( 9); /* CL */ + prt_.reservePhysReg(10); /* CX */ + prt_.reservePhysReg(12); /* DI */ + prt_.reservePhysReg(18); /* ECX */ + prt_.reservePhysReg(19); /* EDI */ + prt_.reservePhysReg(28); /* FP5 */ + prt_.reservePhysReg(29); /* FP6 */ // linear scan algorithm DEBUG(std::cerr << "Machine Function\n"); @@ -279,14 +324,14 @@ // if this register is fixed we are done if (MRegisterInfo::isPhysicalRegister(cur->reg)) { - markPhysRegNotFree(cur->reg); + prt_.addPhysRegUse(cur->reg); active_.push_back(cur); } // otherwise we are allocating a virtual register. try to find // a free physical register or spill an interval in order to // assign it one (we could spill the current though). else { - backupRegUse(); + PhysRegTracker backupPrt = prt_; // for every interval in inactive we overlap with, mark the // register as not free @@ -297,7 +342,7 @@ reg = v2pMap_[reg]; if (cur->overlaps(**i)) { - markPhysRegNotFree(reg); + prt_.addPhysRegUse(reg); } } @@ -308,17 +353,17 @@ assert(MRegisterInfo::isPhysicalRegister((*i)->reg) && "virtual register interval in fixed set?"); if (cur->overlaps(**i)) - markPhysRegNotFree((*i)->reg); + prt_.addPhysRegUse((*i)->reg); } DEBUG(std::cerr << "\tallocating current interval:\n"); unsigned physReg = getFreePhysReg(cur); if (!physReg) { - assignStackSlotAtInterval(cur); + assignStackSlotAtInterval(cur, backupPrt); } else { - restoreRegUse(); + prt_ = backupPrt; assignVirt2PhysReg(cur->reg, physReg); active_.push_back(cur); } @@ -334,7 +379,7 @@ if (MRegisterInfo::isVirtualRegister(reg)) { reg = v2pMap_[reg]; } - markPhysRegFree(reg); + prt_.delPhysRegUse(reg); } typedef LiveIntervals::Reg2RegMap Reg2RegMap; @@ -514,7 +559,7 @@ if (MRegisterInfo::isVirtualRegister(reg)) { reg = v2pMap_[reg]; } - markPhysRegFree(reg); + prt_.delPhysRegUse(reg); // remove from active i = active_.erase(i); } @@ -524,7 +569,7 @@ if (MRegisterInfo::isVirtualRegister(reg)) { reg = v2pMap_[reg]; } - markPhysRegFree(reg); + prt_.delPhysRegUse(reg); // add to inactive inactive_.push_back(*i); // remove from active @@ -554,7 +599,7 @@ if (MRegisterInfo::isVirtualRegister(reg)) { reg = v2pMap_[reg]; } - markPhysRegNotFree(reg); + prt_.addPhysRegUse(reg); // add to active active_.push_back(*i); // remove from inactive @@ -578,7 +623,8 @@ } } -void RA::assignStackSlotAtInterval(IntervalPtrs::value_type cur) +void RA::assignStackSlotAtInterval(IntervalPtrs::value_type cur, + const PhysRegTracker& backupPrt) { DEBUG(std::cerr << "\t\tassigning stack slot at interval " << *cur << ":\n"); @@ -631,7 +677,7 @@ for (TargetRegisterClass::iterator i = rc->allocation_order_begin(*mf_); i != rc->allocation_order_end(*mf_); ++i) { unsigned reg = *i; - if (!reserved_[reg] && minWeight > regWeight[reg]) { + if (!prt_.isPhysRegReserved(reg) && minWeight > regWeight[reg]) { minWeight = regWeight[reg]; minReg = reg; } @@ -640,7 +686,7 @@ << mri_->getName(minReg) << " (" << minWeight << ")\n"); if (cur->weight < minWeight) { - restoreRegUse(); + prt_ = backupPrt; DEBUG(std::cerr << "\t\t\t\tspilling: " << *cur << '\n'); assignVirt2StackSlot(cur->reg); } @@ -684,23 +730,15 @@ unsigned physReg = getFreePhysReg(cur); assert(physReg && "no free physical register after spill?"); - restoreRegUse(); + prt_ = backupPrt; for (unsigned i = 0; i < spilled.size(); ++i) - markPhysRegFree(spilled[i]); + prt_.delPhysRegUse(spilled[i]); assignVirt2PhysReg(cur->reg, physReg); active_.push_back(cur); } } -bool RA::physRegAvailable(unsigned physReg) -{ - assert(!reserved_[physReg] && - "cannot call this method with a reserved register"); - - return !regUse_[physReg]; -} - unsigned RA::getFreePhysReg(IntervalPtrs::value_type cur) { DEBUG(std::cerr << "\t\tgetting free physical register: "); @@ -709,7 +747,7 @@ for (TargetRegisterClass::iterator i = rc->allocation_order_begin(*mf_); i != rc->allocation_order_end(*mf_); ++i) { unsigned reg = *i; - if (!reserved_[reg] && !regUse_[reg]) { + if (prt_.isPhysRegAvail(reg)) { DEBUG(std::cerr << mri_->getName(reg) << '\n'); return reg; } @@ -719,14 +757,6 @@ return 0; } -bool RA::tempPhysRegAvailable(unsigned physReg) -{ - assert(reserved_[physReg] && - "cannot call this method with a not reserved temp register"); - - return !regUse_[physReg]; -} - unsigned RA::getFreeTempPhysReg(unsigned virtReg) { DEBUG(std::cerr << "\t\tgetting free temporary physical register: "); @@ -738,7 +768,7 @@ i(rc->allocation_order_end(*mf_)), e(rc->allocation_order_begin(*mf_)); i != e; ++i) { unsigned reg = *i; - if (reserved_[reg] && !regUse_[reg]) { + if (prt_.isReservedPhysRegAvail(reg)) { DEBUG(std::cerr << mri_->getName(reg) << '\n'); return reg; } @@ -753,7 +783,7 @@ bool inserted = v2pMap_.insert(std::make_pair(virtReg, physReg)).second; assert(inserted && "attempting to assign a virt->phys mapping to an " "already mapped register"); - markPhysRegNotFree(physReg); + prt_.addPhysRegUse(physReg); } void RA::clearVirtReg(unsigned virtReg) @@ -762,7 +792,7 @@ assert(it != v2pMap_.end() && "attempting to clear a not allocated virtual register"); unsigned physReg = it->second; - markPhysRegFree(physReg); + prt_.delPhysRegUse(physReg); v2pMap_.erase(it); DEBUG(std::cerr << "\t\t\tcleared register " << mri_->getName(physReg) << "\n"); @@ -815,26 +845,6 @@ instrAdded_ += mri_->loadRegFromStackSlot(*currentMbb_, currentInstr_, physReg, frameIndex, rc); assignVirt2PhysReg(virtReg, physReg); -} - -void RA::markPhysRegFree(unsigned physReg) -{ - assert(regUse_[physReg] != 0); - --regUse_[physReg]; - for (const unsigned* as = mri_->getAliasSet(physReg); *as; ++as) { - physReg = *as; - assert(regUse_[physReg] != 0); - --regUse_[physReg]; - } -} - -void RA::markPhysRegNotFree(unsigned physReg) -{ - ++regUse_[physReg]; - for (const unsigned* as = mri_->getAliasSet(physReg); *as; ++as) { - physReg = *as; - ++regUse_[physReg]; - } } FunctionPass* llvm::createLinearScanRegisterAllocator() { From lattner at cs.uiuc.edu Mon Feb 2 11:43:08 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 2 11:43:08 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/llvm-expand.c Message-ID: <200402021742.LAA29194@niobe.cs.uiuc.edu> Changes in directory gcc-3.4/gcc: llvm-expand.c updated: 1.4 -> 1.5 --- Log message: Expand -X (where X is a floating point type) as -0.0 - X instead of 0.0 - X, in order to fix PR216. --- Diffs of the changes: (+4 -1) Index: gcc-3.4/gcc/llvm-expand.c diff -u gcc-3.4/gcc/llvm-expand.c:1.4 gcc-3.4/gcc/llvm-expand.c:1.5 --- gcc-3.4/gcc/llvm-expand.c:1.4 Fri Jan 30 16:28:42 2004 +++ gcc-3.4/gcc/llvm-expand.c Mon Feb 2 11:42:13 2004 @@ -5677,7 +5677,10 @@ case NEGATE_EXPR: /* -A === 0-A */ op1 = llvm_expand_expr(Fn, TREE_OPERAND(exp, 0), 0); - op0 = llvm_constant_get_null(op1->Ty); + if (!llvm_type_is_fp(op1->Ty)) + op0 = llvm_constant_get_null(op1->Ty); + else + op0 = llvm_constant_new(op1->Ty, "-0.0"); Result = append_inst(Fn, create_binary_inst("tmp", O_Sub, op0, op1)); break; case BIT_NOT_EXPR: /* ~A === A^-1 */ From lattner at cs.uiuc.edu Mon Feb 2 11:50:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 2 11:50:02 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402021749.LAA29234@niobe.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.104 -> 1.105 --- Log message: Bug fixed --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.104 llvm/docs/ReleaseNotes.html:1.105 --- llvm/docs/ReleaseNotes.html:1.104 Sun Feb 1 16:52:12 2004 +++ llvm/docs/ReleaseNotes.html Mon Feb 2 11:48:56 2004 @@ -174,6 +174,7 @@ management functions in libc runtime to allow them to be overriden
  • [llvm-gcc] asserts when an extern inline function is redefined
  • [llvmg++] Dynamically initialized constants cannot be marked 'constant'
  • +
  • [llvmgcc] floating-point unary minus is incorrect for +0.0
  • @@ -613,7 +614,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/01 22:52:12 $ + Last modified: $Date: 2004/02/02 17:48:56 $ From lattner at cs.uiuc.edu Mon Feb 2 11:50:06 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 2 11:50:06 2004 Subject: [llvm-commits] CVS: llvm-www/releases/1.1/docs/ReleaseNotes.html Message-ID: <200402021749.LAA29582@niobe.cs.uiuc.edu> Changes in directory llvm-www/releases/1.1/docs: ReleaseNotes.html updated: 1.13 -> 1.14 --- Log message: Bug found --- Diffs of the changes: (+2 -1) Index: llvm-www/releases/1.1/docs/ReleaseNotes.html diff -u llvm-www/releases/1.1/docs/ReleaseNotes.html:1.13 llvm-www/releases/1.1/docs/ReleaseNotes.html:1.14 --- llvm-www/releases/1.1/docs/ReleaseNotes.html:1.13 Sun Feb 1 16:52:49 2004 +++ llvm-www/releases/1.1/docs/ReleaseNotes.html Mon Feb 2 11:49:04 2004 @@ -450,6 +450,7 @@
  • [llvm-gcc] asserts when an extern inline function is redefined
  • +
  • [llvmgcc] floating-point unary minus is incorrect for +0.0
  • @@ -761,7 +762,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/01 22:52:49 $ + Last modified: $Date: 2004/02/02 17:49:04 $ From lattner at cs.uiuc.edu Mon Feb 2 12:41:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 2 12:41:04 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200402021840.MAA30943@niobe.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.39 -> 1.40 --- Log message: Add a new method to ConstantFP --- Diffs of the changes: (+18 -0) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.39 llvm/include/llvm/Constants.h:1.40 --- llvm/include/llvm/Constants.h:1.39 Sun Feb 1 16:48:09 2004 +++ llvm/include/llvm/Constants.h Mon Feb 2 12:40:29 2004 @@ -283,6 +283,24 @@ return T.I == 0; } + /// isExactlyValue - We don't rely on operator== working on double values, as + /// it returns true for things that are clearly not equal, like -0.0 and 0.0. + /// As such, this method can be used to do an exact bit-for-bit comparison of + /// two floating point values. + bool isExactlyValue(double V) const { + union { + double V; + uint64_t I; + } T1; + T1.V = Val; + union { + double V; + uint64_t I; + } T2; + T2.V = Val; + return T1.I == T2.I; + } + /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ConstantFP *) { return true; } static bool classof(const Constant *CPV); // defined in Constants.cpp From gaeke at cs.uiuc.edu Mon Feb 2 12:43:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Feb 2 12:43:02 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/llvm-out.h Message-ID: <200402021839.MAA06119@psmith.cs.uiuc.edu> Changes in directory gcc-3.4/gcc: llvm-out.h updated: 1.1 -> 1.2 --- Log message: Address PR186 by unconditionally defining SUPPORTS_WEAK and SUPPORTS_ONE_ONLY if EMIT_LLVM is set. --- Diffs of the changes: (+10 -0) Index: gcc-3.4/gcc/llvm-out.h diff -u gcc-3.4/gcc/llvm-out.h:1.1 gcc-3.4/gcc/llvm-out.h:1.2 --- gcc-3.4/gcc/llvm-out.h:1.1 Thu Jan 8 16:35:32 2004 +++ gcc-3.4/gcc/llvm-out.h Mon Feb 2 12:39:26 2004 @@ -75,6 +75,16 @@ #undef ASM_OUTPUT_DEF #undef ASM_OUTPUT_WEAK_ALIAS +/* Enable weak and link-once-only symbol support, regardless of target. */ +#ifdef SUPPORTS_WEAK +#undef SUPPORTS_WEAK +#endif +#define SUPPORTS_WEAK 1 +#ifdef SUPPORTS_ONE_ONLY +#undef SUPPORTS_ONE_ONLY +#endif +#define SUPPORTS_ONE_ONLY 1 + #define LLVM_TODO() \ do { \ From lattner at cs.uiuc.edu Mon Feb 2 12:54:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 2 12:54:03 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200402021853.MAA31069@niobe.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.40 -> 1.41 --- Log message: Correct the method I just added to actually return false sometimes --- Diffs of the changes: (+1 -1) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.40 llvm/include/llvm/Constants.h:1.41 --- llvm/include/llvm/Constants.h:1.40 Mon Feb 2 12:40:29 2004 +++ llvm/include/llvm/Constants.h Mon Feb 2 12:53:04 2004 @@ -297,7 +297,7 @@ double V; uint64_t I; } T2; - T2.V = Val; + T2.V = V; return T1.I == T2.I; } From lattner at cs.uiuc.edu Mon Feb 2 12:57:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 2 12:57:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200402021856.MAA23938@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.150 -> 1.151 --- Log message: Codegen -0.0 correctly. Do not use fldz! This is another -0.0 == +0.0 problem, arg. --- Diffs of the changes: (+4 -4) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.150 llvm/lib/Target/X86/InstSelectSimple.cpp:1.151 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.150 Fri Jan 30 16:13:44 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Mon Feb 2 12:56:30 2004 @@ -438,10 +438,9 @@ BMI(MBB, IP, IntegralOpcodeTab[Class], 1, R).addZImm(CI->getRawValue()); } } else if (ConstantFP *CFP = dyn_cast(C)) { - double Value = CFP->getValue(); - if (Value == +0.0) + if (CFP->isExactlyValue(+0.0)) BMI(MBB, IP, X86::FLD0, 0, R); - else if (Value == +1.0) + else if (CFP->isExactlyValue(+1.0)) BMI(MBB, IP, X86::FLD1, 0, R); else { // Otherwise we need to spill the constant to memory... @@ -1212,7 +1211,7 @@ // sub 0, X -> neg X if (OperatorClass == 1 && Class != cLong) - if (ConstantInt *CI = dyn_cast(Op0)) + if (ConstantInt *CI = dyn_cast(Op0)) { if (CI->isNullValue()) { unsigned op1Reg = getReg(Op1, MBB, IP); switch (Class) { @@ -1228,6 +1227,7 @@ return; } } + } if (!isa(Op1) || Class == cLong) { static const unsigned OpcodeTab[][4] = { From lattner at cs.uiuc.edu Mon Feb 2 13:01:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 2 13:01:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/UnitTests/2004-02-02-NegativeZero.c Message-ID: <200402021900.NAA24725@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/UnitTests: 2004-02-02-NegativeZero.c added (r1.1) --- Log message: New testcase for -0.0 handling --- Diffs of the changes: (+12 -0) Index: llvm/test/Programs/SingleSource/UnitTests/2004-02-02-NegativeZero.c diff -c /dev/null llvm/test/Programs/SingleSource/UnitTests/2004-02-02-NegativeZero.c:1.1 *** /dev/null Mon Feb 2 13:00:39 2004 --- llvm/test/Programs/SingleSource/UnitTests/2004-02-02-NegativeZero.c Mon Feb 2 13:00:29 2004 *************** *** 0 **** --- 1,12 ---- + void test(double X) { + printf("%f %f\n", -0.0 - X, -X); + } + int main() { + test(+0.0); + test(-0.0); + + + printf("negzero = %f poszero = %f\n", -0.0, +0.0); + } + + From gaeke at cs.uiuc.edu Mon Feb 2 13:06:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Feb 2 13:06:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetMachineImpls.h Message-ID: <200402021905.NAA26884@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetMachineImpls.h updated: 1.8 -> 1.9 --- Log message: Add prototype for llvm::allocatePowerPCTargetMachine(). --- Diffs of the changes: (+8 -0) Index: llvm/include/llvm/Target/TargetMachineImpls.h diff -u llvm/include/llvm/Target/TargetMachineImpls.h:1.8 llvm/include/llvm/Target/TargetMachineImpls.h:1.9 --- llvm/include/llvm/Target/TargetMachineImpls.h:1.8 Sun Dec 28 03:48:17 2003 +++ llvm/include/llvm/Target/TargetMachineImpls.h Mon Feb 2 13:05:08 2004 @@ -36,6 +36,14 @@ // TargetMachine *allocateX86TargetMachine(const Module &M, IntrinsicLowering *IL = 0); + + // allocatePowerPCTargetMachine - Allocate and return a subclass + // of TargetMachine that implements the PowerPC backend. This takes + // ownership of the IntrinsicLowering pointer, deleting it when + // the target machine is destroyed. + // + TargetMachine *allocatePowerPCTargetMachine(const Module &M, + IntrinsicLowering *IL = 0); } // End llvm namespace #endif From gaeke at cs.uiuc.edu Mon Feb 2 13:06:04 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Feb 2 13:06:04 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PowerPC.h Message-ID: <200402021905.NAA26950@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PowerPC.h updated: 1.1 -> 1.2 --- Log message: Add comments describing how you would add prototypes for factory methods for PowerPC-specific passes here. --- Diffs of the changes: (+15 -0) Index: llvm/lib/Target/PowerPC/PowerPC.h diff -u llvm/lib/Target/PowerPC/PowerPC.h:1.1 llvm/lib/Target/PowerPC/PowerPC.h:1.2 --- llvm/lib/Target/PowerPC/PowerPC.h:1.1 Wed Jan 21 15:13:19 2004 +++ llvm/lib/Target/PowerPC/PowerPC.h Mon Feb 2 13:05:28 2004 @@ -15,6 +15,21 @@ #ifndef TARGET_POWERPC_H #define TARGET_POWERPC_H +#include + +namespace llvm { + +class FunctionPass; +class TargetMachine; + +// Here is where you would define factory methods for powerpc-specific +// passes. For example: +// FunctionPass *createPowerPCSimpleInstructionSelector (TargetMachine &TM); +// FunctionPass *createPowerPCCodePrinterPass(std::ostream &OS, +// TargetMachine &TM); + +} // end namespace llvm; + // Defines symbolic names for PowerPC registers. This defines a mapping from // register name to register number. // From gaeke at cs.uiuc.edu Mon Feb 2 13:07:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Feb 2 13:07:03 2004 Subject: [llvm-commits] CVS: llvm/tools/llc/llc.cpp Message-ID: <200402021906.NAA27073@zion.cs.uiuc.edu> Changes in directory llvm/tools/llc: llc.cpp updated: 1.88 -> 1.89 --- Log message: Add a -march=powerpc option. Automatically select it if this looks like a big-endian, 32-bit module, or if __ppc__, __POWERPC__, or __APPLE__ are defined. --- Diffs of the changes: (+10 -1) Index: llvm/tools/llc/llc.cpp diff -u llvm/tools/llc/llc.cpp:1.88 llvm/tools/llc/llc.cpp:1.89 --- llvm/tools/llc/llc.cpp:1.88 Sun Dec 28 03:51:04 2003 +++ llvm/tools/llc/llc.cpp Mon Feb 2 13:06:12 2004 @@ -37,12 +37,13 @@ static cl::opt Force("f", cl::desc("Overwrite output files")); -enum ArchName { noarch, x86, Sparc }; +enum ArchName { noarch, x86, Sparc, PowerPC }; static cl::opt Arch("march", cl::desc("Architecture to generate assembly for:"), cl::Prefix, cl::values(clEnumVal(x86, " IA-32 (Pentium and above)"), clEnumValN(Sparc, "sparc", " SPARC V9"), + clEnumValN(PowerPC, "powerpc", " PowerPC"), 0), cl::init(noarch)); @@ -87,6 +88,9 @@ case Sparc: TargetMachineAllocator = allocateSparcTargetMachine; break; + case PowerPC: + TargetMachineAllocator = allocatePowerPCTargetMachine; + break; default: // Decide what the default target machine should be, by looking at // the module. This heuristic (ILP32, LE -> IA32; LP64, BE -> @@ -95,6 +99,9 @@ if (mod.getEndianness() == Module::LittleEndian && mod.getPointerSize() == Module::Pointer32) { TargetMachineAllocator = allocateX86TargetMachine; + } else if (mod.getEndianness() == Module::BigEndian && + mod.getPointerSize() == Module::Pointer32) { + TargetMachineAllocator = allocatePowerPCTargetMachine; } else if (mod.getEndianness() == Module::BigEndian && mod.getPointerSize() == Module::Pointer64) { TargetMachineAllocator = allocateSparcTargetMachine; @@ -105,6 +112,8 @@ TargetMachineAllocator = allocateX86TargetMachine; #elif defined(sparc) || defined(__sparc__) || defined(__sparcv9) TargetMachineAllocator = allocateSparcTargetMachine; +#elif defined(__POWERPC__) || defined(__ppc__) || defined(__APPLE__) + TargetMachineAllocator = allocatePowerPCTargetMachine; #else std::cerr << argv[0] << ": module does not specify a target to use. " << "You must use the -march option.\n"; From gaeke at cs.uiuc.edu Mon Feb 2 13:07:07 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Feb 2 13:07:07 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp Message-ID: <200402021906.NAA27117@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PowerPCTargetMachine.cpp updated: 1.3 -> 1.4 --- Log message: Include PowerPC.h. Flesh out the stub versions of addPassesToEmitAssembly() and addPassesToJITCompile() slightly. --- Diffs of the changes: (+13 -3) Index: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp diff -u llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.3 llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.4 --- llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.3 Fri Jan 23 00:39:30 2004 +++ llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp Mon Feb 2 13:06:36 2004 @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include "PowerPCTargetMachine.h" +#include "PowerPC.h" #include "llvm/Module.h" #include "llvm/PassManager.h" #include "llvm/Target/TargetMachineImpls.h" @@ -35,17 +36,26 @@ FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 4), JITInfo(*this) { } -// addPassesToEmitAssembly - We currently use all of the same passes as the JIT -// does to emit statically compiled machine code. +/// addPassesToEmitAssembly - Add passes to the specified pass manager +/// to implement a static compiler for this target. +/// bool PowerPCTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) { - return true; + // + PM.add(createRegisterAllocator()); + PM.add(createPrologEpilogCodeInserter()); + // + PM.add(createMachineCodeDeleter()); + return true; // change to `return false' when this actually works. } /// addPassesToJITCompile - Add passes to the specified pass manager to /// implement a fast dynamic compiler for this target. /// void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) { + // + PM.add(createRegisterAllocator()); + PM.add(createPrologEpilogCodeInserter()); } } // end namespace llvm From gaeke at cs.uiuc.edu Mon Feb 2 13:07:10 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Feb 2 13:07:10 2004 Subject: [llvm-commits] CVS: llvm/tools/llc/Makefile Message-ID: <200402021906.NAA27025@zion.cs.uiuc.edu> Changes in directory llvm/tools/llc: Makefile updated: 1.44 -> 1.45 --- Log message: Link in the PowerPC back-end. --- Diffs of the changes: (+1 -0) Index: llvm/tools/llc/Makefile diff -u llvm/tools/llc/Makefile:1.44 llvm/tools/llc/Makefile:1.45 --- llvm/tools/llc/Makefile:1.44 Mon Dec 15 17:10:25 2003 +++ llvm/tools/llc/Makefile Mon Feb 2 13:05:52 2004 @@ -10,6 +10,7 @@ TOOLNAME = llc USEDLIBS = sparc \ x86 \ + powerpc \ selectiondag \ regalloc \ sched \ From lattner at cs.uiuc.edu Mon Feb 2 13:24:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 2 13:24:04 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/FloatingPoint.cpp Message-ID: <200402021923.NAA13138@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: FloatingPoint.cpp updated: 1.17 -> 1.18 --- Log message: Add support for OneArgFPRW instructions, fix a couple of typeos --- Diffs of the changes: (+43 -12) Index: llvm/lib/Target/X86/FloatingPoint.cpp diff -u llvm/lib/Target/X86/FloatingPoint.cpp:1.17 llvm/lib/Target/X86/FloatingPoint.cpp:1.18 --- llvm/lib/Target/X86/FloatingPoint.cpp:1.17 Fri Jan 30 16:25:18 2004 +++ llvm/lib/Target/X86/FloatingPoint.cpp Mon Feb 2 13:23:15 2004 @@ -94,7 +94,7 @@ return StackTop - 1 - getSlot(RegNo) + llvm::X86::ST0; } - // pushReg - Push the specifiex FP register onto the stack + // pushReg - Push the specified FP register onto the stack void pushReg(unsigned Reg) { assert(Reg < 8 && "Register number out of range!"); assert(StackTop < 8 && "Stack overflow!"); @@ -140,6 +140,7 @@ void handleZeroArgFP(MachineBasicBlock::iterator &I); void handleOneArgFP(MachineBasicBlock::iterator &I); + void handleOneArgFPRW(MachineBasicBlock::iterator &I); void handleTwoArgFP(MachineBasicBlock::iterator &I); void handleSpecialFP(MachineBasicBlock::iterator &I); }; @@ -219,14 +220,11 @@ }); switch (Flags & X86II::FPTypeMask) { - case X86II::ZeroArgFP: handleZeroArgFP(I); break; - case X86II::OneArgFP: handleOneArgFP(I); break; - - case X86II::OneArgFPRW: // ST(0) = fsqrt(ST(0)) - assert(0 && "FP instr type not handled yet!"); - - case X86II::TwoArgFP: handleTwoArgFP(I); break; - case X86II::SpecialFP: handleSpecialFP(I); break; + case X86II::ZeroArgFP: handleZeroArgFP(I); break; + case X86II::OneArgFP: handleOneArgFP(I); break; // fstp ST(0) + case X86II::OneArgFPRW: handleOneArgFPRW(I); break; // ST(0) = fsqrt(ST(0)) + case X86II::TwoArgFP: handleTwoArgFP(I); break; + case X86II::SpecialFP: handleSpecialFP(I); break; default: assert(0 && "Unknown FP Type!"); } @@ -371,7 +369,7 @@ //===----------------------------------------------------------------------===// /// handleZeroArgFP - ST(0) = fld0 ST(0) = flds -// +/// void FPS::handleZeroArgFP(MachineBasicBlock::iterator &I) { MachineInstr *MI = *I; unsigned DestReg = getFPReg(MI->getOperand(0)); @@ -381,12 +379,13 @@ pushReg(DestReg); } -/// handleOneArgFP - fst ST(0), -// +/// handleOneArgFP - fst , ST(0) +/// void FPS::handleOneArgFP(MachineBasicBlock::iterator &I) { MachineInstr *MI = *I; assert(MI->getNumOperands() == 5 && "Can only handle fst* instructions!"); + // Is this the last use of the source register? unsigned Reg = getFPReg(MI->getOperand(4)); bool KillsSrc = false; for (LiveVariables::killed_iterator KI = LV->killed_begin(MI), @@ -413,6 +412,38 @@ popStackAfter(I); } } + + +/// handleOneArgFPRW - fchs - ST(0) = -ST(0) +/// +void FPS::handleOneArgFPRW(MachineBasicBlock::iterator &I) { + MachineInstr *MI = *I; + assert(MI->getNumOperands() == 2 && "Can only handle fst* instructions!"); + + // Is this the last use of the source register? + unsigned Reg = getFPReg(MI->getOperand(1)); + bool KillsSrc = false; + for (LiveVariables::killed_iterator KI = LV->killed_begin(MI), + E = LV->killed_end(MI); KI != E; ++KI) + KillsSrc |= KI->second == X86::FP0+Reg; + + if (KillsSrc) { + // If this is the last use of the source register, just make sure it's on + // the top of the stack. + moveToTop(Reg, I); + assert(StackTop > 0 && "Stack cannot be empty!"); + --StackTop; + pushReg(getFPReg(MI->getOperand(0))); + } else { + // If this is not the last use of the source register, _copy_ it to the top + // of the stack. + duplicateToTop(Reg, getFPReg(MI->getOperand(0)), I); + } + + MI->RemoveOperand(1); // Drop the source operand. + MI->RemoveOperand(0); // Drop the destination operand. +} + //===----------------------------------------------------------------------===// // Define tables of various ways to map pseudo instructions From lattner at cs.uiuc.edu Mon Feb 2 13:32:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 2 13:32:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp X86InstrInfo.td Message-ID: <200402021931.NAA17272@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.151 -> 1.152 X86InstrInfo.td updated: 1.15 -> 1.16 --- Log message: Generate the fchs instruction to negate a floating point number --- Diffs of the changes: (+15 -1) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.151 llvm/lib/Target/X86/InstSelectSimple.cpp:1.152 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.151 Mon Feb 2 12:56:30 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Mon Feb 2 13:31:38 2004 @@ -1227,7 +1227,13 @@ return; } } - } + } else if (ConstantFP *CFP = dyn_cast(Op0)) + if (CFP->isExactlyValue(-0.0)) { + // -0.0 - X === -X + unsigned op1Reg = getReg(Op1, MBB, IP); + BMI(MBB, IP, X86::FCHS, 1, DestReg).addReg(op1Reg); + return; + } if (!isa(Op1) || Class == cLong) { static const unsigned OpcodeTab[][4] = { Index: llvm/lib/Target/X86/X86InstrInfo.td diff -u llvm/lib/Target/X86/X86InstrInfo.td:1.15 llvm/lib/Target/X86/X86InstrInfo.td:1.16 --- llvm/lib/Target/X86/X86InstrInfo.td:1.15 Sat Dec 20 10:22:59 2003 +++ llvm/lib/Target/X86/X86InstrInfo.td Mon Feb 2 13:31:38 2004 @@ -388,6 +388,10 @@ class FPInst o, Format F, ArgType t, FPFormat fp> : X86Inst { let FPForm = fp; let FPFormBits = FPForm.Value; } +// Pseudo instructions for floating point. We use these pseudo instructions +// because they can be expanded by the fp spackifier into one of many different +// forms of instructions for doing these operations. Until the stackifier runs, +// we prefer to be abstract. def FpMOV : FPInst<"FMOV", 0, Pseudo, ArgF80, SpecialFP>; // f1 = fmov f2 def FpADD : FPInst<"FADD", 0, Pseudo, ArgF80, TwoArgFP>; // f1 = fadd f2, f3 def FpSUB : FPInst<"FSUB", 0, Pseudo, ArgF80, TwoArgFP>; // f1 = fsub f2, f3 @@ -428,6 +432,10 @@ // Floating point constant loads... def FLD0 : FPInst<"fldz", 0xEE, RawFrm, ArgF80, ZeroArgFP>, D9; def FLD1 : FPInst<"fld1", 0xE8, RawFrm, ArgF80, ZeroArgFP>, D9; + + +// Unary read-modify-write operations... +def FCHS : FPInst<"fchs", 0xE0, RawFrm, ArgF80, OneArgFPRW>, D9, Imp<[ST0],[ST0]>; // f1 = fchs f2 // Binary arithmetic operations... class FPST0rInst o> From gaeke at cs.uiuc.edu Mon Feb 2 13:33:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Feb 2 13:33:03 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp Message-ID: <200402021932.NAA17659@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: DeadArgumentElimination.cpp updated: 1.14 -> 1.15 --- Log message: Make deadarghaX0r warning louder. (I just love typing haX0r. haX0r haX0r haX0r.) --- Diffs of the changes: (+1 -1) Index: llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp diff -u llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.14 llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.15 --- llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.14 Fri Nov 21 15:54:21 2003 +++ llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp Mon Feb 2 13:32:27 2004 @@ -101,7 +101,7 @@ virtual bool ShouldHackArguments() const { return true; } }; RegisterPass Y("deadarghaX0r", - "Dead Argument Hacking (bugpoint usage only)"); + "Dead Argument Hacking (BUGPOINT USE ONLY; DO NOT USE)"); } /// createDeadArgEliminationPass - This pass removes arguments from functions From lattner at cs.uiuc.edu Mon Feb 2 13:41:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 2 13:41:03 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402021940.NAA23082@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.105 -> 1.106 --- Log message: Bug fixed --- Diffs of the changes: (+3 -2) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.105 llvm/docs/ReleaseNotes.html:1.106 --- llvm/docs/ReleaseNotes.html:1.105 Mon Feb 2 11:48:56 2004 +++ llvm/docs/ReleaseNotes.html Mon Feb 2 13:40:06 2004 @@ -142,6 +142,7 @@
    1. [loopsimplify] Many pointless phi nodes are created
    2. +
    3. The X86 backend didn't generate fchs to negate floating point numbers
    @@ -163,7 +164,7 @@ cause use of invalid pointers!
  • [bcreader] Bytecode reader misreads 'long -9223372036854775808'!
  • VMCore mishandles double -0.0
  • - +
  • [X86] X86 backend code generates -0.0 as +0.0
  • @@ -614,7 +615,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/02 17:48:56 $ + Last modified: $Date: 2004/02/02 19:40:06 $ From lattner at cs.uiuc.edu Mon Feb 2 13:41:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 2 13:41:05 2004 Subject: [llvm-commits] CVS: llvm-www/releases/1.1/docs/ReleaseNotes.html Message-ID: <200402021940.NAA23624@zion.cs.uiuc.edu> Changes in directory llvm-www/releases/1.1/docs: ReleaseNotes.html updated: 1.14 -> 1.15 --- Log message: Bug found --- Diffs of the changes: (+4 -1) Index: llvm-www/releases/1.1/docs/ReleaseNotes.html diff -u llvm-www/releases/1.1/docs/ReleaseNotes.html:1.14 llvm-www/releases/1.1/docs/ReleaseNotes.html:1.15 --- llvm-www/releases/1.1/docs/ReleaseNotes.html:1.14 Mon Feb 2 11:49:04 2004 +++ llvm-www/releases/1.1/docs/ReleaseNotes.html Mon Feb 2 13:40:23 2004 @@ -678,6 +678,9 @@ support the unwind instruction, so code that throws a C++ exception or calls the C longjmp function will abort. +Bugs in 1.1 fixed in 1.2: @@ -762,7 +765,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/02 17:49:04 $ + Last modified: $Date: 2004/02/02 19:40:23 $ From lattner at cs.uiuc.edu Mon Feb 2 13:58:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 2 13:58:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.td Message-ID: <200402021957.NAA26187@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86InstrInfo.td updated: 1.16 -> 1.17 --- Log message: No need to declare implicit uses/defs of ST0 --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/X86/X86InstrInfo.td diff -u llvm/lib/Target/X86/X86InstrInfo.td:1.16 llvm/lib/Target/X86/X86InstrInfo.td:1.17 --- llvm/lib/Target/X86/X86InstrInfo.td:1.16 Mon Feb 2 13:31:38 2004 +++ llvm/lib/Target/X86/X86InstrInfo.td Mon Feb 2 13:57:45 2004 @@ -435,7 +435,7 @@ // Unary read-modify-write operations... -def FCHS : FPInst<"fchs", 0xE0, RawFrm, ArgF80, OneArgFPRW>, D9, Imp<[ST0],[ST0]>; // f1 = fchs f2 +def FCHS : FPInst<"fchs", 0xE0, RawFrm, ArgF80, OneArgFPRW>, D9; // f1 = fchs f2 // Binary arithmetic operations... class FPST0rInst o> From lattner at cs.uiuc.edu Mon Feb 2 14:11:10 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 2 14:11:10 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LICM.cpp Message-ID: <200402022010.OAA30845@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LICM.cpp updated: 1.55 -> 1.56 --- Log message: Update comment --- Diffs of the changes: (+1 -1) Index: llvm/lib/Transforms/Scalar/LICM.cpp diff -u llvm/lib/Transforms/Scalar/LICM.cpp:1.55 llvm/lib/Transforms/Scalar/LICM.cpp:1.56 --- llvm/lib/Transforms/Scalar/LICM.cpp:1.55 Wed Jan 7 18:09:44 2004 +++ llvm/lib/Transforms/Scalar/LICM.cpp Mon Feb 2 14:09:22 2004 @@ -679,7 +679,7 @@ I != E; ++I) { AliasSet &AS = *I; // We can promote this alias set if it has a store, if it is a "Must" alias - // set, and if the pointer is loop invariant. + // set, if the pointer is loop invariant, if if we are not eliminating any volatile loads or stores. if (!AS.isForwardingAliasSet() && AS.isMod() && AS.isMustAlias() && !AS.isVolatile() && isLoopInvariant(AS.begin()->first)) { assert(AS.begin() != AS.end() && From lattner at cs.uiuc.edu Mon Feb 2 14:11:13 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 2 14:11:13 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200402022010.OAA30852@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.149 -> 1.150 --- Log message: Disable (x - (y - z)) => (x + (z - y)) optimization for floating point. --- Diffs of the changes: (+2 -1) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.149 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.150 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.149 Wed Jan 14 00:06:08 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Feb 2 14:09:56 2004 @@ -512,7 +512,8 @@ // Replace (x - (y - z)) with (x + (z - y)) if the (y - z) subexpression // is not used by anyone else... // - if (Op1I->getOpcode() == Instruction::Sub) { + if (Op1I->getOpcode() == Instruction::Sub && + !Op1I->getType()->isFloatingPoint()) { // Swap the two operands of the subexpr... Value *IIOp0 = Op1I->getOperand(0), *IIOp1 = Op1I->getOperand(1); Op1I->setOperand(0, IIOp1); From lattner at cs.uiuc.edu Mon Feb 2 14:22:34 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 2 14:22:34 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/iOperators.cpp Message-ID: <200402022021.OAA32043@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: iOperators.cpp updated: 1.25 -> 1.26 --- Log message: Floating point negates are -0.0 - X, not 0.0 - X --- Diffs of the changes: (+13 -5) Index: llvm/lib/VMCore/iOperators.cpp diff -u llvm/lib/VMCore/iOperators.cpp:1.25 llvm/lib/VMCore/iOperators.cpp:1.26 --- llvm/lib/VMCore/iOperators.cpp:1.25 Thu Nov 20 11:45:12 2003 +++ llvm/lib/VMCore/iOperators.cpp Mon Feb 2 14:21:29 2004 @@ -78,9 +78,14 @@ BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name, Instruction *InsertBefore) { - return new BinaryOperator(Instruction::Sub, - Constant::getNullValue(Op->getType()), Op, - Op->getType(), Name, InsertBefore); + if (!Op->getType()->isFloatingPoint()) + return new BinaryOperator(Instruction::Sub, + Constant::getNullValue(Op->getType()), Op, + Op->getType(), Name, InsertBefore); + else + return new BinaryOperator(Instruction::Sub, + ConstantFP::get(Op->getType(), -0.0), Op, + Op->getType(), Name, InsertBefore); } BinaryOperator *BinaryOperator::createNot(Value *Op, const std::string &Name, @@ -98,8 +103,11 @@ bool BinaryOperator::isNeg(const Value *V) { if (const BinaryOperator *Bop = dyn_cast(V)) - return Bop->getOpcode() == Instruction::Sub && - Bop->getOperand(0) == Constant::getNullValue(Bop->getType()); + if (Bop->getOpcode() == Instruction::Sub) + if (!V->getType()->isFloatingPoint()) + return Bop->getOperand(0) == Constant::getNullValue(Bop->getType()); + else + return Bop->getOperand(0) == ConstantFP::get(Bop->getType(), -0.0); return false; } From alkis at cs.uiuc.edu Mon Feb 2 14:31:06 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon Feb 2 14:31:06 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200402022030.OAA32186@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.43 -> 1.44 --- Log message: Should be more careful. The previously applied change made all counts outside of loops = 0. --- Diffs of the changes: (+6 -10) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.43 llvm/lib/CodeGen/LiveIntervals.cpp:1.44 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.43 Sun Feb 1 10:13:05 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Mon Feb 2 14:29:57 2004 @@ -109,17 +109,13 @@ const MachineBasicBlock* mbb = mbbi; unsigned loopDepth = loopInfo.getLoopDepth(mbb->getBasicBlock()); - if (loopDepth) { - for (MachineBasicBlock::const_iterator mii = mbb->begin(), - mie = mbb->end(); mii != mie; ++mii) { - MachineInstr* mi = *mii; - - for (int i = mi->getNumOperands() - 1; i >= 0; --i) { - MachineOperand& mop = mi->getOperand(i); - - if (!mop.isVirtualRegister()) - continue; + for (MachineBasicBlock::const_iterator mii = mbb->begin(), + mie = mbb->end(); mii != mie; ++mii) { + MachineInstr* mi = *mii; + for (int i = mi->getNumOperands() - 1; i >= 0; --i) { + MachineOperand& mop = mi->getOperand(i); + if (mop.isVirtualRegister()) { unsigned reg = mop.getAllocatedRegNum(); Reg2IntervalMap::iterator r2iit = r2iMap_.find(reg); assert(r2iit != r2iMap_.end()); From alkis at cs.uiuc.edu Mon Feb 2 15:56:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon Feb 2 15:56:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200402022155.PAA11620@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.118 -> 1.119 --- Log message: Add MachineOperand::setDef() and MachineOperand::setUse() so that the TwoAddressInstructionPass can correctly update use/def information. --- Diffs of the changes: (+3 -0) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.118 llvm/include/llvm/CodeGen/MachineInstr.h:1.119 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.118 Sun Dec 14 07:30:19 2003 +++ llvm/include/llvm/CodeGen/MachineInstr.h Mon Feb 2 15:55:18 2004 @@ -288,6 +288,9 @@ bool isHiBits64 () const { return flags & HIFLAG64; } bool isLoBits64 () const { return flags & LOFLAG64; } + MachineOperand& setUse () { flags |= USEFLAG; return *this; } + MachineOperand& setDef () { flags |= DEFFLAG; return *this; } + // used to check if a machine register has been allocated to this operand bool hasAllocatedReg() const { return (regNum >= 0 && From alkis at cs.uiuc.edu Mon Feb 2 15:57:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon Feb 2 15:57:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Message-ID: <200402022156.PAA11914@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: TwoAddressInstructionPass.cpp updated: 1.9 -> 1.10 --- Log message: Correctly update def/use information for modified machine operands. --- Diffs of the changes: (+9 -3) Index: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp diff -u llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.9 llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.10 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.9 Sat Jan 31 15:21:43 2004 +++ llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Mon Feb 2 15:56:40 2004 @@ -146,11 +146,17 @@ LV.addVirtualRegisterDead(regB, &*mbbi, prevMi); // replace all occurences of regB with regA + // and mark all uses and defs of regA as def&use for (unsigned i = 1; i < mi->getNumOperands(); ++i) { - if (mi->getOperand(i).isRegister() && - mi->getOperand(i).getReg() == regB) - mi->SetMachineOperandReg(i, regA); + MachineOperand& op = mi->getOperand(i); + if (op.isRegister()) { + if (op.getReg() == regB) + mi->SetMachineOperandReg(i, regA); + if (op.getReg() == regA) + op.setDef().setUse(); + } } + DEBUG(std::cerr << "\t\tmodified original to: "; mi->print(std::cerr, TM)); assert(mi->getOperand(0).getAllocatedRegNum() == From alkis at cs.uiuc.edu Mon Feb 2 16:01:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon Feb 2 16:01:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <200402022200.QAA13252@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.38 -> 1.39 --- Log message: Fix debugging output. --- Diffs of the changes: (+1 -1) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.38 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.39 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.38 Mon Feb 2 01:30:36 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Mon Feb 2 16:00:32 2004 @@ -443,7 +443,7 @@ unsigned virtReg = op.getAllocatedRegNum(); Virt2PhysMap::const_iterator it = v2pMap_.find(virtReg); if (it != v2pMap_.end()) { - DEBUG(std::cerr << "\t\t\t%reg" << it->second + DEBUG(std::cerr << "\t\t\t%reg" << it->first << " -> " << mri_->getName(it->second) << '\n'); (*currentInstr_)->SetMachineOperandReg(i, it->second); } From brukman at cs.uiuc.edu Mon Feb 2 16:33:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Mon Feb 2 16:33:02 2004 Subject: [llvm-commits] [parallel] CVS: llvm/include/llvm/Intrinsics.h Message-ID: <200402022232.QAA08690@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Intrinsics.h updated: 1.15 -> 1.15.2.1 --- Log message: Added the "join" intrinsic function. --- Diffs of the changes: (+3 -0) Index: llvm/include/llvm/Intrinsics.h diff -u llvm/include/llvm/Intrinsics.h:1.15 llvm/include/llvm/Intrinsics.h:1.15.2.1 --- llvm/include/llvm/Intrinsics.h:1.15 Mon Jan 5 23:32:17 2004 +++ llvm/include/llvm/Intrinsics.h Mon Feb 2 16:32:05 2004 @@ -44,6 +44,9 @@ dbg_func_start, // Start of a function dbg_declare, // Declare a local object + // Parallelism/atomicity/synchronization intrinsics... + join, + //===------------------------------------------------------------------===// // This section defines intrinsic functions used to represent Alpha // instructions... From brukman at cs.uiuc.edu Mon Feb 2 16:34:03 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Mon Feb 2 16:34:03 2004 Subject: [llvm-commits] [parallel] CVS: llvm/lib/VMCore/Function.cpp IntrinsicLowering.cpp Verifier.cpp Message-ID: <200402022233.QAA09910@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Function.cpp updated: 1.62 -> 1.62.2.1 IntrinsicLowering.cpp updated: 1.5 -> 1.5.2.1 Verifier.cpp updated: 1.78 -> 1.78.2.1 --- Log message: Add support for the "join" intrinsic: * lowered to abort() * currently takes no parameters, in the future will take as parameter a token generated by the corresponding pbr. --- Diffs of the changes: (+11 -0) Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.62 llvm/lib/VMCore/Function.cpp:1.62.2.1 --- llvm/lib/VMCore/Function.cpp:1.62 Sat Jan 10 15:42:24 2004 +++ llvm/lib/VMCore/Function.cpp Mon Feb 2 16:33:06 2004 @@ -214,6 +214,9 @@ if (getName() == "llvm.dbg.func.start") return Intrinsic::dbg_func_start; if (getName() == "llvm.dbg.declare") return Intrinsic::dbg_declare; break; + case 'j': + if (getName() == "llvm.join") return Intrinsic::join; + break; case 'l': if (getName() == "llvm.longjmp") return Intrinsic::longjmp; break; Index: llvm/lib/VMCore/IntrinsicLowering.cpp diff -u llvm/lib/VMCore/IntrinsicLowering.cpp:1.5 llvm/lib/VMCore/IntrinsicLowering.cpp:1.5.2.1 --- llvm/lib/VMCore/IntrinsicLowering.cpp:1.5 Wed Jan 14 14:41:29 2004 +++ llvm/lib/VMCore/IntrinsicLowering.cpp Mon Feb 2 16:33:06 2004 @@ -57,6 +57,11 @@ if (CI->getType() != Type::VoidTy) CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); break; // Simply strip out debugging intrinsics + + case Intrinsic::join: + // Insert the call to abort + new CallInst(M->getOrInsertFunction("abort", Type::VoidTy, 0), "", CI); + break; } assert(CI->use_empty() && Index: llvm/lib/VMCore/Verifier.cpp diff -u llvm/lib/VMCore/Verifier.cpp:1.78 llvm/lib/VMCore/Verifier.cpp:1.78.2.1 --- llvm/lib/VMCore/Verifier.cpp:1.78 Tue Jan 13 23:42:52 2004 +++ llvm/lib/VMCore/Verifier.cpp Mon Feb 2 16:33:06 2004 @@ -561,6 +561,9 @@ case Intrinsic::dbg_region_end: NumArgs = 1; break; case Intrinsic::dbg_func_start: NumArgs = 1; break; case Intrinsic::dbg_declare: NumArgs = 1; break; + + // FIXME: this should take a single parameter which is returned by pbr + case Intrinsic::join: NumArgs = 0; break; case Intrinsic::alpha_ctlz: NumArgs = 1; break; case Intrinsic::alpha_cttz: NumArgs = 1; break; From alkis at cs.uiuc.edu Mon Feb 2 17:10:03 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon Feb 2 17:10:03 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Message-ID: <200402022309.RAA22305@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: TwoAddressInstructionPass.cpp updated: 1.10 -> 1.11 --- Log message: Revert changes. Will implement this using a different set of primitives --- Diffs of the changes: (+3 -9) Index: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp diff -u llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.10 llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.11 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.10 Mon Feb 2 15:56:40 2004 +++ llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Mon Feb 2 17:08:58 2004 @@ -146,17 +146,11 @@ LV.addVirtualRegisterDead(regB, &*mbbi, prevMi); // replace all occurences of regB with regA - // and mark all uses and defs of regA as def&use for (unsigned i = 1; i < mi->getNumOperands(); ++i) { - MachineOperand& op = mi->getOperand(i); - if (op.isRegister()) { - if (op.getReg() == regB) - mi->SetMachineOperandReg(i, regA); - if (op.getReg() == regA) - op.setDef().setUse(); - } + if (mi->getOperand(i).isRegister() && + mi->getOperand(i).getReg() == regB) + mi->SetMachineOperandReg(i, regA); } - DEBUG(std::cerr << "\t\tmodified original to: "; mi->print(std::cerr, TM)); assert(mi->getOperand(0).getAllocatedRegNum() == From alkis at cs.uiuc.edu Mon Feb 2 17:10:07 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon Feb 2 17:10:07 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200402022309.RAA22304@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.119 -> 1.120 --- Log message: Revert changes. Will implement this using a different set of primitives --- Diffs of the changes: (+0 -3) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.119 llvm/include/llvm/CodeGen/MachineInstr.h:1.120 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.119 Mon Feb 2 15:55:18 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Mon Feb 2 17:08:57 2004 @@ -288,9 +288,6 @@ bool isHiBits64 () const { return flags & HIFLAG64; } bool isLoBits64 () const { return flags & LOFLAG64; } - MachineOperand& setUse () { flags |= USEFLAG; return *this; } - MachineOperand& setDef () { flags |= DEFFLAG; return *this; } - // used to check if a machine register has been allocated to this operand bool hasAllocatedReg() const { return (regNum >= 0 && From brukman at cs.uiuc.edu Mon Feb 2 17:29:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Mon Feb 2 17:29:01 2004 Subject: [llvm-commits] [parallel] CVS: llvm/test/Feature/parabr.ll Message-ID: <200402022328.RAA22565@zion.cs.uiuc.edu> Changes in directory llvm/test/Feature: parabr.ll added (r1.1.2.1) --- Log message: Test case for reading/processing parallel branch instr and join intrinsic. --- Diffs of the changes: (+19 -0) Index: llvm/test/Feature/parabr.ll diff -c /dev/null llvm/test/Feature/parabr.ll:1.1.2.1 *** /dev/null Mon Feb 2 17:28:21 2004 --- llvm/test/Feature/parabr.ll Mon Feb 2 17:28:11 2004 *************** *** 0 **** --- 1,19 ---- + declare void %llvm.join() + + void %main() { + header: + pbr label %bb1, label %bb2 + + bb1: + br label %sink + + bb2: + br label %sink + + sink: + call void %llvm.join() + br label %exit + + exit: + ret void + } From alkis at cs.uiuc.edu Mon Feb 2 19:14:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon Feb 2 19:14:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200402030113.TAA32381@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.120 -> 1.121 --- Log message: When an instruction like: A += B had both A and B virtual registers spilled, A was loaded from its stack location twice. This fixes the bug. --- Diffs of the changes: (+6 -0) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.120 llvm/include/llvm/CodeGen/MachineInstr.h:1.121 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.120 Mon Feb 2 17:08:57 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Mon Feb 2 19:13:07 2004 @@ -207,6 +207,10 @@ return *this; } + bool operator==(const MachineOperand& rhs) const { + return regNum == rhs.regNum && opType == rhs.opType; + } + // Accessor methods. Caller is responsible for checking the // operand type before invoking the corresponding accessor. // @@ -282,8 +286,10 @@ } bool isUse () const { return flags & USEFLAG; } + bool isEverUsed (const MachineInstr&) const; bool isDef () const { return flags & DEFFLAG; } bool isHiBits32 () const { return flags & HIFLAG32; } + bool isEverDefined (const MachineInstr&) const; bool isLoBits32 () const { return flags & LOFLAG32; } bool isHiBits64 () const { return flags & HIFLAG64; } bool isLoBits64 () const { return flags & LOFLAG64; } From alkis at cs.uiuc.edu Mon Feb 2 19:14:05 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon Feb 2 19:14:05 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp MachineInstr.cpp Message-ID: <200402030113.TAA32382@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.39 -> 1.40 MachineInstr.cpp updated: 1.82 -> 1.83 --- Log message: When an instruction like: A += B had both A and B virtual registers spilled, A was loaded from its stack location twice. This fixes the bug. --- Diffs of the changes: (+24 -10) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.39 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.40 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.39 Mon Feb 2 16:00:32 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Mon Feb 2 19:13:06 2004 @@ -470,7 +470,8 @@ for (unsigned i = 0, e = (*currentInstr_)->getNumOperands(); i != e; ++i) { MachineOperand& op = (*currentInstr_)->getOperand(i); - if (op.isVirtualRegister() && op.isUse() && !op.isDef()) { + if (op.isVirtualRegister() && op.isUse() && + !op.isEverDefined(**currentInstr_)) { unsigned virtReg = op.getAllocatedRegNum(); unsigned physReg = 0; Virt2PhysMap::const_iterator it = v2pMap_.find(virtReg); @@ -497,7 +498,9 @@ for (unsigned i = 0, e = (*currentInstr_)->getNumOperands(); i != e; ++i) { MachineOperand& op = (*currentInstr_)->getOperand(i); - if (op.isVirtualRegister() && op.isDef()) { + if (op.isVirtualRegister()) { + assert(op.isEverDefined(**currentInstr_) && + "operand should be defined by this instruction"); unsigned virtReg = op.getAllocatedRegNum(); unsigned physReg = 0; Virt2PhysMap::const_iterator it = v2pMap_.find(virtReg); @@ -506,14 +509,9 @@ } else { physReg = getFreeTempPhysReg(virtReg); - } - if (op.isUse()) { // def and use - loadVirt2PhysReg(virtReg, physReg); - } - else { assignVirt2PhysReg(virtReg, physReg); + tempDefOperands_.push_back(virtReg); } - tempDefOperands_.push_back(virtReg); (*currentInstr_)->SetMachineOperandReg(i, physReg); } } @@ -815,8 +813,6 @@ int RA::getStackSlot(unsigned virtReg) { - // use lower_bound so that we can do a possibly O(1) insert later - // if necessary Virt2StackSlotMap::iterator it = v2ssMap_.find(virtReg); assert(it != v2ssMap_.end() && "attempt to get stack slot on register that does not live on the stack"); Index: llvm/lib/CodeGen/MachineInstr.cpp diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.82 llvm/lib/CodeGen/MachineInstr.cpp:1.83 --- llvm/lib/CodeGen/MachineInstr.cpp:1.82 Sun Dec 14 07:24:17 2003 +++ llvm/lib/CodeGen/MachineInstr.cpp Mon Feb 2 19:13:06 2004 @@ -27,6 +27,24 @@ // extern const TargetInstrDescriptor *TargetInstrDescriptors; +bool MachineOperand::isEverUsed(const MachineInstr& mi) const +{ + for (int i = 0, e = mi.getNumOperands(); i != e; ++i) { + if (*this == mi.getOperand(i) && mi.getOperand(i).isUse()) + return true; + } + return false; +} + +bool MachineOperand::isEverDefined(const MachineInstr& mi) const +{ + for (int i = 0, e = mi.getNumOperands(); i != e; ++i) { + if (*this == mi.getOperand(i) && mi.getOperand(i).isDef()) + return true; + } + return false; +} + // Constructor for instructions with variable #operands MachineInstr::MachineInstr(MachineOpCode OpCode, unsigned numOperands) : opCode(OpCode), From lattner at cs.uiuc.edu Tue Feb 3 01:28:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 01:28:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/FloatingPoint.cpp Message-ID: <200402030727.BAA06691@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: FloatingPoint.cpp updated: 1.18 -> 1.19 --- Log message: Add support for one argument OneArgFP instructions --- Diffs of the changes: (+4 -3) Index: llvm/lib/Target/X86/FloatingPoint.cpp diff -u llvm/lib/Target/X86/FloatingPoint.cpp:1.18 llvm/lib/Target/X86/FloatingPoint.cpp:1.19 --- llvm/lib/Target/X86/FloatingPoint.cpp:1.18 Mon Feb 2 13:23:15 2004 +++ llvm/lib/Target/X86/FloatingPoint.cpp Tue Feb 3 01:27:34 2004 @@ -383,10 +383,11 @@ /// void FPS::handleOneArgFP(MachineBasicBlock::iterator &I) { MachineInstr *MI = *I; - assert(MI->getNumOperands() == 5 && "Can only handle fst* instructions!"); + assert((MI->getNumOperands() == 5 || MI->getNumOperands() == 1) && + "Can only handle fst* & ftst instructions!"); // Is this the last use of the source register? - unsigned Reg = getFPReg(MI->getOperand(4)); + unsigned Reg = getFPReg(MI->getOperand(MI->getNumOperands()-1)); bool KillsSrc = false; for (LiveVariables::killed_iterator KI = LV->killed_begin(MI), E = LV->killed_end(MI); KI != E; ++KI) @@ -403,7 +404,7 @@ } else { moveToTop(Reg, I); // Move to the top of the stack... } - MI->RemoveOperand(4); // Remove explicit ST(0) operand + MI->RemoveOperand(MI->getNumOperands()-1); // Remove explicit ST(0) operand if (MI->getOpcode() == X86::FSTPr80 || MI->getOpcode() == X86::FISTPr64) { assert(StackTop > 0 && "Stack empty??"); From lattner at cs.uiuc.edu Tue Feb 3 01:28:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 01:28:04 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.td Message-ID: <200402030728.BAA06703@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86InstrInfo.td updated: 1.17 -> 1.18 --- Log message: Add the ftst instruction --- Diffs of the changes: (+3 -1) Index: llvm/lib/Target/X86/X86InstrInfo.td diff -u llvm/lib/Target/X86/X86InstrInfo.td:1.17 llvm/lib/Target/X86/X86InstrInfo.td:1.18 --- llvm/lib/Target/X86/X86InstrInfo.td:1.17 Mon Feb 2 13:57:45 2004 +++ llvm/lib/Target/X86/X86InstrInfo.td Tue Feb 3 01:27:50 2004 @@ -434,8 +434,10 @@ def FLD1 : FPInst<"fld1", 0xE8, RawFrm, ArgF80, ZeroArgFP>, D9; -// Unary read-modify-write operations... +// Unary operations... def FCHS : FPInst<"fchs", 0xE0, RawFrm, ArgF80, OneArgFPRW>, D9; // f1 = fchs f2 + +def FTST : FPInst<"ftst", 0xE4, RawFrm, ArgF80, OneArgFP>, D9; // ftst ST(0) // Binary arithmetic operations... class FPST0rInst o> From lattner at cs.uiuc.edu Tue Feb 3 01:58:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 01:58:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Regression/C/2004-02-03-AggregateCopy.c Message-ID: <200402030757.BAA07080@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/Regression/C: 2004-02-03-AggregateCopy.c added (r1.1) --- Log message: Add new testcase for PR221 --- Diffs of the changes: (+14 -0) Index: llvm/test/Programs/SingleSource/Regression/C/2004-02-03-AggregateCopy.c diff -c /dev/null llvm/test/Programs/SingleSource/Regression/C/2004-02-03-AggregateCopy.c:1.1 *** /dev/null Tue Feb 3 01:57:02 2004 --- llvm/test/Programs/SingleSource/Regression/C/2004-02-03-AggregateCopy.c Tue Feb 3 01:56:52 2004 *************** *** 0 **** --- 1,14 ---- + #include + + typedef struct { + int X; + } agg; + + int main() { + agg A; A.X = 123; + agg B, C; + B = C = A; + + printf("%d, %d, %d\n", A.X, B.X, C.X); + } + From lattner at cs.uiuc.edu Tue Feb 3 02:00:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 02:00:01 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/llvm-expand.c Message-ID: <200402030759.BAA07122@zion.cs.uiuc.edu> Changes in directory gcc-3.4/gcc: llvm-expand.c updated: 1.5 -> 1.6 --- Log message: Fix PR221: [llvm-gcc] miscompilation of 'X = Y = Z' with aggregate values testcase: test/Programs/SingleSource/Regression/C/2004-02-03-AggregateCopy.c --- Diffs of the changes: (+10 -2) Index: gcc-3.4/gcc/llvm-expand.c diff -u gcc-3.4/gcc/llvm-expand.c:1.5 gcc-3.4/gcc/llvm-expand.c:1.6 --- gcc-3.4/gcc/llvm-expand.c:1.5 Mon Feb 2 11:42:13 2004 +++ gcc-3.4/gcc/llvm-expand.c Tue Feb 3 01:59:32 2004 @@ -5933,8 +5933,16 @@ case MODIFY_EXPR: /* = expression */ /* Expand the assignment out. The result of a modify expr is the value produced, not the lvalue returned by llvm_expand_assignment. */ - llvm_expand_assignment(Fn, TREE_OPERAND (exp, 0), - TREE_OPERAND (exp, 1), &Result); + op0 = llvm_expand_assignment(Fn, TREE_OPERAND (exp, 0), + TREE_OPERAND (exp, 1), &Result); + + /* If this modify expression is being assigned to another location, make + * sure to expand the memberwise copy as well! + */ + if (DestLoc) + llvm_copy_aggregate(Fn, DestLoc, op0, + TYPE_VOLATILE(TREE_TYPE(TREE_OPERAND (exp, 0))), 0); + break; case PREINCREMENT_EXPR: return llvm_expand_increment(Fn, exp, 1, 1); From lattner at cs.uiuc.edu Tue Feb 3 02:04:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 02:04:01 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402030803.CAA07531@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.106 -> 1.107 --- Log message: bug fixed --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.106 llvm/docs/ReleaseNotes.html:1.107 --- llvm/docs/ReleaseNotes.html:1.106 Mon Feb 2 13:40:06 2004 +++ llvm/docs/ReleaseNotes.html Tue Feb 3 02:03:41 2004 @@ -176,6 +176,7 @@
  • [llvm-gcc] asserts when an extern inline function is redefined
  • [llvmg++] Dynamically initialized constants cannot be marked 'constant'
  • [llvmgcc] floating-point unary minus is incorrect for +0.0
  • +
  • [llvm-gcc] miscompilation of 'X = Y = Z' with aggregate values
  • @@ -615,7 +616,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/02 19:40:06 $ + Last modified: $Date: 2004/02/03 08:03:41 $ From lattner at cs.uiuc.edu Tue Feb 3 02:05:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 02:05:01 2004 Subject: [llvm-commits] CVS: llvm-www/releases/1.1/docs/ReleaseNotes.html Message-ID: <200402030804.CAA07889@zion.cs.uiuc.edu> Changes in directory llvm-www/releases/1.1/docs: ReleaseNotes.html updated: 1.15 -> 1.16 --- Log message: Bug found. :( --- Diffs of the changes: (+3 -1) Index: llvm-www/releases/1.1/docs/ReleaseNotes.html diff -u llvm-www/releases/1.1/docs/ReleaseNotes.html:1.15 llvm-www/releases/1.1/docs/ReleaseNotes.html:1.16 --- llvm-www/releases/1.1/docs/ReleaseNotes.html:1.15 Mon Feb 2 13:40:23 2004 +++ llvm-www/releases/1.1/docs/ReleaseNotes.html Tue Feb 3 02:03:55 2004 @@ -452,6 +452,8 @@
  • [llvmgcc] floating-point unary minus is incorrect for +0.0
  • + +
  • [llvm-gcc] miscompilation of 'X = Y = Z' with aggregate values
  • @@ -765,7 +767,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/02 19:40:23 $ + Last modified: $Date: 2004/02/03 08:03:55 $ From lattner at cs.uiuc.edu Tue Feb 3 02:14:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 02:14:02 2004 Subject: [llvm-commits] CVS: llvm-www/header.incl Message-ID: <200402030813.CAA16087@zion.cs.uiuc.edu> Changes in directory llvm-www: header.incl updated: 1.11 -> 1.12 --- Log message: Add a link to the bugz list --- Diffs of the changes: (+1 -0) Index: llvm-www/header.incl diff -u llvm-www/header.incl:1.11 llvm-www/header.incl:1.12 --- llvm-www/header.incl:1.11 Thu Jan 29 17:11:21 2004 +++ llvm-www/header.incl Tue Feb 3 02:13:36 2004 @@ -66,6 +66,7 @@ Mailing Lists:
    LLVM-announce
    LLVM-dev
    + LLVM-bugs
    LLVM-commits From gaeke at cs.uiuc.edu Tue Feb 3 12:30:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Feb 3 12:30:03 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/llvm-expand.c Message-ID: <200402031829.MAA01938@seraph.cs.uiuc.edu> Changes in directory gcc-3.4/gcc: llvm-expand.c updated: 1.6 -> 1.7 --- Log message: Fix syntax error: declare ElVal along with the declarations, before any statements, in this block. --- Diffs of the changes: (+1 -2) Index: gcc-3.4/gcc/llvm-expand.c diff -u gcc-3.4/gcc/llvm-expand.c:1.6 gcc-3.4/gcc/llvm-expand.c:1.7 --- gcc-3.4/gcc/llvm-expand.c:1.6 Tue Feb 3 01:59:32 2004 +++ gcc-3.4/gcc/llvm-expand.c Tue Feb 3 12:29:24 2004 @@ -3526,6 +3526,7 @@ */ unsigned FieldSize = 0; tree FieldSizeTree = DECL_SIZE(field); + llvm_value *ElVal; /* * TODO: @@ -3540,8 +3541,6 @@ */ assert ((FieldSizeTree != NULL_TREE) && "Struct/Union member of unknown length!"); FieldSize = TREE_INT_CST_LOW (FieldSizeTree); - - llvm_value *ElVal; assert(FieldIndex && "Structure isn't laid out by LLVM yet!"); From lattner at cs.uiuc.edu Tue Feb 3 12:55:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 12:55:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200402031854.MAA17235@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.152 -> 1.153 --- Log message: Generate ftst instructions for comparison against zero --- Diffs of the changes: (+9 -0) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.152 llvm/lib/Target/X86/InstSelectSimple.cpp:1.153 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.152 Mon Feb 2 13:31:38 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Tue Feb 3 12:54:04 2004 @@ -702,6 +702,15 @@ return OpNum; } + // Special case handling of comparison against +/- 0.0 + if (ConstantFP *CFP = dyn_cast(Op1)) + if (CFP->isExactlyValue(+0.0) || CFP->isExactlyValue(-0.0)) { + BMI(MBB, IP, X86::FTST, 1).addReg(Op0r); + BMI(MBB, IP, X86::FNSTSWr8, 0); + BMI(MBB, IP, X86::SAHF, 1); + return OpNum; + } + unsigned Op1r = getReg(Op1, MBB, IP); switch (Class) { default: assert(0 && "Unknown type class!"); From lattner at cs.uiuc.edu Tue Feb 3 16:01:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 16:01:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Message-ID: <200402032200.QAA21542@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: PromoteMemoryToRegister.cpp updated: 1.59 -> 1.60 --- Log message: Handle extremely trivial cases extremely efficiently. This speeds up SRoA/mem2reg from 41.2s to 27.5s on the testcase in PR209. --- Diffs of the changes: (+30 -17) Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp diff -u llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.59 llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.60 --- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.59 Sun Jan 11 19:18:32 2004 +++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Tue Feb 3 16:00:33 2004 @@ -400,25 +400,38 @@ // void PromoteMem2Reg::PromoteLocallyUsedAlloca(AllocaInst *AI) { assert(!AI->use_empty() && "There are no uses of the alloca!"); - - // Uses of the uninitialized memory location shall get zero... - Value *CurVal = Constant::getNullValue(AI->getAllocatedType()); - BasicBlock *BB = cast(AI->use_back())->getParent(); - for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) { - Instruction *Inst = I++; - if (LoadInst *LI = dyn_cast(Inst)) { - if (LI->getOperand(0) == AI) { - // Loads just return the "current value"... - LI->replaceAllUsesWith(CurVal); - BB->getInstList().erase(LI); - } - } else if (StoreInst *SI = dyn_cast(Inst)) { - if (SI->getOperand(1) == AI) { - // Loads just update the "current value"... - CurVal = SI->getOperand(0); - BB->getInstList().erase(SI); + + // Handle degenerate cases quickly. + if (AI->hasOneUse()) { + Instruction *U = cast(AI->use_back()); + if (LoadInst *LI = dyn_cast(U)) { + // Must be a load of uninitialized value. + LI->replaceAllUsesWith(Constant::getNullValue(AI->getAllocatedType())); + } else { + // Otherwise it must be a store which is never read. + assert(isa(U)); + } + BB->getInstList().erase(U); + } else { + // Uses of the uninitialized memory location shall get zero... + Value *CurVal = Constant::getNullValue(AI->getAllocatedType()); + + for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) { + Instruction *Inst = I++; + if (LoadInst *LI = dyn_cast(Inst)) { + if (LI->getOperand(0) == AI) { + // Loads just return the "current value"... + LI->replaceAllUsesWith(CurVal); + BB->getInstList().erase(LI); + } + } else if (StoreInst *SI = dyn_cast(Inst)) { + if (SI->getOperand(1) == AI) { + // Loads just update the "current value"... + CurVal = SI->getOperand(0); + BB->getInstList().erase(SI); + } } } } From lattner at cs.uiuc.edu Tue Feb 3 16:35:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 16:35:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Message-ID: <200402032234.QAA19204@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: PromoteMemoryToRegister.cpp updated: 1.60 -> 1.61 --- Log message: Bunch up all locally used allocas by the block they are allocated in, and process them all as a group. This speeds up SRoA/mem2reg from 28.46s to 0.62s on the testcase from PR209. --- Diffs of the changes: (+74 -13) Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp diff -u llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.60 llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.61 --- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.60 Tue Feb 3 16:00:33 2004 +++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Tue Feb 3 16:34:12 2004 @@ -110,7 +110,9 @@ private: void MarkDominatingPHILive(BasicBlock *BB, unsigned AllocaNum, std::set &DeadPHINodes); - void PromoteLocallyUsedAlloca(AllocaInst *AI); + void PromoteLocallyUsedAlloca(BasicBlock *BB, AllocaInst *AI); + void PromoteLocallyUsedAllocas(BasicBlock *BB, + const std::vector &AIs); void RenamePass(BasicBlock *BB, BasicBlock *Pred, std::vector &IncVals); @@ -122,6 +124,13 @@ void PromoteMem2Reg::run() { Function &F = *DF.getRoot()->getParent(); + // LocallyUsedAllocas - Keep track of all of the alloca instructions which are + // only used in a single basic block. These instructions can be efficiently + // promoted by performing a single linear scan over that one block. Since + // individual basic blocks are sometimes large, we group together all allocas + // that are live in a single basic block by the basic block they are live in. + std::map > LocallyUsedAllocas; + for (unsigned AllocaNum = 0; AllocaNum != Allocas.size(); ++AllocaNum) { AllocaInst *AI = Allocas[AllocaNum]; @@ -207,9 +216,9 @@ // If the alloca is only read and written in one basic block, just perform a // linear sweep over the block to eliminate it. if (OnlyUsedInOneBlock) { - PromoteLocallyUsedAlloca(AI); + LocallyUsedAllocas[OnlyBlock].push_back(AI); - // Remove the alloca from the Allocas list, since it has been processed + // Remove the alloca from the Allocas list, since it will be processed. Allocas[AllocaNum] = Allocas.back(); Allocas.pop_back(); --AllocaNum; @@ -272,6 +281,20 @@ AllocaLookup[Allocas[AllocaNum]] = AllocaNum; } + // Process all allocas which are only used in a single basic block. + for (std::map >::iterator I = + LocallyUsedAllocas.begin(), E = LocallyUsedAllocas.end(); I != E; ++I){ + const std::vector &Allocas = I->second; + assert(!Allocas.empty() && "empty alloca list??"); + + // It's common for there to only be one alloca in the list. Handle it + // efficiently. + if (Allocas.size() == 1) + PromoteLocallyUsedAlloca(I->first, Allocas[0]); + else + PromoteLocallyUsedAllocas(I->first, Allocas); + } + if (Allocas.empty()) return; // All of the allocas must have been trivial! @@ -393,15 +416,13 @@ } } -// PromoteLocallyUsedAlloca - Many allocas are only used within a single basic -// block. If this is the case, avoid traversing the CFG and inserting a lot of -// potentially useless PHI nodes by just performing a single linear pass over -// the basic block using the Alloca. -// -void PromoteMem2Reg::PromoteLocallyUsedAlloca(AllocaInst *AI) { +/// PromoteLocallyUsedAlloca - Many allocas are only used within a single basic +/// block. If this is the case, avoid traversing the CFG and inserting a lot of +/// potentially useless PHI nodes by just performing a single linear pass over +/// the basic block using the Alloca. +/// +void PromoteMem2Reg::PromoteLocallyUsedAlloca(BasicBlock *BB, AllocaInst *AI) { assert(!AI->use_empty() && "There are no uses of the alloca!"); - BasicBlock *BB = cast(AI->use_back())->getParent(); - // Handle degenerate cases quickly. if (AI->hasOneUse()) { @@ -422,13 +443,13 @@ Instruction *Inst = I++; if (LoadInst *LI = dyn_cast(Inst)) { if (LI->getOperand(0) == AI) { - // Loads just return the "current value"... + // Loads just returns the "current value"... LI->replaceAllUsesWith(CurVal); BB->getInstList().erase(LI); } } else if (StoreInst *SI = dyn_cast(Inst)) { if (SI->getOperand(1) == AI) { - // Loads just update the "current value"... + // Store updates the "current value"... CurVal = SI->getOperand(0); BB->getInstList().erase(SI); } @@ -441,6 +462,46 @@ assert(AI->use_empty() && "Uses of alloca from more than one BB??"); AI->getParent()->getInstList().erase(AI); } + +/// PromoteLocallyUsedAllocas - This method is just like +/// PromoteLocallyUsedAlloca, except that it processes multiple alloca +/// instructions in parallel. This is important in cases where we have large +/// basic blocks, as we don't want to rescan the entire basic block for each +/// alloca which is locally used in it (which might be a lot). +void PromoteMem2Reg:: +PromoteLocallyUsedAllocas(BasicBlock *BB, const std::vector &AIs) { + std::map CurValues; + for (unsigned i = 0, e = AIs.size(); i != e; ++i) + CurValues[AIs[i]] = 0; // Insert with null value + + for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) { + Instruction *Inst = I++; + if (LoadInst *LI = dyn_cast(Inst)) { + // Is this a load of an alloca we are tracking? + if (AllocaInst *AI = dyn_cast(LI->getOperand(0))) { + std::map::iterator AIt = CurValues.find(AI); + if (AIt != CurValues.end()) { + // Loads just returns the "current value"... + if (AIt->second == 0) // Uninitialized value?? + AIt->second =Constant::getNullValue(AIt->first->getAllocatedType()); + LI->replaceAllUsesWith(AIt->second); + BB->getInstList().erase(LI); + } + } + } else if (StoreInst *SI = dyn_cast(Inst)) { + if (AllocaInst *AI = dyn_cast(SI->getOperand(1))) { + std::map::iterator AIt = CurValues.find(AI); + if (AIt != CurValues.end()) { + // Store updates the "current value"... + AIt->second = SI->getOperand(0); + BB->getInstList().erase(SI); + } + } + } + } +} + + // QueuePhiNode - queues a phi-node to be added to a basic-block for a specific // Alloca returns true if there wasn't already a phi-node for that variable From alkis at cs.uiuc.edu Tue Feb 3 16:52:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue Feb 3 16:52:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200402032251.QAA27608@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.109 -> 1.110 --- Log message: Do not do jit-ls tests when DISABLE_JIT is defined. --- Diffs of the changes: (+4 -4) Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.109 llvm/test/Programs/Makefile.programs:1.110 --- llvm/test/Programs/Makefile.programs:1.109 Tue Jan 20 00:54:02 2004 +++ llvm/test/Programs/Makefile.programs Tue Feb 3 16:51:05 2004 @@ -171,7 +171,7 @@ ifdef ENABLE_LINEARSCAN all:: $(LLCLSDIFFS) endif -endif +endif#DISABLE_LLC_DIFFS ifndef DISABLE_CBE_DIFFS all:: $(CBEDIFFS) @@ -180,16 +180,16 @@ ifdef TARGET_HAS_JIT ifndef DISABLE_JIT all:: $(JITDIFFS) -endif ifdef ENABLE_LINEARSCAN all:: $(JITLSDIFFS) endif -endif +endif#DISABLE_JIT +endif#TARGET_HAS_JIT ifdef ENABLE_LLI all:: $(LLIDIFFS) endif -endif +endif#DISABLE_DIFFS # Given a version of the entire program linked together into a single unit of # raw output from the C frontend, optimize it. From lattner at cs.uiuc.edu Tue Feb 3 16:57:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 16:57:01 2004 Subject: [llvm-commits] CVS: llvm/Makefile Message-ID: <200402032256.QAA17561@niobe.cs.uiuc.edu> Changes in directory llvm: Makefile updated: 1.17 -> 1.18 --- Log message: Apply Michael Kahl's patch to fix the 'make tools-only' target when OBJDIR != SRCDIR. See PR222. --- Diffs of the changes: (+2 -2) Index: llvm/Makefile diff -u llvm/Makefile:1.17 llvm/Makefile:1.18 --- llvm/Makefile:1.17 Thu Jan 22 15:54:51 2004 +++ llvm/Makefile Tue Feb 3 16:56:40 2004 @@ -22,8 +22,8 @@ $(LEVEL)/config.log \ $(LEVEL)/TAGS -tools-only: - @for dir in lib/Support utils lib tools; do $(MAKE) -C $$dir; done +tools-only: DIRS = $(DIRS:runtime=) +tools-only: all configure: autoconf/configure.ac autoconf/aclocal.m4 cd autoconf && aclocal && autoconf -o ../configure configure.ac From lattner at cs.uiuc.edu Tue Feb 3 17:01:14 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 17:01:14 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402032300.RAA17586@niobe.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.107 -> 1.108 --- Log message: Bug fixed --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.107 llvm/docs/ReleaseNotes.html:1.108 --- llvm/docs/ReleaseNotes.html:1.107 Tue Feb 3 02:03:41 2004 +++ llvm/docs/ReleaseNotes.html Tue Feb 3 16:59:56 2004 @@ -133,6 +133,7 @@
    1. [build] Makefiles break if C frontend target string has unexpected value
    2. [build] hard-wired assumption that shared-library extension is ".so"
    3. +
    4. make tools-only doesn't make lib/Support
    @@ -616,7 +617,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/03 08:03:41 $ + Last modified: $Date: 2004/02/03 22:59:56 $ From lattner at cs.uiuc.edu Tue Feb 3 17:01:20 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 17:01:20 2004 Subject: [llvm-commits] CVS: llvm-www/releases/1.1/docs/ReleaseNotes.html Message-ID: <200402032300.RAA17601@niobe.cs.uiuc.edu> Changes in directory llvm-www/releases/1.1/docs: ReleaseNotes.html updated: 1.16 -> 1.17 --- Log message: bug found --- Diffs of the changes: (+2 -2) Index: llvm-www/releases/1.1/docs/ReleaseNotes.html diff -u llvm-www/releases/1.1/docs/ReleaseNotes.html:1.16 llvm-www/releases/1.1/docs/ReleaseNotes.html:1.17 --- llvm-www/releases/1.1/docs/ReleaseNotes.html:1.16 Tue Feb 3 02:03:55 2004 +++ llvm-www/releases/1.1/docs/ReleaseNotes.html Tue Feb 3 17:00:20 2004 @@ -397,7 +397,7 @@
  • [bcreader] Bytecode reader misreads 'long -9223372036854775808'!
  • VMCore mishandles double -0.0
  • - +
  • make tools-only doesn't make lib/Support
  • @@ -767,7 +767,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/03 08:03:55 $ + Last modified: $Date: 2004/02/03 23:00:20 $ From lattner at cs.uiuc.edu Tue Feb 3 17:06:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 17:06:03 2004 Subject: [llvm-commits] CVS: llvm/Makefile Message-ID: <200402032305.RAA16153@zion.cs.uiuc.edu> Changes in directory llvm: Makefile updated: 1.18 -> 1.19 --- Log message: Revised version of a patch for PR222 that works with my version of gmake. --- Diffs of the changes: (+6 -2) Index: llvm/Makefile diff -u llvm/Makefile:1.18 llvm/Makefile:1.19 --- llvm/Makefile:1.18 Tue Feb 3 16:56:40 2004 +++ llvm/Makefile Tue Feb 3 17:05:24 2004 @@ -7,9 +7,14 @@ # ##===----------------------------------------------------------------------===## LEVEL = . -DIRS = lib/Support utils lib tools runtime +DIRS = lib/Support utils lib tools OPTIONAL_DIRS = projects +ifneq ($(MAKECMDGOALS),tools-only) +DIRS += runtime +endif + + include $(LEVEL)/Makefile.common test :: all @@ -22,7 +27,6 @@ $(LEVEL)/config.log \ $(LEVEL)/TAGS -tools-only: DIRS = $(DIRS:runtime=) tools-only: all configure: autoconf/configure.ac autoconf/aclocal.m4 From lattner at cs.uiuc.edu Tue Feb 3 17:12:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 17:12:03 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/BasicBlock.cpp Message-ID: <200402032311.RAA26066@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: BasicBlock.cpp updated: 1.38 -> 1.39 --- Log message: In BasicBlock::splitBasicBlock, just use islist::splice to move the instructions, instead of a loop that is really inefficient with large basic blocks. This speeds up the inliner pass on the testcase in PR209 from 13.8s to 2.24s which still isn't exactly speedy, but is a lot better. :) --- Diffs of the changes: (+3 -8) Index: llvm/lib/VMCore/BasicBlock.cpp diff -u llvm/lib/VMCore/BasicBlock.cpp:1.38 llvm/lib/VMCore/BasicBlock.cpp:1.39 --- llvm/lib/VMCore/BasicBlock.cpp:1.38 Fri Nov 21 10:52:05 2003 +++ llvm/lib/VMCore/BasicBlock.cpp Tue Feb 3 17:11:21 2004 @@ -233,14 +233,9 @@ BasicBlock *New = new BasicBlock(BBName, getParent()); - // Go from the end of the basic block through to the iterator pointer, moving - // to the new basic block... - Instruction *Inst = 0; - do { - iterator EndIt = end(); - Inst = InstList.remove(--EndIt); // Remove from end - New->InstList.push_front(Inst); // Add to front - } while (Inst != &*I); // Loop until we move the specified instruction. + // Move all of the specified instructions from the original basic block into + // the new basic block. + New->getInstList().splice(New->end(), this->getInstList(), I, end()); // Add a branch instruction to the newly formed basic block. new BranchInst(New, this); From lattner at cs.uiuc.edu Tue Feb 3 19:07:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 19:07:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp Message-ID: <200402040106.TAA23216@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Instruction.cpp updated: 1.33 -> 1.34 --- Log message: If changing a parent, don't add then remove the object from the leak detector --- Diffs of the changes: (+5 -5) Index: llvm/lib/VMCore/Instruction.cpp diff -u llvm/lib/VMCore/Instruction.cpp:1.33 llvm/lib/VMCore/Instruction.cpp:1.34 --- llvm/lib/VMCore/Instruction.cpp:1.33 Mon Jan 12 17:18:25 2004 +++ llvm/lib/VMCore/Instruction.cpp Tue Feb 3 19:06:38 2004 @@ -35,13 +35,13 @@ } void Instruction::setParent(BasicBlock *P) { - if (getParent()) - LeakDetector::addGarbageObject(this); + if (getParent()) { + if (!P) LeakDetector::addGarbageObject(this); + } else { + if (P) LeakDetector::removeGarbageObject(this); + } Parent = P; - - if (getParent()) - LeakDetector::removeGarbageObject(this); } // Specialize setName to take care of symbol table majik From lattner at cs.uiuc.edu Tue Feb 3 19:20:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 19:20:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/CloneFunction.cpp CloneTrace.cpp Message-ID: <200402040119.TAA31638@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: CloneFunction.cpp updated: 1.19 -> 1.20 CloneTrace.cpp updated: 1.5 -> 1.6 --- Log message: Give CloneBasicBlock an optional function argument to specify which function to add the cloned block to. This allows the block to be added to the function immediately, and all of the instructions to be immediately added to the function symbol table, which speeds up the inliner from 3.7 -> 3.38s on the PR209. --- Diffs of the changes: (+10 -13) Index: llvm/lib/Transforms/Utils/CloneFunction.cpp diff -u llvm/lib/Transforms/Utils/CloneFunction.cpp:1.19 llvm/lib/Transforms/Utils/CloneFunction.cpp:1.20 --- llvm/lib/Transforms/Utils/CloneFunction.cpp:1.19 Fri Jan 9 00:12:12 2004 +++ llvm/lib/Transforms/Utils/CloneFunction.cpp Tue Feb 3 19:19:43 2004 @@ -42,8 +42,8 @@ // CloneBasicBlock - See comments in Cloning.h BasicBlock *llvm::CloneBasicBlock(const BasicBlock *BB, std::map &ValueMap, - const char *NameSuffix) { - BasicBlock *NewBB = new BasicBlock(""); + const char *NameSuffix, Function *F) { + BasicBlock *NewBB = new BasicBlock("", F); if (BB->hasName()) NewBB->setName(BB->getName()+NameSuffix); // Loop over all instructions copying them over... @@ -82,8 +82,7 @@ const BasicBlock &BB = *BI; // Create a new basic block and copy instructions into it! - BasicBlock *CBB = CloneBasicBlock(&BB, ValueMap, NameSuffix); - NewFunc->getBasicBlockList().push_back(CBB); + BasicBlock *CBB = CloneBasicBlock(&BB, ValueMap, NameSuffix, NewFunc); ValueMap[&BB] = CBB; // Add basic block mapping. if (ReturnInst *RI = dyn_cast(CBB->getTerminator())) Index: llvm/lib/Transforms/Utils/CloneTrace.cpp diff -u llvm/lib/Transforms/Utils/CloneTrace.cpp:1.5 llvm/lib/Transforms/Utils/CloneTrace.cpp:1.6 --- llvm/lib/Transforms/Utils/CloneTrace.cpp:1.5 Fri Jan 9 00:12:15 2004 +++ llvm/lib/Transforms/Utils/CloneTrace.cpp Tue Feb 3 19:19:43 2004 @@ -7,11 +7,11 @@ // //===----------------------------------------------------------------------===// // -// This file implements the CloneTrace interface, which is used -// when writing runtime optimizations. It takes a vector of basic blocks -// clones the basic blocks, removes internal phi nodes, adds it to the -// same function as the original (although there is no jump to it) and -// returns the new vector of basic blocks. +// This file implements the CloneTrace interface, which is used when writing +// runtime optimizations. It takes a vector of basic blocks clones the basic +// blocks, removes internal phi nodes, adds it to the same function as the +// original (although there is no jump to it) and returns the new vector of +// basic blocks. // //===----------------------------------------------------------------------===// @@ -34,16 +34,14 @@ End = origTrace.end(); T != End; ++T) { //Clone Basic Block - BasicBlock *clonedBlock = CloneBasicBlock(*T, ValueMap); + BasicBlock *clonedBlock = + CloneBasicBlock(*T, ValueMap, ".tr", (*T)->getParent()); //Add it to our new trace clonedTrace.push_back(clonedBlock); //Add this new mapping to our Value Map ValueMap[*T] = clonedBlock; - - //Add this cloned BB to the old BB's function - (*T)->getParent()->getBasicBlockList().push_back(clonedBlock); //Loop over the phi instructions and delete operands //that are from blocks not in the trace From lattner at cs.uiuc.edu Tue Feb 3 19:42:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 19:42:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp Message-ID: <200402040141.TAA11106@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: InlineFunction.cpp updated: 1.18 -> 1.19 --- Log message: Move the cloning of the function body much earlier in the inlinefunction process. The only optimization we did so far is to avoid creating a PHI node, then immediately destroying it in the common case where the callee has one return statement. Instead, we just don't create the return value. This has no noticable performance impact, but paves the way for future improvements. --- Diffs of the changes: (+55 -53) Index: llvm/lib/Transforms/Utils/InlineFunction.cpp diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.18 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.19 --- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.18 Fri Jan 9 00:12:20 2004 +++ llvm/lib/Transforms/Utils/InlineFunction.cpp Tue Feb 3 19:41:09 2004 @@ -11,7 +11,7 @@ // parameters and the return value as appropriate. // // FIXME: This pass should transform alloca instructions in the called function -// into malloc/free pairs! Or perhaps it should refuse to inline them! +// into alloca/dealloca pairs! Or perhaps it should refuse to inline them! // //===----------------------------------------------------------------------===// @@ -50,7 +50,31 @@ BasicBlock *OrigBB = TheCall->getParent(); Function *Caller = OrigBB->getParent(); - // We want to clone the entire callee function into the whole between the + // Calculate the vector of arguments to pass into the function cloner... + std::map ValueMap; + assert(std::distance(CalledFunc->abegin(), CalledFunc->aend()) == + std::distance(CS.arg_begin(), CS.arg_end()) && + "No varargs calls can be inlined!"); + + CallSite::arg_iterator AI = CS.arg_begin(); + for (Function::const_aiterator I = CalledFunc->abegin(), E=CalledFunc->aend(); + I != E; ++I, ++AI) + ValueMap[I] = *AI; + + // Get an iterator to the last basic block in the function, which will have + // the new function inlined after it. + // + Function::iterator LastBlock = &Caller->back(); + + // Clone the entire body of the callee into the caller. Make sure to capture + // all of the return instructions from the cloned function. + std::vector Returns; + CloneFunctionInto(Caller, CalledFunc, ValueMap, Returns, ".i"); + + + + + // We want to clone the entire callee function into the hole between the // "starter" and "ender" blocks. How we accomplish this depends on whether // this is an invoke instruction or a call instruction. @@ -96,72 +120,50 @@ // node that gets values from each of the old RET instructions in the original // function. // - PHINode *PHI = 0; if (!TheCall->use_empty()) { - // The PHI node should go at the front of the new basic block to merge all - // possible incoming values. - // - PHI = new PHINode(CalledFunc->getReturnType(), TheCall->getName(), - AfterCallBB->begin()); - - // Anything that used the result of the function call should now use the PHI - // node as their operand. - // - TheCall->replaceAllUsesWith(PHI); + // We only need to make the PHI if there is more than one return instruction + if (Returns.size() > 1) { + // The PHI node should go at the front of the new basic block to merge all + // possible incoming values. + // + PHINode *PHI = new PHINode(CalledFunc->getReturnType(), + TheCall->getName(), AfterCallBB->begin()); + + // Anything that used the result of the function call should now use the + // PHI node as their operand. + // + TheCall->replaceAllUsesWith(PHI); + + // Add all of the return instructions as entries in the PHI node. + for (unsigned i = 0, e = Returns.size(); i != e; ++i) { + ReturnInst *RI = Returns[i]; + + assert(RI->getReturnValue() && "Ret should have value!"); + assert(RI->getReturnValue()->getType() == PHI->getType() && + "Ret value not consistent in function!"); + PHI->addIncoming(RI->getReturnValue(), RI->getParent()); + } + + } else if (!Returns.empty()) { + // Otherwise, if there is exactly one return value, just replace anything + // using the return value of the call with the computed value. + TheCall->replaceAllUsesWith(Returns[0]->getReturnValue()); + } } - // Get an iterator to the last basic block in the function, which will have - // the new function inlined after it. - // - Function::iterator LastBlock = &Caller->back(); - - // Calculate the vector of arguments to pass into the function cloner... - std::map ValueMap; - assert(std::distance(CalledFunc->abegin(), CalledFunc->aend()) == - std::distance(CS.arg_begin(), CS.arg_end()) && - "No varargs calls can be inlined!"); - - CallSite::arg_iterator AI = CS.arg_begin(); - for (Function::const_aiterator I = CalledFunc->abegin(), E=CalledFunc->aend(); - I != E; ++I, ++AI) - ValueMap[I] = *AI; - // Since we are now done with the Call/Invoke, we can delete it. delete TheCall; - // Make a vector to capture the return instructions in the cloned function... - std::vector Returns; - - // Do all of the hard part of cloning the callee into the caller... - CloneFunctionInto(Caller, CalledFunc, ValueMap, Returns, ".i"); - // Loop over all of the return instructions, turning them into unconditional // branches to the merge point now... for (unsigned i = 0, e = Returns.size(); i != e; ++i) { ReturnInst *RI = Returns[i]; - BasicBlock *BB = RI->getParent(); // Add a branch to the merge point where the PHI node lives if it exists. new BranchInst(AfterCallBB, RI); - if (PHI) { // The PHI node should include this value! - assert(RI->getReturnValue() && "Ret should have value!"); - assert(RI->getReturnValue()->getType() == PHI->getType() && - "Ret value not consistent in function!"); - PHI->addIncoming(RI->getReturnValue(), BB); - } - // Delete the return instruction now - BB->getInstList().erase(RI); - } - - // Check to see if the PHI node only has one argument. This is a common - // case resulting from there only being a single return instruction in the - // function call. Because this is so common, eliminate the PHI node. - // - if (PHI && PHI->getNumIncomingValues() == 1) { - PHI->replaceAllUsesWith(PHI->getIncomingValue(0)); - PHI->getParent()->getInstList().erase(PHI); + RI->getParent()->getInstList().erase(RI); } // Change the branch that used to go to AfterCallBB to branch to the first From 46hdnhpti at lycos.de Tue Feb 3 20:51:03 2004 From: 46hdnhpti at lycos.de (Amber Mcmullen) Date: Tue Feb 3 20:51:03 2004 Subject: [llvm-commits] Promote someone else's online business and cash in big Message-ID: An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20040203/f3b79aa3/attachment.html From aezvhsd8 at gsi.de Tue Feb 3 20:51:07 2004 From: aezvhsd8 at gsi.de (Stephan Marrero) Date: Tue Feb 3 20:51:07 2004 Subject: [llvm-commits] Cash in on other people's businesses Message-ID: <87$6nq8cn7356$879-61801phgurq8@sz5.aui> An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20040203/562c78d0/attachment.html From lattner at cs.uiuc.edu Tue Feb 3 20:52:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 20:52:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp Message-ID: <200402040251.UAA13109@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: InlineFunction.cpp updated: 1.19 -> 1.20 --- Log message: More refactoring. Move alloca instructions and handle invoke instructions before we delete the original call site, allowing slight simplifications of code, but nothing exciting. --- Diffs of the changes: (+132 -129) Index: llvm/lib/Transforms/Utils/InlineFunction.cpp diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.19 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.20 --- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.19 Tue Feb 3 19:41:09 2004 +++ llvm/lib/Transforms/Utils/InlineFunction.cpp Tue Feb 3 20:51:48 2004 @@ -50,153 +50,68 @@ BasicBlock *OrigBB = TheCall->getParent(); Function *Caller = OrigBB->getParent(); - // Calculate the vector of arguments to pass into the function cloner... - std::map ValueMap; - assert(std::distance(CalledFunc->abegin(), CalledFunc->aend()) == - std::distance(CS.arg_begin(), CS.arg_end()) && - "No varargs calls can be inlined!"); - - CallSite::arg_iterator AI = CS.arg_begin(); - for (Function::const_aiterator I = CalledFunc->abegin(), E=CalledFunc->aend(); - I != E; ++I, ++AI) - ValueMap[I] = *AI; - // Get an iterator to the last basic block in the function, which will have // the new function inlined after it. // Function::iterator LastBlock = &Caller->back(); - // Clone the entire body of the callee into the caller. Make sure to capture - // all of the return instructions from the cloned function. + // Make sure to capture all of the return instructions from the cloned + // function. std::vector Returns; - CloneFunctionInto(Caller, CalledFunc, ValueMap, Returns, ".i"); - + { // Scope to destroy ValueMap after cloning. + // Calculate the vector of arguments to pass into the function cloner... + std::map ValueMap; + assert(std::distance(CalledFunc->abegin(), CalledFunc->aend()) == + std::distance(CS.arg_begin(), CS.arg_end()) && + "No varargs calls can be inlined!"); + + CallSite::arg_iterator AI = CS.arg_begin(); + for (Function::const_aiterator I = CalledFunc->abegin(), + E = CalledFunc->aend(); I != E; ++I, ++AI) + ValueMap[I] = *AI; + + // Clone the entire body of the callee into the caller. + CloneFunctionInto(Caller, CalledFunc, ValueMap, Returns, ".i"); + } - - - // We want to clone the entire callee function into the hole between the - // "starter" and "ender" blocks. How we accomplish this depends on whether - // this is an invoke instruction or a call instruction. - - BasicBlock *InvokeDest = 0; // Exception handling destination - std::vector InvokeDestPHIValues; // Values for PHI nodes in InvokeDest - BasicBlock *AfterCallBB; - - if (InvokeInst *II = dyn_cast(TheCall)) { - InvokeDest = II->getExceptionalDest(); - - // If there are PHI nodes in the exceptional destination block, we need to - // keep track of which values came into them from this invoke, then remove - // the entry for this block. - for (BasicBlock::iterator I = InvokeDest->begin(); - PHINode *PN = dyn_cast(I); ++I) { - // Save the value to use for this edge... - InvokeDestPHIValues.push_back(PN->getIncomingValueForBlock(OrigBB)); - } - - // Add an unconditional branch to make this look like the CallInst case... - BranchInst *NewBr = new BranchInst(II->getNormalDest(), TheCall); - - // Split the basic block. This guarantees that no PHI nodes will have to be - // updated due to new incoming edges, and make the invoke case more - // symmetric to the call case. - AfterCallBB = OrigBB->splitBasicBlock(NewBr, - CalledFunc->getName()+".entry"); - - // Remove (unlink) the InvokeInst from the function... - OrigBB->getInstList().remove(TheCall); - - } else { // It's a call - // If this is a call instruction, we need to split the basic block that the - // call lives in. - // - AfterCallBB = OrigBB->splitBasicBlock(TheCall, - CalledFunc->getName()+".entry"); - // Remove (unlink) the CallInst from the function... - AfterCallBB->getInstList().remove(TheCall); - } - - // If we have a return value generated by this call, convert it into a PHI - // node that gets values from each of the old RET instructions in the original - // function. - // - if (!TheCall->use_empty()) { - // We only need to make the PHI if there is more than one return instruction - if (Returns.size() > 1) { - // The PHI node should go at the front of the new basic block to merge all - // possible incoming values. - // - PHINode *PHI = new PHINode(CalledFunc->getReturnType(), - TheCall->getName(), AfterCallBB->begin()); - - // Anything that used the result of the function call should now use the - // PHI node as their operand. - // - TheCall->replaceAllUsesWith(PHI); - - // Add all of the return instructions as entries in the PHI node. - for (unsigned i = 0, e = Returns.size(); i != e; ++i) { - ReturnInst *RI = Returns[i]; - - assert(RI->getReturnValue() && "Ret should have value!"); - assert(RI->getReturnValue()->getType() == PHI->getType() && - "Ret value not consistent in function!"); - PHI->addIncoming(RI->getReturnValue(), RI->getParent()); - } - - } else if (!Returns.empty()) { - // Otherwise, if there is exactly one return value, just replace anything - // using the return value of the call with the computed value. - TheCall->replaceAllUsesWith(Returns[0]->getReturnValue()); - } - } - - // Since we are now done with the Call/Invoke, we can delete it. - delete TheCall; - - // Loop over all of the return instructions, turning them into unconditional - // branches to the merge point now... - for (unsigned i = 0, e = Returns.size(); i != e; ++i) { - ReturnInst *RI = Returns[i]; - - // Add a branch to the merge point where the PHI node lives if it exists. - new BranchInst(AfterCallBB, RI); - - // Delete the return instruction now - RI->getParent()->getInstList().erase(RI); - } - - // Change the branch that used to go to AfterCallBB to branch to the first - // basic block of the inlined function. - // - TerminatorInst *Br = OrigBB->getTerminator(); - assert(Br && Br->getOpcode() == Instruction::Br && - "splitBasicBlock broken!"); - Br->setOperand(0, ++LastBlock); + // Remember the first block that is newly cloned over. + Function::iterator FirstNewBlock = LastBlock; ++FirstNewBlock; // If there are any alloca instructions in the block that used to be the entry // block for the callee, move them to the entry block of the caller. First // calculate which instruction they should be inserted before. We insert the // instructions at the end of the current alloca list. // - if (isa(LastBlock->begin())) { + if (isa(FirstNewBlock->begin())) { BasicBlock::iterator InsertPoint = Caller->begin()->begin(); while (isa(InsertPoint)) ++InsertPoint; - for (BasicBlock::iterator I = LastBlock->begin(), E = LastBlock->end(); - I != E; ) + for (BasicBlock::iterator I = FirstNewBlock->begin(), + E = FirstNewBlock->end(); I != E; ) if (AllocaInst *AI = dyn_cast(I++)) if (isa(AI->getArraySize())) { - LastBlock->getInstList().remove(AI); + FirstNewBlock->getInstList().remove(AI); Caller->front().getInstList().insert(InsertPoint, AI); } } - // If we just inlined a call due to an invoke instruction, scan the inlined - // function checking for function calls that should now be made into invoke - // instructions, and for unwind's which should be turned into branches. - if (InvokeDest) { - for (Function::iterator BB = LastBlock, E = Caller->end(); BB != E; ++BB) { + // If we are inlining for an invoke instruction, we must make sure to rewrite + // any inlined 'unwind' instructions into branches to the invoke exception + // destination, and call instructions into invoke instructions. + if (InvokeInst *II = dyn_cast(TheCall)) { + BasicBlock *InvokeDest = II->getExceptionalDest(); + std::vector InvokeDestPHIValues; + + // If there are PHI nodes in the exceptional destination block, we need to + // keep track of which values came into them from this invoke, then remove + // the entry for this block. + for (BasicBlock::iterator I = InvokeDest->begin(); + PHINode *PN = dyn_cast(I); ++I) + // Save the value to use for this edge... + InvokeDestPHIValues.push_back(PN->getIncomingValueForBlock(OrigBB)); + + for (Function::iterator BB = FirstNewBlock, E = Caller->end(); + BB != E; ++BB) { for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) { // We only need to check for function calls: inlined invoke instructions // require no special handling... @@ -257,16 +172,104 @@ // the exception destination block still have entries due to the original // invoke instruction. Eliminate these entries (which might even delete the // PHI node) now. - for (BasicBlock::iterator I = InvokeDest->begin(); - PHINode *PN = dyn_cast(I); ++I) - PN->removeIncomingValue(AfterCallBB); + InvokeDest->removePredecessor(II->getParent()); } + + // We want to clone the entire callee function into the hole between the + // "starter" and "ender" blocks. How we accomplish this depends on whether + // this is an invoke instruction or a call instruction. + BasicBlock *AfterCallBB; + if (InvokeInst *II = dyn_cast(TheCall)) { + + // Add an unconditional branch to make this look like the CallInst case... + BranchInst *NewBr = new BranchInst(II->getNormalDest(), TheCall); + + // Split the basic block. This guarantees that no PHI nodes will have to be + // updated due to new incoming edges, and make the invoke case more + // symmetric to the call case. + AfterCallBB = OrigBB->splitBasicBlock(NewBr, + CalledFunc->getName()+".entry"); + + // Remove (unlink) the InvokeInst from the function... + OrigBB->getInstList().remove(TheCall); + + } else { // It's a call + // If this is a call instruction, we need to split the basic block that the + // call lives in. + // + AfterCallBB = OrigBB->splitBasicBlock(TheCall, + CalledFunc->getName()+".entry"); + // Remove (unlink) the CallInst from the function... + AfterCallBB->getInstList().remove(TheCall); + } + + // Handle all of the return instructions that we just cloned in, and eliminate + // any users of the original call/invoke instruction. + if (Returns.size() > 1) { + // The PHI node should go at the front of the new basic block to merge all + // possible incoming values. + // + PHINode *PHI = 0; + if (!TheCall->use_empty()) { + PHI = new PHINode(CalledFunc->getReturnType(), + TheCall->getName(), AfterCallBB->begin()); + + // Anything that used the result of the function call should now use the + // PHI node as their operand. + // + TheCall->replaceAllUsesWith(PHI); + } + + // Loop over all of the return instructions, turning them into unconditional + // branches to the merge point now, and adding entries to the PHI node as + // appropriate. + for (unsigned i = 0, e = Returns.size(); i != e; ++i) { + ReturnInst *RI = Returns[i]; + + if (PHI) { + assert(RI->getReturnValue() && "Ret should have value!"); + assert(RI->getReturnValue()->getType() == PHI->getType() && + "Ret value not consistent in function!"); + PHI->addIncoming(RI->getReturnValue(), RI->getParent()); + } + + // Add a branch to the merge point where the PHI node lives if it exists. + new BranchInst(AfterCallBB, RI); + + // Delete the return instruction now + RI->getParent()->getInstList().erase(RI); + } + + } else if (!Returns.empty()) { + // Otherwise, if there is exactly one return value, just replace anything + // using the return value of the call with the computed value. + if (!TheCall->use_empty()) + TheCall->replaceAllUsesWith(Returns[0]->getReturnValue()); + + // Add a branch to the merge point where the PHI node lives if it exists. + new BranchInst(AfterCallBB, Returns[0]); + + // Delete the return instruction now + Returns[0]->getParent()->getInstList().erase(Returns[0]); + } + + // Since we are now done with the Call/Invoke, we can delete it. + delete TheCall; + + // Change the branch that used to go to AfterCallBB to branch to the first + // basic block of the inlined function. + // + TerminatorInst *Br = OrigBB->getTerminator(); + assert(Br && Br->getOpcode() == Instruction::Br && + "splitBasicBlock broken!"); + Br->setOperand(0, FirstNewBlock); + // Now that the function is correct, make it a little bit nicer. In // particular, move the basic blocks inserted from the end of the function // into the space made by splitting the source basic block. // Caller->getBasicBlockList().splice(AfterCallBB, Caller->getBasicBlockList(), - LastBlock, Caller->end()); + FirstNewBlock, Caller->end()); // We should always be able to fold the entry block of the function into the // single predecessor of the block... From lattner at cs.uiuc.edu Tue Feb 3 21:22:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 21:22:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/BasicBlock.cpp Message-ID: <200402040321.VAA17613@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: BasicBlock.cpp updated: 1.39 -> 1.40 --- Log message: When splitting a basic block, insert the new half immediately after the first half. --- Diffs of the changes: (+1 -1) Index: llvm/lib/VMCore/BasicBlock.cpp diff -u llvm/lib/VMCore/BasicBlock.cpp:1.39 llvm/lib/VMCore/BasicBlock.cpp:1.40 --- llvm/lib/VMCore/BasicBlock.cpp:1.39 Tue Feb 3 17:11:21 2004 +++ llvm/lib/VMCore/BasicBlock.cpp Tue Feb 3 21:21:31 2004 @@ -231,7 +231,7 @@ assert(I != InstList.end() && "Trying to get me to create degenerate basic block!"); - BasicBlock *New = new BasicBlock(BBName, getParent()); + BasicBlock *New = new BasicBlock(BBName, getNext()); // Move all of the specified instructions from the original basic block into // the new basic block. From lattner at cs.uiuc.edu Tue Feb 3 21:23:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 21:23:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/LowerSetJmp.cpp Message-ID: <200402040322.VAA17647@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: LowerSetJmp.cpp updated: 1.14 -> 1.15 --- Log message: Remove unneeded code now that splitBasicBlock does the "right thing" --- Diffs of the changes: (+0 -5) Index: llvm/lib/Transforms/IPO/LowerSetJmp.cpp diff -u llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.14 llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.15 --- llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.14 Fri Nov 21 15:54:22 2003 +++ llvm/lib/Transforms/IPO/LowerSetJmp.cpp Tue Feb 3 21:21:51 2004 @@ -413,11 +413,6 @@ SetJmpContBlock->setName("SetJmpContBlock"); - // Reposition the split BB in the BB list to make things tidier. - Func->getBasicBlockList().remove(SetJmpContBlock); - Func->getBasicBlockList().insert(++Function::iterator(ABlock), - SetJmpContBlock); - // This PHI node will be in the new block created from the // splitBasicBlock call. PHINode* PHI = new PHINode(Type::IntTy, "SetJmpReturn", Inst); From lattner at cs.uiuc.edu Tue Feb 3 21:58:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 21:58:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/BasicBlock.h Message-ID: <200402040357.VAA14775@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: BasicBlock.h updated: 1.36 -> 1.37 --- Log message: Delete the BasicBlock ctor that only takes a BasicBlock to insert before. This fails when the basic block points to the function->end. Instead, require that the client pass in the function AND the basicblock to insert into. --- Diffs of the changes: (+5 -4) Index: llvm/include/llvm/BasicBlock.h diff -u llvm/include/llvm/BasicBlock.h:1.36 llvm/include/llvm/BasicBlock.h:1.37 --- llvm/include/llvm/BasicBlock.h:1.36 Wed Jan 14 22:37:10 2004 +++ llvm/include/llvm/BasicBlock.h Tue Feb 3 21:57:34 2004 @@ -67,13 +67,14 @@ typedef std::reverse_iterator reverse_iterator; /// BasicBlock ctor - If the function parameter is specified, the basic block - /// is automatically inserted at the end of the function. + /// is automatically inserted at either the end of the function (if + /// InsertBefore is null), or before the specified basic block. /// - BasicBlock(const std::string &Name = "", Function *Parent = 0); - /// BasicBlock ctor - If the InsertBefore parameter is specified, the basic /// block is automatically inserted right before the specified block. - BasicBlock(const std::string &Name, BasicBlock *InsertBefore); + /// + BasicBlock(const std::string &Name = "", Function *Parent = 0, + BasicBlock *InsertBefore = 0); ~BasicBlock(); // Specialize setName to take care of symbol table majik From lattner at cs.uiuc.edu Tue Feb 3 21:59:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 21:59:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopSimplify.cpp TailRecursionElimination.cpp Message-ID: <200402040358.VAA15284@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopSimplify.cpp updated: 1.30 -> 1.31 TailRecursionElimination.cpp updated: 1.12 -> 1.13 --- Log message: Adjust to the new BasicBlock ctor, which requires a function parameter --- Diffs of the changes: (+2 -2) Index: llvm/lib/Transforms/Scalar/LoopSimplify.cpp diff -u llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.30 llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.31 --- llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.30 Wed Jan 7 18:09:44 2004 +++ llvm/lib/Transforms/Scalar/LoopSimplify.cpp Tue Feb 3 21:58:28 2004 @@ -151,7 +151,7 @@ const std::vector &Preds) { // Create new basic block, insert right before the original block... - BasicBlock *NewBB = new BasicBlock(BB->getName()+Suffix, BB); + BasicBlock *NewBB = new BasicBlock(BB->getName()+Suffix, BB->getParent(), BB); // The preheader first gets an unconditional branch to the loop header... BranchInst *BI = new BranchInst(BB, NewBB); Index: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp diff -u llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:1.12 llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:1.13 --- llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:1.12 Sun Dec 14 17:57:39 2003 +++ llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp Tue Feb 3 21:58:28 2004 @@ -290,7 +290,7 @@ if (OldEntry == 0) { OldEntry = &F->getEntryBlock(); std::string OldName = OldEntry->getName(); OldEntry->setName("tailrecurse"); - BasicBlock *NewEntry = new BasicBlock(OldName, OldEntry); + BasicBlock *NewEntry = new BasicBlock(OldName, F, OldEntry); new BranchInst(OldEntry, NewEntry); // Now that we have created a new block, which jumps to the entry From lattner at cs.uiuc.edu Tue Feb 3 21:59:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 21:59:04 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/BasicBlock.cpp Message-ID: <200402040358.VAA15030@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: BasicBlock.cpp updated: 1.40 -> 1.41 --- Log message: Adjust to the new BB ctor --- Diffs of the changes: (+8 -24) Index: llvm/lib/VMCore/BasicBlock.cpp diff -u llvm/lib/VMCore/BasicBlock.cpp:1.40 llvm/lib/VMCore/BasicBlock.cpp:1.41 --- llvm/lib/VMCore/BasicBlock.cpp:1.40 Tue Feb 3 21:21:31 2004 +++ llvm/lib/VMCore/BasicBlock.cpp Tue Feb 3 21:57:50 2004 @@ -61,25 +61,8 @@ template class SymbolTableListTraits; -// BasicBlock ctor - If the function parameter is specified, the basic block is -// automatically inserted at the end of the function. -// -BasicBlock::BasicBlock(const std::string &name, Function *Parent) - : Value(Type::LabelTy, Value::BasicBlockVal, name) { - // Initialize the instlist... - InstList.setItemParent(this); - - // Make sure that we get added to a function - LeakDetector::addGarbageObject(this); - - if (Parent) - Parent->getBasicBlockList().push_back(this); -} - -/// BasicBlock ctor - If the InsertBefore parameter is specified, the basic -/// block is automatically inserted right before the specified block. -/// -BasicBlock::BasicBlock(const std::string &Name, BasicBlock *InsertBefore) +BasicBlock::BasicBlock(const std::string &Name, Function *Parent, + BasicBlock *InsertBefore) : Value(Type::LabelTy, Value::BasicBlockVal, Name) { // Initialize the instlist... InstList.setItemParent(this); @@ -88,10 +71,11 @@ LeakDetector::addGarbageObject(this); if (InsertBefore) { - assert(InsertBefore->getParent() && - "Cannot insert block before another block that is not embedded into" - " a function yet!"); - InsertBefore->getParent()->getBasicBlockList().insert(InsertBefore, this); + assert(Parent && + "Cannot insert block before another block with no function!"); + Parent->getBasicBlockList().insert(InsertBefore, this); + } else if (Parent) { + Parent->getBasicBlockList().push_back(this); } } @@ -231,7 +215,7 @@ assert(I != InstList.end() && "Trying to get me to create degenerate basic block!"); - BasicBlock *New = new BasicBlock(BBName, getNext()); + BasicBlock *New = new BasicBlock(BBName, getParent(), getNext()); // Move all of the specified instructions from the original basic block into // the new basic block. From lattner at cs.uiuc.edu Tue Feb 3 22:00:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 22:00:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/Utils/Cloning.h Message-ID: <200402040359.VAA15327@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms/Utils: Cloning.h updated: 1.13 -> 1.14 --- Log message: Check in header file I forgot before. --- Diffs of the changes: (+5 -2) Index: llvm/include/llvm/Transforms/Utils/Cloning.h diff -u llvm/include/llvm/Transforms/Utils/Cloning.h:1.13 llvm/include/llvm/Transforms/Utils/Cloning.h:1.14 --- llvm/include/llvm/Transforms/Utils/Cloning.h:1.13 Tue Nov 11 16:41:31 2003 +++ llvm/include/llvm/Transforms/Utils/Cloning.h Tue Feb 3 21:59:08 2004 @@ -55,11 +55,14 @@ /// is recorded in the ValueMap map. /// /// If you have a particular suffix you'd like to use to add to any cloned -/// names, specify it as the optional second parameter. +/// names, specify it as the optional third parameter. +/// +/// If you would like the basic block to be auto-inserted into the end of a +/// function, you can specify it as the optional fourth parameter. /// BasicBlock *CloneBasicBlock(const BasicBlock *BB, std::map &ValueMap, - const char *NameSuffix = ""); + const char *NameSuffix = "", Function *F = 0); /// CloneFunction - Return a copy of the specified function, but without From lattner at cs.uiuc.edu Tue Feb 3 22:18:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 3 22:18:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp Message-ID: <200402040417.WAA23734@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: InlineFunction.cpp updated: 1.20 -> 1.21 --- Log message: Optimize the case where we are inlining a function that contains only one basic block, and that basic block ends with a return instruction. In this case, we can just splice the cloned "body" of the function directly into the source basic block, avoiding a lot of rearrangement and splitBasicBlock's linear scan over the split block. This speeds up the inliner on the testcase in PR209 from 2.3s to 1.7s, a 35% reduction. --- Diffs of the changes: (+67 -37) Index: llvm/lib/Transforms/Utils/InlineFunction.cpp diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.20 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.21 --- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.20 Tue Feb 3 20:51:48 2004 +++ llvm/lib/Transforms/Utils/InlineFunction.cpp Tue Feb 3 22:17:06 2004 @@ -175,34 +175,78 @@ InvokeDest->removePredecessor(II->getParent()); } + // If we cloned in _exactly one_ basic block, and if that block ends in a + // return instruction, we splice the body of the inlined callee directly into + // the calling basic block. + if (Returns.size() == 1 && std::distance(FirstNewBlock, Caller->end()) == 1) { + // Move all of the instructions right before the call. + OrigBB->getInstList().splice(TheCall, FirstNewBlock->getInstList(), + FirstNewBlock->begin(), FirstNewBlock->end()); + // Remove the cloned basic block. + Caller->getBasicBlockList().pop_back(); + + // If the call site was an invoke instruction, add a branch to the normal + // destination. + if (InvokeInst *II = dyn_cast(TheCall)) + new BranchInst(II->getNormalDest(), TheCall); + + // If the return instruction returned a value, replace uses of the call with + // uses of the returned value. + if (!TheCall->use_empty()) + TheCall->replaceAllUsesWith(Returns[0]->getReturnValue()); + + // Since we are now done with the Call/Invoke, we can delete it. + TheCall->getParent()->getInstList().erase(TheCall); + + // Since we are now done with the return instruction, delete it also. + Returns[0]->getParent()->getInstList().erase(Returns[0]); + + // We are now done with the inlining. + return true; + } + + // Otherwise, we have the normal case, of more than one block to inline or + // multiple return sites. + // We want to clone the entire callee function into the hole between the // "starter" and "ender" blocks. How we accomplish this depends on whether // this is an invoke instruction or a call instruction. BasicBlock *AfterCallBB; if (InvokeInst *II = dyn_cast(TheCall)) { - + // Add an unconditional branch to make this look like the CallInst case... BranchInst *NewBr = new BranchInst(II->getNormalDest(), TheCall); - + // Split the basic block. This guarantees that no PHI nodes will have to be // updated due to new incoming edges, and make the invoke case more // symmetric to the call case. AfterCallBB = OrigBB->splitBasicBlock(NewBr, CalledFunc->getName()+".entry"); - - // Remove (unlink) the InvokeInst from the function... - OrigBB->getInstList().remove(TheCall); - + } else { // It's a call - // If this is a call instruction, we need to split the basic block that the - // call lives in. + // If this is a call instruction, we need to split the basic block that + // the call lives in. // AfterCallBB = OrigBB->splitBasicBlock(TheCall, CalledFunc->getName()+".entry"); - // Remove (unlink) the CallInst from the function... - AfterCallBB->getInstList().remove(TheCall); } + // Change the branch that used to go to AfterCallBB to branch to the first + // basic block of the inlined function. + // + TerminatorInst *Br = OrigBB->getTerminator(); + assert(Br && Br->getOpcode() == Instruction::Br && + "splitBasicBlock broken!"); + Br->setOperand(0, FirstNewBlock); + + + // Now that the function is correct, make it a little bit nicer. In + // particular, move the basic blocks inserted from the end of the function + // into the space made by splitting the source basic block. + // + Caller->getBasicBlockList().splice(AfterCallBB, Caller->getBasicBlockList(), + FirstNewBlock, Caller->end()); + // Handle all of the return instructions that we just cloned in, and eliminate // any users of the original call/invoke instruction. if (Returns.size() > 1) { @@ -213,74 +257,60 @@ if (!TheCall->use_empty()) { PHI = new PHINode(CalledFunc->getReturnType(), TheCall->getName(), AfterCallBB->begin()); - + // Anything that used the result of the function call should now use the // PHI node as their operand. // TheCall->replaceAllUsesWith(PHI); } - + // Loop over all of the return instructions, turning them into unconditional // branches to the merge point now, and adding entries to the PHI node as // appropriate. for (unsigned i = 0, e = Returns.size(); i != e; ++i) { ReturnInst *RI = Returns[i]; - + if (PHI) { assert(RI->getReturnValue() && "Ret should have value!"); assert(RI->getReturnValue()->getType() == PHI->getType() && "Ret value not consistent in function!"); PHI->addIncoming(RI->getReturnValue(), RI->getParent()); } - + // Add a branch to the merge point where the PHI node lives if it exists. new BranchInst(AfterCallBB, RI); - + // Delete the return instruction now RI->getParent()->getInstList().erase(RI); } - + } else if (!Returns.empty()) { // Otherwise, if there is exactly one return value, just replace anything // using the return value of the call with the computed value. if (!TheCall->use_empty()) TheCall->replaceAllUsesWith(Returns[0]->getReturnValue()); - + // Add a branch to the merge point where the PHI node lives if it exists. new BranchInst(AfterCallBB, Returns[0]); - + // Delete the return instruction now Returns[0]->getParent()->getInstList().erase(Returns[0]); } - + // Since we are now done with the Call/Invoke, we can delete it. - delete TheCall; - - // Change the branch that used to go to AfterCallBB to branch to the first - // basic block of the inlined function. - // - TerminatorInst *Br = OrigBB->getTerminator(); - assert(Br && Br->getOpcode() == Instruction::Br && - "splitBasicBlock broken!"); - Br->setOperand(0, FirstNewBlock); - - // Now that the function is correct, make it a little bit nicer. In - // particular, move the basic blocks inserted from the end of the function - // into the space made by splitting the source basic block. - // - Caller->getBasicBlockList().splice(AfterCallBB, Caller->getBasicBlockList(), - FirstNewBlock, Caller->end()); + TheCall->getParent()->getInstList().erase(TheCall); // We should always be able to fold the entry block of the function into the // single predecessor of the block... - assert(cast(Br)->isUnconditional() && "splitBasicBlock broken!"); + assert(cast(Br)->isUnconditional() &&"splitBasicBlock broken!"); BasicBlock *CalleeEntry = cast(Br)->getSuccessor(0); SimplifyCFG(CalleeEntry); - + // Okay, continue the CFG cleanup. It's often the case that there is only a // single return instruction in the callee function. If this is the case, // then we have an unconditional branch from the return block to the // 'AfterCallBB'. Check for this case, and eliminate the branch is possible. SimplifyCFG(AfterCallBB); + return true; } From alkis at cs.uiuc.edu Wed Feb 4 11:22:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 4 11:22:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.td Printer.cpp Message-ID: <200402041721.LAA15188@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86InstrInfo.td updated: 1.18 -> 1.19 Printer.cpp updated: 1.76 -> 1.77 --- Log message: IMULri* instructions do not require their first two registers operands to be the same (IOW they are not two address instructions). --- Diffs of the changes: (+9 -7) Index: llvm/lib/Target/X86/X86InstrInfo.td diff -u llvm/lib/Target/X86/X86InstrInfo.td:1.18 llvm/lib/Target/X86/X86InstrInfo.td:1.19 --- llvm/lib/Target/X86/X86InstrInfo.td:1.18 Tue Feb 3 01:27:50 2004 +++ llvm/lib/Target/X86/X86InstrInfo.td Wed Feb 4 11:21:04 2004 @@ -270,10 +270,12 @@ def IMULrr16 : I2A16<"imul", 0xAF, MRMSrcReg>, TB, OpSize, Pattern<(set R16, (times R16, R16))>; def IMULrr32 : I2A32<"imul", 0xAF, MRMSrcReg>, TB , Pattern<(set R32, (times R32, R32))>; -def IMULri16 : I2A16<"imul", 0x69, MRMSrcReg>, OpSize; -def IMULri32 : I2A32<"imul", 0x69, MRMSrcReg>; -def IMULri16b : I2A8<"imul", 0x6B, MRMSrcReg>, OpSize; -def IMULri32b : I2A8<"imul", 0x6B, MRMSrcReg>; + +// These are suprisingly enough not two addres instructions! +def IMULri16 : X86Inst<"imul", 0x69, MRMSrcReg, Arg16>, OpSize; +def IMULri32 : X86Inst<"imul", 0x69, MRMSrcReg, Arg32>; +def IMULri16b : X86Inst<"imul", 0x6B, MRMSrcReg, Arg8>, OpSize; +def IMULri32b : X86Inst<"imul", 0x6B, MRMSrcReg, Arg8>; // Logical operators... Index: llvm/lib/Target/X86/Printer.cpp diff -u llvm/lib/Target/X86/Printer.cpp:1.76 llvm/lib/Target/X86/Printer.cpp:1.77 --- llvm/lib/Target/X86/Printer.cpp:1.76 Wed Jan 14 11:14:42 2004 +++ llvm/lib/Target/X86/Printer.cpp Wed Feb 4 11:21:04 2004 @@ -666,8 +666,8 @@ // ModR/M input. The first two operands should be the same, post register // allocation. This is for things like: add r32, r/m32 // - // 3 Operands: in this form, we can have 'INST R, R, imm', which is used for - // instructions like the IMULri instructions. + // 3 Operands: in this form, we can have 'INST R1, R2, imm', which is used + // for instructions like the IMULri instructions. // // 2 Operands: this is for things like mov that do not read a second input // @@ -678,7 +678,7 @@ (MI->getOperand(2).isRegister() || MI->getOperand(2).isImmediate()))) && "Bad format for MRMSrcReg!"); - if (MI->getNumOperands() == 3 && + if (MI->getNumOperands() == 3 && !MI->getOperand(2).isImmediate() && MI->getOperand(0).getReg() != MI->getOperand(1).getReg()) O << "**"; From lattner at cs.uiuc.edu Wed Feb 4 15:34:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 4 15:34:05 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp Message-ID: <200402042133.PAA05738@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: InlineFunction.cpp updated: 1.21 -> 1.22 --- Log message: Two changes: 1. Don't scan to the end of alloca instructions in the caller function to insert inlined allocas, just insert at the top. This saves a lot of time inlining into functions with a lot of allocas. 2. Use splice to move the alloca instructions over, instead of remove/insert. This allows us to transfer a block at a time, and eliminates a bunch of silly symbol table manipulations. This speeds up the inliner on the testcase in PR209 from 1.73s -> 1.04s (67%) --- Diffs of the changes: (+12 -5) Index: llvm/lib/Transforms/Utils/InlineFunction.cpp diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.21 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.22 --- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.21 Tue Feb 3 22:17:06 2004 +++ llvm/lib/Transforms/Utils/InlineFunction.cpp Wed Feb 4 15:33:42 2004 @@ -73,7 +73,7 @@ // Clone the entire body of the callee into the caller. CloneFunctionInto(Caller, CalledFunc, ValueMap, Returns, ".i"); } - + // Remember the first block that is newly cloned over. Function::iterator FirstNewBlock = LastBlock; ++FirstNewBlock; @@ -84,14 +84,21 @@ // if (isa(FirstNewBlock->begin())) { BasicBlock::iterator InsertPoint = Caller->begin()->begin(); - while (isa(InsertPoint)) ++InsertPoint; - for (BasicBlock::iterator I = FirstNewBlock->begin(), E = FirstNewBlock->end(); I != E; ) if (AllocaInst *AI = dyn_cast(I++)) if (isa(AI->getArraySize())) { - FirstNewBlock->getInstList().remove(AI); - Caller->front().getInstList().insert(InsertPoint, AI); + // Scan for the block of allocas that we can move over. + while (isa(I) && + isa(cast(I)->getArraySize())) + ++I; + + // Transfer all of the allocas over in a block. Using splice means + // that they instructions aren't removed from the symbol table, then + // reinserted. + Caller->front().getInstList().splice(InsertPoint, + FirstNewBlock->getInstList(), + AI, I); } } From gaeke at cs.uiuc.edu Wed Feb 4 15:41:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 4 15:41:02 2004 Subject: [llvm-commits] CVS: llvm/runtime/Makefile Message-ID: <200402042140.PAA08802@zion.cs.uiuc.edu> Changes in directory llvm/runtime: Makefile updated: 1.12 -> 1.13 --- Log message: Clean out DESTLIBBYTECODE when making clean in runtime. --- Diffs of the changes: (+2 -0) Index: llvm/runtime/Makefile diff -u llvm/runtime/Makefile:1.12 llvm/runtime/Makefile:1.13 --- llvm/runtime/Makefile:1.12 Fri Jan 16 15:13:10 2004 +++ llvm/runtime/Makefile Wed Feb 4 15:40:49 2004 @@ -30,3 +30,5 @@ install:: clean:: + rm -f $(DESTLIBBYTECODE)/* + From gaeke at cs.uiuc.edu Wed Feb 4 15:42:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 4 15:42:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86TargetMachine.cpp Message-ID: <200402042141.PAA08932@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86TargetMachine.cpp updated: 1.44 -> 1.45 --- Log message: Take away the default iostream argument of createMachineFunctionPrinterPass(), at Chris's request. --- Diffs of the changes: (+6 -6) Index: llvm/lib/Target/X86/X86TargetMachine.cpp diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.44 llvm/lib/Target/X86/X86TargetMachine.cpp:1.45 --- llvm/lib/Target/X86/X86TargetMachine.cpp:1.44 Sun Dec 28 15:23:38 2003 +++ llvm/lib/Target/X86/X86TargetMachine.cpp Wed Feb 4 15:41:01 2004 @@ -77,18 +77,18 @@ // Print the instruction selected machine code... if (PrintCode) - PM.add(createMachineFunctionPrinterPass()); + PM.add(createMachineFunctionPrinterPass(&std::cerr)); // Perform register allocation to convert to a concrete x86 representation PM.add(createRegisterAllocator()); if (PrintCode) - PM.add(createMachineFunctionPrinterPass()); + PM.add(createMachineFunctionPrinterPass(&std::cerr)); PM.add(createX86FloatingPointStackifierPass()); if (PrintCode) - PM.add(createMachineFunctionPrinterPass()); + PM.add(createMachineFunctionPrinterPass(&std::cerr)); // Insert prolog/epilog code. Eliminate abstract frame index references... PM.add(createPrologEpilogCodeInserter()); @@ -134,18 +134,18 @@ // Print the instruction selected machine code... if (PrintCode) - PM.add(createMachineFunctionPrinterPass()); + PM.add(createMachineFunctionPrinterPass(&std::cerr)); // Perform register allocation to convert to a concrete x86 representation PM.add(createRegisterAllocator()); if (PrintCode) - PM.add(createMachineFunctionPrinterPass()); + PM.add(createMachineFunctionPrinterPass(&std::cerr)); PM.add(createX86FloatingPointStackifierPass()); if (PrintCode) - PM.add(createMachineFunctionPrinterPass()); + PM.add(createMachineFunctionPrinterPass(&std::cerr)); // Insert prolog/epilog code. Eliminate abstract frame index references... PM.add(createPrologEpilogCodeInserter()); From gaeke at cs.uiuc.edu Wed Feb 4 15:42:05 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 4 15:42:05 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/Passes.h Message-ID: <200402042141.PAA09179@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: Passes.h updated: 1.13 -> 1.14 --- Log message: Include and instead of . Take away the default iostream argument of createMachineFunctionPrinterPass(), at Chris's request. --- Diffs of the changes: (+3 -2) Index: llvm/include/llvm/CodeGen/Passes.h diff -u llvm/include/llvm/CodeGen/Passes.h:1.13 llvm/include/llvm/CodeGen/Passes.h:1.14 --- llvm/include/llvm/CodeGen/Passes.h:1.13 Fri Jan 30 15:53:44 2004 +++ llvm/include/llvm/CodeGen/Passes.h Wed Feb 4 15:41:10 2004 @@ -15,7 +15,8 @@ #ifndef LLVM_CODEGEN_PASSES_H #define LLVM_CODEGEN_PASSES_H -#include +#include +#include namespace llvm { @@ -25,7 +26,7 @@ /// MachineFunctionPrinter pass - This pass prints out the machine function to /// standard error, as a debugging tool. - FunctionPass *createMachineFunctionPrinterPass(std::ostream *OS = &std::cerr, + FunctionPass *createMachineFunctionPrinterPass(std::ostream *OS, const std::string &Banner =""); /// PHIElimination pass - This pass eliminates machine instruction PHI nodes From gaeke at cs.uiuc.edu Wed Feb 4 15:42:09 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 4 15:42:09 2004 Subject: [llvm-commits] CVS: llvm/Makefile.rules Message-ID: <200402042141.PAA09192@zion.cs.uiuc.edu> Changes in directory llvm: Makefile.rules updated: 1.176 -> 1.177 --- Log message: Always replace instead of appending when creating archive files. It may be slightly slower, but I think we can handle it, especially if it means BytecodeLibs are correctly regenerated. --- Diffs of the changes: (+1 -1) Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.176 llvm/Makefile.rules:1.177 --- llvm/Makefile.rules:1.176 Thu Jan 22 16:53:48 2004 +++ llvm/Makefile.rules Wed Feb 4 15:41:23 2004 @@ -352,7 +352,7 @@ DependC := $(CC) -MM -I$(LEVEL)/include $(CPPFLAGS) # Archive a bunch of .o files into a .a file... -AR = ${AR_PATH} cq +AR = $(AR_PATH) cr #---------------------------------------------------------- From lattner at cs.uiuc.edu Wed Feb 4 15:45:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 4 15:45:03 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/CloneFunction.cpp Message-ID: <200402042144.PAA12219@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: CloneFunction.cpp updated: 1.20 -> 1.21 --- Log message: Minor speedup, don't query ValueMap each time through the loop --- Diffs of the changes: (+3 -6) Index: llvm/lib/Transforms/Utils/CloneFunction.cpp diff -u llvm/lib/Transforms/Utils/CloneFunction.cpp:1.20 llvm/lib/Transforms/Utils/CloneFunction.cpp:1.21 --- llvm/lib/Transforms/Utils/CloneFunction.cpp:1.20 Tue Feb 3 19:19:43 2004 +++ llvm/lib/Transforms/Utils/CloneFunction.cpp Wed Feb 4 15:44:26 2004 @@ -92,14 +92,11 @@ // Loop over all of the instructions in the function, fixing up operand // references as we go. This uses ValueMap to do all the hard work. // - for (Function::const_iterator BB = OldFunc->begin(), BE = OldFunc->end(); - BB != BE; ++BB) { - BasicBlock *NBB = cast(ValueMap[BB]); - + for (Function::iterator BB = cast(ValueMap[OldFunc->begin()]), + BE = NewFunc->end(); BB != BE; ++BB) // Loop over all instructions, fixing each one as we find it... - for (BasicBlock::iterator II = NBB->begin(); II != NBB->end(); ++II) + for (BasicBlock::iterator II = BB->begin(); II != BB->end(); ++II) RemapInstruction(II, ValueMap); - } } /// CloneFunction - Return a copy of the specified function, but without From gaeke at cs.uiuc.edu Wed Feb 4 15:59:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 4 15:59:01 2004 Subject: [llvm-commits] CVS: llvm-www/demo/index.cgi Message-ID: <200402042158.PAA13107@zion.cs.uiuc.edu> Changes in directory llvm-www/demo: index.cgi updated: 1.20 -> 1.21 --- Log message: llvm-gcc should emit warnings. --- Diffs of the changes: (+2 -2) Index: llvm-www/demo/index.cgi diff -u llvm-www/demo/index.cgi:1.20 llvm-www/demo/index.cgi:1.21 --- llvm-www/demo/index.cgi:1.20 Wed Jan 14 23:11:33 2004 +++ llvm-www/demo/index.cgi Wed Feb 4 15:58:18 2004 @@ -5,7 +5,7 @@ # doing remote web JO99C compilations. (It could still be used for that # purpose, though the two scripts have diverged somewhat.) # -# Last modified $Date: 2004/01/15 05:11:33 $ +# Last modified $Date: 2004/02/04 21:58:18 $ # use CGI; @@ -300,7 +300,7 @@ $stats = "-Wa,--stats,--time-passes,--info-output-file=$timerFile" if ( $c->param('showstats') ); try_run( "llvm C/C++ front-end (llvm-gcc)", - "llvm-gcc $stats -o $bytecodeFile -c $inputFile > $outputFile 2>&1", + "llvm-gcc -Wall $stats -o $bytecodeFile -c $inputFile > $outputFile 2>&1", $outputFile ); if ( $c->param('showstats') && -s $timerFile ) { ( $UnhilightedResult, $HtmlResult ) = From gaeke at cs.uiuc.edu Wed Feb 4 16:12:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 4 16:12:01 2004 Subject: [llvm-commits] CVS: llvm-www/demo/index.cgi Message-ID: <200402042211.QAA15131@zion.cs.uiuc.edu> Changes in directory llvm-www/demo: index.cgi updated: 1.21 -> 1.22 --- Log message: Turn on autoflush. Fix bug where warnings from llvm-gcc got printed twice. --- Diffs of the changes: (+7 -3) Index: llvm-www/demo/index.cgi diff -u llvm-www/demo/index.cgi:1.21 llvm-www/demo/index.cgi:1.22 --- llvm-www/demo/index.cgi:1.21 Wed Feb 4 15:58:18 2004 +++ llvm-www/demo/index.cgi Wed Feb 4 16:11:22 2004 @@ -5,13 +5,15 @@ # doing remote web JO99C compilations. (It could still be used for that # purpose, though the two scripts have diverged somewhat.) # -# Last modified $Date: 2004/02/04 21:58:18 $ +# Last modified $Date: 2004/02/04 22:11:22 $ # use CGI; use POSIX; use Mail::Send; +$| = 1; + open( STDERR, ">&STDOUT" ) or die "can't redirect stderr to stdout"; if ( !-d "/tmp/webcompile" ) { mkdir( "/tmp/webcompile", 0777 ); } @@ -219,11 +221,13 @@ sub try_run { my ( $program, $commandline, $outputFile ) = @_; - #print "command line was [ $commandline ]\n"; + #print "

    Command line was $commandline

    \n"; my $retcode = system($commandline); + #print "

    Finished running command.

    \n"; if ( -s $outputFile ) { - print dumpFile( "Output from $program", $outputFile ); + print scalar dumpFile( "Output from $program", $outputFile ); } + #print "

    Finished dumping command output.

    \n"; if ( WIFEXITED($retcode) && WEXITSTATUS($retcode) != 0 ) { barf( "$program exited with an error. Please correct source and resubmit.\n" From alkis at cs.uiuc.edu Wed Feb 4 16:18:25 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 4 16:18:25 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp RegAllocLinearScan.cpp MachineInstr.cpp Message-ID: <200402042217.QAA15447@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: TwoAddressInstructionPass.cpp updated: 1.11 -> 1.12 RegAllocLinearScan.cpp updated: 1.40 -> 1.41 MachineInstr.cpp updated: 1.83 -> 1.84 --- Log message: Modify the two address instruction pass to remove the duplicate operand of the instruction and thus simplify the register allocation. --- Diffs of the changes: (+93 -103) Index: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp diff -u llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.11 llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.12 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.11 Mon Feb 2 17:08:58 2004 +++ llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Wed Feb 4 16:17:40 2004 @@ -16,11 +16,14 @@ // to: // // A = B -// A = A op C +// A op= C // -// Note that if a register allocator chooses to use this pass, that it has to -// be capable of handling the non-SSA nature of these rewritten virtual -// registers. +// Note that if a register allocator chooses to use this pass, that it +// has to be capable of handling the non-SSA nature of these rewritten +// virtual registers. +// +// It is also worth noting that the duplicate operand of the two +// address instruction is removed. // //===----------------------------------------------------------------------===// @@ -98,63 +101,70 @@ mi->getOperand(1).isUse() && "two address instruction invalid"); - // we have nothing to do if the two operands are the same + // if the two operands are the same we just remove the use + // and mark the def as def&use if (mi->getOperand(0).getAllocatedRegNum() == - mi->getOperand(1).getAllocatedRegNum()) - continue; - - MadeChange = true; + mi->getOperand(1).getAllocatedRegNum()) { + } + else { + MadeChange = true; - // rewrite: - // a = b op c - // to: - // a = b - // a = a op c - unsigned regA = mi->getOperand(0).getAllocatedRegNum(); - unsigned regB = mi->getOperand(1).getAllocatedRegNum(); - - assert(MRegisterInfo::isVirtualRegister(regA) && - MRegisterInfo::isVirtualRegister(regB) && - "cannot update physical register live information"); - - // first make sure we do not have a use of a in the - // instruction (a = b + a for example) because our - // transformation will not work. This should never occur - // because we are in SSA form. - for (unsigned i = 1; i != mi->getNumOperands(); ++i) - assert(!mi->getOperand(i).isRegister() || - mi->getOperand(i).getAllocatedRegNum() != (int)regA); - - const TargetRegisterClass* rc =MF.getSSARegMap()->getRegClass(regA); - unsigned Added = MRI.copyRegToReg(*mbbi, mii, regA, regB, rc); - numInstrsAdded += Added; - - MachineInstr* prevMi = *(mii - 1); - DEBUG(std::cerr << "\t\tadded instruction: "; - prevMi->print(std::cerr, TM)); - - // update live variables for regA - assert(Added == 1 && "Cannot handle multi-instruction copies yet!"); - LiveVariables::VarInfo& varInfo = LV.getVarInfo(regA); - varInfo.DefInst = prevMi; - - // update live variables for regB - if (LV.removeVirtualRegisterKilled(regB, &*mbbi, mi)) - LV.addVirtualRegisterKilled(regB, &*mbbi, prevMi); - - if (LV.removeVirtualRegisterDead(regB, &*mbbi, mi)) - LV.addVirtualRegisterDead(regB, &*mbbi, prevMi); - - // replace all occurences of regB with regA - for (unsigned i = 1; i < mi->getNumOperands(); ++i) { - if (mi->getOperand(i).isRegister() && - mi->getOperand(i).getReg() == regB) - mi->SetMachineOperandReg(i, regA); + // rewrite: + // a = b op c + // to: + // a = b + // a = a op c + unsigned regA = mi->getOperand(0).getAllocatedRegNum(); + unsigned regB = mi->getOperand(1).getAllocatedRegNum(); + + assert(MRegisterInfo::isVirtualRegister(regA) && + MRegisterInfo::isVirtualRegister(regB) && + "cannot update physical register live information"); + + // first make sure we do not have a use of a in the + // instruction (a = b + a for example) because our + // transformation will not work. This should never occur + // because we are in SSA form. + for (unsigned i = 1; i != mi->getNumOperands(); ++i) + assert(!mi->getOperand(i).isRegister() || + mi->getOperand(i).getAllocatedRegNum() != (int)regA); + + const TargetRegisterClass* rc = + MF.getSSARegMap()->getRegClass(regA); + unsigned Added = MRI.copyRegToReg(*mbbi, mii, regA, regB, rc); + numInstrsAdded += Added; + + MachineInstr* prevMi = *(mii - 1); + DEBUG(std::cerr << "\t\tadded instruction: "; + prevMi->print(std::cerr, TM)); + + // update live variables for regA + assert(Added == 1 && + "Cannot handle multi-instruction copies yet!"); + LiveVariables::VarInfo& varInfo = LV.getVarInfo(regA); + varInfo.DefInst = prevMi; + + // update live variables for regB + if (LV.removeVirtualRegisterKilled(regB, &*mbbi, mi)) + LV.addVirtualRegisterKilled(regB, &*mbbi, prevMi); + + if (LV.removeVirtualRegisterDead(regB, &*mbbi, mi)) + LV.addVirtualRegisterDead(regB, &*mbbi, prevMi); + + // replace all occurences of regB with regA + for (unsigned i = 1, e = mi->getNumOperands(); i != e; ++i) { + if (mi->getOperand(i).isRegister() && + mi->getOperand(i).getReg() == regB) + mi->SetMachineOperandReg(i, regA); + } } + + assert(mi->getOperand(0).isDef()); + mi->getOperand(0).setUse(); + mi->RemoveOperand(1); + DEBUG(std::cerr << "\t\tmodified original to: "; mi->print(std::cerr, TM)); - assert(mi->getOperand(0).getAllocatedRegNum() == - mi->getOperand(1).getAllocatedRegNum()); } } Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.40 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.41 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.40 Mon Feb 2 19:13:06 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Wed Feb 4 16:17:40 2004 @@ -109,10 +109,6 @@ typedef std::vector IntervalPtrs; IntervalPtrs unhandled_, fixed_, active_, inactive_; - typedef std::vector Regs; - Regs tempUseOperands_; - Regs tempDefOperands_; - PhysRegTracker prt_; typedef std::map Virt2PhysMap; @@ -428,7 +424,6 @@ for (currentInstr_ = currentMbb_->begin(); currentInstr_ != currentMbb_->end(); ) { - DEBUG(std::cerr << "\tinstruction: "; (*currentInstr_)->print(std::cerr, *tm_);); @@ -465,13 +460,17 @@ continue; } + typedef std::vector Regs; + Regs toClear; + Regs toSpill; + + const unsigned numOperands = (*currentInstr_)->getNumOperands(); + DEBUG(std::cerr << "\t\tloading temporarily used operands to " "registers:\n"); - for (unsigned i = 0, e = (*currentInstr_)->getNumOperands(); - i != e; ++i) { + for (unsigned i = 0; i != numOperands; ++i) { MachineOperand& op = (*currentInstr_)->getOperand(i); - if (op.isVirtualRegister() && op.isUse() && - !op.isEverDefined(**currentInstr_)) { + if (op.isVirtualRegister() && op.isUse()) { unsigned virtReg = op.getAllocatedRegNum(); unsigned physReg = 0; Virt2PhysMap::const_iterator it = v2pMap_.find(virtReg); @@ -481,26 +480,28 @@ else { physReg = getFreeTempPhysReg(virtReg); loadVirt2PhysReg(virtReg, physReg); - tempUseOperands_.push_back(virtReg); + // we will clear uses that are not also defs + // before we allocate registers the defs + if (op.isDef()) + toSpill.push_back(virtReg); + else + toClear.push_back(virtReg); } (*currentInstr_)->SetMachineOperandReg(i, physReg); } } - DEBUG(std::cerr << "\t\tclearing temporarily used operands:\n"); - for (unsigned i = 0, e = tempUseOperands_.size(); i != e; ++i) { - clearVirtReg(tempUseOperands_[i]); - } - tempUseOperands_.clear(); + DEBUG(std::cerr << "\t\tclearing temporarily used but not defined " + "operands:\n"); + std::for_each(toClear.begin(), toClear.end(), + std::bind1st(std::mem_fun(&RA::clearVirtReg), this)); DEBUG(std::cerr << "\t\tassigning temporarily defined operands to " "registers:\n"); - for (unsigned i = 0, e = (*currentInstr_)->getNumOperands(); - i != e; ++i) { + for (unsigned i = 0; i != numOperands; ++i) { MachineOperand& op = (*currentInstr_)->getOperand(i); if (op.isVirtualRegister()) { - assert(op.isEverDefined(**currentInstr_) && - "operand should be defined by this instruction"); + assert(!op.isUse() && "we should not have uses here!"); unsigned virtReg = op.getAllocatedRegNum(); unsigned physReg = 0; Virt2PhysMap::const_iterator it = v2pMap_.find(virtReg); @@ -510,21 +511,18 @@ else { physReg = getFreeTempPhysReg(virtReg); assignVirt2PhysReg(virtReg, physReg); - tempDefOperands_.push_back(virtReg); + // need to spill this after we are done with + // this instruction + toSpill.push_back(virtReg); } (*currentInstr_)->SetMachineOperandReg(i, physReg); } } + ++currentInstr_; // spills will go after this instruction - DEBUG(std::cerr << "\t\tspilling temporarily defined operands " - "of this instruction:\n"); - ++currentInstr_; // we want to insert after this instruction - for (unsigned i = 0, e = tempDefOperands_.size(); i != e; ++i) { - spillVirtReg(tempDefOperands_[i]); - } - --currentInstr_; // restore currentInstr_ iterator - tempDefOperands_.clear(); - ++currentInstr_; + DEBUG(std::cerr << "\t\tspilling temporarily defined operands:\n"); + std::for_each(toSpill.begin(), toSpill.end(), + std::bind1st(std::mem_fun(&RA::spillVirtReg), this)); } } Index: llvm/lib/CodeGen/MachineInstr.cpp diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.83 llvm/lib/CodeGen/MachineInstr.cpp:1.84 --- llvm/lib/CodeGen/MachineInstr.cpp:1.83 Mon Feb 2 19:13:06 2004 +++ llvm/lib/CodeGen/MachineInstr.cpp Wed Feb 4 16:17:40 2004 @@ -27,24 +27,6 @@ // extern const TargetInstrDescriptor *TargetInstrDescriptors; -bool MachineOperand::isEverUsed(const MachineInstr& mi) const -{ - for (int i = 0, e = mi.getNumOperands(); i != e; ++i) { - if (*this == mi.getOperand(i) && mi.getOperand(i).isUse()) - return true; - } - return false; -} - -bool MachineOperand::isEverDefined(const MachineInstr& mi) const -{ - for (int i = 0, e = mi.getNumOperands(); i != e; ++i) { - if (*this == mi.getOperand(i) && mi.getOperand(i).isDef()) - return true; - } - return false; -} - // Constructor for instructions with variable #operands MachineInstr::MachineInstr(MachineOpCode OpCode, unsigned numOperands) : opCode(OpCode), From alkis at cs.uiuc.edu Wed Feb 4 16:18:32 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 4 16:18:32 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.cpp X86CodeEmitter.cpp Printer.cpp PeepholeOptimizer.cpp Message-ID: <200402042217.QAA15437@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86RegisterInfo.cpp updated: 1.40 -> 1.41 X86CodeEmitter.cpp updated: 1.46 -> 1.47 Printer.cpp updated: 1.77 -> 1.78 PeepholeOptimizer.cpp updated: 1.9 -> 1.10 --- Log message: Modify the two address instruction pass to remove the duplicate operand of the instruction and thus simplify the register allocation. --- Diffs of the changes: (+66 -66) Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.40 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.41 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.40 Tue Nov 11 16:41:33 2003 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Wed Feb 4 16:17:40 2004 @@ -110,10 +110,10 @@ Amount = (Amount+Align-1)/Align*Align; if (Old->getOpcode() == X86::ADJCALLSTACKDOWN) { - New=BuildMI(X86::SUBri32, 2, X86::ESP).addReg(X86::ESP).addZImm(Amount); + New=BuildMI(X86::SUBri32, 1, X86::ESP, MOTy::UseAndDef).addZImm(Amount); } else { assert(Old->getOpcode() == X86::ADJCALLSTACKUP); - New=BuildMI(X86::ADDri32, 2, X86::ESP).addReg(X86::ESP).addZImm(Amount); + New=BuildMI(X86::ADDri32, 1, X86::ESP, MOTy::UseAndDef).addZImm(Amount); } } } @@ -181,7 +181,7 @@ int EBPOffset = MFI->getObjectOffset(MFI->getObjectIndexEnd()-1)+4; if (NumBytes) { // adjust stack pointer: ESP -= numbytes - MI= BuildMI(X86::SUBri32, 2, X86::ESP).addReg(X86::ESP).addZImm(NumBytes); + MI= BuildMI(X86::SUBri32, 1, X86::ESP, MOTy::UseAndDef).addZImm(NumBytes); MBBI = MBB.insert(MBBI, MI)+1; } @@ -215,7 +215,7 @@ if (NumBytes) { // adjust stack pointer: ESP -= numbytes - MI= BuildMI(X86::SUBri32, 2, X86::ESP).addReg(X86::ESP).addZImm(NumBytes); + MI= BuildMI(X86::SUBri32, 1, X86::ESP, MOTy::UseAndDef).addZImm(NumBytes); MBB.insert(MBBI, MI); } } @@ -248,7 +248,7 @@ unsigned NumBytes = MFI->getStackSize(); if (NumBytes) { // adjust stack pointer back: ESP += numbytes - MI =BuildMI(X86::ADDri32, 2, X86::ESP).addReg(X86::ESP).addZImm(NumBytes); + MI =BuildMI(X86::ADDri32, 1, X86::ESP, MOTy::UseAndDef).addZImm(NumBytes); MBBI = 1+MBB.insert(MBBI, MI); } } Index: llvm/lib/Target/X86/X86CodeEmitter.cpp diff -u llvm/lib/Target/X86/X86CodeEmitter.cpp:1.46 llvm/lib/Target/X86/X86CodeEmitter.cpp:1.47 --- llvm/lib/Target/X86/X86CodeEmitter.cpp:1.46 Sat Dec 20 10:22:59 2003 +++ llvm/lib/Target/X86/X86CodeEmitter.cpp Wed Feb 4 16:17:40 2004 @@ -548,10 +548,10 @@ case X86II::MRMDestReg: { MCE.emitByte(BaseOpcode); - MachineOperand &SrcOp = MI.getOperand(1+II->isTwoAddrInstr(Opcode)); - emitRegModRMByte(MI.getOperand(0).getReg(), getX86RegNum(SrcOp.getReg())); - if (MI.getNumOperands() == 4) - emitConstant(MI.getOperand(3).getImmedValue(), sizeOfPtr(Desc)); + emitRegModRMByte(MI.getOperand(0).getReg(), + getX86RegNum(MI.getOperand(1).getReg())); + if (MI.getNumOperands() == 3) + emitConstant(MI.getOperand(2).getImmedValue(), sizeOfPtr(Desc)); break; } case X86II::MRMDestMem: @@ -562,18 +562,10 @@ case X86II::MRMSrcReg: MCE.emitByte(BaseOpcode); - if (MI.getNumOperands() == 2) { - emitRegModRMByte(MI.getOperand(MI.getNumOperands()-1).getReg(), - getX86RegNum(MI.getOperand(0).getReg())); - } else if (MI.getOperand(2).isImmediate()) { - emitRegModRMByte(MI.getOperand(1).getReg(), - getX86RegNum(MI.getOperand(0).getReg())); - + emitRegModRMByte(MI.getOperand(1).getReg(), + getX86RegNum(MI.getOperand(0).getReg())); + if (MI.getNumOperands() == 3) emitConstant(MI.getOperand(2).getImmedValue(), sizeOfPtr(Desc)); - } else { - emitRegModRMByte(MI.getOperand(2).getReg(), - getX86RegNum(MI.getOperand(0).getReg())); - } break; case X86II::MRMSrcMem: Index: llvm/lib/Target/X86/Printer.cpp diff -u llvm/lib/Target/X86/Printer.cpp:1.77 llvm/lib/Target/X86/Printer.cpp:1.78 --- llvm/lib/Target/X86/Printer.cpp:1.77 Wed Feb 4 11:21:04 2004 +++ llvm/lib/Target/X86/Printer.cpp Wed Feb 4 16:17:40 2004 @@ -609,35 +609,31 @@ return; } case X86II::MRMDestReg: { - // There are two acceptable forms of MRMDestReg instructions, those with 2, - // 3 and 4 operands: + // There are three forms of MRMDestReg instructions, those with 2 + // or 3 operands: // - // 2 Operands: this is for things like mov that do not read a second input + // 2 Operands: this is for things like mov that do not read a + // second input. // - // 3 Operands: in this form, the first two registers (the destination, and - // the first operand) should be the same, post register allocation. The 3rd - // operand is an additional input. This should be for things like add - // instructions. + // 2 Operands: two address instructions which def&use the first + // argument and use the second as input. // - // 4 Operands: This form is for instructions which are 3 operands forms, but - // have a constant argument as well. + // 3 Operands: in this form, two address instructions are the same + // as in 2 but have a constant argument as well. // bool isTwoAddr = TII.isTwoAddrInstr(Opcode); assert(MI->getOperand(0).isRegister() && (MI->getNumOperands() == 2 || - (isTwoAddr && MI->getOperand(1).isRegister() && - MI->getOperand(0).getReg() == MI->getOperand(1).getReg() && - (MI->getNumOperands() == 3 || - (MI->getNumOperands() == 4 && MI->getOperand(3).isImmediate())))) + (MI->getNumOperands() == 3 && MI->getOperand(2).isImmediate())) && "Bad format for MRMDestReg!"); O << TII.getName(MI->getOpCode()) << " "; printOp(MI->getOperand(0)); O << ", "; - printOp(MI->getOperand(1+isTwoAddr)); - if (MI->getNumOperands() == 4) { + printOp(MI->getOperand(1)); + if (MI->getNumOperands() == 3) { O << ", "; - printOp(MI->getOperand(3)); + printOp(MI->getOperand(2)); } O << "\n"; return; @@ -659,40 +655,35 @@ } case X86II::MRMSrcReg: { - // There are three forms that are acceptable for MRMSrcReg instructions, - // those with 3 and 2 operands: + // There are three forms that are acceptable for MRMSrcReg + // instructions, those with 2 or 3 operands: // - // 3 Operands: in this form, the last register (the second input) is the - // ModR/M input. The first two operands should be the same, post register - // allocation. This is for things like: add r32, r/m32 + // 2 Operands: this is for things like mov that do not read a + // second input. + // + // 2 Operands: in this form, the last register is the ModR/M + // input. The first operand is a def&use. This is for things + // like: add r32, r/m32 // // 3 Operands: in this form, we can have 'INST R1, R2, imm', which is used // for instructions like the IMULri instructions. // - // 2 Operands: this is for things like mov that do not read a second input // assert(MI->getOperand(0).isRegister() && MI->getOperand(1).isRegister() && - (MI->getNumOperands() == 2 || - (MI->getNumOperands() == 3 && - (MI->getOperand(2).isRegister() || - MI->getOperand(2).isImmediate()))) + (MI->getNumOperands() == 2 || + (MI->getNumOperands() == 3 && + (MI->getOperand(2).isImmediate()))) && "Bad format for MRMSrcReg!"); - if (MI->getNumOperands() == 3 && !MI->getOperand(2).isImmediate() && - MI->getOperand(0).getReg() != MI->getOperand(1).getReg()) - O << "**"; O << TII.getName(MI->getOpCode()) << " "; printOp(MI->getOperand(0)); - - // If this is IMULri* instructions, print the non-two-address operand. - if (MI->getNumOperands() == 3 && MI->getOperand(2).isImmediate()) { - O << ", "; - printOp(MI->getOperand(1)); - } - O << ", "; - printOp(MI->getOperand(MI->getNumOperands()-1)); + printOp(MI->getOperand(1)); + if (MI->getNumOperands() == 3) { + O << ", "; + printOp(MI->getOperand(2)); + } O << "\n"; return; } @@ -705,7 +696,7 @@ (MI->getNumOperands() == 1+4 && isMem(MI, 1)) || (MI->getNumOperands() == 2+4 && MI->getOperand(1).isRegister() && isMem(MI, 2)) - && "Bad format for MRMDestReg!"); + && "Bad format for MRMSrcMem!"); if (MI->getNumOperands() == 2+4 && MI->getOperand(0).getReg() != MI->getOperand(1).getReg()) O << "**"; Index: llvm/lib/Target/X86/PeepholeOptimizer.cpp diff -u llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.9 llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.10 --- llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.9 Sun Dec 14 07:24:15 2003 +++ llvm/lib/Target/X86/PeepholeOptimizer.cpp Wed Feb 4 16:17:40 2004 @@ -67,15 +67,35 @@ // immediate despite the fact that the operands are 16 or 32 bits. Because // this can save three bytes of code size (and icache space), we want to // shrink them if possible. + case X86::IMULri16: case X86::IMULri32: + assert(MI->getNumOperands() == 3 && "These should all have 3 operands!"); + if (MI->getOperand(2).isImmediate()) { + int Val = MI->getOperand(2).getImmedValue(); + // If the value is the same when signed extended from 8 bits... + if (Val == (signed int)(signed char)Val) { + unsigned Opcode; + switch (MI->getOpcode()) { + default: assert(0 && "Unknown opcode value!"); + case X86::IMULri16: Opcode = X86::IMULri16b; break; + case X86::IMULri32: Opcode = X86::IMULri32b; break; + } + unsigned R0 = MI->getOperand(0).getReg(); + unsigned R1 = MI->getOperand(1).getReg(); + *I = BuildMI(Opcode, 2, R0).addReg(R1).addZImm((char)Val); + delete MI; + return true; + } + } + return false; + case X86::ADDri16: case X86::ADDri32: case X86::SUBri16: case X86::SUBri32: - case X86::IMULri16: case X86::IMULri32: case X86::ANDri16: case X86::ANDri32: case X86::ORri16: case X86::ORri32: case X86::XORri16: case X86::XORri32: - assert(MI->getNumOperands() == 3 && "These should all have 3 operands!"); - if (MI->getOperand(2).isImmediate()) { - int Val = MI->getOperand(2).getImmedValue(); + assert(MI->getNumOperands() == 2 && "These should all have 2 operands!"); + if (MI->getOperand(1).isImmediate()) { + int Val = MI->getOperand(1).getImmedValue(); // If the value is the same when signed extended from 8 bits... if (Val == (signed int)(signed char)Val) { unsigned Opcode; @@ -85,8 +105,6 @@ case X86::ADDri32: Opcode = X86::ADDri32b; break; case X86::SUBri16: Opcode = X86::SUBri16b; break; case X86::SUBri32: Opcode = X86::SUBri32b; break; - case X86::IMULri16: Opcode = X86::IMULri16b; break; - case X86::IMULri32: Opcode = X86::IMULri32b; break; case X86::ANDri16: Opcode = X86::ANDri16b; break; case X86::ANDri32: Opcode = X86::ANDri32b; break; case X86::ORri16: Opcode = X86::ORri16b; break; @@ -95,8 +113,7 @@ case X86::XORri32: Opcode = X86::XORri32b; break; } unsigned R0 = MI->getOperand(0).getReg(); - unsigned R1 = MI->getOperand(1).getReg(); - *I = BuildMI(Opcode, 2, R0).addReg(R1).addZImm((char)Val); + *I = BuildMI(Opcode, 1, R0, MOTy::UseAndDef).addZImm((char)Val); delete MI; return true; } From alkis at cs.uiuc.edu Wed Feb 4 16:18:38 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 4 16:18:38 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstrBuilder.h MachineInstr.h Message-ID: <200402042217.QAA15454@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstrBuilder.h updated: 1.16 -> 1.17 MachineInstr.h updated: 1.121 -> 1.122 --- Log message: Modify the two address instruction pass to remove the duplicate operand of the instruction and thus simplify the register allocation. --- Diffs of the changes: (+11 -14) Index: llvm/include/llvm/CodeGen/MachineInstrBuilder.h diff -u llvm/include/llvm/CodeGen/MachineInstrBuilder.h:1.16 llvm/include/llvm/CodeGen/MachineInstrBuilder.h:1.17 --- llvm/include/llvm/CodeGen/MachineInstrBuilder.h:1.16 Tue Nov 11 16:41:31 2003 +++ llvm/include/llvm/CodeGen/MachineInstrBuilder.h Wed Feb 4 16:17:40 2004 @@ -138,9 +138,10 @@ /// calls that are expected, it does not include the destination register. /// inline MachineInstrBuilder BuildMI(int Opcode, unsigned NumOperands, - unsigned DestReg) { + unsigned DestReg, + MOTy::UseType useType = MOTy::Def) { return MachineInstrBuilder(new MachineInstr(Opcode, NumOperands+1, - true, true)).addReg(DestReg, MOTy::Def); + true, true)).addReg(DestReg, useType); } Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.121 llvm/include/llvm/CodeGen/MachineInstr.h:1.122 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.121 Mon Feb 2 19:13:07 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Wed Feb 4 16:17:40 2004 @@ -207,10 +207,6 @@ return *this; } - bool operator==(const MachineOperand& rhs) const { - return regNum == rhs.regNum && opType == rhs.opType; - } - // Accessor methods. Caller is responsible for checking the // operand type before invoking the corresponding accessor. // @@ -285,14 +281,14 @@ return *SymbolName; } - bool isUse () const { return flags & USEFLAG; } - bool isEverUsed (const MachineInstr&) const; - bool isDef () const { return flags & DEFFLAG; } - bool isHiBits32 () const { return flags & HIFLAG32; } - bool isEverDefined (const MachineInstr&) const; - bool isLoBits32 () const { return flags & LOFLAG32; } - bool isHiBits64 () const { return flags & HIFLAG64; } - bool isLoBits64 () const { return flags & LOFLAG64; } + bool isUse () const { return flags & USEFLAG; } + MachineOperand& setUse () { flags |= USEFLAG; return *this; } + bool isDef () const { return flags & DEFFLAG; } + MachineOperand& setDef () { flags |= DEFFLAG; return *this; } + bool isHiBits32 () const { return flags & HIFLAG32; } + bool isLoBits32 () const { return flags & LOFLAG32; } + bool isHiBits64 () const { return flags & HIFLAG64; } + bool isLoBits64 () const { return flags & LOFLAG64; } // used to check if a machine register has been allocated to this operand bool hasAllocatedReg() const { From criswell at cs.uiuc.edu Wed Feb 4 17:08:03 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Wed Feb 4 17:08:03 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Applications/d/Makefile Message-ID: <200402042307.RAA19212@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Applications/d: Makefile updated: 1.1 -> 1.2 --- Log message: Added missing source file. --- Diffs of the changes: (+1 -1) Index: llvm/test/Programs/MultiSource/Applications/d/Makefile diff -u llvm/test/Programs/MultiSource/Applications/d/Makefile:1.1 llvm/test/Programs/MultiSource/Applications/d/Makefile:1.2 --- llvm/test/Programs/MultiSource/Applications/d/Makefile:1.1 Thu Jan 1 10:50:35 2004 +++ llvm/test/Programs/MultiSource/Applications/d/Makefile Wed Feb 4 17:07:03 2004 @@ -1,6 +1,6 @@ LEVEL = ../../../../.. PROG = make_dparser -Sources=make_dparser.c write_ctables.c gram.c lex.c lr.c arg.c parse.c scan.c symtab.c util.c +Sources=make_dparser.c write_ctables.c gram.c lex.c lr.c arg.c parse.c scan.c symtab.c util.c grammar.g.c CPPFLAGS = -DD_BUILD_VERSION=5725 RUN_OPTIONS="-v $(BUILD_SRC_DIR)/grammar.g" include ../../Makefile.multisrc From lattner at cs.uiuc.edu Wed Feb 4 18:37:08 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 4 18:37:08 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoadValueNumbering.cpp Message-ID: <200402050036.SAA31015@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoadValueNumbering.cpp updated: 1.10 -> 1.11 --- Log message: Implement optimizations for handling large basic blocks. --- Diffs of the changes: (+77 -29) Index: llvm/lib/Analysis/LoadValueNumbering.cpp diff -u llvm/lib/Analysis/LoadValueNumbering.cpp:1.10 llvm/lib/Analysis/LoadValueNumbering.cpp:1.11 --- llvm/lib/Analysis/LoadValueNumbering.cpp:1.10 Tue Nov 11 16:41:31 2003 +++ llvm/lib/Analysis/LoadValueNumbering.cpp Wed Feb 4 18:36:43 2004 @@ -212,47 +212,95 @@ bool LoadVN::haveEqualValueNumber(LoadInst *L1, LoadInst *L2, AliasAnalysis &AA, DominatorSet &DomSetInfo) const { - // Figure out which load dominates the other one. If neither dominates the - // other we cannot eliminate them. - // - // FIXME: This could be enhanced to some cases with a shared dominator! - // - if (DomSetInfo.dominates(L2, L1)) - std::swap(L1, L2); // Make L1 dominate L2 - else if (!DomSetInfo.dominates(L1, L2)) - return false; // Neither instruction dominates the other one... - - BasicBlock *BB1 = L1->getParent(), *BB2 = L2->getParent(); - Value *LoadAddress = L1->getOperand(0); - + assert(L1 != L2 && "haveEqualValueNumber assumes differing loads!"); assert(L1->getType() == L2->getType() && "How could the same source pointer return different types?"); + Value *LoadAddress = L1->getOperand(0); // Find out how many bytes of memory are loaded by the load instruction... unsigned LoadSize = getAnalysis().getTypeSize(L1->getType()); - // L1 now dominates L2. Check to see if the intervening instructions between - // the two loads include a store or call... - // - if (BB1 == BB2) { // In same basic block? - // In this degenerate case, no checking of global basic blocks has to occur - // just check the instructions BETWEEN L1 & L2... + // If the two loads are in the same basic block, just do a local analysis. + if (L1->getParent() == L2->getParent()) { + // It can be _very_ expensive to determine which instruction occurs first in + // the basic block if the block is large (see PR209). For this reason, + // instead of figuring out which block is first, then scanning all of the + // instructions, we scan the instructions both ways from L1 until we find + // L2. Along the way if we find a potentially modifying instruction, we + // kill the search. This helps in cases where we have large blocks the have + // potentially modifying instructions in them which stop the search. + + BasicBlock *BB = L1->getParent(); + BasicBlock::iterator UpIt = L1, DownIt = L1; ++DownIt; + bool NoModifiesUp = true, NoModifiesDown = true; + + // Scan up and down looking for L2, a modifying instruction, or the end of a + // basic block. + while (UpIt != BB->begin() && DownIt != BB->end()) { + // Scan up... + --UpIt; + if (&*UpIt == L2) + return NoModifiesUp; // No instructions invalidate the loads! + if (NoModifiesUp) + NoModifiesUp &= + !(AA.getModRefInfo(UpIt, LoadAddress, LoadSize) & AliasAnalysis::Mod); + + if (&*DownIt == L2) + return NoModifiesDown; + if (NoModifiesDown) + NoModifiesDown &= + !(AA.getModRefInfo(DownIt, LoadAddress, LoadSize) + & AliasAnalysis::Mod); + ++DownIt; + } + + // If we got here, we ran into one end of the basic block or the other. + if (UpIt != BB->begin()) { + // If we know that the upward scan found a modifier, return false. + if (!NoModifiesUp) return false; + + // Otherwise, continue the scan looking for a modifier or L2. + for (--UpIt; &*UpIt != L2; --UpIt) + if (AA.getModRefInfo(UpIt, LoadAddress, LoadSize) & AliasAnalysis::Mod) + return false; + return true; + } else { + // If we know that the downward scan found a modifier, return false. + assert(DownIt != B->end() && "Didn't find instructions??"); + if (!NoModifiesDown) return false; + + // Otherwise, continue the scan looking for a modifier or L2. + for (; &*DownIt != L2; ++DownIt) { + if (AA.getModRefInfo(DownIt, LoadAddress, LoadSize) &AliasAnalysis::Mod) + return false; + } + return true; + } + } else { + // Figure out which load dominates the other one. If neither dominates the + // other we cannot eliminate them. // - if (AA.canInstructionRangeModify(*L1, *L2, LoadAddress, LoadSize)) - return false; // Cannot eliminate load + // FIXME: This could be enhanced greatly! + // + if (DomSetInfo.dominates(L2, L1)) + std::swap(L1, L2); // Make L1 dominate L2 + else if (!DomSetInfo.dominates(L1, L2)) + return false; // Neither instruction dominates the other one... + + BasicBlock *BB1 = L1->getParent(), *BB2 = L2->getParent(); + + // L1 now dominates L2. Check to see if the intervening instructions + // between the two loads might modify the loaded location. - // No instructions invalidate the loads, they produce the same value! - return true; - } else { - // Make sure that there are no store instructions between L1 and the end of - // its basic block... + // Make sure that there are no modifying instructions between L1 and the end + // of its basic block. // if (AA.canInstructionRangeModify(*L1, *BB1->getTerminator(), LoadAddress, LoadSize)) return false; // Cannot eliminate load - // Make sure that there are no store instructions between the start of BB2 - // and the second load instruction... + // Make sure that there are no modifying instructions between the start of + // BB2 and the second load instruction. // if (AA.canInstructionRangeModify(BB2->front(), *L2, LoadAddress, LoadSize)) return false; // Cannot eliminate load @@ -266,7 +314,7 @@ if (CheckForInvalidatingInst(*PI, BB1, LoadAddress, LoadSize, AA, VisitedSet)) return false; - + // If we passed all of these checks then we are sure that the two loads // produce the same value. return true; From lattner at cs.uiuc.edu Wed Feb 4 18:49:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 4 18:49:01 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402050048.SAA31453@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.108 -> 1.109 --- Log message: qoi bug fixed --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.108 llvm/docs/ReleaseNotes.html:1.109 --- llvm/docs/ReleaseNotes.html:1.108 Tue Feb 3 16:59:56 2004 +++ llvm/docs/ReleaseNotes.html Wed Feb 4 18:48:41 2004 @@ -123,6 +123,7 @@
  • [vmcore] OpaqueType objects memory leak
  • [llvmgcc] C front-end does not compile "extern inline" into linkonce
  • Bytecode format inconsistent
  • +
  • [loadvn/inline/gcse] Slow optimizations with extremely large basic blocks
  • @@ -617,7 +618,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/03 22:59:56 $ + Last modified: $Date: 2004/02/05 00:48:41 $ From tbrethou at cs.uiuc.edu Wed Feb 4 22:46:03 2004 From: tbrethou at cs.uiuc.edu (Tanya Brethour) Date: Wed Feb 4 22:46:03 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoadValueNumbering.cpp Message-ID: <200402050445.WAA05735@seraph.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoadValueNumbering.cpp updated: 1.11 -> 1.12 --- Log message: Fixed Chris' typo. --- Diffs of the changes: (+1 -1) Index: llvm/lib/Analysis/LoadValueNumbering.cpp diff -u llvm/lib/Analysis/LoadValueNumbering.cpp:1.11 llvm/lib/Analysis/LoadValueNumbering.cpp:1.12 --- llvm/lib/Analysis/LoadValueNumbering.cpp:1.11 Wed Feb 4 18:36:43 2004 +++ llvm/lib/Analysis/LoadValueNumbering.cpp Wed Feb 4 22:45:21 2004 @@ -266,7 +266,7 @@ return true; } else { // If we know that the downward scan found a modifier, return false. - assert(DownIt != B->end() && "Didn't find instructions??"); + assert(DownIt != BB->end() && "Didn't find instructions??"); if (!NoModifiesDown) return false; // Otherwise, continue the scan looking for a modifier or L2. From tbrethou at cs.uiuc.edu Wed Feb 4 23:05:02 2004 From: tbrethou at cs.uiuc.edu (Tanya Brethour) Date: Wed Feb 4 23:05:02 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Message-ID: <200402050504.XAA11948@seraph.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: TwoAddressInstructionPass.cpp updated: 1.12 -> 1.13 --- Log message: Added missing include. --- Diffs of the changes: (+1 -0) Index: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp diff -u llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.12 llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.13 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.12 Wed Feb 4 16:17:40 2004 +++ llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Wed Feb 4 23:04:39 2004 @@ -38,6 +38,7 @@ #include "llvm/Target/TargetMachine.h" #include "Support/Debug.h" #include "Support/Statistic.h" +#include using namespace llvm; namespace { From lattner at cs.uiuc.edu Wed Feb 4 23:52:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 4 23:52:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoadValueNumbering.cpp Message-ID: <200402050551.XAA03294@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoadValueNumbering.cpp updated: 1.12 -> 1.13 --- Log message: finegrainify namespacification --- Diffs of the changes: (+2 -5) Index: llvm/lib/Analysis/LoadValueNumbering.cpp diff -u llvm/lib/Analysis/LoadValueNumbering.cpp:1.12 llvm/lib/Analysis/LoadValueNumbering.cpp:1.13 --- llvm/lib/Analysis/LoadValueNumbering.cpp:1.12 Wed Feb 4 22:45:21 2004 +++ llvm/lib/Analysis/LoadValueNumbering.cpp Wed Feb 4 23:51:40 2004 @@ -30,8 +30,7 @@ #include "llvm/Support/CFG.h" #include #include - -namespace llvm { +using namespace llvm; namespace { // FIXME: This should not be a FunctionPass. @@ -72,7 +71,7 @@ RegisterAnalysisGroup Y; } -Pass *createLoadValueNumberingPass() { return new LoadVN(); } +Pass *llvm::createLoadValueNumberingPass() { return new LoadVN(); } /// getAnalysisUsage - Does not modify anything. It uses Value Numbering and @@ -388,5 +387,3 @@ return true; } } - -} // End llvm namespace From lattner at cs.uiuc.edu Wed Feb 4 23:57:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 4 23:57:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoadValueNumbering.cpp Message-ID: <200402050556.XAA03803@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoadValueNumbering.cpp updated: 1.13 -> 1.14 --- Log message: This is a big diff with no functionality change. We just reorder some code, which causes big reindentation. While I'm at it, I fix the fixme by removing some dead code. --- Diffs of the changes: (+60 -73) Index: llvm/lib/Analysis/LoadValueNumbering.cpp diff -u llvm/lib/Analysis/LoadValueNumbering.cpp:1.13 llvm/lib/Analysis/LoadValueNumbering.cpp:1.14 --- llvm/lib/Analysis/LoadValueNumbering.cpp:1.13 Wed Feb 4 23:51:40 2004 +++ llvm/lib/Analysis/LoadValueNumbering.cpp Wed Feb 4 23:56:23 2004 @@ -28,7 +28,6 @@ #include "llvm/iMemory.h" #include "llvm/BasicBlock.h" #include "llvm/Support/CFG.h" -#include #include using namespace llvm; @@ -95,83 +94,71 @@ if (isa(V->getType())) getAnalysis().getMustAliases(V, RetVals); - if (LoadInst *LI = dyn_cast(V)) { - // Volatile loads cannot be replaced with the value of other loads. - if (LI->isVolatile()) - return getAnalysis().getEqualNumberNodes(V, RetVals); - - // If we have a load instruction, find all of the load and store - // instructions that use the same source operand. We implement this - // recursively, because there could be a load of a load of a load that are - // all identical. We are guaranteed that this cannot be an infinite - // recursion because load instructions would have to pass through a PHI node - // in order for there to be a cycle. The PHI node would be handled by the - // else case here, breaking the infinite recursion. - // - std::vector PointerSources; - getEqualNumberNodes(LI->getOperand(0), PointerSources); - PointerSources.push_back(LI->getOperand(0)); - - Function *F = LI->getParent()->getParent(); - - // Now that we know the set of equivalent source pointers for the load - // instruction, look to see if there are any load or store candidates that - // are identical. - // - std::vector CandidateLoads; - std::vector CandidateStores; - - while (!PointerSources.empty()) { - Value *Source = PointerSources.back(); - PointerSources.pop_back(); // Get a source pointer... - - for (Value::use_iterator UI = Source->use_begin(), UE = Source->use_end(); - UI != UE; ++UI) - if (LoadInst *Cand = dyn_cast(*UI)) {// Is a load of source? - if (Cand->getParent()->getParent() == F && // In the same function? - Cand != LI && !Cand->isVolatile()) // Not LI itself? - CandidateLoads.push_back(Cand); // Got one... - } else if (StoreInst *Cand = dyn_cast(*UI)) { - if (Cand->getParent()->getParent() == F && !Cand->isVolatile() && - Cand->getOperand(1) == Source) // It's a store THROUGH the ptr... - CandidateStores.push_back(Cand); - } - } - - // Remove duplicates from the CandidateLoads list because alias analysis - // processing may be somewhat expensive and we don't want to do more work - // than necessary. - // - unsigned OldSize = CandidateLoads.size(); - std::sort(CandidateLoads.begin(), CandidateLoads.end()); - CandidateLoads.erase(std::unique(CandidateLoads.begin(), - CandidateLoads.end()), - CandidateLoads.end()); - // FIXME: REMOVE THIS SORTING AND UNIQUING IF IT CAN'T HAPPEN - assert(CandidateLoads.size() == OldSize && "Shrunk the candloads list?"); - - // Get Alias Analysis... - AliasAnalysis &AA = getAnalysis(); - DominatorSet &DomSetInfo = getAnalysis(); - - // Loop over all of the candidate loads. If they are not invalidated by - // stores or calls between execution of them and LI, then add them to - // RetVals. - for (unsigned i = 0, e = CandidateLoads.size(); i != e; ++i) - if (haveEqualValueNumber(LI, CandidateLoads[i], AA, DomSetInfo)) - RetVals.push_back(CandidateLoads[i]); - for (unsigned i = 0, e = CandidateStores.size(); i != e; ++i) - if (haveEqualValueNumber(LI, CandidateStores[i], AA, DomSetInfo)) - RetVals.push_back(CandidateStores[i]->getOperand(0)); - - } else { + if (!isa(V)) { + // Not a load instruction? Just chain to the base value numbering + // implementation to satisfy the request... assert(&getAnalysis() != (ValueNumbering*)this && "getAnalysis() returned this!"); - // Not a load instruction? Just chain to the base value numbering - // implementation to satisfy the request... return getAnalysis().getEqualNumberNodes(V, RetVals); } + + // Volatile loads cannot be replaced with the value of other loads. + LoadInst *LI = cast(V); + if (LI->isVolatile()) + return getAnalysis().getEqualNumberNodes(V, RetVals); + + // If we have a load instruction, find all of the load and store instructions + // that use the same source operand. We implement this recursively, because + // there could be a load of a load of a load that are all identical. We are + // guaranteed that this cannot be an infinite recursion because load + // instructions would have to pass through a PHI node in order for there to be + // a cycle. The PHI node would be handled by the else case here, breaking the + // infinite recursion. + // + std::vector PointerSources; + getEqualNumberNodes(LI->getOperand(0), PointerSources); + PointerSources.push_back(LI->getOperand(0)); + + Function *F = LI->getParent()->getParent(); + + // Now that we know the set of equivalent source pointers for the load + // instruction, look to see if there are any load or store candidates that are + // identical. + // + std::vector CandidateLoads; + std::vector CandidateStores; + + while (!PointerSources.empty()) { + Value *Source = PointerSources.back(); + PointerSources.pop_back(); // Get a source pointer... + + for (Value::use_iterator UI = Source->use_begin(), UE = Source->use_end(); + UI != UE; ++UI) + if (LoadInst *Cand = dyn_cast(*UI)) {// Is a load of source? + if (Cand->getParent()->getParent() == F && // In the same function? + Cand != LI && !Cand->isVolatile()) // Not LI itself? + CandidateLoads.push_back(Cand); // Got one... + } else if (StoreInst *Cand = dyn_cast(*UI)) { + if (Cand->getParent()->getParent() == F && !Cand->isVolatile() && + Cand->getOperand(1) == Source) // It's a store THROUGH the ptr... + CandidateStores.push_back(Cand); + } + } + + // Get Alias Analysis... + AliasAnalysis &AA = getAnalysis(); + DominatorSet &DomSetInfo = getAnalysis(); + + // Loop over all of the candidate loads. If they are not invalidated by + // stores or calls between execution of them and LI, then add them to RetVals. + for (unsigned i = 0, e = CandidateLoads.size(); i != e; ++i) + if (haveEqualValueNumber(LI, CandidateLoads[i], AA, DomSetInfo)) + RetVals.push_back(CandidateLoads[i]); + for (unsigned i = 0, e = CandidateStores.size(); i != e; ++i) + if (haveEqualValueNumber(LI, CandidateStores[i], AA, DomSetInfo)) + RetVals.push_back(CandidateStores[i]->getOperand(0)); + } // CheckForInvalidatingInst - Return true if BB or any of the predecessors of BB From criswell at cs.uiuc.edu Thu Feb 5 10:06:02 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:06:02 2004 Subject: [llvm-commits] CVS: gcc-3.4/libjava/java/net/PlainDatagramSocketImpl.java PlainSocketImpl.java SocketInputStream.java SocketOutputStream.java natPlainDatagramSocketImplNoNet.cc natPlainDatagramSocketImplPosix.cc natPlainDatagramSocketImplWin32.cc natPlainSocketImplNoNet.cc natPlainSocketImplPosix.cc natPlainSocketImplWin32.cc Message-ID: <200402051605.KAA26928@choi.cs.uiuc.edu> Changes in directory gcc-3.4/libjava/java/net: PlainDatagramSocketImpl.java (r1.1.1.1) removed PlainSocketImpl.java (r1.1.1.1) removed SocketInputStream.java (r1.1.1.1) removed SocketOutputStream.java (r1.1.1.1) removed natPlainDatagramSocketImplNoNet.cc (r1.1.1.1) removed natPlainDatagramSocketImplPosix.cc (r1.1.1.1) removed natPlainDatagramSocketImplWin32.cc (r1.1.1.1) removed natPlainSocketImplNoNet.cc (r1.1.1.1) removed natPlainSocketImplPosix.cc (r1.1.1.1) removed natPlainSocketImplWin32.cc (r1.1.1.1) removed --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Thu Feb 5 10:06:12 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:06:12 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/testsuite/g++.dg/ext/lvcast.C Message-ID: <200402051605.KAA26919@choi.cs.uiuc.edu> Changes in directory gcc-3.4/gcc/testsuite/g++.dg/ext: lvcast.C (r1.1.1.1) removed --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Thu Feb 5 10:06:16 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:06:16 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/config/pa/t-bsd Message-ID: <200402051605.KAA26902@choi.cs.uiuc.edu> Changes in directory gcc-3.4/gcc/config/pa: t-bsd (r1.1.1.1) removed --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Thu Feb 5 10:06:21 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:06:21 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/config/i370/t-oe Message-ID: <200402051605.KAA26895@choi.cs.uiuc.edu> Changes in directory gcc-3.4/gcc/config/i370: t-oe (r1.1.1.1) removed --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Thu Feb 5 10:07:04 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:07:04 2004 Subject: [llvm-commits] CVS: gcc-3.4/libstdc++-v3/testsuite/17_intro/header_ciso646.cc Message-ID: <200402051606.KAA26949@choi.cs.uiuc.edu> Changes in directory gcc-3.4/libstdc++-v3/testsuite/17_intro: header_ciso646.cc (r1.1.1.1) removed --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Thu Feb 5 10:07:11 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:07:11 2004 Subject: [llvm-commits] CVS: gcc-3.4/libstdc++-v3/testsuite/27_io/objects/char/12048.cc Message-ID: <200402051606.KAA26955@choi.cs.uiuc.edu> Changes in directory gcc-3.4/libstdc++-v3/testsuite/27_io/objects/char: 12048.cc (r1.1.1.1) removed --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Thu Feb 5 10:07:17 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:07:17 2004 Subject: [llvm-commits] CVS: gcc-3.4/libstdc++-v3/src/Makefile.in Message-ID: <200402051606.KAA26999@choi.cs.uiuc.edu> Changes in directory gcc-3.4/libstdc++-v3/src: Makefile.in updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+24 -24) Index: gcc-3.4/libstdc++-v3/src/Makefile.in diff -u gcc-3.4/libstdc++-v3/src/Makefile.in:1.2 gcc-3.4/libstdc++-v3/src/Makefile.in:1.3 --- gcc-3.4/libstdc++-v3/src/Makefile.in:1.2 Fri Jan 9 10:54:35 2004 +++ gcc-3.4/libstdc++-v3/src/Makefile.in Thu Feb 5 10:05:49 2004 @@ -289,13 +289,13 @@ libstdc___la_DEPENDENCIES = libstdc++-symbol.ver $(libstdc___la_LIBADD) libstdc___la_LDFLAGS = \ - -version-info @libtool_VERSION@ ${version_arg} \ - -lm @LIBUNWIND_FLAG@ + -version-info $(libtool_VERSION) ${version_arg} \ + -lm $(LIBUNWIND_FLAG) # Use special rules for the deprecated source files so that they find # deprecated include files. -GLIBCXX_INCLUDE_DIR = @glibcxx_builddir@/include +GLIBCXX_INCLUDE_DIR = $(glibcxx_builddir)/include # AM_CXXFLAGS needs to be in each subdirectory so that it can be # modified in a per-library or per-sub-library way. Need to manually @@ -338,7 +338,7 @@ # directory to configure libstdc++-v3 to use gcc as the C++ # compilation driver. CXXLINK = $(LIBTOOL) --tag CXX --mode=link $(CXX) \ - @OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@ + $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LDFLAGS) -o $@ debugdir = debug @@ -624,32 +624,32 @@ @GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE@ fi @GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE at libstdc++-symbol.ver: -codecvt_members.cc: ${glibcxx_srcdir}/@CCODECVT_CC@ - @LN_S@ ${glibcxx_srcdir}/@CCODECVT_CC@ . || true +codecvt_members.cc: ${glibcxx_srcdir}/$(CCODECVT_CC) + $(LN_S) ${glibcxx_srcdir}/$(CCODECVT_CC) . || true -collate_members.cc: ${glibcxx_srcdir}/@CCOLLATE_CC@ - @LN_S@ ${glibcxx_srcdir}/@CCOLLATE_CC@ . || true +collate_members.cc: ${glibcxx_srcdir}/$(CCOLLATE_CC) + $(LN_S) ${glibcxx_srcdir}/$(CCOLLATE_CC) . || true -ctype_members.cc: ${glibcxx_srcdir}/@CCTYPE_CC@ - @LN_S@ ${glibcxx_srcdir}/@CCTYPE_CC@ . || true +ctype_members.cc: ${glibcxx_srcdir}/$(CCTYPE_CC) + $(LN_S) ${glibcxx_srcdir}/$(CCTYPE_CC) . || true -messages_members.cc: ${glibcxx_srcdir}/@CMESSAGES_CC@ - @LN_S@ ${glibcxx_srcdir}/@CMESSAGES_CC@ . || true +messages_members.cc: ${glibcxx_srcdir}/$(CMESSAGES_CC) + $(LN_S) ${glibcxx_srcdir}/$(CMESSAGES_CC) . || true -monetary_members.cc: ${glibcxx_srcdir}/@CMONEY_CC@ - @LN_S@ ${glibcxx_srcdir}/@CMONEY_CC@ . || true +monetary_members.cc: ${glibcxx_srcdir}/$(CMONEY_CC) + $(LN_S) ${glibcxx_srcdir}/$(CMONEY_CC) . || true -numeric_members.cc: ${glibcxx_srcdir}/@CNUMERIC_CC@ - @LN_S@ ${glibcxx_srcdir}/@CNUMERIC_CC@ . || true +numeric_members.cc: ${glibcxx_srcdir}/$(CNUMERIC_CC) + $(LN_S) ${glibcxx_srcdir}/$(CNUMERIC_CC) . || true -time_members.cc: ${glibcxx_srcdir}/@CTIME_CC@ - @LN_S@ ${glibcxx_srcdir}/@CTIME_CC@ . || true +time_members.cc: ${glibcxx_srcdir}/$(CTIME_CC) + $(LN_S) ${glibcxx_srcdir}/$(CTIME_CC) . || true -c++locale.cc: ${glibcxx_srcdir}/@CLOCALE_CC@ - @LN_S@ ${glibcxx_srcdir}/@CLOCALE_CC@ ./$@ || true +c++locale.cc: ${glibcxx_srcdir}/$(CLOCALE_CC) + $(LN_S) ${glibcxx_srcdir}/$(CLOCALE_CC) ./$@ || true -basic_file.cc: ${glibcxx_srcdir}/@BASIC_FILE_CC@ - @LN_S@ ${glibcxx_srcdir}/@BASIC_FILE_CC@ ./$@ || true +basic_file.cc: ${glibcxx_srcdir}/$(BASIC_FILE_CC) + $(LN_S) ${glibcxx_srcdir}/$(BASIC_FILE_CC) ./$@ || true strstream.lo: strstream.cc $(LTCXXCOMPILE) -I$(GLIBCXX_INCLUDE_DIR)/backward -Wno-deprecated -c $< strstream.o: strstream.cc @@ -691,12 +691,12 @@ echo `date` > stamp-debug; build_debug: stamp-debug - (cd ${debugdir} && $(MAKE) CXXFLAGS='@DEBUG_FLAGS@' all) + (cd ${debugdir} && $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' all) # Install debug library here. install_debug: (cd ${debugdir} && $(MAKE) \ - toolexeclibdir=@glibcxx_toolexeclibdir@/debug install) + toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install) # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: From criswell at cs.uiuc.edu Thu Feb 5 10:07:23 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:07:23 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/config/sparc/sparc.h Message-ID: <200402051606.KAA26992@choi.cs.uiuc.edu> Changes in directory gcc-3.4/gcc/config/sparc: sparc.h updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+39 -141) Index: gcc-3.4/gcc/config/sparc/sparc.h diff -u gcc-3.4/gcc/config/sparc/sparc.h:1.2 gcc-3.4/gcc/config/sparc/sparc.h:1.3 --- gcc-3.4/gcc/config/sparc/sparc.h:1.2 Thu Jan 8 17:03:38 2004 +++ gcc-3.4/gcc/config/sparc/sparc.h Thu Feb 5 10:05:46 2004 @@ -2109,27 +2109,18 @@ When PIC, we do not accept an address that would require a scratch reg to load into a register. */ -#define CONSTANT_ADDRESS_P(X) \ - (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \ - || GET_CODE (X) == CONST_INT || GET_CODE (X) == HIGH \ - || (GET_CODE (X) == CONST \ - && ! (flag_pic && pic_address_needs_scratch (X)))) +#define CONSTANT_ADDRESS_P(X) constant_address_p (X) /* Define this, so that when PIC, reload won't try to reload invalid addresses which require two reload registers. */ -#define LEGITIMATE_PIC_OPERAND_P(X) (! pic_address_needs_scratch (X)) +#define LEGITIMATE_PIC_OPERAND_P(X) legitimate_pic_operand_p (X) /* Nonzero if the constant value X is a legitimate general operand. Anything can be made to work except floating point constants. If TARGET_VIS, 0.0 can be made to work as well. */ -#define LEGITIMATE_CONSTANT_P(X) \ - (GET_CODE (X) != CONST_DOUBLE || GET_MODE (X) == VOIDmode || \ - (TARGET_VIS && \ - (GET_MODE (X) == SFmode || GET_MODE (X) == DFmode || \ - GET_MODE (X) == TFmode) && \ - fp_zero_operand (X, GET_MODE (X)))) +#define LEGITIMATE_CONSTANT_P(X) legitimate_constant_p (X) /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx and check its validity for a certain class. @@ -2236,110 +2227,19 @@ #define RTX_OK_FOR_OLO10_P(X) \ (GET_CODE (X) == CONST_INT && INTVAL (X) >= -0x1000 && INTVAL (X) < 0xc00 - 8) +#ifdef REG_OK_STRICT #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \ -{ if (RTX_OK_FOR_BASE_P (X)) \ +{ \ + if (legitimate_address_p (MODE, X, 1)) \ goto ADDR; \ - else if (GET_CODE (X) == PLUS) \ - { \ - register rtx op0 = XEXP (X, 0); \ - register rtx op1 = XEXP (X, 1); \ - if (flag_pic && op0 == pic_offset_table_rtx) \ - { \ - if (RTX_OK_FOR_BASE_P (op1)) \ - goto ADDR; \ - else if (flag_pic == 1 \ - && GET_CODE (op1) != REG \ - && GET_CODE (op1) != LO_SUM \ - && GET_CODE (op1) != MEM \ - && (! SYMBOLIC_CONST (op1) \ - || MODE == Pmode) \ - && (GET_CODE (op1) != CONST_INT \ - || SMALL_INT (op1))) \ - goto ADDR; \ - } \ - else if (RTX_OK_FOR_BASE_P (op0)) \ - { \ - if ((RTX_OK_FOR_INDEX_P (op1) \ - /* We prohibit REG + REG for TFmode when \ - there are no instructions which accept \ - REG+REG instructions. We do this \ - because REG+REG is not an offsetable \ - address. If we get the situation \ - in reload where source and destination \ - of a movtf pattern are both MEMs with \ - REG+REG address, then only one of them \ - gets converted to an offsetable \ - address. */ \ - && (MODE != TFmode \ - || (TARGET_FPU && TARGET_ARCH64 \ - && TARGET_V9 \ - && TARGET_HARD_QUAD)) \ - /* We prohibit REG + REG on ARCH32 if \ - not optimizing for DFmode/DImode \ - because then mem_min_alignment is \ - likely to be zero after reload and the \ - forced split would lack a matching \ - splitter pattern. */ \ - && (TARGET_ARCH64 || optimize \ - || (MODE != DFmode \ - && MODE != DImode))) \ - || RTX_OK_FOR_OFFSET_P (op1)) \ - goto ADDR; \ - } \ - else if (RTX_OK_FOR_BASE_P (op1)) \ - { \ - if ((RTX_OK_FOR_INDEX_P (op0) \ - /* See the previous comment. */ \ - && (MODE != TFmode \ - || (TARGET_FPU && TARGET_ARCH64 \ - && TARGET_V9 \ - && TARGET_HARD_QUAD)) \ - && (TARGET_ARCH64 || optimize \ - || (MODE != DFmode \ - && MODE != DImode))) \ - || RTX_OK_FOR_OFFSET_P (op0)) \ - goto ADDR; \ - } \ - else if (USE_AS_OFFSETABLE_LO10 \ - && GET_CODE (op0) == LO_SUM \ - && TARGET_ARCH64 \ - && ! TARGET_CM_MEDMID \ - && RTX_OK_FOR_OLO10_P (op1)) \ - { \ - register rtx op00 = XEXP (op0, 0); \ - register rtx op01 = XEXP (op0, 1); \ - if (RTX_OK_FOR_BASE_P (op00) \ - && CONSTANT_P (op01)) \ - goto ADDR; \ - } \ - else if (USE_AS_OFFSETABLE_LO10 \ - && GET_CODE (op1) == LO_SUM \ - && TARGET_ARCH64 \ - && ! TARGET_CM_MEDMID \ - && RTX_OK_FOR_OLO10_P (op0)) \ - { \ - register rtx op10 = XEXP (op1, 0); \ - register rtx op11 = XEXP (op1, 1); \ - if (RTX_OK_FOR_BASE_P (op10) \ - && CONSTANT_P (op11)) \ - goto ADDR; \ - } \ - } \ - else if (GET_CODE (X) == LO_SUM) \ - { \ - register rtx op0 = XEXP (X, 0); \ - register rtx op1 = XEXP (X, 1); \ - if (RTX_OK_FOR_BASE_P (op0) \ - && CONSTANT_P (op1) \ - /* We can't allow TFmode, because an offset \ - greater than or equal to the alignment (8) \ - may cause the LO_SUM to overflow if !v9. */\ - && (MODE != TFmode || TARGET_V9)) \ - goto ADDR; \ - } \ - else if (GET_CODE (X) == CONST_INT && SMALL_INT (X)) \ +} +#else +#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \ +{ \ + if (legitimate_address_p (MODE, X, 0)) \ goto ADDR; \ } +#endif /* Go to LABEL if ADDR (a legitimate address expression) has an effect that depends on the machine mode it is used for. @@ -2384,33 +2284,11 @@ /* On SPARC, change REG+N into REG+REG, and REG+(X*Y) into REG+REG. */ #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \ -{ rtx sparc_x = (X); \ - if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == MULT) \ - (X) = gen_rtx_PLUS (Pmode, XEXP (X, 1), \ - force_operand (XEXP (X, 0), NULL_RTX)); \ - if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == MULT) \ - (X) = gen_rtx_PLUS (Pmode, XEXP (X, 0), \ - force_operand (XEXP (X, 1), NULL_RTX)); \ - if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == PLUS) \ - (X) = gen_rtx_PLUS (Pmode, force_operand (XEXP (X, 0), NULL_RTX),\ - XEXP (X, 1)); \ - if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == PLUS) \ - (X) = gen_rtx_PLUS (Pmode, XEXP (X, 0), \ - force_operand (XEXP (X, 1), NULL_RTX)); \ - if (sparc_x != (X) && memory_address_p (MODE, X)) \ - goto WIN; \ - if (flag_pic) (X) = legitimize_pic_address (X, MODE, 0); \ - else if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 1))) \ - (X) = gen_rtx_PLUS (Pmode, XEXP (X, 0), \ - copy_to_mode_reg (Pmode, XEXP (X, 1))); \ - else if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 0))) \ - (X) = gen_rtx_PLUS (Pmode, XEXP (X, 1), \ - copy_to_mode_reg (Pmode, XEXP (X, 0))); \ - else if (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == CONST \ - || GET_CODE (X) == LABEL_REF) \ - (X) = copy_to_suggested_reg (X, NULL_RTX, Pmode); \ - if (memory_address_p (MODE, X)) \ - goto WIN; } +{ \ + (X) = legitimize_address (X, OLDX, MODE); \ + if (memory_address_p (MODE, X)) \ + goto WIN; \ +} /* Try a machine-dependent way of reloading an illegitimate address operand. If we find one, push the reload and jump to WIN. This @@ -2855,8 +2733,16 @@ #define ASM_OUTPUT_IDENT(FILE, NAME) \ fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME); +/* Emit a dtp-relative reference to a TLS variable. */ + +#ifdef HAVE_AS_TLS +#define ASM_OUTPUT_DWARF_DTPREL(FILE, SIZE, X) \ + sparc_output_dwarf_dtprel (FILE, SIZE, X) +#endif + #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \ - ((CHAR) == '#' || (CHAR) == '*' || (CHAR) == '^' || (CHAR) == '(' || (CHAR) == '_') + ((CHAR) == '#' || (CHAR) == '*' || (CHAR) == '^' \ + || (CHAR) == '(' || (CHAR) == '_' || (CHAR) == '&') /* Print operand X (an rtx) in assembler syntax to file FILE. CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified. @@ -2943,6 +2829,14 @@ } \ } +#ifdef HAVE_AS_TLS +#define TARGET_TLS 1 +#else +#define TARGET_TLS 0 +#endif +#define TARGET_SUN_TLS TARGET_TLS +#define TARGET_GNU_TLS 0 + /* Define the codes that are matched by predicates in sparc.c. */ #define PREDICATE_CODES \ @@ -2990,7 +2884,11 @@ {"clobbered_register", {REG}}, \ {"input_operand", {SUBREG, REG, CONST_INT, MEM, CONST}}, \ {"const64_operand", {CONST_INT, CONST_DOUBLE}}, \ -{"const64_high_operand", {CONST_INT, CONST_DOUBLE}}, +{"const64_high_operand", {CONST_INT, CONST_DOUBLE}}, \ +{"tgd_symbolic_operand", {SYMBOL_REF}}, \ +{"tld_symbolic_operand", {SYMBOL_REF}}, \ +{"tie_symbolic_operand", {SYMBOL_REF}}, \ +{"tle_symbolic_operand", {SYMBOL_REF}}, /* The number of Pmode words for the setjmp buffer. */ #define JMP_BUF_SIZE 12 From criswell at cs.uiuc.edu Thu Feb 5 10:07:29 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:07:29 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/fixinc/fixincl.x inclhack.def Message-ID: <200402051606.KAA27016@choi.cs.uiuc.edu> Changes in directory gcc-3.4/gcc/fixinc: fixincl.x updated: 1.2 -> 1.3 inclhack.def updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+2 -55) Index: gcc-3.4/gcc/fixinc/fixincl.x diff -u gcc-3.4/gcc/fixinc/fixincl.x:1.2 gcc-3.4/gcc/fixinc/fixincl.x:1.3 --- gcc-3.4/gcc/fixinc/fixincl.x:1.2 Fri Jan 9 10:54:32 2004 +++ gcc-3.4/gcc/fixinc/fixincl.x Thu Feb 5 10:05:47 2004 @@ -2,11 +2,11 @@ * * DO NOT EDIT THIS FILE (fixincl.x) * - * It has been AutoGen-ed Wednesday August 27, 2003 at 05:09:27 PM CDT + * It has been AutoGen-ed Friday August 29, 2003 at 01:36:38 PM EDT * From the definitions inclhack.def * and the template file fixincl */ -/* DO NOT CVS-MERGE THIS FILE, EITHER Wed Aug 27 17:09:27 CDT 2003 +/* DO NOT CVS-MERGE THIS FILE, EITHER Fri Aug 29 13:36:38 EDT 2003 * * You must regenerate it. Use the ./genfixes script. * @@ -338,7 +338,6 @@ mach = \"powerpcle-*-solaris2.[0-4]\";\n\ mach = \"sparc-*-solaris2.[0-4]\";\n\ mach = \"i[34567]86-sequent-ptx*\";\n\ - mach = \"i[34567]86-sequent-sysv3*\";\n\ files = sys/byteorder.h;\n\ replace = <<- _EndOfHeader_\n\ #ifndef _SYS_BYTEORDER_H\n\ @@ -4961,7 +4960,6 @@ tSCC* apzSvr4_KrnlMachs[] = { "*-*-sysv4*", "i?86-sequent-ptx*", - "i?86-sequent-sysv3*", (const char*)NULL }; /* Index: gcc-3.4/gcc/fixinc/inclhack.def diff -u gcc-3.4/gcc/fixinc/inclhack.def:1.2 gcc-3.4/gcc/fixinc/inclhack.def:1.3 --- gcc-3.4/gcc/fixinc/inclhack.def:1.2 Thu Jan 8 17:05:53 2004 +++ gcc-3.4/gcc/fixinc/inclhack.def Thu Feb 5 10:05:47 2004 @@ -252,7 +252,6 @@ mach = "powerpcle-*-solaris2.[0-4]"; mach = "sparc-*-solaris2.[0-4]"; mach = "i[34567]86-sequent-ptx*"; - mach = "i[34567]86-sequent-sysv3*"; files = sys/byteorder.h; replace = <<- _EndOfHeader_ #ifndef _SYS_BYTEORDER_H @@ -2034,55 +2033,6 @@ /* - * In netinet/in.h, the network byte swapping asm functions supported by the - * native cc compiler on PTX 1.x and 2.x are not supported by gcc. Instead, - * include , written out by fixincludes, which has - * these same routines written in an asm format supported by gcc. - */ -#ifdef PTX -fix = { - hackname = ptx_netswap; - files = netinet/in.h; - sed = "/#define NETSWAP/a\\\n" - "\\\n" - "#if defined (__GNUC__) || defined (__GNUG__)\\\n" - "#include \\\n" - "#else /* not __GNUC__ */\n"; - sed = "/#endif[ \t]*\\/\\* NETSWAP \\*\\//i\\\n" - "#endif /* not __GNUC__ */\n"; - /* Half-hearted test case: I have no idea what the file this is really - supposed to operate on looks like. */ - test_text = "#define NETSWAP\n" - "#endif /* NETSWAP */"; -}; -#endif - - -/* - * In pwd.h, PTX 1.x needs stdio.h included since FILE * was added in a - * prototype later on in the file. (It's not clear that this is - * still true, and even if it is, FILE * may be added after this fix runs by - * fixproto.) - */ -#ifdef PTX -fix = { - hackname = ptx_pwd_h; - files = pwd.h; - select = 'FILE \*'; - bypass = 'stdio.h'; - sed = "/#include \\\n" - "#endif /* __STDC__ */\\\n" - "\n"; - test_text = "#include \n" - "void foo (FILE *)"; -}; -#endif - - -/* * On DYNIX/ptx, sys/mc_param.h has an embedded asm for the cpuid instruction * on the P5. This is not used by anything else so we ifdef it out. * Current GCC doesn't seem to complain about the asm, though. @@ -2911,7 +2861,6 @@ * in any case. -- Nathanael */ mach = '*-*-sysv4*'; mach = 'i?86-sequent-ptx*'; - mach = 'i?86-sequent-sysv3*'; files = fs/rfs/rf_cache.h; files = sys/erec.h; files = sys/err.h; From criswell at cs.uiuc.edu Thu Feb 5 10:07:35 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:07:35 2004 Subject: [llvm-commits] CVS: gcc-3.4/libstdc++-v3/libsupc++/Makefile.in eh_term_handler.cc Message-ID: <200402051606.KAA27028@choi.cs.uiuc.edu> Changes in directory gcc-3.4/libstdc++-v3/libsupc++: Makefile.in updated: 1.2 -> 1.3 eh_term_handler.cc updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+12 -12) Index: gcc-3.4/libstdc++-v3/libsupc++/Makefile.in diff -u gcc-3.4/libstdc++-v3/libsupc++/Makefile.in:1.2 gcc-3.4/libstdc++-v3/libsupc++/Makefile.in:1.3 --- gcc-3.4/libstdc++-v3/libsupc++/Makefile.in:1.2 Fri Jan 9 10:54:35 2004 +++ gcc-3.4/libstdc++-v3/libsupc++/Makefile.in Thu Feb 5 10:05:49 2004 @@ -221,13 +221,13 @@ # Need this library to both be part of libstdc++.a, and installed # separately too. -# 1) separate libsupc++.la +# 1) separate libsupc++.la toolexeclib_LTLIBRARIES = libsupc++.la # 2) integrated libsupc++convenience.la that is to be a part of libstdc++.a noinst_LTLIBRARIES = libsupc++convenience.la headers = \ - exception new typeinfo cxxabi.h exception_defines.h + exception new typeinfo cxxabi.h exception_defines.h sources = \ @@ -259,8 +259,8 @@ vterminate.cc -libsupc___la_SOURCES = $(sources) -libsupc__convenience_la_SOURCES = $(sources) +libsupc___la_SOURCES = $(sources) +libsupc__convenience_la_SOURCES = $(sources) glibcxxinstalldir = $(gxx_include_dir) glibcxxinstall_HEADERS = $(headers) @@ -269,13 +269,13 @@ # modified in a per-library or per-sub-library way. Need to manually # set this option because CONFIG_CXXFLAGS has to be after # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden -# as the occasion call for it. +# as the occasion call for it. AM_CXXFLAGS = \ -fno-implicit-templates \ $(LIBSUPCXX_PICFLAGS) \ $(WARN_CXXFLAGS) \ $(OPTIMIZE_CXXFLAGS) \ - $(CONFIG_CXXFLAGS) + $(CONFIG_CXXFLAGS) AM_MAKEFLAGS = \ @@ -304,8 +304,8 @@ # We have to put --tag disable-shared after --tag CXX lest things # CXX undo the affect of disable-shared. LTCXXCOMPILE = $(LIBTOOL) --tag CXX --tag disable-shared \ - --mode=compile $(CXX) $(TOPLEVEL_INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS) + --mode=compile $(CXX) $(TOPLEVEL_INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS) # 3) We'd have a problem when building the shared libstdc++ object if @@ -315,8 +315,8 @@ # directory to configure libstdc++-v3 to use gcc as the C++ # compilation driver. CXXLINK = $(LIBTOOL) --tag CXX --tag disable-shared \ - --mode=link $(CXX) \ - @OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@ + --mode=link $(CXX) \ + $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LDFLAGS) -o $@ subdir = libsupc++ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 Index: gcc-3.4/libstdc++-v3/libsupc++/eh_term_handler.cc diff -u gcc-3.4/libstdc++-v3/libsupc++/eh_term_handler.cc:1.2 gcc-3.4/libstdc++-v3/libsupc++/eh_term_handler.cc:1.3 --- gcc-3.4/libstdc++-v3/libsupc++/eh_term_handler.cc:1.2 Fri Jan 9 10:54:35 2004 +++ gcc-3.4/libstdc++-v3/libsupc++/eh_term_handler.cc Thu Feb 5 10:05:49 2004 @@ -37,13 +37,13 @@ to "std::abort", and rebuilding the library. In a freestanding mode, we default to this latter approach. */ -#if ! _GLIBCXX_HOSTED || defined(__llvm__) +#if ! _GLIBCXX_HOSTED # include #endif /* The current installed user handler. */ std::terminate_handler __cxxabiv1::__terminate_handler = -#if _GLIBCXX_HOSTED && !defined(__llvm__) +#if _GLIBCXX_HOSTED __gnu_cxx::__verbose_terminate_handler; #else std::abort; From criswell at cs.uiuc.edu Thu Feb 5 10:07:40 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:07:40 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/config/arm/lib1funcs.asm t-arm-elf Message-ID: <200402051606.KAA27002@choi.cs.uiuc.edu> Changes in directory gcc-3.4/gcc/config/arm: lib1funcs.asm updated: 1.2 -> 1.3 t-arm-elf updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+118 -71) Index: gcc-3.4/gcc/config/arm/lib1funcs.asm diff -u gcc-3.4/gcc/config/arm/lib1funcs.asm:1.2 gcc-3.4/gcc/config/arm/lib1funcs.asm:1.3 --- gcc-3.4/gcc/config/arm/lib1funcs.asm:1.2 Fri Jan 9 10:54:31 2004 +++ gcc-3.4/gcc/config/arm/lib1funcs.asm Thu Feb 5 10:05:45 2004 @@ -61,66 +61,107 @@ /* Function end macros. Variants for 26 bit APCS and interworking. */ +@ This selects the minimum architecture level required. +#define __ARM_ARCH__ 3 + +#if defined(__ARM_ARCH_3M__) || defined(__ARM_ARCH_4__) \ + || defined(__ARM_ARCH_4T__) +/* We use __ARM_ARCH__ set to 4 here, but in reality it's any processor with + long multiply instructions. That includes v3M. */ +# undef __ARM_ARCH__ +# define __ARM_ARCH__ 4 +#endif + +#if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \ + || defined(__ARM_ARCH_5TE__) +# undef __ARM_ARCH__ +# define __ARM_ARCH__ 5 +#endif + +/* How to return from a function call depends on the architecture variant. */ + #ifdef __APCS_26__ + # define RET movs pc, lr # define RETc(x) mov##x##s pc, lr -# define RETCOND ^ + +#elif (__ARM_ARCH__ > 4) || defined(__ARM_ARCH_4T__) + +# define RET bx lr +# define RETc(x) bx##x lr + +# if (__ARM_ARCH__ == 4) \ + && (defined(__thumb__) || defined(__THUMB_INTERWORK__)) +# define __INTERWORKING__ +# endif + +#else + +# define RET mov pc, lr +# define RETc(x) mov##x pc, lr + +#endif + +/* Don't pass dirn, it's there just to get token pasting right. */ + +.macro RETLDM regs=, cond=, dirn=ia +#ifdef __APCS_26__ + .ifc "\regs","" + ldm\cond\dirn sp!, {pc}^ + .else + ldm\cond\dirn sp!, {\regs, pc}^ + .endif +#elif defined (__INTERWORKING__) + .ifc "\regs","" + ldr\cond lr, [sp], #4 + .else + ldm\cond\dirn sp!, {\regs, lr} + .endif + bx\cond lr +#else + .ifc "\regs","" + ldr\cond pc, [sp], #4 + .else + ldm\cond\dirn sp!, {\regs, pc} + .endif +#endif +.endm + + .macro ARM_LDIV0 LSYM(Ldiv0): str lr, [sp, #-4]! bl SYM (__div0) __PLT__ mov r0, #0 @ About as wrong as it could be. - ldmia sp!, {pc}^ + RETLDM .endm -#else -# ifdef __THUMB_INTERWORK__ -# define RET bx lr -# define RETc(x) bx##x lr + + .macro THUMB_LDIV0 LSYM(Ldiv0): push { lr } bl SYM (__div0) mov r0, #0 @ About as wrong as it could be. +#if defined (__INTERWORKING__) pop { r1 } bx r1 -.endm -.macro ARM_LDIV0 -LSYM(Ldiv0): - str lr, [sp, #-4]! - bl SYM (__div0) __PLT__ - mov r0, #0 @ About as wrong as it could be. - ldr lr, [sp], #4 - bx lr -.endm -# else -# define RET mov pc, lr -# define RETc(x) mov##x pc, lr -.macro THUMB_LDIV0 -LSYM(Ldiv0): - push { lr } - bl SYM (__div0) - mov r0, #0 @ About as wrong as it could be. +#else pop { pc } -.endm -.macro ARM_LDIV0 -LSYM(Ldiv0): - str lr, [sp, #-4]! - bl SYM (__div0) __PLT__ - mov r0, #0 @ About as wrong as it could be. - ldmia sp!, {pc} -.endm -# endif -# define RETCOND #endif +.endm .macro FUNC_END name + SIZE (__\name) +.endm + +.macro DIV_FUNC_END name LSYM(Ldiv0): #ifdef __thumb__ THUMB_LDIV0 #else ARM_LDIV0 #endif - SIZE (__\name) + FUNC_END \name .endm .macro THUMB_FUNC_START name @@ -149,7 +190,24 @@ THUMB_FUNC SYM (__\name): .endm - + +/* Special function that will always be coded in ARM assembly, even if + in Thumb-only compilation. */ + +#if defined(__thumb__) && !defined(__THUMB_INTERWORK__) +.macro ARM_FUNC_START name + FUNC_START \name + bx pc + nop + .arm +_L__\name: /* A hook to tell gdb that we've switched to ARM */ +.endm +#else +.macro ARM_FUNC_START name + FUNC_START \name +.endm +#endif + /* Register aliases. */ work .req r4 @ XXXX is this safe ? @@ -452,7 +510,7 @@ #endif /* ARM version */ - FUNC_END udivsi3 + DIV_FUNC_END udivsi3 #endif /* L_udivsi3 */ /* ------------------------------------------------------------------------ */ @@ -493,7 +551,7 @@ #endif /* ARM version. */ - FUNC_END umodsi3 + DIV_FUNC_END umodsi3 #endif /* L_umodsi3 */ /* ------------------------------------------------------------------------ */ @@ -555,7 +613,7 @@ #endif /* ARM version */ - FUNC_END divsi3 + DIV_FUNC_END divsi3 #endif /* L_divsi3 */ /* ------------------------------------------------------------------------ */ @@ -616,7 +674,7 @@ #endif /* ARM version */ - FUNC_END modsi3 + DIV_FUNC_END modsi3 #endif /* L_modsi3 */ /* ------------------------------------------------------------------------ */ @@ -626,7 +684,7 @@ RET - SIZE (__div0) + FUNC_END div0 #endif /* L_divmodsi_tools */ /* ------------------------------------------------------------------------ */ @@ -639,22 +697,18 @@ #define __NR_getpid (__NR_SYSCALL_BASE+ 20) #define __NR_kill (__NR_SYSCALL_BASE+ 37) + .code 32 FUNC_START div0 stmfd sp!, {r1, lr} swi __NR_getpid cmn r0, #1000 - ldmhsfd sp!, {r1, pc}RETCOND @ not much we can do + RETLDM r1 hs mov r1, #SIGFPE swi __NR_kill -#ifdef __THUMB_INTERWORK__ - ldmfd sp!, {r1, lr} - bx lr -#else - ldmfd sp!, {r1, pc}RETCOND -#endif + RETLDM r1 - SIZE (__div0) + FUNC_END div0 #endif /* L_dvmd_lnx */ /* ------------------------------------------------------------------------ */ @@ -723,24 +777,23 @@ .code 32 .globl _arm_return -_arm_return: - ldmia r13!, {r12} - bx r12 +_arm_return: + RETLDM .code 16 -.macro interwork register - .code 16 +.macro interwork register + .code 16 THUMB_FUNC_START _interwork_call_via_\register - bx pc + bx pc nop - - .code 32 - .globl .Lchange_\register -.Lchange_\register: + + .code 32 + .globl LSYM(Lchange_\register) +LSYM(Lchange_\register): tst \register, #1 - stmeqdb r13!, {lr} + streq lr, [sp, #-4]! adreq lr, _arm_return bx \register @@ -783,16 +836,6 @@ #endif /* L_interwork_call_via_rX */ -#ifdef L_ieee754_dp - /* These functions are coded in ARM state, even when called from - Thumb. */ - .arm #include "ieee754-df.S" -#endif - -#ifdef L_ieee754_sp - /* These functions are coded in ARM state, even when called from - Thumb. */ - .arm #include "ieee754-sf.S" -#endif + Index: gcc-3.4/gcc/config/arm/t-arm-elf diff -u gcc-3.4/gcc/config/arm/t-arm-elf:1.2 gcc-3.4/gcc/config/arm/t-arm-elf:1.3 --- gcc-3.4/gcc/config/arm/t-arm-elf:1.2 Fri Jan 9 10:54:31 2004 +++ gcc-3.4/gcc/config/arm/t-arm-elf Thu Feb 5 10:05:45 2004 @@ -1,5 +1,9 @@ LIB1ASMSRC = arm/lib1funcs.asm -LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func _call_via_rX _interwork_call_via_rX _ieee754_dp _ieee754_sp +LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func \ + _call_via_rX _interwork_call_via_rX \ + _negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi \ + _truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \ + _fixsfsi _fixunssfsi MULTILIB_OPTIONS = marm/mthumb MULTILIB_DIRNAMES = arm thumb From criswell at cs.uiuc.edu Thu Feb 5 10:07:46 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:07:46 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/testsuite/ChangeLog Message-ID: <200402051606.KAA27043@choi.cs.uiuc.edu> Changes in directory gcc-3.4/gcc/testsuite: ChangeLog updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+355 -2) Index: gcc-3.4/gcc/testsuite/ChangeLog diff -u gcc-3.4/gcc/testsuite/ChangeLog:1.2 gcc-3.4/gcc/testsuite/ChangeLog:1.3 --- gcc-3.4/gcc/testsuite/ChangeLog:1.2 Fri Jan 9 10:54:32 2004 +++ gcc-3.4/gcc/testsuite/ChangeLog Thu Feb 5 10:05:47 2004 @@ -1,3 +1,356 @@ +2003-09-23 Geoffrey Keating + + * gcc.dg/darwin-abi-1.c: New file. + +2003-09-21 Andrew Pinski + + PR target/12281 + * gcc.c-torture/compile/20030921-1.c: New test. + +2003-09-22 Eric Botcazou + + * g++.dg/opt/reg-stack2.C: New test. + +2003-09-21 Christian Ehrhardt + + * g++.dg/eh/delayslot1.C: New test. + +2003-09-20 Richard Henderson + + * gcc.dg/format/gcc_diag-1.c: Add tests for %J. + +2003-09-20 Roger Sayle + + * gcc.c-torture/execute/20030920-1.c: New test case. + +2003-09-20 Kriang Lerdsuwanakij + + * g++.dg/rtti/typeid3.C: Correct expected error message. + +2003-09-20 Kriang Lerdsuwanakij + + PR c++/157 + * g++.dg/parse/crash12.C: New test. + +2003-09-19 Janis Johnson + + * gcc.dg/compat/mixed-struct-check.h: New. + * gcc.dg/compat/mixed-struct-defs.h: New. + * gcc.dg/compat/mixed-struct-init.h: New. + * gcc.dg/compat/struct-by-value-19_main.c: New. + * gcc.dg/compat/struct-by-value-19_x.c: New. + * gcc.dg/compat/struct-by-value-19_y.c: New. + * gcc.dg/compat/struct-by-value-20_main.c: New. + * gcc.dg/compat/struct-by-value-20_x.c: New. + * gcc.dg/compat/struct-by-value-20_y.c: New. + * gcc.dg/compat/struct-return-19_main.c: New. + * gcc.dg/compat/struct-return-19_x.c: New. + * gcc.dg/compat/struct-return-19_y.c: New. + * gcc.dg/compat/struct-return-20_main.c: New. + * gcc.dg/compat/struct-return-20_x.c: New. + * gcc.dg/compat/struct-return-20_y.c: New. + +2003-09-19 Andrew Pinski + * g++.dg/init/array11.C: Change unsigned to __SIZE_TYPE__ + so that it will not complain on LP64 targets. + +2003-09-19 Kriang Lerdsuwanakij + + PR c++/495 + * g++.dg/template/friend24.C: New test. + +2003-09-19 Nathan Sidwell + + PR c++/12332 + * g++.dg/template/memtmpl2.C: New test. + +2003-09-18 Mark Mitchell + + PR target/11184 + * gcc.dg/builtin-apply1.c: New test. + +2003-09-18 Nathan Sidwell + + PR c++/9848 + * g++.dg/warn/Wunused-4.C: New test. + +2003-09-18 Volker Reichelt + + PR c++/12316 + * g++.dg/other/gc2.C: New test. + +2003-09-17 Mark Mitchell + + PR c++/11991 + * g++.dg/rtti/typeid3.C: New test. + + PR c++/12266 + * g++.dg/overload/template1.C: New test. + +2003-09-17 Eric Botcazou + + * g++.dg/opt/cfg3.C: New test. + +2003-09-16 Kriang Lerdsuwanakij + + PR c++/7939 + * g++.dg/template/crash11.C: New test. + +2003-09-16 Jason Merrill + Jakub Jelinek + + * gcc.dg/attr-warn-unused-result.c: New test. + +2003-09-15 Nathan Sidwell + + PR c++/12184 + * g++.dg/expr/call2.C: New test. + +2003-09-15 Andreas Jaeger + + * gcc.dg/Wold-style-definition-1.c: New test. + +2003-09-14 Mark Mitchell + + PR c++/3907 + * g++.dg/parse/template12.C: New test. + + * g++.dg/abi/bitfield11.C: New test. + * g++.dg/abi/bitfield12.C: Likewise. + +2003-09-14 Alexandre Oliva + + * gcc.dg/cpp/separate-1.c: Adjust line of error. Test for correct + non-expansion of functional macro name without arguments at EOL. + * gcc.dg/cpp/spacing1.c: Revert 2003-08-04's change. Likewise. + +2003-09-14 Richard Sandiford + + * gcc.c-torture/execute/20030914-[12].c: New tests. + +2003-09-11 Nathan Sidwell + + PR c++/11788 + * g++.dg/overload/addr1.C: New test. + +2003-09-10 Ian Lance Taylor + + * gcc.dg/20030909-1.c: New test. + +2003-09-10 Eric Botcazou + + * gcc.dg/ultrasp10.c: New test. + +2003-09-09 Devang Patel + + * gcc.dg/darwin-ld-6.c: New test. + +2003-09-09 Kaveh R. Ghazi + + * gcc.dg/torture/builtin-explog-1.c: New testcase. + +2003-09-08 Mark Mitchell + + * gcc.dg/ia64-types1.c: New test. + * gcc.dg/ia64-types2.c: Likewise. + +2003-09-08 Kaveh R. Ghazi + + * gcc.dg/builtins-1.c: Add more _Complex tests. + * gcc.dg/torture/builtin-attr-1.c: Likewise. + + * gcc.dg/builtins-1.c: Test existing _Complex functions. + * gcc.dg/torture/builtin-attr-1.c: Likewise. + +2003-09-08 Mark Mitchell + + PR c++/11786 + * g++.dg/lookup/koenig2.C: New test. + + PR c++/5296 + * g++.dg/rtti/typeid2.C: New test. + +2003-09-08 Jakub Jelinek + + * gcc.c-torture/compile/20030904-1.c: New test. + +2003-09-07 Eric Botcazou + + * g++.dg/opt/longbranch2.C: New test. + +2003-09-07 Andrew Pinski + + * g++.dg/template/crash10.C: Only compile it. + +2003-09-07 Andrew Pinski + + PR middle-end/11665 + * gcc.c-torture/compile/20030907-1.c: New test. + * g++.dg/init/array11.C: New test. + +2003-09-07 Mark Mitchell + + PR c++/11852 + * g++.dg/init/struct1.C: New test. + +2003-09-07 Mark Mitchell + + PR c++/12181 + * g++.dg/expr/comma1.C: New test. + +2003-09-06 Mark Mitchell + + PR c++/11867 + * g++.dg/expr/static_cast5.C: New test. + +2003-09-06 Andrew Pinski + + PR c++/11507 + * g++.dg/lookup/scoped7.C: New test. + + PR c++/9574 + * g++.dg/other/static1.C: New test. + + PR c++/11490 + * g++.dg/warn/template-1.C: New test. + + PR c++/11432 + * g++.dg/template/crash10.C: New test. + + PR c++/2478 + * g++.dg/overload/VLA.C: New test. + + PR c++/10804 + * g++.dg/template/call1.C: New test. + +2003-09-06 Nathan Sidwell + + PR c++/11794 + * g++.dg/parse/using3.C: New test. + +2003-09-06 Roger Sayle + + PR c++/11409 + * g++.dg/overload/builtin3.C: New test case. + +2003-09-06 Steven Bosscher + + PR c/9862 + * gcc.dg/20030906-1.c: New test. + * gcc.dg/20030906-2.c: Likewise. + +2003-09-06 Nathan Sidwell + + PR c++/12167 + * g++.dg/parse/defarg5.C: New test. + + * g++.dg/template/non-type-template-argument-1.C: Tweak expected error. + +2003-09-05 Mark Mitchell + + PR c++/12163 + * g++.dg/expr/static_cast4.C: New test. + + PR c++/12146 + * g++.dg/template/crash9.C: New test. + +2003-09-05 Andrew Pinski + + * g++.old-deja/g++.ext/pretty2.C: Update for change + in __FUNCTION__. + * g++.old-deja/g++.ext/pretty3.C: Likewise. + +2003-09-05 Nathan Sidwell + + PR c++/11922 + * g++/dg/template/qualified-id1.C: New test. + + PR c++/12037 + * g++.dg/warn/noeffect4.C: New test. + +2003-09-04 Matt Austern + + * g++.dg/ext/fnname1.C: New test. (__func__ for C++.) + * g++.dg/ext/fnname2.C: Likewise. + * g++.dg/ext/fnname3.C: Likewise. + +2003-09-04 Mark Mitchell + + * g++.dg/expr/lval1.C: New test. + * g++.dg/ext/lvcast.C: Remove. + +2003-09-03 Roger Sayle + + PR optimization/11700. + * gcc.c-torture/compile/20030903-1.c: New test case. + +2003-09-03 Mark Mitchell + + PR c++/12053 + * g++.dg/abi/layout4.C: New test. + +2003-09-02 Scott Brumbaugh + + PR c++/11553 + * g++.dg/parse/friend3.C: New test. + +2003-09-02 Mark Mitchell + + PR c++/11847 + * g++.dg/template/class1.C: New test. + + PR c++/11808 + * g++.dg/expr/call1.C: New test. + +2003-09-01 Mark Mitchell + + PR c++/12114 + * g++.dg/init/ref9.C: New test. + + PR c++/11972 + * g++.dg/template/nested4.C: New test. + +2003-08-29 Mark Mitchell + + PR c++/12093 + * g++.dg/template/non-dependent4.C: New test. + + PR c++/11928 + * g++.dg/inherit/conv1.C: New test. + +2003-08-29 Mark Mitchell + + PR c++/6196 + * g++.dg/ext/label1.C: New test. + * g++.dg/ext/label2.C: Likewise. + +2003-08-28 Mark Mitchell + + * g++.dg/expr/cond3.C: New test. + +2003-08-28 Kaveh R. Ghazi + + * gcc.dg/builtins-1.c: Add new builtin cases. + +2003-08-28 Kaveh R. Ghazi + + * gcc.dg/builtins-1.c: Add new cases. + * gcc.dg/torture/builtin-attr-1.c: Likewise. + +2003-08-28 Kaveh R. Ghazi + + * gcc.dg/builtins-1.c: Add more math builtin tests. + * gcc.dg/torture/builtin-attr-1.c: New test. + +2003-08-28 Mark Mitchell + + PR optimization/5079 + * g++.dg/opt/static3.C: New test. + +2003-08-27 Zdenek Dvorak + + * gcc.misc-tests/gcov-10b.c: New test. + 2003-08-27 Mark Mitchell * g++.dg/opt/ptrmem3.C: New test. @@ -397,7 +750,7 @@ * gcc.dg/i386-387-1.c (dg-options): Add -march=i386. * gcc.dg/i386-387-5.c (dg-options): Likewise. -Wed Jul 30 19:13:34 CEST 2003 Jan Hubicka +2003-07-30 Jan Hubicka * vtgc1.c: Kill. @@ -1578,7 +1931,7 @@ * lib/gcc-dg.exp (dg-require-alias): Fix typo. (dg-require-gc-sections): Likewise. -Sun Jun 8 16:46:04 CEST 2003 Jan Hubicka +2003-06-08 Jan Hubicka * i386-cmov1.c: Fix regular expression. * i386-cvt-1.c: Likewise. From criswell at cs.uiuc.edu Thu Feb 5 10:07:52 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:07:52 2004 Subject: [llvm-commits] CVS: gcc-3.4/libstdc++-v3/include/Makefile.am Makefile.in Message-ID: <200402051606.KAA27021@choi.cs.uiuc.edu> Changes in directory gcc-3.4/libstdc++-v3/include: Makefile.am updated: 1.2 -> 1.3 Makefile.in updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+26 -27) Index: gcc-3.4/libstdc++-v3/include/Makefile.am diff -u gcc-3.4/libstdc++-v3/include/Makefile.am:1.2 gcc-3.4/libstdc++-v3/include/Makefile.am:1.3 --- gcc-3.4/libstdc++-v3/include/Makefile.am:1.2 Fri Jan 9 10:54:35 2004 +++ gcc-3.4/libstdc++-v3/include/Makefile.am Thu Feb 5 10:05:49 2004 @@ -225,7 +225,7 @@ # This is the common subset of files that all three "C" header models use. -c_base_srcdir = @C_INCLUDE_DIR@ +c_base_srcdir = $(C_INCLUDE_DIR) c_base_builddir = . c_base_headers = \ ${c_base_srcdir}/std_cassert.h \ @@ -304,19 +304,19 @@ c_compatibility_headers_extra = endif -host_srcdir = ${glibcxx_srcdir}/@OS_INC_SRCDIR@ +host_srcdir = ${glibcxx_srcdir}/$(OS_INC_SRCDIR) host_builddir = ./${host_alias}/bits host_headers = \ ${host_srcdir}/ctype_base.h \ ${host_srcdir}/ctype_inline.h \ ${host_srcdir}/ctype_noninline.h \ ${host_srcdir}/os_defines.h \ - ${glibcxx_srcdir}/@ATOMICITY_INC_SRCDIR@/atomicity.h \ - ${glibcxx_srcdir}/@FPOS_INC_SRCDIR@/fpos.h + ${glibcxx_srcdir}/$(ATOMICITY_INC_SRCDIR)/atomicity.h \ + ${glibcxx_srcdir}/$(FPOS_INC_SRCDIR)/fpos.h # Non-installed host_header files. host_headers_noinst = \ - ${glibcxx_srcdir}/@CLOCALE_INTERNAL_H@ + ${glibcxx_srcdir}/$(CLOCALE_INTERNAL_H) # These host_headers_extra files are all built with ad hoc naming rules. host_headers_extra = \ @@ -441,13 +441,13 @@ @if [ ! -f stamp-host ]; then \ (cd ${host_builddir} ;\ $(LN_S) ${host_headers} . || true ;\ - $(LN_S) ${glibcxx_srcdir}/@BASIC_FILE_H@ basic_file.h || true ;\ - $(LN_S) ${glibcxx_srcdir}/@CSTDIO_H@ c++io.h || true ;\ - $(LN_S) ${glibcxx_srcdir}/@CLOCALE_H@ c++locale.h || true ;\ - $(LN_S) ${glibcxx_srcdir}/@CLOCALE_INTERNAL_H@ . || true ;\ - $(LN_S) ${glibcxx_srcdir}/@CMESSAGES_H@ messages_members.h || true ;\ - $(LN_S) ${glibcxx_srcdir}/@CTIME_H@ time_members.h || true ;\ - $(LN_S) ${glibcxx_srcdir}/@CCODECVT_H@ codecvt_specializations.h || true);\ + $(LN_S) ${glibcxx_srcdir}/$(BASIC_FILE_H) basic_file.h || true ;\ + $(LN_S) ${glibcxx_srcdir}/$(CSTDIO_H) c++io.h || true ;\ + $(LN_S) ${glibcxx_srcdir}/$(CLOCALE_H) c++locale.h || true ;\ + $(LN_S) ${glibcxx_srcdir}/$(CLOCALE_INTERNAL_H) . || true ;\ + $(LN_S) ${glibcxx_srcdir}/$(CMESSAGES_H) messages_members.h || true ;\ + $(LN_S) ${glibcxx_srcdir}/$(CTIME_H) time_members.h || true ;\ + $(LN_S) ${glibcxx_srcdir}/$(CCODECVT_H) codecvt_specializations.h || true);\ fi ;\ $(STAMP) stamp-host @@ -464,7 +464,6 @@ echo "#endif // _CXXCONFIG_" >>$@ # Host includes for threads -glibcxx_thread_h = @glibcxx_thread_h@ uppercase = [ABCDEFGHIJKLMNOPQRSTUVWXYZ_] ${host_builddir}/gthr.h: ${toplevel_srcdir}/gcc/gthr.h stamp-${host_alias} Index: gcc-3.4/libstdc++-v3/include/Makefile.in diff -u gcc-3.4/libstdc++-v3/include/Makefile.in:1.2 gcc-3.4/libstdc++-v3/include/Makefile.in:1.3 --- gcc-3.4/libstdc++-v3/include/Makefile.in:1.2 Fri Jan 9 10:54:35 2004 +++ gcc-3.4/libstdc++-v3/include/Makefile.in Thu Feb 5 10:05:49 2004 @@ -166,8 +166,6 @@ glibcxx_localedir = @glibcxx_localedir@ glibcxx_prefixdir = @glibcxx_prefixdir@ glibcxx_srcdir = @glibcxx_srcdir@ - -# Host includes for threads glibcxx_thread_h = @glibcxx_thread_h@ glibcxx_toolexecdir = @glibcxx_toolexecdir@ glibcxx_toolexeclibdir = @glibcxx_toolexeclibdir@ @@ -427,7 +425,7 @@ # This is the common subset of files that all three "C" header models use. -c_base_srcdir = @C_INCLUDE_DIR@ +c_base_srcdir = $(C_INCLUDE_DIR) c_base_builddir = . c_base_headers = \ ${c_base_srcdir}/std_cassert.h \ @@ -503,20 +501,20 @@ @GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE at c_compatibility_headers_extra = ${c_compatibility_headers} -host_srcdir = ${glibcxx_srcdir}/@OS_INC_SRCDIR@ +host_srcdir = ${glibcxx_srcdir}/$(OS_INC_SRCDIR) host_builddir = ./${host_alias}/bits host_headers = \ ${host_srcdir}/ctype_base.h \ ${host_srcdir}/ctype_inline.h \ ${host_srcdir}/ctype_noninline.h \ ${host_srcdir}/os_defines.h \ - ${glibcxx_srcdir}/@ATOMICITY_INC_SRCDIR@/atomicity.h \ - ${glibcxx_srcdir}/@FPOS_INC_SRCDIR@/fpos.h + ${glibcxx_srcdir}/$(ATOMICITY_INC_SRCDIR)/atomicity.h \ + ${glibcxx_srcdir}/$(FPOS_INC_SRCDIR)/fpos.h # Non-installed host_header files. host_headers_noinst = \ - ${glibcxx_srcdir}/@CLOCALE_INTERNAL_H@ + ${glibcxx_srcdir}/$(CLOCALE_INTERNAL_H) # These host_headers_extra files are all built with ad hoc naming rules. @@ -560,6 +558,8 @@ ${thread_host_headers} \ ${pch_build} + +# Host includes for threads uppercase = [ABCDEFGHIJKLMNOPQRSTUVWXYZ_] # By adding these files here, automake will remove them for 'make clean' @@ -796,13 +796,13 @@ @if [ ! -f stamp-host ]; then \ (cd ${host_builddir} ;\ $(LN_S) ${host_headers} . || true ;\ - $(LN_S) ${glibcxx_srcdir}/@BASIC_FILE_H@ basic_file.h || true ;\ - $(LN_S) ${glibcxx_srcdir}/@CSTDIO_H@ c++io.h || true ;\ - $(LN_S) ${glibcxx_srcdir}/@CLOCALE_H@ c++locale.h || true ;\ - $(LN_S) ${glibcxx_srcdir}/@CLOCALE_INTERNAL_H@ . || true ;\ - $(LN_S) ${glibcxx_srcdir}/@CMESSAGES_H@ messages_members.h || true ;\ - $(LN_S) ${glibcxx_srcdir}/@CTIME_H@ time_members.h || true ;\ - $(LN_S) ${glibcxx_srcdir}/@CCODECVT_H@ codecvt_specializations.h || true);\ + $(LN_S) ${glibcxx_srcdir}/$(BASIC_FILE_H) basic_file.h || true ;\ + $(LN_S) ${glibcxx_srcdir}/$(CSTDIO_H) c++io.h || true ;\ + $(LN_S) ${glibcxx_srcdir}/$(CLOCALE_H) c++locale.h || true ;\ + $(LN_S) ${glibcxx_srcdir}/$(CLOCALE_INTERNAL_H) . || true ;\ + $(LN_S) ${glibcxx_srcdir}/$(CMESSAGES_H) messages_members.h || true ;\ + $(LN_S) ${glibcxx_srcdir}/$(CTIME_H) time_members.h || true ;\ + $(LN_S) ${glibcxx_srcdir}/$(CCODECVT_H) codecvt_specializations.h || true);\ fi ;\ $(STAMP) stamp-host From criswell at cs.uiuc.edu Thu Feb 5 10:07:59 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:07:59 2004 Subject: [llvm-commits] CVS: gcc-3.4/libstdc++-v3/testsuite/Makefile.in Message-ID: <200402051606.KAA27007@choi.cs.uiuc.edu> Changes in directory gcc-3.4/libstdc++-v3/testsuite: Makefile.in updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+6 -6) Index: gcc-3.4/libstdc++-v3/testsuite/Makefile.in diff -u gcc-3.4/libstdc++-v3/testsuite/Makefile.in:1.2 gcc-3.4/libstdc++-v3/testsuite/Makefile.in:1.3 --- gcc-3.4/libstdc++-v3/testsuite/Makefile.in:1.2 Fri Jan 9 10:54:35 2004 +++ gcc-3.4/libstdc++-v3/testsuite/Makefile.in Thu Feb 5 10:05:49 2004 @@ -147,7 +147,6 @@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ am__leading_dot = @am__leading_dot@ - baseline_dir = @baseline_dir@ bindir = @bindir@ build = @build@ @@ -247,8 +246,9 @@ @GLIBCXX_TEST_ABI_TRUE at noinst_PROGRAMS = abi_check abi_check_SOURCES = abi_check.cc + baseline_file = ${baseline_dir}/baseline_symbols.txt -extract_symvers = @glibcxx_srcdir@/scripts/extract_symvers +extract_symvers = $(glibcxx_srcdir)/scripts/extract_symvers # These two special 'check-script' rules use the bash script # 'check_survey' to do testing. This script is not as portable as the @@ -257,7 +257,7 @@ # items like compile time, execution time, and binary size. survey_script = ${glibcxx_builddir}/scripts/check_survey -# Runs the testsuite/performance tests. +# Runs the testsuite/performance tests. # Some of these tests create large (~75MB) files, allocate huge # ammounts of memory, or otherwise tie up machine resources. Thus, # running this is off by default. @@ -265,7 +265,7 @@ # By adding these files here, automake will remove them for 'make clean' CLEANFILES = *.txt *.tst *.exe core* filebuf_* tmp* ostream_* *.log *.sum \ - testsuite_* site.exp abi_check baseline_symbols + testsuite_* site.exp abi_check baseline_symbols subdir = testsuite ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -593,7 +593,7 @@ exit 1; \ fi; true) -new-abi-baseline: +new-abi-baseline: -@$(mkinstalldirs) ${baseline_dir} -@(output=${baseline_file}; \ if test -f $${output}; then \ @@ -609,7 +609,7 @@ @GLIBCXX_TEST_ABI_TRUE@ -@(./abi_check --check ./current_symbols.txt ${baseline_file} \ @GLIBCXX_TEST_ABI_TRUE@ 2>&1 | tee libstdc++-abi.sum) - at GLIBCXX_TEST_ABI_TRUE@check-abi-verbose: abi_check baseline_symbols current_symbols.txt + at GLIBCXX_TEST_ABI_TRUE@check-abi-verbose: abi_check baseline_symbols current_symbols.txt @GLIBCXX_TEST_ABI_TRUE@ -@(./abi_check --check-verbose ./current_symbols.txt ${baseline_file} \ @GLIBCXX_TEST_ABI_TRUE@ 2>&1 | tee libstdc++-abi.sum) From criswell at cs.uiuc.edu Thu Feb 5 10:08:04 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:08:04 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/config/darwin.h t-interix t-linux-aout Message-ID: <200402051606.KAA27026@choi.cs.uiuc.edu> Changes in directory gcc-3.4/gcc/config: darwin.h updated: 1.2 -> 1.3 t-interix (r1.1.1.1) removed t-linux-aout (r1.1.1.1) removed --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+1 -1) Index: gcc-3.4/gcc/config/darwin.h diff -u gcc-3.4/gcc/config/darwin.h:1.2 gcc-3.4/gcc/config/darwin.h:1.3 --- gcc-3.4/gcc/config/darwin.h:1.2 Thu Jan 8 17:03:34 2004 +++ gcc-3.4/gcc/config/darwin.h Thu Feb 5 10:05:45 2004 @@ -248,7 +248,7 @@ %{Zmulti_module:-multi_module} %{Zsingle_module:-single_module} \ %{Zmultiply_defined*:-multiply_defined %*} \ %{Zmultiplydefinedunused*:-multiply_defined_unused %*} \ - %{prebind} %{noprebind} %{prebind_all_twolevel_modules} \ + %{prebind} %{noprebind} %{nofixprebinding} %{prebind_all_twolevel_modules} \ %{read_only_relocs} \ %{sectcreate*} %{sectorder*} %{seg1addr*} %{segprot*} %{seg_addr_table*} \ %{Zseg_addr_table_filename*:-seg_addr_table_filename %*} \ From criswell at cs.uiuc.edu Thu Feb 5 10:08:10 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:08:10 2004 Subject: [llvm-commits] CVS: gcc-3.4/libstdc++-v3/include/bits/locale_facets.tcc Message-ID: <200402051606.KAA27009@choi.cs.uiuc.edu> Changes in directory gcc-3.4/libstdc++-v3/include/bits: locale_facets.tcc updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+1 -1) Index: gcc-3.4/libstdc++-v3/include/bits/locale_facets.tcc diff -u gcc-3.4/libstdc++-v3/include/bits/locale_facets.tcc:1.2 gcc-3.4/libstdc++-v3/include/bits/locale_facets.tcc:1.3 --- gcc-3.4/libstdc++-v3/include/bits/locale_facets.tcc:1.2 Fri Jan 9 10:54:35 2004 +++ gcc-3.4/libstdc++-v3/include/bits/locale_facets.tcc Thu Feb 5 10:05:49 2004 @@ -105,7 +105,7 @@ const locale::facet** __caches = __loc._M_impl->_M_caches; if (!__caches[__i]) { - __numpunct_cache<_CharT>* __tmp; + __numpunct_cache<_CharT>* __tmp = NULL; try { __tmp = new __numpunct_cache<_CharT>; From criswell at cs.uiuc.edu Thu Feb 5 10:08:16 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:08:16 2004 Subject: [llvm-commits] CVS: gcc-3.4/libstdc++-v3/po/Makefile.in Message-ID: <200402051606.KAA27008@choi.cs.uiuc.edu> Changes in directory gcc-3.4/libstdc++-v3/po: Makefile.in updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+14 -14) Index: gcc-3.4/libstdc++-v3/po/Makefile.in diff -u gcc-3.4/libstdc++-v3/po/Makefile.in:1.2 gcc-3.4/libstdc++-v3/po/Makefile.in:1.3 --- gcc-3.4/libstdc++-v3/po/Makefile.in:1.2 Fri Jan 9 10:54:35 2004 +++ gcc-3.4/libstdc++-v3/po/Makefile.in Thu Feb 5 10:05:49 2004 @@ -221,24 +221,24 @@ # Location of installation directories. locale_installdir = $(DESTDIR)$(datadir)/locale -locale_builddir = @glibcxx_localedir@ +locale_builddir = $(glibcxx_localedir) # Tell automake that foo.po makes foo.mo SUFFIXES = .po .mo -LOCALE_IN = @glibcxx_POFILES@ -LOCALE_OUT = @glibcxx_MOFILES@ +LOCALE_IN = $(glibcxx_POFILES) +LOCALE_OUT = $(glibcxx_MOFILES) MSGFMT = msgfmt # Necessary files. DISTFILES = \ Makefile.am Makefile.in string_literals.cc POTFILES.in $(PACKAGE).pot \ - $(LOCALE_IN) + $(LOCALE_IN) # Specify what gets cleaned up on a 'make clean' -CLEANFILES = $(LOCALE_OUT) +CLEANFILES = $(LOCALE_OUT) subdir = po ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 CONFIG_HEADER = $(top_builddir)/config.h @@ -392,15 +392,15 @@ .po.mo: $(MSGFMT) -o $@ $< -all-local: all-local- at USE_NLS@ -all-local-no: -all-local-yes: $(LOCALE_OUT) +all-local: all-local-$(USE_NLS) +all-local-no: +all-local-yes: $(LOCALE_OUT) # 'make check' needs the catalogs constructed in build directory. -check: check- at USE_NLS@ +check: check-$(USE_NLS) check-no: check-yes: - $(mkinstalldirs) $(locale_builddir) + $(mkinstalldirs) $(locale_builddir) catalogs='$(LOCALE_OUT)'; \ for cat in $$catalogs; do \ cat=`basename $$cat`; \ @@ -408,14 +408,14 @@ install_dir=$(locale_builddir)/$$lang/LC_MESSAGES; \ $(mkinstalldirs) $$install_dir; \ $(INSTALL_DATA) $$cat $$install_dir/$(PACKAGE).mo; \ - done + done -# Install rules here. +# Install rules here. # Wish install could just `cp -R ./share $(locale_installdir)` ... -install-data-local: install-data-local- at USE_NLS@ +install-data-local: install-data-local-$(USE_NLS) install-data-local-no: install-data-local-yes: all-local-yes - $(mkinstalldirs) $(locale_installdir) + $(mkinstalldirs) $(locale_installdir) catalogs='$(LOCALE_OUT)'; \ for cat in $$catalogs; do \ cat=`basename $$cat`; \ From criswell at cs.uiuc.edu Thu Feb 5 10:08:24 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:08:24 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/objc/objc-act.c Message-ID: <200402051606.KAA26989@choi.cs.uiuc.edu> Changes in directory gcc-3.4/gcc/objc: objc-act.c updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+434 -690) Index: gcc-3.4/gcc/objc/objc-act.c diff -u gcc-3.4/gcc/objc/objc-act.c:1.2 gcc-3.4/gcc/objc/objc-act.c:1.3 --- gcc-3.4/gcc/objc/objc-act.c:1.2 Thu Jan 8 17:11:01 2004 +++ gcc-3.4/gcc/objc/objc-act.c Thu Feb 5 10:05:47 2004 @@ -112,76 +112,71 @@ #define PROTOCOL_VERSION 2 /* (Decide if these can ever be validly changed.) */ -#define OBJC_ENCODE_INLINE_DEFS 0 +#define OBJC_ENCODE_INLINE_DEFS 0 #define OBJC_ENCODE_DONT_INLINE_DEFS 1 /*** Private Interface (procedures) ***/ /* Used by compile_file. */ -static void init_objc PARAMS ((void)); -static void finish_objc PARAMS ((void)); +static void init_objc (void); +static void finish_objc (void); /* Code generation. */ -static void synth_module_prologue PARAMS ((void)); -static tree objc_build_constructor PARAMS ((tree, tree)); -static void build_module_descriptor PARAMS ((void)); -static tree init_module_descriptor PARAMS ((tree)); -static tree build_objc_method_call PARAMS ((int, tree, tree, - tree, tree, tree)); -static void generate_strings PARAMS ((void)); -static tree get_proto_encoding PARAMS ((tree)); -static void build_selector_translation_table PARAMS ((void)); - -static tree objc_add_static_instance PARAMS ((tree, tree)); - -static tree build_ivar_template PARAMS ((void)); -static tree build_method_template PARAMS ((void)); -static tree build_private_template PARAMS ((tree)); -static void build_class_template PARAMS ((void)); -static void build_selector_template PARAMS ((void)); -static void build_category_template PARAMS ((void)); -static tree build_super_template PARAMS ((void)); -static tree build_category_initializer PARAMS ((tree, tree, tree, - tree, tree, tree)); -static tree build_protocol_initializer PARAMS ((tree, tree, tree, - tree, tree)); - -static void synth_forward_declarations PARAMS ((void)); -static void generate_ivar_lists PARAMS ((void)); -static void generate_dispatch_tables PARAMS ((void)); -static void generate_shared_structures PARAMS ((void)); -static tree generate_protocol_list PARAMS ((tree)); -static void generate_forward_declaration_to_string_table PARAMS ((void)); -static void build_protocol_reference PARAMS ((tree)); - -static tree build_keyword_selector PARAMS ((tree)); -static tree synth_id_with_class_suffix PARAMS ((const char *, tree)); - -static void generate_static_references PARAMS ((void)); -static int check_methods_accessible PARAMS ((tree, tree, - int)); -static void encode_aggregate_within PARAMS ((tree, int, int, - int, int)); -static const char *objc_demangle PARAMS ((const char *)); -static void objc_expand_function_end PARAMS ((void)); +static void synth_module_prologue (void); +static tree objc_build_constructor (tree, tree); +static rtx build_module_descriptor (void); +static tree init_module_descriptor (tree); +static tree build_objc_method_call (int, tree, tree, tree, tree, tree); +static void generate_strings (void); +static tree get_proto_encoding (tree); +static void build_selector_translation_table (void); + +static tree objc_add_static_instance (tree, tree); + +static tree build_ivar_template (void); +static tree build_method_template (void); +static tree build_private_template (tree); +static void build_class_template (void); +static void build_selector_template (void); +static void build_category_template (void); +static tree build_super_template (void); +static tree build_category_initializer (tree, tree, tree, tree, tree, tree); +static tree build_protocol_initializer (tree, tree, tree, tree, tree); + +static void synth_forward_declarations (void); +static void generate_ivar_lists (void); +static void generate_dispatch_tables (void); +static void generate_shared_structures (void); +static tree generate_protocol_list (tree); +static void generate_forward_declaration_to_string_table (void); +static void build_protocol_reference (tree); + +static tree build_keyword_selector (tree); +static tree synth_id_with_class_suffix (const char *, tree); + +static void generate_static_references (void); +static int check_methods_accessible (tree, tree, int); +static void encode_aggregate_within (tree, int, int, int, int); +static const char *objc_demangle (const char *); +static void objc_expand_function_end (void); /* Hash tables to manage the global pool of method prototypes. */ hash *nst_method_hash_list = 0; hash *cls_method_hash_list = 0; -static size_t hash_func PARAMS ((tree)); -static void hash_init PARAMS ((void)); -static void hash_enter PARAMS ((hash *, tree)); -static hash hash_lookup PARAMS ((hash *, tree)); -static void hash_add_attr PARAMS ((hash, tree)); -static tree lookup_method PARAMS ((tree, tree)); -static tree lookup_instance_method_static PARAMS ((tree, tree)); -static tree lookup_class_method_static PARAMS ((tree, tree)); -static tree add_class PARAMS ((tree)); -static void add_category PARAMS ((tree, tree)); +static size_t hash_func (tree); +static void hash_init (void); +static void hash_enter (hash *, tree); +static hash hash_lookup (hash *, tree); +static void hash_add_attr (hash, tree); +static tree lookup_method (tree, tree); +static tree lookup_instance_method_static (tree, tree); +static tree lookup_class_method_static (tree, tree); +static tree add_class (tree); +static void add_category (tree, tree); enum string_section { @@ -190,113 +185,103 @@ meth_var_types /* method and variable type descriptors */ }; -static tree add_objc_string PARAMS ((tree, - enum string_section)); -static tree get_objc_string_decl PARAMS ((tree, - enum string_section)); -static tree build_objc_string_decl PARAMS ((enum string_section)); -static tree build_selector_reference_decl PARAMS ((void)); +static tree add_objc_string (tree, enum string_section); +static tree get_objc_string_decl (tree, enum string_section); +static tree build_objc_string_decl (enum string_section); +static tree build_selector_reference_decl (void); /* Protocol additions. */ -static tree add_protocol PARAMS ((tree)); -static tree lookup_protocol PARAMS ((tree)); -static void check_protocol_recursively PARAMS ((tree, tree)); -static tree lookup_and_install_protocols PARAMS ((tree)); +static tree add_protocol (tree); +static tree lookup_protocol (tree); +static void check_protocol_recursively (tree, tree); +static tree lookup_and_install_protocols (tree); /* Type encoding. */ -static void encode_type_qualifiers PARAMS ((tree)); -static void encode_pointer PARAMS ((tree, int, int)); -static void encode_array PARAMS ((tree, int, int)); -static void encode_aggregate PARAMS ((tree, int, int)); -static void encode_bitfield PARAMS ((int)); -static void encode_type PARAMS ((tree, int, int)); -static void encode_field_decl PARAMS ((tree, int, int)); - -static void really_start_method PARAMS ((tree, tree)); -static int comp_method_with_proto PARAMS ((tree, tree)); -static int comp_proto_with_proto PARAMS ((tree, tree)); -static tree get_arg_type_list PARAMS ((tree, int, int)); -static tree objc_expr_last PARAMS ((tree)); +static void encode_type_qualifiers (tree); +static void encode_pointer (tree, int, int); +static void encode_array (tree, int, int); +static void encode_aggregate (tree, int, int); +static void encode_bitfield (int); +static void encode_type (tree, int, int); +static void encode_field_decl (tree, int, int); + +static void really_start_method (tree, tree); +static int comp_method_with_proto (tree, tree); +static int comp_proto_with_proto (tree, tree); +static tree get_arg_type_list (tree, int, int); +static tree objc_expr_last (tree); /* Utilities for debugging and error diagnostics. */ -static void warn_with_method PARAMS ((const char *, int, tree)); -static void error_with_ivar PARAMS ((const char *, tree, tree)); -static char *gen_method_decl PARAMS ((tree, char *)); -static char *gen_declaration PARAMS ((tree, char *)); -static void gen_declaration_1 PARAMS ((tree, char *)); -static char *gen_declarator PARAMS ((tree, char *, - const char *)); -static int is_complex_decl PARAMS ((tree)); -static void adorn_decl PARAMS ((tree, char *)); -static void dump_interface PARAMS ((FILE *, tree)); +static void warn_with_method (const char *, int, tree); +static void error_with_ivar (const char *, tree, tree); +static char *gen_method_decl (tree, char *); +static char *gen_declaration (tree, char *); +static void gen_declaration_1 (tree, char *); +static char *gen_declarator (tree, char *, const char *); +static int is_complex_decl (tree); +static void adorn_decl (tree, char *); +static void dump_interface (FILE *, tree); /* Everything else. */ -static tree define_decl PARAMS ((tree, tree)); -static tree lookup_method_in_protocol_list PARAMS ((tree, tree, int)); -static tree lookup_protocol_in_reflist PARAMS ((tree, tree)); -static tree create_builtin_decl PARAMS ((enum tree_code, - tree, const char *)); -static void setup_string_decl PARAMS ((void)); -static void build_string_class_template PARAMS ((void)); -static tree my_build_string PARAMS ((int, const char *)); -static void build_objc_symtab_template PARAMS ((void)); -static tree init_def_list PARAMS ((tree)); -static tree init_objc_symtab PARAMS ((tree)); -static void forward_declare_categories PARAMS ((void)); -static void generate_objc_symtab_decl PARAMS ((void)); -static tree build_selector PARAMS ((tree)); -static tree build_typed_selector_reference PARAMS ((tree, tree)); -static tree build_selector_reference PARAMS ((tree)); -static tree build_class_reference_decl PARAMS ((void)); -static void add_class_reference PARAMS ((tree)); -static tree build_protocol_template PARAMS ((void)); -static tree build_descriptor_table_initializer PARAMS ((tree, tree)); -static tree build_method_prototype_list_template PARAMS ((tree, int)); -static tree build_method_prototype_template PARAMS ((void)); -static int forwarding_offset PARAMS ((tree)); -static tree encode_method_prototype PARAMS ((tree, tree)); -static tree generate_descriptor_table PARAMS ((tree, const char *, - int, tree, tree)); -static void generate_method_descriptors PARAMS ((tree)); -static tree build_tmp_function_decl PARAMS ((void)); -static void hack_method_prototype PARAMS ((tree, tree)); -static void generate_protocol_references PARAMS ((tree)); -static void generate_protocols PARAMS ((void)); -static void check_ivars PARAMS ((tree, tree)); -static tree build_ivar_list_template PARAMS ((tree, int)); -static tree build_method_list_template PARAMS ((tree, int)); -static tree build_ivar_list_initializer PARAMS ((tree, tree)); -static tree generate_ivars_list PARAMS ((tree, const char *, - int, tree)); -static tree build_dispatch_table_initializer PARAMS ((tree, tree)); -static tree generate_dispatch_table PARAMS ((tree, const char *, - int, tree)); -static tree build_shared_structure_initializer PARAMS ((tree, tree, tree, tree, - tree, int, tree, tree, - tree)); -static void generate_category PARAMS ((tree)); -static int is_objc_type_qualifier PARAMS ((tree)); -static tree adjust_type_for_id_default PARAMS ((tree)); -static tree check_duplicates PARAMS ((hash)); -static tree receiver_is_class_object PARAMS ((tree)); -static int check_methods PARAMS ((tree, tree, int)); -static int conforms_to_protocol PARAMS ((tree, tree)); -static void check_protocol PARAMS ((tree, const char *, - const char *)); -static void check_protocols PARAMS ((tree, const char *, - const char *)); -static tree encode_method_def PARAMS ((tree)); -static void gen_declspecs PARAMS ((tree, char *, int)); -static void generate_classref_translation_entry PARAMS ((tree)); -static void handle_class_ref PARAMS ((tree)); -static void generate_struct_by_value_array PARAMS ((void)) +static tree define_decl (tree, tree); +static tree lookup_method_in_protocol_list (tree, tree, int); +static tree lookup_protocol_in_reflist (tree, tree); +static tree create_builtin_decl (enum tree_code, tree, const char *); +static void setup_string_decl (void); +static void build_string_class_template (void); +static tree my_build_string (int, const char *); +static void build_objc_symtab_template (void); +static tree init_def_list (tree); +static tree init_objc_symtab (tree); +static void forward_declare_categories (void); +static void generate_objc_symtab_decl (void); +static tree build_selector (tree); +static tree build_typed_selector_reference (tree, tree); +static tree build_selector_reference (tree); +static tree build_class_reference_decl (void); +static void add_class_reference (tree); +static tree build_protocol_template (void); +static tree build_descriptor_table_initializer (tree, tree); +static tree build_method_prototype_list_template (tree, int); +static tree build_method_prototype_template (void); +static int forwarding_offset (tree); +static tree encode_method_prototype (tree, tree); +static tree generate_descriptor_table (tree, const char *, int, tree, tree); +static void generate_method_descriptors (tree); +static tree build_tmp_function_decl (void); +static void hack_method_prototype (tree, tree); +static void generate_protocol_references (tree); +static void generate_protocols (void); +static void check_ivars (tree, tree); +static tree build_ivar_list_template (tree, int); +static tree build_method_list_template (tree, int); +static tree build_ivar_list_initializer (tree, tree); +static tree generate_ivars_list (tree, const char *, int, tree); +static tree build_dispatch_table_initializer (tree, tree); +static tree generate_dispatch_table (tree, const char *, int, tree); +static tree build_shared_structure_initializer (tree, tree, tree, tree, tree, + int, tree, tree, tree); +static void generate_category (tree); +static int is_objc_type_qualifier (tree); +static tree adjust_type_for_id_default (tree); +static tree check_duplicates (hash); +static tree receiver_is_class_object (tree); +static int check_methods (tree, tree, int); +static int conforms_to_protocol (tree, tree); +static void check_protocol (tree, const char *, const char *); +static void check_protocols (tree, const char *, const char *); +static tree encode_method_def (tree); +static void gen_declspecs (tree, char *, int); +static void generate_classref_translation_entry (tree); +static void handle_class_ref (tree); +static void generate_struct_by_value_array (void) ATTRIBUTE_NORETURN; -static void encode_complete_bitfield PARAMS ((int, tree, int)); -static void mark_referenced_methods PARAMS ((void)); +static void encode_complete_bitfield (int, tree, int); +static void mark_referenced_methods (void); /*** Private Interface (data) ***/ @@ -339,7 +324,7 @@ /* The OCTI_... enumeration itself is in objc/objc-act.h. */ tree objc_global_trees[OCTI_MAX]; -static void handle_impent PARAMS ((struct imp_entry *)); +static void handle_impent (struct imp_entry *); struct imp_entry *imp_list = 0; int imp_count = 0; /* `@implementation' */ @@ -375,7 +360,7 @@ the transition point between the two possibilities. */ static void -generate_struct_by_value_array () +generate_struct_by_value_array (void) { tree type; tree field_decl, field_decl_chain; @@ -406,12 +391,12 @@ chainon (field_decl_chain, field_decl); } finish_struct (type, field_decl_chain, NULL_TREE); - - aggregate_in_mem[i] = aggregate_value_p (type); + + aggregate_in_mem[i] = aggregate_value_p (type, 0); if (!aggregate_in_mem[i]) found = 1; } - + /* We found some structures that are returned in registers instead of memory so output the necessary data. */ if (found) @@ -420,21 +405,21 @@ if (!aggregate_in_mem[i]) break; printf ("#define OBJC_MAX_STRUCT_BY_VALUE %d\n\n", i); - + /* The first member of the structure is always 0 because we don't handle structures with 0 members */ printf ("static int struct_forward_array[] = {\n 0"); - + for (j = 1; j <= i; j++) printf (", %d", aggregate_in_mem[j]); printf ("\n};\n"); } - + exit (0); } bool -objc_init () +objc_init (void) { if (c_objc_common_init () == false) return false; @@ -485,7 +470,7 @@ } void -finish_file () +finish_file (void) { mark_referenced_methods (); c_objc_common_finish_file (); @@ -500,9 +485,7 @@ } static tree -define_decl (declarator, declspecs) - tree declarator; - tree declspecs; +define_decl (tree declarator, tree declspecs) { tree decl = start_decl (declarator, declspecs, 0, NULL_TREE); finish_decl (decl, NULL_TREE, NULL_TREE); @@ -522,10 +505,8 @@ `a' and `b' are of class types A and B such that B is a descendant of A. */ static tree -lookup_method_in_protocol_list (rproto_list, sel_name, class_meth) - tree rproto_list; - tree sel_name; - int class_meth; +lookup_method_in_protocol_list (tree rproto_list, tree sel_name, + int class_meth) { tree rproto, p; tree fnd = 0; @@ -557,9 +538,7 @@ } static tree -lookup_protocol_in_reflist (rproto_list, lproto) - tree rproto_list; - tree lproto; +lookup_protocol_in_reflist (tree rproto_list, tree lproto) { tree rproto, p; @@ -612,10 +591,7 @@ */ int -objc_comptypes (lhs, rhs, reflexive) - tree lhs; - tree rhs; - int reflexive; +objc_comptypes (tree lhs, tree rhs, int reflexive) { /* New clause for protocols. */ @@ -639,20 +615,20 @@ if (rhs_is_proto) { rproto_list = TYPE_PROTOCOL_LIST (rhs); - + if (!reflexive) { /* An assignment between objects of type 'id '; make sure the protocol on the lhs is supported by the object on the rhs. */ - for (lproto = lproto_list; lproto; + for (lproto = lproto_list; lproto; lproto = TREE_CHAIN (lproto)) { p = TREE_VALUE (lproto); rproto = lookup_protocol_in_reflist (rproto_list, p); if (!rproto) - warning + warning ("object does not conform to the `%s' protocol", IDENTIFIER_POINTER (PROTOCOL_NAME (p))); } @@ -664,20 +640,20 @@ of type 'id '. Check that either the protocol on the lhs is supported by the object on the rhs, or viceversa. */ - + /* Check if the protocol on the lhs is supported by the object on the rhs. */ - for (lproto = lproto_list; lproto; + for (lproto = lproto_list; lproto; lproto = TREE_CHAIN (lproto)) { p = TREE_VALUE (lproto); rproto = lookup_protocol_in_reflist (rproto_list, p); - + if (!rproto) { /* Check failed - check if the protocol on the rhs is supported by the object on the lhs. */ - for (rproto = rproto_list; rproto; + for (rproto = rproto_list; rproto; rproto = TREE_CHAIN (rproto)) { p = TREE_VALUE (rproto); @@ -768,10 +744,10 @@ tree rname = TYPE_NAME (TREE_TYPE (lhs)); tree rinter; tree rproto, rproto_list = TYPE_PROTOCOL_LIST (rhs); - + /* Make sure the protocol is supported by the object on the lhs. */ - for (rproto = rproto_list; rproto; + for (rproto = rproto_list; rproto; rproto = TREE_CHAIN (rproto)) { tree p = TREE_VALUE (rproto); @@ -791,9 +767,9 @@ lhs. */ if (!lproto) { - lproto_list = TYPE_PROTOCOL_LIST + lproto_list = TYPE_PROTOCOL_LIST (TREE_TYPE (lhs)); - lproto = lookup_protocol_in_reflist + lproto = lookup_protocol_in_reflist (lproto_list, p); } @@ -806,14 +782,14 @@ p); cat = CLASS_CATEGORY_LIST (cat); } - - rinter = lookup_interface (CLASS_SUPER_NAME + + rinter = lookup_interface (CLASS_SUPER_NAME (rinter)); } - + if (!lproto) warning ("class `%s' does not implement the `%s' protocol", - IDENTIFIER_POINTER (TYPE_NAME + IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (lhs))), IDENTIFIER_POINTER (PROTOCOL_NAME (p))); } @@ -857,7 +833,7 @@ } /* `id' = ` *' ` *' = `id': always allow it. - Please note that + Please note that 'Object *o = [[Object alloc] init]; falls in the case * = `id'. */ @@ -908,24 +884,20 @@ /* Called from c-decl.c before all calls to rest_of_decl_compilation. */ void -objc_check_decl (decl) - tree decl; +objc_check_decl (tree decl) { tree type = TREE_TYPE (decl); if (TREE_CODE (type) == RECORD_TYPE && TREE_STATIC_TEMPLATE (type) && type != constant_string_type) - error ("%H'%D' cannot be statically allocated", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%J'%D' cannot be statically allocated", decl, decl); } /* Implement static typing. At this point, we know we have an interface. */ tree -get_static_reference (interface, protocols) - tree interface; - tree protocols; +get_static_reference (tree interface, tree protocols) { tree type = xref_tag (RECORD_TYPE, interface); @@ -956,8 +928,7 @@ } tree -get_object_reference (protocols) - tree protocols; +get_object_reference (tree protocols) { tree type_decl = lookup_name (objc_id_id); tree type; @@ -1007,10 +978,8 @@ PROTO, the protocol to check, and LIST, a list of protocol it conforms to. */ -static void -check_protocol_recursively (proto, list) - tree proto; - tree list; +static void +check_protocol_recursively (tree proto, tree list) { tree p; @@ -1023,15 +992,14 @@ if (pp == proto) fatal_error ("protocol `%s' has circular dependency", - IDENTIFIER_POINTER (PROTOCOL_NAME (pp))); + IDENTIFIER_POINTER (PROTOCOL_NAME (pp))); if (pp) check_protocol_recursively (proto, PROTOCOL_LIST (pp)); } } static tree -lookup_and_install_protocols (protocols) - tree protocols; +lookup_and_install_protocols (tree protocols) { tree proto; tree prev = NULL; @@ -1067,10 +1035,7 @@ TYPE is its data type. */ static tree -create_builtin_decl (code, type, name) - enum tree_code code; - tree type; - const char *name; +create_builtin_decl (enum tree_code code, tree type, const char *name) { tree decl = build_decl (code, get_identifier (name), type); @@ -1091,7 +1056,7 @@ /* Find the decl for the constant string class. */ static void -setup_string_decl () +setup_string_decl (void) { if (!string_class_decl) { @@ -1106,14 +1071,14 @@ Model: - type_spec--------->sc_spec - (tree_list) (tree_list) - | | - | | - identifier_node identifier_node */ + type_spec--------->sc_spec + (tree_list) (tree_list) + | | + | | + identifier_node identifier_node */ static void -synth_module_prologue () +synth_module_prologue (void) { tree temp_type; tree super_p; @@ -1246,7 +1211,7 @@ /* Predefine the following data type: - struct STRING_OBJECT_CLASS_NAME + struct STRING_OBJECT_CLASS_NAME { Object isa; char *cString; @@ -1254,7 +1219,7 @@ }; */ static void -build_string_class_template () +build_string_class_template (void) { tree field_decl, field_decl_chain; @@ -1275,9 +1240,7 @@ /* Custom build_string which sets TREE_TYPE! */ static tree -my_build_string (len, str) - int len; - const char *str; +my_build_string (int len, const char *str) { return fix_string_type (build_string (len, str)); } @@ -1290,8 +1253,7 @@ class object. */ tree -build_objc_string_object (string) - tree string; +build_objc_string_object (tree string) { tree initlist, constructor; int length; @@ -1354,8 +1316,7 @@ static GTY(()) int num_static_inst; static tree -objc_add_static_instance (constructor, class_decl) - tree constructor, class_decl; +objc_add_static_instance (tree constructor, tree class_decl) { tree *chain, decl; char buf[256]; @@ -1394,8 +1355,7 @@ with type TYPE and elements ELTS. */ static tree -objc_build_constructor (type, elts) - tree type, elts; +objc_build_constructor (tree type, tree elts) { tree constructor, f, e; @@ -1439,7 +1399,7 @@ }; */ static void -build_objc_symtab_template () +build_objc_symtab_template (void) { tree field_decl, field_decl_chain, index; @@ -1494,8 +1454,7 @@ This is a CONSTRUCTOR. */ static tree -init_def_list (type) - tree type; +init_def_list (tree type) { tree expr, initlist = NULL_TREE; struct imp_entry *impent; @@ -1539,8 +1498,7 @@ /* Construct the initial value for all of _objc_symtab. */ static tree -init_objc_symtab (type) - tree type; +init_objc_symtab (tree type) { tree initlist; @@ -1585,7 +1543,7 @@ init_def_list can use them in a CONSTRUCTOR. */ static void -forward_declare_categories () +forward_declare_categories (void) { struct imp_entry *impent; tree sav = objc_implementation_context; @@ -1609,7 +1567,7 @@ and initialized appropriately. */ static void -generate_objc_symtab_decl () +generate_objc_symtab_decl (void) { tree sc_spec; @@ -1640,8 +1598,7 @@ } static tree -init_module_descriptor (type) - tree type; +init_module_descriptor (tree type) { tree initlist, expr; @@ -1678,8 +1635,8 @@ struct objc_module { ... } _OBJC_MODULE = { ... }; */ -static void -build_module_descriptor () +static rtx +build_module_descriptor (void) { tree decl_specs, field_decl, field_decl_chain; @@ -1791,7 +1748,7 @@ c_expand_expr_stmt (decelerator); - finish_function (0, 0); + finish_function (); if (!EMIT_LLVM) { rtx init_sym = XEXP (DECL_RTL (init_function_decl), 0); @@ -1806,7 +1763,7 @@ /* extern const char _OBJC_STRINGS[]; */ static void -generate_forward_declaration_to_string_table () +generate_forward_declaration_to_string_table (void) { tree sc_spec, decl_specs, expr_decl; @@ -1822,9 +1779,7 @@ /* Return the DECL of the string IDENT in the SECTION. */ static tree -get_objc_string_decl (ident, section) - tree ident; - enum string_section section; +get_objc_string_decl (tree ident, enum string_section section) { tree chain; @@ -1849,7 +1804,7 @@ for the array built. */ static void -generate_static_references () +generate_static_references (void) { tree decls = NULL_TREE, ident, decl_spec, expr_decl, expr = NULL_TREE; tree class_name, class, decl, initlist; @@ -1925,7 +1880,7 @@ /* Output all strings. */ static void -generate_strings () +generate_strings (void) { tree sc_spec, decl_specs, expr_decl; tree chain, string_expr; @@ -1979,7 +1934,7 @@ static GTY(()) int selector_reference_idx; static tree -build_selector_reference_decl () +build_selector_reference_decl (void) { tree decl, ident; char buf[256]; @@ -2008,8 +1963,7 @@ /* Just a handy wrapper for add_objc_string. */ static tree -build_selector (ident) - tree ident; +build_selector (tree ident) { tree expr = add_objc_string (ident, meth_var_names); if (flag_typed_selectors) @@ -2019,7 +1973,7 @@ } static void -build_selector_translation_table () +build_selector_translation_table (void) { tree sc_spec, decl_specs; tree chain, initlist = NULL_TREE; @@ -2079,7 +2033,7 @@ if (flag_next_runtime) finish_decl (decl, expr, NULL_TREE); - else + else { if (flag_typed_selectors) { @@ -2091,7 +2045,7 @@ nreverse (eltlist)); } initlist = tree_cons (NULL_TREE, expr, initlist); - + } } @@ -2111,8 +2065,7 @@ } static tree -get_proto_encoding (proto) - tree proto; +get_proto_encoding (tree proto) { tree encoding; if (proto) @@ -2139,8 +2092,7 @@ identifier_node that represent the selector. */ static tree -build_typed_selector_reference (ident, prototype) - tree ident, prototype; +build_typed_selector_reference (tree ident, tree prototype) { tree *chain = &sel_ref_chain; tree expr; @@ -2166,8 +2118,7 @@ } static tree -build_selector_reference (ident) - tree ident; +build_selector_reference (tree ident) { tree *chain = &sel_ref_chain; tree expr; @@ -2197,7 +2148,7 @@ static GTY(()) int class_reference_idx; static tree -build_class_reference_decl () +build_class_reference_decl (void) { tree decl, ident; char buf[256]; @@ -2227,8 +2178,7 @@ it. */ static void -add_class_reference (ident) - tree ident; +add_class_reference (tree ident) { tree chain; @@ -2256,8 +2206,7 @@ reference variable. */ tree -get_class_reference (ident) - tree ident; +get_class_reference (tree ident) { if (flag_next_runtime) { @@ -2296,9 +2245,7 @@ to decls for the strings. */ static tree -add_objc_string (ident, section) - tree ident; - enum string_section section; +add_objc_string (tree ident, enum string_section section) { tree *chain, decl; @@ -2331,8 +2278,7 @@ static GTY(()) int meth_var_types_idx; static tree -build_objc_string_decl (section) - enum string_section section; +build_objc_string_decl (enum string_section section) { tree decl, ident; char buf[256]; @@ -2366,9 +2312,7 @@ void -objc_declare_alias (alias_ident, class_ident) - tree alias_ident; - tree class_ident; +objc_declare_alias (tree alias_ident, tree class_ident) { if (is_class_name (class_ident) != class_ident) warning ("cannot find class `%s'", IDENTIFIER_POINTER (class_ident)); @@ -2379,8 +2323,7 @@ } void -objc_declare_class (ident_list) - tree ident_list; +objc_declare_class (tree ident_list) { tree list; @@ -2392,9 +2335,8 @@ if ((decl = lookup_name (ident))) { error ("`%s' redeclared as different kind of symbol", - IDENTIFIER_POINTER (ident)); - error ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + IDENTIFIER_POINTER (ident)); + error ("%Jprevious declaration of '%D'", decl, decl); } if (! is_class_name (ident)) @@ -2407,8 +2349,7 @@ } tree -is_class_name (ident) - tree ident; +is_class_name (tree ident) { tree chain; @@ -2431,19 +2372,17 @@ } tree -objc_is_id (ident) - tree ident; +objc_is_id (tree ident) { /* NB: This function may be called before the ObjC front-end has been initialized, in which case ID_TYPE will be NULL. */ - return (id_type && ident && TYPE_P (ident) && IS_ID (ident)) - ? id_type + return (id_type && ident && TYPE_P (ident) && IS_ID (ident)) + ? id_type : NULL_TREE; } tree -lookup_interface (ident) - tree ident; +lookup_interface (tree ident) { tree chain; @@ -2459,8 +2398,7 @@ and for @defs constructs. */ tree -get_class_ivars (interface) - tree interface; +get_class_ivars (tree interface) { tree my_name, super_name, ivar_chain; @@ -2515,8 +2453,7 @@ }; */ static tree -build_private_template (class) - tree class; +build_private_template (tree class) { tree ivar_context; @@ -2558,7 +2495,7 @@ }; */ static tree -build_protocol_template () +build_protocol_template (void) { tree decl_specs, field_decl, field_decl_chain; tree template; @@ -2616,9 +2553,7 @@ } static tree -build_descriptor_table_initializer (type, entries) - tree type; - tree entries; +build_descriptor_table_initializer (tree type, tree entries) { tree initlist = NULL_TREE; @@ -2651,15 +2586,13 @@ /* struct objc_method_prototype_list { int count; struct objc_method_prototype { - SEL name; - char *types; + SEL name; + char *types; } list[1]; }; */ static tree -build_method_prototype_list_template (list_type, size) - tree list_type; - int size; +build_method_prototype_list_template (tree list_type, int size) { tree objc_ivar_list_record; tree decl_specs, field_decl, field_decl_chain; @@ -2689,7 +2622,7 @@ } static tree -build_method_prototype_template () +build_method_prototype_template (void) { tree proto_record; tree decl_specs, field_decl, field_decl_chain; @@ -2719,8 +2652,7 @@ static int offset_is_register; static int -forwarding_offset (parm) - tree parm; +forwarding_offset (tree parm) { int offset_in_bytes; @@ -2767,9 +2699,7 @@ } static tree -encode_method_prototype (method_decl, func_decl) - tree method_decl; - tree func_decl; +encode_method_prototype (tree method_decl, tree func_decl) { tree parms; int stack_size, i; @@ -2813,7 +2743,7 @@ { encode_type_qualifiers (TREE_PURPOSE (TREE_TYPE (user_args))); user_args = TREE_CHAIN (user_args); - } + } /* Type. */ encode_type (TREE_TYPE (parms), @@ -2826,7 +2756,7 @@ /* Indicate register. */ if (offset_is_register) obstack_1grow (&util_obstack, '+'); - + obstack_grow (&util_obstack, buf, strlen (buf)); } @@ -2837,12 +2767,8 @@ } static tree -generate_descriptor_table (type, name, size, list, proto) - tree type; - const char *name; - int size; - tree list; - tree proto; +generate_descriptor_table (tree type, const char *name, int size, tree list, + tree proto) { tree sc_spec, decl_specs, decl, initlist; @@ -2863,8 +2789,7 @@ } static void -generate_method_descriptors (protocol) - tree protocol; +generate_method_descriptors (tree protocol) { tree initlist, chain, method_list_template; tree cast, variable_length_type; @@ -2887,7 +2812,7 @@ = build_method_prototype_list_template (objc_method_prototype_template, size); - initlist + initlist = build_descriptor_table_initializer (objc_method_prototype_template, chain); @@ -2927,12 +2852,12 @@ static GTY(()) int build_tmp_function_decl_xxx; static tree -build_tmp_function_decl () +build_tmp_function_decl (void) { tree decl_specs, expr_decl, parms; char buffer[80]; tree tmp_decl; - + /* struct objc_object *objc_xxx (id, SEL, ...); */ pushlevel (0); decl_specs = build_tree_list (NULL_TREE, objc_object_reference); @@ -2958,7 +2883,7 @@ tmp_decl = define_decl (expr_decl, decl_specs); DECL_SOURCE_LINE (tmp_decl) = 0; - + return tmp_decl; } @@ -2970,9 +2895,7 @@ given. */ static void -hack_method_prototype (nst_methods, tmp_decl) - tree nst_methods; - tree tmp_decl; +hack_method_prototype (tree nst_methods, tree tmp_decl) { tree parms; tree parm; @@ -3023,8 +2946,7 @@ } static void -generate_protocol_references (plist) - tree plist; +generate_protocol_references (tree plist) { tree lproto; @@ -3056,7 +2978,7 @@ @protocol() or from a class/category implementation). These statically allocated objects can be referred to via the static (that is, private to this module) symbols _OBJC_PROTOCOL_n. - + The statically allocated Protocol objects that we generate here need to be fixed up at runtime in order to be used: the 'isa' pointer of the objects need to be set up to point to the 'Protocol' @@ -3083,7 +3005,7 @@ and end up being fixed up multiple times at runtime inizialization. But that doesn't hurt, it's just a little inefficient. */ static void -generate_protocols () +generate_protocols (void) { tree p, tmp_decl, encoding; tree sc_spec, decl_specs, decl; @@ -3184,13 +3106,9 @@ } static tree -build_protocol_initializer (type, protocol_name, protocol_list, - instance_methods, class_methods) - tree type; - tree protocol_name; - tree protocol_list; - tree instance_methods; - tree class_methods; +build_protocol_initializer (tree type, tree protocol_name, + tree protocol_list, tree instance_methods, + tree class_methods) { tree initlist = NULL_TREE, expr; tree cast_type; @@ -3239,7 +3157,7 @@ }; */ static void -build_category_template () +build_category_template (void) { tree decl_specs, field_decl, field_decl_chain; @@ -3300,12 +3218,12 @@ }; */ static void -build_selector_template () +build_selector_template (void) { tree decl_specs, field_decl, field_decl_chain; - objc_selector_template + objc_selector_template = start_struct (RECORD_TYPE, get_identifier (UTAG_SELECTOR)); /* void *sel_id; */ @@ -3346,7 +3264,7 @@ }; */ static void -build_class_template () +build_class_template (void) { tree decl_specs, field_decl, field_decl_chain; @@ -3455,7 +3373,7 @@ /* struct objc_protocol **protocol_list; */ - decl_specs = build_tree_list (NULL_TREE, + decl_specs = build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE, get_identifier (UTAG_PROTOCOL))); field_decl @@ -3485,7 +3403,7 @@ /* Generate appropriate forward declarations for an implementation. */ static void -synth_forward_declarations () +synth_forward_declarations (void) { tree sc_spec, decl_specs, an_id; @@ -3518,20 +3436,13 @@ } static void -error_with_ivar (message, decl, rawdecl) - const char *message; - tree decl; - tree rawdecl; +error_with_ivar (const char *message, tree decl, tree rawdecl) { - error ("%H%s `%s'", &DECL_SOURCE_LOCATION (decl), - message, gen_declaration (rawdecl, errbuf)); - + error ("%J%s `%s'", decl, message, gen_declaration (rawdecl, errbuf)); } static void -check_ivars (inter, imp) - tree inter; - tree imp; +check_ivars (tree inter, tree imp) { tree intdecls = CLASS_IVARS (inter); tree impdecls = CLASS_IVARS (imp); @@ -3588,7 +3499,7 @@ This needs to be done just once per compilation. */ static tree -build_super_template () +build_super_template (void) { tree record, decl_specs, field_decl, field_decl_chain; @@ -3628,7 +3539,7 @@ }; */ static tree -build_ivar_template () +build_ivar_template (void) { tree objc_ivar_id, objc_ivar_record; tree decl_specs, field_decl, field_decl_chain; @@ -3671,9 +3582,7 @@ }; */ static tree -build_ivar_list_template (list_type, size) - tree list_type; - int size; +build_ivar_list_template (tree list_type, int size) { tree objc_ivar_list_record; tree decl_specs, field_decl, field_decl_chain; @@ -3709,9 +3618,7 @@ }; */ static tree -build_method_list_template (list_type, size) - tree list_type; - int size; +build_method_list_template (tree list_type, int size) { tree objc_ivar_list_record; tree decl_specs, field_decl, field_decl_chain; @@ -3722,7 +3629,7 @@ decl_specs = build_tree_list - (NULL_TREE, + (NULL_TREE, xref_tag (RECORD_TYPE, get_identifier (UTAG_METHOD_PROTOTYPE_LIST))); field_decl @@ -3753,9 +3660,7 @@ } static tree -build_ivar_list_initializer (type, field_decl) - tree type; - tree field_decl; +build_ivar_list_initializer (tree type, tree field_decl) { tree initlist = NULL_TREE; @@ -3790,7 +3695,7 @@ /* Set offset. */ ivar = tree_cons (NULL_TREE, byte_position (field_decl), ivar); - initlist = tree_cons (NULL_TREE, + initlist = tree_cons (NULL_TREE, objc_build_constructor (type, nreverse (ivar)), initlist); @@ -3803,11 +3708,7 @@ } static tree -generate_ivars_list (type, name, size, list) - tree type; - const char *name; - int size; - tree list; +generate_ivars_list (tree type, const char *name, int size, tree list) { tree sc_spec, decl_specs, decl, initlist; @@ -3828,7 +3729,7 @@ } static void -generate_ivar_lists () +generate_ivar_lists (void) { tree initlist, ivar_list_template, chain; tree cast, variable_length_type; @@ -3884,9 +3785,7 @@ } static tree -build_dispatch_table_initializer (type, entries) - tree type; - tree entries; +build_dispatch_table_initializer (tree type, tree entries) { tree initlist = NULL_TREE; @@ -3908,12 +3807,12 @@ meth_var_types), elemlist); - elemlist = tree_cons (NULL_TREE, + elemlist = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, METHOD_DEFINITION (entries), 1), elemlist); - initlist = tree_cons (NULL_TREE, + initlist = tree_cons (NULL_TREE, objc_build_constructor (type, nreverse (elemlist)), initlist); @@ -3929,12 +3828,12 @@ inane warnings, the definition of the dispatch table entries were changed from: - struct objc_method { SEL _cmd; ...; id (*_imp)(); }; + struct objc_method { SEL _cmd; ...; id (*_imp)(); }; to: - struct objc_method { SEL _cmd; ...; void *_imp; }; */ + struct objc_method { SEL _cmd; ...; void *_imp; }; */ static tree -build_method_template () +build_method_template (void) { tree _SLT_record; tree decl_specs, field_decl, field_decl_chain; @@ -3971,11 +3870,7 @@ static tree -generate_dispatch_table (type, name, size, list) - tree type; - const char *name; - int size; - tree list; +generate_dispatch_table (tree type, const char *name, int size, tree list) { tree sc_spec, decl_specs, decl, initlist; @@ -3997,7 +3892,7 @@ } static void -mark_referenced_methods () +mark_referenced_methods (void) { struct imp_entry *impent; tree chain; @@ -4007,20 +3902,21 @@ chain = CLASS_CLS_METHODS (impent->imp_context); while (chain) { - cgraph_mark_needed_node (cgraph_node (METHOD_DEFINITION (chain)), 1); + cgraph_mark_needed_node (cgraph_node (METHOD_DEFINITION (chain))); chain = TREE_CHAIN (chain); } + chain = CLASS_NST_METHODS (impent->imp_context); while (chain) { - cgraph_mark_needed_node (cgraph_node (METHOD_DEFINITION (chain)), 1); + cgraph_mark_needed_node (cgraph_node (METHOD_DEFINITION (chain))); chain = TREE_CHAIN (chain); } } } static void -generate_dispatch_tables () +generate_dispatch_tables (void) { tree initlist, chain, method_list_template; tree cast, variable_length_type; @@ -4088,8 +3984,7 @@ } static tree -generate_protocol_list (i_or_p) - tree i_or_p; +generate_protocol_list (tree i_or_p) { tree initlist, decl_specs, sc_spec; tree refs_decl, expr_decl, lproto, e, plist; @@ -4175,14 +4070,9 @@ } static tree -build_category_initializer (type, cat_name, class_name, - instance_methods, class_methods, protocol_list) - tree type; - tree cat_name; - tree class_name; - tree instance_methods; - tree class_methods; - tree protocol_list; +build_category_initializer (tree type, tree cat_name, tree class_name, + tree instance_methods, tree class_methods, + tree protocol_list) { tree initlist = NULL_TREE, expr; @@ -4246,17 +4136,10 @@ }; */ static tree -build_shared_structure_initializer (type, isa, super, name, size, status, - dispatch_table, ivar_list, protocol_list) - tree type; - tree isa; - tree super; - tree name; - tree size; - int status; - tree dispatch_table; - tree ivar_list; - tree protocol_list; +build_shared_structure_initializer (tree type, tree isa, tree super, + tree name, tree size, int status, + tree dispatch_table, tree ivar_list, + tree protocol_list) { tree initlist = NULL_TREE, expr; @@ -4339,8 +4222,7 @@ /* static struct objc_category _OBJC_CATEGORY_ = { ... }; */ static void -generate_category (cat) - tree cat; +generate_category (tree cat) { tree sc_spec, decl_specs, decl; tree initlist, cat_name_expr, class_name_expr; @@ -4390,7 +4272,7 @@ static struct objc_class _OBJC_CLASS_Foo={ ... }; */ static void -generate_shared_structures () +generate_shared_structures (void) { tree sc_spec, decl_specs, decl; tree name_expr, super_expr, root_expr; @@ -4493,9 +4375,7 @@ } static tree -synth_id_with_class_suffix (preamble, ctxt) - const char *preamble; - tree ctxt; +synth_id_with_class_suffix (const char *preamble, tree ctxt) { char *string; if (TREE_CODE (ctxt) == CLASS_IMPLEMENTATION_TYPE @@ -4527,13 +4407,12 @@ } else abort (); - + return get_identifier (string); } static int -is_objc_type_qualifier (node) - tree node; +is_objc_type_qualifier (tree node) { return (TREE_CODE (node) == IDENTIFIER_NODE && (node == ridpointers [(int) RID_CONST] @@ -4550,8 +4429,7 @@ type of id (otherwise grokdeclarator will default to int). */ static tree -adjust_type_for_id_default (type) - tree type; +adjust_type_for_id_default (tree type) { tree declspecs, chain; @@ -4567,7 +4445,7 @@ chain = TREE_CHAIN (chain)) { if (TYPED_OBJECT (TREE_VALUE (chain)) - && !(TREE_VALUE (type) + && !(TREE_VALUE (type) && TREE_CODE (TREE_VALUE (type)) == INDIRECT_REF)) error ("can not use an object as parameter to a method\n"); if (!is_objc_type_qualifier (TREE_VALUE (chain))) @@ -4580,28 +4458,25 @@ } /* Usage: - keyworddecl: - selector ':' '(' typename ')' identifier - + keyworddecl: + selector ':' '(' typename ')' identifier + Purpose: - Transform an Objective-C keyword argument into - the C equivalent parameter declarator. - + Transform an Objective-C keyword argument into + the C equivalent parameter declarator. + In: key_name, an "identifier_node" (optional). - arg_type, a "tree_list" (optional). - arg_name, an "identifier_node". - + arg_type, a "tree_list" (optional). + arg_name, an "identifier_node". + Note: It would be really nice to strongly type the preceding - arguments in the function prototype; however, then I - could not use the "accessor" macros defined in "tree.h". - + arguments in the function prototype; however, then I + could not use the "accessor" macros defined in "tree.h". + Out: an instance of "keyword_decl". */ tree -build_keyword_decl (key_name, arg_type, arg_name) - tree key_name; - tree arg_type; - tree arg_name; +build_keyword_decl (tree key_name, tree arg_type, tree arg_name) { tree keyword_decl; @@ -4620,8 +4495,7 @@ /* Given a chain of keyword_decl's, synthesize the full keyword selector. */ static tree -build_keyword_selector (selector) - tree selector; +build_keyword_selector (tree selector) { int len = 0; tree key_chain, key_name; @@ -4668,11 +4542,8 @@ /* Used for declarations and definitions. */ tree -build_method_decl (code, ret_type, selector, add_args) - enum tree_code code; - tree ret_type; - tree selector; - tree add_args; +build_method_decl (enum tree_code code, tree ret_type, tree selector, + tree add_args) { tree method_decl; @@ -4711,10 +4582,7 @@ the method call are done together. */ static tree -get_arg_type_list (meth, context, superflag) - tree meth; - int context; - int superflag; +get_arg_type_list (tree meth, int context, int superflag) { tree arglist, akey; @@ -4754,8 +4622,7 @@ } static tree -check_duplicates (hsh) - hash hsh; +check_duplicates (hash hsh) { tree meth = NULL_TREE; @@ -4786,8 +4653,7 @@ used. */ static tree -receiver_is_class_object (receiver) - tree receiver; +receiver_is_class_object (tree receiver) { tree chain, exp, arg; @@ -4798,7 +4664,7 @@ { return CLASS_NAME (objc_implementation_context); } - + if (flag_next_runtime) { /* The receiver is a variable created by @@ -4814,7 +4680,7 @@ { /* The receiver is a function call that returns an id. Check if it is a call to objc_getClass, if so, pick up the class name. */ - if (TREE_CODE (receiver) == CALL_EXPR + if (TREE_CODE (receiver) == CALL_EXPR && (exp = TREE_OPERAND (receiver, 0)) && TREE_CODE (exp) == ADDR_EXPR && (exp = TREE_OPERAND (exp, 0)) @@ -4843,7 +4709,7 @@ static tree current_objc_message_selector = 0; tree -objc_message_selector () +objc_message_selector (void) { return current_objc_message_selector; } @@ -4856,8 +4722,7 @@ (*((*)())_msgSuper)(receiver, selTransTbl[n], ...); */ tree -build_message_expr (mess) - tree mess; +build_message_expr (tree mess) { tree receiver = TREE_PURPOSE (mess); tree sel_name; @@ -4907,15 +4772,14 @@ 'build_message_expr' for non-template functions. In the case of C++ template functions, it is called from 'build_expr_from_tree' (in decl2.c) after RECEIVER and METHOD_PARAMS have been expanded. */ - + tree -finish_message_expr (receiver, sel_name, method_params) - tree receiver, sel_name, method_params; -{ +finish_message_expr (tree receiver, tree sel_name, tree method_params) +{ tree method_prototype = NULL_TREE, class_ident = NULL_TREE; tree selector, self_object, retval; int statically_typed = 0, statically_allocated = 0; - + /* Determine receiver type. */ tree rtype = TREE_TYPE (receiver); int super = IS_SUPER (rtype); @@ -5106,9 +4970,9 @@ /* We think we have an instance...loophole: extern id Object; */ hsh = hash_lookup (nst_method_hash_list, sel_name); - + if (!hsh) - /* For various loopholes */ + /* For various loopholes */ hsh = hash_lookup (cls_method_hash_list, sel_name); method_prototype = check_duplicates (hsh); @@ -5148,10 +5012,9 @@ If SUPER_FLAG is nonzero, we look up the superclass's method. */ static tree -build_objc_method_call (super_flag, method_prototype, lookup_object, object, - selector, method_params) - int super_flag; - tree method_prototype, lookup_object, object, selector, method_params; +build_objc_method_call (int super_flag, tree method_prototype, + tree lookup_object, tree object, tree selector, + tree method_params) { tree sender = (super_flag ? umsg_super_decl : umsg_decl); tree rcv_p = (super_flag @@ -5249,8 +5112,7 @@ } static void -build_protocol_reference (p) - tree p; +build_protocol_reference (tree p) { tree decl, ident, ptype; @@ -5285,8 +5147,7 @@ /* This function is called by the parser when (and only when) a @protocol() expression is found, in order to compile it. */ tree -build_protocol_expr (protoname) - tree protoname; +build_protocol_expr (tree protoname) { tree expr; tree p = lookup_protocol (protoname); @@ -5323,10 +5184,10 @@ /* This type is a struct containing the fields of a Protocol object. (Cfr. protocol_type instead is the type of a pointer to such a struct). */ - tree protocol_struct_type = xref_tag + tree protocol_struct_type = xref_tag (RECORD_TYPE, get_identifier (PROTOCOL_OBJECT_CLASS_NAME)); tree *chain; - + /* Look for the list of Protocol statically allocated instances to fixup at runtime. Create a new list to hold Protocol statically allocated instances, if the list is not found. At @@ -5341,13 +5202,13 @@ add_objc_string (TYPE_NAME (protocol_struct_type), class_names); } - + /* Add this statically allocated instance to the Protocol list. */ - TREE_PURPOSE (*chain) = tree_cons (NULL_TREE, + TREE_PURPOSE (*chain) = tree_cons (NULL_TREE, PROTOCOL_FORWARD_DECL (p), TREE_PURPOSE (*chain)); } - + return expr; } @@ -5356,8 +5217,7 @@ is found, in order to compile it. It is only called by the parser and only to compile a @selector(). */ tree -build_selector_expr (selnamelist) - tree selnamelist; +build_selector_expr (tree selnamelist) { tree selname; @@ -5381,20 +5241,20 @@ /* First try with instance methods. */ hsh = hash_lookup (nst_method_hash_list, selname); - + /* If not found, try with class methods. */ if (!hsh) { hsh = hash_lookup (cls_method_hash_list, selname); } - + /* If still not found, print out a warning. */ if (!hsh) { warning ("undeclared selector `%s'", IDENTIFIER_POINTER (selname)); } } - + if (flag_typed_selectors) return build_typed_selector_reference (selname, 0); @@ -5403,8 +5263,7 @@ } tree -build_encode_expr (type) - tree type; +build_encode_expr (tree type) { tree result; const char *string; @@ -5421,8 +5280,7 @@ } tree -build_ivar_reference (id) - tree id; +build_ivar_reference (tree id) { if (TREE_CODE (objc_method_context) == CLASS_METHOD_DECL) { @@ -5446,20 +5304,19 @@ /* Compute a hash value for a given method SEL_NAME. */ static size_t -hash_func (sel_name) - tree sel_name; +hash_func (tree sel_name) { - const unsigned char *s + const unsigned char *s = (const unsigned char *)IDENTIFIER_POINTER (sel_name); size_t h = 0; - + while (*s) h = h * 67 + *s++ - 113; - return h; + return h; } - + static void -hash_init () +hash_init (void) { nst_method_hash_list = ggc_calloc (SIZEHASHTABLE, sizeof (hash)); cls_method_hash_list = ggc_calloc (SIZEHASHTABLE, sizeof (hash)); @@ -5471,9 +5328,7 @@ entry's key (method) for comparison. */ static void -hash_enter (hashlist, method) - hash *hashlist; - tree method; +hash_enter (hash *hashlist, tree method) { hash obj; int slot = hash_func (METHOD_SEL_NAME (method)) % SIZEHASHTABLE; @@ -5487,9 +5342,7 @@ } static hash -hash_lookup (hashlist, sel_name) - hash *hashlist; - tree sel_name; +hash_lookup (hash *hashlist, tree sel_name) { hash target; @@ -5506,9 +5359,7 @@ } static void -hash_add_attr (entry, value) - hash entry; - tree value; +hash_add_attr (hash entry, tree value) { attr obj; @@ -5520,9 +5371,7 @@ } static tree -lookup_method (mchain, method) - tree mchain; - tree method; +lookup_method (tree mchain, tree method) { tree key; @@ -5542,9 +5391,7 @@ } static tree -lookup_instance_method_static (interface, ident) - tree interface; - tree ident; +lookup_instance_method_static (tree interface, tree ident) { tree inter = interface; tree chain = CLASS_NST_METHODS (inter); @@ -5595,9 +5442,7 @@ } static tree -lookup_class_method_static (interface, ident) - tree interface; - tree ident; +lookup_class_method_static (tree interface, tree ident) { tree inter = interface; tree chain = CLASS_CLS_METHODS (inter); @@ -5654,9 +5499,7 @@ } tree -add_class_method (class, method) - tree class; - tree method; +add_class_method (tree class, tree method) { tree mth; hash hsh; @@ -5696,9 +5539,7 @@ } tree -add_instance_method (class, method) - tree class; - tree method; +add_instance_method (tree class, tree method) { tree mth; hash hsh; @@ -5738,8 +5579,7 @@ } static tree -add_class (class) - tree class; +add_class (tree class) { /* Put interfaces on list in reverse order. */ TREE_CHAIN (class) = interface_chain; @@ -5748,9 +5588,7 @@ } static void -add_category (class, category) - tree class; - tree category; +add_category (tree class, tree category) { /* Put categories on list in reverse order. */ tree cat = CLASS_CATEGORY_LIST (class); @@ -5774,12 +5612,8 @@ PUBLIC is 1 for public, 0 for protected, and 2 for private. */ tree -add_instance_variable (class, public, declarator, declspecs, width) - tree class; - int public; - tree declarator; - tree declspecs; - tree width; +add_instance_variable (tree class, int public, tree declarator, + tree declspecs, tree width) { tree field_decl, raw_decl; @@ -5824,9 +5658,7 @@ } tree -is_ivar (decl_chain, ident) - tree decl_chain; - tree ident; +is_ivar (tree decl_chain, tree ident) { for ( ; decl_chain; decl_chain = TREE_CHAIN (decl_chain)) if (DECL_NAME (decl_chain) == ident) @@ -5837,8 +5669,7 @@ /* True if the ivar is private and we are not in its implementation. */ int -is_private (decl) - tree decl; +is_private (tree decl) { if (TREE_PRIVATE (decl) && ! is_ivar (CLASS_IVARS (implementation_template), DECL_NAME (decl))) @@ -5854,9 +5685,7 @@ /* We have an instance variable reference;, check to see if it is public. */ int -is_public (expr, identifier) - tree expr; - tree identifier; +is_public (tree expr, tree identifier) { tree basetype = TREE_TYPE (expr); enum tree_code code = TREE_CODE (basetype); @@ -5910,10 +5739,7 @@ /* Make sure all entries in CHAIN are also in LIST. */ static int -check_methods (chain, list, mtype) - tree chain; - tree list; - int mtype; +check_methods (tree chain, tree list, int mtype) { int first = 1; @@ -5947,9 +5773,7 @@ /* Check if CLASS, or its superclasses, explicitly conforms to PROTOCOL. */ static int -conforms_to_protocol (class, protocol) - tree class; - tree protocol; +conforms_to_protocol (tree class, tree protocol) { if (TREE_CODE (protocol) == PROTOCOL_INTERFACE_TYPE) { @@ -5971,14 +5795,11 @@ return 1; } -/* Make sure all methods in CHAIN are accessible as MTYPE methods in +/* Make sure all methods in CHAIN are accessible as MTYPE methods in CONTEXT. This is one of two mechanisms to check protocol integrity. */ static int -check_methods_accessible (chain, context, mtype) - tree chain; - tree context; - int mtype; +check_methods_accessible (tree chain, tree context, int mtype) { int first = 1; tree list; @@ -5995,17 +5816,17 @@ list = CLASS_NST_METHODS (context); if (lookup_method (list, chain)) - break; + break; else if (TREE_CODE (context) == CLASS_IMPLEMENTATION_TYPE || TREE_CODE (context) == CLASS_INTERFACE_TYPE) - context = (CLASS_SUPER_NAME (context) + context = (CLASS_SUPER_NAME (context) ? lookup_interface (CLASS_SUPER_NAME (context)) : NULL_TREE); else if (TREE_CODE (context) == CATEGORY_IMPLEMENTATION_TYPE || TREE_CODE (context) == CATEGORY_INTERFACE_TYPE) - context = (CLASS_NAME (context) + context = (CLASS_NAME (context) ? lookup_interface (CLASS_NAME (context)) : NULL_TREE); else @@ -6040,12 +5861,9 @@ /* Check whether the current interface (accessible via 'objc_implementation_context') actually implements protocol P, along with any protocols that P inherits. */ - + static void -check_protocol (p, type, name) - tree p; - const char *type; - const char *name; +check_protocol (tree p, const char *type, const char *name) { if (TREE_CODE (p) == PROTOCOL_INTERFACE_TYPE) { @@ -6075,7 +5893,7 @@ warning ("%s `%s' does not fully implement the `%s' protocol", type, name, IDENTIFIER_POINTER (PROTOCOL_NAME (p))); } - + /* Check protocols recursively. */ if (PROTOCOL_LIST (p)) { @@ -6083,7 +5901,7 @@ tree super_class = lookup_interface (CLASS_SUPER_NAME (implementation_template)); - while (subs) + while (subs) { tree sub = TREE_VALUE (subs); @@ -6095,16 +5913,13 @@ } } } - + /* Check whether the current interface (accessible via 'objc_implementation_context') actually implements the protocols listed in PROTO_LIST. */ - + static void -check_protocols (proto_list, type, name) - tree proto_list; - const char *type; - const char *name; +check_protocols (tree proto_list, const char *type, const char *name) { for ( ; proto_list; proto_list = TREE_CHAIN (proto_list)) { @@ -6120,11 +5935,8 @@ CATEGORY_INTERFACE_TYPE, or CATEGORY_IMPLEMENTATION_TYPE. */ tree -start_class (code, class_name, super_name, protocol_list) - enum tree_code code; - tree class_name; - tree super_name; - tree protocol_list; +start_class (enum tree_code code, tree class_name, tree super_name, + tree protocol_list) { tree class, decl; @@ -6147,8 +5959,7 @@ { error ("`%s' redeclared as different kind of symbol", IDENTIFIER_POINTER (class_name)); - error ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jprevious declaration of '%D'", decl, decl); } if (code == CLASS_IMPLEMENTATION_TYPE) @@ -6208,7 +6019,7 @@ else if (! super_name) { - CLASS_SUPER_NAME (objc_implementation_context) + CLASS_SUPER_NAME (objc_implementation_context) = CLASS_SUPER_NAME (implementation_template); } } @@ -6281,8 +6092,7 @@ } tree -continue_class (class) - tree class; +continue_class (tree class) { if (TREE_CODE (class) == CLASS_IMPLEMENTATION_TYPE || TREE_CODE (class) == CATEGORY_IMPLEMENTATION_TYPE) @@ -6345,8 +6155,7 @@ /* This is called once we see the "@end" in an interface/implementation. */ void -finish_class (class) - tree class; +finish_class (tree class) { if (TREE_CODE (class) == CLASS_IMPLEMENTATION_TYPE) { @@ -6412,8 +6221,7 @@ } static tree -add_protocol (protocol) - tree protocol; +add_protocol (tree protocol) { /* Put protocol on list in reverse order. */ TREE_CHAIN (protocol) = protocol_chain; @@ -6422,8 +6230,7 @@ } static tree -lookup_protocol (ident) - tree ident; +lookup_protocol (tree ident) { tree chain; @@ -6438,8 +6245,7 @@ they are already declared or defined, the function has no effect. */ void -objc_declare_protocols (names) - tree names; +objc_declare_protocols (tree names) { tree list; @@ -6462,10 +6268,7 @@ } tree -start_protocol (code, name, list) - enum tree_code code; - tree name; - tree list; +start_protocol (enum tree_code code, tree name, tree list) { tree protocol; @@ -6505,8 +6308,7 @@ } void -finish_protocol (protocol) - tree protocol ATTRIBUTE_UNUSED; +finish_protocol (tree protocol ATTRIBUTE_UNUSED) { } @@ -6515,8 +6317,7 @@ ??? What is the FORMAT? Someone please document this! */ static void -encode_type_qualifiers (declspecs) - tree declspecs; +encode_type_qualifiers (tree declspecs) { tree spec; @@ -6542,10 +6343,7 @@ /* Encode a pointer type. */ static void -encode_pointer (type, curtype, format) - tree type; - int curtype; - int format; +encode_pointer (tree type, int curtype, int format) { tree pointer_to = TREE_TYPE (type); @@ -6604,10 +6402,7 @@ } static void -encode_array (type, curtype, format) - tree type; - int curtype; - int format; +encode_array (tree type, int curtype, int format) { tree an_int_cst = TYPE_SIZE (type); tree array_of = TREE_TYPE (type); @@ -6631,12 +6426,8 @@ } static void -encode_aggregate_within (type, curtype, format, left, right) - tree type; - int curtype; - int format; - int left; - int right; +encode_aggregate_within (tree type, int curtype, int format, int left, + int right) { /* The RECORD_TYPE may in fact be a typedef! For purposes of encoding, we need the real underlying enchilada. */ @@ -6752,10 +6543,7 @@ } static void -encode_aggregate (type, curtype, format) - tree type; - int curtype; - int format; +encode_aggregate (tree type, int curtype, int format) { enum tree_code code = TREE_CODE (type); @@ -6792,8 +6580,7 @@ hand generating this string (which is tedious). */ static void -encode_bitfield (width) - int width; +encode_bitfield (int width) { char buffer[40]; sprintf (buffer, "b%d", width); @@ -6803,10 +6590,7 @@ /* FORMAT will be OBJC_ENCODE_INLINE_DEFS or OBJC_ENCODE_DONT_INLINE_DEFS. */ static void -encode_type (type, curtype, format) - tree type; - int curtype; - int format; +encode_type (tree type, int curtype, int format) { enum tree_code code = TREE_CODE (type); @@ -6879,10 +6663,7 @@ } static void -encode_complete_bitfield (position, type, size) - int position; - tree type; - int size; +encode_complete_bitfield (int position, tree type, int size) { enum tree_code code = TREE_CODE (type); char buffer[40]; @@ -6938,10 +6719,7 @@ } static void -encode_field_decl (field_decl, curtype, format) - tree field_decl; - int curtype; - int format; +encode_field_decl (tree field_decl, int curtype, int format) { tree type; @@ -6969,8 +6747,7 @@ } static tree -objc_expr_last (complex_expr) - tree complex_expr; +objc_expr_last (tree complex_expr) { tree next; @@ -6985,8 +6762,7 @@ - synthesize the first two arguments, "self" and "_cmd". */ void -start_method_def (method) - tree method; +start_method_def (tree method) { tree decl_specs; @@ -7070,21 +6846,17 @@ } static void -warn_with_method (message, mtype, method) - const char *message; - int mtype; - tree method; +warn_with_method (const char *message, int mtype, tree method) { /* Add a readable method name to the warning. */ - warning ("%H%s `%c%s'", &DECL_SOURCE_LOCATION (method), - message, mtype, gen_method_decl (method, errbuf)); + warning ("%J%s `%c%s'", method, message, mtype, + gen_method_decl (method, errbuf)); } /* Return 1 if METHOD is consistent with PROTO. */ static int -comp_method_with_proto (method, proto) - tree method, proto; +comp_method_with_proto (tree method, tree proto) { /* Create a function template node at most once. */ if (!function1_template) @@ -7103,8 +6875,7 @@ /* Return 1 if PROTO1 is consistent with PROTO2. */ static int -comp_proto_with_proto (proto0, proto1) - tree proto0, proto1; +comp_proto_with_proto (tree proto0, tree proto1) { /* Create a couple of function_template nodes at most once. */ if (!function1_template) @@ -7130,8 +6901,7 @@ - If we have a prototype, check for type consistency. */ static void -really_start_method (method, parmlist) - tree method, parmlist; +really_start_method (tree method, tree parmlist) { tree sc_spec, ret_spec, ret_decl, decl_specs; tree method_decl, method_id; @@ -7217,11 +6987,11 @@ /* The following routine is always called...this "architecture" is to accommodate "old-style" variable length selectors. - + - a:a b:b // prototype ; id c; id d; // old-style. */ void -continue_method_def () +continue_method_def (void) { tree parmlist; @@ -7243,7 +7013,7 @@ /* Called by the parser, from the `pushlevel' production. */ void -add_objc_decls () +add_objc_decls (void) { if (!UOBJC_SUPER_decl) { @@ -7267,7 +7037,7 @@ } */ tree -get_super_receiver () +get_super_receiver (void) { if (objc_method_context) { @@ -7316,7 +7086,7 @@ included , leaving 'struct objc_class' an incomplete type. */ super_class - = build_component_ref (build_indirect_ref + = build_component_ref (build_indirect_ref (build_c_cast (id_type, super_class), "->"), get_identifier ("isa")); } @@ -7354,8 +7124,7 @@ } static tree -encode_method_def (func_decl) - tree func_decl; +encode_method_def (tree func_decl) { tree parms; int stack_size; @@ -7411,16 +7180,16 @@ } static void -objc_expand_function_end () +objc_expand_function_end (void) { METHOD_ENCODING (objc_method_context) = encode_method_def (current_function_decl); } void -finish_method_def () +finish_method_def (void) { lang_expand_function_end = objc_expand_function_end; - finish_function (0, 1); + finish_function (); lang_expand_function_end = NULL; /* Required to implement _msgSuper. This must be done AFTER finish_function, @@ -7430,8 +7199,7 @@ #if 0 int -lang_report_error_function (decl) - tree decl; +lang_report_error_function (tree decl) { if (objc_method_context) { @@ -7446,8 +7214,7 @@ #endif static int -is_complex_decl (type) - tree type; +is_complex_decl (tree type) { return (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == FUNCTION_TYPE @@ -7460,9 +7227,7 @@ static char tmpbuf[256]; static void -adorn_decl (decl, str) - tree decl; - char *str; +adorn_decl (tree decl, char *str) { enum tree_code code = TREE_CODE (decl); @@ -7562,10 +7327,7 @@ } static char * -gen_declarator (decl, buf, name) - tree decl; - char *buf; - const char *name; +gen_declarator (tree decl, char *buf, const char *name) { if (decl) { @@ -7654,10 +7416,7 @@ } static void -gen_declspecs (declspecs, buf, raw) - tree declspecs; - char *buf; - int raw; +gen_declspecs (tree declspecs, char *buf, int raw) { if (raw) { @@ -7898,7 +7657,7 @@ } } break; - + default: break; } @@ -7909,9 +7668,7 @@ buffer, overwriting the buffer. */ static char * -gen_declaration (atype_or_adecl, buf) - tree atype_or_adecl; - char *buf; +gen_declaration (tree atype_or_adecl, char *buf) { buf[0] = '\0'; gen_declaration_1 (atype_or_adecl, buf); @@ -7922,9 +7679,7 @@ given buffer. */ static void -gen_declaration_1 (atype_or_adecl, buf) - tree atype_or_adecl; - char *buf; +gen_declaration_1 (tree atype_or_adecl, char *buf) { char declbuf[256]; @@ -8013,9 +7768,7 @@ buffer (overwriting) and return a pointer to the buffer. */ static char * -gen_method_decl (method, buf) - tree method; - char *buf; +gen_method_decl (tree method, char *buf) { tree chain; @@ -8082,9 +7835,7 @@ prints out an @interface declaration of all classes compiled in this run); potentially useful for debugging the compiler too. */ static void -dump_interface (fp, chain) - FILE *fp; - tree chain; +dump_interface (FILE *fp, tree chain) { /* FIXME: A heap overflow here whenever a method (or ivar) declaration is so long that it doesn't fit in the buffer. The @@ -8098,13 +7849,13 @@ fprintf (fp, "\n at interface %s", my_name); - /* CLASS_SUPER_NAME is used to store the superclass name for + /* CLASS_SUPER_NAME is used to store the superclass name for classes, and the category name for categories. */ if (CLASS_SUPER_NAME (chain)) { const char *name = IDENTIFIER_POINTER (CLASS_SUPER_NAME (chain)); - - if (TREE_CODE (chain) == CATEGORY_IMPLEMENTATION_TYPE + + if (TREE_CODE (chain) == CATEGORY_IMPLEMENTATION_TYPE || TREE_CODE (chain) == CATEGORY_INTERFACE_TYPE) { fprintf (fp, " (%s)\n", name); @@ -8147,8 +7898,7 @@ /* Demangle function for Objective-C */ static const char * -objc_demangle (mangled) - const char *mangled; +objc_demangle (const char *mangled) { char *demangled, *cp; @@ -8203,15 +7953,13 @@ } const char * -objc_printable_name (decl, kind) - tree decl; - int kind ATTRIBUTE_UNUSED; +objc_printable_name (tree decl, int kind ATTRIBUTE_UNUSED) { return objc_demangle (IDENTIFIER_POINTER (DECL_NAME (decl))); } static void -init_objc () +init_objc (void) { gcc_obstack_init (&util_obstack); util_firstobj = (char *) obstack_finish (&util_obstack); @@ -8222,7 +7970,7 @@ } static void -finish_objc () +finish_objc (void) { struct imp_entry *impent; tree chain; @@ -8258,7 +8006,7 @@ UOBJC_CLASS_decl = impent->class_decl; UOBJC_METACLASS_decl = impent->meta_decl; - + /* Dump the @interface of each class as we compile it, if the -gen-decls option is in use. TODO: Dump the classes in the order they were found, rather than in reverse order as we @@ -8267,7 +8015,7 @@ { dump_interface (gen_declaration_file, objc_implementation_context); } - + if (TREE_CODE (objc_implementation_context) == CLASS_IMPLEMENTATION_TYPE) { /* all of the following reference the string pool... */ @@ -8363,8 +8111,7 @@ /* Subroutines of finish_objc. */ static void -generate_classref_translation_entry (chain) - tree chain; +generate_classref_translation_entry (tree chain) { tree expr, name, decl_specs, decl, sc_spec; tree type; @@ -8390,8 +8137,7 @@ } static void -handle_class_ref (chain) - tree chain; +handle_class_ref (tree chain) { const char *name = IDENTIFIER_POINTER (TREE_VALUE (chain)); char *string = alloca (strlen (name) + 30); @@ -8431,8 +8177,7 @@ } static void -handle_impent (impent) - struct imp_entry *impent; +handle_impent (struct imp_entry *impent) { char *string; @@ -8495,8 +8240,7 @@ /* Look up ID as an instance variable. */ tree -lookup_objc_ivar (id) - tree id; +lookup_objc_ivar (tree id) { tree decl; From criswell at cs.uiuc.edu Thu Feb 5 10:08:34 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:08:34 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/config/i386/linux.h t-netware xm-vsta.h Message-ID: <200402051606.KAA27005@choi.cs.uiuc.edu> Changes in directory gcc-3.4/gcc/config/i386: linux.h updated: 1.2 -> 1.3 t-netware (r1.1.1.1) removed xm-vsta.h (r1.1.1.1) removed --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+0 -12) Index: gcc-3.4/gcc/config/i386/linux.h diff -u gcc-3.4/gcc/config/i386/linux.h:1.2 gcc-3.4/gcc/config/i386/linux.h:1.3 --- gcc-3.4/gcc/config/i386/linux.h:1.2 Thu Jan 8 17:03:36 2004 +++ gcc-3.4/gcc/config/i386/linux.h Thu Feb 5 10:05:46 2004 @@ -21,8 +21,6 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#define LINUX_DEFAULT_ELF - /* Output at beginning of assembler file. */ /* The .file command should always begin the output. */ #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true @@ -115,15 +113,6 @@ #undef LINK_SPEC #ifdef USE_GNULIBC_1 -#ifndef LINUX_DEFAULT_ELF -#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ - %{!shared: \ - %{!ibcs: \ - %{!static: \ - %{rdynamic:-export-dynamic} \ - %{!dynamic-linker:-dynamic-linker /lib/elf/ld-linux.so.1} \ - %{!rpath:-rpath /lib/elf/}} %{static:-static}}}" -#else #define LINK_SPEC "-m elf_i386 %{shared:-shared} \ %{!shared: \ %{!ibcs: \ @@ -131,7 +120,6 @@ %{rdynamic:-export-dynamic} \ %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \ %{static:-static}}}" -#endif #else #define LINK_SPEC "-m elf_i386 %{shared:-shared} \ %{!shared: \ From criswell at cs.uiuc.edu Thu Feb 5 10:08:43 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:08:43 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/config/s390/s390.c s390.md Message-ID: <200402051606.KAA27083@choi.cs.uiuc.edu> Changes in directory gcc-3.4/gcc/config/s390: s390.c updated: 1.2 -> 1.3 s390.md updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+278 -289) Index: gcc-3.4/gcc/config/s390/s390.c diff -u gcc-3.4/gcc/config/s390/s390.c:1.2 gcc-3.4/gcc/config/s390/s390.c:1.3 --- gcc-3.4/gcc/config/s390/s390.c:1.2 Fri Jan 9 10:54:31 2004 +++ gcc-3.4/gcc/config/s390/s390.c Thu Feb 5 10:05:46 2004 @@ -1631,7 +1631,7 @@ return 1; /* Accept immediate LARL operands. */ - if (TARGET_64BIT && larl_operand (op, VOIDmode)) + if (TARGET_CPU_ZARCH && larl_operand (op, VOIDmode)) return 1; /* Thread-local symbols are never legal constants. This is @@ -1730,12 +1730,12 @@ return 1; /* Accept lliXX operands. */ - if (TARGET_64BIT + if (TARGET_ZARCH && s390_single_hi (op, DImode, 0) >= 0) return 1; /* Accept larl operands. */ - if (TARGET_64BIT + if (TARGET_CPU_ZARCH && larl_operand (op, VOIDmode)) return 1; @@ -2260,7 +2260,7 @@ || (GET_CODE (addr) == SYMBOL_REF && SYMBOL_REF_LOCAL_P (addr))) { /* This is a local symbol. */ - if (TARGET_64BIT && larl_operand (addr, VOIDmode)) + if (TARGET_CPU_ZARCH && larl_operand (addr, VOIDmode)) { /* Access local symbols PC-relative via LARL. This is the same as in the non-PIC case, so it is @@ -2309,7 +2309,7 @@ emit_move_insn (reg, new); new = reg; } - else if (TARGET_64BIT) + else if (TARGET_CPU_ZARCH) { /* If the GOT offset might be >= 4k, we determine the position of the GOT entry via a PC-relative LARL (@GOTENT). */ @@ -2378,7 +2378,7 @@ /* @PLT is OK as is on 64-bit, must be converted to GOT-relative @PLTOFF on 31-bit. */ case UNSPEC_PLT: - if (!TARGET_64BIT) + if (!TARGET_CPU_ZARCH) { rtx temp = reg? reg : gen_reg_rtx (Pmode); @@ -2418,7 +2418,7 @@ || (GET_CODE (op0) == SYMBOL_REF && SYMBOL_REF_LOCAL_P (op0))) && GET_CODE (op1) == CONST_INT) { - if (TARGET_64BIT && larl_operand (op0, VOIDmode)) + if (TARGET_CPU_ZARCH && larl_operand (op0, VOIDmode)) { if (INTVAL (op1) & 1) { @@ -2625,7 +2625,7 @@ temp = gen_reg_rtx (Pmode); emit_move_insn (temp, new); } - else if (TARGET_64BIT) + else if (TARGET_CPU_ZARCH) { /* If the GOT offset might be >= 4k, we determine the position of the GOT entry via a PC-relative LARL. */ @@ -2714,7 +2714,7 @@ switch (XINT (XEXP (addr, 0), 1)) { case UNSPEC_INDNTPOFF: - if (TARGET_64BIT) + if (TARGET_CPU_ZARCH) new = addr; else abort (); @@ -3806,12 +3806,12 @@ else continue; - if (get_attr_length (insn) <= (TARGET_64BIT ? 6 : 4)) + if (get_attr_length (insn) <= (TARGET_CPU_ZARCH ? 6 : 4)) continue; *temp_used = 1; - if (TARGET_64BIT) + if (TARGET_CPU_ZARCH) { tmp = emit_insn_before (gen_rtx_SET (Pmode, temp_reg, *label), insn); INSN_ADDRESSES_NEW (tmp, -1); @@ -4212,7 +4212,7 @@ /* Pool start insn switches to proper section and guarantees necessary alignment. */ - if (TARGET_64BIT) + if (TARGET_CPU_ZARCH) insn = emit_insn_after (gen_pool_start_64 (), pool->pool_insn); else insn = emit_insn_after (gen_pool_start_31 (), pool->pool_insn); @@ -4253,7 +4253,7 @@ /* Pool end insn switches back to previous section and guarantees necessary alignment. */ - if (TARGET_64BIT) + if (TARGET_CPU_ZARCH) insn = emit_insn_after (gen_pool_end_64 (), insn); else insn = emit_insn_after (gen_pool_end_31 (), insn); @@ -4380,9 +4380,9 @@ /* We need correct insn addresses. */ shorten_branches (get_insns ()); - /* In 64-bit, we use a LARL to load the pool register. The pool is + /* On zSeries, we use a LARL to load the pool register. The pool is located in the .rodata section, so we emit it after the function. */ - if (TARGET_64BIT) + if (TARGET_CPU_ZARCH) { insn = gen_main_base_64 (base_reg, pool->label); insn = emit_insn_after (insn, pool->pool_insn); @@ -4396,7 +4396,7 @@ s390_dump_pool (pool, 0); } - /* In 31-bit, if the total size of the function's code plus literal pool + /* On S/390, if the total size of the function's code plus literal pool does not exceed 4096 bytes, we use BASR to set up a function base pointer, and emit the literal pool at the end of the function. */ else if (INSN_ADDRESSES (INSN_UID (get_last_insn ())) @@ -4496,7 +4496,7 @@ rtx insn; rtx (*gen_reload_base) (rtx, rtx) = - TARGET_64BIT? gen_reload_base_64 : gen_reload_base_31; + TARGET_CPU_ZARCH? gen_reload_base_64 : gen_reload_base_31; /* We need correct insn addresses. */ @@ -4562,7 +4562,7 @@ || INSN_ADDRESSES (INSN_UID (insn)) == -1) continue; - if (TARGET_64BIT) + if (TARGET_CPU_ZARCH) { if (curr_pool->size < S390_POOL_CHUNK_MAX) continue; @@ -5426,7 +5426,7 @@ SYMBOL_REF_FLAGS (got_symbol) = SYMBOL_FLAG_LOCAL; } - if (TARGET_64BIT) + if (TARGET_CPU_ZARCH) { rtx insn = emit_move_insn (pic_offset_table_rtx, got_symbol); if (maybe_dead) @@ -6583,7 +6583,7 @@ rtx x ATTRIBUTE_UNUSED, unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED) { - if (TARGET_64BIT) + if (TARGET_CPU_ZARCH) readonly_data_section (); else function_section (current_function_decl); @@ -6629,7 +6629,7 @@ } /* Operand 1 is the 'this' pointer. */ - if (aggregate_value_p (TREE_TYPE (TREE_TYPE (function)))) + if (aggregate_value_p (TREE_TYPE (TREE_TYPE (function)), function)) op[1] = gen_rtx_REG (Pmode, 3); else op[1] = gen_rtx_REG (Pmode, 2); Index: gcc-3.4/gcc/config/s390/s390.md diff -u gcc-3.4/gcc/config/s390/s390.md:1.2 gcc-3.4/gcc/config/s390/s390.md:1.3 --- gcc-3.4/gcc/config/s390/s390.md:1.2 Fri Jan 9 10:54:31 2004 +++ gcc-3.4/gcc/config/s390/s390.md Thu Feb 5 10:05:46 2004 @@ -429,8 +429,7 @@ (compare (and:DI (match_operand:DI 0 "memory_operand" "Q,S") (match_operand:DI 1 "immediate_operand" "n,n")) (match_operand:DI 2 "immediate_operand" "n,n")))] - "TARGET_64BIT - && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 0)) + "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 0)) && s390_single_qi (operands[1], DImode, 0) >= 0" { int part = s390_single_qi (operands[1], DImode, 0); @@ -1237,7 +1236,7 @@ (define_insn "*movsi_lli" [(set (match_operand:SI 0 "register_operand" "=d") (match_operand:SI 1 "immediate_operand" "n"))] - "TARGET_64BIT && s390_single_hi (operands[1], SImode, 0) >= 0 + "TARGET_ZARCH && s390_single_hi (operands[1], SImode, 0) >= 0 && !FP_REG_P (operands[0])" { int part = s390_single_hi (operands[1], SImode, 0); @@ -1262,6 +1261,15 @@ [(set_attr "op_type" "RXY") (set_attr "type" "la")]) +(define_insn "*movsi_larl" + [(set (match_operand:SI 0 "register_operand" "=d") + (match_operand:SI 1 "larl_operand" "X"))] + "!TARGET_64BIT && TARGET_CPU_ZARCH + && !FP_REG_P (operands[0])" + "larl\t%0,%1" + [(set_attr "op_type" "RIL") + (set_attr "type" "larl")]) + (define_insn "*movsi" [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,T,!*f,!*f,!*f,!R,!T,?Q") (match_operand:SI 1 "general_operand" "d,R,T,d,d,*f,R,T,*f,*f,?Q"))] @@ -2356,14 +2364,14 @@ (define_insn "*extendqisi2" [(set (match_operand:SI 0 "register_operand" "=d") (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))] - "TARGET_64BIT && TARGET_LONG_DISPLACEMENT" + "TARGET_LONG_DISPLACEMENT" "lb\t%0,%1" [(set_attr "op_type" "RXY")]) (define_split [(set (match_operand:SI 0 "register_operand" "") (sign_extend:SI (match_operand:QI 1 "s_operand" "")))] - "(!TARGET_64BIT || !TARGET_LONG_DISPLACEMENT) && !reload_completed" + "!TARGET_LONG_DISPLACEMENT && !reload_completed" [(parallel [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH)) (clobber (reg:CC 33))]) @@ -2601,14 +2609,14 @@ (define_insn "*zero_extendqisi2_64" [(set (match_operand:SI 0 "register_operand" "=d") (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))] - "TARGET_64BIT" + "TARGET_ZARCH" "llgc\t%0,%1" [(set_attr "op_type" "RXY")]) (define_insn_and_split "*zero_extendqisi2_31" [(set (match_operand:SI 0 "register_operand" "=&d") (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))] - "!TARGET_64BIT" + "!TARGET_ZARCH" "#" "&& reload_completed" [(set (match_dup 0) (const_int 0)) @@ -2623,7 +2631,7 @@ (define_expand "zero_extendqihi2" [(set (match_operand:HI 0 "register_operand" "") (zero_extend:HI (match_operand:QI 1 "register_operand" "")))] - "TARGET_64BIT" + "TARGET_ZARCH" " { operands[1] = gen_lowpart (HImode, operands[1]); @@ -2635,14 +2643,14 @@ (define_insn "*zero_extendqihi2_64" [(set (match_operand:HI 0 "register_operand" "=d") (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))] - "TARGET_64BIT" + "TARGET_ZARCH" "llgc\t%0,%1" [(set_attr "op_type" "RXY")]) (define_insn_and_split "*zero_extendqihi2_31" [(set (match_operand:HI 0 "register_operand" "=&d") (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))] - "!TARGET_64BIT" + "!TARGET_ZARCH" "#" "&& reload_completed" [(set (match_dup 0) (const_int 0)) @@ -4015,7 +4023,6 @@ [(set_attr "op_type" "RRE,RXY") (set_attr "type" "imul")]) - (define_insn "muldi3" [(set (match_operand:DI 0 "register_operand" "=d,d,d") (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0") @@ -4032,6 +4039,15 @@ ; mulsi3 instruction pattern(s). ; +(define_insn "*mulsi3_sign" + [(set (match_operand:SI 0 "register_operand" "=d") + (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R")) + (match_operand:SI 1 "register_operand" "0")))] + "" + "mh\t%0,%2" + [(set_attr "op_type" "RX") + (set_attr "type" "imul")]) + (define_insn "mulsi3" [(set (match_operand:SI 0 "register_operand" "=d,d,d,d") (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0") @@ -4049,37 +4065,34 @@ ; mulsidi3 instruction pattern(s). ; -(define_expand "mulsidi3" - [(set (match_operand:DI 0 "register_operand" "") - (mult:DI (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")) - (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" ""))))] +(define_insn "mulsidi3" + [(set (match_operand:DI 0 "register_operand" "=d,d") + (mult:DI (sign_extend:DI + (match_operand:SI 1 "register_operand" "%0,0")) + (sign_extend:DI + (match_operand:SI 2 "nonimmediate_operand" "d,R"))))] "!TARGET_64BIT" -{ - rtx insn; - - emit_insn (gen_zero_extendsidi2 (operands[0], operands[1])); - insn = emit_insn (gen_mulsi_6432 (operands[0], operands[0], operands[2])); + "@ + mr\t%0,%2 + m\t%0,%2" + [(set_attr "op_type" "RR,RX") + (set_attr "type" "imul")]) - REG_NOTES (insn) = - gen_rtx_EXPR_LIST (REG_EQUAL, - gen_rtx_MULT (DImode, - gen_rtx_SIGN_EXTEND (DImode, operands[1]), - gen_rtx_SIGN_EXTEND (DImode, operands[2])), - REG_NOTES (insn)); - DONE; -}) +; +; umulsidi3 instruction pattern(s). +; -(define_insn "mulsi_6432" - [(set (match_operand:DI 0 "register_operand" "=d,d") - (mult:DI (sign_extend:DI - (truncate:SI (match_operand:DI 1 "register_operand" "0,0"))) - (sign_extend:DI - (match_operand:SI 2 "nonimmediate_operand" "d,R"))))] - "!TARGET_64BIT" - "@ - mr\t%0,%2 - m\t%0,%2" - [(set_attr "op_type" "RR,RX") +(define_insn "umulsidi3" + [(set (match_operand:DI 0 "register_operand" "=d,d") + (mult:DI (zero_extend:DI + (match_operand:SI 1 "register_operand" "%0,0")) + (zero_extend:DI + (match_operand:SI 2 "nonimmediate_operand" "d,m"))))] + "!TARGET_64BIT && TARGET_CPU_ZARCH" + "@ + mlr\t%0,%2 + ml\t%0,%2" + [(set_attr "op_type" "RRE,RXY") (set_attr "type" "imul")]) ; @@ -4214,30 +4227,20 @@ (define_expand "divmoddi4" [(parallel [(set (match_operand:DI 0 "general_operand" "") - (div:DI (match_operand:DI 1 "general_operand" "") + (div:DI (match_operand:DI 1 "register_operand" "") (match_operand:DI 2 "general_operand" ""))) (set (match_operand:DI 3 "general_operand" "") (mod:DI (match_dup 1) (match_dup 2)))]) (clobber (match_dup 4))] "TARGET_64BIT" { - rtx insn, div_equal, mod_equal, equal; + rtx insn, div_equal, mod_equal; div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]); mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]); - equal = gen_rtx_IOR (TImode, - gen_rtx_ZERO_EXTEND (TImode, div_equal), - gen_rtx_ASHIFT (TImode, - gen_rtx_ZERO_EXTEND (TImode, mod_equal), - GEN_INT (64))); operands[4] = gen_reg_rtx(TImode); - emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[4])); - emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]); - emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx); - insn = emit_insn (gen_divmodtidi3 (operands[4], operands[4], operands[2])); - REG_NOTES (insn) = - gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn)); + emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2])); insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4])); REG_NOTES (insn) = @@ -4254,11 +4257,11 @@ [(set (match_operand:TI 0 "register_operand" "=d,d") (ior:TI (zero_extend:TI - (div:DI (truncate:DI (match_operand:TI 1 "register_operand" "0,0")) + (div:DI (match_operand:DI 1 "register_operand" "0,0") (match_operand:DI 2 "general_operand" "d,m"))) (ashift:TI (zero_extend:TI - (mod:DI (truncate:DI (match_dup 1)) + (mod:DI (match_dup 1) (match_dup 2))) (const_int 64))))] "TARGET_64BIT" @@ -4272,11 +4275,11 @@ [(set (match_operand:TI 0 "register_operand" "=d,d") (ior:TI (zero_extend:TI - (div:DI (truncate:DI (match_operand:TI 1 "register_operand" "0,0")) + (div:DI (match_operand:DI 1 "register_operand" "0,0") (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "d,m")))) (ashift:TI (zero_extend:TI - (mod:DI (truncate:DI (match_dup 1)) + (mod:DI (match_dup 1) (sign_extend:DI (match_dup 2)))) (const_int 64))))] "TARGET_64BIT" @@ -4410,13 +4413,69 @@ ; udivsi3 and umodsi3 instruction pattern(s). ; +(define_expand "udivmodsi4" + [(parallel [(set (match_operand:SI 0 "general_operand" "") + (udiv:SI (match_operand:SI 1 "general_operand" "") + (match_operand:SI 2 "nonimmediate_operand" ""))) + (set (match_operand:SI 3 "general_operand" "") + (umod:SI (match_dup 1) (match_dup 2)))]) + (clobber (match_dup 4))] + "!TARGET_64BIT && TARGET_CPU_ZARCH" +{ + rtx insn, div_equal, mod_equal, equal; + + div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]); + mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]); + equal = gen_rtx_IOR (DImode, + gen_rtx_ZERO_EXTEND (DImode, div_equal), + gen_rtx_ASHIFT (DImode, + gen_rtx_ZERO_EXTEND (DImode, mod_equal), + GEN_INT (32))); + + operands[4] = gen_reg_rtx(DImode); + emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[4])); + emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]); + emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx); + insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2])); + REG_NOTES (insn) = + gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn)); + + insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4])); + REG_NOTES (insn) = + gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn)); + + insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4])); + REG_NOTES (insn) = + gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn)); + + DONE; +}) + +(define_insn "udivmoddisi3" + [(set (match_operand:DI 0 "register_operand" "=d,d") + (ior:DI (zero_extend:DI + (truncate:SI + (udiv:DI (match_operand:DI 1 "register_operand" "0,0") + (zero_extend:DI + (match_operand:SI 2 "nonimmediate_operand" "d,m"))))) + (ashift:DI + (zero_extend:DI + (truncate:SI + (umod:DI (match_dup 1) (zero_extend:DI (match_dup 2))))) + (const_int 32))))] + "!TARGET_64BIT && TARGET_CPU_ZARCH" + "@ + dlr\t%0,%2 + dl\t%0,%2" + [(set_attr "op_type" "RRE,RXY") + (set_attr "type" "idiv")]) (define_expand "udivsi3" [(set (match_operand:SI 0 "register_operand" "=d") (udiv:SI (match_operand:SI 1 "general_operand" "") (match_operand:SI 2 "general_operand" ""))) (clobber (match_dup 3))] - "!TARGET_64BIT" + "!TARGET_64BIT && !TARGET_CPU_ZARCH" { rtx insn, udiv_equal, umod_equal, equal; @@ -4507,7 +4566,7 @@ (umod:SI (match_operand:SI 1 "nonimmediate_operand" "") (match_operand:SI 2 "nonimmediate_operand" ""))) (clobber (match_dup 3))] - "!TARGET_64BIT" + "!TARGET_64BIT && !TARGET_CPU_ZARCH" { rtx insn, udiv_equal, umod_equal, equal; @@ -4787,7 +4846,7 @@ (and:SI (match_operand:SI 1 "nonimmediate_operand" "0") (match_operand:SI 2 "immediate_operand" "n"))) (clobber (reg:CC 33))] - "TARGET_64BIT && s390_single_hi (operands[2], SImode, -1) >= 0" + "TARGET_ZARCH && s390_single_hi (operands[2], SImode, -1) >= 0" { int part = s390_single_hi (operands[2], SImode, -1); operands[2] = GEN_INT (s390_extract_hi (operands[2], SImode, part)); @@ -4840,7 +4899,7 @@ (and:HI (match_operand:HI 1 "register_operand" "%0,0") (match_operand:HI 2 "nonmemory_operand" "d,n"))) (clobber (reg:CC 33))] - "TARGET_64BIT" + "TARGET_ZARCH" "@ nr\t%0,%2 nill\t%0,%x2" @@ -4882,7 +4941,7 @@ (and:QI (match_operand:QI 1 "register_operand" "%0,0") (match_operand:QI 2 "nonmemory_operand" "d,n"))) (clobber (reg:CC 33))] - "TARGET_64BIT" + "TARGET_ZARCH" "@ nr\t%0,%2 nill\t%0,%b2" @@ -5041,7 +5100,7 @@ (ior:SI (match_operand:SI 1 "nonimmediate_operand" "0") (match_operand:SI 2 "immediate_operand" "n"))) (clobber (reg:CC 33))] - "TARGET_64BIT && s390_single_hi (operands[2], SImode, 0) >= 0" + "TARGET_ZARCH && s390_single_hi (operands[2], SImode, 0) >= 0" { int part = s390_single_hi (operands[2], SImode, 0); operands[2] = GEN_INT (s390_extract_hi (operands[2], SImode, part)); @@ -5094,7 +5153,7 @@ (ior:HI (match_operand:HI 1 "register_operand" "%0,0") (match_operand:HI 2 "nonmemory_operand" "d,n"))) (clobber (reg:CC 33))] - "TARGET_64BIT" + "TARGET_ZARCH" "@ or\t%0,%2 oill\t%0,%x2" @@ -5136,7 +5195,7 @@ (ior:QI (match_operand:QI 1 "register_operand" "%0,0") (match_operand:QI 2 "nonmemory_operand" "d,n"))) (clobber (reg:CC 33))] - "TARGET_64BIT" + "TARGET_ZARCH" "@ or\t%0,%2 oill\t%0,%b2" @@ -5733,7 +5792,7 @@ [(set (match_operand:SI 0 "register_operand" "=d,d") (rotate:SI (match_operand:SI 1 "register_operand" "d,d") (match_operand:SI 2 "nonmemory_operand" "J,a")))] - "TARGET_64BIT" + "TARGET_CPU_ZARCH" "@ rll\t%0,%1,%c2 rll\t%0,%1,0(%2)" @@ -6164,7 +6223,7 @@ { if (get_attr_length (insn) == 4) return "j%C1\t%l0"; - else if (TARGET_64BIT) + else if (TARGET_CPU_ZARCH) return "jg%C1\t%l0"; else abort (); @@ -6174,7 +6233,7 @@ (set (attr "length") (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000)) (const_int 4) - (ne (symbol_ref "TARGET_64BIT") (const_int 0)) + (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0)) (const_int 6) (eq (symbol_ref "flag_pic") (const_int 0)) (const_int 6)] (const_int 8)))]) @@ -6213,7 +6272,7 @@ { if (get_attr_length (insn) == 4) return "j%D1\t%l0"; - else if (TARGET_64BIT) + else if (TARGET_CPU_ZARCH) return "jg%D1\t%l0"; else abort (); @@ -6223,7 +6282,7 @@ (set (attr "length") (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000)) (const_int 4) - (ne (symbol_ref "TARGET_64BIT") (const_int 0)) + (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0)) (const_int 6) (eq (symbol_ref "flag_pic") (const_int 0)) (const_int 6)] (const_int 8)))]) @@ -6332,7 +6391,7 @@ (set (attr "length") (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000)) (const_int 4) - (ne (symbol_ref "TARGET_64BIT") (const_int 0)) + (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0)) (const_int 10) (eq (symbol_ref "flag_pic") (const_int 0)) (const_int 6)] (const_int 8)))]) @@ -6473,7 +6532,7 @@ { if (get_attr_length (insn) == 4) return "j\t%l0"; - else if (TARGET_64BIT) + else if (TARGET_CPU_ZARCH) return "jg\t%l0"; else abort (); @@ -6483,7 +6542,7 @@ (set (attr "length") (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000)) (const_int 4) - (ne (symbol_ref "TARGET_64BIT") (const_int 0)) + (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0)) (const_int 6) (eq (symbol_ref "flag_pic") (const_int 0)) (const_int 6)] (const_int 8)))]) @@ -6625,6 +6684,7 @@ (use (match_operand 2 "" ""))] "" { + bool plt_call = false; rtx insn; /* Direct function calls need special treatment. */ @@ -6638,11 +6698,12 @@ { sym = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, sym), UNSPEC_PLT); sym = gen_rtx_CONST (Pmode, sym); + plt_call = true; } /* Unless we can use the bras(l) insn, force the routine address into a register. */ - if (!TARGET_SMALL_EXEC && !TARGET_64BIT) + if (!TARGET_SMALL_EXEC && !TARGET_CPU_ZARCH) { if (flag_pic) sym = legitimize_pic_address (sym, 0); @@ -6656,6 +6717,11 @@ /* Emit insn. */ insn = emit_call_insn (gen_call_exp (operands[0], operands[1], gen_rtx_REG (Pmode, RETURN_REGNUM))); + + /* 31-bit PLT stubs use the GOT register implicitly. */ + if (!TARGET_64BIT && plt_call) + use_reg (&CALL_INSN_FUNCTION_USAGE (insn), pic_offset_table_rtx); + DONE; }) @@ -6666,62 +6732,40 @@ "" "") -(define_insn "brasl" - [(call (mem:QI (match_operand:DI 0 "bras_sym_operand" "X")) - (match_operand:SI 1 "const_int_operand" "n")) - (clobber (match_operand:DI 2 "register_operand" "=r"))] - "TARGET_64BIT" - "brasl\t%2,%0" - [(set_attr "op_type" "RIL") - (set_attr "type" "jsr")]) - -(define_insn "bras" - [(call (mem:QI (match_operand:SI 0 "bras_sym_operand" "X")) - (match_operand:SI 1 "const_int_operand" "n")) - (clobber (match_operand:SI 2 "register_operand" "=r"))] - "TARGET_SMALL_EXEC" +(define_insn "*bras" + [(call (mem:QI (match_operand 0 "bras_sym_operand" "X")) + (match_operand 1 "const_int_operand" "n")) + (clobber (match_operand 2 "register_operand" "=r"))] + "TARGET_SMALL_EXEC && GET_MODE (operands[2]) == Pmode" "bras\t%2,%0" [(set_attr "op_type" "RI") (set_attr "type" "jsr")]) -(define_insn "basr_64" - [(call (mem:QI (match_operand:DI 0 "register_operand" "a")) - (match_operand:SI 1 "const_int_operand" "n")) - (clobber (match_operand:DI 2 "register_operand" "=r"))] - "TARGET_64BIT" - "basr\t%2,%0" - [(set_attr "op_type" "RR") - (set_attr "type" "jsr") - (set_attr "atype" "agen")]) - -(define_insn "basr_31" - [(call (mem:QI (match_operand:SI 0 "register_operand" "a")) - (match_operand:SI 1 "const_int_operand" "n")) - (clobber (match_operand:SI 2 "register_operand" "=r"))] - "!TARGET_64BIT" - "basr\t%2,%0" - [(set_attr "op_type" "RR") - (set_attr "type" "jsr") - (set_attr "atype" "agen")]) - -(define_insn "bas_64" - [(call (mem:QI (match_operand:QI 0 "address_operand" "U")) - (match_operand:SI 1 "const_int_operand" "n")) - (clobber (match_operand:DI 2 "register_operand" "=r"))] - "TARGET_64BIT" - "bas\t%2,%a0" - [(set_attr "op_type" "RX") - (set_attr "type" "jsr")]) - -(define_insn "bas_31" - [(call (mem:QI (match_operand:QI 0 "address_operand" "U")) - (match_operand:SI 1 "const_int_operand" "n")) - (clobber (match_operand:SI 2 "register_operand" "=r"))] - "!TARGET_64BIT" - "bas\t%2,%a0" - [(set_attr "op_type" "RX") +(define_insn "*brasl" + [(call (mem:QI (match_operand 0 "bras_sym_operand" "X")) + (match_operand 1 "const_int_operand" "n")) + (clobber (match_operand 2 "register_operand" "=r"))] + "TARGET_CPU_ZARCH && GET_MODE (operands[2]) == Pmode" + "brasl\t%2,%0" + [(set_attr "op_type" "RIL") (set_attr "type" "jsr")]) +(define_insn "*basr" + [(call (mem:QI (match_operand 0 "address_operand" "U")) + (match_operand 1 "const_int_operand" "n")) + (clobber (match_operand 2 "register_operand" "=r"))] + "GET_MODE (operands[2]) == Pmode" +{ + if (get_attr_op_type (insn) == OP_TYPE_RR) + return "basr\t%2,%0"; + else + return "bas\t%2,%a0"; +} + [(set (attr "op_type") + (if_then_else (match_operand 0 "register_operand" "") + (const_string "RR") (const_string "RX"))) + (set_attr "type" "jsr") + (set_attr "atype" "agen")]) ; ; call_value instruction pattern(s). @@ -6734,6 +6778,7 @@ (use (match_operand 3 "" ""))] "" { + bool plt_call = false; rtx insn; /* Direct function calls need special treatment. */ @@ -6747,11 +6792,12 @@ { sym = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, sym), UNSPEC_PLT); sym = gen_rtx_CONST (Pmode, sym); + plt_call = true; } /* Unless we can use the bras(l) insn, force the routine address into a register. */ - if (!TARGET_SMALL_EXEC && !TARGET_64BIT) + if (!TARGET_SMALL_EXEC && !TARGET_CPU_ZARCH) { if (flag_pic) sym = legitimize_pic_address (sym, 0); @@ -6766,6 +6812,11 @@ insn = emit_call_insn ( gen_call_value_exp (operands[0], operands[1], operands[2], gen_rtx_REG (Pmode, RETURN_REGNUM))); + + /* 31-bit PLT stubs use the GOT register implicitly. */ + if (!TARGET_64BIT && plt_call) + use_reg (&CALL_INSN_FUNCTION_USAGE (insn), pic_offset_table_rtx); + DONE; }) @@ -6777,68 +6828,43 @@ "" "") -(define_insn "brasl_r" +(define_insn "*bras_r" [(set (match_operand 0 "register_operand" "=df") - (call (mem:QI (match_operand:DI 1 "bras_sym_operand" "X")) + (call (mem:QI (match_operand 1 "bras_sym_operand" "X")) (match_operand:SI 2 "const_int_operand" "n"))) - (clobber (match_operand:DI 3 "register_operand" "=r"))] - "TARGET_64BIT" - "brasl\t%3,%1" - [(set_attr "op_type" "RIL") - (set_attr "type" "jsr")]) - -(define_insn "bras_r" - [(set (match_operand 0 "register_operand" "=df") - (call (mem:QI (match_operand:SI 1 "bras_sym_operand" "X")) - (match_operand:SI 2 "const_int_operand" "n"))) - (clobber (match_operand:SI 3 "register_operand" "=r"))] - "TARGET_SMALL_EXEC" + (clobber (match_operand 3 "register_operand" "=r"))] + "TARGET_SMALL_EXEC && GET_MODE (operands[3]) == Pmode" "bras\t%3,%1" [(set_attr "op_type" "RI") (set_attr "type" "jsr")]) -(define_insn "basr_r_64" - [(set (match_operand 0 "register_operand" "=df") - (call (mem:QI (match_operand:DI 1 "register_operand" "a")) - (match_operand:SI 2 "const_int_operand" "n"))) - (clobber (match_operand:DI 3 "register_operand" "=r"))] - "TARGET_64BIT" - "basr\t%3,%1" - [(set_attr "op_type" "RR") - (set_attr "type" "jsr") - (set_attr "atype" "agen")]) - -(define_insn "basr_r_31" +(define_insn "*brasl_r" [(set (match_operand 0 "register_operand" "=df") - (call (mem:QI (match_operand:SI 1 "register_operand" "a")) - (match_operand:SI 2 "const_int_operand" "n"))) - (clobber (match_operand:SI 3 "register_operand" "=r"))] - "!TARGET_64BIT" - "basr\t%3,%1" - [(set_attr "op_type" "RR") - (set_attr "type" "jsr") - (set_attr "atype" "agen")]) - -(define_insn "bas_r_64" - [(set (match_operand 0 "register_operand" "=df") - (call (mem:QI (match_operand:QI 1 "address_operand" "U")) - (match_operand:SI 2 "const_int_operand" "n"))) - (clobber (match_operand:DI 3 "register_operand" "=r"))] - "TARGET_64BIT" - "bas\t%3,%a1" - [(set_attr "op_type" "RX") + (call (mem:QI (match_operand 1 "bras_sym_operand" "X")) + (match_operand 2 "const_int_operand" "n"))) + (clobber (match_operand 3 "register_operand" "=r"))] + "TARGET_CPU_ZARCH && GET_MODE (operands[3]) == Pmode" + "brasl\t%3,%1" + [(set_attr "op_type" "RIL") (set_attr "type" "jsr")]) -(define_insn "bas_r_31" +(define_insn "*basr_r" [(set (match_operand 0 "register_operand" "=df") - (call (mem:QI (match_operand:QI 1 "address_operand" "U")) - (match_operand:SI 2 "const_int_operand" "n"))) - (clobber (match_operand:SI 3 "register_operand" "=r"))] - "!TARGET_64BIT" - "bas\t%3,%a1" - [(set_attr "op_type" "RX") - (set_attr "type" "jsr")]) - + (call (mem:QI (match_operand 1 "address_operand" "U")) + (match_operand 2 "const_int_operand" "n"))) + (clobber (match_operand 3 "register_operand" "=r"))] + "GET_MODE (operands[3]) == Pmode" +{ + if (get_attr_op_type (insn) == OP_TYPE_RR) + return "basr\t%3,%1"; + else + return "bas\t%3,%a1"; +} + [(set (attr "op_type") + (if_then_else (match_operand 1 "register_operand" "") + (const_string "RR") (const_string "RX"))) + (set_attr "type" "jsr") + (set_attr "atype" "agen")]) ;; ;;- Thread-local storage support. @@ -6922,7 +6948,7 @@ /* Unless we can use the bras(l) insn, force the routine address into a register. */ - if (!TARGET_SMALL_EXEC && !TARGET_64BIT) + if (!TARGET_SMALL_EXEC && !TARGET_CPU_ZARCH) { if (flag_pic) sym = legitimize_pic_address (sym, 0); @@ -6956,74 +6982,46 @@ "" "") -(define_insn "brasl_tls" - [(set (match_operand 0 "register_operand" "=df") - (call (mem:QI (match_operand:DI 1 "bras_sym_operand" "X")) - (match_operand:SI 2 "const_int_operand" "n"))) - (clobber (match_operand:DI 3 "register_operand" "=r")) - (use (match_operand:DI 4 "" ""))] - "TARGET_64BIT" - "brasl\t%3,%1%J4" - [(set_attr "op_type" "RIL") - (set_attr "type" "jsr")]) - -(define_insn "bras_tls" +(define_insn "*bras_tls" [(set (match_operand 0 "register_operand" "=df") - (call (mem:QI (match_operand:SI 1 "bras_sym_operand" "X")) - (match_operand:SI 2 "const_int_operand" "n"))) - (clobber (match_operand:SI 3 "register_operand" "=r")) - (use (match_operand:SI 4 "" ""))] - "TARGET_SMALL_EXEC" + (call (mem:QI (match_operand 1 "bras_sym_operand" "X")) + (match_operand 2 "const_int_operand" "n"))) + (clobber (match_operand 3 "register_operand" "=r")) + (use (match_operand 4 "" ""))] + "TARGET_SMALL_EXEC && GET_MODE (operands[3]) == Pmode" "bras\t%3,%1%J4" [(set_attr "op_type" "RI") (set_attr "type" "jsr")]) -(define_insn "basr_tls_64" +(define_insn "*brasl_tls" [(set (match_operand 0 "register_operand" "=df") - (call (mem:QI (match_operand:DI 1 "register_operand" "a")) - (match_operand:SI 2 "const_int_operand" "n"))) - (clobber (match_operand:DI 3 "register_operand" "=r")) - (use (match_operand:DI 4 "" ""))] - "TARGET_64BIT" - "basr\t%3,%1%J4" - [(set_attr "op_type" "RR") + (call (mem:QI (match_operand 1 "bras_sym_operand" "X")) + (match_operand 2 "const_int_operand" "n"))) + (clobber (match_operand 3 "register_operand" "=r")) + (use (match_operand 4 "" ""))] + "TARGET_CPU_ZARCH && GET_MODE (operands[3]) == Pmode" + "brasl\t%3,%1%J4" + [(set_attr "op_type" "RIL") (set_attr "type" "jsr")]) -(define_insn "basr_tls_31" - [(set (match_operand 0 "register_operand" "=df") - (call (mem:QI (match_operand:SI 1 "register_operand" "a")) - (match_operand:SI 2 "const_int_operand" "n"))) - (clobber (match_operand:SI 3 "register_operand" "=r")) - (use (match_operand:SI 4 "" ""))] - "!TARGET_64BIT" - "basr\t%3,%1%J4" - [(set_attr "op_type" "RR") - (set_attr "type" "jsr") - (set_attr "atype" "agen")]) - -(define_insn "bas_tls_64" - [(set (match_operand 0 "register_operand" "=df") - (call (mem:QI (match_operand:QI 1 "address_operand" "U")) - (match_operand:SI 2 "const_int_operand" "n"))) - (clobber (match_operand:DI 3 "register_operand" "=r")) - (use (match_operand:DI 4 "" ""))] - "TARGET_64BIT" - "bas\t%3,%a1%J4" - [(set_attr "op_type" "RX") - (set_attr "type" "jsr") - (set_attr "atype" "agen")]) - -(define_insn "bas_tls_31" +(define_insn "*basr_tls" [(set (match_operand 0 "register_operand" "=df") - (call (mem:QI (match_operand:QI 1 "address_operand" "U")) - (match_operand:SI 2 "const_int_operand" "n"))) - (clobber (match_operand:SI 3 "register_operand" "=r")) - (use (match_operand:SI 4 "" ""))] - "!TARGET_64BIT" - "bas\t%3,%a1%J4" - [(set_attr "op_type" "RX") - (set_attr "type" "jsr") - (set_attr "atype" "agen")]) + (call (mem:QI (match_operand 1 "address_operand" "U")) + (match_operand 2 "const_int_operand" "n"))) + (clobber (match_operand 3 "register_operand" "=r")) + (use (match_operand 4 "" ""))] + "GET_MODE (operands[3]) == Pmode" +{ + if (get_attr_op_type (insn) == OP_TYPE_RR) + return "basr\t%3,%1%J4"; + else + return "bas\t%3,%a1%J4"; +} + [(set (attr "op_type") + (if_then_else (match_operand 1 "register_operand" "") + (const_string "RR") (const_string "RX"))) + (set_attr "type" "jsr") + (set_attr "atype" "agen")]) ;; ;;- Miscellaneous instructions. @@ -7207,52 +7205,52 @@ (define_insn "pool_start_31" [(unspec_volatile [(const_int 0)] UNSPECV_POOL_START)] - "!TARGET_64BIT" + "!TARGET_CPU_ZARCH" ".align\t4" [(set_attr "op_type" "NN") (set_attr "length" "2")]) (define_insn "pool_end_31" [(unspec_volatile [(const_int 0)] UNSPECV_POOL_END)] - "!TARGET_64BIT" + "!TARGET_CPU_ZARCH" ".align\t2" [(set_attr "op_type" "NN") (set_attr "length" "2")]) (define_insn "pool_start_64" [(unspec_volatile [(const_int 0)] UNSPECV_POOL_START)] - "TARGET_64BIT" + "TARGET_CPU_ZARCH" ".section\t.rodata\;.align\t8" [(set_attr "op_type" "NN") (set_attr "length" "0")]) (define_insn "pool_end_64" [(unspec_volatile [(const_int 0)] UNSPECV_POOL_END)] - "TARGET_64BIT" + "TARGET_CPU_ZARCH" ".previous" [(set_attr "op_type" "NN") (set_attr "length" "0")]) (define_insn "main_base_31_small" - [(set (match_operand:SI 0 "register_operand" "=a") - (unspec:SI [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))] - "!TARGET_64BIT" + [(set (match_operand 0 "register_operand" "=a") + (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))] + "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode" "basr\t%0,0" [(set_attr "op_type" "RR") (set_attr "type" "la")]) (define_insn "main_base_31_large" - [(set (match_operand:SI 0 "register_operand" "=a") - (unspec:SI [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE)) + [(set (match_operand 0 "register_operand" "=a") + (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE)) (set (pc) (label_ref (match_operand 2 "" "")))] - "!TARGET_64BIT" + "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode" "bras\t%0,%2" [(set_attr "op_type" "RI")]) (define_insn "main_base_64" - [(set (match_operand:DI 0 "register_operand" "=a") - (unspec:DI [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))] - "TARGET_64BIT" + [(set (match_operand 0 "register_operand" "=a") + (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))] + "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode" "larl\t%0,%1" [(set_attr "op_type" "RIL") (set_attr "type" "larl")]) @@ -7264,18 +7262,18 @@ [(set_attr "op_type" "NN")]) (define_insn "reload_base_31" - [(set (match_operand:SI 0 "register_operand" "=a") - (unspec:SI [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))] - "!TARGET_64BIT" + [(set (match_operand 0 "register_operand" "=a") + (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))] + "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode" "basr\t%0,0\;la\t%0,%1-.(%0)" [(set_attr "op_type" "NN") (set_attr "type" "la") (set_attr "length" "6")]) (define_insn "reload_base_64" - [(set (match_operand:DI 0 "register_operand" "=a") - (unspec:DI [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))] - "TARGET_64BIT" + [(set (match_operand 0 "register_operand" "=a") + (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))] + "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode" "larl\t%0,%1" [(set_attr "op_type" "RIL") (set_attr "type" "larl")]) @@ -7302,24 +7300,15 @@ "" "s390_emit_epilogue (); DONE;") - -(define_insn "*return_si" +(define_insn "*return" [(return) - (use (match_operand:SI 0 "register_operand" "a"))] - "!TARGET_64BIT" + (use (match_operand 0 "register_operand" "a"))] + "GET_MODE (operands[0]) == Pmode" "br\t%0" [(set_attr "op_type" "RR") (set_attr "type" "jsr") (set_attr "atype" "agen")]) -(define_insn "*return_di" - [(return) - (use (match_operand:DI 0 "register_operand" "a"))] - "TARGET_64BIT" - "br\t%0" - [(set_attr "op_type" "RR") - (set_attr "type" "jsr") - (set_attr "atype" "agen")]) ;; Instruction definition to extend a 31-bit pointer into a 64-bit ;; pointer. This is used for compatability. @@ -7327,7 +7316,7 @@ (define_expand "ptr_extend" [(set (match_operand:DI 0 "register_operand" "=r") (match_operand:SI 1 "register_operand" "r"))] - "" + "TARGET_64BIT" { emit_insn (gen_anddi3 (operands[0], gen_lowpart (DImode, operands[1]), From criswell at cs.uiuc.edu Thu Feb 5 10:08:52 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:08:52 2004 Subject: [llvm-commits] CVS: gcc-3.4/libjava/ChangeLog Makefile.am Makefile.in Message-ID: <200402051606.KAA27027@choi.cs.uiuc.edu> Changes in directory gcc-3.4/libjava: ChangeLog updated: 1.2 -> 1.3 Makefile.am updated: 1.2 -> 1.3 Makefile.in updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+730 -41) Index: gcc-3.4/libjava/ChangeLog diff -u gcc-3.4/libjava/ChangeLog:1.2 gcc-3.4/libjava/ChangeLog:1.3 --- gcc-3.4/libjava/ChangeLog:1.2 Fri Jan 9 10:54:33 2004 +++ gcc-3.4/libjava/ChangeLog Thu Feb 5 10:05:48 2004 @@ -1,3 +1,590 @@ +2003-09-23 Nathanael Nerode + + * java/lang/System.java: Add GCJ LOCAL note about encoding aliases. + + * java/lang/Float.java, java/lang/Double.java: Add GCJ LOCAL + markers. + +2003-09-22 Anthony Green + + * configure.in (HAVE_USLEEP_DECL): Define for newlib build. + * configure: Rebuilt. + +2003-09-21 Ralph Loader + + PR java/12350: + * java/lang/StringBuffer.java (substring): Fix handling of shared flag. + +2003-09-22 Michael Koch + + * jni.cc (_Jv_LookupJNIMethod): Remove workaround that should hide a + compiler warning but produces a different one now. + +2003-09-22 Michael Koch + + * java/net/InetAddress.java: + Moves around some code, reformats and adds documentation. + No functional changes. + +2003-09-22 Michael Koch + + * java/net/JarURLConnection.java + (JarURLConnection): Modifed code to match classpath more, fixed comment. + (getCertificates): Made it more error prone. + (getMainAttributes): Likewise. + (getAttributes): Implemented. + (getManifest): Reformatted code. + +2003-09-20 Tom Tromey + + * java/awt/Component.java: Indentation cleanup from Classpath. + +2003-09-20 Dalibor Topic + + * java/awt/BasicStroke.java (BasicStroke): Fixed illegal argument + checking to follow 1.4.2 spec. + +2003-08-11 Ingo Proetel + + * gnu/java/rmi/server/UnicastRef.java: make constructor public and check if serverobject + is compatible in case client and server are running in the same VM + (remerged from Classpath on 2003-09-20) + +2003-09-19 David Daney + + * java/lang/ref/Reference.java (clear): Set referent to null and + synchronize. + +2003-09-19 Michael Koch + + * gnu/java/nio/NIODatagramSocket.java, + gnu/java/nio/NIOSocket.java: New files. + * Makefile.am (ordinary_java_source_files): + Added gnu/java/nio/NIODatagramSocket.java and + gnu/java/nio/NIOSocket.java. + * Makefile.in: Regenerated. + +2003-09-19 Thomas Fitzsimmons + + * gnu/java/awt/peer/gtk/GtkDialogPeer.java (create()): Create a + top-level GTK window. + (getArgs): Add "title" property. + * gnu/java/awt/peer/gtk/GtkWindowPeer.java (setResizable): Use + "allow_shrink" and "allow_grow" properties. + * java/awt/Dialog.java: Initialize resizable to true and change + comments accordingly. Initialize visible to false in + constructors. + * java/awt/Frame.java (dispose): Remove method. + * java/awt/Window.java (ownedWindows): New field. + (Window(Window,GraphicsConfiguration)): Add a weak reference to + owner's ownedWindows vector. + (finalize): Remove method. + (hide): Hide owned windows. + (dispose): Dispose of owned windows. + (getOwnedWindows): Implement. + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Remove + unused GtkArg code. + (set(String,boolean)): Clamp gboolean parameter to g_object_set + to TRUE or FALSE. + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c + (create): Set window's size requisition. + (connectHooks): Fix indentation. + (setResizable): Remove function. + (static setBounds): Likewise. + (setBounds): Replace call to setBounds with GTK size requisition + and resize calls. + +2003-09-19 Mohan Embar + + * win32-threads.cc: (ensure_interrupt_event_initialized) New + function for lazy initialization of an auto-reset event. + (_Jv_CondWait) Added thread interrupt support. + (_Jv_ThreadInitData) Added initialization of interrupt support + members. + (_Jv_ThreadDestroyData) Added cleanup of interrupt support members. + (_Jv_ThreadStart) Removed unused code. + (_Jv_Win32GetInterruptEvent) New method for returning interrupt event + to an external caller. + (_Jv_ThreadInterrupt) Implemented. + * include/win32-threads.h: (_Jv_Thread_t) Added a Win32 auto-reset + event for interrupt support as well as a mutex which regulates + access to this. + (_Jv_Win32GetInterruptEvent) Declared new method for returning interrupt + event to an external caller. + * java/lang/natWin32Process.cc: (cleanup) Close handle to spawned + process. + (waitFor) Added interrupt support. + +2003-09-19 Michael Koch + + * java/net/DatagramSocket.java (getLocalAddress): + Renamed result variable to localAddr. + * java/net/MulticastSocket.java: + No need to import gnu.java.net.PlainDatagramSocketImpl. + +2003-09-18 Sascha Brawer + + * java/awt/Toolkit.java (getSystemEventQueue, getSystemEventQueueImpl): + Replace UTF-8 characters in Javadoc by XML/HTML escape sequence. + +2003-09-18 Tom Tromey + + * javax/naming/InitialContext.java: Reindented. + +2003-09-18 Dalibor Topic , + Helmer Kraemer + + * javax/naming/spi/NamingManager.java (getURLContext, + getObjectInstance, getStateToBind): Always use current thread's + context class loader when calling Class.forName. + +2003-09-18 Michael Koch + + * java/util/Timer.java (finalize): Added "throws Throwable". + +2003-09-18 Michael Koch + + * java/net/DatagramSocket.java + (ch): Removed. + (receive): Use getChannel() instead of ch. + (send): Likewise. + (getChannel): Return null. + * java/net/ServerSocket.java + (ch): Removed. + (setChannel): Removed. + (implAccept): Use getChannel() instead of ch. + (close): Likewise. + (getChannel): Return null. + * java/net/Socket.java + (ch): Removed. + (connect): Use getChannel() instead of ch. + (setChannel): Removed. + (getChannel): Return null. + +2003-09-18 Mark Wielaard + + Reported by Guilhem Lavaux and Julian Dolby + * java/io/ObjectStreamClass.java (getSerialPersistentFields): Get the + field "serialPersistentFields", not "getSerialPersistentFields". + +2003-09-18 Ingo Proetel + + * java/util/TimeZone.java: Initialize lazily. + * java/util/Locale.java (readManifest): Fix check for country. + * java/util/GregorianCalendar.java: Make use of ResourceBundle better + traceable + * java/util/Calendar.java: Make use of ResourceBundle better + traceable. + +2003-09-18 Jeroen Frijters + + * java/sql/Timestamp.java + (valueOf): Fixed confusion of java.sql.Date and java.util.Date + +2003-09-18 David P Grove + + * java/io/LineNumberReader (read): Don't reset pos & limit when + markPos is 0. + +2003-09-18 Dalibor Topic + + * gnu/java/rmi/rmic/Compile_gcj.java (COMPILER_ARGS): New private + constant. + (computeArguments): use computeTypicalArguments. + + * gnu/java/rmi/rmic/Makefile.am (EXTRA_DIST): Add Compile_kjc.java, + Compile_jikes.java and RMICException.java. + * gnu/java/rmi/rmic/Compile_kjc.java: New file. + * gnu/java/rmi/rmic/Compile_jikes.java: Likewise. + * gnu/java/rmi/rmic/RMICException.java: Likewise. + + * gnu/java/rmi/rmic/Compiler.java (getDestination): New method. + + * gnu/java/rmi/rmic/CompilerProcess.java: Import java.io.InputStream. + (computeTypicalArguments): New method. + (compile): Print compiler output to System.out. Collect compiler + error output and use it in exception message. + + * gnu/java/rmi/rmic/RMIC.java: Import java.util.Set. + (destination): Initialize to null. + (run): Replace file separator with '.' when processing class. + (processClass): Replace '.' with file separator when compiling + classes. + (findClass): Use SystemClassLoader to load class. + (generateStub): Use full class name for generated stub, that puts + it in right path. Replace '.' with file separator when generating + stub file name. Write just the stub class name without package + information as class name, and constructor name. Write only + interface names for interfaces extending java.rmi.Remote as + implemented. + (generateSkel): Use full class name for generated skel, that puts + it in right path. Replace '.' with file separator when generating + stub file name. Write just the stub class name without package + information as class name. + +2003-09-18 Michael Koch + + * Makefile.am (rmi_java_source_files): + Added gnu/java/rmi/rmic/Compile_kjc.java, + gnu/java/rmi/rmic/Compile_jikes.java and + gnu/java/rmi/rmic/RMICException.java + * Makefile.in: Regenerated. + +2003-09-17 Graydon Hoare + + * gnu/java/awt/peer/gtk/GdkGraphics2D.java, + gnu/java/awt/peer/gtk/GdkPixbufDecoder.java, + jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c, + jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c: + New files. + +2003-09-16 Graydon Hoare + + * java/awt/BufferedImage.java (setData): Support non-component + sample models. + (getData): Same. + +2003-09-10 Graydon Hoare + + * java/awt/geom/AffineTransform.java(transform): Fix airthmetic bugs. + * java/awt/geom/Arc2D.java: Approximate arc segments with cubics. + +2003-09-17 Mohan Embar + + * configure.in: Standardized help text case of + --enable-hash-synchronization + New configure switch --enable-libgcj-multifile and corresponding + automake conditional ONESTEP. + * configure: Rebuilt. + * Makefile.am: Use automake conditional ONESTEP to determine + whether classfiles should be compiled individually or all + at once. + * Makefile.in: Rebuilt. + +2003-09-16 Thomas Fitzsimmons + + * gnu/java/awt/peer/gtk/GtkEmbeddedWindowPeer.java (construct): + Remove method declaration. + (create()): Call native create. + (create(int)): New method. + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c: + (create): Add window_id parameter. Call gtk_plug_new with + window_id parameter. + (construct): Remove method implementation. + +2003-09-16 Mohan Embar + + * Makefile.am: (MOSTLYCLEANFILES) Removed libtool objects. + (mostlyclean-local): New target patterned after clean-local + which recursively deletes all libtool objects using 'libtool rm'. + (clean-local): Slightly modified comment to alleviate monotony. + (distclean-local): New target patterned after clean-local + which recursively deletes all .d files. + * Makefile.in: Rebuilt. + +2003-09-11 Tom Tromey + + * java/net/URLStreamHandler.java (parseURL): If original file + ends with "/", so must canonical result. + * java/io/natFilePosix.cc (getCanonicalPath): Clean up snafus + with nul-termination and finding previous "/". + +2003-09-11 Michael Koch + + * acconfig.h: Removed most items. + * configure.in: Added descriptions to AC_DEFINE macros that where in + acconfig.h before. + * include/config.h.in: Regenerated. + +2003-09-11 Sascha Brawer + + * java/awt/Toolkit.java (getSystemEventQueue): Call SecurityManager + if one is installed. Improve Javadoc. + (getSystemEventQueueImpl): Improve Javadoc. + +2003-09-11 Tom Tromey + + * java/io/natFilePosix.cc (getCanonicalPath): Handle case where + file does not exist. + +2003-09-10 Anthony Green + + * gnu/java/net/natPlainDatagramSocketImplWin32.cc (peekData): + Specify full name when referencing ::java::net::InetAddress. + * gnu/java/net/natPlainSocketImplWin32.cc (accept): Ditto. + Fix argument type. + +2003-09-10 Michael Koch + + * acconfig.h (__NO_MATH_INLINES): Removed. + * configure.in: Removed check for g++ math inlining bug from 2000. + * configure.host: Removed -D__NO_MATH_INLINES in libgcj_cflags and + libgcj_cxxflags. + * configure: Regenerated. + +2003-09-10 David Daney + + * java/util/Arrays.java (equals(all variants)): Quit using + NullPointerException catching to detect null valued parameters. + +2003-09-10 Michael Koch + + * java/net/DatagramSocket.java, + java/net/MulticastSocket.java, + java/net/ServerSocket.java, + java/net/Socket.java: + Use gnu.java.net.Plain*SocketImpl instead of + java.net.PlainSocketImpl. + * java/net/PlainDatagramSocketImpl.java, + java/net/PlainSocketImpl.java, + java/net/SocketInputStream.java, + java/net/SocketOutputStream.java, + java/net/natPlainDatagramSocketImplNoNet.cc, + java/net/natPlainDatagramSocketImplPosix.cc, + java/net/natPlainDatagramSocketImplWin32.cc, + java/net/natPlainSocketImplNoNet.cc, + java/net/natPlainSocketImplPosix.cc, + java/net/natPlainSocketImplWin32.cc: + Removed. + * gnu/java/net/PlainDatagramSocketImpl.java, + gnu/java/net/PlainSocketImpl.java, + gnu/java/net/SocketInputStream.java, + gnu/java/net/SocketOutputStream.java, + gnu/java/net/natPlainDatagramSocketImplNoNet.cc, + gnu/java/net/natPlainDatagramSocketImplPosix.cc, + gnu/java/net/natPlainDatagramSocketImplWin32.cc, + gnu/java/net/natPlainSocketImplNoNet.cc, + gnu/java/net/natPlainSocketImplPosix.cc, + gnu/java/net/natPlainSocketImplWin32.cc: + New files (moved from java/net). + * configure.in: Create links for gnu/java/net/natPlain*SocketImpl.cc + instead of java/net/natPlain*SocketImpl.cc. + * configure: Regenerated. + * Makefile.am: Moved files from java/net to gnu/java/net. + * Makefile.in: Regenerated. + +2003-09-09 Alan Modra + + * configure: Regenerate. + +2003-09-04 Tom Tromey + + * configure.host: Removed erroneous comment. + + * gnu/java/awt/natEmbeddedWindow.cc (setWindowPeer): Removed + lvalue cast; use correct rvalue cast. + +2003-09-02 Thomas Fitzsimmons + + * gnu/java/awt/peer/gtk/GtkDialogPeer.java (create): Add width + and height arguments to GtkWindowPeer.create method call. + * gnu/java/awt/peer/gtk/GtkWindowPeer.java + (create(int,int,int)): New method. + (create(int)): Add call to new create method. + (create()): Add width and height arguments to create method + call. + (GtkWindowPeer): Remove call to setBounds. + * java/awt/Frame.java (Frame(String)): Initialize visible field + to false. + (Frame(GraphicsConfiguration)): Likewise. + (Frame(String,GraphicsConfiguration)): Likewise. + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c (create): + Add width and height parameters. Call + gtk_window_set_default_size. + (connectHooks): Remove unused name variable. + (static setBounds): Call gtk_window_resize not + gtk_widget_set_usize. + (setBounds): Remove unused nchildren variable. + +2003-08-31 Ingo Proetel + + * java/util/logging/Logger.java: provide class and method information + * java/util/logging/LogManager.java: create handlers + * java/util/logging/SimpleFormatter.java: print souceClassName and + sourceMethodName + +2003-08-28 Mohan Embar + + * win32.cc: fixed tab, indentation and whitespace + inconsistencies + removed jvm.h include + added includes java/lang/UnsupportedOperationException.h, + java/io/IOException.h, java/net/SocketException.h + (WSAEventWrapper): class implementation + (_Jv_WinStrError): implemented both overloads + (_Jv_ThrowIOException): implemented both overloads + (_Jv_ThrowSocketException): implemented both overloads + (_Jv_select): implemented + * include/win32.h: fixed tab, indentation and whitespace + inconsistencies + wrapped include with #define WIN32_LEAN_AND_MEAN + added jvm.h include + (WSAEventWrapper): added class declaration + (_Jv_WinStrError): added both overload declarations + (_Jv_ThrowIOException): added both overload declarations + (_Jv_ThrowSocketException): added both overload declarations + removed ENOTCONN, ECONNRESET and ENOPROTOOPT defines + (_Jv_select): added declaration + (_Jv_socket): removed + (_Jv_connect): removed + (_Jv_close): removed + (_Jv_bind): removed + (_Jv_accept): removed + (_Jv_listen): removed + (_Jv_write): removed + (_Jv_read): removed + * java/io/natFileDescriptorWin32.cc: fixed tab, indentation and + whitespace inconsistencies + replaced #include with + removed jvm.h include + (testCanUseGetHandleInfo): new function which tests whether Win32 + GetHandleInformation() call can be used with console buffer handles + (only supported on >=WinNT 5.0) + (winerr): removed (superseded by _Jv_WinStrError in include/win32.h) + (valid): rewrote implementation using GetHandleInformation() + (sync): changed exception throwing to use error string and exception + helper methods declared in include/win32.h + (open): likewise + (write): likewise + (setLength): likewise + (close): likewise + (seek): likewise + (getFilePointer): likewise + (read): likewise + * java/io/natFileWin32.cc: fixed tab, indentation and + whitespace inconsistencies + replaced #include with + removed jvm.h include + (_access): use JV_TEMP_UTF_STRING + (_stat): likewise + (performMkDir): use JV_TEMP_UTF_STRING + (performRenameTo): likewise + (performDelete): likewise + (performCreate): likewise + (performSetReadOnly): likewise + (performSetLastModified): likewise + * java/lang/natWin32Process.cc: fixed tab, indentation and + whitespace inconsistencies + replaced #include with + removed includes gcj/cni.h, jvm.h + (new_string): removed + (startProcess): use JV_TEMP_UTF_STRING, + changed exception throwing to use error string and exception + helper methods declared in include/win32.h + * java/net/natInetAddressWin32.cc: fixed tab, indentation and + whitespace inconsistencies + replaced #include with + removed jvm.h include + removed DISABLE_JAVA_NET conditional code + removed POSIX conditional code not relevant to Win32 + (aton): use JV_TEMP_UTF_STRING + removed POSIX conditional code not relevant to Win32 + (lookup): likewise + (getLocalHostName): likewise + * java/net/natNetworkInterfaceWin32.cc: fixed tab, indentation and + whitespace inconsistencies + removed unnecessary windows.h, winsock.h and gcj/cni.h includes + removed DISABLE_JAVA_NET conditional code + removed POSIX conditional code not relevant to Win32 + (winsock2GetRealNetworkInterfaces): new function to compute network + interfaces via Winsock2 API + (determineGetRealNetworkInterfacesFN): new function for returning + a function pointer to the function used to compute network interfaces. + (getRealNetworkInterfaces): implemented + * java/net/natPlainDatagramSocketImplWin32.cc: fixed tab, indentation and + whitespace inconsistencies + removed gcj/cni.h include + removed DISABLE_JAVA_NET conditional code + removed POSIX conditional code not relevant to Win32 + changed net POSIXisms to Win32isms + replaced _Jv socket-related calls with their real Win32 equivalents + changed exception throwing to use error string and exception + helper methods declared in include/win32.h + (peekData): implemented timeout support + (receive): likewise + * java/net/natPlainSocketImplWin32.cc: fixed tab, indentation and + whitespace inconsistencies + removed gcj/cni.h and gcj/javaprims.h includes + removed DISABLE_JAVA_NET conditional code + removed POSIX conditional code not relevant to Win32 + changed net POSIXisms to Win32isms + replaced _Jv socket-related calls with their real Win32 + equivalents + changed exception throwing to use error string and exception + helper methods declared in include/win32.h + (throwConnectException): helper function for connect() + (connect): implemented timeout support + (accept): likewise + (doRead): new helper function common to both read() method overloads, + includes timeout support + (read): implemented both overloads in terms of doRead() + (available): implemented using ioctlsocket() + +2003-08-28 Mohan Embar + + * java/net/natInetAddressWin32.cc, + java/net/natNetworkInterfaceWin32.cc, + java/net/natPlainDatagramSocketImplWin32.cc, + java/net/natPlainSocketImplWin32.cc: + Readded code enclosed in DISABLE_JAVA_NET defines + in preparation for MinGW cleanup / networking + patch + +2003-08-28 Mohan Embar + + * Makefile.am: Fixed problems with parallel makes. + (all_java_class_files): Readded definition. + (all_java_class_files): New target which depends on + libgcj- at gcc_version@.jar + * Makefile.in: Rebuilt + +2003-08-28 Tom Tromey + + * Makefile.in: Rebuilt. + * Makefile.am (ordinary_java_source_files): Added new files. + * java/lang/Class.h (_Jv_sharedlib_register_hook): Declare as + friend. + * java/net/URLClassLoader.java (findClass): Don't use + findURLResource. Use loader's getClass method. + (URLLoader.getClass): New method. + (addURL): Handle `gcjlib' URLs. + (SoURLLoader): New class. + (SoResource): Likewise. + * gnu/gcj/protocol/gcjlib/Connection.java: New file. + * gnu/gcj/protocol/gcjlib/Handler.java: New file. + * include/jvm.h (struct _Jv_core_chain): Moved from natCore.cc. + (_Jv_RegisterCoreHook): Declare. + (_Jv_FindCore): Declare. + * gnu/gcj/runtime/SharedLibHelper.java: New file. + * gnu/gcj/runtime/natSharedLibLoader.cc (CoreHookFunc): New + typedef. + (core_hook): New function. + (struct SharedLibDummy) [saved_core]: New field. + (init): Set _Jv_RegisterCoreHook. Throw exception on failure. + (register_hook): Set protection domain and class loader on new + class. + (finalize): Free core chain. + * gnu/gcj/Core.java (Core): New constructor. + * gnu/gcj/runtime/SharedLibLoader.java: Rewrote to use + SharedLibHelper. + * gnu/gcj/natCore.cc (_Jv_RegisterResource): Indentation fixlet. + (_Jv_create_core): New function. + (create): Use it. + (default_register_resource): New function. + (_Jv_RegisterCoreHook): New global. + (_Jv_RegisterResource): Use it. + (core_chain_struct): Removed. + (_Jv_FindCore): New function. + (_Jv_FreeCoreChain): New function. + +2003-08-29 Michael Koch + + * java/net/natInetAddressWin32.cc, + java/net/natNetworkInterfaceWin32.cc, + java/net/natPlainDatagramSocketImplWin32.cc, + java/net/natPlainSocketImplWin32.cc: + Removed code enclosed in DISABLE_JAVA_NET defines. + 2003-08-26 Mohan Embar * Makefile.am: (write_entries_to_file) New parameterized Index: gcc-3.4/libjava/Makefile.am diff -u gcc-3.4/libjava/Makefile.am:1.2 gcc-3.4/libjava/Makefile.am:1.3 --- gcc-3.4/libjava/Makefile.am:1.2 Fri Jan 9 10:54:34 2004 +++ gcc-3.4/libjava/Makefile.am Thu Feb 5 10:05:48 2004 @@ -337,6 +337,12 @@ $(gtk_awt_peer_sources) \ $(x_java_source_files) +all_java_class_files = $(all_java_source_files:.java=.class) + +if ONESTEP + +# Compile all classfiles in one go. + libgcj- at gcc_version@.jar: $(all_java_source_files) - at rm -f libgcj- at gcc_version@.jar @echo Compiling Java sourcefiles... @@ -347,13 +353,50 @@ sed -e '/\/\./d' -e '/\/xlib/d' | \ $(ZIP) cfM0E@ $@ -MOSTLYCLEANFILES = $(javao_files) $(nat_files) $(nat_headers) $(c_files) $(x_javao_files) $(x_nat_files) $(x_nat_headers) +# This next rule seems backward, but reflects the fact +# that 1) all classfiles are compiled in one go when the +# libgcj jarfile is built and 2) anything which depends +# on a particular .class file must wait until the jarfile +# is built. +$(all_java_class_files): libgcj- at gcc_version@.jar + +else # !ONESTEP + +# Compile each classfile individually. + +.java.class: + $(JAVAC) $(JCFLAGS) -classpath '' -bootclasspath $(here):$(srcdir) -d $(here) $< + +libgcj- at gcc_version@.jar: $(all_java_class_files) + - at rm -f libgcj- at gcc_version@.jar + @echo Compiling Java sourcefiles... + @: $(call write_entries_to_file,$?,libgcj.sourcelist) + $(JAVAC) $(JCFLAGS) -classpath '' -bootclasspath $(here):$(srcdir) -d $(here) @libgcj.sourcelist +## Note that we explicitly want to include directory information. + find java gnu javax org -type d -o -type f -name '*.class' | \ + sed -e '/\/\./d' -e '/\/xlib/d' | \ + $(ZIP) cfM0E@ $@ + +endif + +# Note: The libtool objects are removed by mostlyclean-local +# because of command-line-length issues. +MOSTLYCLEANFILES = $(nat_headers) $(x_nat_headers) + CLEANFILES = libgcj- at gcc_version@.jar +mostlyclean-local: +## Use libtool rm to remove each libtool object + find . -name '*.lo' -print | xargs $(LIBTOOL) rm -f + clean-local: -## We just remove every .class file that was created. +## Remove every .class file that was created. find . -name '*.class' -print | xargs rm -f +distclean-local: +## Remove every .d file that was created. + find . -name '*.d' -print | xargs rm -f + # Just remove the objects from C++ sources, for testing the C++ compiler. clean-nat: rm -f $(nat_files) $(x_nat_files) @@ -1540,9 +1583,12 @@ gnu/java/rmi/registry/RegistryImpl_Skel.java \ gnu/java/rmi/registry/RegistryImpl_Stub.java \ gnu/java/rmi/rmic/Compile_gcj.java \ +gnu/java/rmi/rmic/Compile_jikes.java \ +gnu/java/rmi/rmic/Compile_kjc.java \ gnu/java/rmi/rmic/Compiler.java \ gnu/java/rmi/rmic/CompilerProcess.java \ gnu/java/rmi/rmic/RMIC.java \ +gnu/java/rmi/rmic/RMICException.java \ gnu/java/rmi/rmic/TabbedWriter.java \ gnu/java/rmi/server/ConnectionRunnerPool.java \ gnu/java/rmi/server/ProtocolConstants.java \ @@ -1965,12 +2011,15 @@ gnu/gcj/protocol/http/Handler.java \ gnu/gcj/protocol/jar/Connection.java \ gnu/gcj/protocol/jar/Handler.java \ +gnu/gcj/protocol/gcjlib/Connection.java \ +gnu/gcj/protocol/gcjlib/Handler.java \ gnu/gcj/runtime/FileDeleter.java \ gnu/gcj/runtime/FinalizerThread.java \ gnu/gcj/runtime/FirstThread.java \ gnu/gcj/runtime/JNIWeakRef.java \ gnu/gcj/runtime/MethodRef.java \ gnu/gcj/runtime/NameFinder.java \ +gnu/gcj/runtime/SharedLibHelper.java \ gnu/gcj/runtime/SharedLibLoader.java \ gnu/gcj/runtime/StackTrace.java \ gnu/gcj/runtime/StringBuffer.java \ @@ -2124,8 +2173,12 @@ gnu/java/locale/LocaleInformation_zh_SG.java \ gnu/java/locale/LocaleInformation_zh_TW.java \ gnu/java/math/MPN.java \ +gnu/java/net/PlainDatagramSocketImpl.java \ +gnu/java/net/PlainSocketImpl.java \ gnu/java/nio/DatagramChannelImpl.java \ gnu/java/nio/FileLockImpl.java \ +gnu/java/nio/NIODatagramSocket.java \ +gnu/java/nio/NIOSocket.java \ gnu/java/nio/PipeImpl.java \ gnu/java/nio/SelectionKeyImpl.java \ gnu/java/nio/SelectorImpl.java \ @@ -2220,8 +2273,6 @@ java/net/NetworkInterface.java \ java/net/NoRouteToHostException.java \ java/net/PasswordAuthentication.java \ -java/net/PlainDatagramSocketImpl.java \ -java/net/PlainSocketImpl.java \ java/net/PortUnreachableException.java \ java/net/ProtocolException.java \ java/net/ServerSocket.java \ @@ -2592,6 +2643,8 @@ gnu/gcj/runtime/natStringBuffer.cc \ gnu/gcj/runtime/natVMClassLoader.cc \ gnu/java/awt/natEmbeddedWindow.cc \ +gnu/java/net/natPlainDatagramSocketImpl.cc \ +gnu/java/net/natPlainSocketImpl.cc \ gnu/java/nio/natFileLockImpl.cc \ gnu/java/nio/natSelectorImpl.cc \ java/io/natFile.cc \ @@ -2620,8 +2673,6 @@ java/lang/reflect/natProxy.cc \ java/net/natNetworkInterface.cc \ java/net/natInetAddress.cc \ -java/net/natPlainDatagramSocketImpl.cc \ -java/net/natPlainSocketImpl.cc \ java/nio/natDirectByteBufferImpl.cc \ java/nio/channels/natFileChannelImpl.cc \ java/text/natCollator.cc \ Index: gcc-3.4/libjava/Makefile.in diff -u gcc-3.4/libjava/Makefile.in:1.2 gcc-3.4/libjava/Makefile.in:1.3 --- gcc-3.4/libjava/Makefile.in:1.2 Fri Jan 9 10:54:34 2004 +++ gcc-3.4/libjava/Makefile.in Thu Feb 5 10:05:48 2004 @@ -427,7 +427,12 @@ $(x_java_source_files) -MOSTLYCLEANFILES = $(javao_files) $(nat_files) $(nat_headers) $(c_files) $(x_javao_files) $(x_nat_files) $(x_nat_headers) +all_java_class_files = $(all_java_source_files:.java=.class) + +# Note: The libtool objects are removed by mostlyclean-local +# because of command-line-length issues. +MOSTLYCLEANFILES = $(nat_headers) $(x_nat_headers) + CLEANFILES = libgcj- at gcc_version@.jar SUFFIXES = .class .java .h @@ -1310,9 +1315,12 @@ gnu/java/rmi/registry/RegistryImpl_Skel.java \ gnu/java/rmi/registry/RegistryImpl_Stub.java \ gnu/java/rmi/rmic/Compile_gcj.java \ +gnu/java/rmi/rmic/Compile_jikes.java \ +gnu/java/rmi/rmic/Compile_kjc.java \ gnu/java/rmi/rmic/Compiler.java \ gnu/java/rmi/rmic/CompilerProcess.java \ gnu/java/rmi/rmic/RMIC.java \ +gnu/java/rmi/rmic/RMICException.java \ gnu/java/rmi/rmic/TabbedWriter.java \ gnu/java/rmi/server/ConnectionRunnerPool.java \ gnu/java/rmi/server/ProtocolConstants.java \ @@ -1727,12 +1735,15 @@ gnu/gcj/protocol/http/Handler.java \ gnu/gcj/protocol/jar/Connection.java \ gnu/gcj/protocol/jar/Handler.java \ +gnu/gcj/protocol/gcjlib/Connection.java \ +gnu/gcj/protocol/gcjlib/Handler.java \ gnu/gcj/runtime/FileDeleter.java \ gnu/gcj/runtime/FinalizerThread.java \ gnu/gcj/runtime/FirstThread.java \ gnu/gcj/runtime/JNIWeakRef.java \ gnu/gcj/runtime/MethodRef.java \ gnu/gcj/runtime/NameFinder.java \ +gnu/gcj/runtime/SharedLibHelper.java \ gnu/gcj/runtime/SharedLibLoader.java \ gnu/gcj/runtime/StackTrace.java \ gnu/gcj/runtime/StringBuffer.java \ @@ -1886,8 +1897,12 @@ gnu/java/locale/LocaleInformation_zh_SG.java \ gnu/java/locale/LocaleInformation_zh_TW.java \ gnu/java/math/MPN.java \ +gnu/java/net/PlainDatagramSocketImpl.java \ +gnu/java/net/PlainSocketImpl.java \ gnu/java/nio/DatagramChannelImpl.java \ gnu/java/nio/FileLockImpl.java \ +gnu/java/nio/NIODatagramSocket.java \ +gnu/java/nio/NIOSocket.java \ gnu/java/nio/PipeImpl.java \ gnu/java/nio/SelectionKeyImpl.java \ gnu/java/nio/SelectorImpl.java \ @@ -1982,8 +1997,6 @@ java/net/NetworkInterface.java \ java/net/NoRouteToHostException.java \ java/net/PasswordAuthentication.java \ -java/net/PlainDatagramSocketImpl.java \ -java/net/PlainSocketImpl.java \ java/net/PortUnreachableException.java \ java/net/ProtocolException.java \ java/net/ServerSocket.java \ @@ -2353,6 +2366,8 @@ gnu/gcj/runtime/natStringBuffer.cc \ gnu/gcj/runtime/natVMClassLoader.cc \ gnu/java/awt/natEmbeddedWindow.cc \ +gnu/java/net/natPlainDatagramSocketImpl.cc \ +gnu/java/net/natPlainSocketImpl.cc \ gnu/java/nio/natFileLockImpl.cc \ gnu/java/nio/natSelectorImpl.cc \ java/io/natFile.cc \ @@ -2381,8 +2396,6 @@ java/lang/reflect/natProxy.cc \ java/net/natNetworkInterface.cc \ java/net/natInetAddress.cc \ -java/net/natPlainDatagramSocketImpl.cc \ -java/net/natPlainSocketImpl.cc \ java/nio/natDirectByteBufferImpl.cc \ java/nio/channels/natFileChannelImpl.cc \ java/text/natCollator.cc \ @@ -2530,20 +2543,21 @@ gnu/gcj/runtime/natNameFinder.lo gnu/gcj/runtime/natSharedLibLoader.lo \ gnu/gcj/runtime/natStackTrace.lo gnu/gcj/runtime/natStringBuffer.lo \ gnu/gcj/runtime/natVMClassLoader.lo gnu/java/awt/natEmbeddedWindow.lo \ -gnu/java/nio/natFileLockImpl.lo gnu/java/nio/natSelectorImpl.lo \ -java/io/natFile.lo java/io/natFileDescriptor.lo \ -java/io/natObjectInputStream.lo java/io/natVMObjectStreamClass.lo \ -java/lang/natCharacter.lo java/lang/natClass.lo \ -java/lang/natClassLoader.lo java/lang/natConcreteProcess.lo \ -java/lang/natDouble.lo java/lang/natFloat.lo java/lang/natMath.lo \ -java/lang/natObject.lo java/lang/natRuntime.lo java/lang/natString.lo \ +gnu/java/net/natPlainDatagramSocketImpl.lo \ +gnu/java/net/natPlainSocketImpl.lo gnu/java/nio/natFileLockImpl.lo \ +gnu/java/nio/natSelectorImpl.lo java/io/natFile.lo \ +java/io/natFileDescriptor.lo java/io/natObjectInputStream.lo \ +java/io/natVMObjectStreamClass.lo java/lang/natCharacter.lo \ +java/lang/natClass.lo java/lang/natClassLoader.lo \ +java/lang/natConcreteProcess.lo java/lang/natDouble.lo \ +java/lang/natFloat.lo java/lang/natMath.lo java/lang/natObject.lo \ +java/lang/natRuntime.lo java/lang/natString.lo \ java/lang/natStringBuffer.lo java/lang/natSystem.lo \ java/lang/natThread.lo java/lang/natVMSecurityManager.lo \ java/lang/ref/natReference.lo java/lang/reflect/natArray.lo \ java/lang/reflect/natConstructor.lo java/lang/reflect/natField.lo \ java/lang/reflect/natMethod.lo java/lang/reflect/natProxy.lo \ java/net/natNetworkInterface.lo java/net/natInetAddress.lo \ -java/net/natPlainDatagramSocketImpl.lo java/net/natPlainSocketImpl.lo \ java/nio/natDirectByteBufferImpl.lo \ java/nio/channels/natFileChannelImpl.lo java/text/natCollator.lo \ java/util/natResourceBundle.lo java/util/natTimeZone.lo \ @@ -2696,13 +2710,14 @@ DATA = $(jar_DATA) $(pkgconfig_DATA) $(toolexecmainlib_DATA) DIST_COMMON = README COPYING ChangeLog Makefile.am Makefile.in NEWS \ -THANKS acinclude.m4 aclocal.m4 configure configure.in \ -libgcj-test.spec.in libgcj.pc.in libgcj.spec.in +THANKS acinclude.m4 aclocal.m4 config.guess config.sub configure \ +configure.in install-sh libgcj-test.spec.in libgcj.pc.in libgcj.spec.in \ +ltmain.sh missing mkinstalldirs DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = gtar +TAR = tar GZIP_ENV = --best DIST_SUBDIRS = @DIRLTDL@ testsuite gcj include @DIRLTDL@ gcj include DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ @@ -2752,6 +2767,8 @@ .deps/gnu/gcj/protocol/core/natCoreInputStream.P \ .deps/gnu/gcj/protocol/file/Connection.P \ .deps/gnu/gcj/protocol/file/Handler.P \ +.deps/gnu/gcj/protocol/gcjlib/Connection.P \ +.deps/gnu/gcj/protocol/gcjlib/Handler.P \ .deps/gnu/gcj/protocol/http/Connection.P \ .deps/gnu/gcj/protocol/http/Handler.P \ .deps/gnu/gcj/protocol/jar/Connection.P \ @@ -2760,6 +2777,7 @@ .deps/gnu/gcj/runtime/FinalizerThread.P \ .deps/gnu/gcj/runtime/FirstThread.P .deps/gnu/gcj/runtime/JNIWeakRef.P \ .deps/gnu/gcj/runtime/MethodRef.P .deps/gnu/gcj/runtime/NameFinder.P \ +.deps/gnu/gcj/runtime/SharedLibHelper.P \ .deps/gnu/gcj/runtime/SharedLibLoader.P \ .deps/gnu/gcj/runtime/StackTrace.P .deps/gnu/gcj/runtime/StringBuffer.P \ .deps/gnu/gcj/runtime/VMClassLoader.P \ @@ -3000,9 +3018,15 @@ .deps/gnu/java/locale/LocaleInformation_zh_HK.P \ .deps/gnu/java/locale/LocaleInformation_zh_SG.P \ .deps/gnu/java/locale/LocaleInformation_zh_TW.P \ -.deps/gnu/java/math/MPN.P .deps/gnu/java/nio/DatagramChannelImpl.P \ -.deps/gnu/java/nio/FileLockImpl.P .deps/gnu/java/nio/PipeImpl.P \ -.deps/gnu/java/nio/SelectionKeyImpl.P .deps/gnu/java/nio/SelectorImpl.P \ +.deps/gnu/java/math/MPN.P .deps/gnu/java/net/PlainDatagramSocketImpl.P \ +.deps/gnu/java/net/PlainSocketImpl.P \ +.deps/gnu/java/net/natPlainDatagramSocketImpl.P \ +.deps/gnu/java/net/natPlainSocketImpl.P \ +.deps/gnu/java/nio/DatagramChannelImpl.P \ +.deps/gnu/java/nio/FileLockImpl.P \ +.deps/gnu/java/nio/NIODatagramSocket.P .deps/gnu/java/nio/NIOSocket.P \ +.deps/gnu/java/nio/PipeImpl.P .deps/gnu/java/nio/SelectionKeyImpl.P \ +.deps/gnu/java/nio/SelectorImpl.P \ .deps/gnu/java/nio/SelectorProviderImpl.P \ .deps/gnu/java/nio/ServerSocketChannelImpl.P \ .deps/gnu/java/nio/SocketChannelImpl.P \ @@ -3024,9 +3048,12 @@ .deps/gnu/java/rmi/registry/RegistryImpl_Skel.P \ .deps/gnu/java/rmi/registry/RegistryImpl_Stub.P \ .deps/gnu/java/rmi/rmic/Compile_gcj.P \ +.deps/gnu/java/rmi/rmic/Compile_jikes.P \ +.deps/gnu/java/rmi/rmic/Compile_kjc.P \ .deps/gnu/java/rmi/rmic/Compiler.P \ .deps/gnu/java/rmi/rmic/CompilerProcess.P \ -.deps/gnu/java/rmi/rmic/RMIC.P .deps/gnu/java/rmi/rmic/TabbedWriter.P \ +.deps/gnu/java/rmi/rmic/RMIC.P .deps/gnu/java/rmi/rmic/RMICException.P \ +.deps/gnu/java/rmi/rmic/TabbedWriter.P \ .deps/gnu/java/rmi/server/ConnectionRunnerPool.P \ .deps/gnu/java/rmi/server/ProtocolConstants.P \ .deps/gnu/java/rmi/server/RMIDefaultSocketFactory.P \ @@ -3500,8 +3527,6 @@ .deps/java/net/NetPermission.P .deps/java/net/NetworkInterface.P \ .deps/java/net/NoRouteToHostException.P \ .deps/java/net/PasswordAuthentication.P \ -.deps/java/net/PlainDatagramSocketImpl.P \ -.deps/java/net/PlainSocketImpl.P \ .deps/java/net/PortUnreachableException.P \ .deps/java/net/ProtocolException.P .deps/java/net/ServerSocket.P \ .deps/java/net/Socket.P .deps/java/net/SocketAddress.P \ @@ -3517,9 +3542,7 @@ .deps/java/net/UnknownHostException.P \ .deps/java/net/UnknownServiceException.P \ .deps/java/net/natInetAddress.P .deps/java/net/natNetworkInterface.P \ -.deps/java/net/natPlainDatagramSocketImpl.P \ -.deps/java/net/natPlainSocketImpl.P .deps/java/nio/Buffer.P \ -.deps/java/nio/BufferOverflowException.P \ +.deps/java/nio/Buffer.P .deps/java/nio/BufferOverflowException.P \ .deps/java/nio/BufferUnderflowException.P .deps/java/nio/ByteBuffer.P \ .deps/java/nio/ByteBufferImpl.P .deps/java/nio/ByteOrder.P \ .deps/java/nio/CharBuffer.P .deps/java/nio/CharBufferImpl.P \ @@ -4793,7 +4816,8 @@ mostlyclean-am: mostlyclean-toolexeclibLTLIBRARIES mostlyclean-compile \ mostlyclean-libtool mostlyclean-binPROGRAMS \ mostlyclean-noinstPROGRAMS mostlyclean-tags \ - mostlyclean-depend mostlyclean-generic + mostlyclean-depend mostlyclean-generic \ + mostlyclean-local mostlyclean: mostlyclean-recursive @@ -4806,7 +4830,8 @@ distclean-am: distclean-toolexeclibLTLIBRARIES distclean-compile \ distclean-libtool distclean-binPROGRAMS \ distclean-noinstPROGRAMS distclean-tags \ - distclean-depend distclean-generic clean-am + distclean-depend distclean-generic clean-am \ + distclean-local -rm -f libtool distclean: distclean-recursive @@ -4858,17 +4883,43 @@ echo "$(GCJH) -jni -d jniinclude -classpath '' -bootclasspath $(top_builddir) $$input"; \ $(GCJH) -jni -d jniinclude -classpath '' -bootclasspath $(top_builddir) $$input -libgcj- at gcc_version@.jar: $(all_java_source_files) - - at rm -f libgcj- at gcc_version@.jar - @echo Compiling Java sourcefiles... - @: $(call write_entries_to_file,$?,libgcj.sourcelist) - $(JAVAC) $(JCFLAGS) -classpath '' -bootclasspath $(here):$(srcdir) -d $(here) @libgcj.sourcelist - find java gnu javax org -type d -o -type f -name '*.class' | \ - sed -e '/\/\./d' -e '/\/xlib/d' | \ - $(ZIP) cfM0E@ $@ +# Compile all classfiles in one go. + + at ONESTEP_TRUE@libgcj- at gcc_version@.jar: $(all_java_source_files) + at ONESTEP_TRUE@ - at rm -f libgcj- at gcc_version@.jar + at ONESTEP_TRUE@ @echo Compiling Java sourcefiles... + at ONESTEP_TRUE@ @: $(call write_entries_to_file,$?,libgcj.sourcelist) + at ONESTEP_TRUE@ $(JAVAC) $(JCFLAGS) -classpath '' -bootclasspath $(here):$(srcdir) -d $(here) @libgcj.sourcelist + at ONESTEP_TRUE@ find java gnu javax org -type d -o -type f -name '*.class' | \ + at ONESTEP_TRUE@ sed -e '/\/\./d' -e '/\/xlib/d' | \ + at ONESTEP_TRUE@ $(ZIP) cfM0E@ $@ + +# This next rule seems backward, but reflects the fact +# that 1) all classfiles are compiled in one go when the +# libgcj jarfile is built and 2) anything which depends +# on a particular .class file must wait until the jarfile +# is built. + at ONESTEP_TRUE@$(all_java_class_files): libgcj- at gcc_version@.jar + +# Compile each classfile individually. + + at ONESTEP_FALSE@.java.class: + at ONESTEP_FALSE@ $(JAVAC) $(JCFLAGS) -classpath '' -bootclasspath $(here):$(srcdir) -d $(here) $< + + at ONESTEP_FALSE@libgcj- at gcc_version@.jar: $(all_java_class_files) + at ONESTEP_FALSE@ - at rm -f libgcj- at gcc_version@.jar + at ONESTEP_FALSE@ find java gnu javax org -type d -o -type f -name '*.class' | \ + at ONESTEP_FALSE@ sed -e '/\/\./d' -e '/\/xlib/d' | \ + at ONESTEP_FALSE@ $(ZIP) cfM0E@ $@ + +mostlyclean-local: + find . -name '*.lo' -print | xargs $(LIBTOOL) rm -f clean-local: find . -name '*.class' -print | xargs rm -f + +distclean-local: + find . -name '*.d' -print | xargs rm -f # Just remove the objects from C++ sources, for testing the C++ compiler. clean-nat: From criswell at cs.uiuc.edu Thu Feb 5 10:09:00 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:09:00 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/config/mips/mips-protos.h mips.c mips.h Message-ID: <200402051606.KAA27049@choi.cs.uiuc.edu> Changes in directory gcc-3.4/gcc/config/mips: mips-protos.h updated: 1.2 -> 1.3 mips.c updated: 1.2 -> 1.3 mips.h updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+72 -51) Index: gcc-3.4/gcc/config/mips/mips-protos.h diff -u gcc-3.4/gcc/config/mips/mips-protos.h:1.2 gcc-3.4/gcc/config/mips/mips-protos.h:1.3 --- gcc-3.4/gcc/config/mips/mips-protos.h:1.2 Fri Jan 9 10:54:31 2004 +++ gcc-3.4/gcc/config/mips/mips-protos.h Thu Feb 5 10:05:46 2004 @@ -1,6 +1,6 @@ /* Prototypes of target machine for GNU compiler. MIPS version. Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2001, 2002 Free Software Foundation, Inc. + 1999, 2001, 2002, 2003 Free Software Foundation, Inc. Contributed by A. Lichnewsky (lich at inria.inria.fr). Changed by Michael Meissner (meissner at osf.org). 64 bit r4000 support by Ian Lance Taylor (ian at cygnus.com) and @@ -98,8 +98,8 @@ extern void print_operand (FILE *, rtx, int); extern void print_operand_address (FILE *, rtx); extern int mips_output_external (FILE *, tree, const char *); -#ifdef ASM_OUTPUT_UNDEF_FUNCTION -extern int mips_output_external_libcall (FILE *, const char *); +#if TARGET_IRIX5 || TARGET_IRIX6 +extern void mips_output_external_libcall (rtx); #endif extern void mips_output_filename (FILE *, const char *); extern void mips_output_lineno (FILE *, int); Index: gcc-3.4/gcc/config/mips/mips.c diff -u gcc-3.4/gcc/config/mips/mips.c:1.2 gcc-3.4/gcc/config/mips/mips.c:1.3 --- gcc-3.4/gcc/config/mips/mips.c:1.2 Fri Jan 9 10:54:31 2004 +++ gcc-3.4/gcc/config/mips/mips.c Thu Feb 5 10:05:46 2004 @@ -1081,7 +1081,7 @@ daddu $at,$at,$gp and the final address is $at + %got_lo(symbol). */ - return (flag_pic == 1 ? 1 : 3); + return (TARGET_XGOT ? 3 : 1); case SYMBOL_GOT_LOCAL: /* For o32 and o64, the sequence is: @@ -1303,6 +1303,28 @@ } } +/* Accept a register or the floating point constant 1 in the appropriate mode. */ + +int +reg_or_const_float_1_operand (rtx op, enum machine_mode mode) +{ + REAL_VALUE_TYPE d; + + switch (GET_CODE (op)) + { + case CONST_DOUBLE: + if (mode != GET_MODE (op) + || (mode != DFmode && mode != SFmode)) + return 0; + + REAL_VALUE_FROM_CONST_DOUBLE (d, op); + return REAL_VALUES_EQUAL (d, dconst1); + + default: + return register_operand (op, mode); + } +} + /* Accept the floating point constant 1 in the appropriate mode. */ int @@ -1881,10 +1903,10 @@ && GET_CODE (src) == SYMBOL_REF && mips_classify_symbol (src) == SYMBOL_GOT_GLOBAL) { - if (flag_pic == 1) - src = mips_load_got16 (src, RELOC_GOT_DISP); - else + if (TARGET_XGOT) src = mips_load_got32 (temp, src, RELOC_GOT_HI, RELOC_GOT_LO); + else + src = mips_load_got16 (src, RELOC_GOT_DISP); emit_insn (gen_rtx_SET (VOIDmode, dest, src)); return; } @@ -3213,10 +3235,10 @@ && GET_CODE (addr) == SYMBOL_REF && mips_classify_symbol (addr) == SYMBOL_GOT_GLOBAL) { - if (flag_pic == 1) - addr = mips_load_got16 (addr, RELOC_CALL16); - else + if (TARGET_XGOT) addr = mips_load_got32 (0, addr, RELOC_CALL_HI, RELOC_CALL_LO); + else + addr = mips_load_got16 (addr, RELOC_CALL16); } addr = force_reg (Pmode, addr); } @@ -4632,8 +4654,7 @@ implemented. */ if (TARGET_ABICALLS) { - if (flag_pic == 0) - flag_pic = 1; + flag_pic = 1; if (mips_section_threshold > 0) warning ("-G is incompatible with PIC code which is the default"); } @@ -5496,19 +5517,20 @@ return 0; } -#ifdef ASM_OUTPUT_UNDEF_FUNCTION -int -mips_output_external_libcall (FILE *file ATTRIBUTE_UNUSED, const char *name) +#if TARGET_IRIX5 || TARGET_IRIX6 +void +mips_output_external_libcall (rtx fun) { register struct extern_list *p; - p = (struct extern_list *) ggc_alloc (sizeof (struct extern_list)); - p->next = extern_head; - p->name = name; - p->size = -1; - extern_head = p; - - return 0; + if (mips_abi == ABI_32) + { + p = (struct extern_list *) ggc_alloc (sizeof (struct extern_list)); + p->next = extern_head; + p->name = XSTR (fun, 0); + p->size = -1; + extern_head = p; + } } #endif @@ -5934,7 +5956,7 @@ if (regno == GP_REG_FIRST + 31 && mips16_hard_float && !mips_entry - && !aggregate_value_p (return_type) + && !aggregate_value_p (return_type, current_function_decl) && GET_MODE_CLASS (DECL_MODE (return_type)) == MODE_FLOAT && GET_MODE_SIZE (DECL_MODE (return_type)) <= UNITS_PER_FPVALUE) return true; @@ -6713,9 +6735,9 @@ REGNO (pic_offset_table_rtx) = cfun->machine->global_pointer; /* If struct value address is treated as the first argument, make it so. */ - if (aggregate_value_p (DECL_RESULT (fndecl)) + if (aggregate_value_p (DECL_RESULT (fndecl), fndecl) && ! current_function_returns_pcc_struct - && struct_value_incoming_rtx == 0) + && targetm.calls.struct_value_rtx (fndecl, 0) == 0) { tree type = build_pointer_type (fntype); tree function_result_decl = build_decl (PARM_DECL, NULL_TREE, type); @@ -7180,7 +7202,7 @@ registers. */ if (TARGET_MIPS16 && mips16_hard_float - && ! aggregate_value_p (return_type) + && ! aggregate_value_p (return_type, current_function_decl) && GET_MODE_CLASS (DECL_MODE (return_type)) == MODE_FLOAT && GET_MODE_SIZE (DECL_MODE (return_type)) <= UNITS_PER_FPVALUE) return 0; Index: gcc-3.4/gcc/config/mips/mips.h diff -u gcc-3.4/gcc/config/mips/mips.h:1.2 gcc-3.4/gcc/config/mips/mips.h:1.3 --- gcc-3.4/gcc/config/mips/mips.h:1.2 Fri Jan 9 10:54:31 2004 +++ gcc-3.4/gcc/config/mips/mips.h Thu Feb 5 10:05:46 2004 @@ -153,7 +153,7 @@ #define MASK_SOFT_FLOAT 0x00000100 /* software floating point */ #define MASK_FLOAT64 0x00000200 /* fp registers are 64 bits */ #define MASK_ABICALLS 0x00000400 /* emit .abicalls/.cprestore/.cpload */ -#define MASK_UNUSED1 0x00000800 /* Unused Mask. */ +#define MASK_XGOT 0x00000800 /* emit big-got PIC */ #define MASK_LONG_CALLS 0x00001000 /* Always call through a register */ #define MASK_64BIT 0x00002000 /* Use 64 bit GP registers and insns */ #define MASK_EMBEDDED_PIC 0x00004000 /* Generate embedded PIC code */ @@ -218,6 +218,7 @@ /* .abicalls, etc from Pyramid V.4 */ #define TARGET_ABICALLS (target_flags & MASK_ABICALLS) +#define TARGET_XGOT (target_flags & MASK_XGOT) /* software floating point */ #define TARGET_SOFT_FLOAT (target_flags & MASK_SOFT_FLOAT) @@ -514,9 +515,9 @@ N_("Use GP relative sdata/sbss sections (now ignored)")}, \ {"gpopt", 0, \ N_("Use GP relative sdata/sbss sections (now ignored)")}, \ - {"no-gpOPT", 0, \ + {"no-gpOPT", 0, \ N_("Don't use GP relative sdata/sbss sections (now ignored)")}, \ - {"no-gpopt", 0, \ + {"no-gpopt", 0, \ N_("Don't use GP relative sdata/sbss sections (now ignored)")}, \ {"stats", 0, \ N_("Output compiler statistics (now ignored)")}, \ @@ -602,6 +603,10 @@ N_("Generate mips16 code") }, \ {"no-mips16", -MASK_MIPS16, \ N_("Generate normal-mode code") }, \ + {"xgot", MASK_XGOT, \ + N_("Lift restrictions on GOT size") }, \ + {"no-xgot", -MASK_XGOT, \ + N_("Do not lift restrictions on GOT size") }, \ {"debug", MASK_DEBUG, \ NULL}, \ {"debuga", MASK_DEBUG_A, \ @@ -1082,7 +1087,7 @@ %{membedded-pic} \ %{mabi=32:-32}%{mabi=n32:-n32}%{mabi=64:-64}%{mabi=n64:-64} \ %{mabi=eabi} %{mabi=o64} %{!mabi*: %(asm_abi_default_spec)} \ -%{mgp32} %{mgp64} %{march=*} \ +%{mgp32} %{mgp64} %{march=*} %{mxgot:-xgot} \ %(target_asm_spec) \ %(subtarget_asm_spec)" @@ -1410,12 +1415,7 @@ on the full register even if a narrower mode is specified. */ #define WORD_REGISTER_OPERATIONS -/* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD - will either zero-extend or sign-extend. The value of this macro should - be the code that says which one of the two operations is implicitly - done, NIL if none. - - When in 64 bit mode, mips_move_1word will sign extend SImode and CCmode +/* When in 64 bit mode, move insns will sign extend SImode and CCmode moves. All other references are zero extended. */ #define LOAD_EXTEND_OP(MODE) \ (TARGET_64BIT && ((MODE) == SImode || (MODE) == CCmode) \ @@ -1804,31 +1804,31 @@ sub-initializer must be suitable as an initializer for the type `HARD_REG_SET' which is defined in `hard-reg-set.h'. */ -#define REG_CLASS_CONTENTS \ -{ \ +#define REG_CLASS_CONTENTS \ +{ \ { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* no registers */ \ { 0x0003000c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* mips16 nonarg regs */\ { 0x000300fc, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* mips16 registers */ \ { 0x01000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* mips16 T register */ \ { 0x010300fc, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* mips16 and T regs */ \ { 0x02000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* SVR4 PIC function address register */ \ - { 0xfdffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* Every other GPR */ \ + { 0xfdffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* Every other GPR */ \ { 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* integer registers */ \ { 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* floating registers*/ \ { 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000 }, /* hi register */ \ { 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000 }, /* lo register */ \ { 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000 }, /* mul/div registers */ \ - { 0x00000000, 0x00000000, 0xffff0000, 0x0000ffff, 0x00000000, 0x00000000 }, /* cop0 registers */ \ - { 0x00000000, 0x00000000, 0x00000000, 0xffff0000, 0x0000ffff, 0x00000000 }, /* cop2 registers */ \ - { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffff0000, 0x0000ffff }, /* cop3 registers */ \ + { 0x00000000, 0x00000000, 0xffff0000, 0x0000ffff, 0x00000000, 0x00000000 }, /* cop0 registers */ \ + { 0x00000000, 0x00000000, 0x00000000, 0xffff0000, 0x0000ffff, 0x00000000 }, /* cop2 registers */ \ + { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffff0000, 0x0000ffff }, /* cop3 registers */ \ { 0xffffffff, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000 }, /* union classes */ \ { 0xffffffff, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000 }, \ { 0x00000000, 0xffffffff, 0x00000001, 0x00000000, 0x00000000, 0x00000000 }, \ - { 0xffffffff, 0x00000000, 0xffff0000, 0x0000ffff, 0x00000000, 0x00000000 }, \ - { 0xffffffff, 0x00000000, 0x00000000, 0xffff0000, 0x0000ffff, 0x00000000 }, \ - { 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0xffff0000, 0x0000ffff }, \ - { 0x00000000, 0x00000000, 0xffff0000, 0xffffffff, 0xffffffff, 0x0000ffff }, \ - { 0xffffffff, 0x00000000, 0xffff0000, 0xffffffff, 0xffffffff, 0x0000ffff }, \ + { 0xffffffff, 0x00000000, 0xffff0000, 0x0000ffff, 0x00000000, 0x00000000 }, \ + { 0xffffffff, 0x00000000, 0x00000000, 0xffff0000, 0x0000ffff, 0x00000000 }, \ + { 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0xffff0000, 0x0000ffff }, \ + { 0x00000000, 0x00000000, 0xffff0000, 0xffffffff, 0xffffffff, 0x0000ffff }, \ + { 0xffffffff, 0x00000000, 0xffff0000, 0xffffffff, 0xffffffff, 0x0000ffff }, \ { 0x00000000, 0x00000000, 0x000007f8, 0x00000000, 0x00000000, 0x00000000 }, /* status registers */ \ { 0xffffffff, 0xffffffff, 0xffff07ff, 0xffffffff, 0xffffffff, 0x0000ffff } /* all registers */ \ } @@ -2663,9 +2663,7 @@ /* Specify the machine mode that this machine uses for the index in the tablejump instruction. - ??? Using HImode in mips16 mode can cause overflow. However, the - overflow is no more likely than the overflow in a branch - instruction. Large functions can currently break in both ways. */ + ??? Using HImode in mips16 mode can cause overflow. */ #define CASE_VECTOR_MODE \ (TARGET_MIPS16 ? HImode : ptr_mode) @@ -2803,6 +2801,7 @@ {"small_int", { CONST_INT }}, \ {"mips_const_double_ok", { CONST_DOUBLE }}, \ {"const_float_1_operand", { CONST_DOUBLE }}, \ + {"reg_or_const_float_1_operand", { CONST_DOUBLE, REG}}, \ {"simple_memory_operand", { MEM, SUBREG }}, \ {"equality_op", { EQ, NE }}, \ {"cmp_op", { EQ, NE, GT, GE, GTU, GEU, LT, LE, \ @@ -3361,7 +3360,7 @@ do { \ if (TARGET_EMBEDDED_PIC || TARGET_MIPS16) \ function_section (current_function_decl); \ - (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); \ + (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); \ } while (0) /* This is how to output an assembler line From criswell at cs.uiuc.edu Thu Feb 5 10:09:09 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:09:09 2004 Subject: [llvm-commits] CVS: gcc-3.4/libstdc++-v3/libmath/Makefile.in Message-ID: <200402051606.KAA27003@choi.cs.uiuc.edu> Changes in directory gcc-3.4/libstdc++-v3/libmath: Makefile.in updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+1 -1) Index: gcc-3.4/libstdc++-v3/libmath/Makefile.in diff -u gcc-3.4/libstdc++-v3/libmath/Makefile.in:1.2 gcc-3.4/libstdc++-v3/libmath/Makefile.in:1.3 --- gcc-3.4/libstdc++-v3/libmath/Makefile.in:1.2 Fri Jan 9 10:54:35 2004 +++ gcc-3.4/libstdc++-v3/libmath/Makefile.in Thu Feb 5 10:05:49 2004 @@ -204,7 +204,7 @@ noinst_LTLIBRARIES = libmath.la -libmath_la_LIBADD = @LIBMATHOBJS@ +libmath_la_LIBADD = $(LIBMATHOBJS) libmath_la_DEPENDENCIES = $(libmath_la_LIBADD) From criswell at cs.uiuc.edu Thu Feb 5 10:09:18 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:09:18 2004 Subject: [llvm-commits] CVS: gcc-3.4/libstdc++-v3/ChangeLog Makefile.in acinclude.m4 aclocal.m4 configure configure.ac Message-ID: <200402051606.KAA27109@choi.cs.uiuc.edu> Changes in directory gcc-3.4/libstdc++-v3: ChangeLog updated: 1.2 -> 1.3 Makefile.in updated: 1.2 -> 1.3 acinclude.m4 updated: 1.2 -> 1.3 aclocal.m4 updated: 1.2 -> 1.3 configure updated: 1.2 -> 1.3 configure.ac updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+358 -61) Index: gcc-3.4/libstdc++-v3/ChangeLog diff -u gcc-3.4/libstdc++-v3/ChangeLog:1.2 gcc-3.4/libstdc++-v3/ChangeLog:1.3 --- gcc-3.4/libstdc++-v3/ChangeLog:1.2 Fri Jan 9 10:54:34 2004 +++ gcc-3.4/libstdc++-v3/ChangeLog Thu Feb 5 10:05:48 2004 @@ -1,3 +1,172 @@ +2003-09-23 Benjamin Kosnik + + * include/bits/locale_facets.tcc: Tweak to avoid warnings. + * testsuite/testsuite_hooks.h: Same. + * testsuite/*/*.cc: Same. + +2003-09-22 Petur Runolfsson + + * include/bits/istream.tcc (basic_istream::read, + basic_istream::readsome, basic_istream::putback, + basic_istream::unget, operator>>(basic_istream, CharT)): + Avoid redundant setstate(failbit) calls when sentry::operator bool() + returns false. + +2003-09-22 Carlo Wood + + PR libstdc++/12365 + * include/bits/demangle.h (qualifier(int, cv_qualifier_nt, + char const*, int, int)): Remove unused identifier + cv_qualifier for overloaded constructor. + +2003-09-18 Benjamin Kosnik + + PR libstdc++/11504 + * acinclude.m4 (GLIBCXX_EXPORT_FLAGS): Add -Wcast-qual to + WARN_FLAGS, remove -Wno-format. + * aclocal.m4: Regenerate. + * configure: Regenerate. + +2003-09-18 Petur Runolfsson + + * config/io/basic_file_stdio.cc (sys_getc, sys_ungetc): Delete. + * config/io/basic_file_stdio.h: Same. + * include/std/std_fstream.h (__ctype_type): Delete. + * include/std/std_streambuf.h (__ctype_type, __state_type): Delete. + +2003-09-17 Benjamin Kosnik + + PR libstdc++/12239 + * configure.host (abi_baseline_pair): Error out on solaris2 + configurations without a minor version number. + +2003-09-13 Phil Edwards + + * docs/doxygen/run_doxygen: Clear GENERATE_TAGFILE entirely + if man pages are on. + * docs/doxygen/user.cfg.in: And here. + +2003-09-10 Daniel Jacobowitz + Andreas Jaeger + + PR libstdc++/12189 + * acinclude.m4 (GLIBCXX_CONFIGURE_TESTSUITE): Don't build + abi_check if cross compiling. + * aclocal.m4: Regenerated. + * configure: Regenerated. + +2003-09-10 Jeffrey D. Oldham + + * libsupc++/vec.cc (__cxa_vec_new2): If the allocator returns + NULL, return NULL. This reflects a C++ ABI change 2003 Sep 05. + (__cxa_vec_new3): Likewise. + +2003-09-10 Petur Runolfsson + + * include/bits/fstream.tcc (basic_filebuf::seekoff): + Use codecvt::length to handle variable-width stateless encodings + correctly. + * testsuite/27_io/basic_filebuf/seekoff/wchar_t/1.cc: New test. + * testsuite/27_io/basic_filebuf/seekoff/wchar_t/2.cc: New test. + +2003-09-10 Alan Modra + + * config/io/basic_file_stdio.cc (_M_open_mode): Assign __p_mode + rather than or'ing. + +2003-09-09 Alan Modra + + * configure: Regenerate. + +2003-09-09 David Edelsohn + + * src/ios.cc (ios_base::Init::Init): Remove unnecessary + qualifier from _S_synced_with_stdio. + +2003-09-09 Bernardo Innocenti + + * include/c_std/std_cstdlib.h: Avoid using missing C library symbols. + +2003-09-04 Petur Runolfsson + + PR libstdc++/9028 + * include/bits/fstream.tcc + (basic_filebuf::_M_destroy_internal_buffer): Destroy _M_ext_buf. + (basic_filebuf::basic_filebuf): Initialize _M_ext_buf, + _M_ext_buf_size, _M_ext_next and _M_ext_end. + (basic_filebuf::underflow): Handle variable-width stateless + encodings (codecvt::encoding() == 0), including UTF-8. + * include/std/std_fstream.h (basic_filebuf): + Declare _M_ext_buf, _M_ext_buf_size, _M_ext_next, _M_ext_end. + * testsuite/27_io/basic_filebuf/underflow/wchar_t/1.cc: New test. + * testsuite/27_io/basic_filebuf/underflow/wchar_t/2.cc: New test. + * testsuite/27_io/basic_filebuf/underflow/wchar_t/3.cc: New test. + * testsuite/27_io/basic_filebuf/underflow/wchar_t/4.cc: New test. + * testsuite/27_io/basic_filebuf/underflow/wchar_t/5.cc: New test. + * testsuite/27_io/objects/wchar_t/12.cc: New test. + * testsuite/27_io/objects/wchar_t/13.cc: New test. + +2003-09-04 Jonathan Wakely + + * docs/html/faq/index.html: Note that a namespace alias can't be + used when specialising templates in extension namespace. + * docs/html/faq/index.txt: Regenerate. + +2003-09-03 Petur Runolfsson + + PR libstdc++/12048 + * include/ext/stdio_sync_filebuf.h + (stdio_sync_filebuf::_M_unget_buf): Declare it. + (stdio_sync_filebuf::stdio_sync_filebuf): Initialize _M_unget_buf. + (stdio_sync_filebuf::uflow): Store the returned character in + _M_unget_buf. + (stdio_sync_filebuf::pbackfail): If argument is eof(), pass + _M_unget_buf to syncungetc(). Set _M_unget_buf to eof(). + (stdio_sync_filebuf::xsgetn): Store last read character in + _M_unget_buf, if any, else eof(). + (stdio_sync_filebuf::xsgetn: Store last read character in + _M_unget_buf, if any, else eof(). + * testsuite/27_io/objects/char/12048.cc: Rename to... + * testsuite/27_io/objects/char/12048-1.cc: ...this. + * testsuite/27_io/objects/char/12048-2.cc: New test. + * testsuite/27_io/objects/char/12048-3.cc: New test. + * testsuite/27_io/objects/char/12048-4.cc: New test. + * testsuite/27_io/objects/char/12048-5.cc: New test. XFAIL. + * testsuite/27_io/objects/wchar_t/12048-1.cc: New test. + * testsuite/27_io/objects/wchar_t/12048-2.cc: New test. + * testsuite/27_io/objects/wchar_t/12048-3.cc: New test. + * testsuite/27_io/objects/wchar_t/12048-4.cc: New test. + * testsuite/27_io/objects/wchar_t/12048-5.cc: New test. XFAIL. + * testsuite/ext/stdio_sync_filebuf_char.cc + (test02, test03, test04, test05): New tests. + * testsuite/ext/stdio_sync_filebuf_wchar_t.cc + (test02, test03, test04, test05): New tests. + +2003-09-03 Petur Runolfsson + + * docs/html/27_io/howto.html: setbuf(0, 0) has no effect on + stringbuf or strstreambuf. Fix typos. + +2003-09-02 Phil Edwards + + * acinclude.m4 (GLIBCXX_ENABLE_HOSTED): #define _GLIBCXX_HOSTED + appropriately. + * config.h.in: Add _GLIBCXX_HOSTED. + * libsupc++/eh_term_handler.cc: Test it here; initialize + __terminate_handler to std::abort if freestanding. + * aclocal.m4, configure: Regenerated. + * docs/html/configopts.html: Document --disable-hosted-libstdcxx. + +2003-08-29 Nathan Myers + + PR libstdc++/11990 + * include/bits/locale_facets.tcc (__pad): delete dead code. + +2003-08-28 Alan Modra + + * configure.ac: Test $with_cross_host against $build_alias, not $build. + * configure: Regenerate. + 2003-08-27 Petur Runolfsson * testsuite/27_io/objects/wchar_t/10.cc: Move wcout stuff... Index: gcc-3.4/libstdc++-v3/Makefile.in diff -u gcc-3.4/libstdc++-v3/Makefile.in:1.2 gcc-3.4/libstdc++-v3/Makefile.in:1.3 --- gcc-3.4/libstdc++-v3/Makefile.in:1.2 Fri Jan 9 10:54:34 2004 +++ gcc-3.4/libstdc++-v3/Makefile.in Thu Feb 5 10:05:48 2004 @@ -219,7 +219,7 @@ # -I/-D flags to pass when compiling. AM_CPPFLAGS = $(GLIBCXX_INCLUDES) @GLIBCXX_HOSTED_TRUE at hosted_source = src po -SUBDIRS = include libmath libsupc++ $(hosted_source) testsuite +SUBDIRS = include libmath libsupc++ $(hosted_source) testsuite # Multilib support. MAKEOVERRIDES = @@ -273,7 +273,7 @@ "NM_FOR_BUILD=$(NM_FOR_BUILD)" \ "NM_FOR_TARGET=$(NM_FOR_TARGET)" \ "DESTDIR=$(DESTDIR)" \ - "WERROR=$(WERROR)" + "WERROR=$(WERROR)" # Subdir rules rely on $(FLAGS_TO_PASS) Index: gcc-3.4/libstdc++-v3/acinclude.m4 diff -u gcc-3.4/libstdc++-v3/acinclude.m4:1.2 gcc-3.4/libstdc++-v3/acinclude.m4:1.3 --- gcc-3.4/libstdc++-v3/acinclude.m4:1.2 Fri Jan 9 10:54:34 2004 +++ gcc-3.4/libstdc++-v3/acinclude.m4 Thu Feb 5 10:05:48 2004 @@ -585,24 +585,27 @@ # Look for setenv, so that extended locale tests can be performed. GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv) + + if test $enable_symvers = no; then + enable_abi_check=no + else + case "$host" in + *-*-cygwin*) + enable_abi_check=no ;; + *) + enable_abi_check=yes ;; + esac + fi + else + # Only build this as native, since automake does not understand + # CXX_FOR_BUILD. + enable_abi_check=no fi # Export file names for ABI checking. baseline_dir="$glibcxx_srcdir/config/abi/${abi_baseline_pair}\$(MULTISUBDIR)" AC_SUBST(baseline_dir) - # Determine if checking the ABI is desirable. - if test $enable_symvers = no || test $is_hosted = no; then - enable_abi_check=no - else - case "$host" in - *-*-cygwin*) - enable_abi_check=no ;; - *) - enable_abi_check=yes ;; - esac - fi - GLIBCXX_CONDITIONAL(GLIBCXX_TEST_WCHAR_T, test $enable_wchar_t = yes) GLIBCXX_CONDITIONAL(GLIBCXX_TEST_ABI, test $enable_abi_check = yes) ]) @@ -653,7 +656,7 @@ OPTIMIZE_CXXFLAGS= AC_SUBST(OPTIMIZE_CXXFLAGS) - WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings' + WARN_FLAGS='-Wall -W -Wwrite-strings -Wcast-qual' AC_SUBST(WARN_FLAGS) ]) @@ -1276,6 +1279,9 @@ dnl Sets: dnl is_hosted (yes/no) dnl +dnl Defines: +dnl _GLIBCXX_HOSTED (always defined, either to 1 or 0) +dnl AC_DEFUN(GLIBCXX_ENABLE_HOSTED, [ AC_ARG_ENABLE([hosted-libstdcxx], AC_HELP_STRING([--disable-hosted-libstdcxx], @@ -1284,12 +1290,16 @@ if test "$enable_hosted_libstdcxx" = no; then AC_MSG_NOTICE([Only freestanding libraries will be built]) is_hosted=no + hosted_define=0 enable_abi_check=no enable_libstdcxx_pch=no else is_hosted=yes + hosted_define=1 fi GLIBCXX_CONDITIONAL(GLIBCXX_HOSTED, test $is_hosted = yes) + AC_DEFINE_UNQUOTED(_GLIBCXX_HOSTED, $hosted_define, + [Define to 1 if a full hosted library is built, or 0 if freestanding.]) ]) Index: gcc-3.4/libstdc++-v3/aclocal.m4 diff -u gcc-3.4/libstdc++-v3/aclocal.m4:1.2 gcc-3.4/libstdc++-v3/aclocal.m4:1.3 --- gcc-3.4/libstdc++-v3/aclocal.m4:1.2 Fri Jan 9 10:54:34 2004 +++ gcc-3.4/libstdc++-v3/aclocal.m4 Thu Feb 5 10:05:48 2004 @@ -598,24 +598,27 @@ # Look for setenv, so that extended locale tests can be performed. GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv) + + if test $enable_symvers = no; then + enable_abi_check=no + else + case "$host" in + *-*-cygwin*) + enable_abi_check=no ;; + *) + enable_abi_check=yes ;; + esac + fi + else + # Only build this as native, since automake does not understand + # CXX_FOR_BUILD. + enable_abi_check=no fi # Export file names for ABI checking. baseline_dir="$glibcxx_srcdir/config/abi/${abi_baseline_pair}\$(MULTISUBDIR)" AC_SUBST(baseline_dir) - # Determine if checking the ABI is desirable. - if test $enable_symvers = no || test $is_hosted = no; then - enable_abi_check=no - else - case "$host" in - *-*-cygwin*) - enable_abi_check=no ;; - *) - enable_abi_check=yes ;; - esac - fi - GLIBCXX_CONDITIONAL(GLIBCXX_TEST_WCHAR_T, test $enable_wchar_t = yes) GLIBCXX_CONDITIONAL(GLIBCXX_TEST_ABI, test $enable_abi_check = yes) ]) @@ -666,7 +669,7 @@ OPTIMIZE_CXXFLAGS= AC_SUBST(OPTIMIZE_CXXFLAGS) - WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings' + WARN_FLAGS='-Wall -W -Wwrite-strings -Wcast-qual' AC_SUBST(WARN_FLAGS) ]) @@ -1289,6 +1292,9 @@ dnl Sets: dnl is_hosted (yes/no) dnl +dnl Defines: +dnl _GLIBCXX_HOSTED (always defined, either to 1 or 0) +dnl AC_DEFUN(GLIBCXX_ENABLE_HOSTED, [ AC_ARG_ENABLE([hosted-libstdcxx], AC_HELP_STRING([--disable-hosted-libstdcxx], @@ -1297,12 +1303,16 @@ if test "$enable_hosted_libstdcxx" = no; then AC_MSG_NOTICE([Only freestanding libraries will be built]) is_hosted=no + hosted_define=0 enable_abi_check=no enable_libstdcxx_pch=no else is_hosted=yes + hosted_define=1 fi GLIBCXX_CONDITIONAL(GLIBCXX_HOSTED, test $is_hosted = yes) + AC_DEFINE_UNQUOTED(_GLIBCXX_HOSTED, $hosted_define, + [Define to 1 if a full hosted library is built, or 0 if freestanding.]) ]) Index: gcc-3.4/libstdc++-v3/configure diff -u gcc-3.4/libstdc++-v3/configure:1.2 gcc-3.4/libstdc++-v3/configure:1.3 --- gcc-3.4/libstdc++-v3/configure:1.2 Fri Jan 9 10:54:34 2004 +++ gcc-3.4/libstdc++-v3/configure Thu Feb 5 10:05:48 2004 @@ -971,7 +971,7 @@ else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi - cd "$ac_popdir" + cd $ac_popdir done fi @@ -1170,7 +1170,7 @@ echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 - rm -f core *.core && + rm -f core core.* *.core && rm -rf conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 @@ -2800,7 +2800,8 @@ echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then for ac_declaration in \ - '' \ + ''\ + '#include ' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ @@ -2814,8 +2815,8 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_declaration #include +$ac_declaration int main () { @@ -3125,7 +3126,8 @@ fi fi for ac_declaration in \ - '' \ + ''\ + '#include ' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ @@ -3139,8 +3141,8 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_declaration #include +$ac_declaration int main () { @@ -4265,7 +4267,7 @@ case $host in *-*-irix6*) # Find out which ABI we are using. - echo '#line 4268 "configure"' > conftest.$ac_ext + echo '#line 4270 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -4334,7 +4336,7 @@ x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; - ppc64-*linux*) + ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) @@ -4819,13 +4821,20 @@ { echo "$as_me:$LINENO: Only freestanding libraries will be built" >&5 echo "$as_me: Only freestanding libraries will be built" >&6;} is_hosted=no + hosted_define=0 enable_abi_check=no enable_libstdcxx_pch=no else is_hosted=yes + hosted_define=1 fi +cat >>confdefs.h <<_ACEOF +#define _GLIBCXX_HOSTED $hosted_define +_ACEOF + + # Check for support bits and g++ features that don't require linking. @@ -4862,7 +4871,7 @@ # # Fake what AC_TRY_COMPILE does. XXX Look at redoing this new-style. cat > conftest.$ac_ext << EOF -#line 4865 "configure" +#line 4874 "configure" struct S { ~S(); }; void bar(); void foo() @@ -5453,7 +5462,7 @@ ( exit $ac_status ) ac_cv_header_stdc=no fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi @@ -5644,7 +5653,7 @@ ( exit $ac_status ) enable_clocale_flag=generic fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi @@ -7800,7 +7809,7 @@ ( exit $ac_status ) ac_sectionLDflags=no fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" @@ -27274,7 +27283,7 @@ ( exit $ac_status ) ac_cv_func_mmap_fixed_mapped=no fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi echo "$as_me:$LINENO: result: $ac_cv_func_mmap_fixed_mapped" >&5 @@ -27309,7 +27318,7 @@ # If Canadian cross, then don't pick up tools from the build directory. # Used only in GLIBCXX_EXPORT_INCLUDES. if test -n "$with_cross_host" && - test x"$build" != x"$with_cross_host" && + test x"$build_alias" != x"$with_cross_host" && test x"$build" != x"$target"; then CANADIAN=yes @@ -46814,7 +46823,7 @@ ( exit $ac_status ) ac_sectionLDflags=no fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" @@ -48864,7 +48873,7 @@ ( exit $ac_status ) ac_sectionLDflags=no fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" @@ -50783,7 +50792,7 @@ ( exit $ac_status ) ac_sectionLDflags=no fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" @@ -52711,7 +52720,7 @@ ( exit $ac_status ) ac_sectionLDflags=no fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" @@ -54586,7 +54595,7 @@ ( exit $ac_status ) ac_sectionLDflags=no fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" @@ -56360,7 +56369,7 @@ ( exit $ac_status ) ac_sectionLDflags=no fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" @@ -59005,23 +59014,122 @@ fi + + if test $enable_symvers = no; then + enable_abi_check=no + else + case "$host" in + *-*-cygwin*) + enable_abi_check=no ;; + *) + enable_abi_check=yes ;; + esac + fi + else + # Only build this as native, since automake does not understand + # CXX_FOR_BUILD. + enable_abi_check=no fi # Export file names for ABI checking. baseline_dir="$glibcxx_srcdir/config/abi/${abi_baseline_pair}\$(MULTISUBDIR)" - # Determine if checking the ABI is desirable. - if test $enable_symvers = no || test $is_hosted = no; then - enable_abi_check=no - else - case "$host" in - *-*-cygwin*) - enable_abi_check=no ;; - *) - enable_abi_check=yes ;; - esac - fi + + + + +# Propagate the target-specific source directories through the build chain. +# (Nothing currently uses cpu_include_dir directly; only atomicity_include_dir +# uses it, and it only gets used in this file.) +ATOMICITY_INC_SRCDIR=config/${atomicity_include_dir} +OS_INC_SRCDIR=config/${os_include_dir} +FPOS_INC_SRCDIR=config/${fpos_include_dir} + + + + +# Determine cross-compile flags and AM_CONDITIONALs. +#AC_SUBST(GLIBCXX_IS_NATIVE) +#AM_CONDITIONAL(CANADIAN, test $CANADIAN = yes) +# from GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT: +#AM_CONDITIONAL(GLIBCXX_BUILD_LIBMATH, test $need_libmath = yes) + + +if test $is_hosted = yes; then + GLIBCXX_HOSTED_TRUE= + GLIBCXX_HOSTED_FALSE='#' +else + GLIBCXX_HOSTED_TRUE='#' + GLIBCXX_HOSTED_FALSE= +fi + + + + +if test $enable_libstdcxx_pch = yes; then + GLIBCXX_BUILD_PCH_TRUE= + GLIBCXX_BUILD_PCH_FALSE='#' +else + GLIBCXX_BUILD_PCH_TRUE='#' + GLIBCXX_BUILD_PCH_FALSE= +fi + + + + +if test $enable_cheaders = c; then + GLIBCXX_C_HEADERS_C_TRUE= + GLIBCXX_C_HEADERS_C_FALSE='#' +else + GLIBCXX_C_HEADERS_C_TRUE='#' + GLIBCXX_C_HEADERS_C_FALSE= +fi + + + + +if test $enable_cheaders = c_std; then + GLIBCXX_C_HEADERS_C_STD_TRUE= + GLIBCXX_C_HEADERS_C_STD_FALSE='#' +else + GLIBCXX_C_HEADERS_C_STD_TRUE='#' + GLIBCXX_C_HEADERS_C_STD_FALSE= +fi + + + + +if test $c_compatibility = yes; then + GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE= + GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE='#' +else + GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE='#' + GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE= +fi + + + + +if test $enable_libstdcxx_debug = yes; then + GLIBCXX_BUILD_DEBUG_TRUE= + GLIBCXX_BUILD_DEBUG_FALSE='#' +else + GLIBCXX_BUILD_DEBUG_TRUE='#' + GLIBCXX_BUILD_DEBUG_FALSE= +fi + + + + +if test $enable_symvers != no; then + GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE= + GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE='#' +else + GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE='#' + GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE= +fi + @@ -59322,7 +59430,7 @@ OPTIMIZE_CXXFLAGS= - WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings' + WARN_FLAGS='-Wall -W -Wwrite-strings -Wcast-qual' Index: gcc-3.4/libstdc++-v3/configure.ac diff -u gcc-3.4/libstdc++-v3/configure.ac:1.2 gcc-3.4/libstdc++-v3/configure.ac:1.3 --- gcc-3.4/libstdc++-v3/configure.ac:1.2 Fri Jan 9 10:54:34 2004 +++ gcc-3.4/libstdc++-v3/configure.ac Thu Feb 5 10:05:49 2004 @@ -165,7 +165,7 @@ # If Canadian cross, then don't pick up tools from the build directory. # Used only in GLIBCXX_EXPORT_INCLUDES. if test -n "$with_cross_host" && - test x"$build" != x"$with_cross_host" && + test x"$build_alias" != x"$with_cross_host" && test x"$build" != x"$target"; then CANADIAN=yes From criswell at cs.uiuc.edu Thu Feb 5 10:09:28 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:09:28 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/cp/cp-lang.c cp-tree.h decl.c decl2.c method.c pt.c rtti.c semantics.c typeck.c Message-ID: <200402051606.KAA27130@choi.cs.uiuc.edu> Changes in directory gcc-3.4/gcc/cp: cp-lang.c updated: 1.2 -> 1.3 cp-tree.h updated: 1.2 -> 1.3 decl.c updated: 1.2 -> 1.3 decl2.c updated: 1.2 -> 1.3 method.c updated: 1.2 -> 1.3 pt.c updated: 1.2 -> 1.3 rtti.c updated: 1.2 -> 1.3 semantics.c updated: 1.2 -> 1.3 typeck.c updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+772 -1011) Index: gcc-3.4/gcc/cp/cp-lang.c diff -u gcc-3.4/gcc/cp/cp-lang.c:1.2 gcc-3.4/gcc/cp/cp-lang.c:1.3 --- gcc-3.4/gcc/cp/cp-lang.c:1.2 Thu Jan 8 17:03:40 2004 +++ gcc-3.4/gcc/cp/cp-lang.c Thu Feb 5 10:05:46 2004 @@ -32,6 +32,11 @@ #include "diagnostic.h" #include "cxx-pretty-print.h" +#include "llvm-out.h" +#ifdef EMIT_LLVM +#include "llvm-internals.h" +#endif + enum c_language_kind c_language = clk_cxx; static HOST_WIDE_INT cxx_get_alias_set (tree); @@ -42,6 +47,10 @@ static bool cp_var_mod_type_p (tree); static void cxx_initialize_diagnostics (diagnostic_context *); +#if EMIT_LLVM +void llvm_cxx_expand_function_start (); +#endif + #undef LANG_HOOKS_NAME #define LANG_HOOKS_NAME "GNU C++" #undef LANG_HOOKS_TREE_SIZE @@ -110,6 +119,12 @@ #define LANG_HOOKS_DECL_PRINTABLE_NAME cxx_printable_name #undef LANG_HOOKS_PRINT_ERROR_FUNCTION #define LANG_HOOKS_PRINT_ERROR_FUNCTION cxx_print_error_function +#undef LANG_HOOKS_BUILTIN_TYPE_DECLS +#define LANG_HOOKS_BUILTIN_TYPE_DECLS cxx_builtin_type_decls +#undef LANG_HOOKS_PUSHLEVEL +#define LANG_HOOKS_PUSHLEVEL lhd_do_nothing_i +#undef LANG_HOOKS_POPLEVEL +#define LANG_HOOKS_POPLEVEL lhd_do_nothing_iii_return_null_tree #undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL cxx_warn_unused_global_decl #undef LANG_HOOKS_WRITE_GLOBALS @@ -123,6 +138,18 @@ #undef LANG_HOOKS_FUNCTION_FINAL #define LANG_HOOKS_FUNCTION_FINAL cxx_pop_function_context +#undef LANG_HOOKS_RTL_EXPAND_START +#define LANG_HOOKS_RTL_EXPAND_START cxx_expand_function_start +#undef LANG_HOOKS_RTL_EXPAND_STMT +#define LANG_HOOKS_RTL_EXPAND_STMT expand_stmt + +#ifdef EMIT_LLVM +#undef LANG_HOOKS_LLVM_IR_EXPAND_START +#define LANG_HOOKS_LLVM_IR_EXPAND_START llvm_cxx_expand_function_start +#undef LANG_HOOKS_LLVM_IR_EXPAND_STMT +#define LANG_HOOKS_LLVM_IR_EXPAND_STMT llvm_expand_stmt +#endif + /* Attribute hooks. */ #undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE #define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE c_common_attribute_table @@ -166,10 +193,12 @@ #undef LANG_HOOKS_EXPR_SIZE #define LANG_HOOKS_EXPR_SIZE cp_expr_size +#undef LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR +#define LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR cxx_callgraph_analyze_expr #undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION expand_body -#undef LANG_HOOKS_CALLGRAPH_LOWER_FUNCTION -#define LANG_HOOKS_CALLGRAPH_LOWER_FUNCTION lower_function +#undef LANG_HOOKS_LLVM_CALLGRAPH_EXPAND_FUNCTION +#define LANG_HOOKS_LLVM_CALLGRAPH_EXPAND_FUNCTION expand_body #undef LANG_HOOKS_MAKE_TYPE #define LANG_HOOKS_MAKE_TYPE cxx_make_type @@ -187,6 +216,8 @@ #define LANG_HOOKS_INCOMPLETE_TYPE_ERROR cxx_incomplete_type_error #undef LANG_HOOKS_TYPE_PROMOTES_TO #define LANG_HOOKS_TYPE_PROMOTES_TO cxx_type_promotes_to +#undef LANG_HOOKS_REGISTER_BUILTIN_TYPE +#define LANG_HOOKS_REGISTER_BUILTIN_TYPE c_register_builtin_type /* Each front end provides its own hooks, for toplev.c. */ const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; Index: gcc-3.4/gcc/cp/cp-tree.h diff -u gcc-3.4/gcc/cp/cp-tree.h:1.2 gcc-3.4/gcc/cp/cp-tree.h:1.3 --- gcc-3.4/gcc/cp/cp-tree.h:1.2 Thu Jan 8 17:03:40 2004 +++ gcc-3.4/gcc/cp/cp-tree.h Thu Feb 5 10:05:46 2004 @@ -39,6 +39,7 @@ IDENTIFIER_MARKED (IDENTIFIER_NODEs) NEW_EXPR_USE_GLOBAL (in NEW_EXPR). DELETE_EXPR_USE_GLOBAL (in DELETE_EXPR). + COMPOUND_EXPR_OVERLOADED (in COMPOUND_EXPR). TREE_INDIRECT_USING (in NAMESPACE_DECL). ICS_USER_FLAG (in _CONV) CLEANUP_P (in TRY_BLOCK) @@ -46,6 +47,7 @@ PTRMEM_OK_P (in ADDR_EXPR, OFFSET_REF) PARMLIST_ELLIPSIS_P (in PARMLIST) DECL_PRETTY_FUNCTION_P (in VAR_DECL) + KOENIG_LOOKUP_P (in CALL_EXPR) 1: IDENTIFIER_VIRTUAL_P. TI_PENDING_TEMPLATE_FLAG. TEMPLATE_PARMS_FOR_INLINE. @@ -796,7 +798,6 @@ int returns_abnormally; int in_function_try_handler; int in_base_initializer; - int x_expanding_p; /* True if this function can throw an exception. */ bool can_throw : 1; @@ -858,17 +859,6 @@ #define current_function_returns_abnormally \ cp_function_chain->returns_abnormally -/* Nonzero if we should generate RTL for functions that we process. - When this is zero, we just accumulate tree structure, without - interacting with the back end. */ - -#define expanding_p cp_function_chain->x_expanding_p - -/* Nonzero if we are in the semantic analysis phase for the current - function. */ - -#define doing_semantic_analysis_p() (!expanding_p) - /* Nonzero if we are processing a base initializer. Zero elsewhere. */ #define in_base_initializer cp_function_chain->in_base_initializer @@ -2293,6 +2283,14 @@ #define DELETE_EXPR_USE_GLOBAL(NODE) TREE_LANG_FLAG_0 (NODE) #define DELETE_EXPR_USE_VEC(NODE) TREE_LANG_FLAG_1 (NODE) +/* Indicates that this is a non-dependent COMPOUND_EXPR which will + resolve to a function call. */ +#define COMPOUND_EXPR_OVERLOADED(NODE) TREE_LANG_FLAG_0 (NODE) + +/* In a CALL_EXPR appearing in a template, true if Koenig lookup + should be performed at instantiation time. */ +#define KOENIG_LOOKUP_P(NODE) TREE_LANG_FLAG_0(NODE) + /* Nonzero if this AGGR_INIT_EXPR provides for initialization via a constructor call, rather than an ordinary function call. */ #define AGGR_INIT_VIA_CTOR_P(NODE) \ @@ -2932,15 +2930,27 @@ /* The kinds of scopes we recognize. */ typedef enum scope_kind { - sk_block, /* An ordinary block scope. */ + sk_block = 0, /* An ordinary block scope. This enumerator must + have the value zero because "cp_binding_level" + is initialized by using "memset" to set the + contents to zero, and the default scope kind + is "sk_block". */ + sk_cleanup, /* A scope for (pseudo-)scope for cleanup. It is + peusdo in that it is transparent to name lookup + activities. */ sk_try, /* A try-block. */ sk_catch, /* A catch-block. */ sk_for, /* The scope of the variable declared in a for-init-statement. */ + sk_function_parms, /* The scope containing function parameters. */ + sk_class, /* The scope containing the members of a class. */ + sk_namespace, /* The scope containing the members of a + namespace, including the global scope. */ sk_template_parms, /* A scope for template parameters. */ - sk_template_spec /* A scope corresponding to a template - specialization. There is never anything in - this scope. */ + sk_template_spec /* Like sk_template_parms, but for an explicit + specialization. Since, by definition, an + explicit specialization is introduced by + "template <>", this scope is always empty. */ } scope_kind; /* Various kinds of template specialization, instantiation, etc. */ @@ -3027,9 +3037,13 @@ (lookup_template_class use) */ tf_stmt_expr_cmpd = 1 << 6, /* tsubsting the compound statement of a statement expr. */ - tf_stmt_expr_body = 1 << 7 /* tsubsting the statements in the + tf_stmt_expr_body = 1 << 7, /* tsubsting the statements in the body of the compound statement of a statement expr. */ + tf_conv = 1 << 8 /* We are determining what kind of + conversion might be permissible, + not actually performing the + conversion. */ } tsubst_flags_t; /* The kind of checking we can do looking in a class hierarchy. */ @@ -3084,7 +3098,7 @@ extern GTY(()) tree anonymous_namespace_name; /* is_in_anonymous_namespace - Return true if the specified decl nodes is in an - anonymous namespace! */ + anonymous namespace! */ extern int is_in_anonymous_namespace(tree decl); /* The number of function bodies which we are currently processing. @@ -3528,7 +3542,7 @@ extern tree convert_for_arg_passing (tree, tree); extern tree cp_convert_parm_for_inlining (tree, tree, tree); extern bool is_properly_derived_from (tree, tree); -extern tree initialize_reference (tree, tree, tree); +extern tree initialize_reference (tree, tree, tree, tree *); extern tree make_temporary_var_for_ref_to_temp (tree, tree); extern tree strip_top_quals (tree); extern tree perform_implicit_conversion (tree, tree); @@ -3602,7 +3616,6 @@ extern int global_bindings_p (void); extern int kept_level_p (void); extern tree getdecls (void); -extern void pushlevel (int); extern void insert_block (tree); extern void set_block (tree); extern tree pushdecl (tree); @@ -3615,11 +3628,12 @@ extern void cxx_mark_function_context (struct function *); extern int toplevel_bindings_p (void); extern int namespace_bindings_p (void); -extern void keep_next_level (int); +extern void keep_next_level (bool); +extern scope_kind innermost_scope_kind (void); extern int template_parm_scope_p (void); extern void set_class_shadows (tree); extern void maybe_push_cleanup_level (tree); -extern void begin_scope (scope_kind); +extern cxx_scope *begin_scope (scope_kind, tree); extern void finish_scope (void); extern void resume_level (struct cp_binding_level *); extern void delete_block (tree); @@ -3748,7 +3762,8 @@ extern tmpl_spec_kind current_tmpl_spec_kind (int); extern tree cp_fname_init (const char *); extern tree check_elaborated_type_specifier (enum tag_types, tree, bool); -extern int add_binding (cxx_binding *, tree); +extern tree cxx_builtin_type_decls (void); + extern bool have_extern_spec; /* in decl2.c */ @@ -3801,7 +3816,7 @@ extern tree get_guard (tree); extern tree get_guard_cond (tree); extern tree set_guard (tree); -extern void lower_function (tree); +extern tree cxx_callgraph_analyze_expr (tree *, int *, tree); /* XXX Not i18n clean. */ #define cp_deprecated(STR) \ @@ -4114,7 +4129,7 @@ extern tree finish_stmt_expr_expr (tree); extern tree finish_stmt_expr (tree, bool); extern tree perform_koenig_lookup (tree, tree); -extern tree finish_call_expr (tree, tree, bool); +extern tree finish_call_expr (tree, tree, bool, bool); extern tree finish_increment_expr (tree, enum tree_code); extern tree finish_this_expr (void); extern tree finish_object_call_expr (tree, tree, tree); @@ -4141,11 +4156,10 @@ bool, bool, bool *, const char **); extern tree finish_typeof (tree); -extern tree finish_sizeof (tree); -extern tree finish_alignof (tree); extern void finish_decl_cleanup (tree, tree); extern void finish_eh_cleanup (tree); extern void expand_body (tree); +extern void cxx_expand_function_start (void); extern tree nullify_returns_r (tree *, int *, void *); extern void do_pushlevel (scope_kind); extern tree do_poplevel (void); @@ -4170,13 +4184,10 @@ extern tree canonical_type_variant (tree); extern tree copy_base_binfos (tree, tree, tree); extern int member_p (tree); -extern cp_lvalue_kind real_lvalue_p (tree); -extern int non_cast_lvalue_p (tree); -extern cp_lvalue_kind real_non_cast_lvalue_p (tree); -extern int non_cast_lvalue_or_else (tree, const char *); -extern tree build_min (enum tree_code, tree, - ...); +extern cp_lvalue_kind real_lvalue_p (tree); +extern tree build_min (enum tree_code, tree, ...); extern tree build_min_nt (enum tree_code, ...); +extern tree build_min_non_dep (enum tree_code, tree, ...); extern tree build_cplus_new (tree, tree); extern tree get_target_expr (tree); extern tree build_cplus_staticfn_type (tree, tree, tree); @@ -4254,8 +4265,8 @@ extern bool compparms (tree, tree); extern int comp_cv_qualification (tree, tree); extern int comp_cv_qual_signature (tree, tree); -extern tree expr_sizeof (tree); -extern tree cxx_sizeof_or_alignof_type (tree, enum tree_code, int); +extern tree cxx_sizeof_or_alignof_expr (tree, enum tree_code); +extern tree cxx_sizeof_or_alignof_type (tree, enum tree_code, bool); #define cxx_sizeof_nowarn(T) cxx_sizeof_or_alignof_type (T, SIZEOF_EXPR, false) extern tree inline_conversion (tree); extern tree decay_conversion (tree); Index: gcc-3.4/gcc/cp/decl.c diff -u gcc-3.4/gcc/cp/decl.c:1.2 gcc-3.4/gcc/cp/decl.c:1.3 --- gcc-3.4/gcc/cp/decl.c:1.2 Thu Jan 8 17:03:40 2004 +++ gcc-3.4/gcc/cp/decl.c Thu Feb 5 10:05:46 2004 @@ -56,7 +56,6 @@ static tree grokparms (tree); static const char *redeclaration_error_message (tree, tree); -static void push_binding_level (cxx_scope *); static void pop_binding_level (void); static void suspend_binding_level (void); static void resume_binding_level (struct cp_binding_level *); @@ -69,7 +68,7 @@ static tree lookup_tag_reverse (tree, tree); static void push_local_name (tree); static void warn_extern_redeclared_static (tree, tree); -static tree grok_reference_init (tree, tree, tree); +static tree grok_reference_init (tree, tree, tree, tree *); static tree grokfndecl (tree, tree, tree, tree, int, enum overload_flags, tree, tree, int, int, int, int, int, int, tree); @@ -118,7 +117,7 @@ static void maybe_deduce_size_from_array_init (tree, tree); static void layout_var_decl (tree); static void maybe_commonize_var (tree); -static tree check_initializer (tree, tree, int); +static tree check_initializer (tree, tree, int, tree *); static void make_rtl_for_nonlocal_decl (tree, tree, const char *); static void save_function_data (tree); static void check_function_type (tree, tree); @@ -371,51 +370,27 @@ TREE_LIST; the TREE_VALUE is the actual declaration. */ tree dead_vars_from_for; - /* 1 for the level that holds the parameters of a function. - 2 for the level that holds a class declaration. */ - unsigned parm_flag : 2; - - /* 1 means make a BLOCK for this level regardless of all else. - 2 for temporary binding contours created by the compiler. */ - unsigned keep : 2; + /* Binding depth at which this level began. */ + int binding_depth; + + /* The kind of scope that this object represents. However, a + SK_TEMPLATE_SPEC scope is represented with KIND set to + SK_TEMPALTE_PARMS and EXPLICIT_SPEC_P set to true. */ + enum scope_kind kind : 4; + + /* True if this scope is an SK_TEMPLATE_SPEC scope. This field is + only valid if KIND == SK_TEMPLATE_PARMS. */ + bool explicit_spec_p : 1; - /* Nonzero if this level "doesn't exist" for tags. */ - unsigned tag_transparent : 1; + /* true means make a BLOCK for this level regardless of all else. */ + unsigned keep : 1; /* Nonzero if this level can safely have additional cleanup-needing variables added to it. */ unsigned more_cleanups_ok : 1; unsigned have_cleanups : 1; - /* Nonzero if this scope is for storing the decls for template - parameters and generic decls; these decls will be discarded and - replaced with a TEMPLATE_DECL. */ - unsigned template_parms_p : 1; - - /* Nonzero if this scope corresponds to the `<>' in a - `template <>' clause. Whenever this flag is set, - TEMPLATE_PARMS_P will be set as well. */ - unsigned template_spec_p : 1; - - /* This is set for a namespace binding level. */ - unsigned namespace_p : 1; - - /* True if this level is that of a for-statement where we need to - worry about ambiguous (ARM or ISO) scope rules. */ - unsigned is_for_scope : 1; - - /* True if this level corresponds to a TRY block. Currently this - information is only available while building the tree structure. */ - unsigned is_try_scope : 1; - - /* True if this level corresponds to a CATCH block. Currently this - information is only available while building the tree structure. */ - unsigned is_catch_scope : 1; - - /* Three bits left for this word. */ - - /* Binding depth at which this level began. */ - unsigned binding_depth; + /* 22 bits left to fill a 32-bit word. */ }; #define NULL_BINDING_LEVEL ((struct cp_binding_level *) NULL) @@ -435,9 +410,9 @@ static GTY((deletable (""))) struct cp_binding_level *free_binding_level; -/* Nonzero means unconditionally make a BLOCK for the next level pushed. */ +/* true means unconditionally make a BLOCK for the next level pushed. */ -static int keep_next_level_flag; +static bool keep_next_level_flag; /* A TREE_LIST of VAR_DECLs. The TREE_PURPOSE is a RECORD_TYPE or UNION_TYPE; the TREE_VALUE is a VAR_DECL with that type. At the @@ -469,28 +444,24 @@ static const char * cxx_scope_descriptor (cxx_scope *scope) { - const char *desc; - - if (scope->namespace_p) - desc = "namespace-scope"; - else if (scope->parm_flag == 1) - desc = "function-prototype-scope"; - else if (scope->parm_flag == 2) - desc = "class-scope"; - else if (scope->is_for_scope) - desc = "for-scope"; - else if (scope->is_try_scope) - desc = "try-scope"; - else if (scope->is_catch_scope) - desc = "catch-scope"; - else if (scope->template_spec_p) - desc = "template-explicit-spec-scope"; - else if (scope->template_parms_p) - desc = "template-prototype-scope"; - else - desc = "block-scope"; + /* The order of this table must match the "scope_kind" + enumerators. */ + static const char* scope_kind_names[] = { + "block-scope", + "cleanup-scope", + "try-scope", + "catch-scope", + "for-scope", + "function-parameter-scope", + "class-scope", + "namespace-scope", + "template-parameter-scope", + "template-explicit-spec-scope" + }; + const scope_kind kind = scope->explicit_spec_p + ? sk_template_spec : scope->kind; - return desc; + return scope_kind_names[kind]; } /* Output a debugging information about SCOPE when performning @@ -506,10 +477,27 @@ verbatim ("%s %s %p %d\n", action, desc, (void *) scope, line); } -/* Construct a scope that may be TAG-TRANSPARENT, the sub-blocks of - which may be KEPT. */ -static inline cxx_scope * -make_cxx_scope (bool tag_transparent, int keep) +/* Return the estimated initial size of the hashtable of a NAMESPACE + scope. */ + +static inline size_t +namespace_scope_ht_size (tree ns) +{ + tree name = DECL_NAME (ns); + + return name == std_identifier + ? NAMESPACE_STD_HT_SIZE + : (name == global_scope_name + ? GLOBAL_SCOPE_HT_SIZE + : NAMESPACE_ORDINARY_HT_SIZE); +} + +/* Create a new KIND scope and make it the top of the active scopes stack. + ENTITY is the scope of the associated C++ entity (namespace, class, + function); it is NULL otherwise. */ + +cxx_scope * +begin_scope (scope_kind kind, tree entity) { cxx_scope *scope; @@ -521,31 +509,62 @@ } else scope = ggc_alloc (sizeof (cxx_scope)); - memset (scope, 0, sizeof (cxx_scope)); - scope->tag_transparent = tag_transparent; - scope->keep = keep; + + scope->this_entity = entity; scope->more_cleanups_ok = true; + switch (kind) + { + case sk_cleanup: + scope->keep = true; + break; + + case sk_template_spec: + scope->explicit_spec_p = true; + kind = sk_template_parms; + /* fall through */ + case sk_template_parms: + case sk_block: + case sk_try: + case sk_catch: + case sk_for: + case sk_class: + case sk_function_parms: + scope->keep = keep_next_level_flag; + break; - return scope; -} + case sk_namespace: + scope->type_decls = binding_table_new (namespace_scope_ht_size (entity)); + NAMESPACE_LEVEL (entity) = scope; + VARRAY_TREE_INIT (scope->static_decls, + DECL_NAME (entity) == std_identifier + || DECL_NAME (entity) == global_scope_name + ? 200 : 10, + "Static declarations"); + break; -static void -push_binding_level (cxx_scope *newlevel) -{ - /* Add this level to the front of the chain (stack) of levels that - are active. */ - newlevel->level_chain = current_binding_level; - current_binding_level = newlevel; + default: + /* Should not happen. */ + my_friendly_assert (false, 20030922); + break; + } + scope->kind = kind; + + /* Add it to the front of currently active scopes stack. */ + scope->level_chain = current_binding_level; + current_binding_level = scope; + keep_next_level_flag = false; if (ENABLE_SCOPE_CHECKING) { - newlevel->binding_depth = binding_depth; + scope->binding_depth = binding_depth; indent (binding_depth); - cxx_scope_debug (newlevel, input_location.line, "push"); + cxx_scope_debug (scope, input_location.line, "push"); is_class_level = 0; binding_depth++; } + + return scope; } /* Find the innermost enclosing class scope, and reset @@ -556,9 +575,9 @@ { struct cp_binding_level *level = current_binding_level; - while (level && level->parm_flag != 2) + while (level && level->kind != sk_class) level = level->level_chain; - if (level && level->parm_flag == 2) + if (level && level->kind == sk_class) class_binding_level = level; else class_binding_level = 0; @@ -587,7 +606,7 @@ register struct cp_binding_level *level = current_binding_level; current_binding_level = current_binding_level->level_chain; level->level_chain = free_binding_level; - if (level->parm_flag == 2) + if (level->kind == sk_class) level->type_decls = NULL; else binding_table_free (level->type_decls); @@ -660,7 +679,7 @@ struct cp_binding_level *b; b = current_binding_level; - while (b->parm_flag == 2) + while (b->kind == sk_class) b = b->level_chain; return b; @@ -677,7 +696,7 @@ { struct cp_binding_level *b = innermost_nonclass_level (); - return b->namespace_p || b->template_parms_p; + return b->kind == sk_namespace || b->kind == sk_template_parms; } /* Nonzero if this is a namespace scope, or if we are defining a class @@ -689,15 +708,15 @@ { struct cp_binding_level *b = innermost_nonclass_level (); - return b->namespace_p; + return b->kind == sk_namespace; } -/* If KEEP is nonzero, make a BLOCK node for the next binding level, +/* If KEEP is true, make a BLOCK node for the next binding level, unconditionally. Otherwise, use the normal logic to decide whether or not to create a BLOCK. */ void -keep_next_level (int keep) +keep_next_level (bool keep) { keep_next_level_flag = keep; } @@ -709,9 +728,17 @@ { return (current_binding_level->blocks != NULL_TREE || current_binding_level->keep + || current_binding_level->kind == sk_cleanup || current_binding_level->names != NULL_TREE - || (current_binding_level->type_decls != NULL - && !current_binding_level->tag_transparent)); + || current_binding_level->type_decls != NULL); +} + +/* Returns the kind of the innermost scope. */ + +scope_kind +innermost_scope_kind (void) +{ + return current_binding_level->kind; } /* Returns nonzero if this scope was created to store template @@ -720,7 +747,7 @@ int template_parm_scope_p (void) { - return current_binding_level->template_parms_p; + return innermost_scope_kind () == sk_template_parms; } /* Returns the kind of template specialization we are currently @@ -736,7 +763,9 @@ struct cp_binding_level *b; /* Scan through the template parameter scopes. */ - for (b = current_binding_level; b->template_parms_p; b = b->level_chain) + for (b = current_binding_level; + b->kind == sk_template_parms; + b = b->level_chain) { /* If we see a specialization scope inside a parameter scope, then something is wrong. That corresponds to a declaration @@ -747,7 +776,7 @@ which is always invalid since [temp.expl.spec] forbids the specialization of a class member template if the enclosing class templates are not explicitly specialized as well. */ - if (b->template_spec_p) + if (b->explicit_spec_p) { if (n_template_parm_scopes == 0) innermost_specialization_p = 1; @@ -817,20 +846,6 @@ class_binding_level->class_shadowed = shadows; } -/* Enter a new binding level. - If TAG_TRANSPARENT is nonzero, do so only for the name space of variables, - not for that of tags. */ - -void -pushlevel (int tag_transparent) -{ - if (cfun && !doing_semantic_analysis_p ()) - return; - - push_binding_level (make_cxx_scope (tag_transparent, keep_next_level_flag)); - keep_next_level_flag = 0; -} - /* We're defining an object of type TYPE. If it needs a cleanup, but we're not allowed to add any more objects with cleanups to the current scope, create a new binding level. */ @@ -841,50 +856,11 @@ if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type) && current_binding_level->more_cleanups_ok == 0) { - keep_next_level (2); - pushlevel (1); + begin_scope (sk_cleanup, NULL); clear_last_expr (); add_scope_stmt (/*begin_p=*/1, /*partial_p=*/1); } } - -/* Enter a new scope. The KIND indicates what kind of scope is being - created. */ - -void -begin_scope (scope_kind sk) -{ - pushlevel (0); - - switch (sk) - { - case sk_block: - break; - - case sk_try: - current_binding_level->is_try_scope = 1; - break; - - case sk_catch: - current_binding_level->is_catch_scope = 1; - break; - - case sk_for: - current_binding_level->is_for_scope = 1; - break; - - case sk_template_spec: - current_binding_level->template_spec_p = 1; - /* Fall through. */ - - case sk_template_parms: - current_binding_level->template_parms_p = 1; - break; - - default: - abort (); - } -} /* Exit the current scope. */ @@ -912,82 +888,6 @@ IDENTIFIER_BINDING (id) = binding; } -/* ID is already bound in the current scope. But, DECL is an - additional binding for ID in the same scope. This is the `struct - stat' hack whereby a non-typedef class-name or enum-name can be - bound at the same level as some other kind of entity. It's the - responsibility of the caller to check that inserting this name is - valid here. Returns nonzero if the new binding was successful. */ - -int -add_binding (cxx_binding *binding, tree decl) -{ - tree bval = BINDING_VALUE (binding); - int ok = 1; - - timevar_push (TV_NAME_LOOKUP); - if (TREE_CODE (decl) == TYPE_DECL && DECL_ARTIFICIAL (decl)) - /* The new name is the type name. */ - BINDING_TYPE (binding) = decl; - else if (!bval) - /* This situation arises when push_class_level_binding moves an - inherited type-binding out of the way to make room for a new - value binding. */ - BINDING_VALUE (binding) = decl; - else if (TREE_CODE (bval) == TYPE_DECL && DECL_ARTIFICIAL (bval)) - { - /* The old binding was a type name. It was placed in - BINDING_VALUE because it was thought, at the point it was - declared, to be the only entity with such a name. Move the - type name into the type slot; it is now hidden by the new - binding. */ - BINDING_TYPE (binding) = bval; - BINDING_VALUE (binding) = decl; - INHERITED_VALUE_BINDING_P (binding) = 0; - } - else if (TREE_CODE (bval) == TYPE_DECL - && TREE_CODE (decl) == TYPE_DECL - && DECL_NAME (decl) == DECL_NAME (bval) - && (same_type_p (TREE_TYPE (decl), TREE_TYPE (bval)) - /* If either type involves template parameters, we must - wait until instantiation. */ - || uses_template_parms (TREE_TYPE (decl)) - || uses_template_parms (TREE_TYPE (bval)))) - /* We have two typedef-names, both naming the same type to have - the same name. This is OK because of: - - [dcl.typedef] - - In a given scope, a typedef specifier can be used to redefine - the name of any type declared in that scope to refer to the - type to which it already refers. */ - ok = 0; - /* There can be two block-scope declarations of the same variable, - so long as they are `extern' declarations. However, there cannot - be two declarations of the same static data member: - - [class.mem] - - A member shall not be declared twice in the - member-specification. */ - else if (TREE_CODE (decl) == VAR_DECL && TREE_CODE (bval) == VAR_DECL - && DECL_EXTERNAL (decl) && DECL_EXTERNAL (bval) - && !DECL_CLASS_SCOPE_P (decl)) - { - duplicate_decls (decl, BINDING_VALUE (binding)); - ok = 0; - } - else - { - error ("declaration of `%#D'", decl); - cp_error_at ("conflicts with previous declaration `%#D'", - BINDING_VALUE (binding)); - ok = 0; - } - - POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, ok); -} - /* Add DECL to the list of things declared in B. */ static void @@ -1014,7 +914,7 @@ b->names_size++; /* If appropriate, add decl to separate list of statics */ - if (b->namespace_p) + if (b->kind == sk_namespace) if ((TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)) || (TREE_CODE (decl) == FUNCTION_DECL && (!TREE_PUBLIC (decl) || DECL_DECLARED_INLINE_P (decl)))) @@ -1034,14 +934,12 @@ /* Skip over any local classes. This makes sense if we call push_local_binding with a friend decl of a local class. */ - b = current_binding_level; - while (b->parm_flag == 2) - b = b->level_chain; + b = innermost_nonclass_level (); if (lookup_name_current_level (id)) { /* Supplement the existing binding. */ - if (!add_binding (IDENTIFIER_BINDING (id), decl)) + if (!supplement_binding (IDENTIFIER_BINDING (id), decl)) /* It didn't work. Something else must be bound at this level. Do not add DECL to the list of things to pop later. */ @@ -1080,7 +978,7 @@ if (binding && BINDING_SCOPE (binding) == class_binding_level) /* Supplement the existing binding. */ - result = add_binding (IDENTIFIER_BINDING (id), decl); + result = supplement_binding (IDENTIFIER_BINDING (id), decl); else /* Create a new binding. */ push_binding (id, decl, class_binding_level); @@ -1168,7 +1066,7 @@ static void pop_label (tree label, tree old_value) { - if (!processing_template_decl && doing_semantic_analysis_p ()) + if (!processing_template_decl) { if (DECL_INITIAL (label) == NULL_TREE) { @@ -1238,15 +1136,13 @@ tree block = NULL_TREE; tree decl; int leaving_for_scope; + scope_kind kind; timevar_push (TV_NAME_LOOKUP); - if (cfun && !doing_semantic_analysis_p ()) - POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE); - my_friendly_assert (current_binding_level->parm_flag != 2, - 19990916); + my_friendly_assert (current_binding_level->kind != sk_class, 19990916); - real_functionbody = (current_binding_level->keep == 2 + real_functionbody = (current_binding_level->kind == sk_cleanup ? ((functionbody = 0), tmp) : functionbody); subblocks = functionbody >= 0 ? current_binding_level->blocks : 0; @@ -1258,7 +1154,7 @@ rather than the end. This hack is no longer used. */ my_friendly_assert (keep == 0 || keep == 1, 0); - if (current_binding_level->keep == 1) + if (current_binding_level->keep) keep = 1; /* Any uses of undefined labels, and any defined labels, now operate @@ -1275,9 +1171,9 @@ if (labels->binding_level == current_binding_level) { tree decl; - if (current_binding_level->is_try_scope) + if (current_binding_level->kind == sk_try) labels->in_try_scope = 1; - if (current_binding_level->is_catch_scope) + if (current_binding_level->kind == sk_catch) labels->in_catch_scope = 1; for (decl = labels->names_in_scope; decl; decl = TREE_CHAIN (decl)) @@ -1359,7 +1255,7 @@ ended. We only use the new rules if flag_new_for_scope is nonzero. */ leaving_for_scope - = current_binding_level->is_for_scope && flag_new_for_scope == 1; + = current_binding_level->kind == sk_for && flag_new_for_scope == 1; /* Remove declarations for all the DECLs in this level. */ for (link = decls; link; link = TREE_CHAIN (link)) @@ -1490,7 +1386,7 @@ pop_labels (block); } - tmp = current_binding_level->keep; + kind = current_binding_level->kind; pop_binding_level (); if (functionbody) @@ -1515,7 +1411,7 @@ TREE_USED (block) = 1; /* Take care of compiler's internal binding structures. */ - if (tmp == 2) + if (kind == sk_cleanup) { tree scope_stmts; @@ -1576,7 +1472,6 @@ { /* The RTL expansion machinery requires us to provide this callback, but it is not applicable in function-at-a-time mode. */ - my_friendly_assert (cfun && !doing_semantic_analysis_p (), 20000911); } /* Do a pushlevel for class declarations. */ @@ -1587,11 +1482,7 @@ if (ENABLE_SCOPE_CHECKING) is_class_level = 1; - push_binding_level (make_cxx_scope (false, 0)); - - class_binding_level = current_binding_level; - class_binding_level->parm_flag = 2; - class_binding_level->this_entity = current_class_type; + class_binding_level = begin_scope (sk_class, current_class_type); } /* ...and a poplevel for class declarations. */ @@ -1623,7 +1514,7 @@ /* Find the next enclosing class, and recreate IDENTIFIER_CLASS_VALUEs appropriate for that class. */ b = level->level_chain; - while (b && b->parm_flag != 2) + while (b && b->kind != sk_class) b = b->level_chain; if (b) @@ -1898,8 +1789,6 @@ tree t; int i = 0, len; fprintf (stderr, " blocks=" HOST_PTR_PRINTF, (void *) lvl->blocks); - if (lvl->tag_transparent) - fprintf (stderr, " tag-transparent"); if (lvl->more_cleanups_ok) fprintf (stderr, " more-cleanups-ok"); if (lvl->have_cleanups) @@ -2005,32 +1894,17 @@ the identifier is polymorphic, with three possible values: NULL_TREE, a list of "cxx_binding"s. */ - -/* Push the initial binding contour of NAMESPACE-scope. Any subsequent - push of NS is actually a resume. */ -static void -initial_push_namespace_scope (tree ns) -{ - tree name = DECL_NAME (ns); - cxx_scope *scope; - - pushlevel (0); - scope = current_binding_level; - scope->namespace_p = true; - scope->type_decls = binding_table_new (name == std_identifier - ? NAMESPACE_STD_HT_SIZE - : (name == global_scope_name - ? GLOBAL_SCOPE_HT_SIZE - : NAMESPACE_ORDINARY_HT_SIZE)); - VARRAY_TREE_INIT (scope->static_decls, - name == std_identifier || name == global_scope_name - ? 200 : 10, - "Static declarations"); - scope->this_entity = ns; - NAMESPACE_LEVEL (ns) = scope; -} - - +/* + * Function: is_in_anonymous_namespace () + * + * Description: + * This function takes a GCC internal tree and determines whether it was + * declared an anonymous namespace. + * + * Return value: + * 0 - This tree was not declared in an anonymous namespace. + * 1 - This tree was declared in an anonymous namespace. + */ int is_in_anonymous_namespace(tree decl) { tree Context; if (decl && DECL_P(decl)) @@ -2062,9 +1936,8 @@ } - -/* Push into the scope of the NAME namespace. If NAME is NULL_TREE, then - we use the anonymous namespace. */ +/* Push into the scope of the NAME namespace. If NAME is NULL_TREE, then we + select a name that is unique to this compilation unit. */ void push_namespace (tree name) @@ -2121,7 +1994,7 @@ d = build_lang_decl (NAMESPACE_DECL, name, void_type_node); DECL_CONTEXT (d) = FROB_CONTEXT (current_namespace); d = pushdecl (d); - initial_push_namespace_scope (d); + begin_scope (sk_namespace, d); } else resume_binding_level (NAMESPACE_LEVEL (d)); @@ -2282,13 +2155,13 @@ inserted into namespace level, finish_file wouldn't find them when doing pending instantiations. Therefore, don't stop at namespace level, but continue until :: . */ - if (global_scope_p (b) || (pseudo && b->template_parms_p)) + if (global_scope_p (b) || (pseudo && b->kind == sk_template_parms)) break; old_bindings = store_bindings (b->names, old_bindings); /* We also need to check class_shadowed to save class-level type bindings, since pushclass doesn't fill in b->names. */ - if (b->parm_flag == 2) + if (b->kind == sk_class) old_bindings = store_bindings (b->class_shadowed, old_bindings); /* Unwind type-value slots back to top level. */ @@ -2359,7 +2232,7 @@ { tree type; - if (!b->namespace_p) + if (b->kind != sk_namespace) { /* Shadow the marker, not the real thing, so that the marker gets restored later. */ @@ -2375,7 +2248,7 @@ if (decl) { if (BINDING_VALUE (binding)) - add_binding (binding, decl); + supplement_binding (binding, decl); else BINDING_VALUE (binding) = decl; } @@ -2426,7 +2299,7 @@ verbatim ("XXX entering pop_everything ()\n"); while (!toplevel_bindings_p ()) { - if (current_binding_level->parm_flag == 2) + if (current_binding_level->kind == sk_class) pop_nested_class (); else poplevel (0, 0, 0); @@ -2482,8 +2355,8 @@ friend case, push_template_decl will already have put the friend into global scope, if appropriate. */ if (TREE_CODE (type) != ENUMERAL_TYPE - && !globalize && b->template_parms_p - && b->level_chain->parm_flag == 2) + && !globalize && b->kind == sk_template_parms + && b->level_chain->kind == sk_class) { finish_member_declaration (CLASSTYPE_TI_TEMPLATE (type)); /* Put this UDT in the table of UDTs for the class, since @@ -2567,7 +2440,7 @@ } /* Push a tag name NAME for struct/class/union/enum type TYPE. - Normally put it into the inner-most non-tag-transparent scope, + Normally put it into the inner-most non-sk_cleanup scope, but if GLOBALIZE is true, put it in the inner-most non-class scope. The latter is needed for implicit declarations. */ @@ -2578,8 +2451,8 @@ timevar_push (TV_NAME_LOOKUP); b = current_binding_level; - while (b->tag_transparent - || (b->parm_flag == 2 + while (b->kind == sk_cleanup + || (b->kind == sk_class && (globalize /* We may be defining a new type in the initializer of a static member variable. We allow this when @@ -2616,8 +2489,9 @@ if (!context) context = current_namespace; - if ((b->template_parms_p && b->level_chain->parm_flag == 2) - || b->parm_flag == 2) + if (b->kind == sk_class + || (b->kind == sk_template_parms + && b->level_chain->kind == sk_class)) in_class = 1; if (current_lang_name == lang_name_java) @@ -2631,7 +2505,7 @@ d = maybe_process_template_type_declaration (type, globalize, b); - if (b->parm_flag == 2) + if (b->kind == sk_class) { if (!PROCESSING_REAL_TEMPLATE_DECL_P ()) /* Put this TYPE_DECL on the TYPE_FIELDS list for the @@ -2661,14 +2535,12 @@ && !processing_template_decl) VARRAY_PUSH_TREE (local_classes, type); } - if (b->parm_flag == 2) + if (b->kind == sk_class + && !COMPLETE_TYPE_P (current_class_type)) { - if (!COMPLETE_TYPE_P (current_class_type)) - { - maybe_add_class_template_decl_list (current_class_type, - type, /*friend_p=*/0); - CLASSTYPE_NESTED_UTDS (current_class_type) = b->type_decls; - } + maybe_add_class_template_decl_list (current_class_type, + type, /*friend_p=*/0); + CLASSTYPE_NESTED_UTDS (current_class_type) = b->type_decls; } } @@ -2721,7 +2593,7 @@ return; b = current_binding_level; - while (b->tag_transparent) + while (b->kind == sk_cleanup) b = b->level_chain; if (b->type_decls != NULL) binding_table_remove_anonymous_types (b->type_decls); @@ -2851,7 +2723,8 @@ if (TREE_CODE (newdecl) == TYPE_DECL || TREE_CODE (newdecl) == TEMPLATE_DECL - || TREE_CODE (newdecl) == CONST_DECL) + || TREE_CODE (newdecl) == CONST_DECL + || TREE_CODE (newdecl) == NAMESPACE_DECL) return; /* Don't get confused by static member functions; that's a different @@ -2922,19 +2795,18 @@ && DECL_UNINLINABLE (olddecl) && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl))) { - warning ("%Hfunction '%D' redeclared as inline", - &DECL_SOURCE_LOCATION (newdecl), newdecl); - warning ("%Hprevious declaration of '%D' with attribute noinline", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + warning ("%Jfunction '%D' redeclared as inline", newdecl, newdecl); + warning ("%Jprevious declaration of '%D' with attribute noinline", + olddecl, olddecl); } else if (DECL_DECLARED_INLINE_P (olddecl) && DECL_UNINLINABLE (newdecl) && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl))) { - warning ("%Hfunction '%D' redeclared with attribute noinline", - &DECL_SOURCE_LOCATION (newdecl), newdecl); - warning ("%Hprevious declaration of '%D' was inline", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + warning ("%Jfunction '%D' redeclared with attribute noinline", + newdecl, newdecl); + warning ("%Jprevious declaration of '%D' was inline", + olddecl, olddecl); } } @@ -2979,9 +2851,9 @@ if (DECL_ANTICIPATED (olddecl)) ; /* Do nothing yet. */ else if ((DECL_EXTERN_C_P (newdecl) - && DECL_EXTERN_C_P (olddecl)) - || compparms (TYPE_ARG_TYPES (TREE_TYPE (newdecl)), - TYPE_ARG_TYPES (TREE_TYPE (olddecl)))) + && DECL_EXTERN_C_P (olddecl)) + || compparms (TYPE_ARG_TYPES (TREE_TYPE (newdecl)), + TYPE_ARG_TYPES (TREE_TYPE (olddecl)))) { /* A near match; override the builtin. */ @@ -3010,6 +2882,10 @@ else if (DECL_ANTICIPATED (olddecl)) TREE_TYPE (olddecl) = TREE_TYPE (newdecl); + /* Whether or not the builtin can throw exceptions has no + bearing on this declarator. */ + TREE_NOTHROW (olddecl) = 0; + if (DECL_THIS_STATIC (newdecl) && !DECL_THIS_STATIC (olddecl)) { /* If a builtin function is redeclared as `static', merge @@ -3119,8 +2995,10 @@ else if (current_class_type == NULL_TREE || IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (newdecl)) != current_class_type) { - error ("conflicting types for `%#D'", newdecl); - cp_error_at ("previous declaration as `%#D'", olddecl); + error ("conflicting declaration '%#D'", newdecl); + cp_error_at ("'%D' has a previous declaration as `%#D'", + olddecl, olddecl); + return false; } } else if (TREE_CODE (newdecl) == FUNCTION_DECL @@ -3174,8 +3052,7 @@ { /* Prototype decl follows defn w/o prototype. */ cp_warning_at ("prototype for `%#D'", newdecl); - warning ("%Hfollows non-prototype definition here", - &DECL_SOURCE_LOCATION (olddecl)); + warning ("%Jfollows non-prototype definition here", olddecl); } else if (TREE_CODE (olddecl) == FUNCTION_DECL && DECL_LANGUAGE (newdecl) != DECL_LANGUAGE (olddecl)) @@ -3230,10 +3107,8 @@ && ! DECL_DECLARED_INLINE_P (olddecl) && TREE_ADDRESSABLE (olddecl) && warn_inline) { - warning ("`%#D' was used before it was declared inline", - newdecl); - warning ("%Hprevious non-inline declaration here", - &DECL_SOURCE_LOCATION (olddecl)); + warning ("`%#D' was used before it was declared inline", newdecl); + warning ("%Jprevious non-inline declaration here", olddecl); } } } @@ -3679,10 +3554,6 @@ int need_new_binding; timevar_push (TV_NAME_LOOKUP); - /* We shouldn't be calling pushdecl when we're generating RTL for a - function that we already did semantic analysis on previously. */ - my_friendly_assert (!cfun || doing_semantic_analysis_p (), - 19990913); need_new_binding = 1; @@ -4063,10 +3934,10 @@ b = b->level_chain; /* ARM $8.3 */ - if (b->parm_flag == 1) + if (b->kind == sk_function_parms) { error ("declaration of `%#D' shadows a parameter", - name); + name); err = true; } } @@ -4127,7 +3998,7 @@ timevar_push (TV_NAME_LOOKUP); current_function_decl = NULL_TREE; - if (level->parm_flag == 2) + if (level->kind == sk_class) { b = class_binding_level; class_binding_level = level; @@ -4694,9 +4565,6 @@ tree decl; decl = build_decl (LABEL_DECL, id, void_type_node); - if (expanding_p) - /* Make sure every label has an rtx. */ - label_rtx (decl); DECL_CONTEXT (decl) = current_function_decl; DECL_MODE (decl) = VOIDmode; @@ -4865,7 +4733,7 @@ if (b == level) break; - if ((b->is_try_scope || b->is_catch_scope) && ! saw_eh) + if ((b->kind == sk_try || b->kind == sk_catch) && ! saw_eh) { if (! identified) { @@ -4878,7 +4746,7 @@ pedwarn ("%H from here", locus); identified = 1; } - if (b->is_try_scope) + if (b->kind == sk_try) error (" enters try block"); else error (" enters catch block"); @@ -4970,7 +4838,7 @@ if (u > 1 && DECL_ARTIFICIAL (b)) /* Can't skip init of __exception_info. */ - error ("%H enters catch block", &DECL_SOURCE_LOCATION (b)); + error ("%J enters catch block", b); else if (u > 1) cp_error_at (" skips initialization of `%#D'", b); else @@ -4984,8 +4852,7 @@ } /* Define a label, specifying the location in the source file. - Return the LABEL_DECL node for the label, if the definition is valid. - Otherwise return 0. */ + Return the LABEL_DECL node for the label. */ tree define_label (location_t location, tree name) @@ -5001,17 +4868,16 @@ /* After labels, make any new cleanups in the function go into their own new (temporary) binding contour. */ - for (p = current_binding_level; !(p->parm_flag); p = p->level_chain) + for (p = current_binding_level; + p->kind != sk_function_parms; + p = p->level_chain) p->more_cleanups_ok = 0; if (name == get_identifier ("wchar_t")) pedwarn ("label named wchar_t"); if (DECL_INITIAL (decl) != NULL_TREE) - { - error ("duplicate label `%D'", decl); - POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE); - } + error ("duplicate label `%D'", decl); else { /* Mark label as having been defined. */ @@ -5024,9 +4890,10 @@ ent->binding_level = current_binding_level; } check_previous_gotos (decl); - POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl); } + timevar_pop (TV_NAME_LOOKUP); + return decl; } struct cp_switch @@ -5118,7 +4985,9 @@ /* After labels, make any new cleanups in the function go into their own new (temporary) binding contour. */ - for (p = current_binding_level; !(p->parm_flag); p = p->level_chain) + for (p = current_binding_level; + p->kind != sk_function_parms; + p = p->level_chain) p->more_cleanups_ok = 0; return r; @@ -5198,7 +5067,7 @@ return the structure (or union or enum) definition for that name. Searches binding levels from BINDING_SCOPE up to the global level. If THISLEVEL_ONLY is nonzero, searches only the specified context - (but skips any tag-transparent contexts to find one that is + (but skips any sk_cleanup contexts to find one that is meaningful for tags). FORM says which kind of type the caller wants; it is RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE. @@ -5227,7 +5096,7 @@ if (type != NULL) POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, type); } - else if (level->namespace_p) + else if (level->kind == sk_namespace) /* Do namespace lookup. */ for (tail = current_namespace; 1; tail = CP_DECL_CONTEXT (tail)) { @@ -5286,9 +5155,9 @@ POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, entry->type); } } - if (thislevel_only && ! level->tag_transparent) + if (thislevel_only && level->kind != sk_cleanup) { - if (level->template_parms_p && allow_template_parms_p) + if (level->kind == sk_template_parms && allow_template_parms_p) { /* We must deal with cases like this: @@ -5751,7 +5620,7 @@ /* Add all _DECLs seen through local using-directives. */ for (level = current_binding_level; - !level->namespace_p; + level->kind != sk_namespace; level = level->level_chain) if (!lookup_using_namespace (name, &binding, level->using_directives, scope, flags, spacesp)) @@ -5936,7 +5805,7 @@ struct cp_binding_level *level; for (level = current_binding_level; - level && !level->namespace_p; + level && level->kind != sk_namespace; level = level->level_chain) { tree class_type; @@ -5944,7 +5813,7 @@ /* A conversion operator can only be declared in a class scope. */ - if (level->parm_flag != 2) + if (level->kind != sk_class) continue; /* Lookup the conversion operator in the class. */ @@ -6034,11 +5903,9 @@ tree t = NULL_TREE; timevar_push (TV_NAME_LOOKUP); - b = current_binding_level; - while (b->parm_flag == 2) - b = b->level_chain; + b = innermost_nonclass_level (); - if (b->namespace_p) + if (b->kind == sk_namespace) { t = IDENTIFIER_NAMESPACE_VALUE (name); @@ -6054,7 +5921,7 @@ if (BINDING_SCOPE (IDENTIFIER_BINDING (name)) == b) POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, IDENTIFIER_VALUE (name)); - if (b->keep == 2) + if (b->kind == sk_cleanup) b = b->level_chain; else break; @@ -6072,7 +5939,8 @@ register tree t = NULL_TREE; timevar_push (TV_NAME_LOOKUP); - my_friendly_assert (! current_binding_level->namespace_p, 980716); + my_friendly_assert (current_binding_level->kind != sk_namespace, + 980716); if (REAL_IDENTIFIER_TYPE_VALUE (name) != NULL_TREE && REAL_IDENTIFIER_TYPE_VALUE (name) != global_type_node) @@ -6083,7 +5951,7 @@ if (purpose_member (name, b->type_shadowed)) POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, REAL_IDENTIFIER_TYPE_VALUE (name)); - if (b->keep == 2) + if (b->kind == sk_cleanup) b = b->level_chain; else break; @@ -6094,6 +5962,19 @@ } + +/* A chain of TYPE_DECLs for the builtin types. */ + +static GTY(()) tree builtin_type_decls; + +/* Return a chain of TYPE_DECLs for the builtin types. */ + +tree +cxx_builtin_type_decls () +{ + return builtin_type_decls; +} + /* Push the declarations of builtin types into the namespace. RID_INDEX is the index of the builtin type in the array RID_POINTERS. NAME is the name used when looking up the builtin @@ -6121,8 +6002,7 @@ { tdecl = build_decl (TYPE_DECL, tname, type); DECL_ARTIFICIAL (tdecl) = 1; - if (tname) - SET_IDENTIFIER_GLOBAL_VALUE (tname, tdecl); + SET_IDENTIFIER_GLOBAL_VALUE (tname, tdecl); } if (rname) { @@ -6136,6 +6016,12 @@ if (!TYPE_NAME (type)) TYPE_NAME (type) = tdecl; + + if (tdecl) + { + TREE_CHAIN (tdecl) = builtin_type_decls; + builtin_type_decls = tdecl; + } } /* Record one of the standard Java types. @@ -6266,7 +6152,7 @@ my_friendly_assert (global_namespace == NULL_TREE, 375); global_namespace = build_lang_decl (NAMESPACE_DECL, global_scope_name, void_type_node); - initial_push_namespace_scope (global_namespace); + begin_scope (sk_namespace, global_namespace); current_lang_name = NULL_TREE; @@ -6504,7 +6390,7 @@ if (current_function_decl) { struct cp_binding_level *b = current_binding_level; - while (b->level_chain->parm_flag == 0) + while (b->level_chain->kind != sk_function_parms) b = b->level_chain; pushdecl_with_scope (decl, b); } @@ -6548,9 +6434,13 @@ if (libname) SET_DECL_ASSEMBLER_NAME (decl, get_identifier (libname)); if (EMIT_LLVM) + { llvm_make_decl_llvm(decl, NULL); + } else + { make_decl_rtl (decl, NULL); + } /* Warn if a function in the namespace for users is used without an occasion to consider it declared. */ @@ -6742,8 +6632,8 @@ /* ISO C++ 9.5.3. Anonymous unions may not have function members. */ if (TYPE_METHODS (t)) - error ("%Han anonymous union cannot have function members", - &DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (t))); + error ("%Jan anonymous union cannot have function members", + TYPE_MAIN_DECL (t)); /* Anonymous aggregates cannot have fields with ctors, dtors or complex assignment operators (because they cannot have these methods themselves). @@ -7076,8 +6966,7 @@ && DECL_DECLARED_INLINE_P (decl) && DECL_UNINLINABLE (decl) && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl))) - warning ("%Hinline function '%D' given attribute noinline", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jinline function '%D' given attribute noinline", decl, decl); if (context && COMPLETE_TYPE_P (complete_type (context))) { @@ -7228,14 +7117,18 @@ DECL_INITIAL (decl) = NULL_TREE; } -/* Handle initialization of references. - These three arguments are from `cp_finish_decl', and have the - same meaning here that they do there. +/* Handle initialization of references. DECL, TYPE, and INIT have the + same meaning as in cp_finish_decl. *CLEANUP must be NULL on entry, + but will be set to a new CLEANUP_STMT if a temporary is created + that must be destroeyd subsequently. + + Returns an initializer expression to use to initialize DECL, or + NULL if the initialization can be performed statically. Quotes on semantics can be found in ARM 8.4.3. */ static tree -grok_reference_init (tree decl, tree type, tree init) +grok_reference_init (tree decl, tree type, tree init, tree *cleanup) { tree tmp; @@ -7272,7 +7165,7 @@ DECL_INITIAL for local references (instead assigning to them explicitly); we need to allow the temporary to be initialized first. */ - tmp = initialize_reference (type, init, decl); + tmp = initialize_reference (type, init, decl, cleanup); if (tmp == error_mark_node) return NULL_TREE; @@ -7442,8 +7335,8 @@ TREE_PUBLIC (decl) = 0; DECL_COMMON (decl) = 0; cp_warning_at ("sorry: semantics of inline function static data `%#D' are wrong (you'll wind up with multiple copies)", decl); - warning ("%H you can work around this by removing the initializer", - &DECL_SOURCE_LOCATION (decl)); + warning ("%J you can work around this by removing the initializer", + decl); } } } @@ -7692,13 +7585,14 @@ } /* Verify INIT (the initializer for DECL), and record the - initialization in DECL_INITIAL, if appropriate. + initialization in DECL_INITIAL, if appropriate. CLEANUP is as for + grok_reference_init. If the return value is non-NULL, it is an expression that must be evaluated dynamically to initialize DECL. */ static tree -check_initializer (tree decl, tree init, int flags) +check_initializer (tree decl, tree init, int flags, tree *cleanup) { tree type = TREE_TYPE (decl); @@ -7748,7 +7642,7 @@ init = NULL_TREE; } else if (!DECL_EXTERNAL (decl) && TREE_CODE (type) == REFERENCE_TYPE) - init = grok_reference_init (decl, type, init); + init = grok_reference_init (decl, type, init, cleanup); else if (init) { if (TREE_CODE (init) == CONSTRUCTOR && TREE_HAS_CONSTRUCTOR (init)) @@ -7951,7 +7845,7 @@ return; } - if (current_binding_level->is_for_scope) + if (current_binding_level->kind == sk_for) { struct cp_binding_level *outer = current_binding_level->level_chain; @@ -7974,7 +7868,7 @@ { BINDING_VALUE (outer_binding) = DECL_SHADOWED_FOR_VAR (BINDING_VALUE (outer_binding)); - current_binding_level->is_for_scope = 0; + current_binding_level->kind = sk_block; } } timevar_pop (TV_NAME_LOOKUP); @@ -8055,8 +7949,9 @@ void cp_finish_decl (tree decl, tree init, tree asmspec_tree, int flags) { - register tree type; + tree type; tree ttype = NULL_TREE; + tree cleanup; const char *asmspec = NULL; int was_readonly = 0; @@ -8069,6 +7964,9 @@ my_friendly_assert (TREE_CODE (decl) != RESULT_DECL, 20030619); + /* Assume no cleanup is required. */ + cleanup = NULL_TREE; + /* If a name was specified, get the string. */ if (global_scope_p (current_binding_level)) asmspec_tree = maybe_apply_renaming_pragma (decl, asmspec_tree); @@ -8184,7 +8082,7 @@ is *not* defined. */ && (!DECL_EXTERNAL (decl) || init)) { - init = check_initializer (decl, init, flags); + init = check_initializer (decl, init, flags, &cleanup); /* Thread-local storage cannot be dynamically initialized. */ if (DECL_THREAD_LOCAL (decl) && init) { @@ -8263,8 +8161,7 @@ if (DECL_FUNCTION_SCOPE_P (decl)) { /* This is a local declaration. */ - if (doing_semantic_analysis_p ()) - maybe_inject_for_scope_var (decl); + maybe_inject_for_scope_var (decl); /* Initialize the local variable. */ if (processing_template_decl) { @@ -8300,6 +8197,11 @@ } } + /* If a CLEANUP_STMT was created to destroy a temporary bound to a + reference, insert it in the statement-tree now. */ + if (cleanup) + add_stmt (cleanup); + finish_end: if (was_readonly) @@ -11173,8 +11075,7 @@ { decl = build_decl (TYPE_DECL, declarator, type); if (in_namespace || ctype) - error ("%Htypedef name may not be a nested-name-specifier", - &DECL_SOURCE_LOCATION (decl)); + error ("%Jtypedef name may not be a nested-name-specifier", decl); if (!current_function_decl) DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace); } @@ -11220,8 +11121,8 @@ if (ctype == NULL_TREE) { if (TREE_CODE (type) != METHOD_TYPE) - error ("%Hinvalid type qualifier for non-member function type", - &DECL_SOURCE_LOCATION (decl)); + error ("%Jinvalid type qualifier for non-member function type", + decl); else ctype = TYPE_METHOD_BASETYPE (type); } @@ -13057,8 +12958,7 @@ if (enumtype != NULL_TREE && TREE_CODE (enumtype) == ENUMERAL_TYPE) { error ("multiple definition of `%#T'", enumtype); - error ("%Hprevious definition here", - &DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (enumtype))); + error ("%Jprevious definition here", TYPE_MAIN_DECL (enumtype)); /* Clear out TYPE_VALUES, and start again. */ TYPE_VALUES (enumtype) = NULL_TREE; } @@ -13500,8 +13400,7 @@ if (DECL_DECLARED_INLINE_P (decl1) && lookup_attribute ("noinline", attrs)) - warning ("%Hinline function '%D' given attribute noinline", - &DECL_SOURCE_LOCATION (decl1), decl1); + warning ("%Jinline function '%D' given attribute noinline", decl1, decl1); if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl1)) /* This is a constructor, we must ensure that any default args @@ -13595,7 +13494,7 @@ CFUN set up, and our per-function variables initialized. FIXME factor out the non-RTL stuff. */ bl = current_binding_level; - init_function_start (decl1); + allocate_struct_function (decl1); current_binding_level = bl; /* Even though we're inside a function body, we still don't want to @@ -13744,8 +13643,7 @@ DECL_INTERFACE_KNOWN (decl1) = 1; } - pushlevel (0); - current_binding_level->parm_flag = 1; + begin_scope (sk_function_parms, decl1); ++function_depth; @@ -13866,9 +13764,6 @@ f->bindings = NULL; f->x_local_names = NULL; - /* When we get back here again, we will be expanding. */ - f->x_expanding_p = 1; - /* If we've already decided that we cannot inline this function, we must remember that fact when we actually go to expand the function. */ @@ -14000,7 +13895,7 @@ /* Always keep the BLOCK node associated with the outermost pair of curly braces of a function. These are needed for correct operation of dwarfout.c. */ - keep_next_level (1); + keep_next_level (true); stmt = begin_compound_stmt (/*has_no_scope=*/false); COMPOUND_STMT_BODY_BLOCK (stmt) = 1; @@ -14120,7 +14015,7 @@ /* If the current binding level isn't the outermost binding level for this function, either there is a bug, or we have experienced syntax errors and the statement tree is malformed. */ - if (current_binding_level->parm_flag != 1) + if (current_binding_level->kind != sk_function_parms) { /* Make sure we have already experienced errors. */ if (errorcount == 0) @@ -14130,9 +14025,9 @@ levels. */ DECL_SAVED_TREE (fndecl) = build_stmt (COMPOUND_STMT, NULL_TREE); - while (current_binding_level->parm_flag != 1) + while (current_binding_level->kind != sk_function_parms) { - if (current_binding_level->parm_flag == 2) + if (current_binding_level->kind == sk_class) pop_nested_class (); else poplevel (0, 0, 0); @@ -14140,6 +14035,10 @@ } poplevel (1, 0, 1); + /* Statements should always be full-expressions at the outermost set + of curly braces for a function. */ + my_friendly_assert (stmts_are_full_exprs_p (), 19990831); + /* Set up the named return value optimization, if we can. Here, we eliminate the copy from the nrv into the RESULT_DECL and any cleanup for the nrv. genrtl_start_function and declare_return_variable @@ -14152,7 +14051,7 @@ if (r != error_mark_node /* This is only worth doing for fns that return in memory--and simpler, since we don't have to worry about promoted modes. */ - && aggregate_value_p (TREE_TYPE (TREE_TYPE (fndecl))) + && aggregate_value_p (TREE_TYPE (TREE_TYPE (fndecl)), fndecl) /* Only allow this for variables declared in the outer scope of the function so we know that their lifetime always ends with a return; see g++.dg/opt/nrv6.C. We could be more flexible if @@ -14210,13 +14109,11 @@ inline function, as we might never be compiled separately. */ && (DECL_INLINE (fndecl) || processing_template_decl)) warning ("no return statement in function returning non-void"); - - /* Clear out memory we no longer need. */ - free_after_parsing (cfun); - /* Since we never call rest_of_compilation, we never clear - CFUN. Do so explicitly. */ - free_after_compilation (cfun); + + /* We're leaving the context of this function, so zap cfun. It's still in + DECL_SAVED_INSNS, and we'll restore it in tree_rest_of_compilation. */ cfun = NULL; + current_function_decl = NULL; /* If this is an in-class inline definition, we may have to pop the bindings for the template parameters that we added in @@ -14323,8 +14220,7 @@ cp_finish_decl (fndecl, NULL_TREE, NULL_TREE, 0); /* Make a place for the parms */ - pushlevel (0); - current_binding_level->parm_flag = 1; + begin_scope (sk_function_parms, fndecl); DECL_IN_AGGR_P (fndecl) = 1; return fndecl; @@ -14528,13 +14424,34 @@ = ggc_alloc_cleared (sizeof (struct language_function)); f->language = p; - /* It takes an explicit call to expand_body to generate RTL for a - function. */ - expanding_p = 0; - /* Whenever we start a new function, we destroy temporaries in the usual way. */ current_stmt_tree ()->stmts_are_full_exprs_p = 1; + + if (f->decl) + { + tree fn = f->decl; + + current_function_is_thunk = DECL_THUNK_P (fn); + + if (DECL_SAVED_FUNCTION_DATA (fn)) + { + /* If we already parsed this function, and we're just expanding it + now, restore saved state. */ + *cp_function_chain = *DECL_SAVED_FUNCTION_DATA (fn); + + /* If we decided that we didn't want to inline this function, + make sure the back-end knows that. */ + if (!current_function_cannot_inline) + current_function_cannot_inline = cp_function_chain->cannot_inline; + + /* We don't need the saved data anymore. Unless this is an inline + function; we need the named return value info for + cp_copy_res_decl_for_inlining. */ + if (! DECL_INLINE (fn)) + DECL_SAVED_FUNCTION_DATA (fn) = NULL; + } + } } /* Free the language-specific parts of F, now that we've finished Index: gcc-3.4/gcc/cp/decl2.c diff -u gcc-3.4/gcc/cp/decl2.c:1.2 gcc-3.4/gcc/cp/decl2.c:1.3 --- gcc-3.4/gcc/cp/decl2.c:1.2 Thu Jan 8 17:05:28 2004 +++ gcc-3.4/gcc/cp/decl2.c Thu Feb 5 10:05:46 2004 @@ -467,8 +467,8 @@ expr = build_array_ref (array_expr, index_exp); } if (processing_template_decl && expr != error_mark_node) - return build_min (ARRAY_REF, TREE_TYPE (expr), orig_array_expr, - orig_index_exp); + return build_min_non_dep (ARRAY_REF, expr, + orig_array_expr, orig_index_exp); return expr; } @@ -1625,6 +1625,17 @@ } } +/* Return true if VAR has already been provided to the back end; in that + case VAR should not be modified further by the front end. */ +static bool +var_finalized_p (tree var) +{ + if (flag_unit_at_a_time) + return cgraph_varpool_node (var)->finalized; + else + return TREE_ASM_WRITTEN (var); +} + /* If necessary, write out the vtables for the dynamic class CTYPE. Returns true if any vtables were emitted. */ @@ -1638,7 +1649,7 @@ /* If the vtables for this class have already been emitted there is nothing more to do. */ primary_vtbl = CLASSTYPE_VTABLES (ctype); - if (TREE_ASM_WRITTEN (primary_vtbl)) + if (var_finalized_p (primary_vtbl)) return false; /* Ignore dummy vtables made by get_vtable_decl. */ if (TREE_TYPE (primary_vtbl) == void_type_node) @@ -2462,7 +2473,7 @@ tree v; for (v = vars; v; v = TREE_CHAIN (v)) - if (! TREE_ASM_WRITTEN (TREE_VALUE (v))) + if (!var_finalized_p (TREE_VALUE (v))) rest_of_decl_compilation (TREE_VALUE (v), 0, 1, 1); } @@ -2563,63 +2574,30 @@ return 0; } -/* Callgraph code does not understand the member pointers. Mark the methods - referenced as used. */ -static tree -mark_member_pointers_and_eh_handlers (tree *tp, - int *walk_subtrees, - void *data ATTRIBUTE_UNUSED) +/* Called via LANGHOOK_CALLGRAPH_ANALYZE_EXPR. It is supposed to mark + decls referenced from frontend specific constructs; it will be called + only for language-specific tree nodes. + + Here we must deal with member pointers. */ + +tree +cxx_callgraph_analyze_expr (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, + tree from ATTRIBUTE_UNUSED) { - /* Avoid useless walking of complex type and declaration nodes. */ - if (TYPE_P (*tp) || DECL_P (*tp)) - { - *walk_subtrees = 0; - return 0; - } - switch (TREE_CODE (*tp)) + tree t = *tp; + + switch (TREE_CODE (t)) { case PTRMEM_CST: - if (TYPE_PTRMEMFUNC_P (TREE_TYPE (*tp))) - cgraph_mark_needed_node (cgraph_node (PTRMEM_CST_MEMBER (*tp)), 1); + if (TYPE_PTRMEMFUNC_P (TREE_TYPE (t))) + cgraph_mark_needed_node (cgraph_node (PTRMEM_CST_MEMBER (t))); break; - /* EH handlers will emit EH tables referencing typeinfo. */ - case HANDLER: - if (HANDLER_TYPE (*tp)) - { - tree tinfo = eh_type_info (HANDLER_TYPE (*tp)); - - cgraph_varpool_mark_needed_node (cgraph_varpool_node (tinfo)); - } - break; - - case EH_SPEC_BLOCK: - { - tree type; - - for (type = EH_SPEC_RAISES ((*tp)); type; - type = TREE_CHAIN (type)) - { - tree tinfo = eh_type_info (TREE_VALUE (type)); - - cgraph_varpool_mark_needed_node (cgraph_varpool_node (tinfo)); - } - } - break; default: break; } - return 0; -} -/* Called via LANGHOOK_CALLGRAPH_LOWER_FUNCTION. It is supposed to lower - frontend specific constructs that would otherwise confuse the middle end. */ -void -lower_function (tree fn) -{ - walk_tree_without_duplicates (&DECL_SAVED_TREE (fn), - mark_member_pointers_and_eh_handlers, - NULL); + return NULL; } /* This routine is called from the last rule in yyparse (). @@ -2737,12 +2715,12 @@ them to the beginning of the array, then get rid of the leftovers. */ n_new = VARRAY_ACTIVE_SIZE (unemitted_tinfo_decls) - n_old; - memmove (&VARRAY_TREE (unemitted_tinfo_decls, 0), - &VARRAY_TREE (unemitted_tinfo_decls, n_old), - n_new * sizeof (tree)); + if (n_new) + memmove (&VARRAY_TREE (unemitted_tinfo_decls, 0), + &VARRAY_TREE (unemitted_tinfo_decls, n_old), + n_new * sizeof (tree)); memset (&VARRAY_TREE (unemitted_tinfo_decls, n_new), - 0, - n_old * sizeof (tree)); + 0, n_old * sizeof (tree)); VARRAY_ACTIVE_SIZE (unemitted_tinfo_decls) = n_new; /* The list of objects with static storage duration is built up @@ -2885,7 +2863,7 @@ for (i = 0; i < pending_statics_used; ++i) { tree decl = VARRAY_TREE (pending_statics, i); - if (TREE_ASM_WRITTEN (decl)) + if (var_finalized_p (decl)) continue; import_export_decl (decl); if (DECL_NOT_REALLY_EXTERN (decl) && ! DECL_IN_AGGR_P (decl)) @@ -2895,6 +2873,9 @@ && wrapup_global_declarations (&VARRAY_TREE (pending_statics, 0), pending_statics_used)) reconsider = true; + + if (cgraph_assemble_pending_functions ()) + reconsider = true; } while (reconsider); @@ -3039,7 +3020,7 @@ expr = build_function_call (fn, args); if (processing_template_decl && expr != error_mark_node) - return build_min (CALL_EXPR, TREE_TYPE (expr), orig_fn, orig_args); + return build_min_non_dep (CALL_EXPR, expr, orig_fn, orig_args); return expr; } @@ -3253,10 +3234,8 @@ if (flags & LOOKUP_COMPLAIN) { error ("`%D' denotes an ambiguous type",name); - error ("%H first type here", - &DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (BINDING_TYPE (old)))); - error ("%H other type here", - &DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type))); + error ("%J first type here", TYPE_MAIN_DECL (BINDING_TYPE (old))); + error ("%J other type here", TYPE_MAIN_DECL (type)); } } return old; @@ -3509,6 +3488,8 @@ /* We must find only functions, or exactly one non-function. */ if (!k->functions) k->functions = fn; + else if (fn == k->functions) + ; else if (is_overloaded_fn (k->functions) && is_overloaded_fn (fn)) k->functions = build_overload (fn, k->functions); else Index: gcc-3.4/gcc/cp/method.c diff -u gcc-3.4/gcc/cp/method.c:1.2 gcc-3.4/gcc/cp/method.c:1.3 --- gcc-3.4/gcc/cp/method.c:1.2 Thu Jan 8 17:05:28 2004 +++ gcc-3.4/gcc/cp/method.c Thu Feb 5 10:05:46 2004 @@ -431,6 +431,7 @@ tree x = copy_node (a); TREE_CHAIN (x) = t; DECL_CONTEXT (x) = thunk_fndecl; + SET_DECL_RTL (x, NULL_RTX); t = x; } a = nreverse (t); Index: gcc-3.4/gcc/cp/pt.c diff -u gcc-3.4/gcc/cp/pt.c:1.2 gcc-3.4/gcc/cp/pt.c:1.3 --- gcc-3.4/gcc/cp/pt.c:1.2 Thu Jan 8 17:05:28 2004 +++ gcc-3.4/gcc/cp/pt.c Thu Feb 5 10:05:47 2004 @@ -94,7 +94,7 @@ static int resolve_overloaded_unification (tree, tree, tree, tree, unification_kind_t, int); static int try_one_overload (tree, tree, tree, tree, tree, - unification_kind_t, int); + unification_kind_t, int, bool); static int unify (tree, tree, tree, tree, int); static void add_pending_template (tree); static void reopen_tinst_level (tree); @@ -353,7 +353,8 @@ parms, current_template_parms); TEMPLATE_PARMS_FOR_INLINE (current_template_parms) = 1; - pushlevel (0); + begin_scope (TREE_VEC_LENGTH (parms) ? sk_template_parms : sk_template_spec, + NULL); for (i = 0; i < TREE_VEC_LENGTH (parms); ++i) { tree parm = TREE_VALUE (TREE_VEC_ELT (parms, i)); @@ -610,7 +611,7 @@ pushtag contains special code to call pushdecl_with_scope on the TEMPLATE_DECL for S2. */ - begin_scope (sk_template_parms); + begin_scope (sk_template_parms, NULL); ++processing_template_decl; ++processing_template_parmlist; note_template_header (0); @@ -654,7 +655,7 @@ void begin_specialization (void) { - begin_scope (sk_template_spec); + begin_scope (sk_template_spec, NULL); note_template_header (1); check_specialization_scope (); } @@ -2947,8 +2948,7 @@ A template-parameter may not be given default arguments by two different declarations in the same scope. */ error ("redefinition of default argument for `%#D'", parm); - error ("%H original definition appeared here", - &DECL_SOURCE_LOCATION (tmpl_parm)); + error ("%J original definition appeared here", tmpl_parm); return; } @@ -3210,9 +3210,12 @@ tree type_referred_to = TREE_TYPE (type); /* If this expression already has reference type, get the - underling object. */ + underlying object. */ if (TREE_CODE (expr_type) == REFERENCE_TYPE) { + if (TREE_CODE (expr) == NOP_EXPR + && TREE_CODE (TREE_OPERAND (expr, 0)) == ADDR_EXPR) + STRIP_NOPS (expr); my_friendly_assert (TREE_CODE (expr) == ADDR_EXPR, 20000604); expr = TREE_OPERAND (expr, 0); expr_type = TREE_TYPE (expr); @@ -3266,7 +3269,7 @@ } cxx_mark_addressable (expr); - return build1 (ADDR_EXPR, type, expr); + return build_nop (type, build_address (expr)); } break; @@ -3852,7 +3855,8 @@ return error_mark_node; my_friendly_assert (!arglist || TREE_CODE (arglist) == TREE_VEC, 20030726); - if (fns == NULL_TREE) + if (fns == NULL_TREE + || TREE_CODE (fns) == FUNCTION_DECL) { error ("non-template used as template"); return error_mark_node; @@ -4998,6 +5002,8 @@ DECL_USE_TEMPLATE (tmpl) = 0; DECL_TEMPLATE_INFO (tmpl) = NULL_TREE; CLASSTYPE_USE_TEMPLATE (TREE_TYPE (tmpl)) = 0; + CLASSTYPE_TI_ARGS (TREE_TYPE (tmpl)) + = INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (TREE_TYPE (tmpl))); /* Inject this template into the global scope. */ friend_type = TREE_TYPE (pushdecl_top_level (tmpl)); @@ -5251,12 +5257,14 @@ if (TYPE_LANG_SPECIFIC (tag) && CLASSTYPE_IS_TEMPLATE (tag)) /* Unfortunately, lookup_template_class sets CLASSTYPE_IMPLICIT_INSTANTIATION for a partial - instantiation (i.e., for the type of a member template - class nested within a template class.) This behavior is - required for maybe_process_partial_specialization to work - correctly, but is not accurate in this case; the TAG is not - an instantiation of anything. (The corresponding - TEMPLATE_DECL is an instantiation, but the TYPE is not.) */ + instantiation (i.e., for the type of a member + template class nested within a template class.) + This behavior is required for + maybe_process_partial_specialization to work + correctly, but is not accurate in this case; + the TAG is not an instantiation of anything. + (The corresponding TEMPLATE_DECL is an + instantiation, but the TYPE is not.) */ CLASSTYPE_USE_TEMPLATE (newtag) = 0; /* Now, we call pushtag to put this NEWTAG into the scope of @@ -5273,8 +5281,13 @@ || DECL_FUNCTION_TEMPLATE_P (t)) { /* Build new TYPE_METHODS. */ - - tree r = tsubst (t, args, tf_error, NULL_TREE); + tree r; + + if (TREE_CODE (t) == TEMPLATE_DECL) + processing_template_decl++; + r = tsubst (t, args, tf_error, NULL_TREE); + if (TREE_CODE (t) == TEMPLATE_DECL) + processing_template_decl--; set_current_access_from_decl (r); grok_special_member_properties (r); finish_member_declaration (r); @@ -7089,7 +7102,17 @@ my_friendly_assert (!dependent_type_p (scope), 20030729); if (!BASELINK_P (name) && !DECL_P (expr)) - expr = lookup_qualified_name (scope, expr, /*is_type_p=*/0, false); + { + expr = lookup_qualified_name (scope, expr, /*is_type_p=*/0, false); + if (TREE_CODE (TREE_CODE (expr) == TEMPLATE_DECL + ? DECL_TEMPLATE_RESULT (expr) : expr) == TYPE_DECL) + { + if (complain & tf_error) + error ("`%E' names a type, but a non-type is expected", + qualified_id); + return error_mark_node; + } + } if (DECL_P (expr)) check_accessibility_of_qualified_id (expr, /*object_type=*/NULL_TREE, @@ -7303,7 +7326,6 @@ case ROUND_DIV_EXPR: case EXACT_DIV_EXPR: case BIT_AND_EXPR: - case BIT_ANDTC_EXPR: case BIT_IOR_EXPR: case BIT_XOR_EXPR: case TRUNC_MOD_EXPR: @@ -7548,7 +7570,8 @@ scope = tsubst_expr (scope, args, complain, in_decl); decl = lookup_qualified_name (scope, name, - /*is_type_p=*/0, /*complain=*/false); + /*is_type_p=*/false, + /*complain=*/false); if (decl == error_mark_node) qualified_name_lookup_error (scope, name); else @@ -7973,6 +7996,8 @@ else op1 = tsubst_non_call_postfix_expression (op1, args, complain, in_decl); + if (TREE_CODE (op1) == LABEL_DECL) + return finish_label_address_expr (DECL_NAME (op1)); return build_x_unary_op (ADDR_EXPR, op1); case PLUS_EXPR: @@ -7984,7 +8009,6 @@ case ROUND_DIV_EXPR: case EXACT_DIV_EXPR: case BIT_AND_EXPR: - case BIT_ANDTC_EXPR: case BIT_IOR_EXPR: case BIT_XOR_EXPR: case TRUNC_MOD_EXPR: @@ -8046,10 +8070,10 @@ op1 = RECUR (op1); --skip_evaluation; } - if (TREE_CODE (t) == SIZEOF_EXPR) - return finish_sizeof (op1); + if (TYPE_P (op1)) + return cxx_sizeof_or_alignof_type (op1, TREE_CODE (t), true); else - return finish_alignof (op1); + return cxx_sizeof_or_alignof_expr (op1, TREE_CODE (t)); case MODOP_EXPR: return build_x_modify_expr @@ -8091,18 +8115,9 @@ bool koenig_p; function = TREE_OPERAND (t, 0); - /* To determine whether or not we should perform Koenig lookup - we must look at the form of the FUNCTION. */ - koenig_p = !(/* Koenig lookup does not apply to qualified - names. */ - TREE_CODE (function) == SCOPE_REF - /* Or to references to members of classes. */ - || TREE_CODE (function) == COMPONENT_REF - /* If it is a FUNCTION_DECL or a baselink, then - the name was already resolved when the - template was parsed. */ - || TREE_CODE (function) == FUNCTION_DECL - || TREE_CODE (function) == BASELINK); + /* When we parsed the expression, we determined whether or + not Koenig lookup should be performed. */ + koenig_p = KOENIG_LOOKUP_P (t); if (TREE_CODE (function) == SCOPE_REF) { qualified_p = true; @@ -8118,23 +8133,22 @@ function = tsubst_copy_and_build (function, args, complain, in_decl, !qualified_p); + if (BASELINK_P (function)) + qualified_p = true; } call_args = RECUR (TREE_OPERAND (t, 1)); - if (BASELINK_P (function)) - qualified_p = 1; - if (koenig_p - && TREE_CODE (function) != TEMPLATE_ID_EXPR && (is_overloaded_fn (function) || DECL_P (function) || TREE_CODE (function) == IDENTIFIER_NODE)) + function = perform_koenig_lookup (function, call_args); + + if (TREE_CODE (function) == IDENTIFIER_NODE) { - if (call_args) - function = perform_koenig_lookup (function, call_args); - else if (TREE_CODE (function) == IDENTIFIER_NODE) - function = unqualified_name_lookup_error (function); + unqualified_name_lookup_error (function); + return error_mark_node; } /* Remember that there was a reference to this entity. */ @@ -8152,7 +8166,8 @@ call_args, NULL_TREE, qualified_p ? LOOKUP_NONVIRTUAL : LOOKUP_NORMAL)); return finish_call_expr (function, call_args, - /*disallow_virtual=*/qualified_p); + /*disallow_virtual=*/qualified_p, + koenig_p); } case COND_EXPR: @@ -8232,7 +8247,8 @@ tmpl = TREE_OPERAND (TREE_OPERAND (member, 1), 0); args = TREE_OPERAND (TREE_OPERAND (member, 1), 1); member = lookup_qualified_name (TREE_OPERAND (member, 0), tmpl, - /*is_type=*/0, /*complain=*/false); + /*is_type_p=*/false, + /*complain=*/false); if (BASELINK_P (member)) BASELINK_FUNCTIONS (member) = build_nt (TEMPLATE_ID_EXPR, BASELINK_FUNCTIONS (member), @@ -8918,9 +8934,15 @@ { tree tempargs = copy_node (targs); int good = 0; + bool addr_p; if (TREE_CODE (arg) == ADDR_EXPR) - arg = TREE_OPERAND (arg, 0); + { + arg = TREE_OPERAND (arg, 0); + addr_p = true; + } + else + addr_p = false; if (TREE_CODE (arg) == COMPONENT_REF) /* Handle `&x' where `x' is some static or non-static member @@ -8956,10 +8978,8 @@ if (subargs) { elem = tsubst (TREE_TYPE (fn), subargs, tf_none, NULL_TREE); - if (TREE_CODE (elem) == METHOD_TYPE) - elem = build_ptrmemfunc_type (build_pointer_type (elem)); - good += try_one_overload (tparms, targs, tempargs, parm, elem, - strict, sub_strict); + good += try_one_overload (tparms, targs, tempargs, parm, + elem, strict, sub_strict, addr_p); } } } @@ -8967,14 +8987,9 @@ || TREE_CODE (arg) == FUNCTION_DECL) { for (; arg; arg = OVL_NEXT (arg)) - { - tree type = TREE_TYPE (OVL_CURRENT (arg)); - if (TREE_CODE (type) == METHOD_TYPE) - type = build_ptrmemfunc_type (build_pointer_type (type)); - good += try_one_overload (tparms, targs, tempargs, parm, - type, - strict, sub_strict); - } + good += try_one_overload (tparms, targs, tempargs, parm, + TREE_TYPE (OVL_CURRENT (arg)), + strict, sub_strict, addr_p); } else abort (); @@ -9003,6 +9018,9 @@ /* Subroutine of resolve_overloaded_unification; does deduction for a single overload. Fills TARGS with any deduced arguments, or error_mark_node if different overloads deduce different arguments for a given parm. + ADDR_P is true if the expression for which deduction is being + performed was of the form "& fn" rather than simply "fn". + Returns 1 on success. */ static int @@ -9012,7 +9030,8 @@ tree parm, tree arg, unification_kind_t strict, - int sub_strict) + int sub_strict, + bool addr_p) { int nargs; tree tempargs; @@ -9028,6 +9047,11 @@ if (uses_template_parms (arg)) return 1; + if (TREE_CODE (arg) == METHOD_TYPE) + arg = build_ptrmemfunc_type (build_pointer_type (arg)); + else if (addr_p) + arg = build_pointer_type (arg); + sub_strict |= maybe_adjust_types_for_deduction (strict, &parm, &arg); /* We don't copy orig_targs for this because if we have already deduced @@ -10594,7 +10618,14 @@ details. */ DECL_TI_TEMPLATE (new_decl) = DECL_TI_TEMPLATE (decl); COPY_DECL_ASSEMBLER_NAME (decl, new_decl); - COPY_DECL_RTL (decl, new_decl); + if (EMIT_LLVM) + { + COPY_DECL_LLVM (decl, new_decl); + } + else + { + COPY_DECL_RTL (decl, new_decl); + } DECL_USE_TEMPLATE (new_decl) = DECL_USE_TEMPLATE (decl); /* Call duplicate decls to merge the old and new declarations. */ @@ -10724,10 +10755,14 @@ timevar_push (TV_PARSE); - /* We may be in the middle of deferred access check. Disable - it now. */ + /* We may be in the middle of deferred access check. Disable it now. */ push_deferring_access_checks (dk_no_deferred); + /* Our caller does not expect collection to happen, which it might if + we decide to compile the function to rtl now. Arrange for a new + gc context to be created if so. */ + function_depth++; + /* Set TD to the template whose DECL_TEMPLATE_RESULT is the pattern for the instantiation. */ td = template_for_substitution (d); @@ -10972,6 +11007,7 @@ input_location = saved_loc; pop_deferring_access_checks (); pop_tinst_level (); + function_depth--; timevar_pop (TV_PARSE); @@ -11333,7 +11369,8 @@ /* ... or any of the template arguments is a dependent type or an expression that is type-dependent or value-dependent. */ else if (CLASS_TYPE_P (type) && CLASSTYPE_TEMPLATE_INFO (type) - && any_dependent_template_arguments_p (CLASSTYPE_TI_ARGS (type))) + && (any_dependent_template_arguments_p + (INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (type))))) return true; /* All TYPEOF_TYPEs are dependent; if the argument of the `typeof' @@ -11805,6 +11842,11 @@ types. */ if (TREE_CODE (expr) == OVERLOAD) return expr; + /* Preserve string constants; conversions from string constants to + "char *" are allowed, even though normally a "const char *" + cannot be used to initialize a "char *". */ + if (TREE_CODE (expr) == STRING_CST) + return expr; if (TREE_CODE (expr) == COND_EXPR) return build (COND_EXPR, @@ -11812,7 +11854,8 @@ TREE_OPERAND (expr, 0), build_non_dependent_expr (TREE_OPERAND (expr, 1)), build_non_dependent_expr (TREE_OPERAND (expr, 2))); - if (TREE_CODE (expr) == COMPOUND_EXPR) + if (TREE_CODE (expr) == COMPOUND_EXPR + && !COMPOUND_EXPR_OVERLOADED (expr)) return build (COMPOUND_EXPR, TREE_TYPE (expr), TREE_OPERAND (expr, 0), Index: gcc-3.4/gcc/cp/rtti.c diff -u gcc-3.4/gcc/cp/rtti.c:1.2 gcc-3.4/gcc/cp/rtti.c:1.3 --- gcc-3.4/gcc/cp/rtti.c:1.2 Fri Jan 9 10:54:32 2004 +++ gcc-3.4/gcc/cp/rtti.c Thu Feb 5 10:05:47 2004 @@ -358,8 +358,9 @@ TREE_READONLY (d) = 1; TREE_STATIC (d) = 1; DECL_EXTERNAL (d) = 1; - SET_DECL_ASSEMBLER_NAME (d, name); DECL_COMDAT (d) = 1; + TREE_PUBLIC (d) = 1; + SET_DECL_ASSEMBLER_NAME (d, name); pushdecl_top_level_and_finish (d, NULL_TREE); @@ -373,6 +374,10 @@ my_friendly_assert (unemitted_tinfo_decls != 0, 20030312); VARRAY_PUSH_TREE (unemitted_tinfo_decls, d); + /* + * LLVM_TODO: + * I don't know if this should be here or not. + */ if (is_in_anonymous_namespace(TYPE_CONTEXT(type))) TREE_PUBLIC(d) = 0; } @@ -655,6 +660,7 @@ (NULL_TREE, ptrdiff_type_node, void_list_node)))); tmp = build_function_type (ptr_type_node, tmp); dcast_fn = build_library_fn_ptr (name, tmp); + DECL_IS_PURE (dcast_fn) = 1; pop_nested_namespace (ns); dynamic_cast_node = dcast_fn; } @@ -689,7 +695,12 @@ return error_mark_node; if (processing_template_decl) - return build_min (DYNAMIC_CAST_EXPR, type, expr); + { + expr = build_min (DYNAMIC_CAST_EXPR, type, expr); + TREE_SIDE_EFFECTS (expr) = 1; + + return expr; + } return convert_from_reference (build_dynamic_cast_1 (type, expr)); } Index: gcc-3.4/gcc/cp/semantics.c diff -u gcc-3.4/gcc/cp/semantics.c:1.2 gcc-3.4/gcc/cp/semantics.c:1.3 --- gcc-3.4/gcc/cp/semantics.c:1.2 Thu Jan 8 17:05:28 2004 +++ gcc-3.4/gcc/cp/semantics.c Thu Feb 5 10:05:47 2004 @@ -61,9 +61,6 @@ static void genrtl_eh_spec_block (tree); static void genrtl_handler (tree); static void cp_expand_stmt (tree); -static struct llvm_function *genrtl_start_function (tree); -static void genrtl_finish_function (struct llvm_function *, tree); -static tree clear_decl_rtl (tree *, int *, void *); /* Finish processing the COND, the SUBSTMT condition for STMT. */ @@ -364,7 +361,7 @@ { if (!processing_template_decl) add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0); - begin_scope (sk); + begin_scope (sk, NULL); } } @@ -380,13 +377,17 @@ mark the used labels as used. */ if (TREE_CODE (destination) == LABEL_DECL) TREE_USED (destination) = 1; - - if (TREE_CODE (destination) != LABEL_DECL) - /* We don't inline calls to functions with computed gotos. - Those functions are typically up to some funny business, - and may be depending on the labels being at particular - addresses, or some such. */ - DECL_UNINLINABLE (current_function_decl) = 1; + else + { + /* The DESTINATION is being used as an rvalue. */ + if (!processing_template_decl) + destination = decay_conversion (destination); + /* We don't inline calls to functions with computed gotos. + Those functions are typically up to some funny business, + and may be depending on the labels being at particular + addresses, or some such. */ + DECL_UNINLINABLE (current_function_decl) = 1; + } check_goto (destination); @@ -1004,7 +1005,7 @@ statement-expression. But, if it's a statement-expression with a scopeless block, there's nothing to keep, and we don't want to accidentally keep a block *inside* the scopeless block. */ - keep_next_level (0); + keep_next_level (false); return r; } @@ -1408,7 +1409,7 @@ last_expr_type = NULL_TREE; - keep_next_level (1); + keep_next_level (true); return last_tree; } @@ -1534,8 +1535,9 @@ } /* Perform Koenig lookup. FN is the postfix-expression representing - the call; ARGS are the arguments to the call. Returns the - functions to be considered by overload resolution. */ + the function (or functions) to call; ARGS are the arguments to the + call. Returns the functions to be considered by overload + resolution. */ tree perform_koenig_lookup (tree fn, tree args) @@ -1585,7 +1587,7 @@ Returns code for the call. */ tree -finish_call_expr (tree fn, tree args, bool disallow_virtual) +finish_call_expr (tree fn, tree args, bool disallow_virtual, bool koenig_p) { tree result; tree orig_fn; @@ -1605,7 +1607,11 @@ { if (type_dependent_expression_p (fn) || any_type_dependent_arguments_p (args)) - return build_nt (CALL_EXPR, fn, args); + { + result = build_nt (CALL_EXPR, fn, args); + KOENIG_LOOKUP_P (result) = koenig_p; + return result; + } if (!BASELINK_P (fn) && TREE_CODE (fn) != PSEUDO_DTOR_EXPR && TREE_TYPE (fn) != unknown_type_node) @@ -1618,12 +1624,11 @@ to refer to it. */ if (!BASELINK_P (fn) && is_overloaded_fn (fn)) { - tree f; + tree f = fn; - if (TREE_CODE (fn) == TEMPLATE_ID_EXPR) - f = get_first_fn (TREE_OPERAND (fn, 0)); - else - f = get_first_fn (fn); + if (TREE_CODE (f) == TEMPLATE_ID_EXPR) + f = TREE_OPERAND (f, 0); + f = get_first_fn (f); if (DECL_FUNCTION_MEMBER_P (f)) { tree type = currently_open_derived_class (DECL_CONTEXT (f)); @@ -1707,7 +1712,10 @@ result = build_function_call (fn, args); if (processing_template_decl) - return build (CALL_EXPR, TREE_TYPE (result), orig_fn, orig_args); + { + result = build (CALL_EXPR, TREE_TYPE (result), orig_fn, orig_args); + KOENIG_LOOKUP_P (result) = koenig_p; + } return result; } @@ -2661,26 +2669,6 @@ return type; } -/* Compute the value of the `sizeof' operator. */ - -tree -finish_sizeof (tree t) -{ - return TYPE_P (t) ? cxx_sizeof (t) : expr_sizeof (t); -} - -/* Implement the __alignof keyword: Return the minimum required - alignment of T, measured in bytes. */ - -tree -finish_alignof (tree t) -{ - if (processing_template_decl) - return build_min (ALIGNOF_EXPR, size_type_node, t); - - return TYPE_P (t) ? cxx_alignof (t) : c_alignof_expr (t); -} - /* Generate RTL for the statement T, and its substatements, and any other statements at its nesting level. */ @@ -2859,14 +2847,7 @@ void expand_body (tree fn) { - location_t saved_loc; tree saved_function; -#if EMIT_LLVM - struct llvm_function *LLVMFn; -#endif - - if (flag_unit_at_a_time && !cgraph_global_info_ready) - abort (); /* Compute the appropriate object-file linkage for inline functions. */ @@ -2879,75 +2860,57 @@ we're not planning on emitting it, in case we get a chance to inline it. */ if (DECL_EXTERNAL (fn)) + { return; + } - /* Save the current file name and line number. When we expand the - body of the function, we'll set INPUT_LOCATION so that - error-messages come out in the right places. */ - saved_loc = input_location; + /* ??? When is this needed? */ saved_function = current_function_decl; - input_location = DECL_SOURCE_LOCATION (fn); - current_function_decl = fn; timevar_push (TV_INTEGRATION); - - /* Optimize the body of the function before expanding it. */ optimize_function (fn); - timevar_pop (TV_INTEGRATION); - timevar_push (TV_EXPAND); - -#if EMIT_LLVM - LLVMFn = -#endif - genrtl_start_function (fn); - - current_function_is_thunk = DECL_THUNK_P (fn); - - /* Expand the body. */ -#if EMIT_LLVM - llvm_expand_stmt(LLVMFn, DECL_SAVED_TREE (fn)); -#else - expand_stmt (DECL_SAVED_TREE (fn)); -#endif - /* Statements should always be full-expressions at the outermost set - of curly braces for a function. */ - my_friendly_assert (stmts_are_full_exprs_p (), 19990831); - - /* The outermost statement for a function contains the line number - recorded when we finished processing the function. */ - input_line = STMT_LINENO (DECL_SAVED_TREE (fn)); + tree_rest_of_compilation (fn, function_depth > 1); - /* Generate code for the function. */ - genrtl_finish_function ( -#if EMIT_LLVM - LLVMFn, -#endif - fn); - - /* If possible, obliterate the body of the function so that it can - be garbage collected. */ - if (dump_enabled_p (TDI_all)) - /* Keep the body; we're going to dump it. */ - ; - else if (DECL_INLINE (fn) && flag_inline_trees) - /* We might need the body of this function so that we can expand - it inline somewhere else. */ - ; - else - /* We don't need the body; blow it away. */ - DECL_SAVED_TREE (fn) = NULL_TREE; - - /* And restore the current source position. */ current_function_decl = saved_function; - input_location = saved_loc; - extract_interface_info (); - timevar_pop (TV_EXPAND); + extract_interface_info (); /* Emit any thunks that should be emitted at the same time as FN. */ emit_associated_thunks (fn); + + /* If this function is marked with the constructor attribute, add it + to the list of functions to be called along with constructors + from static duration objects. */ + if (DECL_STATIC_CONSTRUCTOR (fn)) + static_ctors = tree_cons (NULL_TREE, fn, static_ctors); + + /* If this function is marked with the destructor attribute, add it + to the list of functions to be called along with destructors from + static duration objects. */ + if (DECL_STATIC_DESTRUCTOR (fn)) + static_dtors = tree_cons (NULL_TREE, fn, static_dtors); + + if (DECL_CLONED_FUNCTION_P (fn)) + { + /* If this is a clone, go through the other clones now and mark + their parameters used. We have to do that here, as we don't + know whether any particular clone will be expanded, and + therefore cannot pick one arbitrarily. */ + tree probe; + + for (probe = TREE_CHAIN (DECL_CLONED_FUNCTION (fn)); + probe && DECL_CLONED_FUNCTION_P (probe); + probe = TREE_CHAIN (probe)) + { + tree parms; + + for (parms = DECL_ARGUMENTS (probe); + parms; parms = TREE_CHAIN (parms)) + TREE_USED (parms) = 1; + } + } } /* Generate RTL for FN. */ @@ -2993,62 +2956,16 @@ if (flag_syntax_only) return; - if (flag_unit_at_a_time && cgraph_global_info_ready) - abort (); - - if (flag_unit_at_a_time && !cgraph_global_info_ready) - { - if (at_eof) - { - /* Compute the appropriate object-file linkage for inline - functions. */ - if (DECL_DECLARED_INLINE_P (fn)) - import_export_decl (fn); - cgraph_finalize_function (fn, DECL_SAVED_TREE (fn)); - } - else - { - if (!DECL_EXTERNAL (fn)) - { - DECL_NOT_REALLY_EXTERN (fn) = 1; - DECL_EXTERNAL (fn) = 1; - } - /* Remember this function. In finish_file we'll decide if - we actually need to write this function out. */ - defer_fn (fn); - /* Let the back-end know that this function exists. */ - (*debug_hooks->deferred_inline_function) (fn); - } - return; - } + /* Compute the appropriate object-file linkage for inline functions. */ + if (DECL_DECLARED_INLINE_P (fn)) + import_export_decl (fn); + function_depth++; - /* If possible, avoid generating RTL for this function. Instead, - just record it as an inline function, and wait until end-of-file - to decide whether to write it out or not. */ - if (/* We have to generate RTL if it's not an inline function. */ - (DECL_INLINE (fn) || DECL_COMDAT (fn)) - /* Or if we have to emit code for inline functions anyhow. */ - && !flag_keep_inline_functions - /* Or if we actually have a reference to the function. */ - && !DECL_NEEDED_P (fn)) - { - /* Set DECL_EXTERNAL so that assemble_external will be called as - necessary. We'll clear it again in finish_file. */ - if (!DECL_EXTERNAL (fn)) - { - DECL_NOT_REALLY_EXTERN (fn) = 1; - DECL_EXTERNAL (fn) = 1; - } - /* Remember this function. In finish_file we'll decide if - we actually need to write this function out. */ - defer_fn (fn); - /* Let the back-end know that this function exists. */ - (*debug_hooks->deferred_inline_function) (fn); - return; - } + /* Expand or defer, at the whim of the compilation unit manager. */ + cgraph_finalize_function (fn, function_depth > 1); - expand_body (fn); + function_depth--; } /* Helper function for walk_tree, used by finish_function to override all @@ -3076,231 +2993,25 @@ /* Start generating the RTL for FN. */ -static struct llvm_function * -genrtl_start_function (tree fn) +void +cxx_expand_function_start (void) { -#if EMIT_LLVM - struct llvm_function *LLVMFn; -#endif - - /* Tell everybody what function we're processing. */ - current_function_decl = fn; - /* Get the RTL machinery going for this function. */ - init_function_start (fn); - /* Let everybody know that we're expanding this function, not doing - semantic analysis. */ - expanding_p = 1; - - /* Even though we're inside a function body, we still don't want to - call expand_expr to calculate the size of a variable-sized array. - We haven't necessarily assigned RTL to all variables yet, so it's - not safe to try to expand expressions involving them. */ - immediate_size_expand = 0; - cfun->x_dont_save_pending_sizes_p = 1; - - /* Let the user know we're compiling this function. */ - announce_function (fn); - - /* Initialize the per-function data. */ - my_friendly_assert (!DECL_PENDING_INLINE_P (fn), 20000911); - if (DECL_SAVED_FUNCTION_DATA (fn)) - { - /* If we already parsed this function, and we're just expanding it - now, restore saved state. */ - *cp_function_chain = *DECL_SAVED_FUNCTION_DATA (fn); - - /* This function is being processed in whole-function mode; we - already did semantic analysis. */ - cfun->x_whole_function_mode_p = 1; - - /* If we decided that we didn't want to inline this function, - make sure the back-end knows that. */ - if (!current_function_cannot_inline) - current_function_cannot_inline = cp_function_chain->cannot_inline; - - /* We don't need the saved data anymore. Unless this is an inline - function; we need the named return value info for - cp_copy_res_decl_for_inlining. */ - if (! DECL_INLINE (fn)) - DECL_SAVED_FUNCTION_DATA (fn) = NULL; - } - - /* Keep track of how many functions we're presently expanding. */ - ++function_depth; - -#if EMIT_LLVM - /* Create a binding level for the parameters. */ - LLVMFn = llvm_expand_function_start (fn, /*parms_have_cleanups=*/0); - - /* If the named return value optimization has been applied to this function, - * set the LLVM value of the named returned value equal to the llvm of the - * DECL_RESULT. - */ - if (current_function_return_value) - COPY_DECL_LLVM (DECL_RESULT (fn), current_function_return_value); - - /* If this function is `main'. */ - if (DECL_MAIN_P (fn)) - llvm_expand_main_function (LLVMFn); - - return LLVMFn; -#else - /* Create a binding level for the parameters. */ - expand_function_start (fn, /*parms_have_cleanups=*/0); - /* If this function is `main'. */ - if (DECL_MAIN_P (fn)) - expand_main_function (); - /* Give our named return value the same RTL as our RESULT_DECL. */ if (current_function_return_value) - COPY_DECL_RTL (DECL_RESULT (fn), current_function_return_value); -#endif + COPY_DECL_RTL (DECL_RESULT (cfun->decl), current_function_return_value); } -/* Finish generating the RTL for FN. */ - -static void -genrtl_finish_function (struct llvm_function *LLVMFn, tree fn) -{ -#if 0 - tree t; - - if (write_symbols != NO_DEBUG) - { - /* Keep this code around in case we later want to control debug info - based on whether a type is "used". (jason 1999-11-11) */ - - tree ttype = target_type (fntype); - tree parmdecl; - - if (IS_AGGR_TYPE (ttype)) - /* Let debugger know it should output info for this type. */ - note_debug_info_needed (ttype); - - for (parmdecl = DECL_ARGUMENTS (fndecl); parmdecl; parmdecl = TREE_CHAIN (parmdecl)) - { - ttype = target_type (TREE_TYPE (parmdecl)); - if (IS_AGGR_TYPE (ttype)) - /* Let debugger know it should output info for this type. */ - note_debug_info_needed (ttype); - } - } -#endif - - /* Clean house because we will need to reorder insns here. */ - do_pending_stack_adjust (); - - /* If we have a named return value, we need to force a return so that - the return register is USEd. */ - if (DECL_NAME (DECL_RESULT (fn))) - emit_jump (return_label); - - /* We hard-wired immediate_size_expand to zero in start_function. - Expand_function_end will decrement this variable. So, we set the - variable to one here, so that after the decrement it will remain - zero. */ - immediate_size_expand = 1; - - if (EMIT_LLVM) - llvm_expand_function_end (LLVMFn, fn, 0); - else { - /* Generate rtl for function exit. */ - expand_function_end (); - } - - /* If this is a nested function (like a template instantiation that - we're compiling in the midst of compiling something else), push a - new GC context. That will keep local variables on the stack from - being collected while we're doing the compilation of this - function. */ - if (function_depth > 1) - ggc_push_context (); - - /* There's no need to defer outputting this function any more; we - know we want to output it. */ - DECL_DEFER_OUTPUT (fn) = 0; - #if EMIT_LLVM - if (EMIT_CODE_INCREMENTALLY) llvm_function_print(LLVMFn, llvm_out_file); - cfun = 0; -#else - /* Run the optimizers and output the assembler code for this - function. */ - rest_of_compilation (fn); -#endif - - /* Undo the call to ggc_push_context above. */ - if (function_depth > 1) - ggc_pop_context (); - -#if 0 - /* Keep this code around in case we later want to control debug info - based on whether a type is "used". (jason 1999-11-11) */ - - if (ctype && TREE_ASM_WRITTEN (fn)) - note_debug_info_needed (ctype); -#endif - - /* If this function is marked with the constructor attribute, add it - to the list of functions to be called along with constructors - from static duration objects. */ - if (DECL_STATIC_CONSTRUCTOR (fn)) - static_ctors = tree_cons (NULL_TREE, fn, static_ctors); - - /* If this function is marked with the destructor attribute, add it - to the list of functions to be called along with destructors from - static duration objects. */ - if (DECL_STATIC_DESTRUCTOR (fn)) - static_dtors = tree_cons (NULL_TREE, fn, static_dtors); - - --function_depth; - - /* In C++, we should never be saving RTL for the function. */ - my_friendly_assert (!DECL_SAVED_INSNS (fn), 20010903); - -#if !EMIT_LLVM - /* Since we don't need the RTL for this function anymore, stop - pointing to it. That's especially important for LABEL_DECLs, - since you can reach all the instructions in the function from the - CODE_LABEL stored in the DECL_RTL for the LABEL_DECL. Walk the - BLOCK-tree, clearing DECL_RTL for LABEL_DECLs and non-static - local variables. */ - walk_tree_without_duplicates (&DECL_SAVED_TREE (fn), - clear_decl_rtl, - NULL); - - /* Clear out the RTL for the arguments. */ - for (t = DECL_ARGUMENTS (fn); t; t = TREE_CHAIN (t)) - { - SET_DECL_RTL (t, NULL_RTX); - DECL_INCOMING_RTL (t) = NULL_RTX; - } -#endif - - if (!(flag_inline_trees && DECL_INLINE (fn))) - /* DECL_INITIAL must remain nonzero so we know this was an - actual function definition. */ - DECL_INITIAL (fn) = error_mark_node; - - /* Let the error reporting routines know that we're outside a - function. For a nested function, this value is used in - pop_cp_function_context and then reset via pop_function_context. */ - current_function_decl = NULL_TREE; -} - -/* Clear out the DECL_RTL for the non-static variables in BLOCK and - its sub-blocks. */ - -#if !EMIT_LLVM -static tree -clear_decl_rtl (tree* tp, - int* walk_subtrees ATTRIBUTE_UNUSED , - void* data ATTRIBUTE_UNUSED ) +/* + * Description: + * This function is the LLVM version of cxx_expand_function_start(). + */ +void +llvm_cxx_expand_function_start (void) { - if (nonstatic_local_decl_p (*tp)) - SET_DECL_RTL (*tp, NULL_RTX); - - return NULL_TREE; + /* Give our named return value the same LLVM as our RESULT_DECL. */ + if (current_function_return_value) + COPY_DECL_LLVM (DECL_RESULT (cfun->decl), current_function_return_value); } #endif Index: gcc-3.4/gcc/cp/typeck.c diff -u gcc-3.4/gcc/cp/typeck.c:1.2 gcc-3.4/gcc/cp/typeck.c:1.3 --- gcc-3.4/gcc/cp/typeck.c:1.2 Thu Jan 8 17:05:28 2004 +++ gcc-3.4/gcc/cp/typeck.c Thu Feb 5 10:05:47 2004 @@ -902,11 +902,8 @@ if (t1 == t2) return true; - /* This should never happen. */ - my_friendly_assert (t1 != error_mark_node, 307); - /* Suppress errors caused by previously reported errors */ - if (t2 == error_mark_node) + if (t1 == error_mark_node || t2 == error_mark_node) return false; my_friendly_assert (TYPE_P (t1) && TYPE_P (t2), 20030623); @@ -1172,23 +1169,33 @@ they fail to match. */ if (!t1 || !t2) return false; - if (!same_type_p (TREE_VALUE (t2), TREE_VALUE (t1))) + if (!same_type_p (TREE_VALUE (t1), TREE_VALUE (t2))) return false; } return true; } +/* Process a sizeof or alignof expression where the operand is a + type. */ + tree -cxx_sizeof_or_alignof_type (tree type, enum tree_code op, int complain) +cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool complain) { enum tree_code type_code; tree value; const char *op_name; my_friendly_assert (op == SIZEOF_EXPR || op == ALIGNOF_EXPR, 20020720); + if (type == error_mark_node) + return error_mark_node; + if (processing_template_decl) - return build_min (op, size_type_node, type); + { + value = build_min (op, size_type_node, type); + TREE_READONLY (value) = 1; + return value; + } op_name = operator_name_info[(int) op].name; @@ -1207,30 +1214,46 @@ return value; } +/* Process a sizeof or alignof expression where the operand is an + expression. */ + tree -expr_sizeof (tree e) +cxx_sizeof_or_alignof_expr (tree e, enum tree_code op) { + const char *op_name = operator_name_info[(int) op].name; + + if (e == error_mark_node) + return error_mark_node; + if (processing_template_decl) - return build_min (SIZEOF_EXPR, size_type_node, e); - + { + e = build_min (op, size_type_node, e); + TREE_SIDE_EFFECTS (e) = 0; + TREE_READONLY (e) = 1; + + return e; + } + if (TREE_CODE (e) == COMPONENT_REF && DECL_C_BIT_FIELD (TREE_OPERAND (e, 1))) - error ("sizeof applied to a bit-field"); - if (is_overloaded_fn (e)) { - pedwarn ("ISO C++ forbids applying `sizeof' to an expression of function type"); - return c_sizeof (char_type_node); + error ("invalid application of `%s' to a bit-field", op_name); + e = char_type_node; + } + else if (is_overloaded_fn (e)) + { + pedwarn ("ISO C++ forbids applying `%s' to an expression of function type", op_name); + e = char_type_node; } else if (type_unknown_p (e)) { cxx_incomplete_type_error (e, TREE_TYPE (e)); - return c_sizeof (char_type_node); + e = char_type_node; } - - if (e == error_mark_node) - return e; - - return cxx_sizeof (TREE_TYPE (e)); + else + e = TREE_TYPE (e); + + return cxx_sizeof_or_alignof_type (e, op, true); } @@ -1912,8 +1935,8 @@ expr = build_class_member_access_expr (object, member, access_path, /*preserve_reference=*/false); if (processing_template_decl && expr != error_mark_node) - return build_min (COMPONENT_REF, TREE_TYPE (expr), orig_object, - orig_name); + return build_min_non_dep (COMPONENT_REF, expr, + orig_object, orig_name); return expr; } @@ -1970,7 +1993,7 @@ rval = build_indirect_ref (expr, errorstring); if (processing_template_decl && rval != error_mark_node) - return build_min (INDIRECT_REF, TREE_TYPE (rval), orig_expr); + return build_min_non_dep (INDIRECT_REF, rval, orig_expr); else return rval; } @@ -2515,8 +2538,12 @@ if (!COMPLETE_TYPE_P (complete_type (type))) { - error ("parameter type of called function is incomplete"); - parmval = val; + if (fndecl) + error ("parameter %P of `%D' has incomplete type `%T'", + i, fndecl, type); + else + error ("parameter %P has incomplete type `%T'", i, type); + parmval = error_mark_node; } else { @@ -2620,7 +2647,7 @@ expr = build_new_op (code, LOOKUP_NORMAL, arg1, arg2, NULL_TREE); if (processing_template_decl && expr != error_mark_node) - return build_min (code, TREE_TYPE (expr), orig_arg1, orig_arg2); + return build_min_non_dep (code, expr, orig_arg1, orig_arg2); return expr; } @@ -2817,7 +2844,6 @@ break; case BIT_AND_EXPR: - case BIT_ANDTC_EXPR: case BIT_IOR_EXPR: case BIT_XOR_EXPR: if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) @@ -3521,7 +3547,8 @@ } if (processing_template_decl && exp != error_mark_node) - return build_min (code, TREE_TYPE (exp), orig_expr, NULL_TREE); + return build_min_non_dep (code, exp, orig_expr, + /*For {PRE,POST}{INC,DEC}REMENT_EXPR*/NULL_TREE); return exp; } @@ -3564,9 +3591,7 @@ if (error_operand_p (t) || !cxx_mark_addressable (t)) return error_mark_node; - addr = build1 (ADDR_EXPR, - build_pointer_type (TREE_TYPE (t)), - t); + addr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (t)), t); if (staticp (t)) TREE_CONSTANT (addr) = 1; @@ -3977,7 +4002,7 @@ is an error. */ else if (TREE_CODE (argtype) != FUNCTION_TYPE && TREE_CODE (argtype) != METHOD_TYPE - && !non_cast_lvalue_or_else (arg, "unary `&'")) + && !lvalue_or_else (arg, "unary `&'")) return error_mark_node; if (argtype != error_mark_node) @@ -3986,12 +4011,24 @@ { tree addr; - if (TREE_CODE (arg) == COMPONENT_REF - && TREE_CODE (TREE_OPERAND (arg, 1)) == BASELINK) - arg = BASELINK_FUNCTIONS (TREE_OPERAND (arg, 1)); - if (TREE_CODE (arg) != COMPONENT_REF) addr = build_address (arg); + else if (TREE_CODE (TREE_OPERAND (arg, 1)) == BASELINK) + { + tree fn = BASELINK_FUNCTIONS (TREE_OPERAND (arg, 1)); + + /* We can only get here with a single static member + function. */ + my_friendly_assert (TREE_CODE (fn) == FUNCTION_DECL + && DECL_STATIC_FUNCTION_P (fn), + 20030906); + mark_used (fn); + addr = build_address (fn); + if (TREE_SIDE_EFFECTS (TREE_OPERAND (arg, 0))) + /* Do not lose object's side effects. */ + addr = build (COMPOUND_EXPR, TREE_TYPE (addr), + TREE_OPERAND (arg, 0), addr); + } else if (DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1))) { error ("attempt to take address of bit-field structure member `%D'", @@ -4271,8 +4308,8 @@ expr = build_conditional_expr (ifexp, op1, op2); if (processing_template_decl && expr != error_mark_node) - return build_min (COND_EXPR, TREE_TYPE (expr), - orig_ifexp, orig_op1, orig_op2); + return build_min_non_dep (COND_EXPR, expr, + orig_ifexp, orig_op1, orig_op2); return expr; } @@ -4318,8 +4355,8 @@ result = build_compound_expr (op1, op2); if (processing_template_decl && result != error_mark_node) - return build_min (COMPOUND_EXPR, TREE_TYPE (result), - orig_op1, orig_op2); + return build_min_non_dep (COMPOUND_EXPR, result, orig_op1, orig_op2); + return result; } @@ -4376,8 +4413,10 @@ if (processing_template_decl) { - tree t = build_min (STATIC_CAST_EXPR, type, expr); - return t; + expr = build_min (STATIC_CAST_EXPR, type, expr); + /* We don't know if it will or will not have side effects. */ + TREE_SIDE_EFFECTS (expr) = 1; + return expr; } /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue. @@ -4411,19 +4450,20 @@ if (TREE_CODE (type) == REFERENCE_TYPE && CLASS_TYPE_P (TREE_TYPE (type)) && CLASS_TYPE_P (intype) - && real_non_cast_lvalue_p (expr) + && real_lvalue_p (expr) && DERIVED_FROM_P (intype, TREE_TYPE (type)) && can_convert (build_pointer_type (TYPE_MAIN_VARIANT (intype)), build_pointer_type (TYPE_MAIN_VARIANT (TREE_TYPE (type)))) && at_least_as_qualified_p (TREE_TYPE (type), intype)) { - /* At this point we have checked all of the conditions except - that B is not a virtual base class of D. That will be - checked by build_base_path. */ - tree base = lookup_base (TREE_TYPE (type), intype, ba_any, NULL); + /* There is a standard conversion from "D*" to "B*" even if "B" + is ambiguous or inaccessible. Therefore, we ask lookup_base + to check these conditions. */ + tree base = lookup_base (TREE_TYPE (type), intype, ba_check, NULL); - /* Convert from B* to D*. */ + /* Convert from "B*" to "D*". This function will check that "B" + is not a virtual base of "D". */ expr = build_base_path (MINUS_EXPR, build_address (expr), base, /*nonnull=*/false); /* Convert the pointer to a reference -- but then remember that @@ -4467,9 +4507,10 @@ converted to an enumeration type. */ || (INTEGRAL_OR_ENUMERATION_TYPE_P (type) && INTEGRAL_OR_ENUMERATION_TYPE_P (intype))) - /* Really, build_c_cast should defer to this function rather - than the other way around. */ - return build_c_cast (type, expr); + /* Really, build_c_cast should defer to this function rather + than the other way around. */ + return build_c_cast (type, expr); + if (TYPE_PTR_P (type) && TYPE_PTR_P (intype) && CLASS_TYPE_P (TREE_TYPE (type)) && CLASS_TYPE_P (TREE_TYPE (intype)) @@ -4481,10 +4522,11 @@ tree base; check_for_casting_away_constness (intype, type, "static_cast"); - base = lookup_base (TREE_TYPE (type), TREE_TYPE (intype), - ba_check | ba_quiet, NULL); + base = lookup_base (TREE_TYPE (type), TREE_TYPE (intype), ba_check, + NULL); return build_base_path (MINUS_EXPR, expr, base, /*nonnull=*/false); } + if ((TYPE_PTRMEM_P (type) && TYPE_PTRMEM_P (intype)) || (TYPE_PTRMEMFUNC_P (type) && TYPE_PTRMEMFUNC_P (intype))) { @@ -4561,6 +4603,11 @@ if (processing_template_decl) { tree t = build_min (REINTERPRET_CAST_EXPR, type, expr); + + if (!TREE_SIDE_EFFECTS (t) + && type_dependent_expression_p (expr)) + /* There might turn out to be side effects inside expr. */ + TREE_SIDE_EFFECTS (t) = 1; return t; } @@ -4645,6 +4692,11 @@ if (processing_template_decl) { tree t = build_min (CONST_CAST_EXPR, type, expr); + + if (!TREE_SIDE_EFFECTS (t) + && type_dependent_expression_p (expr)) + /* There might turn out to be side effects inside expr. */ + TREE_SIDE_EFFECTS (t) = 1; return t; } @@ -4714,6 +4766,8 @@ { tree t = build_min (CAST_EXPR, type, tree_cons (NULL_TREE, value, NULL_TREE)); + /* We don't know if it will or will not have side effects. */ + TREE_SIDE_EFFECTS (t) = 1; return t; } @@ -5677,7 +5731,8 @@ if (fndecl) savew = warningcount, savee = errorcount; - rhs = initialize_reference (type, rhs, /*decl=*/NULL_TREE); + rhs = initialize_reference (type, rhs, /*decl=*/NULL_TREE, + /*cleanup=*/NULL); if (fndecl) { if (warningcount > savew) From criswell at cs.uiuc.edu Thu Feb 5 10:09:43 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:09:43 2004 Subject: [llvm-commits] CVS: gcc-3.4/libiberty/configure Message-ID: <200402051606.KAA27089@choi.cs.uiuc.edu> Changes in directory gcc-3.4/libiberty: configure updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+5966 -2068) Index: gcc-3.4/libiberty/configure diff -u gcc-3.4/libiberty/configure:1.2 gcc-3.4/libiberty/configure:1.3 --- gcc-3.4/libiberty/configure:1.2 Fri Jan 9 10:54:33 2004 +++ gcc-3.4/libiberty/configure Thu Feb 5 10:05:47 2004 @@ -1,40 +1,324 @@ #! /bin/sh - # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.13 -# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# Generated by GNU Autoconf 2.57. # +# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +# Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + -# Defaults: -ac_help= +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# ac_default_prefix=/usr/local -# Any additions from configure.in: -ac_help="$ac_help - --with-target-subdir=SUBDIR Configuring in a subdirectory for target" -ac_help="$ac_help - --with-build-subdir=SUBDIR Configuring in a subdirectory for build" -ac_help="$ac_help - --with-cross-host=HOST Configuring with a cross compiler" -ac_help="$ac_help - --with-newlib Configuring with newlib" -ac_help="$ac_help - --enable-maintainer-mode - enable make rules and dependencies not useful - (and sometimes confusing) to the casual installer" -ac_help="$ac_help - --enable-install-libiberty Install headers for end users" +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +ac_unique_file="xmalloc.c" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if STDC_HEADERS +# include +# include +#else +# if HAVE_STDLIB_H +# include +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#endif +#if HAVE_STRINGS_H +# include +#endif +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif +#if HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS libiberty_topdir MAINT NOTMAINT MAKEINFO BUILD_INFO PERL HAVE_PERL build build_cpu build_vendor build_os host host_cpu host_vendor host_os AR ac_ct_AR RANLIB ac_ct_RANLIB CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT ac_libiberty_warn_cflags NO_MINUS_C_MINUS_O OUTPUT_OPTION INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CPP EGREP LIBOBJS CHECK target_header_dir pexecute INSTALL_DEST LTLIBOBJS' +ac_subst_files='host_makefile_frag' # Initialize some variables set by options. +ac_init_help= +ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. -build=NONE -cache_file=./config.cache +cache_file=/dev/null exec_prefix=NONE -host=NONE no_create= -nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE @@ -43,10 +327,15 @@ silent= site= srcdir= -target=NONE verbose= x_includes=NONE x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' @@ -60,17 +349,9 @@ infodir='${prefix}/info' mandir='${prefix}/man' -# Initialize some other variables. -subdirs= -MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} -# Maximum number of lines to put in a shell here document. -ac_max_here_lines=12 - ac_prev= for ac_option do - # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" @@ -78,59 +359,59 @@ continue fi - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. - case "$ac_option" in + case $ac_option in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir="$ac_optarg" ;; + bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) - ac_prev=build ;; + ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build="$ac_optarg" ;; + build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) - datadir="$ac_optarg" ;; + datadir=$ac_optarg ;; -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac - eval "enable_${ac_feature}='$ac_optarg'" ;; + eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ @@ -139,95 +420,47 @@ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; + exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [same as prefix] - --bindir=DIR user executables in DIR [EPREFIX/bin] - --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] - --libexecdir=DIR program executables in DIR [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data in DIR - [PREFIX/share] - --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data in DIR - [PREFIX/com] - --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] - --libdir=DIR object code libraries in DIR [EPREFIX/lib] - --includedir=DIR C header files in DIR [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] - --infodir=DIR info documentation in DIR [PREFIX/info] - --mandir=DIR man documentation in DIR [PREFIX/man] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM - run sed PROGRAM on installed program names -EOF - cat << EOF -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR -EOF - if test -n "$ac_help"; then - echo "--enable and --with options recognized:$ac_help" - fi - exit 0 ;; + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; -host | --host | --hos | --ho) - ac_prev=host ;; + ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; + host_alias=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir="$ac_optarg" ;; + includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir="$ac_optarg" ;; + infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir="$ac_optarg" ;; + libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) - libexecdir="$ac_optarg" ;; + libexecdir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ @@ -236,19 +469,19 @@ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir="$ac_optarg" ;; + localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir="$ac_optarg" ;; + mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) + | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ @@ -262,26 +495,26 @@ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir="$ac_optarg" ;; + oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; + prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix="$ac_optarg" ;; + program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix="$ac_optarg" ;; + program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ @@ -298,7 +531,7 @@ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; + program_transform_name=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) @@ -308,7 +541,7 @@ ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) - sbindir="$ac_optarg" ;; + sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ @@ -319,58 +552,57 @@ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) - sharedstatedir="$ac_optarg" ;; + sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; + site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; + srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir="$ac_optarg" ;; + sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target ;; + ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; + target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.13" - exit 0 ;; + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac - eval "with_${ac_package}='$ac_optarg'" ;; + eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. @@ -381,99 +613,110 @@ ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; + x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; + x_libraries=$ac_optarg ;; - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } -fi - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 6 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } fi -exec 5>./config.log -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; esac done -# NLS nuisances. -# Only set these to C if already set. These must not be set unconditionally -# because not all systems understand e.g. LANG=C (notably SCO). -# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! -# Non-C LC_CTYPE values break the ctype check. -if test "${LANG+set}" = set; then LANG=C; export LANG; fi -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi -if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=xmalloc.c # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. @@ -483,13 +726,442 @@ fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } fi fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +_ACEOF + + cat <<_ACEOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-maintainer-mode + enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer + --enable-install-libiberty Install headers for end users + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-target-subdir=SUBDIR Configuring in a subdirectory for target + --with-build-subdir=SUBDIR Configuring in a subdirectory for build + --with-cross-host=HOST Configuring with a cross compiler + --with-newlib Configuring with newlib + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit 0 +fi +exec 5>config.log +cat >&5 <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.57. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_sep= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core core.* *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then @@ -500,39 +1172,103 @@ fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi else - echo "creating cache $cache_file" - > $cache_file + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } fi ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -ac_exeext= -ac_objext=o -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi at caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + + + + + + + + + + + + @@ -542,30 +1278,30 @@ # exported. We don't use libtool yet, but some day we might, so... ORIGINAL_LD_FOR_MULTILIBS=$LD + # Check whether --with-target-subdir or --without-target-subdir was given. if test "${with_target_subdir+set}" = set; then withval="$with_target_subdir" - : -fi + +fi; # Check whether --with-build-subdir or --without-build-subdir was given. if test "${with_build_subdir+set}" = set; then withval="$with_build_subdir" - : -fi + +fi; # Check whether --with-cross-host or --without-cross-host was given. if test "${with_cross_host+set}" = set; then withval="$with_cross_host" - : -fi + +fi; # Check whether --with-newlib or --without-newlib was given. if test "${with_newlib+set}" = set; then withval="$with_newlib" - : -fi +fi; if test "${srcdir}" = "."; then if test -n "${with_build_subdir}"; then @@ -594,29 +1330,35 @@ ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break fi done if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in $libiberty_topdir $srcdir/$libiberty_topdir" 1>&2; exit 1; } + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $libiberty_topdir $srcdir/$libiberty_topdir" >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $libiberty_topdir $srcdir/$libiberty_topdir" >&2;} + { (exit 1); exit 1; }; } fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. -echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:610: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo $ECHO_N "checking whether to enable maintainer-specific portions of Makefiles... $ECHO_C" >&6 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval="$enable_maintainer_mode" maintainer_mode=$enableval else maintainer_mode=no -fi - +fi; -echo "$ac_t""$maintainer_mode" 1>&6 +echo "$as_me:$LINENO: result: $maintainer_mode" >&5 +echo "${ECHO_T}$maintainer_mode" >&6 if test "$maintainer_mode" = "yes"; then MAINT='' @@ -630,31 +1372,37 @@ # rely on it - libiberty is built before texinfo. # Extract the first word of "makeinfo", so it can be a program name with args. set dummy makeinfo; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:635: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_MAKEINFO'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_MAKEINFO+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$MAKEINFO"; then ac_cv_prog_MAKEINFO="$MAKEINFO" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_MAKEINFO="makeinfo" - break - fi - done - IFS="$ac_save_ifs" +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_MAKEINFO="makeinfo" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + fi fi -MAKEINFO="$ac_cv_prog_MAKEINFO" +MAKEINFO=$ac_cv_prog_MAKEINFO if test -n "$MAKEINFO"; then - echo "$ac_t""$MAKEINFO" 1>&6 + echo "$as_me:$LINENO: result: $MAKEINFO" >&5 +echo "${ECHO_T}$MAKEINFO" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi if test "x$MAKEINFO" = "x"; then @@ -666,8 +1414,10 @@ x*\ [1-3].* ) MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true" BUILD_INFO= - echo "configure: warning: -*** Makeinfo is too old. Info documentation will not be built." 1>&2 + { echo "$as_me:$LINENO: WARNING: +*** Makeinfo is too old. Info documentation will not be built." >&5 +echo "$as_me: WARNING: +*** Makeinfo is too old. Info documentation will not be built." >&2;} ;; esac fi @@ -676,31 +1426,37 @@ # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:681: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_PERL'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_PERL+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$PERL"; then ac_cv_prog_PERL="$PERL" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_PERL="perl" - break - fi - done - IFS="$ac_save_ifs" +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_PERL="perl" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + fi fi -PERL="$ac_cv_prog_PERL" +PERL=$ac_cv_prog_PERL if test -n "$PERL"; then - echo "$ac_t""$PERL" 1>&6 + echo "$as_me:$LINENO: result: $PERL" >&5 +echo "${ECHO_T}$PERL" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi if test x"$PERL" = x""; then @@ -710,550 +1466,1486 @@ fi - # Make sure we can run config.sub. -if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : -else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } -fi - -echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:721: checking host system type" >&5 - -host_alias=$host -case "$host_alias" in -NONE) - case $nonopt in - NONE) - if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : - else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } - fi ;; - *) host_alias=$nonopt ;; - esac ;; -esac - -host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` -host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$host" 1>&6 - +$ac_config_sub sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 +echo "$as_me: error: cannot run $ac_config_sub" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6 +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_build_alias=$build_alias +test -z "$ac_cv_build_alias" && + ac_cv_build_alias=`$ac_config_guess` +test -z "$ac_cv_build_alias" && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6 +build=$ac_cv_build +build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6 +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_host_alias=$host_alias +test -z "$ac_cv_host_alias" && + ac_cv_host_alias=$ac_cv_build_alias +ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6 +host=$ac_cv_host +host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:744: checking build system type" >&5 - -build_alias=$build -case "$build_alias" in -NONE) - case $nonopt in - NONE) build_alias=$host_alias ;; - *) build_alias=$nonopt ;; - esac ;; -esac - -build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` -build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$build" 1>&6 -if test $host != $build; then - ac_tool_prefix=${host_alias}- -else - ac_tool_prefix= -fi -# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:770: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_AR="${ac_tool_prefix}ar" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="ar" +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + fi fi -AR="$ac_cv_prog_AR" +AR=$ac_cv_prog_AR if test -n "$AR"; then - echo "$ac_t""$AR" 1>&6 + echo "$as_me:$LINENO: result: $AR" >&5 +echo "${ECHO_T}$AR" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi +fi +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="ar" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 +echo "${ECHO_T}$ac_ct_AR" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + AR=$ac_ct_AR +else + AR="$ac_cv_prog_AR" +fi -# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:802: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - break - fi - done - IFS="$ac_save_ifs" +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + fi fi -RANLIB="$ac_cv_prog_RANLIB" +RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 + echo "$as_me:$LINENO: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - +fi if test -z "$ac_cv_prog_RANLIB"; then -if test -n "$ac_tool_prefix"; then + ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:834: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="ranlib" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" fi fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi + RANLIB=$ac_ct_RANLIB else - RANLIB=":" -fi + RANLIB="$ac_cv_prog_RANLIB" fi -# Extract the first word of "gcc", so it can be a program name with args. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:871: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + fi fi -CC="$ac_cv_prog_CC" +CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - echo "$ac_t""no" 1>&6 + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" fi +fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:901: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - break - fi - done - IFS="$ac_save_ifs" +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift - if test $# -gt 0; then + if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift - set dummy "$ac_dir/$ac_word" "$@" - shift - ac_cv_prog_CC="$@" + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi -CC="$ac_cv_prog_CC" +CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi - -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:950: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. else - ac_cv_prog_gcc=no -fi -fi - -echo "$ac_t""$ac_cv_prog_gcc" 1>&6 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done -if test $ac_cv_prog_gcc = yes; then - GCC=yes - ac_libiberty_warn_cflags='-W -Wall -Wtraditional -pedantic' - ac_test_CFLAGS="${CFLAGS+set}" - ac_save_CFLAGS="$CFLAGS" - CFLAGS= - echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:975: checking whether ${CC-cc} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - echo 'void f(){}' > conftest.c -if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then - ac_cv_prog_cc_g=yes -else - ac_cv_prog_cc_g=no fi -rm -f conftest* - fi - -echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 - if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" - elif test $ac_cv_prog_cc_g = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-O2" - fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - GCC= - ac_libiberty_warn_cflags= - test "${CFLAGS+set}" = set || CFLAGS="-g" + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - - -if test "x$CC" != xcc; then - echo $ac_n "checking whether $CC and cc understand -c and -o together""... $ac_c" 1>&6 -echo "configure:1007: checking whether $CC and cc understand -c and -o together" >&5 -else - echo $ac_n "checking whether cc understands -c and -o together""... $ac_c" 1>&6 -echo "configure:1010: checking whether cc understands -c and -o together" >&5 + test -n "$CC" && break + done fi -set dummy $CC; ac_cc="`echo $2 | - sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`" -if eval "test \"`echo '$''{'ac_cv_prog_cc_${ac_cc}_c_o'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - echo 'foo(){}' > conftest.c -# Make sure it works both with $CC and with simple cc. -# We do the test twice because some compilers refuse to overwrite an -# existing .o file with -o, though they will create one. -ac_try='${CC-cc} -c conftest.c -o conftest.o 1>&5' -if { (eval echo configure:1022: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } && - test -f conftest.o && { (eval echo configure:1023: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; -then - eval ac_cv_prog_cc_${ac_cc}_c_o=yes - if test "x$CC" != xcc; then - # Test first that cc exists at all. - if { ac_try='cc -c conftest.c 1>&5'; { (eval echo configure:1028: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then - ac_try='cc -c conftest.c -o conftest.o 1>&5' - if { (eval echo configure:1030: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } && - test -f conftest.o && { (eval echo configure:1031: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; - then - # cc works too. - : - else - # cc exists but doesn't like -o. - eval ac_cv_prog_cc_${ac_cc}_c_o=no - fi - fi - fi + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else - eval ac_cv_prog_cc_${ac_cc}_c_o=no -fi -rm -f conftest* +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done fi -if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then - echo "$ac_t""yes" 1>&6 +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 else - echo "$ac_t""no" 1>&6 - cat >> confdefs.h <<\EOF -#define NO_MINUS_C_MINUS_O 1 -EOF + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + CC=$ac_ct_CC fi -# autoconf is lame and doesn't give us any substitution variable for this. -if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then - NO_MINUS_C_MINUS_O=yes -else - OUTPUT_OPTION='-o $@' fi +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ -echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6 -echo "configure:1067: checking for POSIXized ISC" >&5 -if test -d /etc/conf/kconfig.d && - grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 -then - echo "$ac_t""yes" 1>&6 - ISC=yes # If later tests want to check for ISC. - cat >> confdefs.h <<\EOF -#define _POSIX_SOURCE 1 -EOF +int +main () +{ - if test "$GCC" = yes; then - CC="$CC -posix" + ; + return 0; +} +_ACEOF +# FIXME: Cleanup? +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + gcc_no_link=no +else + gcc_no_link=yes +fi + +if test x$gcc_no_link = xyes; then + # Setting cross_compile will disable run tests; it will + # also disable AC_CHECK_FILE but that's generally + # correct if we can't link. + cross_compiling=yes + EXEEXT= +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:$LINENO: checking for C compiler default output" >&5 +echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; + * ) + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no else - CC="$CC -Xp" + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi fi -else - echo "$ac_t""no" 1>&6 - ISC= fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 -echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1088: checking for working const" >&5 -if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done else - cat > conftest.$ac_ext <&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +fi +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ -int main() { +int +main () +{ -/* Ultrix mips cc rejects this. */ -typedef int charset[2]; const charset x; -/* SunOS 4.1.1 cc rejects this. */ -char const *const *ccp; -char **p; -/* NEC SVR4.0.2 mips cc rejects this. */ -struct point {int x, y;}; -static struct point const zero = {0,0}; -/* AIX XL C 1.02.0.0 rejects this. - It does not let you subtract one const X* pointer from another in an arm - of an if-expression whose if-part is not a constant expression */ -const char *g = "string"; -ccp = &g + (g ? g-g : 0); -/* HPUX 7.0 cc rejects these. */ -++ccp; -p = (char**) ccp; -ccp = (char const *const *) p; -{ /* SCO 3.2v4 cc rejects this. */ - char *t; - char const *s = 0 ? (char *) 0 : (char const *) 0; - - *t++ = 0; -} -{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ - int x[] = {25, 17}; - const int *foo = &x[0]; - ++foo; -} -{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ - typedef const int *iptr; - iptr p = 0; - ++p; -} -{ /* AIX XL C 1.02.0.0 rejects this saying - "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; -} -{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; + ; + return 0; } - -; return 0; } -EOF -if { (eval echo configure:1142: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_c_const=yes +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_c_const=no -fi -rm -f conftest* -fi + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -echo "$ac_t""$ac_cv_c_const" 1>&6 -if test $ac_cv_c_const = no; then - cat >> confdefs.h <<\EOF -#define const -EOF +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cc_g=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + ''\ + '#include ' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +if test x$GCC = xyes; then + ac_libiberty_warn_cflags='-W -Wall -Wtraditional -pedantic' +fi + + +if test "x$CC" != xcc; then + echo "$as_me:$LINENO: checking whether $CC and cc understand -c and -o together" >&5 +echo $ECHO_N "checking whether $CC and cc understand -c and -o together... $ECHO_C" >&6 +else + echo "$as_me:$LINENO: checking whether cc understands -c and -o together" >&5 +echo $ECHO_N "checking whether cc understands -c and -o together... $ECHO_C" >&6 +fi +set dummy $CC; ac_cc=`echo $2 | + sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` +if eval "test \"\${ac_cv_prog_cc_${ac_cc}_c_o+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +# Make sure it works both with $CC and with simple cc. +# We do the test twice because some compilers refuse to overwrite an +# existing .o file with -o, though they will create one. +ac_try='$CC -c conftest.$ac_ext -o conftest.$ac_objext >&5' +if { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + test -f conftest.$ac_objext && { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; +then + eval ac_cv_prog_cc_${ac_cc}_c_o=yes + if test "x$CC" != xcc; then + # Test first that cc exists at all. + if { ac_try='cc -c conftest.$ac_ext >&5' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_try='cc -c conftest.$ac_ext -o conftest.$ac_objext >&5' + if { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + test -f conftest.$ac_objext && { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; + then + # cc works too. + : + else + # cc exists but doesn't like -o. + eval ac_cv_prog_cc_${ac_cc}_c_o=no + fi + fi + fi +else + eval ac_cv_prog_cc_${ac_cc}_c_o=no +fi +rm -f conftest* + +fi +if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + +cat >>confdefs.h <<\_ACEOF +#define NO_MINUS_C_MINUS_O 1 +_ACEOF fi -echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:1163: checking for inline" >&5 -if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +# autoconf is lame and doesn't give us any substitution variable for this. +if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then + NO_MINUS_C_MINUS_O=yes +else + OUTPUT_OPTION='-o $@' +fi + + + + +echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 +if test "${ac_cv_c_const+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset x; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *ccp; + char **p; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + ccp = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++ccp; + p = (char**) ccp; + ccp = (char const *const *) p; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + } +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_const=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_c_const=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +echo "${ECHO_T}$ac_cv_c_const" >&6 +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for inline" >&5 +echo $ECHO_N "checking for inline... $ECHO_C" >&6 +if test "${ac_cv_c_inline+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do - cat > conftest.$ac_ext <conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw foo_t foo () {return 0; } +#endif -int main() { -} $ac_kw foo() { -; return 0; } -EOF -if { (eval echo configure:1177: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_c_inline=$ac_kw; break else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext done fi - -echo "$ac_t""$ac_cv_c_inline" 1>&6 -case "$ac_cv_c_inline" in +echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 +echo "${ECHO_T}$ac_cv_c_inline" >&6 +case $ac_cv_c_inline in inline | yes) ;; - no) cat >> confdefs.h <<\EOF -#define inline -EOF + no) +cat >>confdefs.h <<\_ACEOF +#define inline +_ACEOF ;; - *) cat >> confdefs.h <>confdefs.h <<_ACEOF #define inline $ac_cv_c_inline -EOF +_ACEOF ;; esac -echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6 -echo "configure:1203: checking whether byte ordering is bigendian" >&5 -if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 +if test "${ac_cv_c_bigendian+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_c_bigendian=unknown # See if sys/param.h defines the BYTE_ORDER macro. -cat > conftest.$ac_ext <conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include #include -int main() { +int +main () +{ #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN bogus endian macros #endif -; return 0; } -EOF -if { (eval echo configure:1221: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then # It does; now see whether it defined to BIG_ENDIAN or not. -cat > conftest.$ac_ext <conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include #include -int main() { +int +main () +{ #if BYTE_ORDER != BIG_ENDIAN not big endian #endif -; return 0; } -EOF -if { (eval echo configure:1236: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_c_bigendian=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_c_bigendian=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_c_bigendian=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then if test "$cross_compiling" = yes; then - echo $ac_n "cross-compiling... " 2>&6 + echo $ac_n "cross-compiling... " 2>&6 else - cat > conftest.$ac_ext <conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ main () { /* Are we little or big endian? From Harbison&Steele. */ union @@ -1264,26 +2956,36 @@ u.l = 1; exit (u.c[sizeof (long) - 1] == 1); } -EOF -if { (eval echo configure:1269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_c_bigendian=no else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_c_bigendian=yes + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_c_bigendian=yes fi -rm -fr conftest* +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - fi fi - -echo "$ac_t""$ac_cv_c_bigendian" 1>&6 +echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6 if test $ac_cv_c_bigendian = unknown; then -echo $ac_n "checking to probe for byte ordering""... $ac_c" 1>&6 -echo "configure:1287: checking to probe for byte ordering" >&5 +echo "$as_me:$LINENO: checking to probe for byte ordering" >&5 +echo $ECHO_N "checking to probe for byte ordering... $ECHO_C" >&6 cat >conftest.c <&6 fi fi -echo "$ac_t""$ac_cv_c_bigendian" 1>&6 +echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6 fi if test $ac_cv_c_bigendian = yes; then - cat >> confdefs.h <<\EOF + +cat >>confdefs.h <<\_ACEOF #define WORDS_BIGENDIAN 1 -EOF +_ACEOF + - cat >> confdefs.h <<\EOF +cat >>confdefs.h <<\_ACEOF #define HOST_WORDS_BIG_ENDIAN 1 -EOF +_ACEOF BYTEORDER=4321 else BYTEORDER=1234 fi -cat >> confdefs.h <>confdefs.h <<_ACEOF #define BYTEORDER $BYTEORDER -EOF +_ACEOF if test $ac_cv_c_bigendian = unknown; then - { echo "configure: error: unknown endianess - sorry" 1>&2; exit 1; } + { { echo "$as_me:$LINENO: error: unknown endianess - sorry" >&5 +echo "$as_me: error: unknown endianess - sorry" >&2;} + { (exit please pre-set ac_cv_c_bigendian); exit please pre-set ac_cv_c_bigendian; }; } fi + ac_config_headers="$ac_config_headers config.h:config.in" @@ -1347,60 +3056,73 @@ # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1356: checking for a BSD compatible install" >&5 +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" - for ac_dir in $PATH; do - # Account for people who put trailing slashes in PATH elements. - case "$ac_dir/" in - /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - if test -f $ac_dir/$ac_prog; then - if test $ac_prog = install && - grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - else - ac_cv_path_install="$ac_dir/$ac_prog -c" - break 2 - fi - fi + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi done - ;; - esac - done - IFS="$ac_save_IFS" + done + ;; +esac +done + fi if test "${ac_cv_path_install+set}" = set; then - INSTALL="$ac_cv_path_install" + INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. - INSTALL="$ac_install_sh" + INSTALL=$ac_install_sh fi fi -echo "$ac_t""$INSTALL" 1>&6 +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' @@ -1412,278 +3134,318 @@ # It's OK to check for header files. Although the compiler may not be # able to link anything, it had better be able to at least compile # something. -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1417: checking how to run the C preprocessor" >&5 +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1438: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1455: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -nologo -E" - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1472: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP=/lib/cpp -fi -rm -f conftest* -fi -rm -f conftest* + ac_cpp_err=yes fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" -fi - CPP="$ac_cv_prog_CPP" +if test -z "$ac_cpp_err"; then + : else - ac_cv_prog_CPP="$CPP" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue fi -echo "$ac_t""$CPP" 1>&6 +rm -f conftest.err conftest.$ac_ext -for ac_hdr in sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1500: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1510: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* + ac_cpp_err=yes fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <&6 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break fi +rm -f conftest.err conftest.$ac_ext + done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP -echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:1537: checking for sys/wait.h that is POSIX.1 compatible" >&5 -if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +fi + CPP=$ac_cv_prog_CPP else - cat > conftest.$ac_ext < -#include -#ifndef WEXITSTATUS -#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) -#endif -#ifndef WIFEXITED -#define WIFEXITED(stat_val) (((stat_val) & 255) == 0) + ac_cv_prog_CPP=$CPP +fi +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include #endif -int main() { -int s; -wait (&s); -s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; -; return 0; } -EOF -if { (eval echo configure:1558: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_header_sys_wait_h=yes + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_header_sys_wait_h=no -fi -rm -f conftest* + ac_cpp_err=yes fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -echo "$ac_t""$ac_cv_header_sys_wait_h" 1>&6 -if test $ac_cv_header_sys_wait_h = yes; then - cat >> confdefs.h <<\EOF -#define HAVE_SYS_WAIT_H 1 -EOF - + # Broken: fails on valid input. +continue fi +rm -f conftest.err conftest.$ac_ext -echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:1579: checking whether time.h and sys/time.h may both be included" >&5 -if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -#include -#include -int main() { -struct tm *tp; -; return 0; } -EOF -if { (eval echo configure:1593: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_header_time=yes + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_header_time=no -fi -rm -f conftest* + ac_cpp_err=yes fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -echo "$ac_t""$ac_cv_header_time" 1>&6 -if test $ac_cv_header_time = yes; then - cat >> confdefs.h <<\EOF -#define TIME_WITH_SYS_TIME 1 -EOF - + # Passes both tests. +ac_preproc_ok=: +break fi +rm -f conftest.err conftest.$ac_ext - -echo $ac_n "checking whether errno must be declared""... $ac_c" 1>&6 -echo "configure:1615: checking whether errno must be declared" >&5 -if eval "test \"`echo '$''{'libiberty_cv_declare_errno'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -int main() { -int x = errno; -; return 0; } -EOF -if { (eval echo configure:1627: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - libiberty_cv_declare_errno=no +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - libiberty_cv_declare_errno=yes -fi -rm -f conftest* + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } fi -echo "$ac_t""$libiberty_cv_declare_errno" 1>&6 -if test $libiberty_cv_declare_errno = yes -then cat >> confdefs.h <<\EOF -#define NEED_DECLARATION_ERRNO 1 -EOF - -fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu -echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1649: checking for ANSI C header files" >&5 -if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6 +if test "${ac_cv_prog_egrep+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 +echo "${ECHO_T}$ac_cv_prog_egrep" >&6 + EGREP=$ac_cv_prog_egrep + + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include #include #include #include -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1662: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_header_stdc=yes else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_header_stdc=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. -cat > conftest.$ac_ext <conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include -EOF + +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "memchr" >/dev/null 2>&1; then + $EGREP "memchr" >/dev/null 2>&1; then : else - rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* @@ -1692,16 +3454,20 @@ if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. -cat > conftest.$ac_ext <conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include -EOF + +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "free" >/dev/null 2>&1; then + $EGREP "free" >/dev/null 2>&1; then : else - rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* @@ -1710,115 +3476,592 @@ if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -if test "$cross_compiling" = yes; then + if test "$cross_compiling" = yes; then : else - cat > conftest.$ac_ext <conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif -EOF -if { (eval echo configure:1729: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then : else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_header_stdc=no + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_Header=no" +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + + + + + + + + + + + + + + + + + + + +for ac_header in sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf at gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf at gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +echo "$as_me:$LINENO: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo $ECHO_N "checking for sys/wait.h that is POSIX.1 compatible... $ECHO_C" >&6 +if test "${ac_cv_header_sys_wait_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#ifndef WEXITSTATUS +# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) +#endif +#ifndef WIFEXITED +# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) +#endif + +int +main () +{ + int s; + wait (&s); + s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_sys_wait_h=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_sys_wait_h=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_header_sys_wait_h" >&5 +echo "${ECHO_T}$ac_cv_header_sys_wait_h" >&6 +if test $ac_cv_header_sys_wait_h = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_SYS_WAIT_H 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 +echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 +if test "${ac_cv_header_time+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_time=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_time=no fi -rm -fr conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 +echo "${ECHO_T}$ac_cv_header_time" >&6 +if test $ac_cv_header_time = yes; then + +cat >>confdefs.h <<\_ACEOF +#define TIME_WITH_SYS_TIME 1 +_ACEOF -fi fi -echo "$ac_t""$ac_cv_header_stdc" 1>&6 -if test $ac_cv_header_stdc = yes; then - cat >> confdefs.h <<\EOF -#define STDC_HEADERS 1 -EOF + +echo "$as_me:$LINENO: checking whether errno must be declared" >&5 +echo $ECHO_N "checking whether errno must be declared... $ECHO_C" >&6 +if test "${libiberty_cv_declare_errno+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +int x = errno; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + libiberty_cv_declare_errno=no +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +libiberty_cv_declare_errno=yes +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $libiberty_cv_declare_errno" >&5 +echo "${ECHO_T}$libiberty_cv_declare_errno" >&6 +if test $libiberty_cv_declare_errno = yes +then +cat >>confdefs.h <<\_ACEOF +#define NEED_DECLARATION_ERRNO 1 +_ACEOF fi -echo $ac_n "checking for uintptr_t""... $ac_c" 1>&6 -echo "configure:1753: checking for uintptr_t" >&5 -if eval "test \"`echo '$''{'ac_cv_type_uintptr_t'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + +echo "$as_me:$LINENO: checking for uintptr_t" >&5 +echo $ECHO_N "checking for uintptr_t... $ECHO_C" >&6 +if test "${ac_cv_type_uintptr_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext < -#if STDC_HEADERS -#include -#include -#endif -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "(^|[^a-zA-Z_0-9])uintptr_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then - rm -rf conftest* + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((uintptr_t *) 0) + return 0; +if (sizeof (uintptr_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_type_uintptr_t=yes else - rm -rf conftest* - ac_cv_type_uintptr_t=no -fi -rm -f conftest* + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +ac_cv_type_uintptr_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$ac_t""$ac_cv_type_uintptr_t" 1>&6 -if test $ac_cv_type_uintptr_t = no; then - cat >> confdefs.h <<\EOF +echo "$as_me:$LINENO: result: $ac_cv_type_uintptr_t" >&5 +echo "${ECHO_T}$ac_cv_type_uintptr_t" >&6 +if test $ac_cv_type_uintptr_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF #define uintptr_t unsigned long -EOF +_ACEOF fi # Given the above check, we always have uintptr_t or a fallback # definition. So define HAVE_UINTPTR_T in case any imported code # relies on it. -cat >> confdefs.h <<\EOF + +cat >>confdefs.h <<\_ACEOF #define HAVE_UINTPTR_T 1 -EOF +_ACEOF -echo $ac_n "checking for pid_t""... $ac_c" 1>&6 -echo "configure:1794: checking for pid_t" >&5 -if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -#if STDC_HEADERS -#include -#include -#endif -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "(^|[^a-zA-Z_0-9])pid_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then - rm -rf conftest* +echo "$as_me:$LINENO: checking for pid_t" >&5 +echo $ECHO_N "checking for pid_t... $ECHO_C" >&6 +if test "${ac_cv_type_pid_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((pid_t *) 0) + return 0; +if (sizeof (pid_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_type_pid_t=yes else - rm -rf conftest* - ac_cv_type_pid_t=no -fi -rm -f conftest* + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +ac_cv_type_pid_t=no fi -echo "$ac_t""$ac_cv_type_pid_t" 1>&6 -if test $ac_cv_type_pid_t = no; then - cat >> confdefs.h <<\EOF +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5 +echo "${ECHO_T}$ac_cv_type_pid_t" >&6 +if test $ac_cv_type_pid_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF #define pid_t int -EOF +_ACEOF fi @@ -1884,7 +4127,70 @@ # These are neither executed nor required, but they help keep # autoheader happy without adding a bunch of text to acconfig.h. if test "x" = "y"; then - for ac_func in asprintf atexit basename bcmp bcopy bsearch bzero calloc clock \ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +for ac_func in asprintf atexit basename bcmp bcopy bsearch bzero calloc clock \ getcwd getpagesize index insque mkstemps memchr memcmp memcpy \ memmove mempcpy memset putenv random rename rindex sigsetmask \ strcasecmp setenv stpcpy stpncpy strchr strdup strncasecmp strrchr strstr \ @@ -1894,70 +4200,108 @@ pstat_getstatic pstat_getdynamic sysmp getsysinfo table sysctl \ realpath canonicalize_file_name do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1899: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. Under hpux, + including includes and causes problems + checking for functions defined therein. */ +#if defined (__STDC__) && !defined (_HPUX_SOURCE) +# include +#else +# include +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:1927: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 fi done - cat >> confdefs.h <<\EOF + +cat >>confdefs.h <<\_ACEOF #define HAVE_SYS_ERRLIST 1 -EOF +_ACEOF - cat >> confdefs.h <<\EOF + +cat >>confdefs.h <<\_ACEOF #define HAVE_SYS_NERR 1 -EOF +_ACEOF - cat >> confdefs.h <<\EOF + +cat >>confdefs.h <<\_ACEOF #define HAVE_SYS_SIGLIST 1 -EOF +_ACEOF fi @@ -1979,7 +4323,12 @@ # newlib provide and which ones we will be expected to provide. if test "x${with_newlib}" = "xyes"; then - LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o" + LIBOBJS="$LIBOBJS asprintf.$ac_objext" + LIBOBJS="$LIBOBJS basename.$ac_objext" + LIBOBJS="$LIBOBJS insque.$ac_objext" + LIBOBJS="$LIBOBJS random.$ac_objext" + LIBOBJS="$LIBOBJS strdup.$ac_objext" + LIBOBJS="$LIBOBJS vasprintf.$ac_objext" for f in $funcs; do case "$f" in @@ -1987,9 +4336,9 @@ ;; *) n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <>confdefs.h <<_ACEOF #define $n 1 -EOF +_ACEOF ;; esac @@ -2015,17 +4364,16 @@ enable_install_libiberty=$enableval else enable_install_libiberty=no -fi - +fi; # Option parsed, now set things appropriately. case x"$enable_install_libiberty" in xyes|x) target_header_dir=libiberty ;; - xno) + xno) target_header_dir= ;; - *) + *) # This could be sanity-checked in various ways... target_header_dir="${enable_install_libiberty}" ;; @@ -2062,8 +4410,16 @@ # Handle VxWorks configuration specially, since on VxWorks the # libraries are actually on the target board, not in the file # system. - LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o" - LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o" + LIBOBJS="$LIBOBJS basename.$ac_objext" + LIBOBJS="$LIBOBJS getpagesize.$ac_objext" + LIBOBJS="$LIBOBJS insque.$ac_objext" + LIBOBJS="$LIBOBJS random.$ac_objext" + LIBOBJS="$LIBOBJS strcasecmp.$ac_objext" + LIBOBJS="$LIBOBJS strncasecmp.$ac_objext" + LIBOBJS="$LIBOBJS strdup.$ac_objext" + LIBOBJS="$LIBOBJS vfork.$ac_objext" + LIBOBJS="$LIBOBJS waitpid.$ac_objext" + LIBOBJS="$LIBOBJS vasprintf.$ac_objext" for f in $funcs; do case "$f" in basename | getpagesize | insque | random | strcasecmp) @@ -2072,9 +4428,9 @@ ;; *) n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <>confdefs.h <<_ACEOF #define $n 1 -EOF +_ACEOF ;; esac @@ -2112,11 +4468,11 @@ # missing. # DJ - only if we're *building* cygwin, not just building *with* cygwin - + if test -n "${with_target_subdir}" then funcs="`echo $funcs | sed -e 's/random//'`" - LIBOBJS="$LIBOBJS random.o" + LIBOBJS="$LIBOBJS random.$ac_objext" vars="`echo $vars | sed -e 's/sys_siglist//'`" checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`" fi @@ -2130,19 +4486,19 @@ ;; *-*-uwin*) - # Under some versions of uwin, vfork is notoriously buggy and the test + # Under some versions of uwin, vfork is notoriously buggy and the test # can hang configure; on other versions, vfork exists just as a stub. # FIXME: This should be removed once vfork in uwin's runtime is fixed. ac_cv_func_vfork_works=no # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are - # macros (actually, these are imported from a DLL, but the end effect + # macros (actually, these are imported from a DLL, but the end effect # is the same), so the test below won't find them. libiberty_cv_var_sys_nerr=yes libiberty_cv_var_sys_errlist=yes ;; *-*-*vms*) - # Under VMS, vfork works very different than on Unix. The standard test + # Under VMS, vfork works very different than on Unix. The standard test # won't work, and it isn't easily adaptable. It makes more sense to # just force it. ac_cv_func_vfork_works=yes @@ -2152,205 +4508,354 @@ # We haven't set the list of objects yet. Use the standard autoconf # tests. This will only work if the compiler works. - echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:2157: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + echo "$as_me:$LINENO: checking for library containing strerror" >&5 +echo $ECHO_N "checking for library containing strerror... $ECHO_C" >&6 +if test "${ac_cv_search_strerror+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_strerror=no +if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char strerror (); +int +main () +{ +strerror (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_strerror="none required" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_strerror" = no; then + for ac_lib in cposix; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ -cat > conftest.$ac_ext << EOF +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char strerror (); +int +main () +{ +strerror (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_strerror="-l$ac_lib" +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -#line 2168 "configure" -#include "confdefs.h" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + done +fi +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_strerror" >&5 +echo "${ECHO_T}$ac_cv_search_strerror" >&6 +if test "$ac_cv_search_strerror" != no; then + test "$ac_cv_search_strerror" = "none required" || LIBS="$ac_cv_search_strerror $LIBS" -main(){return(0);} -EOF -if { (eval echo configure:2173: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - ac_cv_prog_cc_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cc_cross=no - else - ac_cv_prog_cc_cross=yes - fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cc_works=no fi -rm -fr conftest* -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 -if test $ac_cv_prog_cc_works = no; then - { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:2199: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 -cross_compiling=$ac_cv_prog_cc_cross - - for ac_func in $funcs -do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2206: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. Under hpux, + including includes and causes problems + checking for functions defined therein. */ +#if defined (__STDC__) && !defined (_HPUX_SOURCE) +# include +#else +# include +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:2234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 -LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" + LIBOBJS="$LIBOBJS $ac_func.$ac_objext" fi done - echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:2261: checking whether alloca needs Cray hooks" >&5 -if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5 +echo $ECHO_N "checking whether alloca needs Cray hooks... $ECHO_C" >&6 +if test "${ac_cv_os_cray+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #if defined(CRAY) && ! defined(CRAY2) webecray #else wenotbecray #endif -EOF +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "webecray" >/dev/null 2>&1; then - rm -rf conftest* + $EGREP "webecray" >/dev/null 2>&1; then ac_cv_os_cray=yes else - rm -rf conftest* ac_cv_os_cray=no fi rm -f conftest* fi - -echo "$ac_t""$ac_cv_os_cray" 1>&6 +echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5 +echo "${ECHO_T}$ac_cv_os_cray" >&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do - echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2291: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. Under hpux, + including includes and causes problems + checking for functions defined therein. */ +#if defined (__STDC__) && !defined (_HPUX_SOURCE) +# include +#else +# include +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:2319: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <>confdefs.h <<_ACEOF #define CRAY_STACKSEG_END $ac_func -EOF +_ACEOF break -else - echo "$ac_t""no" 1>&6 fi done fi -echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:2345: checking stack direction for C alloca" >&5 -if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking stack direction for C alloca" >&5 +echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6 +if test "${ac_cv_c_stack_direction+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_c_stack_direction=0 else - cat > conftest.$ac_ext <conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ find_stack_direction () { static char *addr = 0; @@ -2367,142 +4872,377 @@ { exit (find_stack_direction() < 0); } -EOF -if { (eval echo configure:2372: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_c_stack_direction=1 else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_c_stack_direction=-1 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_c_stack_direction=-1 +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5 +echo "${ECHO_T}$ac_cv_c_stack_direction" >&6 + +cat >>confdefs.h <<_ACEOF +#define STACK_DIRECTION $ac_cv_c_stack_direction +_ACEOF + + + + +for ac_header in unistd.h vfork.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes fi -rm -fr conftest* +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf at gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf at gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF -echo "$ac_t""$ac_cv_c_stack_direction" 1>&6 -cat >> confdefs.h <&6 -echo "configure:2394: checking for vfork.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2404: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF -#define HAVE_VFORK_H 1 -EOF -else - echo "$ac_t""no" 1>&6 -fi -echo $ac_n "checking for working vfork""... $ac_c" 1>&6 -echo "configure:2429: checking for working vfork" >&5 -if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test "$cross_compiling" = yes; then - echo $ac_n "checking for vfork""... $ac_c" 1>&6 -echo "configure:2435: checking for vfork" >&5 -if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char vfork(); below. */ -#include + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. Under hpux, + including includes and causes problems + checking for functions defined therein. */ +#if defined (__STDC__) && !defined (_HPUX_SOURCE) +# include +#else +# include +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char vfork(); - -int main() { - + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_vfork) || defined (__stub___vfork) +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -vfork(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:2463: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_vfork=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_vfork=no" -fi -rm -f conftest* +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + fi +done -if eval "test \"`echo '$ac_cv_func_'vfork`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : +if test "x$ac_cv_func_fork" = xyes; then + echo "$as_me:$LINENO: checking for working fork" >&5 +echo $ECHO_N "checking for working fork... $ECHO_C" >&6 +if test "${ac_cv_func_fork_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_fork_works=cross else - echo "$ac_t""no" 1>&6 + cat >conftest.$ac_ext <<_ACEOF +/* By Ruediger Kuhlmann. */ + #include + #if HAVE_UNISTD_H + # include + #endif + /* Some systems only have a dummy stub for fork() */ + int main () + { + if (fork() < 0) + exit (1); + exit (0); + } +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_fork_works=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_fork_works=no +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_func_fork_works" >&5 +echo "${ECHO_T}$ac_cv_func_fork_works" >&6 + +else + ac_cv_func_fork_works=$ac_cv_func_fork +fi +if test "x$ac_cv_func_fork_works" = xcross; then + case $host in + *-*-amigaos* | *-*-msdosdjgpp*) + # Override, as these systems have only a dummy fork() stub + ac_cv_func_fork_works=no + ;; + *) + ac_cv_func_fork_works=yes + ;; + esac + { echo "$as_me:$LINENO: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5 +echo "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;} fi - ac_cv_func_vfork_works=$ac_cv_func_vfork +if test "x$ac_cv_func_vfork" = xyes; then + echo "$as_me:$LINENO: checking for working vfork" >&5 +echo $ECHO_N "checking for working vfork... $ECHO_C" >&6 +if test "${ac_cv_func_vfork_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* Thanks to Paul Eggert for this test. */ #include +#include #include #include -#ifdef HAVE_UNISTD_H -#include +#include +#if HAVE_UNISTD_H +# include #endif -#ifdef HAVE_VFORK_H -#include +#if HAVE_VFORK_H +# include #endif /* On some sparc systems, changes by the child to local and incoming - argument registers are propagated back to the parent. - The compiler is told about this with #include , - but some compilers (e.g. gcc -O) don't grok . - Test for this by using a static variable whose address - is put into a register that is clobbered by the vfork. */ -static + argument registers are propagated back to the parent. The compiler + is told about this with #include , but some compilers + (e.g. gcc -O) don't grok . Test for this by using a + static variable whose address is put into a register that is + clobbered by the vfork. */ +static void #ifdef __cplusplus sparc_address_test (int arg) -#else +# else sparc_address_test (arg) int arg; #endif { @@ -2520,25 +5260,27 @@ } } } -main() { + +int +main () +{ pid_t parent = getpid (); pid_t child; - sparc_address_test (); + sparc_address_test (0); child = vfork (); if (child == 0) { - /* Here is another test for sparc vfork register problems. - This test uses lots of local variables, at least - as many local variables as main has allocated so far - including compiler temporaries. 4 locals are enough for - gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe. - A buggy compiler should reuse the register of parent - for one of the local variables, since it will think that - parent can't possibly be used any more in this routine. - Assigning to the local variable will thus munge parent - in the parent process. */ + /* Here is another test for sparc vfork register problems. This + test uses lots of local variables, at least as many local + variables as main has allocated so far including compiler + temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris + 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should + reuse the register of parent for one of the local variables, + since it will think that parent can't possibly be used any more + in this routine. Assigning to the local variable will thus + munge parent in the parent process. */ pid_t p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); @@ -2548,11 +5290,10 @@ || p != p5 || p != p6 || p != p7) _exit(1); - /* On some systems (e.g. IRIX 3.3), - vfork doesn't separate parent from child file descriptors. - If the child closes a descriptor before it execs or exits, - this munges the parent's descriptor as well. - Test for this by closing stdout in the child. */ + /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent + from child file descriptors. If the child closes a descriptor + before it execs or exits, this munges the parent's descriptor + as well. Test for this by closing stdout in the child. */ _exit(close(fileno(stdout)) != 0); } else { int status; @@ -2575,279 +5316,470 @@ ); } } -EOF -if { (eval echo configure:2580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_func_vfork_works=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_func_vfork_works=no + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_vfork_works=no +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi -rm -fr conftest* fi +echo "$as_me:$LINENO: result: $ac_cv_func_vfork_works" >&5 +echo "${ECHO_T}$ac_cv_func_vfork_works" >&6 +fi; +if test "x$ac_cv_func_fork_works" = xcross; then + ac_cv_func_vfork_works=ac_cv_func_vfork + { echo "$as_me:$LINENO: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5 +echo "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;} fi -echo "$ac_t""$ac_cv_func_vfork_works" 1>&6 -if test $ac_cv_func_vfork_works = no; then - cat >> confdefs.h <<\EOF +if test "x$ac_cv_func_vfork_works" = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_WORKING_VFORK 1 +_ACEOF + +else + +cat >>confdefs.h <<\_ACEOF #define vfork fork -EOF +_ACEOF + +fi +if test "x$ac_cv_func_fork_works" = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_WORKING_FORK 1 +_ACEOF fi if test $ac_cv_func_vfork_works = no; then - LIBOBJS="$LIBOBJS vfork.o" + LIBOBJS="$LIBOBJS vfork.$ac_objext" fi # We only need _doprnt if we might use it to implement v*printf. if test $ac_cv_func_vprintf != yes \ || test $ac_cv_func_vfprintf != yes \ || test $ac_cv_func_vsprintf != yes; then - for ac_func in _doprnt + +for ac_func in _doprnt do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2612: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. Under hpux, + including includes and causes problems + checking for functions defined therein. */ +#if defined (__STDC__) && !defined (_HPUX_SOURCE) +# include +#else +# include +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:2640: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 -LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" + LIBOBJS="$LIBOBJS $ac_func.$ac_objext" fi done else - for ac_func in _doprnt + +for ac_func in _doprnt do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2670: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. Under hpux, + including includes and causes problems + checking for functions defined therein. */ +#if defined (__STDC__) && !defined (_HPUX_SOURCE) +# include +#else +# include +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:2698: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 fi done fi for v in $vars; do - echo $ac_n "checking for $v""... $ac_c" 1>&6 -echo "configure:2726: checking for $v" >&5 - if eval "test \"`echo '$''{'libiberty_cv_var_$v'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5 +echo $ECHO_N "checking for $v... $ECHO_C" >&6 + if eval "test \"\${libiberty_cv_var_$v+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ int *p; -int main() { +int +main () +{ extern int $v []; p = $v; -; return 0; } -EOF -if { (eval echo configure:2738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then eval "libiberty_cv_var_$v=yes" else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "libiberty_cv_var_$v=no" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "libiberty_cv_var_$v=no" fi -rm -f conftest* +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then - echo "$ac_t""yes" 1>&6 + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <>confdefs.h <<_ACEOF #define $n 1 -EOF +_ACEOF else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi done # special check for _system_configuration because AIX <4.3.2 do not # contain the `physmem' member. - echo $ac_n "checking for external symbol _system_configuration""... $ac_c" 1>&6 -echo "configure:2765: checking for external symbol _system_configuration" >&5 - cat > conftest.$ac_ext <&5 +echo $ECHO_N "checking for external symbol _system_configuration... $ECHO_C" >&6 + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include -int main() { +int +main () +{ double x = _system_configuration.physmem; -; return 0; } -EOF -if { (eval echo configure:2774: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +cat >>confdefs.h <<\_ACEOF #define HAVE__SYSTEM_CONFIGURATION 1 -EOF +_ACEOF else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - echo "$ac_t""no" 1>&6 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext - for ac_func in $checkfuncs + +for ac_func in $checkfuncs do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2792: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. Under hpux, + including includes and causes problems + checking for functions defined therein. */ +#if defined (__STDC__) && !defined (_HPUX_SOURCE) +# include +#else +# include +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:2820: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 fi done - echo $ac_n "checking whether canonicalize_file_name must be declared""... $ac_c" 1>&6 -echo "configure:2845: checking whether canonicalize_file_name must be declared" >&5 -if eval "test \"`echo '$''{'libiberty_cv_decl_needed_canonicalize_file_name'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5 +echo $ECHO_N "checking whether canonicalize_file_name must be declared... $ECHO_C" >&6 +if test "${libiberty_cv_decl_needed_canonicalize_file_name+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include "confdefs.h" #include @@ -2864,27 +5796,43 @@ #ifdef HAVE_UNISTD_H #include #endif -int main() { +int +main () +{ char *(*pfn) = (char *(*)) canonicalize_file_name -; return 0; } -EOF -if { (eval echo configure:2872: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then libiberty_cv_decl_needed_canonicalize_file_name=no else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - libiberty_cv_decl_needed_canonicalize_file_name=yes + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +libiberty_cv_decl_needed_canonicalize_file_name=yes fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$ac_t""$libiberty_cv_decl_needed_canonicalize_file_name" 1>&6 +echo "$as_me:$LINENO: result: $libiberty_cv_decl_needed_canonicalize_file_name" >&5 +echo "${ECHO_T}$libiberty_cv_decl_needed_canonicalize_file_name" >&6 if test $libiberty_cv_decl_needed_canonicalize_file_name = yes; then - cat >> confdefs.h <<\EOF + +cat >>confdefs.h <<\_ACEOF #define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 -EOF +_ACEOF fi @@ -2900,112 +5848,264 @@ esac -for ac_hdr in stdlib.h unistd.h sys/stat.h sys/types.h +if test x$gcc_no_link = xyes; then + if test "x${ac_cv_func_mmap_fixed_mapped+set}" != xset; then + ac_cv_func_mmap_fixed_mapped=no + fi +fi +if test "x${ac_cv_func_mmap_fixed_mapped+set}" != xset; then + + +for ac_header in stdlib.h unistd.h do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2908: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2918: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* + ac_cpp_err=yes fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf at gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf at gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - echo "$ac_t""no" 1>&6 + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + done + for ac_func in getpagesize do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2947: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ -#include + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. Under hpux, + including includes and causes problems + checking for functions defined therein. */ +#if defined (__STDC__) && !defined (_HPUX_SOURCE) +# include +#else +# include +#endif /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { - + builtin and then its argument prototype would still apply. */ +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:2975: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" -fi -rm -f conftest* -fi +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <&6 fi done -echo $ac_n "checking for working mmap""... $ac_c" 1>&6 -echo "configure:3000: checking for working mmap" >&5 -if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for working mmap" >&5 +echo $ECHO_N "checking for working mmap... $ECHO_C" >&6 +if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_mmap_fixed_mapped=no else - cat > conftest.$ac_ext <conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +/* malloc might have been renamed as rpl_malloc. */ +#undef malloc /* Thanks to Mike Haertel and Jim Avera for this test. Here is a matrix of mmap possibilities: @@ -3019,47 +6119,34 @@ back from the file, nor mmap's back from the file at a different address. (There have been systems where private was not correctly implemented like the infamous i386 svr4.0, and systems where the - VM page cache was not coherent with the filesystem buffer cache + VM page cache was not coherent with the file system buffer cache like early versions of FreeBSD and possibly contemporary NetBSD.) For shared mappings, we should conversely verify that changes get - propogated back to all the places they're supposed to be. + propagated back to all the places they're supposed to be. Grep wants private fixed already mapped. The main things grep needs to know about mmap are: * does it exist and is it safe to write into the mmap'd area * how to use it (BSD variants) */ -#include + #include #include -#if HAVE_SYS_TYPES_H -# include -#endif - -#if HAVE_STDLIB_H -# include -#endif - -#if HAVE_SYS_STAT_H -# include -#endif - -#if HAVE_UNISTD_H -# include +#if !STDC_HEADERS && !HAVE_STDLIB_H +char *malloc (); #endif /* This mess was copied from the GNU getpagesize.h. */ -#ifndef HAVE_GETPAGESIZE - +#if !HAVE_GETPAGESIZE /* Assume that all systems that can run configure have sys/param.h. */ -# ifndef HAVE_SYS_PARAM_H +# if !HAVE_SYS_PARAM_H # define HAVE_SYS_PARAM_H 1 # endif # ifdef _SC_PAGESIZE # define getpagesize() sysconf(_SC_PAGESIZE) # else /* no _SC_PAGESIZE */ -# ifdef HAVE_SYS_PARAM_H +# if HAVE_SYS_PARAM_H # include # ifdef EXEC_PAGESIZE # define getpagesize() EXEC_PAGESIZE @@ -3086,111 +6173,114 @@ #endif /* no HAVE_GETPAGESIZE */ -#ifdef __cplusplus -extern "C" { void *malloc(unsigned); } -#else -char *malloc(); -#endif - int -main() +main () { - char *data, *data2, *data3; - int i, pagesize; - int fd; - - pagesize = getpagesize(); - - /* - * First, make a file with some known garbage in it. - */ - data = malloc(pagesize); - if (!data) - exit(1); - for (i = 0; i < pagesize; ++i) - *(data + i) = rand(); - umask(0); - fd = creat("conftestmmap", 0600); - if (fd < 0) - exit(1); - if (write(fd, data, pagesize) != pagesize) - exit(1); - close(fd); - - /* - * Next, try to mmap the file at a fixed address which - * already has something else allocated at it. If we can, - * also make sure that we see the same garbage. - */ - fd = open("conftestmmap", O_RDWR); - if (fd < 0) - exit(1); - data2 = malloc(2 * pagesize); - if (!data2) - exit(1); - data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1); - if (data2 != mmap(data2, pagesize, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_FIXED, fd, 0L)) - exit(1); - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data2 + i)) - exit(1); - - /* - * Finally, make sure that changes to the mapped area - * do not percolate back to the file as seen by read(). - * (This is a bug on some variants of i386 svr4.0.) - */ - for (i = 0; i < pagesize; ++i) - *(data2 + i) = *(data2 + i) + 1; - data3 = malloc(pagesize); - if (!data3) - exit(1); - if (read(fd, data3, pagesize) != pagesize) - exit(1); - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data3 + i)) - exit(1); - close(fd); - unlink("conftestmmap"); - exit(0); -} + char *data, *data2, *data3; + int i, pagesize; + int fd; + + pagesize = getpagesize (); + + /* First, make a file with some known garbage in it. */ + data = (char *) malloc (pagesize); + if (!data) + exit (1); + for (i = 0; i < pagesize; ++i) + *(data + i) = rand (); + umask (0); + fd = creat ("conftest.mmap", 0600); + if (fd < 0) + exit (1); + if (write (fd, data, pagesize) != pagesize) + exit (1); + close (fd); -EOF -if { (eval echo configure:3161: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then + /* Next, try to mmap the file at a fixed address which already has + something else allocated at it. If we can, also make sure that + we see the same garbage. */ + fd = open ("conftest.mmap", O_RDWR); + if (fd < 0) + exit (1); + data2 = (char *) malloc (2 * pagesize); + if (!data2) + exit (1); + data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1); + if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_FIXED, fd, 0L)) + exit (1); + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data2 + i)) + exit (1); + + /* Finally, make sure that changes to the mapped area do not + percolate back to the file as seen by read(). (This is a bug on + some variants of i386 svr4.0.) */ + for (i = 0; i < pagesize; ++i) + *(data2 + i) = *(data2 + i) + 1; + data3 = (char *) malloc (pagesize); + if (!data3) + exit (1); + if (read (fd, data3, pagesize) != pagesize) + exit (1); + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data3 + i)) + exit (1); + close (fd); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_func_mmap_fixed_mapped=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_func_mmap_fixed_mapped=no + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_mmap_fixed_mapped=no fi -rm -fr conftest* +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - fi - -echo "$ac_t""$ac_cv_func_mmap_fixed_mapped" 1>&6 +echo "$as_me:$LINENO: result: $ac_cv_func_mmap_fixed_mapped" >&5 +echo "${ECHO_T}$ac_cv_func_mmap_fixed_mapped" >&6 if test $ac_cv_func_mmap_fixed_mapped = yes; then - cat >> confdefs.h <<\EOF + +cat >>confdefs.h <<\_ACEOF #define HAVE_MMAP 1 -EOF +_ACEOF fi +rm -f conftest.mmap +fi -echo $ac_n "checking for working strncmp""... $ac_c" 1>&6 -echo "configure:3185: checking for working strncmp" >&5 -if eval "test \"`echo '$''{'ac_cv_func_strncmp_works'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for working strncmp" >&5 +echo $ECHO_N "checking for working strncmp... $ECHO_C" >&6 +if test "${ac_cv_func_strncmp_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_strncmp_works=no else - cat > conftest.$ac_ext <conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ /* Test by Jim Wilson and Kaveh Ghazi. Check whether strncmp reads past the end of its string parameters. */ @@ -3230,7 +6320,7 @@ dev_zero = open ("/dev/zero", O_RDONLY); if (dev_zero < 0) exit (1); - + p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, dev_zero, 0); if (p == (char *)-1) @@ -3252,25 +6342,35 @@ exit (0); } -EOF -if { (eval echo configure:3257: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_func_strncmp_works=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_func_strncmp_works=no + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_strncmp_works=no fi -rm -fr conftest* +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - rm -f core core.* *.core fi - -echo "$ac_t""$ac_cv_func_strncmp_works" 1>&6 +echo "$as_me:$LINENO: result: $ac_cv_func_strncmp_works" >&5 +echo "${ECHO_T}$ac_cv_func_strncmp_works" >&6 if test $ac_cv_func_strncmp_works = no ; then - LIBOBJS="$LIBOBJS strncmp.o" + LIBOBJS="$LIBOBJS strncmp.$ac_objext" fi @@ -3284,396 +6384,1167 @@ # We need multilib support, but only if configuring for the target. -trap '' 1 2 15 -cat > confcache <<\EOF + ac_config_files="$ac_config_files Makefile testsuite/Makefile" + ac_config_commands="$ac_config_commands default" +cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. # -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. # -EOF +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. -(set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote substitution - # turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - -e "s/'/'\\\\''/g" \ - -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' - ;; - esac >> confcache -if cmp -s $cache_file confcache; then - : -else +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else if test -w $cache_file; then - echo "updating cache $cache_file" - cat confcache > $cache_file + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' fi -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - DEFS=-DHAVE_CONFIG_H -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS <&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. # Run this file to recreate the current configuration. -# This directory was configured as follows, -# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# -# $0 $ac_configure_args -# # Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. +# configure, is in config.log if it exists. -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by $as_me, which was +generated by GNU Autoconf 2.57. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.57, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 do - case "\$ac_option" in + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_shift=: + ;; + -*) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.13" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + esac + shift done -ac_given_srcdir=$srcdir -ac_given_INSTALL="$INSTALL" +ac_configure_extra_args= -trap 'rm -fr `echo "Makefile testsuite/Makefile config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 -EOF -cat >> $CONFIG_STATUS </dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi -# Protect against being on the right side of a sed subst in config.status. -sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; - s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF -$ac_vpsub -$extrasub -s%@SHELL@%$SHELL%g -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@FFLAGS@%$FFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@bindir@%$bindir%g -s%@sbindir@%$sbindir%g -s%@libexecdir@%$libexecdir%g -s%@datadir@%$datadir%g -s%@sysconfdir@%$sysconfdir%g -s%@sharedstatedir@%$sharedstatedir%g -s%@localstatedir@%$localstatedir%g -s%@libdir@%$libdir%g -s%@includedir@%$includedir%g -s%@oldincludedir@%$oldincludedir%g -s%@infodir@%$infodir%g -s%@mandir@%$mandir%g -s%@libiberty_topdir@%$libiberty_topdir%g -s%@MAINT@%$MAINT%g -s%@NOTMAINT@%$NOTMAINT%g -s%@MAKEINFO@%$MAKEINFO%g -s%@BUILD_INFO@%$BUILD_INFO%g -s%@PERL@%$PERL%g -s%@HAVE_PERL@%$HAVE_PERL%g -s%@host@%$host%g -s%@host_alias@%$host_alias%g -s%@host_cpu@%$host_cpu%g -s%@host_vendor@%$host_vendor%g -s%@host_os@%$host_os%g -s%@build@%$build%g -s%@build_alias@%$build_alias%g -s%@build_cpu@%$build_cpu%g -s%@build_vendor@%$build_vendor%g -s%@build_os@%$build_os%g -s%@AR@%$AR%g -s%@RANLIB@%$RANLIB%g -s%@CC@%$CC%g -s%@ac_libiberty_warn_cflags@%$ac_libiberty_warn_cflags%g -s%@NO_MINUS_C_MINUS_O@%$NO_MINUS_C_MINUS_O%g -s%@OUTPUT_OPTION@%$OUTPUT_OPTION%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -/@host_makefile_frag@/r $host_makefile_frag -s%@host_makefile_frag@%%g -s%@CPP@%$CPP%g -s%@CHECK@%$CHECK%g -s%@target_header_dir@%$target_header_dir%g -s%@LIBOBJS@%$LIBOBJS%g -s%@pexecute@%$pexecute%g -s%@INSTALL_DEST@%$INSTALL_DEST%g +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS section. +# + +srcdir=${srcdir} +host=${host} +target=${target} +with_target_subdir=${with_target_subdir} +with_build_subdir=${with_build_subdir} +with_multisubdir=${with_multisubdir} +ac_configure_args="--enable-multilib ${ac_configure_args}" +CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} +ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}" +libiberty_topdir=${libiberty_topdir} + + +_ACEOF + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "testsuite/Makefile" ) CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;; + "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; + "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s, at SHELL@,$SHELL,;t t +s, at PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s, at PACKAGE_NAME@,$PACKAGE_NAME,;t t +s, at PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s, at PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s, at PACKAGE_STRING@,$PACKAGE_STRING,;t t +s, at PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s, at exec_prefix@,$exec_prefix,;t t +s, at prefix@,$prefix,;t t +s, at program_transform_name@,$program_transform_name,;t t +s, at bindir@,$bindir,;t t +s, at sbindir@,$sbindir,;t t +s, at libexecdir@,$libexecdir,;t t +s, at datadir@,$datadir,;t t +s, at sysconfdir@,$sysconfdir,;t t +s, at sharedstatedir@,$sharedstatedir,;t t +s, at localstatedir@,$localstatedir,;t t +s, at libdir@,$libdir,;t t +s, at includedir@,$includedir,;t t +s, at oldincludedir@,$oldincludedir,;t t +s, at infodir@,$infodir,;t t +s, at mandir@,$mandir,;t t +s, at build_alias@,$build_alias,;t t +s, at host_alias@,$host_alias,;t t +s, at target_alias@,$target_alias,;t t +s, at DEFS@,$DEFS,;t t +s, at ECHO_C@,$ECHO_C,;t t +s, at ECHO_N@,$ECHO_N,;t t +s, at ECHO_T@,$ECHO_T,;t t +s, at LIBS@,$LIBS,;t t +s, at libiberty_topdir@,$libiberty_topdir,;t t +s, at MAINT@,$MAINT,;t t +s, at NOTMAINT@,$NOTMAINT,;t t +s, at MAKEINFO@,$MAKEINFO,;t t +s, at BUILD_INFO@,$BUILD_INFO,;t t +s, at PERL@,$PERL,;t t +s, at HAVE_PERL@,$HAVE_PERL,;t t +s, at build@,$build,;t t +s, at build_cpu@,$build_cpu,;t t +s, at build_vendor@,$build_vendor,;t t +s, at build_os@,$build_os,;t t +s, at host@,$host,;t t +s, at host_cpu@,$host_cpu,;t t +s, at host_vendor@,$host_vendor,;t t +s, at host_os@,$host_os,;t t +s, at AR@,$AR,;t t +s, at ac_ct_AR@,$ac_ct_AR,;t t +s, at RANLIB@,$RANLIB,;t t +s, at ac_ct_RANLIB@,$ac_ct_RANLIB,;t t +s, at CC@,$CC,;t t +s, at CFLAGS@,$CFLAGS,;t t +s, at LDFLAGS@,$LDFLAGS,;t t +s, at CPPFLAGS@,$CPPFLAGS,;t t +s, at ac_ct_CC@,$ac_ct_CC,;t t +s, at EXEEXT@,$EXEEXT,;t t +s, at OBJEXT@,$OBJEXT,;t t +s, at ac_libiberty_warn_cflags@,$ac_libiberty_warn_cflags,;t t +s, at NO_MINUS_C_MINUS_O@,$NO_MINUS_C_MINUS_O,;t t +s, at OUTPUT_OPTION@,$OUTPUT_OPTION,;t t +s, at INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s, at INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s, at INSTALL_DATA@,$INSTALL_DATA,;t t +s, at CPP@,$CPP,;t t +s, at EGREP@,$EGREP,;t t +s, at LIBOBJS@,$LIBOBJS,;t t +s, at CHECK@,$CHECK,;t t +s, at target_header_dir@,$target_header_dir,;t t +s, at pexecute@,$pexecute,;t t +s, at INSTALL_DEST@,$INSTALL_DEST,;t t +s, at LTLIBOBJS@,$LTLIBOBJS,;t t +/@host_makefile_frag@/r $host_makefile_frag +s, at host_makefile_frag@,,;t t CEOF -EOF -cat >> $CONFIG_STATUS <<\EOF +_ACEOF -# Split the substitutions into bite-sized pieces for seds with -# small command number limits, like on Digital OSF/1 and HP-UX. -ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. -ac_file=1 # Number of current file. -ac_beg=1 # First line for current file. -ac_end=$ac_max_sed_cmds # Line after last line for current file. -ac_more_lines=: -ac_sed_cmds="" -while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file - else - sed "${ac_end}q" conftest.subs > conftest.s$ac_file - fi - if test ! -s conftest.s$ac_file; then - ac_more_lines=false - rm -f conftest.s$ac_file - else - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f conftest.s$ac_file" + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false else - ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` fi - ac_file=`expr $ac_file + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_cmds` + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat fi -done -if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat -fi -EOF +fi # test -n "$CONFIG_FILES" -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. - - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dir_suffix= ac_dots= - fi - - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac - case "$ac_given_INSTALL" in - [/$]*) INSTALL="$ac_given_INSTALL" ;; - *) INSTALL="$ac_dots$ac_given_INSTALL" ;; - esac - - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac - - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -s%@INSTALL@%$INSTALL%g -" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file -fi; done -rm -f conftest.s* + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s, at configure_input@,$configure_input,;t t +s, at srcdir@,$ac_srcdir,;t t +s, at abs_srcdir@,$ac_abs_srcdir,;t t +s, at top_srcdir@,$ac_top_srcdir,;t t +s, at abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s, at builddir@,$ac_builddir,;t t +s, at abs_builddir@,$ac_abs_builddir,;t t +s, at top_builddir@,$ac_top_builddir,;t t +s, at abs_top_builddir@,$ac_abs_top_builddir,;t t +s, at INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_HEADER section. +# # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' -ac_dC='\3' -ac_dD='%g' -# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". -ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='\([ ]\)%\1#\2define\3' +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='[ ].*$,\1#\2' +ac_dC=' ' +ac_dD=',;t' +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='$,\1#\2define\3' ac_uC=' ' -ac_uD='\4%g' -# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_eB='$%\1#\2define\3' -ac_eC=' ' -ac_eD='%g' +ac_uD=',;t' -if test "${CONFIG_HEADERS+set}" != set; then -EOF -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF -fi -for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; esac - echo creating $ac_file - - rm -f conftest.frag conftest.in conftest.out - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - cat $ac_file_inputs > conftest.in - -EOF + test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} -# Transform confdefs.h into a sed script conftest.vals that substitutes -# the proper values into config.h.in to produce config.h. And first: -# Protect against being on the right side of a sed subst in config.status. -# Protect against being in an unquoted here document in config.status. -rm -f conftest.vals -cat > conftest.hdr <<\EOF -s/[\\&%]/\\&/g -s%[\\$`]%\\&%g -s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp -s%ac_d%ac_u%gp -s%ac_u%ac_e%gp -EOF -sed -n -f conftest.hdr confdefs.h > conftest.vals -rm -f conftest.hdr + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + # Remove the trailing spaces. + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in + +_ACEOF + +# Transform confdefs.h into two sed scripts, `conftest.defines' and +# `conftest.undefs', that substitutes the proper values into +# config.h.in to produce config.h. The first handles `#define' +# templates, and the second `#undef' templates. +# And first: Protect against being on the right side of a sed subst in +# config.status. Protect against being in an unquoted here document +# in config.status. +rm -f conftest.defines conftest.undefs +# Using a here document instead of a string reduces the quoting nightmare. +# Putting comments in sed scripts is not portable. +# +# `end' is used to avoid that the second main sed command (meant for +# 0-ary CPP macros) applies to n-ary macro definitions. +# See the Autoconf documentation for `clear'. +cat >confdef2sed.sed <<\_ACEOF +s/[\\&,]/\\&/g +s,[\\$`],\\&,g +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp +t end +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp +: end +_ACEOF +# If some macros were called several times there might be several times +# the same #defines, which is useless. Nevertheless, we may not want to +# sort them, since we want the *last* AC-DEFINE to be honored. +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs +rm -f confdef2sed.sed # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. -cat >> conftest.vals <<\EOF -s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% -EOF - -# Break up conftest.vals because some shells have a limit on -# the size of here documents, and old seds have small limits too. - +cat >>conftest.undefs <<\_ACEOF +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, +_ACEOF + +# Break up conftest.defines because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS +echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS +echo ' :' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.defines >/dev/null +do + # Write a limited-size here document to $tmp/defines.sed. + echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#define' lines. + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/defines.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines +echo ' fi # grep' >>$CONFIG_STATUS +echo >>$CONFIG_STATUS + +# Break up conftest.undefs because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS rm -f conftest.tail -while : +while grep . conftest.undefs >/dev/null do - ac_lines=`grep -c . conftest.vals` - # grep -c gives empty output for an empty file on some AIX systems. - if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi - # Write a limited-size here document to conftest.frag. - echo ' cat > conftest.frag <> $CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + # Write a limited-size here document to $tmp/undefs.sed. + echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#undef' + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS echo 'CEOF - sed -f conftest.frag conftest.in > conftest.out - rm -f conftest.in - mv conftest.out conftest.in -' >> $CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail - rm -f conftest.vals - mv conftest.tail conftest.vals -done -rm -f conftest.vals - -cat >> $CONFIG_STATUS <<\EOF - rm -f conftest.frag conftest.h - echo "/* $ac_file. Generated automatically by configure. */" > conftest.h - cat conftest.in >> conftest.h - rm -f conftest.in - if cmp -s $ac_file conftest.h 2>/dev/null; then - echo "$ac_file is unchanged" - rm -f conftest.h - else - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" + sed -f $tmp/undefs.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail + rm -f conftest.undefs + mv conftest.tail conftest.undefs +done +rm -f conftest.undefs + +cat >>$CONFIG_STATUS <<\_ACEOF + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + echo "/* Generated by configure. */" >$tmp/config.h + else + echo "/* $ac_file. Generated by configure. */" >$tmp/config.h + fi + cat $tmp/in >>$tmp/config.h + rm -f $tmp/in + if test x"$ac_file" != x-; then + if diff $ac_file $tmp/config.h >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + rm -f $ac_file + mv $tmp/config.h $ac_file fi - rm -f $ac_file - mv conftest.h $ac_file + else + cat $tmp/config.h + rm -f $tmp/config.h fi -fi; done +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF -EOF -cat >> $CONFIG_STATUS </dev/null || +$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_dest" : 'X\(//\)[^/]' \| \ + X"$ac_dest" : 'X\(//\)$' \| \ + X"$ac_dest" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_dest" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` -EOF -cat >> $CONFIG_STATUS <<\EOF -test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h + + { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 +echo "$as_me: executing $ac_dest commands" >&6;} + case $ac_dest in + default ) test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h if test -n "$CONFIG_FILES"; then if test -n "${with_build_subdir}" || test -n "${with_target_subdir}"; then # FIXME: We shouldn't need to set ac_file @@ -3681,10 +7552,37 @@ LD="${ORIGINAL_LD_FOR_MULTILIBS}" . ${libiberty_topdir}/config-ml.in fi -fi -exit 0 -EOF +fi ;; + esac +done +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi From criswell at cs.uiuc.edu Thu Feb 5 10:10:11 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:10:11 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/Makefile.in alias.c builtins.c c-common.c c-common.h c-decl.c c-lang.c c-lex.c c-pragma.c c-pretty-print.c c-semantics.c c-typeck.c calls.c cgraphunit.c dwarf2out.c emit-rtl.c expr.c fold-const.c function.c gcc.c integrate.c langhooks-def.h langhooks.c langhooks.h llvm-expand.c llvm-out.c llvm-out.h loop.c opts.c stmt.c toplev.c tree-optimize.c tree.c tree.def tree.h varasm.c version.c configure.frag Message-ID: <200402051606.KAA27177@choi.cs.uiuc.edu> Changes in directory gcc-3.4/gcc: Makefile.in updated: 1.2 -> 1.3 alias.c updated: 1.2 -> 1.3 builtins.c updated: 1.2 -> 1.3 c-common.c updated: 1.2 -> 1.3 c-common.h updated: 1.2 -> 1.3 c-decl.c updated: 1.2 -> 1.3 c-lang.c updated: 1.2 -> 1.3 c-lex.c updated: 1.2 -> 1.3 c-pragma.c updated: 1.3 -> 1.4 c-pretty-print.c updated: 1.1.1.2 -> 1.2 c-semantics.c updated: 1.2 -> 1.3 c-typeck.c updated: 1.2 -> 1.3 calls.c updated: 1.2 -> 1.3 cgraphunit.c updated: 1.1.1.3 -> 1.2 dwarf2out.c updated: 1.2 -> 1.3 emit-rtl.c updated: 1.2 -> 1.3 expr.c updated: 1.2 -> 1.3 fold-const.c updated: 1.2 -> 1.3 function.c updated: 1.2 -> 1.3 gcc.c updated: 1.2 -> 1.3 integrate.c updated: 1.2 -> 1.3 langhooks-def.h updated: 1.2 -> 1.3 langhooks.c updated: 1.2 -> 1.3 langhooks.h updated: 1.2 -> 1.3 llvm-expand.c updated: 1.7 -> 1.8 llvm-out.c updated: 1.1 -> 1.2 llvm-out.h updated: 1.2 -> 1.3 loop.c updated: 1.2 -> 1.3 opts.c updated: 1.2 -> 1.3 stmt.c updated: 1.2 -> 1.3 toplev.c updated: 1.3 -> 1.4 tree-optimize.c updated: 1.1.1.1 -> 1.2 tree.c updated: 1.2 -> 1.3 tree.def updated: 1.2 -> 1.3 tree.h updated: 1.2 -> 1.3 varasm.c updated: 1.2 -> 1.3 version.c updated: 1.2 -> 1.3 configure.frag (r1.1.1.1) removed --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+2028 -1933) Index: gcc-3.4/gcc/Makefile.in diff -u gcc-3.4/gcc/Makefile.in:1.2 gcc-3.4/gcc/Makefile.in:1.3 --- gcc-3.4/gcc/Makefile.in:1.2 Thu Jan 8 17:03:26 2004 +++ gcc-3.4/gcc/Makefile.in Thu Feb 5 10:05:44 2004 @@ -186,7 +186,6 @@ FLEXFLAGS = AR = ar AR_FLAGS = rc -DLLTOOL = dlltool RANLIB = @RANLIB@ # ------------------------------------------- @@ -223,6 +222,7 @@ # Make sure the $(MAKE) variable is defined. @SET_MAKE@ +REMAKEFLAGS=LANGUAGES="$(LANGUAGES)" BOOT_CFLAGS="$(BOOT_CFLAGS)" # -------- # UNSORTED @@ -336,8 +336,8 @@ # each of $(system_prefix)/usr/include, $(system_prefix)/usr/lib, etc. TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@ -xmake_file=@dep_host_xmake_file@ -tmake_file=@dep_tmake_file@ +xmake_file=@xmake_file@ +tmake_file=@tmake_file@ out_file=$(srcdir)/config/@out_file@ out_object_file=@out_object_file@ md_file=$(srcdir)/config/@md_file@ @@ -661,12 +661,16 @@ DIAGNOSTIC_H = diagnostic.h diagnostic.def $(PRETTY_PRINT_H) C_PRETTY_PRINT_H = $(PRETTY_PRINT_H) $(C_COMMON_H) $(TREE_H) -# sed inserts variable overrides after the following line. -####target overrides - at target_overrides@ +# target overrides +ifneq ($(tmake_file),) +include $(tmake_file) +endif + +# host overrides +ifneq ($(xmake_file),) +include $(xmake_file) +endif -####host overrides - at host_overrides@ # # Now figure out from those variables how to compile and link. @@ -735,6 +739,7 @@ # Support for additional languages (other than C). # C can be supported this way too (leave for later). +LANG_MAKEFRAGS = @all_lang_makefrags@ LANG_MAKEFILES = @all_lang_makefiles@ LANG_STAGESTUFF = @all_stagestuff@ @@ -848,13 +853,13 @@ reload.o reload1.o reorg.o resource.o rtl.o rtlanal.o rtl-error.o \ sbitmap.o sched-deps.o sched-ebb.o sched-rgn.o sched-vis.o sdbout.o \ sibcall.o simplify-rtx.o sreal.o ssa.o ssa-ccp.o ssa-dce.o stmt.o \ - stor-layout.o stringpool.o timevar.o toplev.o tracer.o tree.o tree-dump.o \ + stor-layout.o stringpool.o targhooks.o timevar.o toplev.o tracer.o tree.o tree-dump.o \ unroll.o varasm.o varray.o version.o vmsdbgout.o xcoffout.o \ alloc-pool.o et-forest.o cfghooks.o bt-load.o pretty-print.o $(GGC) $(LLVM_OBJS) OBJS-md = $(out_object_file) OBJS-archive = $(EXTRA_OBJS) $(host_hook_obj) hashtable.o tree-inline.o \ - cgraph.o cgraphunit.o + tree-optimize.o cgraph.o cgraphunit.o OBJS = $(OBJS-common) $(out_object_file) $(OBJS-archive) @@ -926,27 +931,24 @@ # targets). The name of each hooked is "lang.${target_name}" (eg: lang.info). # Configure computes and adds these here. -####language hooks +# language hooks, generated by configure @language_hooks@ -# sed inserts language fragments after the following line. -####language fragments - at language_fragments@ +# per-language makefile fragments +ifneq ($(LANG_MAKEFRAGS),) +include $(LANG_MAKEFRAGS) +endif -# End of language makefile fragments. # # ----------------------------- # Rebuilding this configuration # ----------------------------- -Makefile: $(srcdir)/Makefile.in config.status $(srcdir)/version.c \ - $(xmake_file) $(tmake_file) $(LANG_MAKEFILES) - $(SHELL) $(srcdir)/configure.frag $(srcdir) "$(SUBDIRS)" \ - "$(xmake_file)" "$(tmake_file)" - cp config.status config.run - LANGUAGES="$(CONFIG_LANGUAGES)" $(SHELL) config.run - rm -f config.run +Makefile: config.status $(srcdir)/Makefile.in $(srcdir)/version.c + LANGUAGES="$(CONFIG_LANGUAGES)" \ + CONFIG_HEADERS= \ + CONFIG_FILES=$@ $(SHELL) config.status config.h: cs-config.h ; @true bconfig.h: cs-bconfig.h ; @true @@ -1015,7 +1017,9 @@ @MAINT@ echo timestamp > $(srcdir)/cstamp-h.in auto-host.h: cstamp-h ; @true cstamp-h: config.in config.status - CONFIG_HEADERS=auto-host.h:config.in LANGUAGES="$(CONFIG_LANGUAGES)" $(SHELL) config.status + CONFIG_HEADERS=auto-host.h:config.in \ + CONFIG_FILES= \ + LANGUAGES="$(CONFIG_LANGUAGES)" $(SHELL) config.status # Really, really stupid make features, such as SUN's KEEP_STATE, may force # a target to build even if it is up-to-date. So we must verify that @@ -1295,7 +1299,7 @@ c-objc-common.o : c-objc-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ $(C_TREE_H) $(RTL_H) insn-config.h $(INTEGRATE_H) $(EXPR_H) $(C_TREE_H) \ flags.h toplev.h tree-inline.h $(DIAGNOSTIC_H) $(VARRAY_H) \ - langhooks.h $(GGC_H) gt-c-objc-common.h $(TARGET_H) cgraph.h + langhooks.h $(GGC_H) $(TARGET_H) cgraph.h c-aux-info.o : c-aux-info.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ $(C_TREE_H) flags.h toplev.h c-convert.o : c-convert.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ @@ -1408,8 +1412,6 @@ gencheck.o : gencheck.c gencheck.h tree.def $(BCONFIG_H) $(SYSTEM_H) \ coretypes.h $(GTM_H) $(lang_tree_files) - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) \ - $(srcdir)/gencheck.c $(OUTPUT_OPTION) gencheck.h : s-gencheck ; @true s-gencheck : Makefile @@ -1468,17 +1470,20 @@ langhooks.o : langhooks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) toplev.h \ tree-inline.h $(RTL_H) insn-config.h $(INTEGRATE_H) langhooks.h \ - $(LANGHOOKS_DEF_H) flags.h $(GGC_H) gt-langhooks.h + $(LANGHOOKS_DEF_H) flags.h $(GGC_H) gt-langhooks.h diagnostic.h tree.o : tree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) flags.h function.h \ toplev.h $(GGC_H) $(HASHTAB_H) $(TARGET_H) output.h $(TM_P_H) langhooks.h \ real.h gt-tree.h tree-dump.o: tree-dump.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ $(C_TREE_H) flags.h langhooks.h toplev.h output.h c-pragma.h $(RTL_H) $(GGC_H) \ $(EXPR_H) $(SPLAY_TREE_H) tree-dump.h -tree-inline.o : tree-inline.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ - $(RTL_H) $(EXPR_H) flags.h $(PARAMS_H) input.h insn-config.h $(INTEGRATE_H) \ - $(VARRAY_H) $(HASHTAB_H) $(SPLAY_TREE_H) toplev.h langhooks.h \ - $(C_COMMON_H) tree-inline.h cgraph.h +tree-inline.o : tree-inline.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ + $(TREE_H) $(RTL_H) $(EXPR_H) flags.h $(PARAMS_H) input.h insn-config.h \ + $(INTEGRATE_H) $(VARRAY_H) $(HASHTAB_H) $(SPLAY_TREE_H) toplev.h \ + langhooks.h $(C_COMMON_H) tree-inline.h cgraph.h intl.h +tree-optimize.o : tree-optimize.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ + $(TREE_H) toplev.h langhooks.h cgraph.h $(TIMEVAR_H) function.h $(GGC_H) + print-tree.o : print-tree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ $(GGC_H) langhooks.h real.h stor-layout.o : stor-layout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ @@ -1492,6 +1497,10 @@ opts.o : opts.c opts.h options.h toplev.h $(CONFIG_H) $(SYSTEM_H) \ coretypes.h $(TREE_H) $(TM_H) $(LANGHOOKS_H) $(GGC_H) $(RTL_H) \ output.h $(DIAGNOSTIC_H) $(TM_P_H) $(INSN_ATTR_H) intl.h +targhooks.o : targhooks.c targhooks.h $(CONFIG_H) $(SYSTEM_H) \ + coretypes.h $(TREE_H) $(TM_H) $(RTL_H) $(TM_P_H) function.h \ + output.h toplev.h + toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_H) \ function.h flags.h xcoffout.h input.h $(INSN_ATTR_H) output.h $(DIAGNOSTIC_H) \ debug.h insn-config.h intl.h $(RECOG_H) Makefile toplev.h \ @@ -1530,16 +1539,16 @@ function.o : function.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \ flags.h function.h $(EXPR_H) $(OPTABS_H) libfuncs.h $(REGS_H) hard-reg-set.h \ insn-config.h $(RECOG_H) output.h toplev.h except.h $(HASHTAB_H) $(GGC_H) \ - $(TM_P_H) langhooks.h gt-function.h + $(TM_P_H) langhooks.h gt-function.h $(TARGET_H) stmt.o : stmt.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) flags.h \ function.h insn-config.h hard-reg-set.h $(EXPR_H) libfuncs.h except.h \ $(LOOP_H) $(RECOG_H) toplev.h output.h varray.h $(GGC_H) $(TM_P_H) \ - langhooks.h $(PREDICT_H) gt-stmt.h $(OPTABS_H) -except.o : except.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \ - flags.h except.h function.h $(EXPR_H) libfuncs.h $(INTEGRATE_H) langhooks.h \ - insn-config.h hard-reg-set.h $(BASIC_BLOCK_H) output.h \ + langhooks.h $(PREDICT_H) gt-stmt.h $(OPTABS_H) $(TARGET_H) +except.o : except.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ + $(TREE_H) flags.h except.h function.h $(EXPR_H) libfuncs.h $(INTEGRATE_H) \ + langhooks.h insn-config.h hard-reg-set.h $(BASIC_BLOCK_H) output.h \ dwarf2asm.h dwarf2out.h toplev.h $(HASHTAB_H) intl.h $(GGC_H) \ - gt-except.h + gt-except.h cgraph.h expr.o : expr.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) flags.h \ function.h $(REGS_H) $(EXPR_H) $(OPTABS_H) libfuncs.h $(INSN_ATTR_H) insn-config.h \ $(RECOG_H) output.h typeclass.h hard-reg-set.h toplev.h hard-reg-set.h \ @@ -1700,7 +1709,7 @@ et-forest.o : et-forest.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) et-forest.h alloc-pool.h combine.o : combine.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) flags.h \ function.h insn-config.h $(INSN_ATTR_H) $(REGS_H) $(EXPR_H) \ - $(BASIC_BLOCK_H) $(RECOG_H) real.h hard-reg-set.h toplev.h $(TM_P_H) + $(BASIC_BLOCK_H) $(RECOG_H) real.h hard-reg-set.h toplev.h $(TM_P_H) $(TREE_H) $(TARGET_H) regclass.o : regclass.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ hard-reg-set.h flags.h $(BASIC_BLOCK_H) $(REGS_H) insn-config.h $(RECOG_H) reload.h \ real.h toplev.h function.h output.h $(GGC_H) $(TM_P_H) $(EXPR_H) $(TIMEVAR_H) @@ -1884,8 +1893,6 @@ dummy-conditions.o : dummy-conditions.c $(BCONFIG_H) $(SYSTEM_H) \ coretypes.h $(GTM_H) gensupport.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) \ - $(srcdir)/dummy-conditions.c $(OUTPUT_OPTION) insn-flags.h: s-flags ; @true s-flags : $(md_file) genflags$(build_exeext) $(srcdir)/move-if-change @@ -2044,7 +2051,7 @@ gt-expr.h gt-sdbout.h gt-optabs.h gt-bitmap.h \ gt-dwarf2out.h gt-ra-build.h gt-reg-stack.h gt-dwarf2asm.h \ gt-dbxout.h gt-c-common.h gt-c-decl.h gt-c-parse.h \ -gt-c-pragma.h gt-c-objc-common.h gtype-c.h gt-input.h gt-cfglayout.h \ +gt-c-pragma.h gtype-c.h gt-input.h gt-cfglayout.h \ gt-stringpool.h gt-langhooks.h : s-gtype ; @true gtyp-gen.h: Makefile @@ -2089,43 +2096,43 @@ # about the target machine. They do depend on config.h itself, # since that describes the host machine. +# The names of programs that run on the "build" machine. +genprognames=genconfig genflags gencodes genemit genopinit genrecog \ + genextract genpeep genattr genoutput + +# The names of the executable files for those programs. +genprogs=$(genprognames:%=%$(build_exeext)) + +# Object files used in those programs. +genobjs=$(genprognames:%=%.o) read-rtl.o gensupport.o genattrtab.o \ + genautomata.o gengenrtl.o genpreds.o gengtype.o \ + genconstants.o gen-protos.o scan.o fix-header.o scan-decls.o \ + gencheck.o dummy-conditions.o genconditions.o + +$(genprogs): %$(build_exeext): %.o $(BUILD_RTL) $(BUILD_SUPPORT) \ + $(BUILD_PRINT) $(BUILD_ERRORS) \ + $(BUILD_LIBDEPS) + $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \ + $< $(BUILD_RTL) $(BUILD_SUPPORT) $(BUILD_PRINT) \ + $(BUILD_ERRORS) $(BUILD_LIBS) + +$(genobjs): %.o : %.c + $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) + read-rtl.o: read-rtl.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) $(RTL_H) \ $(OBSTACK_H) $(HASHTAB_H) - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/read-rtl.c $(OUTPUT_OPTION) gensupport.o: gensupport.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) $(RTL_H) \ $(OBSTACK_H) errors.h $(HASHTAB_H) gensupport.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/gensupport.c $(OUTPUT_OPTION) - -genconfig$(build_exeext) : genconfig.o $(BUILD_RTL) $(BUILD_SUPPORT) \ - $(BUILD_PRINT) $(BUILD_ERRORS) $(BUILD_LIBDEPS) - $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \ - genconfig.o $(BUILD_RTL) $(BUILD_SUPPORT) $(BUILD_PRINT) \ - $(BUILD_ERRORS) $(BUILD_LIBS) genconfig.o : genconfig.c $(RTL_H) $(BCONFIG_H) \ $(SYSTEM_H) coretypes.h $(GTM_H) errors.h gensupport.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/genconfig.c $(OUTPUT_OPTION) - -genflags$(build_exeext) : genflags.o $(BUILD_RTL) $(BUILD_SUPPORT) \ - $(BUILD_PRINT) $(BUILD_ERRORS) $(BUILD_LIBDEPS) - $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \ - genflags.o $(BUILD_RTL) $(BUILD_SUPPORT) $(BUILD_PRINT) \ - $(BUILD_ERRORS) $(BUILD_LIBS) genflags.o : genflags.c $(RTL_H) $(OBSTACK_H) $(BCONFIG_H) \ $(SYSTEM_H) coretypes.h $(GTM_H) errors.h gensupport.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/genflags.c $(OUTPUT_OPTION) - -gencodes$(build_exeext) : gencodes.o $(BUILD_RTL) $(BUILD_SUPPORT) \ - $(BUILD_PRINT) $(BUILD_ERRORS) $(BUILD_LIBDEPS) - $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \ - gencodes.o $(BUILD_RTL) $(BUILD_SUPPORT) $(BUILD_PRINT) \ - $(BUILD_ERRORS) $(BUILD_LIBS) gencodes.o : gencodes.c $(RTL_H) $(BCONFIG_H) \ $(SYSTEM_H) coretypes.h $(GTM_H) errors.h gensupport.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/gencodes.c $(OUTPUT_OPTION) genconstants$(build_exeext) : genconstants.o $(BUILD_RTL) $(BUILD_EARLY_SUPPORT) \ $(BUILD_ERRORS) $(BUILD_LIBDEPS) @@ -2135,67 +2142,24 @@ genconstants.o : genconstants.c $(RTL_H) $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) \ errors.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/genconstants.c $(OUTPUT_OPTION) - -genemit$(build_exeext) : genemit.o $(BUILD_RTL) $(BUILD_SUPPORT) \ - $(BUILD_PRINT) $(BUILD_ERRORS) $(BUILD_LIBDEPS) - $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \ - genemit.o $(BUILD_RTL) $(BUILD_SUPPORT) $(BUILD_PRINT) \ - $(BUILD_ERRORS) $(BUILD_LIBS) genemit.o : genemit.c $(RTL_H) $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) \ errors.h gensupport.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/genemit.c $(OUTPUT_OPTION) - -genopinit$(build_exeext) : genopinit.o $(BUILD_RTL) $(BUILD_SUPPORT) \ - $(BUILD_PRINT) $(BUILD_ERRORS) $(BUILD_LIBDEPS) - $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \ - genopinit.o $(BUILD_RTL) $(BUILD_SUPPORT) $(BUILD_PRINT) \ - $(BUILD_ERRORS) $(BUILD_LIBS) genopinit.o : genopinit.c $(RTL_H) $(BCONFIG_H) \ $(SYSTEM_H) coretypes.h $(GTM_H) errors.h gensupport.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/genopinit.c $(OUTPUT_OPTION) - -genrecog$(build_exeext) : genrecog.o $(BUILD_RTL) $(BUILD_SUPPORT) \ - $(BUILD_PRINT) $(BUILD_ERRORS) $(BUILD_LIBDEPS) - $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \ - genrecog.o $(BUILD_RTL) $(BUILD_SUPPORT) $(BUILD_PRINT) \ - $(BUILD_ERRORS) $(BUILD_LIBS) genrecog.o : genrecog.c $(RTL_H) $(BCONFIG_H) \ $(SYSTEM_H) coretypes.h $(GTM_H) errors.h gensupport.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/genrecog.c $(OUTPUT_OPTION) - -genextract$(build_exeext) : genextract.o $(BUILD_RTL) $(BUILD_SUPPORT) \ - $(BUILD_PRINT) $(BUILD_ERRORS) $(BUILD_LIBDEPS) - $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \ - genextract.o $(BUILD_RTL) $(BUILD_SUPPORT) $(BUILD_PRINT) \ - $(BUILD_ERRORS) $(BUILD_LIBS) genextract.o : genextract.c $(RTL_H) $(BCONFIG_H) \ $(SYSTEM_H) coretypes.h $(GTM_H) insn-config.h errors.h gensupport.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/genextract.c $(OUTPUT_OPTION) - -genpeep$(build_exeext) : genpeep.o $(BUILD_RTL) $(BUILD_SUPPORT) \ - $(BUILD_PRINT) $(BUILD_ERRORS) $(BUILD_LIBDEPS) - $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \ - genpeep.o $(BUILD_RTL) $(BUILD_SUPPORT) $(BUILD_PRINT) \ - $(BUILD_ERRORS) $(BUILD_LIBS) genpeep.o : genpeep.c $(RTL_H) $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) \ errors.h gensupport.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/genpeep.c $(OUTPUT_OPTION) - -genattr$(build_exeext) : genattr.o $(BUILD_RTL) $(BUILD_SUPPORT) \ - $(BUILD_PRINT) $(BUILD_ERRORS) $(BUILD_LIBDEPS) - $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \ - genattr.o $(BUILD_RTL) $(BUILD_SUPPORT) $(BUILD_PRINT) \ - $(BUILD_ERRORS) $(BUILD_LIBS) genattr.o : genattr.c $(RTL_H) $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) errors.h \ gensupport.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/genattr.c $(OUTPUT_OPTION) genattrtab$(build_exeext) : genattrtab.o genautomata.o \ $(BUILD_RTL) $(BUILD_SUPPORT) $(BUILD_PRINT) $(BUILD_ERRORS) $(BUILD_VARRAY) \ @@ -2207,21 +2171,12 @@ genattrtab.o : genattrtab.c $(RTL_H) $(OBSTACK_H) $(BCONFIG_H) \ $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(GGC_H) gensupport.h genattrtab.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/genattrtab.c $(OUTPUT_OPTION) genautomata.o : genautomata.c $(RTL_H) $(OBSTACK_H) $(BCONFIG_H) \ $(SYSTEM_H) coretypes.h $(GTM_H) errors.h varray.h genattrtab.h $(HASHTAB_H) - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/genautomata.c $(OUTPUT_OPTION) - -genoutput$(build_exeext) : genoutput.o $(BUILD_RTL) $(BUILD_SUPPORT) \ - $(BUILD_PRINT) $(BUILD_ERRORS) $(BUILD_LIBDEPS) - $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \ - genoutput.o $(BUILD_RTL) $(BUILD_SUPPORT) $(BUILD_PRINT) \ - $(BUILD_ERRORS) $(BUILD_LIBS) genoutput.o : genoutput.c $(RTL_H) $(BCONFIG_H) \ $(SYSTEM_H) coretypes.h $(GTM_H) errors.h gensupport.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/genoutput.c $(OUTPUT_OPTION) gengenrtl$(build_exeext) : gengenrtl.o $(BUILD_LIBDEPS) $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \ @@ -2229,14 +2184,12 @@ gengenrtl.o : gengenrtl.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H) coretypes.h \ $(GTM_H) real.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/gengenrtl.c $(OUTPUT_OPTION) genpreds$(build_exeext) : genpreds.o $(BUILD_LIBDEPS) $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \ genpreds.o $(BUILD_LIBS) genpreds.o : genpreds.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/genpreds.c $(OUTPUT_OPTION) gengtype$(build_exeext) : gengtype.o gengtype-lex.o gengtype-yacc.o \ $(BUILD_LIBDEPS) @@ -2245,8 +2198,6 @@ gengtype.o : gengtype.c gengtype.h $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) \ real.h $(RTL_BASE_H) gtyp-gen.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) \ - $(srcdir)/gengtype.c $(OUTPUT_OPTION) gengtype-lex.o : $(parsedir)/gengtype-lex.c gengtype.h $(parsedir)/gengtype-yacc.c \ $(BCONFIG_H) coretypes.h $(GTM_H) $(SYSTEM_H) @@ -2286,8 +2237,6 @@ genconditions.o : genconditions.c $(RTL_H) $(BCONFIG_H) $(SYSTEM_H) coretypes.h \ $(GTM_H) errors.h - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) \ - $(srcdir)/genconditions.c $(OUTPUT_OPTION) # # Compile the libraries to be used by gen*. @@ -2587,10 +2536,8 @@ $(GEN_PROTOS_OBJS) $(BUILD_LIBS) gen-protos.o: gen-protos.c scan.h $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/gen-protos.c $(OUTPUT_OPTION) scan.o: scan.c scan.h $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/scan.c $(OUTPUT_OPTION) xsys-protos.h: $(GCC_PASSES) $(srcdir)/sys-protos.h deduced.h gen-protos$(build_exeext) Makefile sed -e s/TARGET_GETGROUPS_T/$(TARGET_GETGROUPS_T)/ \ @@ -2611,10 +2558,8 @@ fix-header.o: fix-header.c $(OBSTACK_H) scan.h \ xsys-protos.h $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) $(CPPLIB_H) - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/fix-header.c $(OUTPUT_OPTION) scan-decls.o: scan-decls.c scan.h $(CPPLIB_H) $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) - $(CC_FOR_BUILD) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) $(srcdir)/scan-decls.c $(OUTPUT_OPTION) # stmp-fixproto depends on this, not on fix-header directly. # The idea is to make sure fix-header gets built, @@ -2688,99 +2633,55 @@ TEXI_CPPINT_FILES = $(docdir)/cppinternals.texi -$(docobjdir)/cpp.info: $(TEXI_CPP_FILES) stmp-docobjdir - $(MAKEINFO) $(MAKEINFOFLAGS) -I $(docdir) -I $(docdir)/include \ - -o $@ $(docdir)/cpp.texi +$(docobjdir)/cpp.info cpp.dvi: $(TEXI_CPP_FILES) +$(docobjdir)/gcc.info gcc.dvi: $(TEXI_GCC_FILES) +$(docobjdir)/gccint.info gccint.dvi: $(TEXI_GCCINT_FILES) +$(docobjdir)/gccinstall.info gccinstall.dvi: $(TEXI_GCCINSTALL_FILES) +$(docobjdir)/cppinternals.info cppinternals.dvi: $(TEXI_CPPINT_FILES) -$(docobjdir)/gcc.info: $(TEXI_GCC_FILES) stmp-docobjdir +$(docobjdir)/%.info: $(docdir)/%.texi stmp-docobjdir $(MAKEINFO) $(MAKEINFOFLAGS) -I $(docdir) -I $(docdir)/include \ - -o $@ $(docdir)/gcc.texi - -$(docobjdir)/gccint.info: $(TEXI_GCCINT_FILES) stmp-docobjdir - $(MAKEINFO) $(MAKEINFOFLAGS) -I $(docdir) -I $(docdir)/include \ - -o $@ $(docdir)/gccint.texi - -$(docobjdir)/gccinstall.info: $(TEXI_GCCINSTALL_FILES) stmp-docobjdir - $(MAKEINFO) $(MAKEINFOFLAGS) -I $(docdir) -I $(docdir)/include \ - -o $@ $(docdir)/install.texi - -$(docobjdir)/cppinternals.info: $(TEXI_CPPINT_FILES) stmp-docobjdir - $(MAKEINFO) $(MAKEINFOFLAGS) -I $(docdir) -I $(docdir)/include \ - -o $@ $(docdir)/cppinternals.texi + -o $@ $< dvi: gcc.dvi gccint.dvi gccinstall.dvi cpp.dvi lang.dvi cppinternals.dvi -# This works with GNU Make's default rule. -cpp.dvi: $(TEXI_CPP_FILES) - $(TEXI2DVI) -I $(docdir) -I $(docdir)/include $(docdir)/cpp.texi - -gcc.dvi: $(TEXI_GCC_FILES) - $(TEXI2DVI) -I $(docdir) -I $(docdir)/include $(docdir)/gcc.texi - -gccint.dvi: $(TEXI_GCCINT_FILES) - $(TEXI2DVI) -I $(docdir) -I $(docdir)/include $(docdir)/gccint.texi +%.dvi: $(docdir)/%.texi + $(TEXI2DVI) -I $(docdir) -I $(docdir)/include $< -gccinstall.dvi: $(TEXI_GCCINSTALL_FILES) +gccinstall.dvi: s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ $(TEXI2DVI) -I $$s/doc -I $$s/doc/include -o $@ $$s/doc/install.texi -cppinternals.dvi: $(TEXI_CPPINT_FILES) - $(TEXI2DVI) -I $(docdir) -I $(docdir)/include $(docdir)/cppinternals.texi - generated-manpages: $(docobjdir)/gcov.1 $(docobjdir)/cpp.1 $(docobjdir)/gcc.1 \ - $(docobjdir)/gfdl.7 $(docobjdir)/gpl.7 $(docobjdir)/fsf-funding.7 \ - lang.generated-manpages - -$(docobjdir)/gcov.1: $(docdir)/gcov.texi stmp-docobjdir - $(STAMP) $(docobjdir)/gcov.1 - -$(TEXI2POD) $(docdir)/gcov.texi > gcov.pod - -($(POD2MAN) --section=1 gcov.pod > $(docobjdir)/gcov.1.T$$$$ && \ - mv -f $(docobjdir)/gcov.1.T$$$$ $(docobjdir)/gcov.1) || \ - (rm -f $(docobjdir)/gcov.1.T$$$$ && exit 1) - -rm -f gcov.pod + $(docobjdir)/gfdl.7 $(docobjdir)/gpl.7 $(docobjdir)/fsf-funding.7 \ + lang.generated-manpages +$(docobjdir)/gcov.1: $(docdir)/gcov.texi $(docobjdir)/cpp.1: $(docdir)/cpp.texi $(docdir)/cppenv.texi \ - $(docdir)/cppopts.texi stmp-docobjdir - $(STAMP) $(docobjdir)/cpp.1 - -$(TEXI2POD) $(docdir)/cpp.texi > cpp.pod - -($(POD2MAN) --section=1 cpp.pod > $(docobjdir)/cpp.1.T$$$$ && \ - mv -f $(docobjdir)/cpp.1.T$$$$ $(docobjdir)/cpp.1) || \ - (rm -f $(docobjdir)/cpp.1.T$$$$ && exit 1) - -rm -f cpp.pod - + $(docdir)/cppopts.texi $(docobjdir)/gcc.1: $(docdir)/invoke.texi $(docdir)/cppenv.texi \ - $(docdir)/cppopts.texi stmp-docobjdir - $(STAMP) $(docobjdir)/gcc.1 - -$(TEXI2POD) $(docdir)/invoke.texi > gcc.pod - -($(POD2MAN) --section=1 gcc.pod > $(docobjdir)/gcc.1.T$$$$ && \ - mv -f $(docobjdir)/gcc.1.T$$$$ $(docobjdir)/gcc.1) || \ - (rm -f $(docobjdir)/gcc.1.T$$$$ && exit 1) - -rm -f gcc.pod - -$(docobjdir)/gfdl.7: $(docdir)/include/fdl.texi stmp-docobjdir - $(STAMP) $(docobjdir)/gfdl.7 - -$(TEXI2POD) $(docdir)/include/fdl.texi > gfdl.pod - -($(POD2MAN) --section=7 gfdl.pod > $(docobjdir)/gfdl.7.T$$$$ && \ - mv -f $(docobjdir)/gfdl.7.T$$$$ $(docobjdir)/gfdl.7) || \ - (rm -f $(docobjdir)/gfdl.7.T$$$$ && exit 1) - -rm -f gfdl.pod - -$(docobjdir)/gpl.7: $(docdir)/include/gpl.texi stmp-docobjdir - $(STAMP) $(docobjdir)/gpl.7 - -$(TEXI2POD) $(docdir)/include/gpl.texi > gpl.pod - -($(POD2MAN) --section=7 gpl.pod > $(docobjdir)/gpl.7.T$$$$ && \ - mv -f $(docobjdir)/gpl.7.T$$$$ $(docobjdir)/gpl.7) || \ - (rm -f $(docobjdir)/gpl.7.T$$$$ && exit 1) - -rm -f gpl.pod - -$(docobjdir)/fsf-funding.7: $(docdir)/include/funding.texi stmp-docobjdir - $(STAMP) $(docobjdir)/fsf-funding.7 - -$(TEXI2POD) $(docdir)/include/funding.texi > fsf-funding.pod - -($(POD2MAN) --section=7 fsf-funding.pod \ - > $(docobjdir)/fsf-funding.7.T$$$$ && \ - mv -f $(docobjdir)/fsf-funding.7.T$$$$ $(docobjdir)/fsf-funding.7) || \ - (rm -f $(docobjdir)/fsf-funding.7.T$$$$ && exit 1) - -rm -f fsf-funding.pod + $(docdir)/cppopts.texi +$(docobjdir)/gfdl.7: $(docdir)/include/fdl.texi +$(docobjdir)/gpl.7: $(docdir)/include/gpl.texi +$(docobjdir)/fsf-funding.7: $(docdir)/include/funding.texi + +$(docobjdir)/%.1: $(docdir)/%.texi stmp-docobjdir + $(STAMP) $@ + -$(TEXI2POD) $< > $(basename $(notdir $@)).pod + -($(POD2MAN) --section=1 \ + $(basename $(notdir $@)).pod > $(@).T$$$$ && \ + mv -f $(@).T$$$$ $@) || \ + (rm -f $(@).T$$$$ && exit 1) + -rm -f $(basename $(notdir $@)).pod + +$(docobjdir)/%.7: $(docdir)/%.texi stmp-docobjdir + $(STAMP) $@ + -$(TEXI2POD) $< > $(basename $(notdir $@)).pod + -($(POD2MAN) --section=7 \ + $(basename $(notdir $@)).pod > $(@).T$$$$ && \ + mv -f $(@).T$$$$ $@) || \ + (rm -f $(@).T$$$$ && exit 1) + -rm -f $(basename $(notdir $@)).pod # # Deletion of files made during compilation. @@ -3319,7 +3220,7 @@ -rm -f $@ sed '/set tmpdir/ s|testsuite|$(TESTSUITEDIR)|' < site.exp > $@ -check-g++: $(TESTSUITEDIR)/site.exp +check-g++ check-gcc check-g77 check-objc: check-% : $(TESTSUITEDIR)/site.exp -(rootme=`${PWD_COMMAND}`; export rootme; \ srcdir=`cd ${srcdir}; ${PWD_COMMAND}` ; export srcdir ; \ cd $(TESTSUITEDIR); \ @@ -3327,37 +3228,7 @@ if [ -f $${rootme}/../expect/expect ] ; then \ TCL_LIBRARY=`cd .. ; cd ${srcdir}/../tcl/library ; ${PWD_COMMAND}` ; \ export TCL_LIBRARY ; fi ; \ - $(RUNTEST) --tool g++ $(RUNTESTFLAGS)) - -check-gcc: $(TESTSUITEDIR)/site.exp - -(rootme=`${PWD_COMMAND}`; export rootme; \ - srcdir=`cd ${srcdir}; ${PWD_COMMAND}` ; export srcdir ; \ - cd $(TESTSUITEDIR); \ - EXPECT=${EXPECT} ; export EXPECT ; \ - if [ -f $${rootme}/../expect/expect ] ; then \ - TCL_LIBRARY=`cd .. ; cd ${srcdir}/../tcl/library ; ${PWD_COMMAND}` ; \ - export TCL_LIBRARY ; fi ; \ - $(RUNTEST) --tool gcc $(RUNTESTFLAGS)) - -check-g77: $(TESTSUITEDIR)/site.exp - -(rootme=`${PWD_COMMAND}`; export rootme; \ - srcdir=`cd ${srcdir}; ${PWD_COMMAND}` ; export srcdir ; \ - cd $(TESTSUITEDIR); \ - EXPECT=${EXPECT} ; export EXPECT ; \ - if [ -f $${rootme}/../expect/expect ] ; then \ - TCL_LIBRARY=`cd .. ; cd ${srcdir}/../tcl/library ; ${PWD_COMMAND}` ; \ - export TCL_LIBRARY ; fi ; \ - $(RUNTEST) --tool g77 $(RUNTESTFLAGS)) - -check-objc: $(TESTSUITEDIR)/site.exp - -(rootme=`${PWD_COMMAND}`; export rootme; \ - srcdir=`cd ${srcdir}; ${PWD_COMMAND}` ; export srcdir ; \ - cd $(TESTSUITEDIR); \ - EXPECT=${EXPECT} ; export EXPECT ; \ - if [ -f $${rootme}/../expect/expect ] ; then \ - TCL_LIBRARY=`cd .. ; cd ${srcdir}/../tcl/library ; ${PWD_COMMAND}` ; \ - export TCL_LIBRARY ; fi ; \ - $(RUNTEST) --tool objc $(RUNTESTFLAGS)) + $(RUNTEST) --tool $* $(RUNTESTFLAGS)) check-consistency: testsuite/site.exp -rootme=`${PWD_COMMAND}`; export rootme; \ @@ -3607,22 +3478,22 @@ echo $${stage}_build > stage_last restage1: unstage1 - $(MAKE) stage1_build + $(MAKE) $(REMAKEFLAGS) stage1_build restage2: unstage2 - $(MAKE) LANGUAGES="$(LANGUAGES)" stage2_build + $(MAKE) $(REMAKEFLAGS) stage2_build restage3: unstage3 - $(MAKE) LANGUAGES="$(LANGUAGES)" stage3_build + $(MAKE) $(REMAKEFLAGS) stage3_build restage4: unstage4 - $(MAKE) LANGUAGES="$(LANGUAGES)" stage4_build + $(MAKE) $(REMAKEFLAGS) stage4_build restageprofile: unstageprofile - $(MAKE) LANGUAGES="$(LANGUAGES)" stageprofile_build + $(MAKE) $(REMAKEFLAGS) stageprofile_build restagefeedback: unstagefeedback - $(MAKE) LANGUAGES="$(LANGUAGES)" stagefeedback_build + $(MAKE) $(REMAKEFLAGS) stagefeedback_build # Bubble up a bugfix through all the stages. Primarily useful for fixing # bugs that cause the compiler to crash while building stage 2. @@ -3630,31 +3501,31 @@ if test -f stage_last; then \ LAST=`sed -e 's/_build//' < stage_last`; \ if test "$$LAST" != "stage1"; then \ - $(MAKE) $$LAST; \ + $(MAKE) $(REMAKEFLAGS) $$LAST; \ $(STAMP) $${LAST}_copy; \ fi; \ fi if test -f stage1_copy; then $(MAKE) unstage1; fi - $(MAKE) LANGUAGES="$(LANGUAGES)" stage1_copy + $(MAKE) $(REMAKEFLAGS) stage1_copy if test -f stage2_copy; then $(MAKE) unstage2; fi - $(MAKE) LANGUAGES="$(LANGUAGES)" stage2_copy + $(MAKE) $(REMAKEFLAGS) stage2_copy if test -f stage3_copy; then $(MAKE) unstage3; fi - $(MAKE) LANGUAGES="$(LANGUAGES)" stage3_build + $(MAKE) $(REMAKEFLAGS) stage3_build if test -f stage4_copy; then \ - $(MAKE) stage3_copy; $(MAKE) unstage4; \ - $(MAKE) LANGUAGES="$(LANGUAGES)" stage4_build || exit 1; \ + $(MAKE) $(REMAKEFLAGS) stage3_copy; $(MAKE) unstage4; \ + $(MAKE) $(REMAKEFLAGS) stage4_build || exit 1; \ fi quickstrap: if test -f stage_last ; then \ - LAST=`cat stage_last`; rm $$LAST; $(MAKE) BOOT_CFLAGS="$(BOOT_CFLAGS)" LANGUAGES="$(LANGUAGES)" $$LAST; \ + LAST=`cat stage_last`; rm $$LAST; $(MAKE) $(REMAKEFLAGS) $$LAST; \ else \ - $(MAKE) stage1_build; \ + $(MAKE) $(REMAKEFLAGS) stage1_build; \ fi cleanstrap: -$(MAKE) clean - $(MAKE) LANGUAGES="$(LANGUAGES)" BOOT_CFLAGS="$(BOOT_CFLAGS)" bootstrap + $(MAKE) $(REMAKEFLAGS) bootstrap unstrap: -rm -rf stage[234]* @@ -3665,64 +3536,64 @@ # not from scratch. restrap: $(MAKE) unstrap - $(MAKE) LANGUAGES="$(LANGUAGES)" BOOT_CFLAGS="$(BOOT_CFLAGS)" bootstrap + $(MAKE) $(REMAKEFLAGS) bootstrap -# Compare the object files in the current directory with those in the -# stage2 directory. -# ./ avoids bug in some versions of tail. -slowcompare slowcompare3 slowcompare4 slowcompare-lean slowcompare3-lean slowcompare4-lean: force +# These targets compare the object files in the current directory with +# those in a stage directory. We need to skip the first N bytes of +# each object file. The "slow" mechanism assumes nothing special +# about cmp and uses the tail command to skip. ./ avoids a bug in +# some versions of tail. The "gnu" targets use gnu cmp (diffutils +# v2.4 or later), to avoid running tail and the overhead of twice +# copying each object file. Likewise, the "fast" targets use the skip +# parameter of cmp available on some systems to accomplish the same +# thing. An exit status of 1 is precisely the result we're looking +# for (other values mean other problems). +slowcompare slowcompare3 slowcompare4 slowcompare-lean slowcompare3-lean slowcompare4-lean \ +fastcompare fastcompare3 fastcompare4 fastcompare-lean fastcompare3-lean fastcompare4-lean \ + gnucompare gnucompare3 gnucompare4 gnucompare-lean gnucompare3-lean gnucompare4-lean: force -rm -f .bad_compare - case "$@" in slowcompare | slowcompare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^slowcompare\([0-9][0-9]*\).*,\1,'` ;; esac; \ + case "$@" in *compare | *compare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^[a-z]*compare\([0-9][0-9]*\).*,\1,'` ;; esac; \ for file in *$(objext); do \ - tail +16c ./$$file > tmp-foo1; \ - tail +16c stage$$stage/$$file > tmp-foo2 \ - && (cmp tmp-foo1 tmp-foo2 > /dev/null 2>&1 || echo $$file differs >> .bad_compare) || true; \ - done - case "$@" in slowcompare | slowcompare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^slowcompare\([0-9][0-9]*\).*,\1,'` ;; esac; \ - for dir in tmp-foo $(SUBDIRS); do \ - if [ "`echo $$dir/*$(objext)`" != "$$dir/*$(objext)" ] ; then \ - for file in $$dir/*$(objext); do \ + case "$@" in \ + slowcompare* ) \ tail +16c ./$$file > tmp-foo1; \ tail +16c stage$$stage/$$file > tmp-foo2 \ && (cmp tmp-foo1 tmp-foo2 > /dev/null 2>&1 || echo $$file differs >> .bad_compare) || true; \ - done; \ - else true; fi; \ - done - -rm -f tmp-foo* - case "$@" in slowcompare | slowcompare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^slowcompare\([0-9][0-9]*\).*,\1,'` ;; esac; \ - if [ -f .bad_compare ]; then \ - echo "Bootstrap comparison failure!"; \ - cat .bad_compare; \ - exit 1; \ - else \ - case "$@" in \ - *-lean ) rm -rf stage$$stage ;; \ - *) ;; \ - esac; true; \ - fi - -# Compare the object files in the current directory with those in the -# stage2 directory. Use gnu cmp (diffutils v2.4 or later) to avoid -# running tail and the overhead of twice copying each object file. -# An exit status of 1 is precisely the result we're looking for (other -# values mean other problems). -gnucompare gnucompare3 gnucompare4 gnucompare-lean gnucompare3-lean gnucompare4-lean: force - -rm -f .bad_compare - case "$@" in gnucompare | gnucompare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^gnucompare\([0-9][0-9]*\).*,\1,'` ;; esac; \ - for file in *$(objext); do \ - cmp --ignore-initial=16 $$file stage$$stage/$$file > /dev/null 2>&1; \ - test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \ + ;; \ + fastcompare* ) \ + cmp $$file stage$$stage/$$file 16 16 > /dev/null 2>&1; \ + test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \ + ;; \ + gnucompare* ) \ + cmp --ignore-initial=16 $$file stage$$stage/$$file > /dev/null 2>&1; \ + test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \ + ;; \ + esac ; \ done - case "$@" in gnucompare | gnucompare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^gnucompare\([0-9][0-9]*\).*,\1,'` ;; esac; \ + case "$@" in *compare | *compare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^[a-z]*compare\([0-9][0-9]*\).*,\1,'` ;; esac; \ for dir in tmp-foo $(SUBDIRS); do \ if [ "`echo $$dir/*$(objext)`" != "$$dir/*$(objext)" ] ; then \ for file in $$dir/*$(objext); do \ - cmp --ignore-initial=16 $$file stage$$stage/$$file > /dev/null 2>&1; \ - test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \ + case "$@" in \ + slowcompare* ) \ + tail +16c ./$$file > tmp-foo1; \ + tail +16c stage$$stage/$$file > tmp-foo2 \ + && (cmp tmp-foo1 tmp-foo2 > /dev/null 2>&1 || echo $$file differs >> .bad_compare) || true; \ + ;; \ + fastcompare* ) \ + cmp $$file stage$$stage/$$file 16 16 > /dev/null 2>&1; \ + test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \ + ;; \ + gnucompare* ) \ + cmp --ignore-initial=16 $$file stage$$stage/$$file > /dev/null 2>&1; \ + test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \ + ;; \ + esac ; \ done; \ else true; fi; \ done - case "$@" in gnucompare | gnucompare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^gnucompare\([0-9][0-9]*\).*,\1,'` ;; esac; \ + -rm -f tmp-foo* + case "$@" in *compare | *compare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^[a-z]*compare\([0-9][0-9]*\).*,\1,'` ;; esac; \ if [ -f .bad_compare ]; then \ echo "Bootstrap comparison failure!"; \ cat .bad_compare; \ @@ -3730,6 +3601,7 @@ else \ case "$@" in \ *-lean ) rm -rf stage$$stage ;; \ + *) ;; \ esac; true; \ fi Index: gcc-3.4/gcc/alias.c diff -u gcc-3.4/gcc/alias.c:1.2 gcc-3.4/gcc/alias.c:1.3 --- gcc-3.4/gcc/alias.c:1.2 Thu Jan 8 17:03:26 2004 +++ gcc-3.4/gcc/alias.c Thu Feb 5 10:05:44 2004 @@ -111,7 +111,7 @@ static tree decl_for_component_ref (tree); static rtx adjust_offset_for_component_ref (tree, rtx); static int nonoverlapping_memrefs_p (rtx, rtx); -static int write_dependence_p (rtx, rtx, int); +static int write_dependence_p (rtx, rtx, int, int); static int nonlocal_mentioned_p_1 (rtx *, void *); static int nonlocal_mentioned_p (rtx); @@ -891,10 +891,8 @@ { rtx temp = find_base_value (XEXP (src, 0)); -#ifdef POINTERS_EXTEND_UNSIGNED - if (temp != 0 && CONSTANT_P (temp) && GET_MODE (temp) != Pmode) + if (temp != 0 && CONSTANT_P (temp)) temp = convert_memory_address (Pmode, temp); -#endif return temp; } @@ -1310,10 +1308,8 @@ { rtx temp = find_base_term (XEXP (x, 0)); -#ifdef POINTERS_EXTEND_UNSIGNED - if (temp != 0 && CONSTANT_P (temp) && GET_MODE (temp) != Pmode) + if (temp != 0 && CONSTANT_P (temp)) temp = convert_memory_address (Pmode, temp); -#endif return temp; } @@ -2205,10 +2201,11 @@ } /* Returns nonzero if a write to X might alias a previous read from - (or, if WRITEP is nonzero, a write to) MEM. */ + (or, if WRITEP is nonzero, a write to) MEM. If CONSTP is nonzero, + honor the RTX_UNCHANGING_P flags on X and MEM. */ static int -write_dependence_p (rtx mem, rtx x, int writep) +write_dependence_p (rtx mem, rtx x, int writep, int constp) { rtx x_addr, mem_addr; rtx fixed_scalar; @@ -2227,15 +2224,18 @@ if (DIFFERENT_ALIAS_SETS_P (x, mem)) return 0; - /* Unchanging memory can't conflict with non-unchanging memory. */ - if (RTX_UNCHANGING_P (x) != RTX_UNCHANGING_P (mem)) - return 0; + if (constp) + { + /* Unchanging memory can't conflict with non-unchanging memory. */ + if (RTX_UNCHANGING_P (x) != RTX_UNCHANGING_P (mem)) + return 0; - /* If MEM is an unchanging read, then it can't possibly conflict with - the store to X, because there is at most one store to MEM, and it must - have occurred somewhere before MEM. */ - if (! writep && RTX_UNCHANGING_P (mem)) - return 0; + /* If MEM is an unchanging read, then it can't possibly conflict with + the store to X, because there is at most one store to MEM, and it + must have occurred somewhere before MEM. */ + if (! writep && RTX_UNCHANGING_P (mem)) + return 0; + } if (nonoverlapping_memrefs_p (x, mem)) return 0; @@ -2276,7 +2276,7 @@ int anti_dependence (rtx mem, rtx x) { - return write_dependence_p (mem, x, /*writep=*/0); + return write_dependence_p (mem, x, /*writep=*/0, /*constp*/1); } /* Output dependence: X is written after store in MEM takes place. */ @@ -2284,7 +2284,16 @@ int output_dependence (rtx mem, rtx x) { - return write_dependence_p (mem, x, /*writep=*/1); + return write_dependence_p (mem, x, /*writep=*/1, /*constp*/1); +} + +/* Unchanging anti dependence: Like anti_dependence but ignores + the UNCHANGING_RTX_P property on const variable references. */ + +int +unchanging_anti_dependence (rtx mem, rtx x) +{ + return write_dependence_p (mem, x, /*writep=*/0, /*constp*/0); } /* A subroutine of nonlocal_mentioned_p, returns 1 if *LOC mentions Index: gcc-3.4/gcc/builtins.c diff -u gcc-3.4/gcc/builtins.c:1.2 gcc-3.4/gcc/builtins.c:1.3 --- gcc-3.4/gcc/builtins.c:1.2 Fri Jan 9 10:54:24 2004 +++ gcc-3.4/gcc/builtins.c Thu Feb 5 10:05:44 2004 @@ -79,11 +79,6 @@ required to implement the function call in all cases. */ tree implicit_built_in_decls[(int) END_BUILTINS]; -/* Trigonometric and mathematical constants used in builtin folding. */ -static bool builtin_dconsts_init = 0; -static REAL_VALUE_TYPE dconstpi; -static REAL_VALUE_TYPE dconste; - static int get_pointer_alignment (tree, unsigned int); static tree c_strlen (tree, int); static const char *c_getstr (tree); @@ -157,27 +152,12 @@ static bool readonly_data_expr (tree); static rtx expand_builtin_fabs (tree, rtx, rtx); static rtx expand_builtin_cabs (tree, rtx); -static void init_builtin_dconsts (void); static tree fold_builtin_cabs (tree, tree, tree); static tree fold_builtin_trunc (tree); static tree fold_builtin_floor (tree); static tree fold_builtin_ceil (tree); static tree fold_builtin_bitop (tree); -/* Initialize mathematical constants for constant folding builtins. - These constants need to be given to at least 160 bits precision. */ - -static void -init_builtin_dconsts (void) -{ - real_from_string (&dconstpi, - "3.1415926535897932384626433832795028841971693993751058209749445923078"); - real_from_string (&dconste, - "2.7182818284590452353602874713526624977572470936999595749669676277241"); - - builtin_dconsts_init = true; -} - /* Return the alignment in bits of EXP, a pointer valued expression. But don't return more than MAX_ALIGN no matter what. The alignment returned is, by default, the alignment of the thing that @@ -497,10 +477,7 @@ if (setjmp_alias_set == -1) setjmp_alias_set = new_alias_set (); -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (buf_addr) != Pmode) - buf_addr = convert_memory_address (Pmode, buf_addr); -#endif + buf_addr = convert_memory_address (Pmode, buf_addr); buf_addr = force_reg (Pmode, force_operand (buf_addr, NULL_RTX)); @@ -639,10 +616,11 @@ expand_builtin_setjmp_setup (buf_addr, next_lab); - /* Set TARGET to zero and branch to the continue label. */ + /* Set TARGET to zero and branch to the continue label. Use emit_jump to + ensure that pending stack adjustments are flushed. */ emit_move_insn (target, const0_rtx); - emit_jump_insn (gen_jump (cont_lab)); - emit_barrier (); + emit_jump (cont_lab); + emit_label (next_lab); expand_builtin_setjmp_receiver (next_lab); @@ -680,10 +658,7 @@ if (setjmp_alias_set == -1) setjmp_alias_set = new_alias_set (); -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (buf_addr) != Pmode) - buf_addr = convert_memory_address (Pmode, buf_addr); -#endif + buf_addr = convert_memory_address (Pmode, buf_addr); buf_addr = force_reg (Pmode, buf_addr); @@ -826,10 +801,7 @@ insn_data[(int) CODE_FOR_prefetch].operand[0].mode)) || (GET_MODE (op0) != Pmode)) { -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (op0) != Pmode) - op0 = convert_memory_address (Pmode, op0); -#endif + op0 = convert_memory_address (Pmode, op0); op0 = force_reg (Pmode, op0); } emit_insn (gen_prefetch (op0, op1, op2)); @@ -852,10 +824,7 @@ rtx addr = expand_expr (exp, NULL_RTX, ptr_mode, EXPAND_SUM); rtx mem; -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (addr) != Pmode) - addr = convert_memory_address (Pmode, addr); -#endif + addr = convert_memory_address (Pmode, addr); mem = gen_rtx_MEM (BLKmode, memory_address (BLKmode, addr)); @@ -940,7 +909,7 @@ /* The second value is the structure value address unless this is passed as an "invisible" first argument. */ - if (struct_value_rtx) + if (targetm.calls.struct_value_rtx (cfun ? TREE_TYPE (cfun->decl) : 0, 0)) size += GET_MODE_SIZE (Pmode); for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) @@ -1115,6 +1084,7 @@ rtx registers; int size, align, regno; enum machine_mode mode; + rtx struct_incoming_value = targetm.calls.struct_value_rtx (cfun ? TREE_TYPE (cfun->decl) : 0, 1); /* Create a block where the arg-pointer, structure value address, and argument registers can be saved. */ @@ -1122,7 +1092,7 @@ /* Walk past the arg-pointer and structure value address. */ size = GET_MODE_SIZE (Pmode); - if (struct_value_rtx) + if (targetm.calls.struct_value_rtx (cfun ? TREE_TYPE (cfun->decl) : 0, 0)) size += GET_MODE_SIZE (Pmode); /* Save each register used in calling a function to the block. */ @@ -1148,10 +1118,10 @@ /* Save the structure value address unless this is passed as an "invisible" first argument. */ - if (struct_value_incoming_rtx) + if (struct_incoming_value) { emit_move_insn (adjust_address (registers, Pmode, size), - copy_to_reg (struct_value_incoming_rtx)); + copy_to_reg (struct_incoming_value)); size += GET_MODE_SIZE (Pmode); } @@ -1209,11 +1179,9 @@ rtx incoming_args, result, reg, dest, src, call_insn; rtx old_stack_level = 0; rtx call_fusage = 0; + rtx struct_value = targetm.calls.struct_value_rtx (cfun ? TREE_TYPE (cfun->decl) : 0, 0); -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (arguments) != Pmode) - arguments = convert_memory_address (Pmode, arguments); -#endif + arguments = convert_memory_address (Pmode, arguments); /* Create a block where the return registers can be saved. */ result = assign_stack_local (BLKmode, apply_result_size (), -1); @@ -1262,7 +1230,7 @@ /* Walk past the arg-pointer and structure value address. */ size = GET_MODE_SIZE (Pmode); - if (struct_value_rtx) + if (struct_value) size += GET_MODE_SIZE (Pmode); /* Restore each of the registers previously saved. Make USE insns @@ -1282,13 +1250,13 @@ /* Restore the structure value address unless this is passed as an "invisible" first argument. */ size = GET_MODE_SIZE (Pmode); - if (struct_value_rtx) + if (struct_value) { rtx value = gen_reg_rtx (Pmode); emit_move_insn (value, adjust_address (arguments, Pmode, size)); - emit_move_insn (struct_value_rtx, value); - if (GET_CODE (struct_value_rtx) == REG) - use_reg (&call_fusage, struct_value_rtx); + emit_move_insn (struct_value, value); + if (GET_CODE (struct_value) == REG) + use_reg (&call_fusage, struct_value); size += GET_MODE_SIZE (Pmode); } @@ -1351,7 +1319,8 @@ OK_DEFER_POP; /* Return the address of the result block. */ - return copy_addr_to_reg (XEXP (result, 0)); + result = copy_addr_to_reg (XEXP (result, 0)); + return convert_memory_address (ptr_mode, result); } /* Perform an untyped return. */ @@ -1364,10 +1333,7 @@ rtx reg; rtx call_fusage = 0; -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (result) != Pmode) - result = convert_memory_address (Pmode, result); -#endif + result = convert_memory_address (Pmode, result); apply_result_size (); result = gen_rtx_MEM (BLKmode, result); @@ -1462,7 +1428,11 @@ /* We have taken care of the easy cases during constant folding. This case is not obvious, so emit (constant_p_rtx (ARGLIST)) and let CSE - get a chance to see if it can deduce whether ARGLIST is constant. */ + get a chance to see if it can deduce whether ARGLIST is constant. + If CSE isn't going to run, of course, don't bother waiting. */ + + if (cse_not_expected) + return const0_rtx; current_function_calls_constant_p = 1; @@ -1490,18 +1460,79 @@ switch (fn) { + CASE_MATHFN (BUILT_IN_ACOS) + CASE_MATHFN (BUILT_IN_ACOSH) + CASE_MATHFN (BUILT_IN_ASIN) + CASE_MATHFN (BUILT_IN_ASINH) CASE_MATHFN (BUILT_IN_ATAN) + CASE_MATHFN (BUILT_IN_ATAN2) + CASE_MATHFN (BUILT_IN_ATANH) + CASE_MATHFN (BUILT_IN_CBRT) CASE_MATHFN (BUILT_IN_CEIL) + CASE_MATHFN (BUILT_IN_COPYSIGN) CASE_MATHFN (BUILT_IN_COS) + CASE_MATHFN (BUILT_IN_COSH) + CASE_MATHFN (BUILT_IN_DREM) + CASE_MATHFN (BUILT_IN_ERF) + CASE_MATHFN (BUILT_IN_ERFC) CASE_MATHFN (BUILT_IN_EXP) + CASE_MATHFN (BUILT_IN_EXP10) + CASE_MATHFN (BUILT_IN_EXP2) + CASE_MATHFN (BUILT_IN_EXPM1) + CASE_MATHFN (BUILT_IN_FABS) + CASE_MATHFN (BUILT_IN_FDIM) CASE_MATHFN (BUILT_IN_FLOOR) + CASE_MATHFN (BUILT_IN_FMA) + CASE_MATHFN (BUILT_IN_FMAX) + CASE_MATHFN (BUILT_IN_FMIN) + CASE_MATHFN (BUILT_IN_FMOD) + CASE_MATHFN (BUILT_IN_FREXP) + CASE_MATHFN (BUILT_IN_GAMMA) + CASE_MATHFN (BUILT_IN_HUGE_VAL) + CASE_MATHFN (BUILT_IN_HYPOT) + CASE_MATHFN (BUILT_IN_ILOGB) + CASE_MATHFN (BUILT_IN_INF) + CASE_MATHFN (BUILT_IN_J0) + CASE_MATHFN (BUILT_IN_J1) + CASE_MATHFN (BUILT_IN_JN) + CASE_MATHFN (BUILT_IN_LDEXP) + CASE_MATHFN (BUILT_IN_LGAMMA) + CASE_MATHFN (BUILT_IN_LLRINT) + CASE_MATHFN (BUILT_IN_LLROUND) CASE_MATHFN (BUILT_IN_LOG) + CASE_MATHFN (BUILT_IN_LOG10) + CASE_MATHFN (BUILT_IN_LOG1P) + CASE_MATHFN (BUILT_IN_LOG2) + CASE_MATHFN (BUILT_IN_LOGB) + CASE_MATHFN (BUILT_IN_LRINT) + CASE_MATHFN (BUILT_IN_LROUND) + CASE_MATHFN (BUILT_IN_MODF) + CASE_MATHFN (BUILT_IN_NAN) + CASE_MATHFN (BUILT_IN_NANS) CASE_MATHFN (BUILT_IN_NEARBYINT) + CASE_MATHFN (BUILT_IN_NEXTAFTER) + CASE_MATHFN (BUILT_IN_NEXTTOWARD) + CASE_MATHFN (BUILT_IN_POW) + CASE_MATHFN (BUILT_IN_POW10) + CASE_MATHFN (BUILT_IN_REMAINDER) + CASE_MATHFN (BUILT_IN_REMQUO) + CASE_MATHFN (BUILT_IN_RINT) CASE_MATHFN (BUILT_IN_ROUND) + CASE_MATHFN (BUILT_IN_SCALB) + CASE_MATHFN (BUILT_IN_SCALBLN) + CASE_MATHFN (BUILT_IN_SCALBN) + CASE_MATHFN (BUILT_IN_SIGNIFICAND) CASE_MATHFN (BUILT_IN_SIN) + CASE_MATHFN (BUILT_IN_SINCOS) + CASE_MATHFN (BUILT_IN_SINH) CASE_MATHFN (BUILT_IN_SQRT) CASE_MATHFN (BUILT_IN_TAN) + CASE_MATHFN (BUILT_IN_TANH) + CASE_MATHFN (BUILT_IN_TGAMMA) CASE_MATHFN (BUILT_IN_TRUNC) + CASE_MATHFN (BUILT_IN_Y0) + CASE_MATHFN (BUILT_IN_Y1) + CASE_MATHFN (BUILT_IN_YN) default: return 0; @@ -2473,10 +2504,7 @@ builtin_memcpy_read_str, (void *) src_str, dest_align, 0); dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX); -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (dest_mem) != ptr_mode) - dest_mem = convert_memory_address (ptr_mode, dest_mem); -#endif + dest_mem = convert_memory_address (ptr_mode, dest_mem); return dest_mem; } @@ -2490,10 +2518,7 @@ if (dest_addr == 0) { dest_addr = force_operand (XEXP (dest_mem, 0), NULL_RTX); -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (dest_addr) != ptr_mode) - dest_addr = convert_memory_address (ptr_mode, dest_addr); -#endif + dest_addr = convert_memory_address (ptr_mode, dest_addr); } return dest_addr; } @@ -2572,10 +2597,7 @@ builtin_memcpy_read_str, (void *) src_str, dest_align, endp); dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX); -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (dest_mem) != ptr_mode) - dest_mem = convert_memory_address (ptr_mode, dest_mem); -#endif + dest_mem = convert_memory_address (ptr_mode, dest_mem); return dest_mem; } @@ -2590,10 +2612,7 @@ dest_mem = move_by_pieces (dest_mem, src_mem, INTVAL (len_rtx), MIN (dest_align, src_align), endp); dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX); -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (dest_mem) != ptr_mode) - dest_mem = convert_memory_address (ptr_mode, dest_mem); -#endif + dest_mem = convert_memory_address (ptr_mode, dest_mem); return dest_mem; } @@ -2829,10 +2848,7 @@ builtin_strncpy_read_str, (void *) p, dest_align, 0); dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX); -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (dest_mem) != ptr_mode) - dest_mem = convert_memory_address (ptr_mode, dest_mem); -#endif + dest_mem = convert_memory_address (ptr_mode, dest_mem); return dest_mem; } @@ -2950,10 +2966,7 @@ builtin_memset_gen_str, val_rtx, dest_align, 0); dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX); -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (dest_mem) != ptr_mode) - dest_mem = convert_memory_address (ptr_mode, dest_mem); -#endif + dest_mem = convert_memory_address (ptr_mode, dest_mem); return dest_mem; } @@ -2974,10 +2987,7 @@ builtin_memset_read_str, &c, dest_align, 0); dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX); -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (dest_mem) != ptr_mode) - dest_mem = convert_memory_address (ptr_mode, dest_mem); -#endif + dest_mem = convert_memory_address (ptr_mode, dest_mem); return dest_mem; } @@ -2990,10 +3000,7 @@ if (dest_addr == 0) { dest_addr = force_operand (XEXP (dest_mem, 0), NULL_RTX); -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (dest_addr) != ptr_mode) - dest_addr = convert_memory_address (ptr_mode, dest_addr); -#endif + dest_addr = convert_memory_address (ptr_mode, dest_addr); } return dest_addr; @@ -3662,21 +3669,8 @@ start_sequence (); -#ifdef EXPAND_BUILTIN_SAVEREGS /* Do whatever the machine needs done in this case. */ - val = EXPAND_BUILTIN_SAVEREGS (); -#else - /* ??? We used to try and build up a call to the out of line function, - guessing about what registers needed saving etc. This became much - harder with __builtin_va_start, since we don't have a tree for a - call to __builtin_saveregs to fall back on. There was exactly one - port (i860) that used this code, and I'm unconvinced it could actually - handle the general case. So we no longer try to handle anything - weird and make the backend absorb the evil. */ - - error ("__builtin_saveregs not supported by this target"); - val = const0_rtx; -#endif + val = targetm.calls.expand_builtin_saveregs (); seq = get_insns (); end_sequence (); @@ -4004,10 +3998,7 @@ #endif } -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (addr) != Pmode) - addr = convert_memory_address (Pmode, addr); -#endif + addr = convert_memory_address (Pmode, addr); result = gen_rtx_MEM (TYPE_MODE (type), addr); set_mem_alias_set (result, get_varargs_alias_set ()); @@ -4066,13 +4057,8 @@ size = expand_expr (TYPE_SIZE_UNIT (va_list_type_node), NULL_RTX, VOIDmode, EXPAND_NORMAL); -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (dstb) != Pmode) - dstb = convert_memory_address (Pmode, dstb); - - if (GET_MODE (srcb) != Pmode) - srcb = convert_memory_address (Pmode, srcb); -#endif + dstb = convert_memory_address (Pmode, dstb); + srcb = convert_memory_address (Pmode, srcb); /* "Dereference" to BLKmode memories. */ dstb = gen_rtx_MEM (BLKmode, dstb); @@ -4155,11 +4141,7 @@ /* Allocate the desired space. */ result = allocate_dynamic_stack_space (op0, target, BITS_PER_UNIT); - -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (result) != ptr_mode) - result = convert_memory_address (ptr_mode, result); -#endif + result = convert_memory_address (ptr_mode, result); return result; } @@ -5409,15 +5391,14 @@ && TREE_CODE (TREE_OPERAND (arglist, 0)) == STRING_CST)) return integer_one_node; - /* If we aren't going to be running CSE or this expression - has side effects, show we don't know it to be a constant. - Likewise if it's a pointer or aggregate type since in those - case we only want literals, since those are only optimized + /* If this expression has side effects, show we don't know it to be a + constant. Likewise if it's a pointer or aggregate type since in + those case we only want literals, since those are only optimized when generating RTL, not later. And finally, if we are compiling an initializer, not code, we need to return a definite result now; there's not going to be any more optimization done. */ - if (TREE_SIDE_EFFECTS (arglist) || cse_not_expected + if (TREE_SIDE_EFFECTS (arglist) || AGGREGATE_TYPE_P (TREE_TYPE (arglist)) || POINTER_TYPE_P (TREE_TYPE (arglist)) || cfun == 0) @@ -5664,6 +5645,8 @@ { tree rpart, ipart, result, arglist; + arg = save_expr (arg); + rpart = fold (build1 (REALPART_EXPR, type, arg)); ipart = fold (build1 (IMAGPART_EXPR, type, arg)); @@ -5883,6 +5866,216 @@ return NULL_TREE; } +/* Return true if EXPR is the real constant contained in VALUE. */ + +static bool +real_dconstp (tree expr, const REAL_VALUE_TYPE *value) +{ + STRIP_NOPS (expr); + + return ((TREE_CODE (expr) == REAL_CST + && ! TREE_CONSTANT_OVERFLOW (expr) + && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), *value)) + || (TREE_CODE (expr) == COMPLEX_CST + && real_dconstp (TREE_REALPART (expr), value) + && real_zerop (TREE_IMAGPART (expr)))); +} + +/* A subroutine of fold_builtin to fold the various logarithmic + functions. EXP is the CALL_EXPR of a call to a builtin log* + function. VALUE is the base of the log* function. */ + +static tree +fold_builtin_logarithm (tree exp, const REAL_VALUE_TYPE *value) +{ + tree arglist = TREE_OPERAND (exp, 1); + + if (validate_arglist (arglist, REAL_TYPE, VOID_TYPE)) + { + tree fndecl = get_callee_fndecl (exp); + tree type = TREE_TYPE (TREE_TYPE (fndecl)); + tree arg = TREE_VALUE (arglist); + const enum built_in_function fcode = builtin_mathfn_code (arg); + + /* Optimize log*(1.0) = 0.0. */ + if (real_onep (arg)) + return build_real (type, dconst0); + + /* Optimize logN(N) = 1.0. If N can't be truncated to MODE + exactly, then only do this if flag_unsafe_math_optimizations. */ + if (exact_real_truncate (TYPE_MODE (type), value) + || flag_unsafe_math_optimizations) + { + const REAL_VALUE_TYPE value_truncate = + real_value_truncate (TYPE_MODE (type), *value); + if (real_dconstp (arg, &value_truncate)) + return build_real (type, dconst1); + } + + /* Special case, optimize logN(expN(x)) = x. */ + if (flag_unsafe_math_optimizations + && ((value == &dconste + && (fcode == BUILT_IN_EXP + || fcode == BUILT_IN_EXPF + || fcode == BUILT_IN_EXPL)) + || (value == &dconst2 + && (fcode == BUILT_IN_EXP2 + || fcode == BUILT_IN_EXP2F + || fcode == BUILT_IN_EXP2L)) + || (value == &dconst10 + && (fcode == BUILT_IN_EXP10 + || fcode == BUILT_IN_EXP10F + || fcode == BUILT_IN_EXP10L)))) + return convert (type, TREE_VALUE (TREE_OPERAND (arg, 1))); + + /* Optimize log*(func()) for various exponential functions. We + want to determine the value "x" and the power "exponent" in + order to transform logN(x**exponent) into exponent*logN(x). */ + if (flag_unsafe_math_optimizations) + { + tree exponent = 0, x = 0; + + switch (fcode) + { + case BUILT_IN_EXP: + case BUILT_IN_EXPF: + case BUILT_IN_EXPL: + /* Prepare to do logN(exp(exponent) -> exponent*logN(e). */ + x = build_real (type, + real_value_truncate (TYPE_MODE (type), dconste)); + exponent = TREE_VALUE (TREE_OPERAND (arg, 1)); + break; + case BUILT_IN_EXP2: + case BUILT_IN_EXP2F: + case BUILT_IN_EXP2L: + /* Prepare to do logN(exp2(exponent) -> exponent*logN(2). */ + x = build_real (type, dconst2); + exponent = TREE_VALUE (TREE_OPERAND (arg, 1)); + break; + case BUILT_IN_EXP10: + case BUILT_IN_EXP10F: + case BUILT_IN_EXP10L: + case BUILT_IN_POW10: + case BUILT_IN_POW10F: + case BUILT_IN_POW10L: + /* Prepare to do logN(exp10(exponent) -> exponent*logN(10). */ + x = build_real (type, dconst10); + exponent = TREE_VALUE (TREE_OPERAND (arg, 1)); + break; + case BUILT_IN_SQRT: + case BUILT_IN_SQRTF: + case BUILT_IN_SQRTL: + /* Prepare to do logN(sqrt(x) -> 0.5*logN(x). */ + x = TREE_VALUE (TREE_OPERAND (arg, 1)); + exponent = build_real (type, dconsthalf); + break; + case BUILT_IN_CBRT: + case BUILT_IN_CBRTF: + case BUILT_IN_CBRTL: + /* Prepare to do logN(cbrt(x) -> (1/3)*logN(x). */ + x = TREE_VALUE (TREE_OPERAND (arg, 1)); + exponent = build_real (type, real_value_truncate (TYPE_MODE (type), + dconstthird)); + break; + case BUILT_IN_POW: + case BUILT_IN_POWF: + case BUILT_IN_POWL: + /* Prepare to do logN(pow(x,exponent) -> exponent*logN(x). */ + x = TREE_VALUE (TREE_OPERAND (arg, 1)); + exponent = TREE_VALUE (TREE_CHAIN (TREE_OPERAND (arg, 1))); + break; + default: + break; + } + + /* Now perform the optimization. */ + if (x && exponent) + { + tree logfn; + arglist = build_tree_list (NULL_TREE, x); + logfn = build_function_call_expr (fndecl, arglist); + return fold (build (MULT_EXPR, type, exponent, logfn)); + } + } + } + + return 0; +} + +/* A subroutine of fold_builtin to fold the various exponent + functions. EXP is the CALL_EXPR of a call to a builtin function. + VALUE is the value which will be raised to a power. */ + +static tree +fold_builtin_exponent (tree exp, const REAL_VALUE_TYPE *value) +{ + tree arglist = TREE_OPERAND (exp, 1); + + if (validate_arglist (arglist, REAL_TYPE, VOID_TYPE)) + { + tree fndecl = get_callee_fndecl (exp); + tree type = TREE_TYPE (TREE_TYPE (fndecl)); + tree arg = TREE_VALUE (arglist); + + /* Optimize exp*(0.0) = 1.0. */ + if (real_zerop (arg)) + return build_real (type, dconst1); + + /* Optimize expN(1.0) = N. */ + if (real_onep (arg)) + { + REAL_VALUE_TYPE cst; + + real_convert (&cst, TYPE_MODE (type), value); + return build_real (type, cst); + } + + /* Attempt to evaluate expN(integer) at compile-time. */ + if (flag_unsafe_math_optimizations + && TREE_CODE (arg) == REAL_CST + && ! TREE_CONSTANT_OVERFLOW (arg)) + { + REAL_VALUE_TYPE cint; + REAL_VALUE_TYPE c; + HOST_WIDE_INT n; + + c = TREE_REAL_CST (arg); + n = real_to_integer (&c); + real_from_integer (&cint, VOIDmode, n, + n < 0 ? -1 : 0, 0); + if (real_identical (&c, &cint)) + { + REAL_VALUE_TYPE x; + + real_powi (&x, TYPE_MODE (type), value, n); + return build_real (type, x); + } + } + + /* Optimize expN(logN(x)) = x. */ + if (flag_unsafe_math_optimizations) + { + const enum built_in_function fcode = builtin_mathfn_code (arg); + + if ((value == &dconste + && (fcode == BUILT_IN_LOG + || fcode == BUILT_IN_LOGF + || fcode == BUILT_IN_LOGL)) + || (value == &dconst2 + && (fcode == BUILT_IN_LOG2 + || fcode == BUILT_IN_LOG2F + || fcode == BUILT_IN_LOG2L)) + || (value == &dconst10 + && (fcode == BUILT_IN_LOG10 + || fcode == BUILT_IN_LOG10F + || fcode == BUILT_IN_LOG10L))) + return convert (type, TREE_VALUE (TREE_OPERAND (arg, 1))); + } + } + + return 0; +} + /* Used by constant folding to eliminate some builtin calls early. EXP is the CALL_EXPR of a call to a builtin function. */ @@ -6020,107 +6213,32 @@ case BUILT_IN_EXP: case BUILT_IN_EXPF: case BUILT_IN_EXPL: - if (validate_arglist (arglist, REAL_TYPE, VOID_TYPE)) - { - enum built_in_function fcode; - tree arg = TREE_VALUE (arglist); - - /* Optimize exp(0.0) = 1.0. */ - if (real_zerop (arg)) - return build_real (type, dconst1); - - /* Optimize exp(1.0) = e. */ - if (real_onep (arg)) - { - REAL_VALUE_TYPE cst; - - if (! builtin_dconsts_init) - init_builtin_dconsts (); - real_convert (&cst, TYPE_MODE (type), &dconste); - return build_real (type, cst); - } - - /* Attempt to evaluate exp at compile-time. */ - if (flag_unsafe_math_optimizations - && TREE_CODE (arg) == REAL_CST - && ! TREE_CONSTANT_OVERFLOW (arg)) - { - REAL_VALUE_TYPE cint; - REAL_VALUE_TYPE c; - HOST_WIDE_INT n; - - c = TREE_REAL_CST (arg); - n = real_to_integer (&c); - real_from_integer (&cint, VOIDmode, n, - n < 0 ? -1 : 0, 0); - if (real_identical (&c, &cint)) - { - REAL_VALUE_TYPE x; - - if (! builtin_dconsts_init) - init_builtin_dconsts (); - real_powi (&x, TYPE_MODE (type), &dconste, n); - return build_real (type, x); - } - } - - /* Optimize exp(log(x)) = x. */ - fcode = builtin_mathfn_code (arg); - if (flag_unsafe_math_optimizations - && (fcode == BUILT_IN_LOG - || fcode == BUILT_IN_LOGF - || fcode == BUILT_IN_LOGL)) - return TREE_VALUE (TREE_OPERAND (arg, 1)); - } - break; - + return fold_builtin_exponent (exp, &dconste); + case BUILT_IN_EXP2: + case BUILT_IN_EXP2F: + case BUILT_IN_EXP2L: + return fold_builtin_exponent (exp, &dconst2); + case BUILT_IN_EXP10: + case BUILT_IN_EXP10F: + case BUILT_IN_EXP10L: + case BUILT_IN_POW10: + case BUILT_IN_POW10F: + case BUILT_IN_POW10L: + return fold_builtin_exponent (exp, &dconst10); case BUILT_IN_LOG: case BUILT_IN_LOGF: case BUILT_IN_LOGL: - if (validate_arglist (arglist, REAL_TYPE, VOID_TYPE)) - { - enum built_in_function fcode; - tree arg = TREE_VALUE (arglist); - - /* Optimize log(1.0) = 0.0. */ - if (real_onep (arg)) - return build_real (type, dconst0); - - /* Optimize log(exp(x)) = x. */ - fcode = builtin_mathfn_code (arg); - if (flag_unsafe_math_optimizations - && (fcode == BUILT_IN_EXP - || fcode == BUILT_IN_EXPF - || fcode == BUILT_IN_EXPL)) - return TREE_VALUE (TREE_OPERAND (arg, 1)); - - /* Optimize log(sqrt(x)) = log(x)*0.5. */ - if (flag_unsafe_math_optimizations - && (fcode == BUILT_IN_SQRT - || fcode == BUILT_IN_SQRTF - || fcode == BUILT_IN_SQRTL)) - { - tree logfn = build_function_call_expr (fndecl, - TREE_OPERAND (arg, 1)); - return fold (build (MULT_EXPR, type, logfn, - build_real (type, dconsthalf))); - } - - /* Optimize log(pow(x,y)) = y*log(x). */ - if (flag_unsafe_math_optimizations - && (fcode == BUILT_IN_POW - || fcode == BUILT_IN_POWF - || fcode == BUILT_IN_POWL)) - { - tree arg0, arg1, logfn; - - arg0 = TREE_VALUE (TREE_OPERAND (arg, 1)); - arg1 = TREE_VALUE (TREE_CHAIN (TREE_OPERAND (arg, 1))); - arglist = build_tree_list (NULL_TREE, arg0); - logfn = build_function_call_expr (fndecl, arglist); - return fold (build (MULT_EXPR, type, arg1, logfn)); - } - } + return fold_builtin_logarithm (exp, &dconste); + break; + case BUILT_IN_LOG2: + case BUILT_IN_LOG2F: + case BUILT_IN_LOG2L: + return fold_builtin_logarithm (exp, &dconst2); + break; + case BUILT_IN_LOG10: + case BUILT_IN_LOG10F: + case BUILT_IN_LOG10L: + return fold_builtin_logarithm (exp, &dconst10); break; case BUILT_IN_TAN: @@ -6161,8 +6279,6 @@ { REAL_VALUE_TYPE cst; - if (! builtin_dconsts_init) - init_builtin_dconsts (); real_convert (&cst, TYPE_MODE (type), &dconstpi); cst.exp -= 2; return build_real (type, cst); Index: gcc-3.4/gcc/c-common.c diff -u gcc-3.4/gcc/c-common.c:1.2 gcc-3.4/gcc/c-common.c:1.3 --- gcc-3.4/gcc/c-common.c:1.2 Thu Jan 8 17:03:26 2004 +++ gcc-3.4/gcc/c-common.c Thu Feb 5 10:05:44 2004 @@ -430,6 +430,10 @@ int warn_nonnull; +/* Warn about old-style parameter declaration. */ + +int warn_old_style_definition; + /* ObjC language option variables. */ @@ -770,6 +774,8 @@ static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *); static tree handle_nothrow_attribute (tree *, tree, tree, int, bool *); static tree handle_cleanup_attribute (tree *, tree, tree, int, bool *); +static tree handle_warn_unused_result_attribute (tree *, tree, tree, int, + bool *); static tree vector_size_helper (tree, tree); static void check_function_nonnull (tree, tree); @@ -847,6 +853,8 @@ { "may_alias", 0, 0, false, true, false, NULL }, { "cleanup", 1, 1, true, false, false, handle_cleanup_attribute }, + { "warn_unused_result", 0, 0, false, true, true, + handle_warn_unused_result_attribute }, { NULL, 0, 0, false, false, false, NULL } }; @@ -1072,16 +1080,18 @@ const char * fname_as_string (int pretty_p) { - const char *name = NULL; + const char *name = "top level"; + int vrb = 2; + + if (! pretty_p) + { + name = ""; + vrb = 0; + } + + if (current_function_decl) + name = (*lang_hooks.decl_printable_name) (current_function_decl, vrb); - if (pretty_p) - name = (current_function_decl - ? (*lang_hooks.decl_printable_name) (current_function_decl, 2) - : "top level"); - else if (current_function_decl && DECL_NAME (current_function_decl)) - name = IDENTIFIER_POINTER (DECL_NAME (current_function_decl)); - else - name = ""; return name; } @@ -1131,8 +1141,7 @@ input_line = saved_lineno; } if (!ix && !current_function_decl) - pedwarn ("%H'%D' is not defined outside of function scope", - &DECL_SOURCE_LOCATION (decl), decl); + pedwarn ("%J'%D' is not defined outside of function scope", decl, decl); return decl; } @@ -1854,6 +1863,9 @@ if (mode == TYPE_MODE (long_double_type_node)) return long_double_type_node; + if (mode == TYPE_MODE (void_type_node)) + return void_type_node; + if (mode == TYPE_MODE (build_pointer_type (char_type_node))) return unsignedp ? make_unsigned_type (mode) : make_signed_type (mode); @@ -1974,36 +1986,56 @@ || TREE_UNSIGNED (type) == unsignedp) return type; - if (TYPE_PRECISION (type) == TYPE_PRECISION (signed_char_type_node)) + /* Must check the mode of the types, not the precision. Enumeral types + in C++ have precision set to match their range, but may use a wider + mode to match an ABI. If we change modes, we may wind up with bad + conversions. */ + + if (TYPE_MODE (type) == TYPE_MODE (signed_char_type_node)) return unsignedp ? unsigned_char_type_node : signed_char_type_node; - if (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)) + if (TYPE_MODE (type) == TYPE_MODE (integer_type_node)) return unsignedp ? unsigned_type_node : integer_type_node; - if (TYPE_PRECISION (type) == TYPE_PRECISION (short_integer_type_node)) + if (TYPE_MODE (type) == TYPE_MODE (short_integer_type_node)) return unsignedp ? short_unsigned_type_node : short_integer_type_node; - if (TYPE_PRECISION (type) == TYPE_PRECISION (long_integer_type_node)) + if (TYPE_MODE (type) == TYPE_MODE (long_integer_type_node)) return unsignedp ? long_unsigned_type_node : long_integer_type_node; - if (TYPE_PRECISION (type) == TYPE_PRECISION (long_long_integer_type_node)) + if (TYPE_MODE (type) == TYPE_MODE (long_long_integer_type_node)) return (unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node); - if (TYPE_PRECISION (type) == TYPE_PRECISION (widest_integer_literal_type_node)) + if (TYPE_MODE (type) == TYPE_MODE (widest_integer_literal_type_node)) return (unsignedp ? widest_unsigned_literal_type_node : widest_integer_literal_type_node); #if HOST_BITS_PER_WIDE_INT >= 64 - if (TYPE_PRECISION (type) == TYPE_PRECISION (intTI_type_node)) + if (TYPE_MODE (type) == TYPE_MODE (intTI_type_node)) return unsignedp ? unsigned_intTI_type_node : intTI_type_node; #endif - if (TYPE_PRECISION (type) == TYPE_PRECISION (intDI_type_node)) + if (TYPE_MODE (type) == TYPE_MODE (intDI_type_node)) return unsignedp ? unsigned_intDI_type_node : intDI_type_node; - if (TYPE_PRECISION (type) == TYPE_PRECISION (intSI_type_node)) + if (TYPE_MODE (type) == TYPE_MODE (intSI_type_node)) return unsignedp ? unsigned_intSI_type_node : intSI_type_node; - if (TYPE_PRECISION (type) == TYPE_PRECISION (intHI_type_node)) + if (TYPE_MODE (type) == TYPE_MODE (intHI_type_node)) return unsignedp ? unsigned_intHI_type_node : intHI_type_node; - if (TYPE_PRECISION (type) == TYPE_PRECISION (intQI_type_node)) + if (TYPE_MODE (type) == TYPE_MODE (intQI_type_node)) return unsignedp ? unsigned_intQI_type_node : intQI_type_node; return type; } + +/* The C version of the register_builtin_type langhook. */ + +void +c_register_builtin_type (tree type, const char* name) +{ + tree decl; + + decl = build_decl (TYPE_DECL, get_identifier (name), type); + DECL_ARTIFICIAL (decl) = 1; + if (!TYPE_NAME (type)) + TYPE_NAME (type) = decl; + pushdecl (decl); +} + /* Return the minimum number of bits needed to represent VALUE in a signed or unsigned type, UNSIGNEDP says which. */ @@ -2654,8 +2686,6 @@ case NEGATE_EXPR: case ABS_EXPR: case FLOAT_EXPR: - case FFS_EXPR: - case POPCOUNT_EXPR: /* These don't change whether an object is nonzero or zero. */ return c_common_truthvalue_conversion (TREE_OPERAND (expr, 0)); @@ -3948,19 +3978,17 @@ if (high_value) { error ("duplicate (or overlapping) case value"); - error ("%Hthis is the first entry overlapping that value", - &DECL_SOURCE_LOCATION (duplicate)); + error ("%Jthis is the first entry overlapping that value", duplicate); } else if (low_value) { error ("duplicate case value") ; - error ("%Hpreviously used here", &DECL_SOURCE_LOCATION (duplicate)); + error ("%Jpreviously used here", duplicate); } else { error ("multiple default labels in one switch"); - error ("%Hthis is the first default label", - &DECL_SOURCE_LOCATION (duplicate)); + error ("%Jthis is the first default label", duplicate); } if (!cases->root) add_stmt (build_case_label (NULL_TREE, NULL_TREE, label)); @@ -4021,6 +4049,26 @@ bool preserve_result = false; bool return_target = false; + if (STMT_EXPR_WARN_UNUSED_RESULT (exp) && target == const0_rtx) + { + tree stmt = STMT_EXPR_STMT (exp); + tree scope; + + for (scope = COMPOUND_BODY (stmt); + scope && TREE_CODE (scope) != SCOPE_STMT; + scope = TREE_CHAIN (scope)); + + if (scope && SCOPE_STMT_BLOCK (scope)) + warning ("%Hignoring return value of `%D', " + "declared with attribute warn_unused_result", + &expr_wfl_stack->location, + BLOCK_ABSTRACT_ORIGIN (SCOPE_STMT_BLOCK (scope))); + else + warning ("%Hignoring return value of function " + "declared with attribute warn_unused_result", + &expr_wfl_stack->location); + } + /* Since expand_expr_stmt calls free_temp_slots after every expression statement, we must call push_temp_slots here. Otherwise, any temporaries in use now would be considered @@ -4241,7 +4289,7 @@ }; warning (msgs[msgcode], name); - warning ("%Hshadowed declaration is here", &DECL_SOURCE_LOCATION (decl)); + warning ("%Jshadowed declaration is here", decl); } /* Attribute handlers common to C front ends. */ @@ -4682,8 +4730,8 @@ && current_function_decl != NULL_TREE && ! TREE_STATIC (decl)) { - error ("%Hsection attribute cannot be specified for " - "local variables", &DECL_SOURCE_LOCATION (decl)); + error ("%Jsection attribute cannot be specified for " + "local variables", decl); *no_add_attrs = true; } @@ -4693,8 +4741,8 @@ && strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)), TREE_STRING_POINTER (TREE_VALUE (args))) != 0) { - error ("%Hsection of '%D' conflicts with previous declaration", - &DECL_SOURCE_LOCATION (*node), *node); + error ("%Jsection of '%D' conflicts with previous declaration", + *node, *node); *no_add_attrs = true; } else @@ -4702,15 +4750,13 @@ } else { - error ("%Hsection attribute not allowed for '%D'", - &DECL_SOURCE_LOCATION (*node), *node); + error ("%Jsection attribute not allowed for '%D'", *node, *node); *no_add_attrs = true; } } else { - error ("%Hsection attributes are not supported for this target", - &DECL_SOURCE_LOCATION (*node)); + error ("%Jsection attributes are not supported for this target", *node); *no_add_attrs = true; } @@ -4784,8 +4830,7 @@ else if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FIELD_DECL) { - error ("%Halignment may not be specified for '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jalignment may not be specified for '%D'", decl, decl); *no_add_attrs = true; } else @@ -4823,8 +4868,7 @@ if ((TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl)) || (TREE_CODE (decl) != FUNCTION_DECL && ! DECL_EXTERNAL (decl))) { - error ("%H'%D' defined both normally and as an alias", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%J'%D' defined both normally and as an alias", decl, decl); *no_add_attrs = true; } else if (decl_function_context (decl) == 0) @@ -4948,14 +4992,12 @@ if (TREE_CODE (decl) != FUNCTION_DECL) { - error ("%H'%E' attribute applies only to functions", - &DECL_SOURCE_LOCATION (decl), name); + error ("%J'%E' attribute applies only to functions", decl, name); *no_add_attrs = true; } else if (DECL_INITIAL (decl)) { - error ("%Hcan't set '%E' attribute after definition", - &DECL_SOURCE_LOCATION (decl), name); + error ("%Jcan't set '%E' attribute after definition", decl, name); *no_add_attrs = true; } else @@ -4996,14 +5038,12 @@ if (TREE_CODE (decl) != FUNCTION_DECL) { - error ("%H'%E' attribute applies only to functions", - &DECL_SOURCE_LOCATION (decl), name); + error ("%J'%E' attribute applies only to functions", decl, name); *no_add_attrs = true; } else if (DECL_INITIAL (decl)) { - error ("%Hcan't set '%E' attribute after definition", - &DECL_SOURCE_LOCATION (decl), name); + error ("%Jcan't set '%E' attribute after definition", decl, name); *no_add_attrs = true; } else @@ -5507,6 +5547,23 @@ /* That the function has proper type is checked with the eventual call to build_function_call. */ + + return NULL_TREE; +} + +/* Handle a "warn_unused_result" attribute. No special handling. */ + +static tree +handle_warn_unused_result_attribute (tree *node, tree name, + tree args ATTRIBUTE_UNUSED, + int flags ATTRIBUTE_UNUSED, bool *no_add_attrs) +{ + /* Ignore the attribute for functions not returning any value. */ + if (VOID_TYPE_P (TREE_TYPE (*node))) + { + warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name)); + *no_add_attrs = true; + } return NULL_TREE; } Index: gcc-3.4/gcc/c-common.h diff -u gcc-3.4/gcc/c-common.h:1.2 gcc-3.4/gcc/c-common.h:1.3 --- gcc-3.4/gcc/c-common.h:1.2 Thu Jan 8 17:03:26 2004 +++ gcc-3.4/gcc/c-common.h Thu Feb 5 10:05:44 2004 @@ -44,6 +44,7 @@ 2: STMT_LINENO_FOR_FN_P (in _STMT) 3: SCOPE_NO_CLEANUPS_P (in SCOPE_STMT) COMPOUND_STMT_BODY_BLOCK (in COMPOUND_STMT) + STMT_EXPR_WARN_UNUSED_RESULT (in STMT_EXPR) 4: SCOPE_PARTIAL_P (in SCOPE_STMT) */ @@ -595,6 +596,10 @@ extern int warn_nonnull; +/* Warn about old-style parameter declaration. */ + +extern int warn_old_style_definition; + /* ObjC language option variables. */ @@ -952,6 +957,7 @@ extern void c_common_finish (void); extern void c_common_parse_file (int); extern HOST_WIDE_INT c_common_get_alias_set (tree); +extern void c_register_builtin_type (tree, const char*); extern bool c_promoting_integer_type_p (tree); extern int self_promoting_args_p (tree); extern tree strip_array_types (tree); @@ -1052,6 +1058,11 @@ /* Nonzero if this statement-expression does not have an associated scope. */ #define STMT_EXPR_NO_SCOPE(NODE) \ TREE_LANG_FLAG_0 (STMT_EXPR_CHECK (NODE)) + +/* Nonzero if this statement-expression should cause warning if its result + is not used. */ +#define STMT_EXPR_WARN_UNUSED_RESULT(NODE) \ + TREE_LANG_FLAG_3 (STMT_EXPR_CHECK (NODE)) /* LABEL_STMT accessor. This gives access to the label associated with the given label statement. */ Index: gcc-3.4/gcc/c-decl.c diff -u gcc-3.4/gcc/c-decl.c:1.2 gcc-3.4/gcc/c-decl.c:1.3 --- gcc-3.4/gcc/c-decl.c:1.2 Thu Jan 8 17:03:26 2004 +++ gcc-3.4/gcc/c-decl.c Thu Feb 5 10:05:44 2004 @@ -187,7 +187,7 @@ the end of the list on each insertion, or reverse the lists later, we maintain a pointer to the last list entry for each of the lists. - The order of the tags, shadowed, shadowed_tags, and incomplete + The order of the tags, shadowed, and shadowed_tags lists does not matter, so we just prepend to these lists. */ struct c_scope GTY(()) @@ -227,9 +227,6 @@ tree blocks; tree blocks_last; - /* Variable declarations with incomplete type in this scope. */ - tree incomplete; - /* True if we are currently filling this scope with parameter declarations. */ bool parm_flag : 1; @@ -372,8 +369,7 @@ && ! DECL_EXTERNAL (decl) && TYPE_DOMAIN (type) == 0) { - warning ("%Harray '%D' assumed to have one element", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jarray '%D' assumed to have one element", decl, decl); complete_array_type (type, NULL_TREE, 1); @@ -510,7 +506,8 @@ tree decl; tree p; - scope->function_body |= functionbody; + /* The following line does not use |= due to a bug in HP's C compiler */ + scope->function_body = scope->function_body | functionbody; if (keep == KEEP_MAYBE) keep = (scope->names || scope->tags); @@ -543,22 +540,20 @@ for (p = scope->names; p; p = TREE_CHAIN (p)) { - const location_t *locus = &DECL_SOURCE_LOCATION (p); - switch (TREE_CODE (p)) { case LABEL_DECL: if (TREE_USED (p) && !DECL_INITIAL (p)) { - error ("%Hlabel `%D' used but not defined", locus, p); + error ("%Jlabel `%D' used but not defined", p, p); DECL_INITIAL (p) = error_mark_node; } else if (!TREE_USED (p) && warn_unused_label) { if (DECL_INITIAL (p)) - warning ("%Hlabel `%D' defined but not used", locus, p); + warning ("%Jlabel `%D' defined but not used", p, p); else - warning ("%Hlabel `%D' declared but not defined", locus, p); + warning ("%Jlabel `%D' declared but not defined", p, p); } IDENTIFIER_LABEL_VALUE (DECL_NAME (p)) = 0; @@ -583,7 +578,7 @@ && !DECL_IN_SYSTEM_HEADER (p) && DECL_NAME (p) && !DECL_ARTIFICIAL (p)) - warning ("%Hunused variable `%D'", locus, p); + warning ("%Junused variable `%D'", p, p); /* fall through */ default: @@ -780,10 +775,8 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, int different_tu) { - int comptype_flags = (different_tu ? COMPARE_DIFFERENT_TU - : COMPARE_STRICT); int types_match = comptypes (TREE_TYPE (newdecl), TREE_TYPE (olddecl), - comptype_flags); + COMPARE_STRICT); int new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL && DECL_INITIAL (newdecl) != 0); tree oldtype = TREE_TYPE (olddecl); @@ -809,20 +802,19 @@ && DECL_UNINLINABLE (olddecl) && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl))) { - warning ("%Hfunction '%D' redeclared as inline", - &DECL_SOURCE_LOCATION (newdecl), newdecl); - warning ("%Hprevious declaration of function '%D' " - "with attribute noinline", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + warning ("%Jfunction '%D' redeclared as inline", + newdecl, newdecl); + warning ("%Jprevious declaration of function '%D' " + "with attribute noinline", olddecl, olddecl); } else if (DECL_DECLARED_INLINE_P (olddecl) && DECL_UNINLINABLE (newdecl) && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl))) { - warning ("%Hfunction '%D' redeclared with attribute noinline", - &DECL_SOURCE_LOCATION (newdecl), newdecl); - warning ("%Hprevious declaration of function '%D' was inline", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + warning ("%Jfunction '%D' redeclared with attribute noinline", + newdecl, newdecl); + warning ("%Jprevious declaration of function '%D' was inline", + olddecl, olddecl); } } @@ -848,19 +840,18 @@ if (!TREE_PUBLIC (newdecl)) { if (warn_shadow) - warning ("%Hshadowing built-in function '%D'", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + warning ("%Jshadowing built-in function '%D'", + newdecl, newdecl); } else - warning ("%Hbuilt-in function '%D' declared as non-function", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + warning ("%Jbuilt-in function '%D' declared as non-function", + newdecl, newdecl); } else { - error ("%H'%D' redeclared as different kind of symbol", - &DECL_SOURCE_LOCATION (newdecl), newdecl); - error ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + error ("%J'%D' redeclared as different kind of symbol", + newdecl, newdecl); + error ("%Jprevious declaration of '%D'", olddecl, olddecl); } return 0; @@ -889,8 +880,7 @@ built-in definition is overridden, but optionally warn this was a bad choice of name. */ if (warn_shadow) - warning ("%Hshadowing built-in function '%D'", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + warning ("%Jshadowing built-in function '%D'", newdecl, newdecl); /* Discard the old built-in function. */ return 0; } @@ -902,7 +892,7 @@ if (trytype) { - types_match = comptypes (newtype, trytype, comptype_flags); + types_match = comptypes (newtype, trytype, COMPARE_STRICT); if (types_match) oldtype = trytype; if (! different_binding_level) @@ -912,8 +902,8 @@ if (!types_match) { /* If types don't match for a built-in, throw away the built-in. */ - warning ("%Hconflicting types for built-in function '%D'", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + warning ("%Jconflicting types for built-in function '%D'", + newdecl, newdecl); return 0; } } @@ -956,8 +946,7 @@ && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (oldtype))) == void_type_node))) { if (pedantic) - pedwarn ("%Hconflicting types for '%D'", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + pedwarn ("%Jconflicting types for '%D'", newdecl, newdecl); /* Make sure we keep void * as ret type, not char *. */ if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (oldtype))) == void_type_node) TREE_TYPE (newdecl) = newtype = oldtype; @@ -975,8 +964,7 @@ && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == integer_type_node && C_FUNCTION_IMPLICIT_INT (newdecl)) { - pedwarn ("%Hconflicting types for '%D'", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + pedwarn ("%Jconflicting types for '%D'", newdecl, newdecl); /* Make sure we keep void as the return type. */ TREE_TYPE (newdecl) = newtype = oldtype; C_FUNCTION_IMPLICIT_INT (newdecl) = 0; @@ -988,16 +976,15 @@ && ! pedantic /* Return types must still match. */ && comptypes (TREE_TYPE (oldtype), - TREE_TYPE (newtype), comptype_flags) + TREE_TYPE (newtype), COMPARE_STRICT) && TYPE_ARG_TYPES (newtype) == 0)) { - error ("%Hconflicting types for '%D'", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + error ("%Jconflicting types for '%D'", newdecl, newdecl); /* Check for function type mismatch involving an empty arglist vs a nonempty one. */ if (TREE_CODE (olddecl) == FUNCTION_DECL && comptypes (TREE_TYPE (oldtype), - TREE_TYPE (newtype), comptype_flags) + TREE_TYPE (newtype), COMPARE_STRICT) && ((TYPE_ARG_TYPES (oldtype) == 0 && DECL_INITIAL (olddecl) == 0) || @@ -1027,11 +1014,9 @@ } } if (C_DECL_IMPLICIT (olddecl)) - error ("%Hprevious implicit declaration of '%D'", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + error ("%Jprevious implicit declaration of '%D'", olddecl, olddecl); else - error ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + error ("%Jprevious declaration of '%D'", olddecl, olddecl); /* This is safer because the initializer might contain references to variables that were declared between olddecl and newdecl. This @@ -1044,62 +1029,54 @@ else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL && !DECL_THREAD_LOCAL (olddecl) && DECL_THREAD_LOCAL (newdecl)) { - error ("%Hthread-local declaration of '%D' follows non thread-local " - "declaration", &DECL_SOURCE_LOCATION (newdecl), newdecl); - error ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + error ("%Jthread-local declaration of '%D' follows non thread-local " + "declaration", newdecl, newdecl); + error ("%Jprevious declaration of '%D'", olddecl, olddecl); } /* non-TLS declaration cannot follow TLS declaration. */ else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL && DECL_THREAD_LOCAL (olddecl) && !DECL_THREAD_LOCAL (newdecl)) { - error ("%Hnon thread-local declaration of '%D' follows " - "thread-local declaration", - &DECL_SOURCE_LOCATION (newdecl), newdecl); - error ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + error ("%Jnon thread-local declaration of '%D' follows " + "thread-local declaration", newdecl, newdecl); + error ("%Jprevious declaration of '%D'", olddecl, olddecl); } else { errmsg = redeclaration_error_message (newdecl, olddecl); if (errmsg) { - const location_t *locus = &DECL_SOURCE_LOCATION (newdecl); switch (errmsg) { case 1: - error ("%Hredefinition of '%D'", locus, newdecl); + error ("%Jredefinition of '%D'", newdecl, newdecl); break; case 2: - error ("%Hredeclaration of '%D'", locus, newdecl); + error ("%Jredeclaration of '%D'", newdecl, newdecl); break; case 3: - error ("%Hconflicting declarations of '%D'", locus, newdecl); + error ("%Jconflicting declarations of '%D'", newdecl, newdecl); break; default: abort (); } - locus = &DECL_SOURCE_LOCATION (olddecl); if (DECL_INITIAL (olddecl) && current_scope == global_scope) - error ("%H'%D' previously defined here", locus, olddecl); + error ("%J'%D' previously defined here", olddecl, olddecl); else - error ("%H'%D' previously declared here", locus, olddecl); + error ("%J'%D' previously declared here", olddecl, olddecl); return 0; } else if (TREE_CODE (newdecl) == TYPE_DECL && (DECL_IN_SYSTEM_HEADER (olddecl) || DECL_IN_SYSTEM_HEADER (newdecl))) { - const location_t *locus = &DECL_SOURCE_LOCATION (newdecl); - warning ("%Hredefinition of '%D'", locus, newdecl); - locus = &DECL_SOURCE_LOCATION (olddecl); - if (DECL_INITIAL (olddecl) - && current_scope == global_scope) - warning ("%H'%D' previously defined here", locus, olddecl); + warning ("%Jredefinition of '%D'", newdecl, newdecl); + if (DECL_INITIAL (olddecl) && current_scope == global_scope) + warning ("%J'%D' previously defined here", olddecl, olddecl); else - warning ("%H'%D' previously declared here", locus, olddecl); + warning ("%J'%D' previously declared here", olddecl, olddecl); } else if (TREE_CODE (olddecl) == FUNCTION_DECL && DECL_INITIAL (olddecl) != 0 @@ -1120,33 +1097,27 @@ if (TYPE_MAIN_VARIANT (TREE_VALUE (parm)) == void_type_node && TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node) { - const location_t *locus = &DECL_SOURCE_LOCATION (newdecl); - warning ("%Hprototype for '%D' follows", locus, newdecl); - locus = &DECL_SOURCE_LOCATION (olddecl); - warning ("%Hnon-prototype definition here", locus); + warning ("%Jprototype for '%D' follows", newdecl, newdecl); + warning ("%Jnon-prototype definition here", olddecl); break; } if (TYPE_MAIN_VARIANT (TREE_VALUE (parm)) == void_type_node || TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node) { - const location_t *locus = &DECL_SOURCE_LOCATION (newdecl); - error ("%Hprototype for '%D' follows and number of " - "arguments doesn't match", locus, newdecl); - locus = &DECL_SOURCE_LOCATION (olddecl); - error ("%Hnon-prototype definition here", locus); + error ("%Jprototype for '%D' follows and number of " + "arguments doesn't match", newdecl, newdecl); + error ("%Jnon-prototype definition here", olddecl); errmsg = 1; break; } /* Type for passing arg must be consistent with that declared for the arg. */ if (! comptypes (TREE_VALUE (parm), TREE_VALUE (type), - comptype_flags)) + COMPARE_STRICT)) { - const location_t *locus = &DECL_SOURCE_LOCATION (newdecl); - error ("%Hprototype for '%D' follows and argument %d " - "doesn't match", locus, newdecl, nargs); - locus = &DECL_SOURCE_LOCATION (olddecl); - error ("%Hnon-prototype definition here", locus); + error ("%Jprototype for '%D' follows and argument %d " + "doesn't match", newdecl, newdecl, nargs); + error ("%Jnon-prototype definition here", olddecl); errmsg = 1; break; } @@ -1155,30 +1126,28 @@ /* Warn about mismatches in various flags. */ else { - const location_t *locus = &DECL_SOURCE_LOCATION (newdecl); - /* Warn if function is now inline but was previously declared not inline and has been called. */ if (TREE_CODE (olddecl) == FUNCTION_DECL && ! DECL_DECLARED_INLINE_P (olddecl) && DECL_DECLARED_INLINE_P (newdecl) && TREE_USED (olddecl)) - warning ("%H'%D' declared inline after being called", - locus, newdecl); + warning ("%J'%D' declared inline after being called", + newdecl, newdecl); if (TREE_CODE (olddecl) == FUNCTION_DECL && ! DECL_DECLARED_INLINE_P (olddecl) && DECL_DECLARED_INLINE_P (newdecl) && DECL_INITIAL (olddecl) != 0) - warning ("%H'%D' declared inline after its definition", - locus, newdecl); + warning ("%J'%D' declared inline after its definition", + newdecl, newdecl); /* If pedantic, warn when static declaration follows a non-static declaration. Otherwise, do so only for functions. */ if ((pedantic || TREE_CODE (olddecl) == FUNCTION_DECL) && TREE_PUBLIC (olddecl) && !TREE_PUBLIC (newdecl)) - warning ("%Hstatic declaration for '%D' follows non-static", - locus, newdecl); + warning ("%Jstatic declaration for '%D' follows non-static", + newdecl, newdecl); /* If warn_traditional, warn when a non-static function declaration follows a static one. */ @@ -1186,24 +1155,24 @@ && TREE_CODE (olddecl) == FUNCTION_DECL && !TREE_PUBLIC (olddecl) && TREE_PUBLIC (newdecl)) - warning ("%Hnon-static declaration for '%D' follows static", - locus, newdecl); + warning ("%Jnon-static declaration for '%D' follows static", + newdecl, newdecl); /* Warn when const declaration follows a non-const declaration, but not for functions. */ if (TREE_CODE (olddecl) != FUNCTION_DECL && !TREE_READONLY (olddecl) && TREE_READONLY (newdecl)) - warning ("%Hconst declaration for '%D' follows non-const", - locus, newdecl); + warning ("%Jconst declaration for '%D' follows non-const", + newdecl, newdecl); /* These bits are logically part of the type, for variables. But not for functions (where qualifiers are not valid ANSI anyway). */ else if (pedantic && TREE_CODE (olddecl) != FUNCTION_DECL && (TREE_READONLY (newdecl) != TREE_READONLY (olddecl) || TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl))) - pedwarn ("%Htype qualifiers for '%D' conflict with previous " - "declaration", locus, newdecl); + pedwarn ("%Jtype qualifiers for '%D' conflict with previous " + "declaration", newdecl, newdecl); } } @@ -1216,10 +1185,9 @@ /* Don't warn about extern decl followed by (tentative) definition. */ && !(DECL_EXTERNAL (olddecl) && ! DECL_EXTERNAL (newdecl))) { - warning ("%Hredundant redeclaration of '%D' in same scope", - &DECL_SOURCE_LOCATION (newdecl), newdecl); - warning ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (olddecl), olddecl); + warning ("%Jredundant redeclaration of '%D' in same scope", + newdecl, newdecl); + warning ("%Jprevious declaration of '%D'", olddecl, olddecl); } /* Copy all the DECL_... slots specified in the new decl @@ -1574,7 +1542,7 @@ name = IDENTIFIER_POINTER (DECL_NAME (x)); if (TREE_CODE (old) == PARM_DECL) shadow_warning (SW_PARAM, name, old); - else if (C_DECL_FILE_SCOPE (old)) + else if (DECL_FILE_SCOPE_P (old)) shadow_warning (SW_GLOBAL, name, old); else shadow_warning (SW_LOCAL, name, old); @@ -1748,14 +1716,15 @@ IDENTIFIER_SYMBOL_VALUE (name) = x; C_DECL_INVISIBLE (x) = 0; - /* Keep list of variables in this scope with incomplete type. + /* If x's type is incomplete because it's based on a + structure or union which has not yet been fully declared, + attach it to that structure or union type, so we can go + back and complete the variable declaration later, if the + structure or union gets fully declared. + If the input is erroneous, we can have error_mark in the type slot (e.g. "f(void a, ...)") - that doesn't count as an - incomplete type. - - FIXME: Chain these off the TYPE_DECL for the incomplete type, - then we don't have to do (potentially quite costly) searches - in finish_struct. */ + incomplete type. */ if (TREE_TYPE (x) != error_mark_node && !COMPLETE_TYPE_P (TREE_TYPE (x))) { @@ -1763,11 +1732,15 @@ while (TREE_CODE (element) == ARRAY_TYPE) element = TREE_TYPE (element); + element = TYPE_MAIN_VARIANT (element); + if ((TREE_CODE (element) == RECORD_TYPE || TREE_CODE (element) == UNION_TYPE) && (TREE_CODE (x) != TYPE_DECL - || TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE)) - scope->incomplete = tree_cons (NULL_TREE, x, scope->incomplete); + || TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE) + && !COMPLETE_TYPE_P (element)) + C_TYPE_INCOMPLETE_VARS (element) + = tree_cons (NULL_TREE, x, C_TYPE_INCOMPLETE_VARS (element)); } } @@ -1821,9 +1794,8 @@ if (!C_DECL_IMPLICIT (decl)) { implicit_decl_warning (DECL_NAME (decl)); - if (! C_DECL_FILE_SCOPE (decl)) - warning ("%Hprevious declaration of '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + if (! DECL_FILE_SCOPE_P (decl)) + warning ("%Jprevious declaration of '%D'", decl, decl); C_DECL_IMPLICIT (decl) = 1; } /* If this function is global, then it must already be in the @@ -1901,7 +1873,7 @@ return 1; return 0; } - else if (C_DECL_FILE_SCOPE (newdecl)) + else if (DECL_FILE_SCOPE_P (newdecl)) { /* Objects declared at file scope: */ /* If at least one is a reference, it's ok. */ @@ -2058,8 +2030,7 @@ if (dup == label) { error ("duplicate label declaration `%s'", IDENTIFIER_POINTER (name)); - error ("%Hthis is a previous declaration", - &DECL_SOURCE_LOCATION (dup)); + error ("%Jthis is a previous declaration", dup); /* Just use the previous declaration. */ return dup; @@ -2094,12 +2065,11 @@ || (DECL_CONTEXT (label) != current_function_decl && C_DECLARED_LABEL_FLAG (label)))) { - location_t *prev_loc = &DECL_SOURCE_LOCATION (label); error ("%Hduplicate label `%D'", &location, label); if (DECL_INITIAL (label)) - error ("%H`%D' previously defined here", prev_loc, label); + error ("%J`%D' previously defined here", label, label); else - error ("%H`%D' previously declared here", prev_loc, label); + error ("%J`%D' previously declared here", label, label); return 0; } else if (label && DECL_CONTEXT (label) == current_function_decl) @@ -2578,8 +2548,7 @@ if (warn_main > 0 && TREE_CODE (decl) != FUNCTION_DECL && MAIN_NAME_P (DECL_NAME (decl))) - warning ("%H'%D' is usually a function", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%J'%D' is usually a function", decl, decl); if (initialized) /* Is it valid for this decl to have an initializer at all? @@ -2679,11 +2648,30 @@ decl_attributes (&decl, attributes, 0); if (TREE_CODE (decl) == FUNCTION_DECL + && targetm.calls.promote_prototypes (TREE_TYPE (decl))) + { + tree ce = declarator; + + if (TREE_CODE (ce) == INDIRECT_REF) + ce = TREE_OPERAND (declarator, 0); + if (TREE_CODE (ce) == CALL_EXPR) + { + tree args = TREE_PURPOSE (TREE_OPERAND (ce, 1)); + for (; args; args = TREE_CHAIN (args)) + { + tree type = TREE_TYPE (args); + if (INTEGRAL_TYPE_P (type) + && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)) + DECL_ARG_TYPE (args) = integer_type_node; + } + } + } + + if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl) && DECL_UNINLINABLE (decl) && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl))) - warning ("%Hinline function '%D' given attribute noinline", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jinline function '%D' given attribute noinline", decl, decl); /* Add this decl to the current scope. TEM may equal DECL or it may be a previous decl of the same name. */ @@ -2695,7 +2683,7 @@ and we preserved the rtl from the previous one (which may or may not happen). */ && !DECL_RTL_SET_P (tem) - && C_DECL_FILE_SCOPE (tem)) + && DECL_FILE_SCOPE_P (tem)) { if (TREE_TYPE (tem) != error_mark_node && (COMPLETE_TYPE_P (TREE_TYPE (tem)) @@ -2754,14 +2742,12 @@ type = TREE_TYPE (decl); if (failure == 1) - error ("%Hinitializer fails to determine size of '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jinitializer fails to determine size of '%D'", decl, decl); else if (failure == 2) { if (do_default) - error ("%Harray size missing in '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jarray size missing in '%D'", decl, decl); /* If a `static' var's size isn't known, make it extern as well as static, so it does not get allocated. @@ -2777,8 +2763,7 @@ warn only if the value is less than zero. */ else if (pedantic && TYPE_DOMAIN (type) != 0 && tree_int_cst_sgn (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) < 0) - error ("%Hzero or negative size array '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jzero or negative size array '%D'", decl, decl); layout_decl (decl, 0); } @@ -2800,14 +2785,13 @@ Otherwise, let it through, but if it is not `extern' then it may cause an error message later. */ (DECL_INITIAL (decl) != 0 - || !C_DECL_FILE_SCOPE (decl)) + || !DECL_FILE_SCOPE_P (decl)) : /* An automatic variable with an incomplete type is an error. */ !DECL_EXTERNAL (decl))) { - error ("%Hstorage size of '%D' isn't known", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jstorage size of '%D' isn't known", decl, decl); TREE_TYPE (decl) = error_mark_node; } @@ -2817,8 +2801,7 @@ if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST) constant_expression_warning (DECL_SIZE (decl)); else - error ("%Hstorage size of '%D' isn't constant", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jstorage size of '%D' isn't constant", decl, decl); } if (TREE_USED (type)) @@ -2871,7 +2854,7 @@ if (c_dialect_objc ()) objc_check_decl (decl); - if (C_DECL_FILE_SCOPE (decl)) + if (DECL_FILE_SCOPE_P (decl)) { if (DECL_INITIAL (decl) == NULL_TREE || DECL_INITIAL (decl) == error_mark_node) @@ -2901,8 +2884,8 @@ if (TREE_CODE (decl) == VAR_DECL && !DECL_REGISTER (decl) && !TREE_STATIC (decl)) - warning ("%Hignoring asm-specifier for non-static local " - "variable '%D'", &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jignoring asm-specifier for non-static local " + "variable '%D'", decl, decl); else SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec)); } @@ -2911,7 +2894,7 @@ add_decl_stmt (decl); } - if (!C_DECL_FILE_SCOPE (decl)) + if (!DECL_FILE_SCOPE_P (decl)) { /* Recompute the RTL of a local array now if it used to be an incomplete type. */ @@ -2936,7 +2919,7 @@ /* This is a no-op in c-lang.c or something real in objc-act.c. */ if (c_dialect_objc ()) objc_check_decl (decl); - rest_of_decl_compilation (decl, NULL, C_DECL_FILE_SCOPE (decl), 0); + rest_of_decl_compilation (decl, NULL, DECL_FILE_SCOPE_P (decl), 0); } /* At the end of a declaration, throw away any variable type sizes @@ -4387,8 +4370,7 @@ C_DECL_VARIABLE_SIZE (decl) = 1; if (inlinep) - pedwarn ("%Hvariable '%D' declared `inline'", - &DECL_SOURCE_LOCATION (decl), decl); + pedwarn ("%Jvariable '%D' declared `inline'", decl, decl); DECL_EXTERNAL (decl) = extern_ref; @@ -4580,10 +4562,6 @@ declared types. The back end may override this. */ type = TREE_TYPE (decl); DECL_ARG_TYPE (decl) = type; - if (PROMOTE_PROTOTYPES - && INTEGRAL_TYPE_P (type) - && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)) - DECL_ARG_TYPE (decl) = integer_type_node; /* Check for (..., void, ...) and issue an error. */ if (VOID_TYPE_P (type) && !DECL_NAME (decl) && !gave_void_only_once_err) @@ -4605,8 +4583,8 @@ if (!TREE_ASM_WRITTEN (decl)) abort (); - error ("%Hparameter \"%D\" has just a forward declaration", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jparameter \"%D\" has just a forward declaration", + decl, decl); } /* Warn about any struct, union or enum tags defined within this @@ -4842,8 +4820,7 @@ for (y = fieldlist; y != x; y = TREE_CHAIN (y)) if (DECL_NAME (y) == DECL_NAME (x)) { - error ("%Hduplicate member '%D'", - &DECL_SOURCE_LOCATION (x), x); + error ("%Jduplicate member '%D'", x, x); DECL_NAME (x) = NULL_TREE; } } @@ -4859,8 +4836,7 @@ slot = htab_find_slot (htab, y, INSERT); if (*slot) { - error ("%Hduplicate member '%D'", - &DECL_SOURCE_LOCATION (x), x); + error ("%Jduplicate member '%D'", x, x); DECL_NAME (x) = NULL_TREE; } *slot = y; @@ -4961,8 +4937,7 @@ constant_expression_warning (DECL_INITIAL (x)); else { - error ("%Hbit-field '%D' width not an integer constant", - &DECL_SOURCE_LOCATION (x), x); + error ("%Jbit-field '%D' width not an integer constant", x, x); DECL_INITIAL (x) = NULL; } } @@ -4973,8 +4948,7 @@ && TREE_CODE (TREE_TYPE (x)) != BOOLEAN_TYPE && TREE_CODE (TREE_TYPE (x)) != ENUMERAL_TYPE) { - error ("%Hbit-field '%D' has invalid type", - &DECL_SOURCE_LOCATION (x), x); + error ("%Jbit-field '%D' has invalid type", x, x); DECL_INITIAL (x) = NULL; } @@ -4986,8 +4960,7 @@ && !(TREE_CODE (TREE_TYPE (x)) == ENUMERAL_TYPE && (TYPE_PRECISION (TREE_TYPE (x)) == TYPE_PRECISION (integer_type_node)))) - pedwarn ("%Hbit-field '%D' type invalid in ISO C", - &DECL_SOURCE_LOCATION (x), x); + pedwarn ("%Jbit-field '%D' type invalid in ISO C", x, x); /* Detect and ignore out of range field width and process valid field widths. */ @@ -4998,14 +4971,11 @@ ? CHAR_TYPE_SIZE : TYPE_PRECISION (TREE_TYPE (x))); if (tree_int_cst_sgn (DECL_INITIAL (x)) < 0) - error ("%Hnegative width in bit-field '%D'", - &DECL_SOURCE_LOCATION (x), x); + error ("%Jnegative width in bit-field '%D'", x, x); else if (0 < compare_tree_int (DECL_INITIAL (x), max_width)) - pedwarn ("%Hwidth of '%D' exceeds its type", - &DECL_SOURCE_LOCATION (x), x); + pedwarn ("%Jwidth of '%D' exceeds its type", x, x); else if (integer_zerop (DECL_INITIAL (x)) && DECL_NAME (x) != 0) - error ("%Hzero width for bit-field '%D'", - &DECL_SOURCE_LOCATION (x), x); + error ("%Jzero width for bit-field '%D'", x, x); else { /* The test above has assured us that TREE_INT_CST_HIGH is 0. */ @@ -5018,8 +4988,7 @@ || (width < min_precision (TYPE_MAX_VALUE (TREE_TYPE (x)), TREE_UNSIGNED (TREE_TYPE (x)))))) - warning ("%H'%D' is narrower than values of its type", - &DECL_SOURCE_LOCATION (x), x); + warning ("%J'%D' is narrower than values of its type", x, x); DECL_SIZE (x) = bitsize_int (width); DECL_BIT_FIELD (x) = 1; @@ -5036,20 +5005,16 @@ && TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (x))) == NULL_TREE) { if (TREE_CODE (t) == UNION_TYPE) - error ("%Hflexible array member in union", - &DECL_SOURCE_LOCATION (x)); + error ("%Jflexible array member in union", x); else if (TREE_CHAIN (x) != NULL_TREE) - error ("%Hflexible array member not at end of struct", - &DECL_SOURCE_LOCATION (x)); + error ("%Jflexible array member not at end of struct", x); else if (! saw_named_field) - error ("%Hflexible array member in otherwise empty struct", - &DECL_SOURCE_LOCATION (x)); + error ("%Jflexible array member in otherwise empty struct", x); } if (pedantic && TREE_CODE (t) == RECORD_TYPE && flexible_array_type_p (TREE_TYPE (x))) - pedwarn ("%Hinvalid use of structure with flexible array member", - &DECL_SOURCE_LOCATION (x)); + pedwarn ("%Jinvalid use of structure with flexible array member", x); if (DECL_NAME (x)) saw_named_field = 1; @@ -5149,63 +5114,24 @@ /* If this structure or union completes the type of any previous variable declaration, lay it out and output its rtl. */ - - if (current_scope->incomplete != NULL_TREE) - { - tree prev = NULL_TREE; - - for (x = current_scope->incomplete; x; x = TREE_CHAIN (x)) - { - tree decl = TREE_VALUE (x); - - if (TYPE_MAIN_VARIANT (TREE_TYPE (decl)) == TYPE_MAIN_VARIANT (t) - && TREE_CODE (decl) != TYPE_DECL) - { - layout_decl (decl, 0); - /* This is a no-op in c-lang.c or something real in - objc-act.c. */ - if (c_dialect_objc ()) - objc_check_decl (decl); - rest_of_decl_compilation (decl, NULL, toplevel, 0); - if (! toplevel) - expand_decl (decl); - /* Unlink X from the incomplete list. */ - if (prev) - TREE_CHAIN (prev) = TREE_CHAIN (x); - else - current_scope->incomplete = TREE_CHAIN (x); - } - else if (!COMPLETE_TYPE_P (TREE_TYPE (decl)) - && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE) - { - tree element = TREE_TYPE (decl); - while (TREE_CODE (element) == ARRAY_TYPE) - element = TREE_TYPE (element); - if (element == t) - { - layout_array_type (TREE_TYPE (decl)); - if (TREE_CODE (decl) != TYPE_DECL) - { - layout_decl (decl, 0); - if (c_dialect_objc ()) - objc_check_decl (decl); - rest_of_decl_compilation (decl, NULL, toplevel, 0); - if (! toplevel) - expand_decl (decl); - } - /* Unlink X from the incomplete list. */ - if (prev) - TREE_CHAIN (prev) = TREE_CHAIN (x); - else - current_scope->incomplete = TREE_CHAIN (x); - } - else - prev = x; - } - else - prev = x; + for (x = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t)); + x; + x = TREE_CHAIN (x)) + { + tree decl = TREE_VALUE (x); + if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE) + layout_array_type (TREE_TYPE (decl)); + if (TREE_CODE (decl) != TYPE_DECL) + { + layout_decl (decl, 0); + if (c_dialect_objc ()) + objc_check_decl (decl); + rest_of_decl_compilation (decl, NULL, toplevel, 0); + if (! toplevel) + expand_decl (decl); } } + C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t)) = 0; /* Finish debugging output for this type. */ rest_of_type_compilation (t, toplevel); @@ -5505,8 +5431,7 @@ if (DECL_DECLARED_INLINE_P (decl1) && DECL_UNINLINABLE (decl1) && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl1))) - warning ("%Hinline function '%D' given attribute noinline", - &DECL_SOURCE_LOCATION (decl1), decl1); + warning ("%Jinline function '%D' given attribute noinline", decl1, decl1); announce_function (decl1); @@ -5556,29 +5481,27 @@ && TREE_PUBLIC (decl1) && ! MAIN_NAME_P (DECL_NAME (decl1)) && C_DECL_ISNT_PROTOTYPE (old_decl)) - warning ("%Hno previous prototype for '%D'", - &DECL_SOURCE_LOCATION (decl1), decl1); + warning ("%Jno previous prototype for '%D'", decl1, decl1); /* Optionally warn of any def with no previous prototype if the function has already been used. */ else if (warn_missing_prototypes && old_decl != 0 && TREE_USED (old_decl) && TYPE_ARG_TYPES (TREE_TYPE (old_decl)) == 0) - warning ("%H'%D' was used with no prototype before its definition", - &DECL_SOURCE_LOCATION (decl1), decl1); + warning ("%J'%D' was used with no prototype before its definition", + decl1, decl1); /* Optionally warn of any global def with no previous declaration. */ else if (warn_missing_declarations && TREE_PUBLIC (decl1) && old_decl == 0 && ! MAIN_NAME_P (DECL_NAME (decl1))) - warning ("%Hno previous declaration for '%D'", - &DECL_SOURCE_LOCATION (decl1), decl1); + warning ("%Jno previous declaration for '%D'", decl1, decl1); /* Optionally warn of any def with no previous declaration if the function has already been used. */ else if (warn_missing_declarations && old_decl != 0 && TREE_USED (old_decl) && C_DECL_IMPLICIT (old_decl)) - warning ("%H`%D' was used with no declaration before its definition", - &DECL_SOURCE_LOCATION (decl1), decl1); + warning ("%J`%D' was used with no declaration before its definition", + decl1, decl1); /* This is a definition, not a reference. So normally clear DECL_EXTERNAL. @@ -5610,11 +5533,10 @@ { tree args; int argct = 0; - const location_t *locus = &DECL_SOURCE_LOCATION (decl1); if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1))) != integer_type_node) - pedwarn ("%Hreturn type of '%D' is not `int'", locus, decl1); + pedwarn ("%Jreturn type of '%D' is not `int'", decl1, decl1); for (args = TYPE_ARG_TYPES (TREE_TYPE (decl1)); args; args = TREE_CHAIN (args)) @@ -5629,8 +5551,8 @@ { case 1: if (TYPE_MAIN_VARIANT (type) != integer_type_node) - pedwarn ("%Hfirst argument of '%D' should be `int'", - locus, decl1); + pedwarn ("%Jfirst argument of '%D' should be `int'", + decl1, decl1); break; case 2: @@ -5638,8 +5560,8 @@ || TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE || (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type))) != char_type_node)) - pedwarn ("%Hsecond argument of '%D' should be 'char **'", - locus, decl1); + pedwarn ("%Jsecond argument of '%D' should be 'char **'", + decl1, decl1); break; case 3: @@ -5647,8 +5569,8 @@ || TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE || (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type))) != char_type_node)) - pedwarn ("%Hthird argument of '%D' should probably be " - "'char **'", locus, decl1); + pedwarn ("%Jthird argument of '%D' should probably be " + "'char **'", decl1, decl1); break; } } @@ -5657,10 +5579,10 @@ argument because it's only mentioned in an appendix of the standard. */ if (argct > 0 && (argct < 2 || argct > 3)) - pedwarn ("%H'%D' takes only zero or two arguments", locus, decl1); + pedwarn ("%J'%D' takes only zero or two arguments", decl1, decl1); if (! TREE_PUBLIC (decl1)) - pedwarn ("%H'%D' is normally a non-static function", locus, decl1); + pedwarn ("%J'%D' is normally a non-static function", decl1, decl1); } /* Record the decl so that the function name is defined. @@ -5719,8 +5641,8 @@ if (current_scope->parms || current_scope->names || current_scope->tags) { - error ("%Hold-style parameter declarations in prototyped " - "function definition", &DECL_SOURCE_LOCATION (fndecl)); + error ("%Jold-style parameter declarations in prototyped " + "function definition", fndecl); /* Get rid of the old-style declarations. */ poplevel (0, 0, 0); @@ -5733,7 +5655,7 @@ { DECL_CONTEXT (decl) = current_function_decl; if (DECL_NAME (decl) == 0) - error ("%Hparameter name omitted", &DECL_SOURCE_LOCATION (decl)); + error ("%Jparameter name omitted", decl); else { if (IDENTIFIER_SYMBOL_VALUE (DECL_NAME (decl))) @@ -5808,8 +5730,7 @@ { if (TREE_VALUE (parm) == 0) { - error ("%Hparameter name missing from parameter list", - &DECL_SOURCE_LOCATION (fndecl)); + error ("%Jparameter name missing from parameter list", fndecl); TREE_PURPOSE (parm) = 0; continue; } @@ -5817,15 +5738,14 @@ decl = IDENTIFIER_SYMBOL_VALUE (TREE_VALUE (parm)); if (decl && DECL_CONTEXT (decl) == fndecl) { - const location_t *locus = &DECL_SOURCE_LOCATION (decl); /* If we got something other than a PARM_DECL it is an error. */ if (TREE_CODE (decl) != PARM_DECL) - error ("%H\"%D\" declared as a non-parameter", locus, decl); + error ("%J\"%D\" declared as a non-parameter", decl, decl); /* If the declaration is already marked, we have a duplicate name. Complain and ignore the duplicate. */ else if (DECL_WEAK (decl)) { - error ("%Hmultiple parameters named \"%D\"", locus, decl); + error ("%Jmultiple parameters named \"%D\"", decl, decl); TREE_PURPOSE (parm) = 0; continue; } @@ -5833,7 +5753,7 @@ an int. */ else if (VOID_TYPE_P (TREE_TYPE (decl))) { - error ("%Hparameter \"%D\" declared void", locus, decl); + error ("%Jparameter \"%D\" declared void", decl, decl); TREE_TYPE (decl) = integer_type_node; DECL_ARG_TYPE (decl) = integer_type_node; layout_decl (decl, 0); @@ -5842,16 +5762,15 @@ /* If no declaration found, default to int. */ else { - const location_t *locus = &DECL_SOURCE_LOCATION (fndecl); decl = build_decl (PARM_DECL, TREE_VALUE (parm), integer_type_node); DECL_ARG_TYPE (decl) = TREE_TYPE (decl); - DECL_SOURCE_LOCATION (decl) = *locus; + DECL_SOURCE_LOCATION (decl) = DECL_SOURCE_LOCATION (fndecl); pushdecl (decl); if (flag_isoc99) - pedwarn ("%Htype of \"%D\" defaults to \"int\"", locus, decl); + pedwarn ("%Jtype of \"%D\" defaults to \"int\"", decl, decl); else if (extra_warnings) - warning ("%Htype of \"%D\" defaults to \"int\"", locus, decl); + warning ("%Jtype of \"%D\" defaults to \"int\"", decl, decl); } TREE_PURPOSE (parm) = decl; @@ -5863,18 +5782,16 @@ for (parm = current_scope->parms; parm; parm = TREE_CHAIN (parm)) { - const location_t *locus = &DECL_SOURCE_LOCATION (parm); - if (!COMPLETE_TYPE_P (TREE_TYPE (parm))) { - error ("%Hparameter \"%D\" has incomplete type", locus, parm); + error ("%Jparameter \"%D\" has incomplete type", parm, parm); TREE_TYPE (parm) = error_mark_node; } if (! DECL_WEAK (parm)) { - error ("%Hdeclaration for parameter \"%D\" but no such parameter", - locus, parm); + error ("%Jdeclaration for parameter \"%D\" but no such parameter", + parm, parm); /* Pretend the parameter was not missing. This gets us to a standard state and minimizes @@ -5947,7 +5864,7 @@ useful for argument types like uid_t. */ DECL_ARG_TYPE (parm) = TREE_TYPE (parm); - if (PROMOTE_PROTOTYPES + if (targetm.calls.promote_prototypes (TREE_TYPE (current_function_decl)) && INTEGRAL_TYPE_P (TREE_TYPE (parm)) && TYPE_PRECISION (TREE_TYPE (parm)) < TYPE_PRECISION (integer_type_node)) @@ -6041,7 +5958,7 @@ gen_aux_info_record (fndecl, 1, 0, prototype); /* Initialize the RTL code for the function. */ - init_function_start (fndecl); + allocate_struct_function (fndecl); /* Begin the statement tree for this function. */ begin_stmt_tree (&DECL_SAVED_TREE (fndecl)); @@ -6078,13 +5995,10 @@ all the way to assembler language output. The free the storage for the function definition. - This is called after parsing the body of the function definition. - - NESTED is nonzero if the function being finished is nested in another. - CAN_DEFER_P is nonzero if the function may be deferred. */ + This is called after parsing the body of the function definition. */ void -finish_function (int nested, int can_defer_p) +finish_function () { tree fndecl = current_function_decl; @@ -6104,6 +6018,19 @@ poplevel (0, 0, 0); } + if (TREE_CODE (fndecl) == FUNCTION_DECL + && targetm.calls.promote_prototypes (TREE_TYPE (fndecl))) + { + tree args = DECL_ARGUMENTS (fndecl); + for (; args; args = TREE_CHAIN (args)) + { + tree type = TREE_TYPE (args); + if (INTEGRAL_TYPE_P (type) + && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)) + DECL_ARG_TYPE (args) = integer_type_node; + } + } + BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl; /* Must mark the RESULT_DECL as being in this function. */ @@ -6118,8 +6045,7 @@ /* If warn_main is 1 (-Wmain) or 2 (-Wall), we have already warned. If warn_main is -1 (-Wno-main) we don't want to be warned. */ if (!warn_main) - pedwarn ("%Hreturn type of '%D' is not `int'", - &DECL_SOURCE_LOCATION (fndecl), fndecl); + pedwarn ("%Jreturn type of '%D' is not `int'", fndecl, fndecl); } else { @@ -6153,84 +6079,27 @@ && DECL_INLINE (fndecl)) warning ("no return statement in function returning non-void"); - /* Clear out memory we no longer need. */ - free_after_parsing (cfun); - /* Since we never call rest_of_compilation, we never clear - CFUN. Do so explicitly. */ - free_after_compilation (cfun); - cfun = NULL; - - if (flag_unit_at_a_time && can_defer_p) - { - cgraph_finalize_function (fndecl, DECL_SAVED_TREE (fndecl)); - current_function_decl = NULL; - return; - } - - if (! nested) - { - /* Function is parsed. - Generate RTL for the body of this function or defer - it for later expansion. */ - bool uninlinable = true; - - /* There's no reason to do any of the work here if we're only doing - semantic analysis; this code just generates RTL. */ - if (flag_syntax_only) - { - current_function_decl = NULL; - DECL_SAVED_TREE (fndecl) = NULL_TREE; - return; - } - - if (flag_inline_trees && !EMIT_LLVM) - { - /* First, cache whether the current function is inlinable. Some - predicates depend on cfun and current_function_decl to - function completely. */ - timevar_push (TV_INTEGRATION); - uninlinable = !tree_inlinable_function_p (fndecl); - - if (can_defer_p - /* We defer functions marked inline *even if* the function - itself is not inlinable. This is because we don't yet - know if the function will actually be used; we may be - able to avoid emitting it entirely. */ - && (!uninlinable || DECL_DECLARED_INLINE_P (fndecl)) - /* Save function tree for inlining. Should return 0 if the - language does not support function deferring or the - function could not be deferred. */ - && defer_fn (fndecl)) - { - /* Let the back-end know that this function exists. */ - (*debug_hooks->deferred_inline_function) (fndecl); - timevar_pop (TV_INTEGRATION); - current_function_decl = NULL; - return; - } - - /* Then, inline any functions called in it. */ - optimize_inline_calls (fndecl); - timevar_pop (TV_INTEGRATION); - } - - if (EMIT_LLVM) - llvm_c_expand_body (fndecl); - else - c_expand_body (fndecl); + /* With just -Wextra, complain only if function returns both with + and without a value. */ + if (extra_warnings + && current_function_returns_value + && current_function_returns_null) + warning ("this function may return with or without a value"); - /* Keep the function body if it's needed for inlining or dumping. */ - if (uninlinable && !dump_enabled_p (TDI_all)) - { - /* Allow the body of the function to be garbage collected. */ - DECL_SAVED_TREE (fndecl) = NULL_TREE; - } + /* We're leaving the context of this function, so zap cfun. It's still in + DECL_SAVED_INSNS, and we'll restore it in tree_rest_of_compilation. */ + cfun = NULL; - /* Let the error reporting routines know that we're outside a - function. For a nested function, this value is used in - c_pop_function_context and then reset via pop_function_context. */ - current_function_decl = NULL; - } + /* ??? Objc emits functions after finalizing the compilation unit. + This should be cleaned up later and this conditional removed. */ + if (!cgraph_global_info_ready) + cgraph_finalize_function (fndecl, false); + else + if (EMIT_LLVM) + llvm_c_expand_body (fndecl); + else + c_expand_body (fndecl); + current_function_decl = NULL; } /* Generate the RTL for a deferred function FNDECL. */ @@ -6256,152 +6125,28 @@ } } -/* Called to move the SAVE_EXPRs for parameter declarations in a - nested function into the nested function. DATA is really the - nested FUNCTION_DECL. */ - -static tree -set_save_expr_context (tree *tp, - int *walk_subtrees, - void *data) -{ - if (TREE_CODE (*tp) == SAVE_EXPR && !SAVE_EXPR_CONTEXT (*tp)) - SAVE_EXPR_CONTEXT (*tp) = (tree) data; - /* Do not walk back into the SAVE_EXPR_CONTEXT; that will cause - circularity. */ - else if (DECL_P (*tp)) - *walk_subtrees = 0; - - return NULL_TREE; -} - /* Generate the RTL for the body of FNDECL. If NESTED_P is nonzero, then we are already in the process of generating RTL for another - function. If can_defer_p is zero, we won't attempt to defer the - generation of RTL. */ + function. */ static void c_expand_body_1 (tree fndecl, int nested_p) { - timevar_push (TV_EXPAND); - if (nested_p) { /* Make sure that we will evaluate variable-sized types involved in our function's type. */ expand_pending_sizes (DECL_LANG_SPECIFIC (fndecl)->pending_sizes); + /* Squirrel away our current state. */ push_function_context (); } - /* Initialize the RTL code for the function. */ - current_function_decl = fndecl; - input_location = DECL_SOURCE_LOCATION (fndecl); - init_function_start (fndecl); - - /* This function is being processed in whole-function mode. */ - cfun->x_whole_function_mode_p = 1; - - /* Even though we're inside a function body, we still don't want to - call expand_expr to calculate the size of a variable-sized array. - We haven't necessarily assigned RTL to all variables yet, so it's - not safe to try to expand expressions involving them. */ - immediate_size_expand = 0; - cfun->x_dont_save_pending_sizes_p = 1; - - /* Set up parameters and prepare for return, for the function. */ - expand_function_start (fndecl, 0); - - /* If the function has a variably modified type, there may be - SAVE_EXPRs in the parameter types. Their context must be set to - refer to this function; they cannot be expanded in the containing - function. */ - if (decl_function_context (fndecl) - && variably_modified_type_p (TREE_TYPE (fndecl))) - walk_tree (&TREE_TYPE (fndecl), set_save_expr_context, fndecl, - NULL); - - /* If this function is `main', emit a call to `__main' - to run global initializers, etc. */ - if (DECL_NAME (fndecl) - && MAIN_NAME_P (DECL_NAME (fndecl)) - && C_DECL_FILE_SCOPE (fndecl)) - expand_main_function (); - - /* Generate the RTL for this function. */ - expand_stmt (DECL_SAVED_TREE (fndecl)); - - /* We hard-wired immediate_size_expand to zero above. - expand_function_end will decrement this variable. So, we set the - variable to one here, so that after the decrement it will remain - zero. */ - immediate_size_expand = 1; - - /* Allow language dialects to perform special processing. */ - if (lang_expand_function_end) - (*lang_expand_function_end) (); - - /* Generate rtl for function exit. */ - expand_function_end (); - - /* If this is a nested function, protect the local variables in the stack - above us from being collected while we're compiling this function. */ - if (nested_p) - ggc_push_context (); - - /* Run the optimizers and output the assembler code for this function. */ - rest_of_compilation (fndecl); + tree_rest_of_compilation (fndecl, nested_p); - /* Undo the GC context switch. */ if (nested_p) - ggc_pop_context (); - - /* With just -Wextra, complain only if function returns both with - and without a value. */ - if (extra_warnings - && current_function_returns_value - && current_function_returns_null) - warning ("this function may return with or without a value"); - - /* If requested, warn about function definitions where the function will - return a value (usually of some struct or union type) which itself will - take up a lot of stack space. */ - - if (warn_larger_than && !DECL_EXTERNAL (fndecl) && TREE_TYPE (fndecl)) - { - tree ret_type = TREE_TYPE (TREE_TYPE (fndecl)); - - if (ret_type && TYPE_SIZE_UNIT (ret_type) - && TREE_CODE (TYPE_SIZE_UNIT (ret_type)) == INTEGER_CST - && 0 < compare_tree_int (TYPE_SIZE_UNIT (ret_type), - larger_than_size)) - { - const location_t *locus = &DECL_SOURCE_LOCATION (fndecl); - unsigned int size_as_int - = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (ret_type)); - - if (compare_tree_int (TYPE_SIZE_UNIT (ret_type), size_as_int) == 0) - warning ("%Hsize of return value of '%D' is %u bytes", - locus, fndecl, size_as_int); - else - warning ("%Hsize of return value of '%D' is larger than %wd bytes", - locus, fndecl, larger_than_size); - } - } - - if (DECL_SAVED_INSNS (fndecl) == 0 && ! nested_p - && ! flag_inline_trees) - { - /* Stop pointing to the local nodes about to be freed. - But DECL_INITIAL must remain nonzero so we know this - was an actual function definition. - For a nested function, this is done in c_pop_function_context. - If rest_of_compilation set this to 0, leave it 0. */ - if (DECL_INITIAL (fndecl) != 0) - DECL_INITIAL (fndecl) = error_mark_node; - - DECL_ARGUMENTS (fndecl) = 0; - } + /* Return to the enclosing function. */ + pop_function_context (); if (DECL_STATIC_CONSTRUCTOR (fndecl)) { @@ -6420,11 +6165,6 @@ else static_dtors = tree_cons (NULL_TREE, fndecl, static_dtors); } - - if (nested_p) - /* Return to the enclosing function. */ - pop_function_context (); - timevar_pop (TV_EXPAND); } /* Like c_expand_body_1 but only for unnested functions. */ @@ -6485,16 +6225,15 @@ for (t = getdecls (); t; t = TREE_CHAIN (t)) { - const location_t *locus = &DECL_SOURCE_LOCATION (t); if (TREE_CODE (t) != VAR_DECL && DECL_NAME (t)) - error ("%Hdeclaration of non-variable '%D' in 'for' loop " - "initial declaration", locus, t); + error ("%Jdeclaration of non-variable '%D' in 'for' loop " + "initial declaration", t, t); else if (TREE_STATIC (t)) - error ("%Hdeclaration of static variable '%D' in 'for' loop " - "initial declaration", locus, t); + error ("%Jdeclaration of static variable '%D' in 'for' loop " + "initial declaration", t, t); else if (DECL_EXTERNAL (t)) - error ("%Hdeclaration of 'extern' variable '%D' in 'for' loop " - "initial declaration", locus, t); + error ("%Jdeclaration of 'extern' variable '%D' in 'for' loop " + "initial declaration", t, t); } } @@ -6658,7 +6397,7 @@ identifier_global_value (tree t) { tree decl = IDENTIFIER_SYMBOL_VALUE (t); - if (decl == 0 || C_DECL_FILE_SCOPE (decl)) + if (decl == 0 || DECL_FILE_SCOPE_P (decl)) return decl; /* Shadowed by something else; find the true global value. */ @@ -6816,10 +6555,8 @@ } else { - error ("%Hredefinition of global '%D'", - &DECL_SOURCE_LOCATION (decl), decl); - error ("%H'%D' previously defined here", - &DECL_SOURCE_LOCATION (old_decl), old_decl); + error ("%Jredefinition of global '%D'", decl, decl); + error ("%J'%D' previously defined here", old_decl, old_decl); } } else @@ -6888,6 +6625,7 @@ current_scope = global_scope; file_scope_decl = current_file_decl; DECL_INITIAL (file_scope_decl) = poplevel (1, 0, 0); + BLOCK_SUPERCONTEXT (DECL_INITIAL (file_scope_decl)) = file_scope_decl; truly_local_externals = NULL_TREE; /* Start a new global binding level. */ Index: gcc-3.4/gcc/c-lang.c diff -u gcc-3.4/gcc/c-lang.c:1.2 gcc-3.4/gcc/c-lang.c:1.3 --- gcc-3.4/gcc/c-lang.c:1.2 Thu Jan 8 17:03:26 2004 +++ gcc-3.4/gcc/c-lang.c Thu Feb 5 10:05:44 2004 @@ -33,6 +33,9 @@ #include "diagnostic.h" #include "c-pretty-print.h" +#include "llvm-out.h" +#include "llvm-internals.h" + static void c_initialize_diagnostics (diagnostic_context *); enum c_language_kind c_language = clk_c; @@ -96,6 +99,14 @@ #undef LANG_HOOKS_DECL_UNINIT #define LANG_HOOKS_DECL_UNINIT c_decl_uninit +#undef LANG_HOOKS_RTL_EXPAND_STMT +#define LANG_HOOKS_RTL_EXPAND_STMT expand_stmt + +#ifdef EMIT_LLVM +#undef LANG_HOOKS_LLVM_IR_EXPAND_STMT +#define LANG_HOOKS_LLVM_IR_EXPAND_STMT llvm_expand_stmt +#endif + /* Attribute hooks. */ #undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE #define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE c_common_attribute_table @@ -122,6 +133,9 @@ #undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION c_expand_body +#undef LANG_HOOKS_LLVM_CALLGRAPH_EXPAND_FUNCTION +#define LANG_HOOKS_LLVM_CALLGRAPH_EXPAND_FUNCTION llvm_c_expand_body + #undef LANG_HOOKS_TYPE_FOR_MODE #define LANG_HOOKS_TYPE_FOR_MODE c_common_type_for_mode #undef LANG_HOOKS_TYPE_FOR_SIZE @@ -136,6 +150,8 @@ #define LANG_HOOKS_INCOMPLETE_TYPE_ERROR c_incomplete_type_error #undef LANG_HOOKS_TYPE_PROMOTES_TO #define LANG_HOOKS_TYPE_PROMOTES_TO c_type_promotes_to +#undef LANG_HOOKS_REGISTER_BUILTIN_TYPE +#define LANG_HOOKS_REGISTER_BUILTIN_TYPE c_register_builtin_type #undef LANG_HOOKS_WRITE_GLOBALS #define LANG_HOOKS_WRITE_GLOBALS c_write_global_declarations Index: gcc-3.4/gcc/c-lex.c diff -u gcc-3.4/gcc/c-lex.c:1.2 gcc-3.4/gcc/c-lex.c:1.3 --- gcc-3.4/gcc/c-lex.c:1.2 Thu Jan 8 17:03:26 2004 +++ gcc-3.4/gcc/c-lex.c Thu Feb 5 10:05:44 2004 @@ -200,8 +200,11 @@ lexed token on the line. Used for diagnostic line numbers. */ static void cb_line_change (cpp_reader *pfile ATTRIBUTE_UNUSED, const cpp_token *token, - int parsing_args ATTRIBUTE_UNUSED) + int parsing_args) { + if (token->type == CPP_EOF || parsing_args) + return; + src_lineno = SOURCE_LINE (map, token->line); } @@ -215,8 +218,6 @@ void fe_file_change (const struct line_map *new_map) { - unsigned int to_line = SOURCE_LINE (new_map, new_map->to_line); - if (new_map->reason == LC_ENTER) { /* Don't stack the main buffer on the input stack; @@ -253,13 +254,13 @@ #endif pop_srcloc (); - (*debug_hooks->end_source_file) (to_line); + (*debug_hooks->end_source_file) (new_map->to_line); } update_header_times (new_map->to_file); in_system_header = new_map->sysp != 0; input_filename = new_map->to_file; - input_line = to_line; + input_line = new_map->to_line; map = new_map; /* Hook for C++. */ Index: gcc-3.4/gcc/c-pragma.c diff -u gcc-3.4/gcc/c-pragma.c:1.3 gcc-3.4/gcc/c-pragma.c:1.4 --- gcc-3.4/gcc/c-pragma.c:1.3 Tue Jan 13 17:13:08 2004 +++ gcc-3.4/gcc/c-pragma.c Thu Feb 5 10:05:44 2004 @@ -277,8 +277,8 @@ if (SUPPORTS_WEAK && DECL_EXTERNAL (decl) && TREE_USED (decl) && !DECL_WEAK (decl) /* don't complain about a redundant #pragma */ && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) - warning ("%Happlying #pragma weak '%D' after first use results " - "in unspecified behavior", &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Japplying #pragma weak '%D' after first use results " + "in unspecified behavior", decl, decl); declare_weak (decl); } Index: gcc-3.4/gcc/c-pretty-print.c diff -u gcc-3.4/gcc/c-pretty-print.c:1.1.1.2 gcc-3.4/gcc/c-pretty-print.c:1.2 --- gcc-3.4/gcc/c-pretty-print.c:1.1.1.2 Tue Jan 13 10:48:59 2004 +++ gcc-3.4/gcc/c-pretty-print.c Thu Feb 5 10:05:44 2004 @@ -27,6 +27,11 @@ #include "c-pretty-print.h" #include "c-tree.h" +#include "llvm-out.h" +#ifdef EMIT_LLVM +#include "assert.h" +#endif + /* The pretty-printer code is primarily designed to closely follow (GNU) C and C++ grammars. That is to be contrasted with spaghetti codes we used to have in the past. Following a structured @@ -281,9 +286,16 @@ case INTEGER_TYPE: case REAL_TYPE: if (TYPE_NAME (t)) + { t = TYPE_NAME (t); + } else + { t = c_common_type_for_mode (TYPE_MODE (t), TREE_UNSIGNED (t)); + } +#ifdef EMIT_LLVM + assert ((t != NULL_TREE) && "t is equal to NULL_TREE"); +#endif pp_c_type_specifier (pp, t); break; Index: gcc-3.4/gcc/c-semantics.c diff -u gcc-3.4/gcc/c-semantics.c:1.2 gcc-3.4/gcc/c-semantics.c:1.3 --- gcc-3.4/gcc/c-semantics.c:1.2 Thu Jan 8 17:03:26 2004 +++ gcc-3.4/gcc/c-semantics.c Thu Feb 5 10:05:44 2004 @@ -648,6 +648,7 @@ if (TREE_CODE (fn) == FUNCTION_DECL && DECL_CONTEXT (fn) == current_function_decl && DECL_SAVED_INSNS (fn) + && DECL_SAVED_INSNS (fn)->saved_for_inline && !TREE_ASM_WRITTEN (fn) && TREE_ADDRESSABLE (fn)) { Index: gcc-3.4/gcc/c-typeck.c diff -u gcc-3.4/gcc/c-typeck.c:1.2 gcc-3.4/gcc/c-typeck.c:1.3 --- gcc-3.4/gcc/c-typeck.c:1.2 Thu Jan 8 17:03:26 2004 +++ gcc-3.4/gcc/c-typeck.c Thu Feb 5 10:05:44 2004 @@ -51,6 +51,7 @@ static int missing_braces_mentioned; static tree qualify_type (tree, tree); +static int same_translation_unit_p (tree, tree); static int tagged_types_tu_compatible_p (tree, tree, int); static int comp_target_types (tree, tree, int); static int function_types_compatible_p (tree, tree, int); @@ -565,7 +566,7 @@ case ENUMERAL_TYPE: case UNION_TYPE: - if (val != 1 && (flags & COMPARE_DIFFERENT_TU)) + if (val != 1 && !same_translation_unit_p (t1, t2)) val = tagged_types_tu_compatible_p (t1, t2, flags); break; @@ -607,6 +608,34 @@ /* Subroutines of `comptypes'. */ +/* Determine whether two types derive from the same translation unit. + If the CONTEXT chain ends in a null, that type's context is still + being parsed, so if two types have context chains ending in null, + they're in the same translation unit. */ +static int +same_translation_unit_p (tree t1, tree t2) +{ + while (t1 && TREE_CODE (t1) != TRANSLATION_UNIT_DECL) + switch (TREE_CODE_CLASS (TREE_CODE (t1))) + { + case 'd': t1 = DECL_CONTEXT (t1); break; + case 't': t1 = TYPE_CONTEXT (t1); break; + case 'b': t1 = BLOCK_SUPERCONTEXT (t1); break; + default: abort (); + } + + while (t2 && TREE_CODE (t2) != TRANSLATION_UNIT_DECL) + switch (TREE_CODE_CLASS (TREE_CODE (t2))) + { + case 'd': t2 = DECL_CONTEXT (t1); break; + case 't': t2 = TYPE_CONTEXT (t2); break; + case 'b': t2 = BLOCK_SUPERCONTEXT (t2); break; + default: abort (); + } + + return t1 == t2; +} + /* The C standard says that two structures in different translation units are compatible with each other only if the types of their fields are compatible (among other things). So, consider two copies @@ -1553,7 +1582,7 @@ /* Properly declared variable or function reference. */ if (!objc_ivar) ref = decl; - else if (decl != objc_ivar && !C_DECL_FILE_SCOPE (decl)) + else if (decl != objc_ivar && !DECL_FILE_SCOPE_P (decl)) { warning ("local declaration of `%s' hides instance variable", IDENTIFIER_POINTER (id)); @@ -1593,7 +1622,7 @@ TREE_CONSTANT (ref) = 1; } else if (current_function_decl != 0 - && !C_DECL_FILE_SCOPE (current_function_decl) + && !DECL_FILE_SCOPE_P (current_function_decl) && (TREE_CODE (ref) == VAR_DECL || TREE_CODE (ref) == PARM_DECL || TREE_CODE (ref) == FUNCTION_DECL)) @@ -1845,7 +1874,7 @@ (char *) 0, /* arg passing */ fundecl, name, parmnum + 1); - if (PROMOTE_PROTOTYPES + if (targetm.calls.promote_prototypes (fundecl ? TREE_TYPE (fundecl) : 0) && INTEGRAL_TYPE_P (type) && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))) parmval = default_conversion (parmval); @@ -2452,7 +2481,7 @@ file-scope function counts as a constant. */ if (staticp (arg) && ! (TREE_CODE (arg) == FUNCTION_DECL - && !C_DECL_FILE_SCOPE (arg))) + && !DECL_FILE_SCOPE_P (arg))) TREE_CONSTANT (addr) = 1; return addr; } @@ -3603,7 +3632,7 @@ ret = convert_for_assignment (type, value, (char *) 0 /* arg passing */, fn, DECL_NAME (fn), 0); - if (PROMOTE_PROTOTYPES + if (targetm.calls.promote_prototypes (TREE_TYPE (fn)) && INTEGRAL_TYPE_P (type) && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))) ret = default_conversion (ret); @@ -6611,7 +6640,6 @@ break; case BIT_AND_EXPR: - case BIT_ANDTC_EXPR: case BIT_IOR_EXPR: case BIT_XOR_EXPR: if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) Index: gcc-3.4/gcc/calls.c diff -u gcc-3.4/gcc/calls.c:1.2 gcc-3.4/gcc/calls.c:1.3 --- gcc-3.4/gcc/calls.c:1.2 Fri Jan 9 10:13:11 2004 +++ gcc-3.4/gcc/calls.c Thu Feb 5 10:05:44 2004 @@ -1,5 +1,5 @@ /* Convert function calls to rtl insns, for GNU C compiler. - Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998 + Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GCC. @@ -1184,9 +1184,8 @@ mode = TYPE_MODE (type); unsignedp = TREE_UNSIGNED (type); -#ifdef PROMOTE_FUNCTION_ARGS - mode = promote_mode (type, mode, &unsignedp, 1); -#endif + if (targetm.calls.promote_function_args (fndecl ? TREE_TYPE (fndecl) : 0)) + mode = promote_mode (type, mode, &unsignedp, 1); args[i].unsignedp = unsignedp; args[i].mode = mode; @@ -1827,8 +1826,7 @@ if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline && optimize > 0 && !TREE_ADDRESSABLE (fndecl)) { - warning ("%Hinlining failed in call to '%F'", - &DECL_SOURCE_LOCATION (fndecl), fndecl); + warning ("%Jinlining failed in call to '%F'", fndecl, fndecl); warning ("called from here"); } (*lang_hooks.mark_addressable) (fndecl); @@ -2067,6 +2065,7 @@ /* Nonzero if called function returns an aggregate in memory PCC style, by returning the address of where to find it. */ int pcc_struct_value = 0; + rtx struct_value = 0; /* Number of actual parameters in this call, including struct value addr. */ int num_actuals; @@ -2167,20 +2166,34 @@ if (DECL_INLINE (fndecl) && warn_inline && !flag_no_inline && optimize > 0) { - warning ("%Hcan't inline call to '%F'", - &DECL_SOURCE_LOCATION (fndecl), fndecl); + warning ("%Jcan't inline call to '%F'", fndecl, fndecl); warning ("called from here"); } (*lang_hooks.mark_addressable) (fndecl); } + if (ignore + && lookup_attribute ("warn_unused_result", + TYPE_ATTRIBUTES (TREE_TYPE (fndecl)))) + warning ("ignoring return value of `%D', " + "declared with attribute warn_unused_result", fndecl); + flags |= flags_from_decl_or_type (fndecl); } /* If we don't have specific function to call, see if we have a attributes set in the type. */ else - flags |= flags_from_decl_or_type (TREE_TYPE (TREE_TYPE (p))); + { + if (ignore + && lookup_attribute ("warn_unused_result", + TYPE_ATTRIBUTES (TREE_TYPE (TREE_TYPE (p))))) + warning ("ignoring return value of function " + "declared with attribute warn_unused_result"); + flags |= flags_from_decl_or_type (TREE_TYPE (TREE_TYPE (p))); + } + + struct_value = targetm.calls.struct_value_rtx (fndecl ? TREE_TYPE (fndecl) : 0, 0); /* Warn if this value is an aggregate type, regardless of which calling convention we are using for it. */ @@ -2229,7 +2242,7 @@ /* Set up a place to return a structure. */ /* Cater to broken compilers. */ - if (aggregate_value_p (exp)) + if (aggregate_value_p (exp, fndecl)) { /* This call returns a big structure. */ flags &= ~(ECF_CONST | ECF_PURE | ECF_LIBCALL_BLOCK); @@ -2323,7 +2336,7 @@ /* If struct_value_rtx is 0, it means pass the address as if it were an extra parameter. */ - if (structure_value_addr && struct_value_rtx == 0) + if (structure_value_addr && struct_value == 0) { /* If structure_value_addr is a REG other than virtual_outgoing_args_rtx, we can use always use it. If it @@ -2349,6 +2362,14 @@ for (p = actparms, num_actuals = 0; p; p = TREE_CHAIN (p)) num_actuals++; + /* Start updating where the next arg would go. + + On some machines (such as the PA) indirect calls have a difuferent + calling convention than normal calls. The last argument in + INIT_CUMULATIVE_ARGS tells the backend if this is an indirect call + or not. */ + INIT_CUMULATIVE_ARGS (args_so_far, funtype, NULL_RTX, fndecl); + /* Compute number of named args. Normally, don't include the last named arg if anonymous args follow. We do include the last named arg if STRICT_ARGUMENT_NAMING is nonzero. @@ -2365,27 +2386,19 @@ reliable way to pass unnamed args in registers, so we must force them into memory. */ - if ((STRICT_ARGUMENT_NAMING - || ! PRETEND_OUTGOING_VARARGS_NAMED) + if ((targetm.calls.strict_argument_naming (&args_so_far) + || ! targetm.calls.pretend_outgoing_varargs_named (&args_so_far)) && type_arg_types != 0) n_named_args = (list_length (type_arg_types) /* Don't include the last named arg. */ - - (STRICT_ARGUMENT_NAMING ? 0 : 1) + - (targetm.calls.strict_argument_naming (&args_so_far) ? 0 : 1) /* Count the struct value address, if it is passed as a parm. */ + structure_value_addr_parm); else /* If we know nothing, treat all args as named. */ n_named_args = num_actuals; - /* Start updating where the next arg would go. - - On some machines (such as the PA) indirect calls have a different - calling convention than normal calls. The last argument in - INIT_CUMULATIVE_ARGS tells the backend if this is an indirect call - or not. */ - INIT_CUMULATIVE_ARGS (args_so_far, funtype, NULL_RTX, fndecl); - /* Make a vector to hold all the information about each arg. */ args = alloca (num_actuals * sizeof (struct arg_data)); memset (args, 0, num_actuals * sizeof (struct arg_data)); @@ -3018,18 +3031,15 @@ structure value. */ if (pass != 0 && structure_value_addr && ! structure_value_addr_parm) { -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (structure_value_addr) != Pmode) - structure_value_addr = convert_memory_address - (Pmode, structure_value_addr); -#endif - emit_move_insn (struct_value_rtx, + structure_value_addr + = convert_memory_address (Pmode, structure_value_addr); + emit_move_insn (struct_value, force_reg (Pmode, force_operand (structure_value_addr, NULL_RTX))); - if (GET_CODE (struct_value_rtx) == REG) - use_reg (&call_fusage, struct_value_rtx); + if (GET_CODE (struct_value) == REG) + use_reg (&call_fusage, struct_value); } funexp = prepare_call_address (funexp, fndecl, &call_fusage, @@ -3076,10 +3086,19 @@ if (pass && (flags & ECF_LIBCALL_BLOCK)) { rtx insns; + rtx insn; + bool failed = valreg == 0 || GET_CODE (valreg) == PARALLEL; - if (valreg == 0 || GET_CODE (valreg) == PARALLEL) + insns = get_insns (); + + /* Expansion of block moves possibly introduced a loop that may + not appear inside libcall block. */ + for (insn = insns; insn; insn = NEXT_INSN (insn)) + if (GET_CODE (insn) == JUMP_INSN) + failed = true; + + if (failed) { - insns = get_insns (); end_sequence (); emit_insn (insns); } @@ -3100,7 +3119,6 @@ args[i].initial_value, note); note = gen_rtx_EXPR_LIST (VOIDmode, funexp, note); - insns = get_insns (); end_sequence (); if (flags & ECF_PURE) @@ -3253,7 +3271,8 @@ else target = copy_to_reg (valreg); -#ifdef PROMOTE_FUNCTION_RETURN + if (targetm.calls.promote_function_return(funtype)) + { /* If we promoted this return value, make the proper SUBREG. TARGET might be const0_rtx here, so be careful. */ if (GET_CODE (target) == REG @@ -3284,7 +3303,7 @@ SUBREG_PROMOTED_VAR_P (target) = 1; SUBREG_PROMOTED_UNSIGNED_SET (target, unsignedp); } -#endif + } /* If size of args is variable or this was a constructor call for a stack argument, restore saved stack-pointer value. */ @@ -3593,6 +3612,8 @@ int initial_highest_arg_in_use = highest_outgoing_arg_in_use; char *initial_stack_usage_map = stack_usage_map; + rtx struct_value = targetm.calls.struct_value_rtx (0, 0); + #ifdef REG_PARM_STACK_SPACE #ifdef MAYBE_REG_PARM_STACK_SPACE reg_parm_stack_space = MAYBE_REG_PARM_STACK_SPACE; @@ -3645,7 +3666,7 @@ if (outmode != VOIDmode) { tfom = (*lang_hooks.types.type_for_mode) (outmode, 0); - if (aggregate_value_p (tfom)) + if (aggregate_value_p (tfom, 0)) { #ifdef PCC_STATIC_STRUCT_RETURN rtx pointer_reg @@ -3700,7 +3721,7 @@ /* If there's a structure value address to be passed, either pass it in the special place, or pass it as an extra argument. */ - if (mem_value && struct_value_rtx == 0 && ! pcc_struct_value) + if (mem_value && struct_value == 0 && ! pcc_struct_value) { rtx addr = XEXP (mem_value, 0); nargs++; @@ -4010,9 +4031,25 @@ argvec[argnum].locate.offset.constant); rtx stack_area = gen_rtx_MEM (save_mode, memory_address (save_mode, adr)); - argvec[argnum].save_area = gen_reg_rtx (save_mode); - emit_move_insn (argvec[argnum].save_area, stack_area); + if (save_mode == BLKmode) + { + argvec[argnum].save_area + = assign_stack_temp (BLKmode, + argvec[argnum].locate.size.constant, + 0); + + emit_block_move (validize_mem (argvec[argnum].save_area), + stack_area, + GEN_INT (argvec[argnum].locate.size.constant), + BLOCK_OP_CALL_PARM); + } + else + { + argvec[argnum].save_area = gen_reg_rtx (save_mode); + + emit_move_insn (argvec[argnum].save_area, stack_area); + } } } @@ -4075,14 +4112,14 @@ } /* Pass the function the address in which to return a structure value. */ - if (mem_value != 0 && struct_value_rtx != 0 && ! pcc_struct_value) + if (mem_value != 0 && struct_value != 0 && ! pcc_struct_value) { - emit_move_insn (struct_value_rtx, + emit_move_insn (struct_value, force_reg (Pmode, force_operand (XEXP (mem_value, 0), NULL_RTX))); - if (GET_CODE (struct_value_rtx) == REG) - use_reg (&call_fusage, struct_value_rtx); + if (GET_CODE (struct_value) == REG) + use_reg (&call_fusage, struct_value); } /* Don't allow popping to be deferred, since then @@ -4231,7 +4268,13 @@ rtx stack_area = gen_rtx_MEM (save_mode, memory_address (save_mode, adr)); - emit_move_insn (stack_area, argvec[count].save_area); + if (save_mode == BLKmode) + emit_block_move (stack_area, + validize_mem (argvec[count].save_area), + GEN_INT (argvec[count].locate.size.constant), + BLOCK_OP_CALL_PARM); + else + emit_move_insn (stack_area, argvec[count].save_area); } highest_outgoing_arg_in_use = initial_highest_arg_in_use; Index: gcc-3.4/gcc/cgraphunit.c diff -u gcc-3.4/gcc/cgraphunit.c:1.1.1.3 gcc-3.4/gcc/cgraphunit.c:1.2 --- gcc-3.4/gcc/cgraphunit.c:1.1.1.3 Thu Jan 22 09:46:30 2004 +++ gcc-3.4/gcc/cgraphunit.c Thu Feb 5 10:05:44 2004 @@ -39,6 +39,8 @@ #include "fibheap.h" #include "c-common.h" +#include "llvm-out.h" + #define INSNS_PER_CALL 10 static void cgraph_expand_all_functions (void); @@ -71,6 +73,11 @@ static bool decide_is_function_needed (struct cgraph_node *node, tree decl) { +#if 0 + if (EMIT_LLVM) + return true; +#endif + /* If we decided it was needed before, but at the time we didn't have the body of the function available, then it's still needed. We have to go back and re-check its dependencies now. */ @@ -110,6 +117,7 @@ /* We want to emit COMDAT functions only when absolutely necessary. */ if (DECL_COMDAT (decl)) return false; + if (!DECL_INLINE (decl) || (!node->local.disregard_inline_limits /* When declared inline, defer even the uninlinable functions. @@ -495,7 +503,14 @@ /* Generate RTL for the body of DECL. Nested functions are expanded via lang_expand_decl_stmt. */ - (*lang_hooks.callgraph.expand_function) (decl); + if (EMIT_LLVM) + { + (*lang_hooks.callgraph.llvm_expand_function) (decl); + } + else + { + (*lang_hooks.callgraph.expand_function) (decl); + } if (!flag_unit_at_a_time) { Index: gcc-3.4/gcc/dwarf2out.c diff -u gcc-3.4/gcc/dwarf2out.c:1.2 gcc-3.4/gcc/dwarf2out.c:1.3 --- gcc-3.4/gcc/dwarf2out.c:1.2 Fri Jan 9 10:54:24 2004 +++ gcc-3.4/gcc/dwarf2out.c Thu Feb 5 10:05:44 2004 @@ -3812,14 +3812,10 @@ #endif /* Section flags for .debug_str section. */ -#ifdef HAVE_GAS_SHF_MERGE #define DEBUG_STR_SECTION_FLAGS \ - (flag_merge_constants \ + (HAVE_GAS_SHF_MERGE && flag_merge_constants \ ? SECTION_DEBUG | SECTION_MERGE | SECTION_STRINGS | 1 \ : SECTION_DEBUG) -#else -#define DEBUG_STR_SECTION_FLAGS SECTION_DEBUG -#endif /* Labels we insert at beginning sections we can reference instead of the section names themselves. */ @@ -10990,15 +10986,19 @@ static void gen_inlined_subroutine_die (tree stmt, dw_die_ref context_die, int depth) { + tree decl = block_ultimate_origin (stmt); + + /* Emit info for the abstract instance first, if we haven't yet. We + must emit this even if the block is abstract, otherwise when we + emit the block below (or elsewhere), we may end up trying to emit + a die whose origin die hasn't been emitted, and crashing. */ + dwarf2out_abstract_function (decl); + if (! BLOCK_ABSTRACT (stmt)) { dw_die_ref subr_die = new_die (DW_TAG_inlined_subroutine, context_die, stmt); - tree decl = block_ultimate_origin (stmt); char label[MAX_ARTIFICIAL_LABEL_BYTES]; - - /* Emit info for the abstract instance first, if we haven't yet. */ - dwarf2out_abstract_function (decl); add_abstract_origin_attribute (subr_die, decl); ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_BEGIN_LABEL, Index: gcc-3.4/gcc/emit-rtl.c diff -u gcc-3.4/gcc/emit-rtl.c:1.2 gcc-3.4/gcc/emit-rtl.c:1.3 --- gcc-3.4/gcc/emit-rtl.c:1.2 Thu Jan 8 17:03:26 2004 +++ gcc-3.4/gcc/emit-rtl.c Thu Feb 5 10:05:44 2004 @@ -111,9 +111,14 @@ REAL_VALUE_TYPE dconst0; REAL_VALUE_TYPE dconst1; REAL_VALUE_TYPE dconst2; +REAL_VALUE_TYPE dconst3; +REAL_VALUE_TYPE dconst10; REAL_VALUE_TYPE dconstm1; REAL_VALUE_TYPE dconstm2; REAL_VALUE_TYPE dconsthalf; +REAL_VALUE_TYPE dconstthird; +REAL_VALUE_TYPE dconstpi; +REAL_VALUE_TYPE dconste; /* All references to the following fixed hard registers go through these unique rtl objects. On machines where the frame-pointer and @@ -133,8 +138,6 @@ In an inline procedure, the stack and frame pointer rtxs may not be used for anything else. */ -rtx struct_value_rtx; /* (REG:Pmode STRUCT_VALUE_REGNUM) */ -rtx struct_value_incoming_rtx; /* (REG:Pmode STRUCT_VALUE_INCOMING_REGNUM) */ rtx static_chain_rtx; /* (REG:Pmode STATIC_CHAIN_REGNUM) */ rtx static_chain_incoming_rtx; /* (REG:Pmode STATIC_CHAIN_INCOMING_REGNUM) */ rtx pic_offset_table_rtx; /* (REG:Pmode PIC_OFFSET_TABLE_REGNUM) */ @@ -5419,13 +5422,24 @@ REAL_VALUE_FROM_INT (dconst0, 0, 0, double_mode); REAL_VALUE_FROM_INT (dconst1, 1, 0, double_mode); REAL_VALUE_FROM_INT (dconst2, 2, 0, double_mode); + REAL_VALUE_FROM_INT (dconst3, 3, 0, double_mode); + REAL_VALUE_FROM_INT (dconst10, 10, 0, double_mode); REAL_VALUE_FROM_INT (dconstm1, -1, -1, double_mode); REAL_VALUE_FROM_INT (dconstm2, -2, -1, double_mode); dconsthalf = dconst1; dconsthalf.exp--; - for (i = 0; i <= 2; i++) + real_arithmetic (&dconstthird, RDIV_EXPR, &dconst1, &dconst3); + + /* Initialize mathematical constants for constant folding builtins. + These constants need to be given to at least 160 bits precision. */ + real_from_string (&dconstpi, + "3.1415926535897932384626433832795028841971693993751058209749445923078"); + real_from_string (&dconste, + "2.7182818284590452353602874713526624977572470936999595749669676277241"); + + for (i = 0; i < (int) ARRAY_SIZE (const_tiny_rtx); i++) { REAL_VALUE_TYPE *r = (i == 0 ? &dconst0 : i == 1 ? &dconst1 : &dconst2); @@ -5468,23 +5482,6 @@ #ifdef RETURN_ADDRESS_POINTER_REGNUM return_address_pointer_rtx = gen_raw_REG (Pmode, RETURN_ADDRESS_POINTER_REGNUM); -#endif - -#ifdef STRUCT_VALUE - struct_value_rtx = STRUCT_VALUE; -#else - struct_value_rtx = gen_rtx_REG (Pmode, STRUCT_VALUE_REGNUM); -#endif - -#ifdef STRUCT_VALUE_INCOMING - struct_value_incoming_rtx = STRUCT_VALUE_INCOMING; -#else -#ifdef STRUCT_VALUE_INCOMING_REGNUM - struct_value_incoming_rtx - = gen_rtx_REG (Pmode, STRUCT_VALUE_INCOMING_REGNUM); -#else - struct_value_incoming_rtx = struct_value_rtx; -#endif #endif #ifdef STATIC_CHAIN_REGNUM Index: gcc-3.4/gcc/expr.c diff -u gcc-3.4/gcc/expr.c:1.2 gcc-3.4/gcc/expr.c:1.3 --- gcc-3.4/gcc/expr.c:1.2 Thu Jan 8 17:03:26 2004 +++ gcc-3.4/gcc/expr.c Thu Feb 5 10:05:44 2004 @@ -165,6 +165,8 @@ static int is_aligning_offset (tree, tree); static rtx expand_increment (tree, int, int); +static void expand_operands (tree, tree, rtx, rtx*, rtx*, + enum expand_modifier); static rtx do_store_flag (tree, rtx, enum machine_mode, int); #ifdef PUSH_ROUNDING static void emit_single_push_insn (enum machine_mode, rtx, tree); @@ -234,6 +236,9 @@ /* This array records the insn_code of insns to perform block clears. */ enum insn_code clrstr_optab[NUM_MACHINE_MODES]; +/* Stack of EXPR_WITH_FILE_LOCATION nested expressions. */ +struct file_stack *expr_wfl_stack; + /* SLOW_UNALIGNED_ACCESS is nonzero if unaligned accesses are very slow. */ #ifndef SLOW_UNALIGNED_ACCESS @@ -339,15 +344,7 @@ void init_expr (void) { - cfun->expr = ggc_alloc (sizeof (struct expr_status)); - - pending_chain = 0; - pending_stack_adjust = 0; - stack_pointer_delta = 0; - inhibit_defer_pop = 0; - saveregs_value = 0; - apply_args_value = 0; - forced_labels = 0; + cfun->expr = ggc_alloc_cleared (sizeof (struct expr_status)); } /* Small sanity check that the queue is empty at the end of a function. */ @@ -1961,10 +1958,8 @@ dst_addr = copy_to_mode_reg (Pmode, XEXP (dst, 0)); src_addr = copy_to_mode_reg (Pmode, XEXP (src, 0)); -#ifdef POINTERS_EXTEND_UNSIGNED dst_addr = convert_memory_address (ptr_mode, dst_addr); src_addr = convert_memory_address (ptr_mode, src_addr); -#endif dst_tree = make_tree (ptr_type_node, dst_addr); src_tree = make_tree (ptr_type_node, src_addr); @@ -4282,7 +4277,7 @@ since it might be a promoted variable where the zero- or sign- extension needs to be done. Handling this in the normal way is safe because no computation is done before the call. */ - if (TREE_CODE (from) == CALL_EXPR && ! aggregate_value_p (from) + if (TREE_CODE (from) == CALL_EXPR && ! aggregate_value_p (from, from) && TREE_CODE (TYPE_SIZE (TREE_TYPE (from))) == INTEGER_CST && ! ((TREE_CODE (to) == VAR_DECL || TREE_CODE (to) == PARM_DECL) && GET_CODE (DECL_RTL (to)) == REG)) @@ -4303,11 +4298,8 @@ emit_block_move (to_rtx, value, expr_size (from), BLOCK_OP_NORMAL); else { -#ifdef POINTERS_EXTEND_UNSIGNED - if (POINTER_TYPE_P (TREE_TYPE (to)) - && GET_MODE (to_rtx) != GET_MODE (value)) + if (POINTER_TYPE_P (TREE_TYPE (to))) value = convert_memory_address (GET_MODE (to_rtx), value); -#endif emit_move_insn (to_rtx, value); } preserve_temp_slots (to_rtx); @@ -6532,6 +6524,30 @@ return 0; } + +/* Subroutine of expand_expr. Expand the two operands of a binary + expression EXP0 and EXP1 placing the results in OP0 and OP1. + The value may be stored in TARGET if TARGET is nonzero. The + MODIFIER argument is as documented by expand_expr. */ + +static void +expand_operands (tree exp0, tree exp1, rtx target, rtx *op0, rtx *op1, + enum expand_modifier modifier) +{ + if (! safe_from_p (target, exp1, 1)) + target = 0; + if (operand_equal_p (exp0, exp1, 0)) + { + *op0 = expand_expr (exp0, target, VOIDmode, modifier); + *op1 = copy_rtx (*op0); + } + else + { + *op0 = expand_expr (exp0, target, VOIDmode, modifier); + *op1 = expand_expr (exp1, NULL_RTX, VOIDmode, modifier); + } +} + /* expand_expr: generate code for computing expression EXP. An rtx for the computed value is returned. The value is never null. @@ -6576,7 +6592,8 @@ emit_block_move will be flagged with BLOCK_OP_CALL_PARM. */ rtx -expand_expr (tree exp, rtx target, enum machine_mode tmode, enum expand_modifier modifier) +expand_expr (tree exp, rtx target, enum machine_mode tmode, + enum expand_modifier modifier) { rtx op0, op1, temp; tree type = TREE_TYPE (exp); @@ -6715,7 +6732,7 @@ if (! cse_not_expected && mode != BLKmode && target && (GET_CODE (target) != REG || REGNO (target) < FIRST_PSEUDO_REGISTER) && ! (code == CONSTRUCTOR && GET_MODE_SIZE (mode) > UNITS_PER_WORD) - && ! (code == CALL_EXPR && aggregate_value_p (exp))) + && ! (code == CALL_EXPR && aggregate_value_p (exp, exp))) target = 0; switch (code) @@ -6743,8 +6760,7 @@ case PARM_DECL: if (!DECL_RTL_SET_P (exp)) { - error ("%Hprior parameter's size depends on '%D'", - &DECL_SOURCE_LOCATION (exp), exp); + error ("%Jprior parameter's size depends on '%D'", exp, exp); return CONST0_RTX (mode); } @@ -6943,14 +6959,23 @@ case EXPR_WITH_FILE_LOCATION: { rtx to_return; - location_t saved_loc = input_location; + struct file_stack fs; + + fs.location = input_location; + fs.next = expr_wfl_stack; input_filename = EXPR_WFL_FILENAME (exp); input_line = EXPR_WFL_LINENO (exp); + expr_wfl_stack = &fs; if (EXPR_WFL_EMIT_LINE_NOTE (exp)) emit_line_note (input_location); /* Possibly avoid switching back and forth here. */ - to_return = expand_expr (EXPR_WFL_NODE (exp), target, tmode, modifier); - input_location = saved_loc; + to_return = expand_expr (EXPR_WFL_NODE (exp), + (ignore ? const0_rtx : target), + tmode, modifier); + if (expr_wfl_stack != &fs) + abort (); + input_location = fs.location; + expr_wfl_stack = fs.next; return to_return; } @@ -8121,11 +8146,11 @@ { op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, modifier); - /* Don't go to both_summands if modifier - says it's not right to return a PLUS. */ - if (modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER) - goto binop2; - goto both_summands; + /* Return a PLUS if modifier says it's OK. */ + if (modifier == EXPAND_SUM + || modifier == EXPAND_INITIALIZER) + return simplify_gen_binary (PLUS, mode, op0, op1); + goto binop2; } /* Use immed_double_const to ensure that the constant is truncated according to the mode of OP1, then sign extended @@ -8152,12 +8177,8 @@ if ((modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER) || mode != ptr_mode) { - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - if (! operand_equal_p (TREE_OPERAND (exp, 0), - TREE_OPERAND (exp, 1), 0)) - op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0); - else - op1 = op0; + expand_operands (TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1), + subtarget, &op0, &op1, 0); if (op0 == const0_rtx) return op1; if (op1 == const0_rtx) @@ -8165,62 +8186,9 @@ goto binop2; } - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, modifier); - if (! operand_equal_p (TREE_OPERAND (exp, 0), - TREE_OPERAND (exp, 1), 0)) - op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, - VOIDmode, modifier); - else - op1 = op0; - - /* We come here from MINUS_EXPR when the second operand is a - constant. */ - both_summands: - /* Make sure any term that's a sum with a constant comes last. */ - if (GET_CODE (op0) == PLUS - && CONSTANT_P (XEXP (op0, 1))) - { - temp = op0; - op0 = op1; - op1 = temp; - } - /* If adding to a sum including a constant, - associate it to put the constant outside. */ - if (GET_CODE (op1) == PLUS - && CONSTANT_P (XEXP (op1, 1))) - { - rtx constant_term = const0_rtx; - - temp = simplify_binary_operation (PLUS, mode, XEXP (op1, 0), op0); - if (temp != 0) - op0 = temp; - /* Ensure that MULT comes first if there is one. */ - else if (GET_CODE (op0) == MULT) - op0 = gen_rtx_PLUS (mode, op0, XEXP (op1, 0)); - else - op0 = gen_rtx_PLUS (mode, XEXP (op1, 0), op0); - - /* Let's also eliminate constants from op0 if possible. */ - op0 = eliminate_constant_term (op0, &constant_term); - - /* CONSTANT_TERM and XEXP (op1, 1) are known to be constant, so - their sum should be a constant. Form it into OP1, since the - result we want will then be OP0 + OP1. */ - - temp = simplify_binary_operation (PLUS, mode, constant_term, - XEXP (op1, 1)); - if (temp != 0) - op1 = temp; - else - op1 = gen_rtx_PLUS (mode, constant_term, XEXP (op1, 1)); - } - - /* Put a constant term last and put a multiplication first. */ - if (CONSTANT_P (op0) || GET_CODE (op1) == MULT) - temp = op1, op1 = op0, op0 = temp; - - temp = simplify_binary_operation (PLUS, mode, op0, op1); - return temp ? temp : gen_rtx_PLUS (mode, op0, op1); + expand_operands (TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1), + subtarget, &op0, &op1, modifier); + return simplify_gen_binary (PLUS, mode, op0, op1); case MINUS_EXPR: /* For initializers, we are allowed to return a MINUS of two @@ -8232,10 +8200,8 @@ && really_constant_p (TREE_OPERAND (exp, 0)) && really_constant_p (TREE_OPERAND (exp, 1))) { - rtx op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, - modifier); - rtx op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, - modifier); + expand_operands (TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1), + NULL_RTX, &op0, &op1, modifier); /* If the last operand is a CONST_INT, use plus_constant of the negated constant. Else make the MINUS. */ @@ -8257,17 +8223,14 @@ || mode != ptr_mode) goto binop; - if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1), 1)) - subtarget = 0; - - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, modifier); - op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, modifier); + expand_operands (TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1), + subtarget, &op0, &op1, modifier); /* Convert A - const to A + (-const). */ if (GET_CODE (op1) == CONST_INT) { op1 = negate_rtx (mode, op1); - goto both_summands; + return simplify_gen_binary (PLUS, mode, op0, op1); } goto binop2; @@ -8356,14 +8319,14 @@ { if (this_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing) { - op0 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 0), 0), - NULL_RTX, VOIDmode, 0); if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST) - op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, - VOIDmode, 0); + expand_operands (TREE_OPERAND (TREE_OPERAND (exp, 0), 0), + TREE_OPERAND (exp, 1), + NULL_RTX, &op0, &op1, 0); else - op1 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 1), 0), - NULL_RTX, VOIDmode, 0); + expand_operands (TREE_OPERAND (TREE_OPERAND (exp, 0), 0), + TREE_OPERAND (TREE_OPERAND (exp, 1), 0), + NULL_RTX, &op0, &op1, 0); goto binop2; } else if (other_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing @@ -8392,12 +8355,8 @@ } } } - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - if (! operand_equal_p (TREE_OPERAND (exp, 0), - TREE_OPERAND (exp, 1), 0)) - op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0); - else - op1 = op0; + expand_operands (TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1), + subtarget, &op0, &op1, 0); return expand_mult (mode, op0, op1, target, unsignedp); case TRUNC_DIV_EXPR: @@ -8405,15 +8364,13 @@ case CEIL_DIV_EXPR: case ROUND_DIV_EXPR: case EXACT_DIV_EXPR: - if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1), 1)) - subtarget = 0; if (modifier == EXPAND_STACK_PARM) target = 0; /* Possible optimization: compute the dividend with EXPAND_SUM then if the divisor is constant can optimize the case where some terms of the dividend have coeffs divisible by it. */ - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0); + expand_operands (TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1), + subtarget, &op0, &op1, 0); return expand_divmod (0, code, mode, op0, op1, target, unsignedp); case RDIV_EXPR: @@ -8435,12 +8392,10 @@ case FLOOR_MOD_EXPR: case CEIL_MOD_EXPR: case ROUND_MOD_EXPR: - if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1), 1)) - subtarget = 0; if (modifier == EXPAND_STACK_PARM) target = 0; - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0); + expand_operands (TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1), + subtarget, &op0, &op1, 0); return expand_divmod (1, code, mode, op0, op1, target, unsignedp); case FIX_ROUND_EXPR: @@ -8509,8 +8464,8 @@ || (GET_CODE (target) == REG && REGNO (target) < FIRST_PSEUDO_REGISTER)) target = gen_reg_rtx (mode); - op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0); - op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0); + expand_operands (TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1), + target, &op0, &op1, 0); /* First try to do it with a special MIN or MAX instruction. If that does not win, use a conditional jump to select the proper @@ -8567,43 +8522,6 @@ abort (); return temp; - case FFS_EXPR: - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - if (modifier == EXPAND_STACK_PARM) - target = 0; - temp = expand_unop (mode, ffs_optab, op0, target, 1); - if (temp == 0) - abort (); - return temp; - - case CLZ_EXPR: - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - temp = expand_unop (mode, clz_optab, op0, target, 1); - if (temp == 0) - abort (); - return temp; - - case CTZ_EXPR: - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - temp = expand_unop (mode, ctz_optab, op0, target, 1); - if (temp == 0) - abort (); - return temp; - - case POPCOUNT_EXPR: - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - temp = expand_unop (mode, popcount_optab, op0, target, 1); - if (temp == 0) - abort (); - return temp; - - case PARITY_EXPR: - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - temp = expand_unop (mode, parity_optab, op0, target, 1); - if (temp == 0) - abort (); - return temp; - /* ??? Can optimize bitwise operations with one arg constant. Can optimize (a bitwise1 n) bitwise2 (a bitwise3 b) and (a bitwise1 b) bitwise2 b (etc) @@ -9307,11 +9225,8 @@ if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER) { op0 = XEXP (op0, 0); -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (op0) == Pmode && GET_MODE (op0) != mode - && mode == ptr_mode) + if (GET_MODE (op0) == Pmode && mode == ptr_mode) op0 = convert_memory_address (ptr_mode, op0); -#endif return op0; } @@ -9372,11 +9287,8 @@ && ! REG_USERVAR_P (op0)) mark_reg_pointer (op0, TYPE_ALIGN (TREE_TYPE (type))); -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (op0) == Pmode && GET_MODE (op0) != mode - && mode == ptr_mode) + if (GET_MODE (op0) == Pmode && mode == ptr_mode) op0 = convert_memory_address (ptr_mode, op0); -#endif return op0; @@ -9565,10 +9477,8 @@ /* Here to do an ordinary binary operator, generating an instruction from the optab already placed in `this_optab'. */ binop: - if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1), 1)) - subtarget = 0; - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0); + expand_operands (TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1), + subtarget, &op0, &op1, 0); binop2: if (modifier == EXPAND_STACK_PARM) target = 0; @@ -10067,8 +9977,7 @@ || ! safe_from_p (subtarget, arg1, 1)) subtarget = 0; - op0 = expand_expr (arg0, subtarget, VOIDmode, 0); - op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0); + expand_operands (arg0, arg1, subtarget, &op0, &op1, 0); if (target == 0) target = gen_reg_rtx (mode); Index: gcc-3.4/gcc/fold-const.c diff -u gcc-3.4/gcc/fold-const.c:1.2 gcc-3.4/gcc/fold-const.c:1.3 --- gcc-3.4/gcc/fold-const.c:1.2 Thu Jan 8 17:03:27 2004 +++ gcc-3.4/gcc/fold-const.c Thu Feb 5 10:05:44 2004 @@ -110,6 +110,7 @@ static tree fold_mathfn_compare (enum built_in_function, enum tree_code, tree, tree, tree); static tree fold_inf_compare (enum tree_code, tree, tree, tree); +static bool tree_swap_operands_p (tree, tree); /* The following constants represent a bit based encoding of GCC's comparison operators. This encoding simplifies transformations @@ -1110,10 +1111,6 @@ low = int1l & int2l, hi = int1h & int2h; break; - case BIT_ANDTC_EXPR: - low = int1l & ~int2l, hi = int1h & ~int2h; - break; - case RSHIFT_EXPR: int2l = -int2l; case LSHIFT_EXPR: @@ -1828,13 +1825,27 @@ || code == TRUTH_XOR_EXPR || code == TRUTH_NOT_EXPR); } -/* Return nonzero if two operands are necessarily equal. +/* Return nonzero if two operands (typically of the same tree node) + are necessarily equal. If either argument has side-effects this + function returns zero. + If ONLY_CONST is nonzero, only return nonzero for constants. This function tests whether the operands are indistinguishable; it does not test whether they are equal using C's == operation. The distinction is important for IEEE floating point, because (1) -0.0 and 0.0 are distinguishable, but -0.0==0.0, and - (2) two NaNs may be indistinguishable, but NaN!=NaN. */ + (2) two NaNs may be indistinguishable, but NaN!=NaN. + + If ONLY_CONST is zero, a VAR_DECL is considered equal to itself + even though it may hold multiple values during a function. + This is because a GCC tree node guarantees that nothing else is + executed between the evaluation of its "operands" (which may often + be evaluated in arbitrary order). Hence if the operands themselves + don't side-effect, the VAR_DECLs, PARM_DECLs etc... must hold the + same value in each operand/subexpression. Hence a zero value for + ONLY_CONST assumes isochronic (or instantaneous) tree equivalence. + If comparing arbitrary expression trees, such as from different + statements, ONLY_CONST must usually be nonzero. */ int operand_equal_p (tree arg0, tree arg1, int only_const) @@ -4971,6 +4982,49 @@ return NULL_TREE; } +/* Test whether it is preferable two swap two operands, ARG0 and + ARG1, for example because ARG0 is an integer constant and ARG1 + isn't. */ + +static bool +tree_swap_operands_p (tree arg0, tree arg1) +{ + STRIP_SIGN_NOPS (arg0); + STRIP_SIGN_NOPS (arg1); + + if (TREE_CODE (arg1) == INTEGER_CST) + return 0; + if (TREE_CODE (arg0) == INTEGER_CST) + return 1; + + if (TREE_CODE (arg1) == REAL_CST) + return 0; + if (TREE_CODE (arg0) == REAL_CST) + return 1; + + if (TREE_CODE (arg1) == COMPLEX_CST) + return 0; + if (TREE_CODE (arg0) == COMPLEX_CST) + return 1; + + if (TREE_CONSTANT (arg1)) + return 0; + if (TREE_CONSTANT (arg0)) + return 1; + + if (DECL_P (arg1)) + return 0; + if (DECL_P (arg0)) + return 1; + + if (TREE_CODE (arg1) == SAVE_EXPR) + return 0; + if (TREE_CODE (arg0) == SAVE_EXPR) + return 1; + + return 0; +} + /* Perform constant folding and related simplification of EXPR. The related simplifications include x*1 => x, x*0 => 0, etc., and application of the associative law. @@ -5030,8 +5084,7 @@ subop = arg0; if (subop != 0 && TREE_CODE (subop) != INTEGER_CST - && TREE_CODE (subop) != REAL_CST - ) + && TREE_CODE (subop) != REAL_CST) /* Note that TREE_CONSTANT isn't enough: static var addresses are constant but we can't do arithmetic on them. */ @@ -5083,16 +5136,8 @@ if ((code == PLUS_EXPR || code == MULT_EXPR || code == MIN_EXPR || code == MAX_EXPR || code == BIT_IOR_EXPR || code == BIT_XOR_EXPR || code == BIT_AND_EXPR) - && ((TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) != INTEGER_CST) - || (TREE_CODE (arg0) == REAL_CST && TREE_CODE (arg1) != REAL_CST))) - { - tem = arg0; arg0 = arg1; arg1 = tem; - - if (t == orig_t) - t = copy_node (t); - TREE_OPERAND (t, 0) = arg0; - TREE_OPERAND (t, 1) = arg1; - } + && tree_swap_operands_p (arg0, arg1)) + return fold (build (code, type, arg1, arg0)); /* Now WINS is set as described above, ARG0 is the first operand of EXPR, @@ -6113,10 +6158,20 @@ return build_function_call_expr (sqrtfn, arglist); } - /* Optimize exp(x)*exp(y) as exp(x+y). */ - if ((fcode0 == BUILT_IN_EXP && fcode1 == BUILT_IN_EXP) - || (fcode0 == BUILT_IN_EXPF && fcode1 == BUILT_IN_EXPF) - || (fcode0 == BUILT_IN_EXPL && fcode1 == BUILT_IN_EXPL)) + /* Optimize expN(x)*expN(y) as expN(x+y). */ + if (fcode0 == fcode1 + && (fcode0 == BUILT_IN_EXP + || fcode0 == BUILT_IN_EXPF + || fcode0 == BUILT_IN_EXPL + || fcode0 == BUILT_IN_EXP2 + || fcode0 == BUILT_IN_EXP2F + || fcode0 == BUILT_IN_EXP2L + || fcode0 == BUILT_IN_EXP10 + || fcode0 == BUILT_IN_EXP10F + || fcode0 == BUILT_IN_EXP10L + || fcode0 == BUILT_IN_POW10 + || fcode0 == BUILT_IN_POW10F + || fcode0 == BUILT_IN_POW10L)) { tree expfn = TREE_OPERAND (TREE_OPERAND (arg0, 0), 0); tree arg = build (PLUS_EXPR, type, @@ -6329,7 +6384,6 @@ goto bit_rotate; case BIT_AND_EXPR: - bit_and: if (integer_all_onesp (arg1)) return non_lvalue (convert (type, arg0)); if (integer_zerop (arg1)) @@ -6367,19 +6421,6 @@ goto associate; - case BIT_ANDTC_EXPR: - if (integer_all_onesp (arg0)) - return non_lvalue (convert (type, arg1)); - if (integer_zerop (arg0)) - return omit_one_operand (type, arg0, arg1); - if (TREE_CODE (arg1) == INTEGER_CST) - { - arg1 = fold (build1 (BIT_NOT_EXPR, type, arg1)); - code = BIT_AND_EXPR; - goto bit_and; - } - goto binary; - case RDIV_EXPR: /* Don't touch a floating-point divide by zero unless the mode of the constant can represent infinity. */ @@ -6462,10 +6503,19 @@ if (flag_unsafe_math_optimizations) { enum built_in_function fcode = builtin_mathfn_code (arg1); - /* Optimize x/exp(y) into x*exp(-y). */ + /* Optimize x/expN(y) into x*expN(-y). */ if (fcode == BUILT_IN_EXP || fcode == BUILT_IN_EXPF - || fcode == BUILT_IN_EXPL) + || fcode == BUILT_IN_EXPL + || fcode == BUILT_IN_EXP2 + || fcode == BUILT_IN_EXP2F + || fcode == BUILT_IN_EXP2L + || fcode == BUILT_IN_EXP10 + || fcode == BUILT_IN_EXP10F + || fcode == BUILT_IN_EXP10L + || fcode == BUILT_IN_POW10 + || fcode == BUILT_IN_POW10F + || fcode == BUILT_IN_POW10L) { tree expfn = TREE_OPERAND (TREE_OPERAND (arg1, 0), 0); tree arg = build1 (NEGATE_EXPR, type, @@ -6643,18 +6693,10 @@ RROTATE_EXPR by a new constant. */ if (code == LROTATE_EXPR && TREE_CODE (arg1) == INTEGER_CST) { - if (t == orig_t) - t = copy_node (t); - TREE_SET_CODE (t, RROTATE_EXPR); - code = RROTATE_EXPR; - TREE_OPERAND (t, 1) = arg1 - = const_binop - (MINUS_EXPR, - convert (TREE_TYPE (arg1), - build_int_2 (GET_MODE_BITSIZE (TYPE_MODE (type)), 0)), - arg1, 0); - if (tree_int_cst_sgn (arg1) < 0) - return t; + tree tem = build_int_2 (GET_MODE_BITSIZE (TYPE_MODE (type)), 0); + tem = convert (TREE_TYPE (arg1), tem); + tem = const_binop (MINUS_EXPR, tem, arg1, 0); + return fold (build (RROTATE_EXPR, type, arg0, tem)); } /* If we have a rotate of a bit operation with the rotate count and @@ -6662,7 +6704,6 @@ permute the two operations. */ if (code == RROTATE_EXPR && TREE_CODE (arg1) == INTEGER_CST && (TREE_CODE (arg0) == BIT_AND_EXPR - || TREE_CODE (arg0) == BIT_ANDTC_EXPR || TREE_CODE (arg0) == BIT_IOR_EXPR || TREE_CODE (arg0) == BIT_XOR_EXPR) && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) @@ -6852,20 +6893,8 @@ case LE_EXPR: case GE_EXPR: /* If one arg is a real or integer constant, put it last. */ - if ((TREE_CODE (arg0) == INTEGER_CST - && TREE_CODE (arg1) != INTEGER_CST) - || (TREE_CODE (arg0) == REAL_CST - && TREE_CODE (arg0) != REAL_CST)) - { - if (t == orig_t) - t = copy_node (t); - TREE_OPERAND (t, 0) = arg1; - TREE_OPERAND (t, 1) = arg0; - arg0 = TREE_OPERAND (t, 0); - arg1 = TREE_OPERAND (t, 1); - code = swap_tree_comparison (code); - TREE_SET_CODE (t, code); - } + if (tree_swap_operands_p (arg0, arg1)) + return fold (build (swap_tree_comparison (code), type, arg1, arg0)); if (FLOAT_TYPE_P (TREE_TYPE (arg0))) { @@ -7122,16 +7151,12 @@ switch (code) { case GE_EXPR: - code = GT_EXPR; arg1 = const_binop (MINUS_EXPR, arg1, integer_one_node, 0); - t = build (code, type, TREE_OPERAND (t, 0), arg1); - break; + return fold (build (GT_EXPR, type, arg0, arg1)); case LT_EXPR: - code = LE_EXPR; arg1 = const_binop (MINUS_EXPR, arg1, integer_one_node, 0); - t = build (code, type, TREE_OPERAND (t, 0), arg1); - break; + return fold (build (LE_EXPR, type, arg0, arg1)); default: break; @@ -7174,24 +7199,17 @@ convert (type, integer_zero_node), arg0); case GE_EXPR: - code = EQ_EXPR; - if (t == orig_t) - t = copy_node (t); - TREE_SET_CODE (t, EQ_EXPR); - break; + return fold (build (EQ_EXPR, type, arg0, arg1)); + case LE_EXPR: return omit_one_operand (type, convert (type, integer_one_node), arg0); case LT_EXPR: - code = NE_EXPR; - if (t == orig_t) - t = copy_node (t); - TREE_SET_CODE (t, NE_EXPR); - break; + return fold (build (NE_EXPR, type, arg0, arg1)); /* The GE_EXPR and LT_EXPR cases above are not normally - reached because of previous transformations. */ + reached because of previous transformations. */ default: break; @@ -7201,15 +7219,11 @@ switch (code) { case GT_EXPR: - code = EQ_EXPR; arg1 = const_binop (PLUS_EXPR, arg1, integer_one_node, 0); - t = build (code, type, TREE_OPERAND (t, 0), arg1); - break; + return fold (build (EQ_EXPR, type, arg0, arg1)); case LE_EXPR: - code = NE_EXPR; arg1 = const_binop (PLUS_EXPR, arg1, integer_one_node, 0); - t = build (code, type, TREE_OPERAND (t, 0), arg1); - break; + return fold (build (NE_EXPR, type, arg0, arg1)); default: break; } @@ -7222,22 +7236,14 @@ convert (type, integer_zero_node), arg0); case LE_EXPR: - code = EQ_EXPR; - if (t == orig_t) - t = copy_node (t); - TREE_SET_CODE (t, EQ_EXPR); - break; + return fold (build (EQ_EXPR, type, arg0, arg1)); case GE_EXPR: return omit_one_operand (type, convert (type, integer_one_node), arg0); case GT_EXPR: - code = NE_EXPR; - if (t == orig_t) - t = copy_node (t); - TREE_SET_CODE (t, NE_EXPR); - break; + return fold (build (NE_EXPR, type, arg0, arg1)); default: break; @@ -7247,15 +7253,11 @@ switch (code) { case GE_EXPR: - code = NE_EXPR; arg1 = const_binop (MINUS_EXPR, arg1, integer_one_node, 0); - t = build (code, type, TREE_OPERAND (t, 0), arg1); - break; + return fold (build (NE_EXPR, type, arg0, arg1)); case LT_EXPR: - code = EQ_EXPR; arg1 = const_binop (MINUS_EXPR, arg1, integer_one_node, 0); - t = build (code, type, TREE_OPERAND (t, 0), arg1); - break; + return fold (build (EQ_EXPR, type, arg0, arg1)); default: break; } @@ -7431,8 +7433,11 @@ && TREE_CODE (arg1) == INTEGER_CST && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) { - tree dandnotc = fold (build (BIT_ANDTC_EXPR, TREE_TYPE (arg0), - arg1, TREE_OPERAND (arg0, 1))); + tree dandnotc + = fold (build (BIT_AND_EXPR, TREE_TYPE (arg0), + arg1, build1 (BIT_NOT_EXPR, + TREE_TYPE (TREE_OPERAND (arg0, 1)), + TREE_OPERAND (arg0, 1)))); tree rslt = code == EQ_EXPR ? integer_zero_node : integer_one_node; if (integer_nonzerop (dandnotc)) return omit_one_operand (type, rslt, arg0); @@ -7445,8 +7450,10 @@ && TREE_CODE (arg1) == INTEGER_CST && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) { - tree candnotd = fold (build (BIT_ANDTC_EXPR, TREE_TYPE (arg0), - TREE_OPERAND (arg0, 1), arg1)); + tree candnotd + = fold (build (BIT_AND_EXPR, TREE_TYPE (arg0), + TREE_OPERAND (arg0, 1), + build1 (BIT_NOT_EXPR, TREE_TYPE (arg1), arg1))); tree rslt = code == EQ_EXPR ? integer_zero_node : integer_one_node; if (integer_nonzerop (candnotd)) return omit_one_operand (type, rslt, arg0); @@ -7483,16 +7490,17 @@ switch (code) { case EQ_EXPR: + if (! FLOAT_TYPE_P (TREE_TYPE (arg0)) + || ! HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0)))) + return constant_boolean_node (1, type); + break; + case GE_EXPR: case LE_EXPR: if (! FLOAT_TYPE_P (TREE_TYPE (arg0)) || ! HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0)))) return constant_boolean_node (1, type); - code = EQ_EXPR; - if (t == orig_t) - t = copy_node (t); - TREE_SET_CODE (t, code); - break; + return fold (build (EQ_EXPR, type, arg0, arg1)); case NE_EXPR: /* For NE, we can only do this simplification if integer @@ -7773,34 +7781,6 @@ else if (operand_equal_p (arg1, TREE_OPERAND (expr, 2), 0)) return pedantic_omit_one_operand (type, arg1, arg0); - /* If the second operand is zero, invert the comparison and swap - the second and third operands. Likewise if the second operand - is constant and the third is not or if the third operand is - equivalent to the first operand of the comparison. */ - - if (integer_zerop (arg1) - || (TREE_CONSTANT (arg1) && ! TREE_CONSTANT (TREE_OPERAND (t, 2))) - || (TREE_CODE_CLASS (TREE_CODE (arg0)) == '<' - && operand_equal_for_comparison_p (TREE_OPERAND (arg0, 0), - TREE_OPERAND (t, 2), - TREE_OPERAND (arg0, 1)))) - { - /* See if this can be inverted. If it can't, possibly because - it was a floating-point inequality comparison, don't do - anything. */ - tem = invert_truthvalue (arg0); - - if (TREE_CODE (tem) != TRUTH_NOT_EXPR) - { - t = build (code, type, tem, - TREE_OPERAND (t, 2), TREE_OPERAND (t, 1)); - arg0 = tem; - /* arg1 should be the first argument of the new T. */ - arg1 = TREE_OPERAND (t, 1); - STRIP_NOPS (arg1); - } - } - /* If we have A op B ? A : C, we may be able to convert this to a simpler expression, depending on the operation and the values of B and C. Signed zeros prevent all of these transformations, @@ -7976,9 +7956,8 @@ case EQ_EXPR: /* We can replace A with C1 in this case. */ arg1 = convert (type, TREE_OPERAND (arg0, 1)); - t = build (code, type, TREE_OPERAND (t, 0), arg1, - TREE_OPERAND (t, 2)); - break; + return fold (build (code, type, TREE_OPERAND (t, 0), arg1, + TREE_OPERAND (t, 2))); case LT_EXPR: /* If C1 is C2 + 1, this is min(A, C2). */ @@ -8028,11 +8007,7 @@ /* If the second operand is simpler than the third, swap them since that produces better jump optimization results. */ - if ((TREE_CONSTANT (arg1) || DECL_P (arg1) - || TREE_CODE (arg1) == SAVE_EXPR) - && ! (TREE_CONSTANT (TREE_OPERAND (t, 2)) - || DECL_P (TREE_OPERAND (t, 2)) - || TREE_CODE (TREE_OPERAND (t, 2)) == SAVE_EXPR)) + if (tree_swap_operands_p (TREE_OPERAND (t, 1), TREE_OPERAND (t, 2))) { /* See if this can be inverted. If it can't, possibly because it was a floating-point inequality comparison, don't do @@ -8040,14 +8015,8 @@ tem = invert_truthvalue (arg0); if (TREE_CODE (tem) != TRUTH_NOT_EXPR) - { - t = build (code, type, tem, - TREE_OPERAND (t, 2), TREE_OPERAND (t, 1)); - arg0 = tem; - /* arg1 should be the first argument of the new T. */ - arg1 = TREE_OPERAND (t, 1); - STRIP_NOPS (arg1); - } + return fold (build (code, type, tem, + TREE_OPERAND (t, 2), TREE_OPERAND (t, 1))); } /* Convert A ? 1 : 0 to simply A. */ @@ -8538,18 +8507,8 @@ switch (TREE_CODE (t)) { case ABS_EXPR: - case FFS_EXPR: - case POPCOUNT_EXPR: - case PARITY_EXPR: return 1; - case CLZ_EXPR: - case CTZ_EXPR: - /* These are undefined at zero. This is true even if - C[LT]Z_DEFINED_VALUE_AT_ZERO is set, since what we're - computing here is a user-visible property. */ - return 0; - case INTEGER_CST: return tree_int_cst_sgn (t) >= 0; @@ -8687,9 +8646,27 @@ case BUILT_IN_EXP: case BUILT_IN_EXPF: case BUILT_IN_EXPL: + case BUILT_IN_EXP2: + case BUILT_IN_EXP2F: + case BUILT_IN_EXP2L: + case BUILT_IN_EXP10: + case BUILT_IN_EXP10F: + case BUILT_IN_EXP10L: case BUILT_IN_FABS: case BUILT_IN_FABSF: case BUILT_IN_FABSL: + case BUILT_IN_FFS: + case BUILT_IN_FFSL: + case BUILT_IN_FFSLL: + case BUILT_IN_PARITY: + case BUILT_IN_PARITYL: + case BUILT_IN_PARITYLL: + case BUILT_IN_POPCOUNT: + case BUILT_IN_POPCOUNTL: + case BUILT_IN_POPCOUNTLL: + case BUILT_IN_POW10: + case BUILT_IN_POW10F: + case BUILT_IN_POW10L: case BUILT_IN_SQRT: case BUILT_IN_SQRTF: case BUILT_IN_SQRTL: Index: gcc-3.4/gcc/function.c diff -u gcc-3.4/gcc/function.c:1.2 gcc-3.4/gcc/function.c:1.3 --- gcc-3.4/gcc/function.c:1.2 Thu Jan 8 17:03:27 2004 +++ gcc-3.4/gcc/function.c Thu Feb 5 10:05:44 2004 @@ -62,6 +62,8 @@ #include "tm_p.h" #include "integrate.h" #include "langhooks.h" +#include "target.h" + #include "llvm-out.h" #ifndef TRAMPOLINE_ALIGNMENT @@ -76,6 +78,8 @@ #define STACK_ALIGNMENT_NEEDED 1 #endif +#define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT) + /* Some systems use __main in a way incompatible with its use in gcc, in these cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to give the same symbol without quotes for an alternative entry point. You @@ -285,7 +289,7 @@ static int insns_for_mem_comp (const void *, const void *); static int insns_for_mem_walk (rtx *, void *); static void compute_insns_for_mem (rtx, rtx, htab_t); -static void prepare_function_start (void); +static void prepare_function_start (tree); static void do_clobber_return_reg (rtx, void *); static void do_use_return_reg (rtx, void *); static void instantiate_virtual_regs_lossage (rtx); @@ -878,8 +882,7 @@ if (decl && size == -1 && TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST) { - error ("%Hsize of variable '%D' is too large", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jsize of variable '%D' is too large", decl, decl); size = 1; } @@ -4178,16 +4181,37 @@ EXP may be a type node or an expression (whose type is tested). */ int -aggregate_value_p (tree exp) +aggregate_value_p (tree exp, tree fntype) { int i, regno, nregs; rtx reg; tree type = (TYPE_P (exp)) ? exp : TREE_TYPE (exp); + if (fntype) + switch (TREE_CODE (fntype)) + { + case CALL_EXPR: + fntype = get_callee_fndecl (fntype); + fntype = fntype ? TREE_TYPE (fntype) : 0; + break; + case FUNCTION_DECL: + fntype = TREE_TYPE (fntype); + break; + case FUNCTION_TYPE: + case METHOD_TYPE: + break; + case IDENTIFIER_NODE: + fntype = 0; + break; + default: + /* We don't expect other rtl types here. */ + abort(); + } + if (TREE_CODE (type) == VOID_TYPE) return 0; - if (RETURN_IN_MEMORY (type)) + if (targetm.calls.return_in_memory (type, fntype)) return 1; /* Types that are TREE_ADDRESSABLE must be constructed in memory, and thus can't be returned in registers. */ @@ -4231,9 +4255,7 @@ /* This is a dummy PARM_DECL that we used for the function result if the function returns a structure. */ tree function_result_decl = 0; -#ifdef SETUP_INCOMING_VARARGS int varargs_setup = 0; -#endif int reg_parm_stack_space = 0; rtx conversion_insns = 0; @@ -4266,9 +4288,9 @@ stack_args_size.var = 0; /* If struct value address is treated as the first argument, make it so. */ - if (aggregate_value_p (DECL_RESULT (fndecl)) + if (aggregate_value_p (DECL_RESULT (fndecl), fndecl) && ! current_function_returns_pcc_struct - && struct_value_incoming_rtx == 0) + && targetm.calls.struct_value_rtx (TREE_TYPE (fndecl), 1) == 0) { tree type = build_pointer_type (TREE_TYPE (fntype)); @@ -4320,6 +4342,7 @@ int last_named = 0, named_arg; int in_regs; int partial = 0; + int pretend_bytes = 0; /* Set LAST_NAMED if this is last named arg before last anonymous args. */ @@ -4337,7 +4360,7 @@ /* Set NAMED_ARG if this arg should be treated as a named arg. For most machines, if this is a varargs/stdarg function, then we treat the last named arg as if it were anonymous too. */ - named_arg = STRICT_ARGUMENT_NAMING ? 1 : ! last_named; + named_arg = targetm.calls.strict_argument_naming (&args_so_far) ? 1 : ! last_named; if (TREE_TYPE (parm) == error_mark_node /* This can happen after weird syntax errors @@ -4402,11 +4425,12 @@ promoted_mode = passed_mode; -#ifdef PROMOTE_FUNCTION_ARGS - /* Compute the mode in which the arg is actually extended to. */ - unsignedp = TREE_UNSIGNED (passed_type); - promoted_mode = promote_mode (passed_type, promoted_mode, &unsignedp, 1); -#endif + if (targetm.calls.promote_function_args (TREE_TYPE (fndecl))) + { + /* Compute the mode in which the arg is actually extended to. */ + unsignedp = TREE_UNSIGNED (passed_type); + promoted_mode = promote_mode (passed_type, promoted_mode, &unsignedp, 1); + } /* Let machine desc say which reg (if any) the parm arrives in. 0 means it arrives on the stack. */ @@ -4421,7 +4445,6 @@ if (entry_parm == 0) promoted_mode = passed_mode; -#ifdef SETUP_INCOMING_VARARGS /* If this is the last named parameter, do any required setup for varargs or stdargs. We need to know about the case of this being an addressable type, in which case we skip the registers it @@ -4434,11 +4457,18 @@ Also, indicate when RTL generation is to be suppressed. */ if (last_named && !varargs_setup) { - SETUP_INCOMING_VARARGS (args_so_far, promoted_mode, passed_type, - current_function_pretend_args_size, 0); + int varargs_pretend_bytes = 0; + targetm.calls.setup_incoming_varargs (&args_so_far, promoted_mode, + passed_type, + &varargs_pretend_bytes, 0); varargs_setup = 1; + + /* If the back-end has requested extra stack space, record how + much is needed. Do not change pretend_args_size otherwise + since it may be nonzero from an earlier partial argument. */ + if (varargs_pretend_bytes > 0) + current_function_pretend_args_size = varargs_pretend_bytes; } -#endif /* Determine parm's home in the stack, in case it arrives in the stack or we should pretend it did. @@ -4458,7 +4488,8 @@ #endif if (!in_regs && !named_arg) { - int pretend_named = PRETEND_OUTGOING_VARARGS_NAMED; + int pretend_named = + targetm.calls.pretend_outgoing_varargs_named (&args_so_far); if (pretend_named) { #ifdef FUNCTION_INCOMING_ARG @@ -4480,8 +4511,43 @@ #ifdef FUNCTION_ARG_PARTIAL_NREGS if (entry_parm) - partial = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, promoted_mode, - passed_type, named_arg); + { + partial = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, promoted_mode, + passed_type, named_arg); + if (partial +#ifndef MAYBE_REG_PARM_STACK_SPACE + /* The caller might already have allocated stack space + for the register parameters. */ + && reg_parm_stack_space == 0 +#endif + ) + { + /* Part of this argument is passed in registers and part + is passed on the stack. Ask the prologue code to extend + the stack part so that we can recreate the full value. + + PRETEND_BYTES is the size of the registers we need to store. + CURRENT_FUNCTION_PRETEND_ARGS_SIZE is the amount of extra + stack space that the prologue should allocate. + + Internally, gcc assumes that the argument pointer is + aligned to STACK_BOUNDARY bits. This is used both for + alignment optimisations (see init_emit) and to locate + arguments that are aligned to more than PARM_BOUNDARY + bits. We must preserve this invariant by rounding + CURRENT_FUNCTION_PRETEND_ARGS_SIZE up to a stack + boundary. */ + pretend_bytes = partial * UNITS_PER_WORD; + current_function_pretend_args_size + = CEIL_ROUND (pretend_bytes, STACK_BYTES); + + /* If PRETEND_BYTES != CURRENT_FUNCTION_PRETEND_ARGS_SIZE, + insert the padding before the start of the first pretend + argument. */ + stack_args_size.constant + = (current_function_pretend_args_size - pretend_bytes); + } + } #endif memset (&locate, 0, sizeof (locate)); @@ -4526,17 +4592,6 @@ if (partial) { -#ifndef MAYBE_REG_PARM_STACK_SPACE - /* When REG_PARM_STACK_SPACE is nonzero, stack space for - split parameters was allocated by our caller, so we - won't be pushing it in the prolog. */ - if (reg_parm_stack_space == 0) -#endif - current_function_pretend_args_size - = (((partial * UNITS_PER_WORD) + (PARM_BOUNDARY / BITS_PER_UNIT) - 1) - / (PARM_BOUNDARY / BITS_PER_UNIT) - * (PARM_BOUNDARY / BITS_PER_UNIT)); - /* Handle calls that pass values in multiple non-contiguous locations. The Irix 6 ABI has examples of this. */ if (GET_CODE (entry_parm) == PARALLEL) @@ -4580,10 +4635,7 @@ #endif ) { - stack_args_size.constant += locate.size.constant; - /* locate.size doesn't include the part in regs. */ - if (partial) - stack_args_size.constant += current_function_pretend_args_size; + stack_args_size.constant += pretend_bytes + locate.size.constant; if (locate.size.var) ADD_PARM_SIZE (stack_args_size, locate.size.var); } @@ -5131,11 +5183,7 @@ rtx addr = DECL_RTL (function_result_decl); rtx x; -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (addr) != Pmode) - addr = convert_memory_address (Pmode, addr); -#endif - + addr = convert_memory_address (Pmode, addr); x = gen_rtx_MEM (DECL_MODE (result), addr); set_mem_attributes (x, result, 1); SET_DECL_RTL (result, x); @@ -5155,8 +5203,6 @@ #endif #endif -#define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT) - current_function_args_size = ((current_function_args_size + STACK_BYTES - 1) / STACK_BYTES) * STACK_BYTES; @@ -5276,8 +5322,6 @@ that REGNO is promoted from and whether the promotion was signed or unsigned. */ -#ifdef PROMOTE_FUNCTION_ARGS - rtx promoted_input_arg (unsigned int regno, enum machine_mode *pmode, int *punsignedp) { @@ -5305,7 +5349,6 @@ return 0; } -#endif /* Compute the size and offset from the start of the stacked arguments for a parm passed in mode PASSED_MODE and with type TYPE. @@ -5568,15 +5611,15 @@ if we want to warn. */ && (DECL_INITIAL (decl) == NULL_TREE || lang_hooks.decl_uninit (decl)) && regno_uninitialized (REGNO (DECL_RTL (decl)))) - warning ("%H'%D' might be used uninitialized in this function", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%J'%D' might be used uninitialized in this function", + decl, decl); if (extra_warnings && TREE_CODE (decl) == VAR_DECL && DECL_RTL (decl) != 0 && GET_CODE (DECL_RTL (decl)) == REG && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl)))) - warning ("%Hvariable '%D' might be clobbered by `longjmp' or `vfork'", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jvariable '%D' might be clobbered by `longjmp' or `vfork'", + decl, decl); } for (sub = BLOCK_SUBBLOCKS (block); sub; sub = TREE_CHAIN (sub)) uninitialized_vars_warning (sub); @@ -5594,8 +5637,8 @@ if (DECL_RTL (decl) != 0 && GET_CODE (DECL_RTL (decl)) == REG && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl)))) - warning ("%Hargument '%D' might be clobbered by `longjmp' or `vfork'", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jargument '%D' might be clobbered by `longjmp' or `vfork'", + decl, decl); } /* If this function call setjmp, put all vars into the stack @@ -6247,105 +6290,77 @@ return NULL_TREE; } -/* Allocate a function structure and reset its contents to the defaults. */ +/* Allocate a function structure for FNDECL and set its contents + to the defaults. */ -static void -prepare_function_start (void) +void +allocate_struct_function (tree fndecl) { - cfun = ggc_alloc_cleared (sizeof (struct function)); - - init_stmt_for_function (); - init_eh_for_function (); + tree result; - cse_not_expected = ! optimize; + cfun = ggc_alloc_cleared (sizeof (struct function)); - /* Caller save not needed yet. */ - caller_save_needed = 0; + max_parm_reg = LAST_VIRTUAL_REGISTER + 1; - /* No stack slots have been made yet. */ - stack_slot_list = 0; + cfun->stack_alignment_needed = STACK_BOUNDARY; + cfun->preferred_stack_boundary = STACK_BOUNDARY; - current_function_has_nonlocal_label = 0; - current_function_has_nonlocal_goto = 0; + current_function_funcdef_no = funcdef_no++; - /* There is no stack slot for handling nonlocal gotos. */ - nonlocal_goto_handler_slots = 0; - nonlocal_goto_stack_level = 0; + cfun->function_frequency = FUNCTION_FREQUENCY_NORMAL; - /* No labels have been declared for nonlocal use. */ - nonlocal_labels = 0; - nonlocal_goto_handler_labels = 0; + init_stmt_for_function (); + init_eh_for_function (); + init_emit (); + init_expr (); + init_varasm_status (cfun); - /* No function calls so far in this function. */ - function_call_count = 0; + (*lang_hooks.function.init) (cfun); + if (init_machine_status) + cfun->machine = (*init_machine_status) (); - /* No parm regs have been allocated. - (This is important for output_inline_function.) */ - max_parm_reg = LAST_VIRTUAL_REGISTER + 1; + if (fndecl == NULL) + return; - /* Initialize the RTL mechanism. */ - if (!EMIT_LLVM) - init_emit (); + DECL_SAVED_INSNS (fndecl) = cfun; + cfun->decl = fndecl; - /* Initialize the queue of pending postincrement and postdecrements, - and some other info in expr.c. */ - init_expr (); + current_function_name = (*lang_hooks.decl_printable_name) (fndecl, 2); - /* We haven't done register allocation yet. */ - reg_renumber = 0; - - if (!EMIT_LLVM) - init_varasm_status (cfun); - - /* Clear out data used for inlining. */ - cfun->inlinable = 0; - cfun->original_decl_initial = 0; - cfun->original_arg_vector = 0; + result = DECL_RESULT (fndecl); + if (aggregate_value_p (result, fndecl)) + { +#ifdef PCC_STATIC_STRUCT_RETURN + current_function_returns_pcc_struct = 1; +#endif + current_function_returns_struct = 1; + } - cfun->stack_alignment_needed = STACK_BOUNDARY; - cfun->preferred_stack_boundary = STACK_BOUNDARY; + current_function_returns_pointer = POINTER_TYPE_P (TREE_TYPE (result)); - /* Set if a call to setjmp is seen. */ - current_function_calls_setjmp = 0; + current_function_needs_context + = (decl_function_context (current_function_decl) != 0 + && ! DECL_NO_STATIC_CHAIN (current_function_decl)); +} - /* Set if a call to longjmp is seen. */ - current_function_calls_longjmp = 0; +/* Reset cfun, and other non-struct-function variables to defaults as + appropriate for emiiting rtl at the start of a function. */ - current_function_calls_alloca = 0; - current_function_calls_eh_return = 0; - current_function_calls_constant_p = 0; - current_function_contains_functions = 0; - current_function_is_leaf = 0; - current_function_nothrow = 0; - current_function_sp_is_unchanging = 0; - current_function_uses_only_leaf_regs = 0; - current_function_has_computed_jump = 0; - current_function_is_thunk = 0; - - current_function_returns_pcc_struct = 0; - current_function_returns_struct = 0; - current_function_epilogue_delay_list = 0; - current_function_uses_const_pool = 0; - current_function_uses_pic_offset_table = 0; - current_function_cannot_inline = 0; - - /* We have not yet needed to make a label to jump to for tail-recursion. */ - tail_recursion_label = 0; - - /* We haven't had a need to make a save area for ap yet. */ - arg_pointer_save_area = 0; - - /* No stack slots allocated yet. */ - frame_offset = 0; +static void +prepare_function_start (tree fndecl) +{ + if (fndecl && DECL_SAVED_INSNS (fndecl)) + cfun = DECL_SAVED_INSNS (fndecl); + else + allocate_struct_function (fndecl); - /* No SAVE_EXPRs in this function yet. */ - save_expr_regs = 0; + cse_not_expected = ! optimize; - /* No RTL_EXPRs in this function yet. */ - rtl_expr_chain = 0; + /* Caller save not needed yet. */ + caller_save_needed = 0; - /* Set up to allocate temporaries. */ - init_temp_slots (); + /* We haven't done register allocation yet. */ + reg_renumber = 0; /* Indicate that we need to distinguish between the return value of the present function and the return value of a function being called. */ @@ -6359,27 +6374,6 @@ /* Indicate we have no need of a frame pointer yet. */ frame_pointer_needed = 0; - - /* By default assume not stdarg. */ - current_function_stdarg = 0; - - /* We haven't made any trampolines for this function yet. */ - trampoline_list = 0; - - init_pending_stack_adjust (); - inhibit_defer_pop = 0; - - current_function_outgoing_args_size = 0; - - current_function_funcdef_no = funcdef_no++; - - cfun->function_frequency = FUNCTION_FREQUENCY_NORMAL; - - cfun->max_jumptable_ents = 0; - - (*lang_hooks.function.init) (cfun); - if (init_machine_status) - cfun->machine = (*init_machine_status) (); } /* Initialize the rtl expansion mechanism so that we can do simple things @@ -6388,7 +6382,7 @@ void init_dummy_function_start (void) { - prepare_function_start (); + prepare_function_start (NULL); } /* Generate RTL for the start of the function SUBR (a FUNCTION_DECL tree node) @@ -6398,51 +6392,30 @@ void init_function_start (tree subr) { - prepare_function_start (); - - current_function_name = (*lang_hooks.decl_printable_name) (subr, 2); - cfun->decl = subr; - - /* Nonzero if this is a nested function that uses a static chain. */ - - current_function_needs_context - = (decl_function_context (current_function_decl) != 0 - && ! DECL_NO_STATIC_CHAIN (current_function_decl)); + prepare_function_start (subr); if (!EMIT_LLVM) { /* Within function body, compute a type's size as soon it is laid out. */ immediate_size_expand++; - - /* Prevent ever trying to delete the first instruction of a - function. Also tell final how to output a linenum before the - function prologue. Note linenums could be missing, e.g. when - compiling a Java .class file. */ - if (DECL_SOURCE_LINE (subr)) - emit_line_note (DECL_SOURCE_LOCATION (subr)); - - /* Make sure first insn is a note even if we don't want linenums. - This makes sure the first insn will never be deleted. - Also, final expects a note to appear there. */ - emit_note (NOTE_INSN_DELETED); } - /* Set flags used by final.c. */ - if (aggregate_value_p (DECL_RESULT (subr))) - { -#ifdef PCC_STATIC_STRUCT_RETURN - current_function_returns_pcc_struct = 1; -#endif - current_function_returns_struct = 1; - } - + /* Prevent ever trying to delete the first instruction of a + function. Also tell final how to output a linenum before the + function prologue. Note linenums could be missing, e.g. when + compiling a Java .class file. */ + if (DECL_SOURCE_LINE (subr)) + emit_line_note (DECL_SOURCE_LOCATION (subr)); + + /* Make sure first insn is a note even if we don't want linenums. + This makes sure the first insn will never be deleted. + Also, final expects a note to appear there. */ + emit_note (NOTE_INSN_DELETED); + /* Warn if this value is an aggregate type, regardless of which calling convention we are using for it. */ if (warn_aggregate_return && AGGREGATE_TYPE_P (TREE_TYPE (DECL_RESULT (subr)))) warning ("function returns an aggregate"); - - current_function_returns_pointer - = POINTER_TYPE_P (TREE_TYPE (DECL_RESULT (subr))); } /* Make sure all values used by the optimization passes have sane @@ -6588,7 +6561,7 @@ before any library calls that assign parms might generate. */ /* Decide whether to return the value in memory or in a register. */ - if (aggregate_value_p (DECL_RESULT (subr))) + if (aggregate_value_p (DECL_RESULT (subr), subr)) { /* Returning something that won't go in a register. */ rtx value_address = 0; @@ -6602,13 +6575,14 @@ else #endif { + rtx sv = targetm.calls.struct_value_rtx (TREE_TYPE (subr), 1); /* Expect to be passed the address of a place to store the value. If it is passed as an argument, assign_parms will take care of it. */ - if (struct_value_incoming_rtx) + if (sv) { value_address = gen_reg_rtx (Pmode); - emit_move_insn (value_address, struct_value_incoming_rtx); + emit_move_insn (value_address, sv); } } if (value_address) @@ -6925,8 +6899,7 @@ decl; decl = TREE_CHAIN (decl)) if (! TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl)) - warning ("%Hunused parameter '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Junused parameter '%D'", decl, decl); } /* Delete handlers for nonlocal gotos if nothing uses them. */ @@ -7048,10 +7021,9 @@ { int unsignedp = TREE_UNSIGNED (TREE_TYPE (decl_result)); -#ifdef PROMOTE_FUNCTION_RETURN - promote_mode (TREE_TYPE (decl_result), GET_MODE (decl_rtl), - &unsignedp, 1); -#endif + if (targetm.calls.promote_function_return (TREE_TYPE (current_function_decl))) + promote_mode (TREE_TYPE (decl_result), GET_MODE (decl_rtl), + &unsignedp, 1); convert_move (real_decl_rtl, decl_rtl, unsignedp); } @@ -7097,12 +7069,9 @@ assignment and USE below when inlining this function. */ REG_FUNCTION_VALUE_P (outgoing) = 1; -#ifdef POINTERS_EXTEND_UNSIGNED /* The address may be ptr_mode and OUTGOING may be Pmode. */ - if (GET_MODE (outgoing) != GET_MODE (value_address)) - value_address = convert_memory_address (GET_MODE (outgoing), - value_address); -#endif + value_address = convert_memory_address (GET_MODE (outgoing), + value_address); emit_move_insn (outgoing, value_address); Index: gcc-3.4/gcc/gcc.c diff -u gcc-3.4/gcc/gcc.c:1.2 gcc-3.4/gcc/gcc.c:1.3 --- gcc-3.4/gcc/gcc.c:1.2 Thu Jan 8 17:03:27 2004 +++ gcc-3.4/gcc/gcc.c Thu Feb 5 10:05:44 2004 @@ -1441,21 +1441,6 @@ #define MD_STARTFILE_PREFIX_1 "" #endif -/* Supply defaults for the standard prefixes. */ - -#ifndef STANDARD_EXEC_PREFIX -#define STANDARD_EXEC_PREFIX "/usr/local/lib/gcc/" -#endif -#ifndef STANDARD_STARTFILE_PREFIX -#define STANDARD_STARTFILE_PREFIX "/usr/local/lib/" -#endif -#ifndef TOOLDIR_BASE_PREFIX -#define TOOLDIR_BASE_PREFIX "/usr/local/" -#endif -#ifndef STANDARD_BINDIR_PREFIX -#define STANDARD_BINDIR_PREFIX "/usr/local/bin" -#endif - static const char *const standard_exec_prefix = STANDARD_EXEC_PREFIX; static const char *const standard_exec_prefix_1 = "/usr/libexec/gcc/"; static const char *const standard_exec_prefix_2 = "/usr/lib/gcc/"; @@ -3245,7 +3230,7 @@ if (IS_DIR_SEPARATOR (*temp) && strncmp (temp + 1, "lib", 3) == 0 && IS_DIR_SEPARATOR (temp[4]) - && strncmp (temp + 5, "gcc", 7) == 0) + && strncmp (temp + 5, "gcc", 3) == 0) len -= sizeof ("/lib/gcc/") - 1; } @@ -6165,12 +6150,15 @@ /* If standard_startfile_prefix is relative, base it on standard_exec_prefix. This lets us move the installed tree as a unit. If GCC_EXEC_PREFIX is defined, base - standard_startfile_prefix on that as well. */ + standard_startfile_prefix on that as well. + + If the prefix is relative, only search it for native compilers; + otherwise we will search a directory containing host libraries. */ if (IS_ABSOLUTE_PATH (standard_startfile_prefix)) add_sysrooted_prefix (&startfile_prefixes, standard_startfile_prefix, "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1); - else + else if (*cross_compile == '0') { if (gcc_exec_prefix) add_prefix (&startfile_prefixes, Index: gcc-3.4/gcc/integrate.c diff -u gcc-3.4/gcc/integrate.c:1.2 gcc-3.4/gcc/integrate.c:1.3 --- gcc-3.4/gcc/integrate.c:1.2 Thu Jan 8 17:03:27 2004 +++ gcc-3.4/gcc/integrate.c Thu Feb 5 10:05:45 2004 @@ -493,7 +493,7 @@ } cfun->original_decl_initial = DECL_INITIAL (fndecl); cfun->no_debugging_symbols = (write_symbols == NO_DEBUG); - DECL_SAVED_INSNS (fndecl) = cfun; + cfun->saved_for_inline = 1; /* Clean up. */ if (! flag_no_inline) @@ -1029,7 +1029,7 @@ else { if (! structure_value_addr - || ! aggregate_value_p (DECL_RESULT (fndecl))) + || ! aggregate_value_p (DECL_RESULT (fndecl), fndecl)) abort (); /* Pass the function the address in which to return a structure @@ -1284,7 +1284,7 @@ out of the temp register into a BLKmode memory object. */ if (target && TYPE_MODE (TREE_TYPE (TREE_TYPE (fndecl))) == BLKmode - && ! aggregate_value_p (TREE_TYPE (TREE_TYPE (fndecl)))) + && ! aggregate_value_p (TREE_TYPE (TREE_TYPE (fndecl)), fndecl)) target = copy_blkmode_from_reg (0, target, TREE_TYPE (TREE_TYPE (fndecl))); if (structure_value_addr) @@ -2158,11 +2158,7 @@ #endif temp = XEXP (temp, 0); - -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (temp) != GET_MODE (orig)) - temp = convert_memory_address (GET_MODE (orig), temp); -#endif + temp = convert_memory_address (GET_MODE (orig), temp); return temp; } else if (GET_CODE (constant) == LABEL_REF) Index: gcc-3.4/gcc/langhooks-def.h diff -u gcc-3.4/gcc/langhooks-def.h:1.2 gcc-3.4/gcc/langhooks-def.h:1.3 --- gcc-3.4/gcc/langhooks-def.h:1.2 Thu Jan 8 17:03:27 2004 +++ gcc-3.4/gcc/langhooks-def.h Thu Feb 5 10:05:45 2004 @@ -24,6 +24,8 @@ #include "hooks.h" +#include "llvm-out.h" + struct diagnostic_context; struct llvm_value; struct llvm_function; @@ -49,7 +51,9 @@ extern bool lhd_post_options (const char **); extern HOST_WIDE_INT lhd_get_alias_set (tree); extern tree lhd_return_tree (tree); +extern tree lhd_return_null_tree_v (void); extern tree lhd_return_null_tree (tree); +extern tree lhd_do_nothing_iii_return_null_tree (int, int, int); extern int lhd_safe_from_p (rtx, tree); extern int lhd_staticp (tree); extern int lhd_unsafe_for_reeval (tree); @@ -71,6 +75,7 @@ extern bool lhd_warn_unused_global_decl (tree); extern void lhd_incomplete_type_error (tree, tree); extern tree lhd_type_promotes_to (tree); +extern void lhd_register_builtin_type (tree, const char *); extern bool lhd_decl_ok_for_sibcall (tree); extern tree lhd_expr_size (tree); extern bool lhd_decl_uninit (tree); @@ -91,6 +96,8 @@ extern void lhd_tree_inlining_end_inlining (tree); extern tree lhd_tree_inlining_convert_parm_for_inlining (tree, tree, tree); extern void lhd_initialize_diagnostics (struct diagnostic_context *); +extern tree lhd_callgraph_analyze_expr (tree *, int *, tree); + #define LANG_HOOKS_NAME "GNU unknown" #define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct lang_identifier) @@ -137,6 +144,17 @@ #define LANG_HOOKS_FUNCTION_ENTER_NESTED lhd_do_nothing_f #define LANG_HOOKS_FUNCTION_LEAVE_NESTED lhd_do_nothing_f +#define LANG_HOOKS_RTL_EXPAND_START lhd_do_nothing +#define LANG_HOOKS_RTL_EXPAND_STMT (void (*) (tree)) abort +#define LANG_HOOKS_RTL_EXPAND_END lhd_do_nothing + +#ifdef EMIT_LLVM +/* LLVM Code Generation Hooks (akin to RTL Generation Hooks above) */ +#define LANG_HOOKS_LLVM_IR_EXPAND_START lhd_do_nothing +#define LANG_HOOKS_LLVM_IR_EXPAND_STMT (void (*) (tree)) abort +#define LANG_HOOKS_LLVM_IR_EXPAND_END lhd_do_nothing +#endif + /* Attribute hooks. */ #define LANG_HOOKS_ATTRIBUTE_TABLE NULL #define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE NULL @@ -183,15 +201,17 @@ LANG_HOOKS_TREE_INLINING_END_INLINING, \ LANG_HOOKS_TREE_INLINING_CONVERT_PARM_FOR_INLINING, \ LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS \ -} \ +} -#define LANG_HOOKS_CALLGRAPH_LOWER_FUNCTION NULL +#define LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR lhd_callgraph_analyze_expr #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION NULL +#define LANG_HOOKS_LLVM_CALLGRAPH_EXPAND_FUNCTION abort #define LANG_HOOKS_CALLGRAPH_INITIALIZER { \ - LANG_HOOKS_CALLGRAPH_LOWER_FUNCTION, \ + LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR, \ LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION, \ -} \ + LANG_HOOKS_LLVM_CALLGRAPH_EXPAND_FUNCTION, \ +} #define LANG_HOOKS_FUNCTION_INITIALIZER { \ LANG_HOOKS_FUNCTION_INIT, \ @@ -200,6 +220,20 @@ LANG_HOOKS_FUNCTION_LEAVE_NESTED \ } +#define LANG_HOOKS_RTL_EXPAND_INITIALIZER { \ + LANG_HOOKS_RTL_EXPAND_START, \ + LANG_HOOKS_RTL_EXPAND_STMT, \ + LANG_HOOKS_RTL_EXPAND_END \ +} + +#ifdef EMIT_LLVM +#define LANG_HOOKS_LLVM_EXPAND_INITIALIZER { \ + LANG_HOOKS_LLVM_IR_EXPAND_START, \ + LANG_HOOKS_LLVM_IR_EXPAND_STMT, \ + LANG_HOOKS_LLVM_IR_EXPAND_END \ +} +#endif + /* Tree dump hooks. */ extern bool lhd_tree_dump_dump_tree (void *, tree); extern int lhd_tree_dump_type_quals (tree); @@ -217,6 +251,7 @@ #define LANG_HOOKS_MAKE_TYPE make_node #define LANG_HOOKS_INCOMPLETE_TYPE_ERROR lhd_incomplete_type_error #define LANG_HOOKS_TYPE_PROMOTES_TO lhd_type_promotes_to +#define LANG_HOOKS_REGISTER_BUILTIN_TYPE lhd_register_builtin_type #define LANG_HOOKS_FOR_TYPES_INITIALIZER { \ LANG_HOOKS_MAKE_TYPE, \ @@ -226,6 +261,7 @@ LANG_HOOKS_SIGNED_TYPE, \ LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE, \ LANG_HOOKS_TYPE_PROMOTES_TO, \ + LANG_HOOKS_REGISTER_BUILTIN_TYPE, \ LANG_HOOKS_INCOMPLETE_TYPE_ERROR \ } @@ -237,6 +273,7 @@ #define LANG_HOOKS_SET_BLOCK set_block #define LANG_HOOKS_PUSHDECL pushdecl #define LANG_HOOKS_GETDECLS getdecls +#define LANG_HOOKS_BUILTIN_TYPE_DECLS lhd_return_null_tree_v #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl #define LANG_HOOKS_WRITE_GLOBALS write_global_declarations #define LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE NULL @@ -250,6 +287,7 @@ LANG_HOOKS_SET_BLOCK, \ LANG_HOOKS_PUSHDECL, \ LANG_HOOKS_GETDECLS, \ + LANG_HOOKS_BUILTIN_TYPE_DECLS, \ LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \ LANG_HOOKS_WRITE_GLOBALS, \ LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE, \ @@ -307,7 +345,9 @@ LANG_HOOKS_CALLGRAPH_INITIALIZER, \ LANG_HOOKS_TREE_DUMP_INITIALIZER, \ LANG_HOOKS_DECLS, \ - LANG_HOOKS_FOR_TYPES_INITIALIZER \ + LANG_HOOKS_FOR_TYPES_INITIALIZER, \ + LANG_HOOKS_RTL_EXPAND_INITIALIZER, \ + LANG_HOOKS_LLVM_EXPAND_INITIALIZER \ } #endif /* GCC_LANG_HOOKS_DEF_H */ Index: gcc-3.4/gcc/langhooks.c diff -u gcc-3.4/gcc/langhooks.c:1.2 gcc-3.4/gcc/langhooks.c:1.3 --- gcc-3.4/gcc/langhooks.c:1.2 Thu Jan 8 17:03:27 2004 +++ gcc-3.4/gcc/langhooks.c Thu Feb 5 10:05:45 2004 @@ -33,6 +33,7 @@ #include "langhooks.h" #include "langhooks-def.h" #include "ggc.h" +#include "diagnostic.h" /* Do nothing; in many cases the default hook. */ @@ -55,6 +56,16 @@ { } +/* Do nothing (int, int, int). Return NULL_TREE. */ + +tree +lhd_do_nothing_iii_return_null_tree (int i ATTRIBUTE_UNUSED, + int j ATTRIBUTE_UNUSED, + int k ATTRIBUTE_UNUSED) +{ + return NULL_TREE; +} + /* Do nothing (function). */ void @@ -73,6 +84,14 @@ /* Do nothing (return NULL_TREE). */ tree +lhd_return_null_tree_v (void) +{ + return NULL_TREE; +} + +/* Do nothing (return NULL_TREE). */ + +tree lhd_return_null_tree (tree t ATTRIBUTE_UNUSED) { return NULL_TREE; @@ -207,6 +226,13 @@ abort (); } +/* Registration of machine- or os-specific builtin types. */ +void +lhd_register_builtin_type (tree type ATTRIBUTE_UNUSED, + const char* name ATTRIBUTE_UNUSED) +{ +} + /* Invalid use of an incomplete type. */ void lhd_incomplete_type_error (tree value ATTRIBUTE_UNUSED, tree type) @@ -525,6 +551,48 @@ void lhd_initialize_diagnostics (struct diagnostic_context *ctx ATTRIBUTE_UNUSED) { +} + +/* The default function to print out name of current function that caused + an error. */ +void +lhd_print_error_function (diagnostic_context *context, const char *file) +{ + if (diagnostic_last_function_changed (context)) + { + const char *old_prefix = context->printer->prefix; + char *new_prefix = file ? file_name_as_prefix (file) : NULL; + + pp_set_prefix (context->printer, new_prefix); + + if (current_function_decl == NULL) + pp_printf (context->printer, "At top level:"); + else + { + if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE) + pp_printf + (context->printer, "In member function `%s':", + (*lang_hooks.decl_printable_name) (current_function_decl, 2)); + else + pp_printf + (context->printer, "In function `%s':", + (*lang_hooks.decl_printable_name) (current_function_decl, 2)); + } + pp_newline (context->printer); + + diagnostic_set_last_function (context); + pp_flush (context->printer); + context->printer->prefix = old_prefix; + free ((char*) new_prefix); + } +} + +tree +lhd_callgraph_analyze_expr (tree *tp ATTRIBUTE_UNUSED, + int *walk_subtrees ATTRIBUTE_UNUSED, + tree decl ATTRIBUTE_UNUSED) +{ + return NULL; } #include "gt-langhooks.h" Index: gcc-3.4/gcc/langhooks.h diff -u gcc-3.4/gcc/langhooks.h:1.2 gcc-3.4/gcc/langhooks.h:1.3 --- gcc-3.4/gcc/langhooks.h:1.2 Thu Jan 8 17:03:27 2004 +++ gcc-3.4/gcc/langhooks.h Thu Feb 5 10:05:45 2004 @@ -23,6 +23,8 @@ /* This file should be #include-d after tree.h. */ +#include "llvm-representation.h" + struct diagnostic_context; struct llvm_value; struct llvm_function; @@ -56,11 +58,15 @@ struct lang_hooks_for_callgraph { - /* Function passed as argument is needed and will be compiled. - Lower the representation so the calls are explicit. */ - void (*lower_function) (tree); + /* The node passed is a language-specific tree node. If its contents + are relevant to use of other declarations, mark them. */ + tree (*analyze_expr) (tree *, int *, tree); + /* Produce RTL for function passed as argument. */ void (*expand_function) (tree); + + /* Produce LLVM bytecode for function passed as argument. */ + void (*llvm_expand_function) (tree); }; /* Lang hooks for management of language-specific data or status @@ -80,6 +86,34 @@ void (*leave_nested) (struct function *); }; +/* Lang hooks for rtl code generation. */ +struct lang_hooks_for_rtl_expansion +{ + /* Called after expand_function_start, but before expanding the body. */ + void (*start) (void); + + /* Called to expand each statement. */ + void (*stmt) (tree); + + /* Called after expanding the body but before expand_function_end. */ + void (*end) (void); +}; + +/* Lang hooks for LLVM code generation + * (based off of lang_hooks_for_rtl_expansion) + */ +struct lang_hooks_for_llvm_expansion +{ + /* Called after expand_function_start, but before expanding the body. */ + void (*start) (void); + + /* Called to expand each statement. */ + void (*stmt) (llvm_function *, tree); + + /* Called after expanding the body but before expand_function_end. */ + void (*end) (void); +}; + /* The following hooks are used by tree-dump.c. */ struct lang_hooks_for_tree_dump @@ -126,6 +160,15 @@ arguments. The default hook aborts. */ tree (*type_promotes_to) (tree); + /* Register TYPE as a builtin type with the indicated NAME. The + TYPE is placed in the outermost lexical scope. The semantics + should be analogous to: + + typedef TYPE NAME; + + in C. The default hook ignores the declaration. */ + void (*register_builtin_type) (tree, const char *); + /* This routine is called in tree.c to print an error message for invalid use of an incomplete type. VALUE is the expression that was used (or 0 if that isn't known) and TYPE is the type that was @@ -169,6 +212,9 @@ /* Returns the chain of decls so far in the current scope level. */ tree (*getdecls) (void); + /* Returns a chain of TYPE_DECLs for built-in types. */ + tree (*builtin_type_decls) (void); + /* Returns true when we should warn for an unused global DECL. We will already have checked that it has static binding. */ bool (*warn_unused_global) (tree); @@ -404,8 +450,12 @@ struct lang_hooks_for_types types; + struct lang_hooks_for_rtl_expansion rtl_expand; + /* Whenever you add entries here, make sure you adjust langhooks-def.h and langhooks.c accordingly. */ + + struct lang_hooks_for_llvm_expansion llvm_expand; }; /* Each front end provides its own. */ Index: gcc-3.4/gcc/llvm-expand.c diff -u gcc-3.4/gcc/llvm-expand.c:1.7 gcc-3.4/gcc/llvm-expand.c:1.8 --- gcc-3.4/gcc/llvm-expand.c:1.7 Tue Feb 3 12:29:24 2004 +++ gcc-3.4/gcc/llvm-expand.c Thu Feb 5 10:05:45 2004 @@ -2848,8 +2848,16 @@ /* Perform necessary processing */ if ((fndecl = get_callee_fndecl (exp))) { + /* + * Mark the function decl so that we can take the address of it. + */ (*lang_hooks.mark_addressable) (fndecl); + /* + * Mark the function as referenced. + */ + mark_referenced (DECL_ASSEMBLER_NAME(fndecl)); + if (DECL_NAME(fndecl) && IDENTIFIER_POINTER(DECL_NAME(fndecl))) { const char *Name = IDENTIFIER_POINTER(DECL_NAME(fndecl)); unsigned NameLen = IDENTIFIER_LENGTH(DECL_NAME(fndecl)); @@ -6205,7 +6213,6 @@ return llvm_type_get_cannonical_function(BaseType); } - /* Initialize the function, adding arguments to the function as appropriate. Set up parameters and prepare for return, for the function. If subr is an external function, we just set up the arguments. @@ -6262,14 +6269,17 @@ Fn = (llvm_function*)DECL_LLVM(subr); /* No more processing for external functions. */ - if (isExternal) return Fn; + if (isExternal) { + return Fn; + } /* If there is already a body for this function, it's a wierd error. The only * case we allow is if the old function was linkonce. - */ + */ if (!llvm_ilist_empty(llvm_basicblock, Fn->BasicBlocks)) { assert(Fn->Linkage == L_LinkOnce && "Cannot redefine non-linkonce functions!"); + warning ("LLVM: LinkOnce function redefined to external!"); llvm_ilist_clear(llvm_basicblock, Fn->BasicBlocks); llvm_ilist_clear(llvm_argument, Fn->Arguments); Fn->Linkage = L_External; @@ -6726,3 +6736,9 @@ llvm_type *ClassTy = llvm_type_get_from_tree(ty); return D2V(make_temporary_alloca(Fn, ClassTy)); } + +const char *llvm_get_decl_name(llvm_value *V) { + assert ((V != NULL) && "llvm_get_decl_name: Null value!"); + return V->Name; +} + Index: gcc-3.4/gcc/llvm-out.c diff -u gcc-3.4/gcc/llvm-out.c:1.1 gcc-3.4/gcc/llvm-out.c:1.2 --- gcc-3.4/gcc/llvm-out.c:1.1 Thu Jan 8 16:35:32 2004 +++ gcc-3.4/gcc/llvm-out.c Thu Feb 5 10:05:45 2004 @@ -27,7 +27,8 @@ #include "tree.h" #include "tree-inline.h" #include "flags.h" -#include "c-tree.h" +/* #include "c-tree.h" */ +#include "tree.h" #include "toplev.h" #include "ggc.h" #include "tm_p.h" @@ -53,6 +54,7 @@ void llvm_init_codegen() { flag_inline_functions = 0; flag_really_no_inline = 1; + flag_unit_at_a_time = 0; warn_inline = 0; llvm_InitializeProgram(); @@ -143,7 +145,7 @@ to run global initializers, etc. */ if (DECL_NAME (fndecl) && MAIN_NAME_P (DECL_NAME (fndecl)) - && C_DECL_FILE_SCOPE (fndecl)) + && DECL_FILE_SCOPE_P (fndecl)) llvm_expand_main_function (Func); /* Generate LLVM for this function body. */ Index: gcc-3.4/gcc/llvm-out.h diff -u gcc-3.4/gcc/llvm-out.h:1.2 gcc-3.4/gcc/llvm-out.h:1.3 --- gcc-3.4/gcc/llvm-out.h:1.2 Mon Feb 2 12:39:26 2004 +++ gcc-3.4/gcc/llvm-out.h Thu Feb 5 10:05:45 2004 @@ -62,6 +62,9 @@ void llvm_emit_final_program(const char *version); void llvm_program_print(FILE *); +struct llvm_value; +const char *llvm_get_decl_name(struct llvm_value*); + #if EMIT_LLVM /* FIXME: We should eventually implement this for crtstuff.c! This is used for exception handling stuff... */ Index: gcc-3.4/gcc/loop.c diff -u gcc-3.4/gcc/loop.c:1.2 gcc-3.4/gcc/loop.c:1.3 --- gcc-3.4/gcc/loop.c:1.2 Fri Jan 9 10:54:24 2004 +++ gcc-3.4/gcc/loop.c Thu Feb 5 10:05:45 2004 @@ -22,8 +22,8 @@ /* This is the loop optimization pass of the compiler. It finds invariant computations within loops and moves them to the beginning of the loop. Then it identifies basic and - general induction variables. - + general induction variables. + Basic induction variables (BIVs) are a pseudo registers which are set within a loop only by incrementing or decrementing its value. General induction variables (GIVs) are pseudo registers with a value which is a linear function @@ -4231,7 +4231,6 @@ return; } - /* Communication with routines called via `note_stores'. */ static rtx note_insn; @@ -7742,25 +7741,16 @@ /* Update register info for alias analysis. */ - if (seq == NULL_RTX) - return; - - if (INSN_P (seq)) + insn = seq; + while (insn != NULL_RTX) { - insn = seq; - while (insn != NULL_RTX) - { - rtx set = single_set (insn); + rtx set = single_set (insn); - if (set && GET_CODE (SET_DEST (set)) == REG) - record_base_value (REGNO (SET_DEST (set)), SET_SRC (set), 0); + if (set && GET_CODE (SET_DEST (set)) == REG) + record_base_value (REGNO (SET_DEST (set)), SET_SRC (set), 0); - insn = NEXT_INSN (insn); - } + insn = NEXT_INSN (insn); } - else if (GET_CODE (seq) == SET - && GET_CODE (SET_DEST (seq)) == REG) - record_base_value (REGNO (SET_DEST (seq)), SET_SRC (seq), 0); } @@ -7990,7 +7980,7 @@ /* Try to compute whether the compare/branch at the loop end is one or two instructions. */ - get_condition (jump, &first_compare); + get_condition (jump, &first_compare, false); if (first_compare == jump) compare_and_branch = 1; else if (first_compare == prev_nonnote_insn (jump)) @@ -9153,11 +9143,12 @@ If WANT_REG is nonzero, we wish the condition to be relative to that register, if possible. Therefore, do not canonicalize the condition - further. */ + further. If ALLOW_CC_MODE is nonzero, allow the condition returned + to be a compare to a CC mode register. */ rtx canonicalize_condition (rtx insn, rtx cond, int reverse, rtx *earliest, - rtx want_reg) + rtx want_reg, int allow_cc_mode) { enum rtx_code code; rtx prev = insn; @@ -9336,14 +9327,16 @@ /* If OP0 is the result of a comparison, we weren't able to find what was really being compared, so fail. */ - if (GET_MODE_CLASS (GET_MODE (op0)) == MODE_CC) + if (!allow_cc_mode + && GET_MODE_CLASS (GET_MODE (op0)) == MODE_CC) return 0; /* Canonicalize any ordered comparison with integers involving equality if we can do computations in the relevant mode and we do not overflow. */ - if (GET_CODE (op1) == CONST_INT + if (GET_MODE_CLASS (GET_MODE (op0)) != MODE_CC + && GET_CODE (op1) == CONST_INT && GET_MODE (op0) != VOIDmode && GET_MODE_BITSIZE (GET_MODE (op0)) <= HOST_BITS_PER_WIDE_INT) { @@ -9398,10 +9391,13 @@ If EARLIEST is nonzero, it is a pointer to a place where the earliest insn used in locating the condition was found. If a replacement test of the condition is desired, it should be placed in front of that - insn and we will be sure that the inputs are still valid. */ + insn and we will be sure that the inputs are still valid. + + If ALLOW_CC_MODE is nonzero, allow the condition returned to be a + compare CC mode register. */ rtx -get_condition (rtx jump, rtx *earliest) +get_condition (rtx jump, rtx *earliest, int allow_cc_mode) { rtx cond; int reverse; @@ -9421,7 +9417,8 @@ = GET_CODE (XEXP (SET_SRC (set), 2)) == LABEL_REF && XEXP (XEXP (SET_SRC (set), 2), 0) == JUMP_LABEL (jump); - return canonicalize_condition (jump, cond, reverse, earliest, NULL_RTX); + return canonicalize_condition (jump, cond, reverse, earliest, NULL_RTX, + allow_cc_mode); } /* Similar to above routine, except that we also put an invariant last @@ -9430,7 +9427,7 @@ rtx get_condition_for_loop (const struct loop *loop, rtx x) { - rtx comparison = get_condition (x, (rtx*) 0); + rtx comparison = get_condition (x, (rtx*) 0, false); if (comparison == 0 || ! loop_invariant_p (loop, XEXP (comparison, 0)) Index: gcc-3.4/gcc/opts.c diff -u gcc-3.4/gcc/opts.c:1.2 gcc-3.4/gcc/opts.c:1.3 --- gcc-3.4/gcc/opts.c:1.2 Thu Jan 8 17:03:27 2004 +++ gcc-3.4/gcc/opts.c Thu Feb 5 10:05:45 2004 @@ -558,6 +558,7 @@ flag_delete_null_pointer_checks = 1; flag_reorder_blocks = 1; flag_reorder_functions = 1; + flag_unit_at_a_time = 1; } if (optimize >= 3) @@ -565,8 +566,6 @@ flag_inline_functions = 1; flag_rename_registers = 1; flag_unswitch_loops = 1; - if (!EMIT_LLVM) - flag_unit_at_a_time = 1; } if (optimize < 2 || optimize_size) @@ -1223,8 +1222,12 @@ flag_rerun_loop_opt = value; break; + case OPT_frounding_math: + flag_rounding_math = value; + break; + case OPT_fsched_interblock: - flag_schedule_interblock= value; + flag_schedule_interblock = value; break; case OPT_fsched_spec: @@ -1550,7 +1553,10 @@ flag_finite_math_only = set; flag_errno_math = !set; if (set) - flag_signaling_nans = 0; + { + flag_signaling_nans = 0; + flag_rounding_math = 0; + } } /* Return true iff flags are set as if -ffast-math. */ Index: gcc-3.4/gcc/stmt.c diff -u gcc-3.4/gcc/stmt.c:1.2 gcc-3.4/gcc/stmt.c:1.3 --- gcc-3.4/gcc/stmt.c:1.2 Thu Jan 8 17:03:27 2004 +++ gcc-3.4/gcc/stmt.c Thu Feb 5 10:05:45 2004 @@ -57,6 +57,8 @@ #include "langhooks.h" #include "predict.h" #include "optabs.h" +#include "target.h" + #include "llvm-out.h" /* Assume that case vectors are not pc-relative. */ @@ -434,25 +436,7 @@ void init_stmt_for_function (void) { - cfun->stmt =ggc_alloc (sizeof (struct stmt_status)); - - /* We are not currently within any block, conditional, loop or case. */ - block_stack = 0; - stack_block_stack = 0; - loop_stack = 0; - case_stack = 0; - cond_stack = 0; - nesting_stack = 0; - nesting_depth = 0; - - current_block_start_count = 0; - - /* No gotos have been expanded yet. */ - goto_fixup_chain = 0; - - /* We are not processing a ({...}) grouping. */ - expr_stmts_for_value = 0; - clear_last_expr (); + cfun->stmt = ggc_alloc_cleared (sizeof (struct stmt_status)); } /* Record the current file and line. Called from emit_line_note. */ @@ -538,10 +522,7 @@ { rtx x = expand_expr (exp, NULL_RTX, VOIDmode, 0); -#ifdef POINTERS_EXTEND_UNSIGNED - if (GET_MODE (x) != Pmode) - x = convert_memory_address (Pmode, x); -#endif + x = convert_memory_address (Pmode, x); emit_queue (); @@ -988,8 +969,8 @@ && INSN_UID (first_insn) > INSN_UID (f->before_jump) && ! DECL_ERROR_ISSUED (f->target)) { - error ("%Hlabel '%D' used before containing binding contour", - &DECL_SOURCE_LOCATION (f->target), f->target); + error ("%Jlabel '%D' used before containing binding contour", + f->target, f->target); /* Prevent multiple errors for one label. */ DECL_ERROR_ISSUED (f->target) = 1; } @@ -2957,16 +2938,17 @@ if (return_reg != val) { tree type = TREE_TYPE (DECL_RESULT (current_function_decl)); -#ifdef PROMOTE_FUNCTION_RETURN - int unsignedp = TREE_UNSIGNED (type); - enum machine_mode old_mode - = DECL_MODE (DECL_RESULT (current_function_decl)); - enum machine_mode mode - = promote_mode (type, old_mode, &unsignedp, 1); + if (targetm.calls.promote_function_return (TREE_TYPE (current_function_decl))) + { + int unsignedp = TREE_UNSIGNED (type); + enum machine_mode old_mode + = DECL_MODE (DECL_RESULT (current_function_decl)); + enum machine_mode mode + = promote_mode (type, old_mode, &unsignedp, 1); - if (mode != old_mode) - val = convert_modes (mode, old_mode, val, unsignedp); -#endif + if (mode != old_mode) + val = convert_modes (mode, old_mode, val, unsignedp); + } if (GET_CODE (return_reg) == PARALLEL) emit_group_load (return_reg, val, type, int_size_in_bytes (type)); else @@ -3652,7 +3634,7 @@ && ! TREE_USED (decl) && ! DECL_IN_SYSTEM_HEADER (decl) && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl)) - warning ("%Hunused variable '%D'", &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Junused variable '%D'", decl, decl); } /* Generate RTL code to terminate a binding contour. @@ -3712,8 +3694,8 @@ that must be an error, because gotos without fixups come from outside all saved stack-levels. */ if (TREE_ADDRESSABLE (chain->label)) - error ("%Hlabel '%D' used before containing binding contour", - &DECL_SOURCE_LOCATION (chain->label), chain->label); + error ("%Jlabel '%D' used before containing binding contour", + chain->label, chain->label); } } @@ -5439,7 +5421,8 @@ because we can optimize it. */ else if (count < case_values_threshold () - || compare_tree_int (range, 10 * count) > 0 + || compare_tree_int (range, + (optimize_size ? 3 : 10) * count) > 0 /* RANGE may be signed, and really large ranges will show up as negative numbers. */ || compare_tree_int (range, 0) < 0 Index: gcc-3.4/gcc/toplev.c diff -u gcc-3.4/gcc/toplev.c:1.3 gcc-3.4/gcc/toplev.c:1.4 --- gcc-3.4/gcc/toplev.c:1.3 Fri Jan 9 16:30:48 2004 +++ gcc-3.4/gcc/toplev.c Thu Feb 5 10:05:45 2004 @@ -635,6 +635,11 @@ int flag_trapping_math = 1; +/* Nonzero means disable transformations that assume default floating + point rounding behavior. */ + +int flag_rounding_math = 0; + /* Nonzero means disable transformations observable by signaling NaNs. This option implies that any operation on an IEEE signaling NaN can generate a (user-visible) trap. */ @@ -1115,6 +1120,7 @@ { "guess-branch-probability", &flag_guess_branch_prob, 1 }, {"math-errno", &flag_errno_math, 1 }, {"trapping-math", &flag_trapping_math, 1 }, + {"rounding-math", &flag_rounding_math, 1 }, {"unsafe-math-optimizations", &flag_unsafe_math_optimizations, 1 }, {"signaling-nans", &flag_signaling_nans, 1 }, {"bounds-check", &flag_bounds_check, 1 }, @@ -1201,6 +1207,23 @@ return src_pwd; } +/* Called when the start of a function definition is parsed, + this function prints on stderr the name of the function. */ +void +announce_function (tree decl) +{ + if (!quiet_flag) + { + if (rtl_dump_and_exit) + verbatim ("%s ", IDENTIFIER_POINTER (DECL_NAME (decl))); + else + verbatim (" %s", (*lang_hooks.decl_printable_name) (decl, 2)); + fflush (stderr); + pp_needs_newline (global_dc->printer) = true; + diagnostic_set_last_function (global_dc); + } +} + /* Set up a default flag_random_seed and local_tick, unless the user already specified one. */ @@ -1567,7 +1590,7 @@ if (flag_unit_at_a_time && cgraph_varpool_node (decl)->finalized) needed = 0; - else if (flag_unit_at_a_time + else if ((flag_unit_at_a_time && !cgraph_global_info_ready) && (TREE_USED (decl) || TREE_USED (DECL_ASSEMBLER_NAME (decl)))) /* needed */; @@ -1590,6 +1613,7 @@ if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != 0 && DECL_SAVED_INSNS (decl) != 0 + && DECL_SAVED_INSNS (decl)->saved_for_inline && (flag_keep_inline_functions || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl)) || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))) @@ -1641,11 +1665,9 @@ && ! TREE_PUBLIC (decl)) { if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) - pedwarn ("%H'%F' used but never defined", - &DECL_SOURCE_LOCATION (decl), decl); + pedwarn ("%J'%F' used but never defined", decl, decl); else - warning ("%H'%F' declared `static' but never defined", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%J'%F' declared `static' but never defined", decl, decl); /* This symbol is effectively an "extern" declaration now. */ TREE_PUBLIC (decl) = 1; assemble_external (decl); @@ -1666,8 +1688,7 @@ && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl)) /* Otherwise, ask the language. */ && (*lang_hooks.decls.warn_unused_global) (decl)) - warning ("%H'%D' defined but not used", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%J'%D' defined but not used", decl, decl); /* Avoid confusing the debug information machinery when there are errors. */ @@ -1680,6 +1701,44 @@ } } +/* Warn about a use of an identifier which was marked deprecated. */ +void +warn_deprecated_use (tree node) +{ + if (node == 0 || !warn_deprecated_decl) + return; + + if (DECL_P (node)) + warning ("`%s' is deprecated (declared at %s:%d)", + IDENTIFIER_POINTER (DECL_NAME (node)), + DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node)); + else if (TYPE_P (node)) + { + const char *what = NULL; + tree decl = TYPE_STUB_DECL (node); + + if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE) + what = IDENTIFIER_POINTER (TYPE_NAME (node)); + else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL + && DECL_NAME (TYPE_NAME (node))) + what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))); + + if (what) + { + if (decl) + warning ("`%s' is deprecated (declared at %s:%d)", what, + DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); + else + warning ("`%s' is deprecated", what); + } + else if (decl) + warning ("type is deprecated (declared at %s:%d)", + DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); + else + warning ("type is deprecated"); + } +} + /* Save the current INPUT_LOCATION on the top entry in the INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the INPUT_LOCATION accordingly. */ @@ -1856,7 +1915,7 @@ /* Don't output anything when a tentative file-scope definition is seen. But at end of compilation, do output code for them. */ - if (at_end || !DECL_DEFER_OUTPUT (decl)) + if ((at_end || !DECL_DEFER_OUTPUT (decl)) && !DECL_EXTERNAL (decl)) { if (flag_unit_at_a_time && !cgraph_global_info_ready && TREE_CODE (decl) != FUNCTION_DECL && top_level) @@ -1976,14 +2035,33 @@ /* Get the function's name, as described by its RTL. This may be different from the DECL_NAME name used in the source file. */ - x = DECL_RTL (decl); - if (GET_CODE (x) != MEM) - abort (); - x = XEXP (x, 0); - if (GET_CODE (x) != SYMBOL_REF) - abort (); - fnname = XSTR (x, 0); + if (EMIT_LLVM) + { + struct llvm_value * LLVMDecl = DECL_LLVM (decl); +#if 0 + fnname = ((LLVMDecl==NULL)?NULL:xstrdup(llvm_get_decl_name(LLVMDecl))); +#endif + } + else + { + x = DECL_RTL (decl); + if (GET_CODE (x) != MEM) + abort (); + x = XEXP (x, 0); + if (GET_CODE (x) != SYMBOL_REF) + abort (); + fnname = XSTR (x, 0); + } + if (EMIT_LLVM) + { +#if 0 + assemble_start_function (decl, fnname); + final_start_function (NULL, asm_out_file, optimize); +#endif + final (insns, stderr, optimize, 0); + return; + } assemble_start_function (decl, fnname); final_start_function (insns, asm_out_file, optimize); final (insns, asm_out_file, optimize, 0); @@ -2041,6 +2119,23 @@ static void rest_of_handle_stack_regs (tree decl, rtx insns) { +#if defined (HAVE_ATTR_length) + /* If flow2 creates new instructions which need splitting + and scheduling after reload is not done, they might not be + splitten until final which doesn't allow splitting + if HAVE_ATTR_length. */ +#ifdef INSN_SCHEDULING + if (optimize && !flag_schedule_insns_after_reload) +#else + if (optimize) +#endif + { + timevar_push (TV_SHORTEN_BRANCH); + split_all_insns (1); + timevar_pop (TV_SHORTEN_BRANCH); + } +#endif + timevar_push (TV_REG_STACK); open_dump_file (DFI_stack, decl); @@ -2485,8 +2580,9 @@ /* If we are reconsidering an inline function at the end of compilation, skip the stuff for making it inline. */ - if (DECL_SAVED_INSNS (decl) != 0) + if (cfun->rtl_inline_init) return 0; + cfun->rtl_inline_init = 1; /* If this is nested inside an inlined external function, pretend it was only declared. Since we cannot inline such functions, @@ -2516,11 +2612,8 @@ { if (warn_inline && lose && DECL_INLINE (decl)) { - char *msg = xmalloc (2 + strlen (lose) + 1); - msg[0] = '%'; - msg[1] = 'H'; - strcpy(msg + 2, lose); - warning (msg, &DECL_SOURCE_LOCATION (decl)); + char *msg = concat ("%J", lose, NULL); + warning (msg, decl); free (msg); } DECL_ABSTRACT_ORIGIN (decl) = 0; @@ -2543,7 +2636,7 @@ if (open_dump_file (DFI_rtl, decl)) { - if (DECL_SAVED_INSNS (decl)) + if (DECL_SAVED_INSNS (decl) && DECL_SAVED_INSNS (decl)->saved_for_inline) fprintf (rtl_dump_file, ";; (integrable)\n\n"); close_dump_file (DFI_rtl, print_rtl, insns); } @@ -2787,7 +2880,8 @@ tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file); if (tem) rebuild_jump_labels (insns); - purge_all_dead_edges (0); + if (purge_all_dead_edges (0)) + delete_unreachable_blocks (); delete_trivially_dead_insns (insns, max_reg_num ()); @@ -3011,6 +3105,12 @@ rtx insns; int rebuild_label_notes_after_reload; + if (EMIT_LLVM) + { + rest_of_handle_final (decl, insns); + return; + } + timevar_push (TV_REST_OF_COMPILATION); /* Register rtl specific functions for cfg. */ @@ -3574,9 +3674,6 @@ if (! DECL_DEFER_OUTPUT (decl)) { free_after_compilation (cfun); - - /* Clear integrate.c's pointer to the cfun structure we just - destroyed. */ DECL_SAVED_INSNS (decl) = 0; } cfun = 0; @@ -4283,8 +4380,6 @@ #endif || flag_test_coverage || warn_notreached); - - if (EMIT_LLVM) return; /* LLVM must call init_emit_once */ init_regs (); init_fake_stack_mems (); Index: gcc-3.4/gcc/tree-optimize.c diff -u gcc-3.4/gcc/tree-optimize.c:1.1.1.1 gcc-3.4/gcc/tree-optimize.c:1.2 --- gcc-3.4/gcc/tree-optimize.c:1.1.1.1 Tue Jan 13 10:49:09 2004 +++ gcc-3.4/gcc/tree-optimize.c Thu Feb 5 10:05:45 2004 @@ -32,6 +32,8 @@ #include "function.h" #include "ggc.h" +#include "llvm-out.h" +#include "llvm-internals.h" /* Called to move the SAVE_EXPRs for parameter declarations in a nested function into the nested function. DATA is really the @@ -96,6 +98,9 @@ tree_rest_of_compilation (tree fndecl, bool nested_p) { location_t saved_loc; +#ifdef EMIT_LLVM + struct llvm_function *LLVMFn; +#endif timevar_push (TV_EXPAND); @@ -128,20 +133,50 @@ NULL); /* Set up parameters and prepare for return, for the function. */ - expand_function_start (fndecl, 0); + if (EMIT_LLVM) + { + LLVMFn = llvm_expand_function_start (fndecl, 0); + } + else + { + expand_function_start (fndecl, 0); + } /* Allow language dialects to perform special processing. */ - (*lang_hooks.rtl_expand.start) (); + if (EMIT_LLVM) + { + (*lang_hooks.llvm_expand.start) (); + } + else + { + (*lang_hooks.rtl_expand.start) (); + } /* If this function is `main', emit a call to `__main' to run global initializers, etc. */ if (DECL_NAME (fndecl) && MAIN_NAME_P (DECL_NAME (fndecl)) && DECL_FILE_SCOPE_P (fndecl)) - expand_main_function (); + { + if (EMIT_LLVM) + { + llvm_expand_main_function (LLVMFn); + } + else + { + expand_main_function (); + } + } /* Generate the RTL for this function. */ - (*lang_hooks.rtl_expand.stmt) (DECL_SAVED_TREE (fndecl)); + if (EMIT_LLVM) + { + (*lang_hooks.llvm_expand.stmt) (LLVMFn, DECL_SAVED_TREE (fndecl)); + } + else + { + (*lang_hooks.rtl_expand.stmt) (DECL_SAVED_TREE (fndecl)); + } /* We hard-wired immediate_size_expand to zero above. expand_function_end will decrement this variable. So, we set the @@ -150,10 +185,26 @@ immediate_size_expand = 1; /* Allow language dialects to perform special processing. */ - (*lang_hooks.rtl_expand.end) (); +#if 0 + if (EMIT_LLVM) + { + (*lang_hooks.llvm_expand.end) (); + } + else +#endif + { + (*lang_hooks.rtl_expand.end) (); + } /* Generate rtl for function exit. */ - expand_function_end (); + if (EMIT_LLVM) + { + llvm_expand_function_end (LLVMFn, fndecl, 0); + } + else + { + expand_function_end (); + } /* If this is a nested function, protect the local variables in the stack above us from being collected while we're compiling this function. */ @@ -165,7 +216,15 @@ DECL_DEFER_OUTPUT (fndecl) = 0; /* Run the optimizers and output the assembler code for this function. */ +#if EMIT_LLVM + if (EMIT_CODE_INCREMENTALLY) + { + llvm_function_print (LLVMFn, llvm_out_file); + } + cfun = 0; +#else rest_of_compilation (fndecl); +#endif /* Undo the GC context switch. */ if (nested_p) Index: gcc-3.4/gcc/tree.c diff -u gcc-3.4/gcc/tree.c:1.2 gcc-3.4/gcc/tree.c:1.3 --- gcc-3.4/gcc/tree.c:1.2 Thu Jan 8 17:03:27 2004 +++ gcc-3.4/gcc/tree.c Thu Feb 5 10:05:45 2004 @@ -4868,6 +4868,11 @@ TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE; layout_type (long_double_type_node); + float_ptr_type_node = build_pointer_type (float_type_node); + double_ptr_type_node = build_pointer_type (double_type_node); + long_double_ptr_type_node = build_pointer_type (long_double_type_node); + integer_ptr_type_node = build_pointer_type (integer_type_node); + complex_integer_type_node = make_node (COMPLEX_TYPE); TREE_TYPE (complex_integer_type_node) = integer_type_node; layout_type (complex_integer_type_node); Index: gcc-3.4/gcc/tree.def diff -u gcc-3.4/gcc/tree.def:1.2 gcc-3.4/gcc/tree.def:1.3 --- gcc-3.4/gcc/tree.def:1.2 Fri Jan 9 10:54:24 2004 +++ gcc-3.4/gcc/tree.def Thu Feb 5 10:05:45 2004 @@ -615,13 +615,6 @@ operand of the ABS_EXPR must have the same type. */ DEFTREECODE (ABS_EXPR, "abs_expr", '1', 1) -/* Bit scanning and counting. */ -DEFTREECODE (FFS_EXPR, "ffs_expr", '1', 1) -DEFTREECODE (CLZ_EXPR, "clz_expr", '1', 1) -DEFTREECODE (CTZ_EXPR, "ctz_expr", '1', 1) -DEFTREECODE (POPCOUNT_EXPR, "popcount_expr", '1', 1) -DEFTREECODE (PARITY_EXPR, "parity_expr", '1', 1) - /* Shift operations for shift and rotate. Shift means logical shift if done on an unsigned type, arithmetic shift if done on a signed type. @@ -638,7 +631,6 @@ DEFTREECODE (BIT_IOR_EXPR, "bit_ior_expr", '2', 2) DEFTREECODE (BIT_XOR_EXPR, "bit_xor_expr", '2', 2) DEFTREECODE (BIT_AND_EXPR, "bit_and_expr", '2', 2) -DEFTREECODE (BIT_ANDTC_EXPR, "bit_andtc_expr", '2', 2) DEFTREECODE (BIT_NOT_EXPR, "bit_not_expr", '1', 1) /* ANDIF and ORIF allow the second operand not to be computed if the Index: gcc-3.4/gcc/tree.h diff -u gcc-3.4/gcc/tree.h:1.2 gcc-3.4/gcc/tree.h:1.3 --- gcc-3.4/gcc/tree.h:1.2 Thu Jan 8 17:03:27 2004 +++ gcc-3.4/gcc/tree.h Thu Feb 5 10:05:45 2004 @@ -1654,6 +1654,11 @@ #define DECL_ESTIMATED_INSNS(NODE) \ (FUNCTION_DECL_CHECK (NODE)->decl.u1.i) +/* Nonzero for a decl which is at file scope. */ +#define DECL_FILE_SCOPE_P(EXP) \ + (! DECL_CONTEXT (EXP) \ + || TREE_CODE (DECL_CONTEXT (EXP)) == TRANSLATION_UNIT_DECL) + struct function; struct tree_decl GTY(()) @@ -1840,6 +1845,11 @@ TI_DOUBLE_TYPE, TI_LONG_DOUBLE_TYPE, + TI_FLOAT_PTR_TYPE, + TI_DOUBLE_PTR_TYPE, + TI_LONG_DOUBLE_PTR_TYPE, + TI_INTEGER_PTR_TYPE, + TI_VOID_TYPE, TI_PTR_TYPE, TI_CONST_PTR_TYPE, @@ -1918,6 +1928,11 @@ #define double_type_node global_trees[TI_DOUBLE_TYPE] #define long_double_type_node global_trees[TI_LONG_DOUBLE_TYPE] +#define float_ptr_type_node global_trees[TI_FLOAT_PTR_TYPE] +#define double_ptr_type_node global_trees[TI_DOUBLE_PTR_TYPE] +#define long_double_ptr_type_node global_trees[TI_LONG_DOUBLE_PTR_TYPE] +#define integer_ptr_type_node global_trees[TI_INTEGER_PTR_TYPE] + #define complex_integer_type_node global_trees[TI_COMPLEX_INTEGER_TYPE] #define complex_float_type_node global_trees[TI_COMPLEX_FLOAT_TYPE] #define complex_double_type_node global_trees[TI_COMPLEX_DOUBLE_TYPE] @@ -2872,6 +2887,7 @@ extern void init_dummy_function_start (void); extern void expand_dummy_function_end (void); extern void init_function_for_compilation (void); +extern void allocate_struct_function (tree); extern void init_function_start (tree); extern void assign_parms (tree); extern void put_var_into_stack (tree, int); @@ -2886,7 +2902,7 @@ extern void push_temp_slots (void); extern void preserve_temp_slots (rtx); extern void preserve_rtl_expr_temps (tree); -extern int aggregate_value_p (tree); +extern int aggregate_value_p (tree, tree); extern void free_temps_for_rtl_expr (tree); extern void instantiate_virtual_regs (tree, rtx); extern void unshare_all_rtl (tree, rtx); Index: gcc-3.4/gcc/varasm.c diff -u gcc-3.4/gcc/varasm.c:1.2 gcc-3.4/gcc/varasm.c:1.3 --- gcc-3.4/gcc/varasm.c:1.2 Thu Jan 8 17:03:27 2004 +++ gcc-3.4/gcc/varasm.c Thu Feb 5 10:05:45 2004 @@ -434,8 +434,7 @@ { flags = get_named_section_flags (name); if ((flags & SECTION_OVERRIDE) == 0) - error ("%H%D causes a section type conflict", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%J%D causes a section type conflict", decl, decl); } named_section_flags (name, flags); @@ -564,8 +563,7 @@ unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED, unsigned int flags ATTRIBUTE_UNUSED) { -#ifdef HAVE_GAS_SHF_MERGE - if (flag_merge_constants + if (HAVE_GAS_SHF_MERGE && flag_merge_constants && TREE_CODE (decl) == STRING_CST && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE && align <= 256 @@ -627,7 +625,7 @@ } } } -#endif + readonly_data_section (); } @@ -638,10 +636,9 @@ unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED, unsigned int flags ATTRIBUTE_UNUSED) { -#ifdef HAVE_GAS_SHF_MERGE unsigned int modesize = GET_MODE_BITSIZE (mode); - if (flag_merge_constants + if (HAVE_GAS_SHF_MERGE && flag_merge_constants && mode != VOIDmode && mode != BLKmode && modesize <= align @@ -656,7 +653,7 @@ named_section_flags (name, flags); return; } -#endif + readonly_data_section (); } @@ -752,6 +749,9 @@ int reg_number; rtx x; +#ifdef abort +#undef abort +#endif LLVM_SHOULD_NOT_CALL(); /* Check that we are not being given an automatic variable. */ @@ -807,17 +807,15 @@ { /* First detect errors in declaring global registers. */ if (reg_number == -1) - error ("%Hregister name not specified for '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jregister name not specified for '%D'", decl, decl); else if (reg_number < 0) - error ("%Hinvalid register name for '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jinvalid register name for '%D'", decl, decl); else if (TYPE_MODE (TREE_TYPE (decl)) == BLKmode) - error ("%Hdata type of '%D' isn't suitable for a register", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jdata type of '%D' isn't suitable for a register", + decl, decl); else if (! HARD_REGNO_MODE_OK (reg_number, TYPE_MODE (TREE_TYPE (decl)))) - error ("%Hregister specified for '%D' isn't suitable for data type", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jregister specified for '%D' isn't suitable for data type", + decl, decl); /* Now handle properly declared static register variables. */ else { @@ -861,8 +859,7 @@ Also handle vars declared register invalidly. */ if (reg_number >= 0 || reg_number == -3) - error ("%Hregister name given for non-register variable '%D'", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jregister name given for non-register variable '%D'", decl, decl); /* Specifying a section attribute on a variable forces it into a non-.bss section, and thus it cannot be common. */ @@ -1061,18 +1058,23 @@ notice_global_symbol (tree decl) { if ((!first_global_object_name || !weak_global_object_name) - && TREE_PUBLIC (decl) + && TREE_PUBLIC (decl) && !DECL_COMMON (decl) && (TREE_CODE (decl) == FUNCTION_DECL - || ! (DECL_COMMON (decl) - && (DECL_INITIAL (decl) == 0 - || DECL_INITIAL (decl) == error_mark_node)))) + || (TREE_CODE (decl) == VAR_DECL + && (DECL_INITIAL (decl) != 0 + && DECL_INITIAL (decl) != error_mark_node)))) { const char *p; char *name; - rtx decl_rtl = DECL_RTL (decl); + if (EMIT_LLVM) { + struct llvm_value* LLVMDecl = DECL_LLVM(decl); + name = ((LLVMDecl==NULL)?NULL:xstrdup(llvm_get_decl_name(LLVMDecl))); + } else { + rtx decl_rtl = DECL_RTL (decl); - p = (* targetm.strip_name_encoding) (XSTR (XEXP (decl_rtl, 0), 0)); - name = xstrdup (p); + p = (* targetm.strip_name_encoding) (XSTR (XEXP (decl_rtl, 0), 0)); + name = xstrdup (p); + } if (! DECL_WEAK (decl) && ! DECL_ONE_ONLY (decl)) first_global_object_name = name; @@ -1393,9 +1395,7 @@ if (!dont_output_data && DECL_SIZE (decl) == 0) { - error ("%Hstorage size of `%s' isn't known", - &DECL_SOURCE_LOCATION (decl), - IDENTIFIER_POINTER (DECL_NAME (decl))); + error ("%Jstorage size of `%D' isn't known", decl, decl); TREE_ASM_WRITTEN (decl) = 1; return; } @@ -1428,8 +1428,7 @@ if (! dont_output_data && ! host_integerp (DECL_SIZE_UNIT (decl), 1)) { - error ("%Hsize of variable '%D' is too large", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jsize of variable '%D' is too large", decl, decl); return; } @@ -1455,9 +1454,9 @@ #endif if (align > MAX_OFILE_ALIGNMENT) { - warning ("%Halignment of '%D' is greater than maximum object " - "file alignment. Using %d", &DECL_SOURCE_LOCATION (decl), - decl, MAX_OFILE_ALIGNMENT/BITS_PER_UNIT); + warning ("%Jalignment of '%D' is greater than maximum object " + "file alignment. Using %d", decl, decl, + MAX_OFILE_ALIGNMENT/BITS_PER_UNIT); align = MAX_OFILE_ALIGNMENT; } @@ -1523,9 +1522,8 @@ #if !defined(ASM_OUTPUT_ALIGNED_COMMON) && !defined(ASM_OUTPUT_ALIGNED_DECL_COMMON) && !defined(ASM_OUTPUT_ALIGNED_BSS) if ((unsigned HOST_WIDE_INT) DECL_ALIGN (decl) / BITS_PER_UNIT > rounded) - warning ("%Hrequested alignment for '%D' is greater than " - "implemented alignment of %d", &DECL_SOURCE_LOCATION (decl), - decl, rounded); + warning ("%Jrequested alignment for '%D' is greater than " + "implemented alignment of %d", decl, decl, rounded); #endif /* If the target cannot output uninitialized but not common global data @@ -1653,16 +1651,14 @@ /* Similar, for calling a library function FUN. */ void -assemble_external_libcall (rtx fun ATTRIBUTE_UNUSED) +assemble_external_libcall (rtx fun) { -#ifdef ASM_OUTPUT_EXTERNAL_LIBCALL /* Declare library function name external when first used, if nec. */ if (! SYMBOL_REF_USED (fun)) { SYMBOL_REF_USED (fun) = 1; - ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file, fun); + (*targetm.asm_out.external_libcall) (fun); } -#endif } /* Assemble a label named NAME. */ @@ -1686,7 +1682,7 @@ { node = cgraph_node_for_identifier (id); if (node) - cgraph_mark_needed_node (node, 1); + cgraph_mark_needed_node (node); } vnode = cgraph_varpool_node_for_identifier (id); @@ -3500,11 +3496,27 @@ || TREE_CODE (TREE_TYPE (value)) == RECORD_TYPE) && TREE_CONSTANT (value) && CONSTRUCTOR_ELTS (value)) - return - initializer_constant_valid_p (TREE_VALUE (CONSTRUCTOR_ELTS (value)), - endtype); + { + tree elt; + bool absolute = true; + + for (elt = CONSTRUCTOR_ELTS (value); elt; elt = TREE_CHAIN (elt)) + { + tree reloc; + value = TREE_VALUE (elt); + reloc = initializer_constant_valid_p (value, TREE_TYPE (value)); + if (!reloc) + return NULL_TREE; + if (reloc != null_pointer_node) + absolute = false; + } + /* For a non-absolute relocation, there is no single + variable that can be "the variable that determines the + relocation." */ + return absolute ? null_pointer_node : error_mark_node; + } - return TREE_STATIC (value) ? null_pointer_node : 0; + return TREE_STATIC (value) ? null_pointer_node : NULL_TREE; case INTEGER_CST: case VECTOR_CST: @@ -4221,17 +4233,16 @@ declare_weak because the NEWDECL and OLDDECL was not yet been merged; therefore, TREE_ASM_WRITTEN was not set. */ if (TREE_ASM_WRITTEN (olddecl)) - error ("%Hweak declaration of '%D' must precede definition", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + error ("%Jweak declaration of '%D' must precede definition", + newdecl, newdecl); /* If we've already generated rtl referencing OLDDECL, we may have done so in a way that will not function properly with a weak symbol. */ else if (TREE_USED (olddecl) && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl))) - warning ("%Hweak declaration of '%D' after first use results " - "in unspecified behavior", - &DECL_SOURCE_LOCATION (newdecl), newdecl); + warning ("%Jweak declaration of '%D' after first use results " + "in unspecified behavior", newdecl, newdecl); if (SUPPORTS_WEAK) { @@ -4264,19 +4275,16 @@ declare_weak (tree decl) { if (! TREE_PUBLIC (decl)) - error ("%Hweak declaration of '%D' must be public", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jweak declaration of '%D' must be public", decl, decl); else if (TREE_CODE (decl) == FUNCTION_DECL && TREE_ASM_WRITTEN (decl)) - error ("%Hweak declaration of '%D' must precede definition", - &DECL_SOURCE_LOCATION (decl), decl); + error ("%Jweak declaration of '%D' must precede definition", decl, decl); else if (SUPPORTS_WEAK) { if (! DECL_WEAK (decl)) weak_decls = tree_cons (NULL, decl, weak_decls); } else - warning ("%Hweak declaration of '%D' not supported", - &DECL_SOURCE_LOCATION (decl), decl); + warning ("%Jweak declaration of '%D' not supported", decl, decl); mark_weak (decl); } Index: gcc-3.4/gcc/version.c diff -u gcc-3.4/gcc/version.c:1.2 gcc-3.4/gcc/version.c:1.3 --- gcc-3.4/gcc/version.c:1.2 Thu Jan 8 17:03:27 2004 +++ gcc-3.4/gcc/version.c Thu Feb 5 10:05:45 2004 @@ -5,7 +5,7 @@ please modify this string to indicate that, e.g. by putting your organization's name in parentheses at the end of the string. */ -const char version_string[] = "3.4-llvm 20030827 (experimental)"; +const char version_string[] = "3.4-llvm 20030924 (experimental)"; /* This is the location of the online document giving instructions for reporting bugs. If you distribute a modified version of GCC, From criswell at cs.uiuc.edu Thu Feb 5 10:10:38 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 10:10:38 2004 Subject: [llvm-commits] CVS: gcc-3.4/configure configure.in Message-ID: <200402051606.KAA27184@choi.cs.uiuc.edu> Changes in directory gcc-3.4: configure updated: 1.2 -> 1.3 configure.in updated: 1.2 -> 1.3 --- Log message: Commit of merge from September 24, 2003 of mainline GCC. This merge now works reasonably on Linux/x86 and probably works on Solaris/Sparc. --- Diffs of the changes: (+113 -69) Index: gcc-3.4/configure diff -u gcc-3.4/configure:1.2 gcc-3.4/configure:1.3 --- gcc-3.4/configure:1.2 Fri Jan 9 11:06:42 2004 +++ gcc-3.4/configure Thu Feb 5 10:05:30 2004 @@ -795,19 +795,13 @@ if test -n "$PWD" ; then PWD=`${PWDCMD-pwd}`; fi # Export original configure arguments for use by sub-configures. These -# will be expanded once by make, and once by the shell, so they need to -# have '$' quoted for make, and then each argument quoted for the shell. -# What's more, the 'echo' below might expand backslashes. -cat <<\EOF_SED > conftestsed -s,\\,\\\\,g; s,\$,$$,g +# will be expanded by make, so quote '$'. +tmp="$progname $@" +sed -e 's,\$,$$,g' < conftestsed.out +$tmp EOF_SED -tmp="'$progname'" -for ac_arg -do - tmp="$tmp '"`echo "$ac_arg" | sed -fconftestsed` -done -rm -f conftestsed -TOPLEVEL_CONFIGURE_ARGUMENTS="$tmp" +TOPLEVEL_CONFIGURE_ARGUMENTS=`cat conftestsed.out` +rm -f conftestsed.out moveifchange=${srcdir}/move-if-change @@ -1140,7 +1134,7 @@ # newlib is not 64 bit ready noconfigdirs="$noconfigdirs target-newlib target-libgloss" ;; - alpha*-*-freebsd*) + alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu) noconfigdirs="$noconfigdirs target-newlib target-libgloss" ;; alpha*-*-*) @@ -1261,7 +1255,7 @@ i[3456789]86-*-coff | i[3456789]86-*-elf) noconfigdirs="$noconfigdirs ${libgcj}" ;; - i[3456789]86-*-freebsd*) + i[3456789]86-*-freebsd* | i[3456789]86-*-kfreebsd*-gnu) noconfigdirs="$noconfigdirs target-newlib target-libgloss" ;; i[3456789]86-*-linux*) @@ -2516,7 +2510,14 @@ # Base args. Strip norecursion, cache-file, srcdir, host, build, # target and nonopt. These are the ones we might not want to pass -# down to subconfigures. +# down to subconfigures. Also strip program-prefix, program-suffix, +# and program-transform-name, so that we can pass down a consistent +# program-transform-name. If autoconf has put single quotes around +# any of these arguments (because they contain shell metacharacters) +# then this will fail; in practice this only happens for +# --program-transform-name, so be sure to override --program-transform-name +# at the end of the argument list. +# These will be expanded by make, so quote '$'. cat <<\EOF_SED > conftestsed s/ --no[^ ]* / / s/ --c[a-z-]*[= ][^ ]* / / @@ -2524,17 +2525,38 @@ s/ --ho[a-z-]*[= ][^ ]* / / s/ --bu[a-z-]*[= ][^ ]* / / s/ --t[a-z-]*[= ][^ ]* / / +s/ --program-[pst][a-z-]*[= ][^ ]* / / s/ -cache-file[= ][^ ]* / / s/ -srcdir[= ][^ ]* / / s/ -host[= ][^ ]* / / s/ -build[= ][^ ]* / / s/ -target[= ][^ ]* / / +s/ -program-prefix[= ][^ ]* / / +s/ -program-suffix[= ][^ ]* / / +s/ -program-transform-name[= ][^ ]* / / s/ [^' -][^ ]* / / s/^ *//;s/ *$// -s,\\,\\\\,g; s,\$,$$,g +s,\$,$$,g +EOF_SED +sed -f conftestsed < conftestsed.out + ${ac_configure_args} +EOF_SED +baseargs=`cat conftestsed.out` +rm -f conftestsed conftestsed.out + +# Add in --program-transform-name, after --program-prefix and +# --program-suffix have been applied to it. Autoconf has already +# doubled dollar signs and backslashes in program_transform_name; we want +# the backslashes un-doubled, and then the entire thing wrapped in single +# quotes, because this will be expanded first by make and then by the shell. +# Also, because we want to override the logic in subdir configure scripts to +# choose program_transform_name, replace any s,x,x, with s,y,y,. +sed -e "s,\\\\\\\\,\\\\,g; s,','\\\\'',g; s/s,x,x,/s,y,y,/" < conftestsed.out +${program_transform_name} EOF_SED -baseargs=`echo " ${ac_configure_args} " | sed -fconftestsed` -rm -f conftestsed +gcc_transform_name=`cat conftestsed.out` +rm -f conftestsed.out +baseargs="$baseargs --program-transform-name='${gcc_transform_name}'" # For the build-side libraries, we just need to pretend we're native, # and not use the same cache file. Multilibs are neither needed nor @@ -2785,7 +2807,7 @@ # Extract the first word of "${ncn_tool_prefix}ar", so it can be a program name with args. set dummy ${ncn_tool_prefix}ar; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2789: checking for $ac_word" >&5 +echo "configure:2811: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2818,7 +2840,7 @@ # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2822: checking for $ac_word" >&5 +echo "configure:2844: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2857,7 +2879,7 @@ # Extract the first word of "${ncn_tool_prefix}as", so it can be a program name with args. set dummy ${ncn_tool_prefix}as; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2861: checking for $ac_word" >&5 +echo "configure:2883: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2890,7 +2912,7 @@ # Extract the first word of "as", so it can be a program name with args. set dummy as; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2894: checking for $ac_word" >&5 +echo "configure:2916: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_AS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2929,7 +2951,7 @@ # Extract the first word of "${ncn_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ncn_tool_prefix}dlltool; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2933: checking for $ac_word" >&5 +echo "configure:2955: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2962,7 +2984,7 @@ # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2966: checking for $ac_word" >&5 +echo "configure:2988: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_DLLTOOL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3001,7 +3023,7 @@ # Extract the first word of "${ncn_tool_prefix}ld", so it can be a program name with args. set dummy ${ncn_tool_prefix}ld; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3005: checking for $ac_word" >&5 +echo "configure:3027: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3034,7 +3056,7 @@ # Extract the first word of "ld", so it can be a program name with args. set dummy ld; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3038: checking for $ac_word" >&5 +echo "configure:3060: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_LD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3073,7 +3095,7 @@ # Extract the first word of "${ncn_tool_prefix}nm", so it can be a program name with args. set dummy ${ncn_tool_prefix}nm; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3077: checking for $ac_word" >&5 +echo "configure:3099: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_NM'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3106,7 +3128,7 @@ # Extract the first word of "nm", so it can be a program name with args. set dummy nm; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3110: checking for $ac_word" >&5 +echo "configure:3132: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_NM'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3145,7 +3167,7 @@ # Extract the first word of "${ncn_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ncn_tool_prefix}ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3149: checking for $ac_word" >&5 +echo "configure:3171: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3178,7 +3200,7 @@ # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3182: checking for $ac_word" >&5 +echo "configure:3204: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3217,7 +3239,7 @@ # Extract the first word of "${ncn_tool_prefix}windres", so it can be a program name with args. set dummy ${ncn_tool_prefix}windres; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3221: checking for $ac_word" >&5 +echo "configure:3243: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3250,7 +3272,7 @@ # Extract the first word of "windres", so it can be a program name with args. set dummy windres; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3254: checking for $ac_word" >&5 +echo "configure:3276: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_WINDRES'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3289,7 +3311,7 @@ # Extract the first word of "${ncn_tool_prefix}objcopy", so it can be a program name with args. set dummy ${ncn_tool_prefix}objcopy; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3293: checking for $ac_word" >&5 +echo "configure:3315: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_OBJCOPY'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3322,7 +3344,7 @@ # Extract the first word of "objcopy", so it can be a program name with args. set dummy objcopy; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3326: checking for $ac_word" >&5 +echo "configure:3348: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_OBJCOPY'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3361,7 +3383,7 @@ # Extract the first word of "${ncn_tool_prefix}objdump", so it can be a program name with args. set dummy ${ncn_tool_prefix}objdump; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3365: checking for $ac_word" >&5 +echo "configure:3387: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3394,7 +3416,7 @@ # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3398: checking for $ac_word" >&5 +echo "configure:3420: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_OBJDUMP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3442,7 +3464,7 @@ # Extract the first word of "${ncn_target_tool_prefix}ar", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}ar; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3446: checking for $ac_word" >&5 +echo "configure:3468: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3475,7 +3497,7 @@ # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3479: checking for $ac_word" >&5 +echo "configure:3501: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_AR_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3514,7 +3536,7 @@ # Extract the first word of "${ncn_target_tool_prefix}as", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}as; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3518: checking for $ac_word" >&5 +echo "configure:3540: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AS_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3547,7 +3569,7 @@ # Extract the first word of "as", so it can be a program name with args. set dummy as; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3551: checking for $ac_word" >&5 +echo "configure:3573: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_AS_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3586,7 +3608,7 @@ # Extract the first word of "${ncn_target_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}dlltool; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3590: checking for $ac_word" >&5 +echo "configure:3612: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3619,7 +3641,7 @@ # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3623: checking for $ac_word" >&5 +echo "configure:3645: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_DLLTOOL_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3658,7 +3680,7 @@ # Extract the first word of "${ncn_target_tool_prefix}ld", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}ld; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3662: checking for $ac_word" >&5 +echo "configure:3684: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LD_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3691,7 +3713,7 @@ # Extract the first word of "ld", so it can be a program name with args. set dummy ld; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3695: checking for $ac_word" >&5 +echo "configure:3717: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_LD_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3730,7 +3752,7 @@ # Extract the first word of "${ncn_target_tool_prefix}nm", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}nm; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3734: checking for $ac_word" >&5 +echo "configure:3756: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_NM_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3763,7 +3785,7 @@ # Extract the first word of "nm", so it can be a program name with args. set dummy nm; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3767: checking for $ac_word" >&5 +echo "configure:3789: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_NM_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3802,7 +3824,7 @@ # Extract the first word of "${ncn_target_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3806: checking for $ac_word" >&5 +echo "configure:3828: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3835,7 +3857,7 @@ # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3839: checking for $ac_word" >&5 +echo "configure:3861: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_RANLIB_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3874,7 +3896,7 @@ # Extract the first word of "${ncn_target_tool_prefix}windres", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}windres; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3878: checking for $ac_word" >&5 +echo "configure:3900: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_WINDRES_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3907,7 +3929,7 @@ # Extract the first word of "windres", so it can be a program name with args. set dummy windres; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3911: checking for $ac_word" >&5 +echo "configure:3933: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_ncn_cv_WINDRES_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3974,7 +3996,7 @@ NM_FOR_TARGET=${NM_FOR_TARGET}${extra_nmflags_for_target} echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:3978: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:4000: checking whether to enable maintainer-specific portions of Makefiles" >&5 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval="$enable_maintainer_mode" Index: gcc-3.4/configure.in diff -u gcc-3.4/configure.in:1.2 gcc-3.4/configure.in:1.3 --- gcc-3.4/configure.in:1.2 Fri Jan 9 11:06:42 2004 +++ gcc-3.4/configure.in Thu Feb 5 10:05:30 2004 @@ -67,19 +67,13 @@ if test -n "$PWD" ; then PWD=`${PWDCMD-pwd}`; fi # Export original configure arguments for use by sub-configures. These -# will be expanded once by make, and once by the shell, so they need to -# have '$' quoted for make, and then each argument quoted for the shell. -# What's more, the 'echo' below might expand backslashes. -cat <<\EOF_SED > conftestsed -s,\\,\\\\,g; s,\$,$$,g +# will be expanded by make, so quote '$'. +tmp="$progname $@" +sed -e 's,\$,$$,g' < conftestsed.out +$tmp EOF_SED -tmp="'$progname'" -for ac_arg -do - tmp="$tmp '"`echo "$ac_arg" | sed -fconftestsed` -done -rm -f conftestsed -TOPLEVEL_CONFIGURE_ARGUMENTS="$tmp" +TOPLEVEL_CONFIGURE_ARGUMENTS=`cat conftestsed.out` +rm -f conftestsed.out AC_SUBST(TOPLEVEL_CONFIGURE_ARGUMENTS) moveifchange=${srcdir}/move-if-change @@ -391,7 +385,7 @@ # newlib is not 64 bit ready noconfigdirs="$noconfigdirs target-newlib target-libgloss" ;; - alpha*-*-freebsd*) + alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu) noconfigdirs="$noconfigdirs target-newlib target-libgloss" ;; alpha*-*-*) @@ -512,7 +506,7 @@ i[[3456789]]86-*-coff | i[[3456789]]86-*-elf) noconfigdirs="$noconfigdirs ${libgcj}" ;; - i[[3456789]]86-*-freebsd*) + i[[3456789]]86-*-freebsd* | i[[3456789]]86-*-kfreebsd*-gnu) noconfigdirs="$noconfigdirs target-newlib target-libgloss" ;; i[[3456789]]86-*-linux*) @@ -1766,7 +1760,14 @@ # Base args. Strip norecursion, cache-file, srcdir, host, build, # target and nonopt. These are the ones we might not want to pass -# down to subconfigures. +# down to subconfigures. Also strip program-prefix, program-suffix, +# and program-transform-name, so that we can pass down a consistent +# program-transform-name. If autoconf has put single quotes around +# any of these arguments (because they contain shell metacharacters) +# then this will fail; in practice this only happens for +# --program-transform-name, so be sure to override --program-transform-name +# at the end of the argument list. +# These will be expanded by make, so quote '$'. cat <<\EOF_SED > conftestsed s/ --no[[^ ]]* / / s/ --c[[a-z-]]*[[= ]][[^ ]]* / / @@ -1774,17 +1775,38 @@ s/ --ho[[a-z-]]*[[= ]][[^ ]]* / / s/ --bu[[a-z-]]*[[= ]][[^ ]]* / / s/ --t[[a-z-]]*[[= ]][[^ ]]* / / +s/ --program-[[pst]][[a-z-]]*[[= ]][[^ ]]* / / s/ -cache-file[[= ]][[^ ]]* / / s/ -srcdir[[= ]][[^ ]]* / / s/ -host[[= ]][[^ ]]* / / s/ -build[[= ]][[^ ]]* / / s/ -target[[= ]][[^ ]]* / / +s/ -program-prefix[[= ]][[^ ]]* / / +s/ -program-suffix[[= ]][[^ ]]* / / +s/ -program-transform-name[[= ]][[^ ]]* / / s/ [[^' -][^ ]*] / / s/^ *//;s/ *$// -s,\\,\\\\,g; s,\$,$$,g +s,\$,$$,g +EOF_SED +sed -f conftestsed < conftestsed.out + ${ac_configure_args} +EOF_SED +baseargs=`cat conftestsed.out` +rm -f conftestsed conftestsed.out + +# Add in --program-transform-name, after --program-prefix and +# --program-suffix have been applied to it. Autoconf has already +# doubled dollar signs and backslashes in program_transform_name; we want +# the backslashes un-doubled, and then the entire thing wrapped in single +# quotes, because this will be expanded first by make and then by the shell. +# Also, because we want to override the logic in subdir configure scripts to +# choose program_transform_name, replace any s,x,x, with s,y,y,. +sed -e "s,\\\\\\\\,\\\\,g; s,','\\\\'',g; s/s,x,x,/s,y,y,/" < conftestsed.out +${program_transform_name} EOF_SED -baseargs=`echo " ${ac_configure_args} " | sed -fconftestsed` -rm -f conftestsed +gcc_transform_name=`cat conftestsed.out` +rm -f conftestsed.out +baseargs="$baseargs --program-transform-name='${gcc_transform_name}'" # For the build-side libraries, we just need to pretend we're native, # and not use the same cache file. Multilibs are neither needed nor From lattner at cs.uiuc.edu Thu Feb 5 11:21:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 5 11:21:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoadValueNumbering.cpp Message-ID: <200402051720.LAA02376@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoadValueNumbering.cpp updated: 1.14 -> 1.15 --- Log message: In a "seeing the forest through the trees" kinda situation, I realized that a complete rewrite of load-vn will make it a bit faster. This changes speeds up the gcse pass (which uses load-vn) from 25.45s to 0.42s on the testcase in PR209. I've also verified that this gives the exact same results as the old one. --- Diffs of the changes: (+230 -227) Index: llvm/lib/Analysis/LoadValueNumbering.cpp diff -u llvm/lib/Analysis/LoadValueNumbering.cpp:1.14 llvm/lib/Analysis/LoadValueNumbering.cpp:1.15 --- llvm/lib/Analysis/LoadValueNumbering.cpp:1.14 Wed Feb 4 23:56:23 2004 +++ llvm/lib/Analysis/LoadValueNumbering.cpp Thu Feb 5 11:20:00 2004 @@ -50,17 +50,6 @@ /// virtual void getEqualNumberNodes(Value *V1, std::vector &RetVals) const; - private: - /// haveEqualValueNumber - Given two load instructions, determine if they - /// both produce the same value on every execution of the program, assuming - /// that their source operands always give the same value. This uses the - /// AliasAnalysis implementation to invalidate loads when stores or function - /// calls occur that could modify the value produced by the load. - /// - bool haveEqualValueNumber(LoadInst *LI, LoadInst *LI2, AliasAnalysis &AA, - DominatorSet &DomSetInfo) const; - bool haveEqualValueNumber(LoadInst *LI, StoreInst *SI, AliasAnalysis &AA, - DominatorSet &DomSetInfo) const; }; // Register this pass... @@ -84,6 +73,43 @@ AU.addRequired(); } +static bool isPathTransparentTo(BasicBlock *CurBlock, BasicBlock *Dom, + Value *Ptr, unsigned Size, AliasAnalysis &AA, + std::set &Visited, + std::map &TransparentBlocks){ + // If we have already checked out this path, or if we reached our destination, + // stop searching, returning success. + if (CurBlock == Dom || !Visited.insert(CurBlock).second) + return true; + + // Check whether this block is known transparent or not. + std::map::iterator TBI = + TransparentBlocks.lower_bound(CurBlock); + + if (TBI == TransparentBlocks.end() || TBI->first != CurBlock) { + // If this basic block can modify the memory location, then the path is not + // transparent! + if (AA.canBasicBlockModify(*CurBlock, Ptr, Size)) { + TransparentBlocks.insert(TBI, std::make_pair(CurBlock, false)); + return false; + } + TransparentBlocks.insert(TBI, std::make_pair(CurBlock, true)); + } else if (!TBI->second) + // This block is known non-transparent, so that path can't be either. + return false; + + // The current block is known to be transparent. The entire path is + // transparent if all of the predecessors paths to the parent is also + // transparent to the memory location. + for (pred_iterator PI = pred_begin(CurBlock), E = pred_end(CurBlock); + PI != E; ++PI) + if (!isPathTransparentTo(*PI, Dom, Ptr, Size, AA, Visited, + TransparentBlocks)) + return false; + return true; +} + + // getEqualNumberNodes - Return nodes with the same value number as the // specified Value. This fills in the argument vector with any equal values. // @@ -120,14 +146,15 @@ getEqualNumberNodes(LI->getOperand(0), PointerSources); PointerSources.push_back(LI->getOperand(0)); - Function *F = LI->getParent()->getParent(); + BasicBlock *LoadBB = LI->getParent(); + Function *F = LoadBB->getParent(); // Now that we know the set of equivalent source pointers for the load // instruction, look to see if there are any load or store candidates that are // identical. // - std::vector CandidateLoads; - std::vector CandidateStores; + std::map > CandidateLoads; + std::map > CandidateStores; while (!PointerSources.empty()) { Value *Source = PointerSources.back(); @@ -138,239 +165,215 @@ if (LoadInst *Cand = dyn_cast(*UI)) {// Is a load of source? if (Cand->getParent()->getParent() == F && // In the same function? Cand != LI && !Cand->isVolatile()) // Not LI itself? - CandidateLoads.push_back(Cand); // Got one... + CandidateLoads[Cand->getParent()].push_back(Cand); // Got one... } else if (StoreInst *Cand = dyn_cast(*UI)) { if (Cand->getParent()->getParent() == F && !Cand->isVolatile() && Cand->getOperand(1) == Source) // It's a store THROUGH the ptr... - CandidateStores.push_back(Cand); + CandidateStores[Cand->getParent()].push_back(Cand); } } - // Get Alias Analysis... + // Get alias analysis & dominators. AliasAnalysis &AA = getAnalysis(); DominatorSet &DomSetInfo = getAnalysis(); - - // Loop over all of the candidate loads. If they are not invalidated by - // stores or calls between execution of them and LI, then add them to RetVals. - for (unsigned i = 0, e = CandidateLoads.size(); i != e; ++i) - if (haveEqualValueNumber(LI, CandidateLoads[i], AA, DomSetInfo)) - RetVals.push_back(CandidateLoads[i]); - for (unsigned i = 0, e = CandidateStores.size(); i != e; ++i) - if (haveEqualValueNumber(LI, CandidateStores[i], AA, DomSetInfo)) - RetVals.push_back(CandidateStores[i]->getOperand(0)); - -} - -// CheckForInvalidatingInst - Return true if BB or any of the predecessors of BB -// (until DestBB) contain an instruction that might invalidate Ptr. -// -static bool CheckForInvalidatingInst(BasicBlock *BB, BasicBlock *DestBB, - Value *Ptr, unsigned Size, - AliasAnalysis &AA, - std::set &VisitedSet) { - // Found the termination point! - if (BB == DestBB || VisitedSet.count(BB)) return false; - - // Avoid infinite recursion! - VisitedSet.insert(BB); - - // Can this basic block modify Ptr? - if (AA.canBasicBlockModify(*BB, Ptr, Size)) - return true; - - // Check all of our predecessor blocks... - for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE; ++PI) - if (CheckForInvalidatingInst(*PI, DestBB, Ptr, Size, AA, VisitedSet)) - return true; - - // None of our predecessor blocks contain an invalidating instruction, and we - // don't either! - return false; -} - - -/// haveEqualValueNumber - Given two load instructions, determine if they both -/// produce the same value on every execution of the program, assuming that -/// their source operands always give the same value. This uses the -/// AliasAnalysis implementation to invalidate loads when stores or function -/// calls occur that could modify the value produced by the load. -/// -bool LoadVN::haveEqualValueNumber(LoadInst *L1, LoadInst *L2, - AliasAnalysis &AA, - DominatorSet &DomSetInfo) const { - assert(L1 != L2 && "haveEqualValueNumber assumes differing loads!"); - assert(L1->getType() == L2->getType() && - "How could the same source pointer return different types?"); - Value *LoadAddress = L1->getOperand(0); - + Value *LoadPtr = LI->getOperand(0); // Find out how many bytes of memory are loaded by the load instruction... - unsigned LoadSize = getAnalysis().getTypeSize(L1->getType()); + unsigned LoadSize = getAnalysis().getTypeSize(LI->getType()); - // If the two loads are in the same basic block, just do a local analysis. - if (L1->getParent() == L2->getParent()) { - // It can be _very_ expensive to determine which instruction occurs first in - // the basic block if the block is large (see PR209). For this reason, - // instead of figuring out which block is first, then scanning all of the - // instructions, we scan the instructions both ways from L1 until we find - // L2. Along the way if we find a potentially modifying instruction, we - // kill the search. This helps in cases where we have large blocks the have - // potentially modifying instructions in them which stop the search. - - BasicBlock *BB = L1->getParent(); - BasicBlock::iterator UpIt = L1, DownIt = L1; ++DownIt; - bool NoModifiesUp = true, NoModifiesDown = true; - - // Scan up and down looking for L2, a modifying instruction, or the end of a - // basic block. - while (UpIt != BB->begin() && DownIt != BB->end()) { - // Scan up... - --UpIt; - if (&*UpIt == L2) - return NoModifiesUp; // No instructions invalidate the loads! - if (NoModifiesUp) - NoModifiesUp &= - !(AA.getModRefInfo(UpIt, LoadAddress, LoadSize) & AliasAnalysis::Mod); - - if (&*DownIt == L2) - return NoModifiesDown; - if (NoModifiesDown) - NoModifiesDown &= - !(AA.getModRefInfo(DownIt, LoadAddress, LoadSize) - & AliasAnalysis::Mod); - ++DownIt; + // Find all of the candidate loads and stores that are in the same block as + // the defining instruction. + std::set Instrs; + Instrs.insert(CandidateLoads[LoadBB].begin(), CandidateLoads[LoadBB].end()); + CandidateLoads.erase(LoadBB); + Instrs.insert(CandidateStores[LoadBB].begin(), CandidateStores[LoadBB].end()); + CandidateStores.erase(LoadBB); + + // Figure out if the load is invalidated from the entry of the block it is in + // until the actual instruction. This scans the block backwards from LI. If + // we see any candidate load or store instructions, then we know that the + // candidates have the same value # as LI. + bool LoadInvalidatedInBBBefore = false; + for (BasicBlock::iterator I = LI; I != LoadBB->begin(); ) { + --I; + // If this instruction is a candidate load before LI, we know there are no + // invalidating instructions between it and LI, so they have the same value + // number. + if (isa(I) && Instrs.count(I)) { + RetVals.push_back(I); + Instrs.erase(I); } - // If we got here, we ran into one end of the basic block or the other. - if (UpIt != BB->begin()) { - // If we know that the upward scan found a modifier, return false. - if (!NoModifiesUp) return false; - - // Otherwise, continue the scan looking for a modifier or L2. - for (--UpIt; &*UpIt != L2; --UpIt) - if (AA.getModRefInfo(UpIt, LoadAddress, LoadSize) & AliasAnalysis::Mod) - return false; - return true; - } else { - // If we know that the downward scan found a modifier, return false. - assert(DownIt != BB->end() && "Didn't find instructions??"); - if (!NoModifiesDown) return false; - - // Otherwise, continue the scan looking for a modifier or L2. - for (; &*DownIt != L2; ++DownIt) { - if (AA.getModRefInfo(DownIt, LoadAddress, LoadSize) &AliasAnalysis::Mod) - return false; + if (AA.getModRefInfo(I, LoadPtr, LoadSize) & AliasAnalysis::Mod) { + // If the invalidating instruction is a store, and its in our candidate + // set, then we can do store-load forwarding: the load has the same value + // # as the stored value. + if (isa(I) && Instrs.count(I)) { + Instrs.erase(I); + RetVals.push_back(I->getOperand(0)); } - return true; - } - } else { - // Figure out which load dominates the other one. If neither dominates the - // other we cannot eliminate them. - // - // FIXME: This could be enhanced greatly! - // - if (DomSetInfo.dominates(L2, L1)) - std::swap(L1, L2); // Make L1 dominate L2 - else if (!DomSetInfo.dominates(L1, L2)) - return false; // Neither instruction dominates the other one... - - BasicBlock *BB1 = L1->getParent(), *BB2 = L2->getParent(); - - // L1 now dominates L2. Check to see if the intervening instructions - // between the two loads might modify the loaded location. - // Make sure that there are no modifying instructions between L1 and the end - // of its basic block. - // - if (AA.canInstructionRangeModify(*L1, *BB1->getTerminator(), LoadAddress, - LoadSize)) - return false; // Cannot eliminate load - - // Make sure that there are no modifying instructions between the start of - // BB2 and the second load instruction. - // - if (AA.canInstructionRangeModify(BB2->front(), *L2, LoadAddress, LoadSize)) - return false; // Cannot eliminate load - - // Do a depth first traversal of the inverse CFG starting at L2's block, - // looking for L1's block. The inverse CFG is made up of the predecessor - // nodes of a block... so all of the edges in the graph are "backward". - // - std::set VisitedSet; - for (pred_iterator PI = pred_begin(BB2), PE = pred_end(BB2); PI != PE; ++PI) - if (CheckForInvalidatingInst(*PI, BB1, LoadAddress, LoadSize, AA, - VisitedSet)) - return false; - - // If we passed all of these checks then we are sure that the two loads - // produce the same value. - return true; + LoadInvalidatedInBBBefore = true; + break; + } } -} + // Figure out if the load is invalidated between the load and the exit of the + // block it is defined in. While we are scanning the current basic block, if + // we see any candidate loads, then we know they have the same value # as LI. + // + bool LoadInvalidatedInBBAfter = false; + for (BasicBlock::iterator I = LI->getNext(); I != LoadBB->end(); ++I) { + // If this instruction is a load, then this instruction returns the same + // value as LI. + if (isa(I) && Instrs.count(I)) { + RetVals.push_back(I); + Instrs.erase(I); + } -/// haveEqualValueNumber - Given a load instruction and a store instruction, -/// determine if the stored value reaches the loaded value unambiguously on -/// every execution of the program. This uses the AliasAnalysis implementation -/// to invalidate the stored value when stores or function calls occur that -/// could modify the value produced by the load. -/// -bool LoadVN::haveEqualValueNumber(LoadInst *Load, StoreInst *Store, - AliasAnalysis &AA, - DominatorSet &DomSetInfo) const { - // If the store does not dominate the load, we cannot do anything... - if (!DomSetInfo.dominates(Store, Load)) - return false; - - BasicBlock *BB1 = Store->getParent(), *BB2 = Load->getParent(); - Value *LoadAddress = Load->getOperand(0); - - assert(LoadAddress->getType() == Store->getOperand(1)->getType() && - "How could the same source pointer return different types?"); - - // Find out how many bytes of memory are loaded by the load instruction... - unsigned LoadSize = getAnalysis().getTypeSize(Load->getType()); + if (AA.getModRefInfo(I, LoadPtr, LoadSize) & AliasAnalysis::Mod) { + LoadInvalidatedInBBAfter = true; + break; + } + } - // Compute a basic block iterator pointing to the instruction after the store. - BasicBlock::iterator StoreIt = Store; ++StoreIt; + // If there is anything left in the Instrs set, it could not possibly equal + // LI. + Instrs.clear(); + + // TransparentBlocks - For each basic block the load/store is alive across, + // figure out if the pointer is invalidated or not. If it is invalidated, the + // boolean is set to false, if it's not it is set to true. If we don't know + // yet, the entry is not in the map. + std::map TransparentBlocks; + + // Loop over all of the basic blocks that also load the value. If the value + // is live across the CFG from the source to destination blocks, and if the + // value is not invalidated in either the source or destination blocks, add it + // to the equivalence sets. + for (std::map >::iterator + I = CandidateLoads.begin(), E = CandidateLoads.end(); I != E; ++I) { + bool CantEqual = false; + + // Right now we only can handle cases where one load dominates the other. + // FIXME: generalize this! + BasicBlock *BB1 = I->first, *BB2 = LoadBB; + if (DomSetInfo.dominates(BB1, BB2)) { + // The other load dominates LI. If the loaded value is killed entering + // the LoadBB block, we know the load is not live. + if (LoadInvalidatedInBBBefore) + CantEqual = true; + } else if (DomSetInfo.dominates(BB2, BB1)) { + std::swap(BB1, BB2); // Canonicalize + // LI dominates the other load. If the loaded value is killed exiting + // the LoadBB block, we know the load is not live. + if (LoadInvalidatedInBBAfter) + CantEqual = true; + } else { + // None of these loads can VN the same. + CantEqual = true; + } - // Check to see if the intervening instructions between the two store and load - // include a store or call... - // - if (BB1 == BB2) { // In same basic block? - // In this degenerate case, no checking of global basic blocks has to occur - // just check the instructions BETWEEN Store & Load... - // - if (AA.canInstructionRangeModify(*StoreIt, *Load, LoadAddress, LoadSize)) - return false; // Cannot eliminate load + if (!CantEqual) { + // Ok, at this point, we know that BB1 dominates BB2, and that there is + // nothing in the LI block that kills the loaded value. Check to see if + // the value is live across the CFG. + std::set Visited; + for (pred_iterator PI = pred_begin(BB2), E = pred_end(BB2); PI!=E; ++PI) + if (!isPathTransparentTo(*PI, BB1, LoadPtr, LoadSize, AA, + Visited, TransparentBlocks)) { + // None of these loads can VN the same. + CantEqual = true; + break; + } + } - // No instructions invalidate the stored value, they produce the same value! - return true; - } else { - // Make sure that there are no store instructions between the Store and the - // end of its basic block... - // - if (AA.canInstructionRangeModify(*StoreIt, *BB1->getTerminator(), - LoadAddress, LoadSize)) - return false; // Cannot eliminate load - - // Make sure that there are no store instructions between the start of BB2 - // and the second load instruction... - // - if (AA.canInstructionRangeModify(BB2->front(), *Load, LoadAddress,LoadSize)) - return false; // Cannot eliminate load - - // Do a depth first traversal of the inverse CFG starting at L2's block, - // looking for L1's block. The inverse CFG is made up of the predecessor - // nodes of a block... so all of the edges in the graph are "backward". - // - std::set VisitedSet; - for (pred_iterator PI = pred_begin(BB2), PE = pred_end(BB2); PI != PE; ++PI) - if (CheckForInvalidatingInst(*PI, BB1, LoadAddress, LoadSize, AA, - VisitedSet)) - return false; + // If the loads can equal so far, scan the basic block that contains the + // loads under consideration to see if they are invalidated in the block. + // For any loads that are not invalidated, add them to the equivalence + // set! + if (!CantEqual) { + Instrs.insert(I->second.begin(), I->second.end()); + if (BB1 == LoadBB) { + // If LI dominates the block in question, check to see if any of the + // loads in this block are invalidated before they are reached. + for (BasicBlock::iterator BBI = I->first->begin(); ; ++BBI) { + if (isa(BBI) && Instrs.count(BBI)) { + // The load is in the set! + RetVals.push_back(BBI); + Instrs.erase(BBI); + if (Instrs.empty()) break; + } else if (AA.getModRefInfo(BBI, LoadPtr, LoadSize) + & AliasAnalysis::Mod) { + // If there is a modifying instruction, nothing below it will value + // # the same. + break; + } + } + } else { + // If the block dominates LI, make sure that the loads in the block are + // not invalidated before the block ends. + BasicBlock::iterator BBI = I->first->end(); + while (1) { + --BBI; + if (isa(BBI) && Instrs.count(BBI)) { + // The load is in the set! + RetVals.push_back(BBI); + Instrs.erase(BBI); + if (Instrs.empty()) break; + } else if (AA.getModRefInfo(BBI, LoadPtr, LoadSize) + & AliasAnalysis::Mod) { + // If there is a modifying instruction, nothing above it will value + // # the same. + break; + } + } + } - // If we passed all of these checks then we are sure that the two loads - // produce the same value. - return true; + Instrs.clear(); + } } + + // Handle candidate stores. If the loaded location is clobbered on entrance + // to the LoadBB, no store outside of the LoadBB can value number equal, so + // quick exit. + if (LoadInvalidatedInBBBefore) + return; + + for (std::map >::iterator + I = CandidateStores.begin(), E = CandidateStores.end(); I != E; ++I) + if (DomSetInfo.dominates(I->first, LoadBB)) { + // Check to see if the path from the store to the load is transparent + // w.r.t. the memory location. + bool CantEqual = false; + std::set Visited; + for (pred_iterator PI = pred_begin(LoadBB), E = pred_end(LoadBB); + PI != E; ++PI) + if (!isPathTransparentTo(*PI, I->first, LoadPtr, LoadSize, AA, + Visited, TransparentBlocks)) { + // None of these stores can VN the same. + CantEqual = true; + break; + } + Visited.clear(); + if (!CantEqual) { + // Okay, the path from the store block to the load block is clear, and + // we know that there are no invalidating instructions from the start + // of the load block to the load itself. Now we just scan the store + // block. + + BasicBlock::iterator BBI = I->first->end(); + while (1) { + --BBI; + if (AA.getModRefInfo(BBI, LoadPtr, LoadSize)& AliasAnalysis::Mod){ + // If the invalidating instruction is one of the candidates, + // then it provides the value the load loads. + if (StoreInst *SI = dyn_cast(BBI)) + if (std::find(I->second.begin(), I->second.end(), SI) != + I->second.end()) + RetVals.push_back(SI->getOperand(0)); + break; + } + } + } + } } From lattner at cs.uiuc.edu Thu Feb 5 11:32:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 5 11:32:02 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402051731.LAA04531@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.109 -> 1.110 --- Log message: s/gcse/scalarrepl --- Diffs of the changes: (+2 -2) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.109 llvm/docs/ReleaseNotes.html:1.110 --- llvm/docs/ReleaseNotes.html:1.109 Wed Feb 4 18:48:41 2004 +++ llvm/docs/ReleaseNotes.html Thu Feb 5 11:31:37 2004 @@ -123,7 +123,7 @@
  • [vmcore] OpaqueType objects memory leak
  • [llvmgcc] C front-end does not compile "extern inline" into linkonce
  • Bytecode format inconsistent
  • -
  • [loadvn/inline/gcse] Slow optimizations with extremely large basic blocks
  • +
  • [loadvn/inline/scalarrepl] Slow optimizations with extremely large basic blocks
  • @@ -618,7 +618,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/05 00:48:41 $ + Last modified: $Date: 2004/02/05 17:31:37 $ From criswell at cs.uiuc.edu Thu Feb 5 12:46:02 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 5 12:46:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Applications/lambda-0.1.3/Makefile Message-ID: <200402051845.MAA28988@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Applications/lambda-0.1.3: Makefile updated: 1.1 -> 1.2 --- Log message: It seems Solaris/Sparc wants all of libstdc++. --- Diffs of the changes: (+2 -2) Index: llvm/test/Programs/MultiSource/Applications/lambda-0.1.3/Makefile diff -u llvm/test/Programs/MultiSource/Applications/lambda-0.1.3/Makefile:1.1 llvm/test/Programs/MultiSource/Applications/lambda-0.1.3/Makefile:1.2 --- llvm/test/Programs/MultiSource/Applications/lambda-0.1.3/Makefile:1.1 Mon Dec 29 11:37:35 2003 +++ llvm/test/Programs/MultiSource/Applications/lambda-0.1.3/Makefile Thu Feb 5 12:45:15 2004 @@ -1,6 +1,6 @@ LEVEL = ../../../../.. PROG = lambda -LDFLAGS = -lsupc++ -LIBS += -lsupc++ +LDFLAGS = -lstdc++ +LIBS += -lstdc++ STDIN_FILENAME=$(BUILD_SRC_DIR)/input include ../../Makefile.multisrc From alkis at niobe.cs.uiuc.edu Thu Feb 5 14:46:01 2004 From: alkis at niobe.cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Feb 5 14:46:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200402052045.i15Kjop08961@niobe.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.44 -> 1.45 --- Log message: We don't need to scan the blocks that we are live-in on every access. Rather we only have to do it on the creation of the interval. --- Diffs of the changes: (+13 -12) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.44 llvm/lib/CodeGen/LiveIntervals.cpp:1.45 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.44 Mon Feb 2 14:29:57 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Thu Feb 5 14:45:40 2004 @@ -162,21 +162,22 @@ // update interval index for this register r2iMap_.insert(r2iit, std::make_pair(reg, --intervals_.end())); interval = &intervals_.back(); - } - else { - interval = &*r2iit->second; - } - // iterate over all of the blocks that the variable is completely - // live in, adding them to the live interval - for (unsigned i = 0, e = vi.AliveBlocks.size(); i != e; ++i) { - if (vi.AliveBlocks[i]) { - MachineBasicBlock* mbb = lv_->getIndexMachineBasicBlock(i); - if (!mbb->empty()) { - interval->addRange(getInstructionIndex(mbb->front()), - getInstructionIndex(mbb->back()) + 1); + // iterate over all of the blocks that the variable is + // completely live in, adding them to the live + // interval. obviously we only need to do this once. + for (unsigned i = 0, e = vi.AliveBlocks.size(); i != e; ++i) { + if (vi.AliveBlocks[i]) { + MachineBasicBlock* mbb = lv_->getIndexMachineBasicBlock(i); + if (!mbb->empty()) { + interval->addRange(getInstructionIndex(mbb->front()), + getInstructionIndex(mbb->back()) + 1); + } } } + } + else { + interval = &*r2iit->second; } bool killedInDefiningBasicBlock = false; From lattner at cs.uiuc.edu Thu Feb 5 15:12:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 5 15:12:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopSimplify/2004-02-05-DominatorInfoCorruption.ll Message-ID: <200402052111.PAA19097@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopSimplify: 2004-02-05-DominatorInfoCorruption.ll added (r1.1) --- Log message: New testcase for PR223: Loopsimplify incorrectly updates dominator information --- Diffs of the changes: (+17 -0) Index: llvm/test/Regression/Transforms/LoopSimplify/2004-02-05-DominatorInfoCorruption.ll diff -c /dev/null llvm/test/Regression/Transforms/LoopSimplify/2004-02-05-DominatorInfoCorruption.ll:1.1 *** /dev/null Thu Feb 5 15:11:48 2004 --- llvm/test/Regression/Transforms/LoopSimplify/2004-02-05-DominatorInfoCorruption.ll Thu Feb 5 15:11:38 2004 *************** *** 0 **** --- 1,17 ---- + ; RUN: llvm-as < %s | opt -loopsimplify -verify -licm -disable-output + implementation ; Functions: + + void %.subst_48() { + entry: + br label %loopentry.0 + + loopentry.0: ; preds = %entry, %loopentry.0 + br bool false, label %loopentry.0, label %loopentry.2 + + loopentry.2: ; preds = %loopentry.0, %loopentry.2 + %tmp.968 = setle int 0, 3 ; [#uses=1] + br bool %tmp.968, label %loopentry.2, label %UnifiedReturnBlock + + UnifiedReturnBlock: ; preds = %entry, %loopentry.2 + ret void + } From lattner at cs.uiuc.edu Thu Feb 5 15:13:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 5 15:13:00 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopSimplify.cpp Message-ID: <200402052112.PAA19106@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopSimplify.cpp updated: 1.31 -> 1.32 --- Log message: Fix PR223: Loopsimplify incorrectly updates dominator information The problem is that the dominator update code didn't "realize" that it's possible for the newly inserted basic block to dominate anything. Because it IS possible, stuff was getting updated wrong. --- Diffs of the changes: (+106 -34) Index: llvm/lib/Transforms/Scalar/LoopSimplify.cpp diff -u llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.31 llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.32 --- llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.31 Tue Feb 3 21:58:28 2004 +++ llvm/lib/Transforms/Scalar/LoopSimplify.cpp Thu Feb 5 15:12:24 2004 @@ -484,20 +484,44 @@ /// dominators, dominator trees, and dominance frontiers) after a new block has /// been added to the CFG. /// -/// This only supports the case when an existing block (known as "Exit"), had -/// some of its predecessors factored into a new basic block. This +/// This only supports the case when an existing block (known as "NewBBSucc"), +/// had some of its predecessors factored into a new basic block. This /// transformation inserts a new basic block ("NewBB"), with a single -/// unconditional branch to Exit, and moves some predecessors of "Exit" to now -/// branch to NewBB. These predecessors are listed in PredBlocks, even though -/// they are the same as pred_begin(NewBB)/pred_end(NewBB). +/// unconditional branch to NewBBSucc, and moves some predecessors of +/// "NewBBSucc" to now branch to NewBB. These predecessors are listed in +/// PredBlocks, even though they are the same as +/// pred_begin(NewBB)/pred_end(NewBB). /// void LoopSimplify::UpdateDomInfoForRevectoredPreds(BasicBlock *NewBB, std::vector &PredBlocks) { + assert(!PredBlocks.empty() && "No predblocks??"); assert(succ_begin(NewBB) != succ_end(NewBB) && ++succ_begin(NewBB) == succ_end(NewBB) && "NewBB should have a single successor!"); + BasicBlock *NewBBSucc = *succ_begin(NewBB); DominatorSet &DS = getAnalysis(); + // The newly inserted basic block will dominate existing basic blocks iff the + // PredBlocks dominate all of the non-pred blocks. If all predblocks dominate + // the non-pred blocks, then they all must be the same block! + bool NewBBDominatesNewBBSucc = true; + { + BasicBlock *OnePred = PredBlocks[0]; + for (unsigned i = 1, e = PredBlocks.size(); i != e; ++i) + if (PredBlocks[i] != OnePred) { + NewBBDominatesNewBBSucc = false; + break; + } + + if (NewBBDominatesNewBBSucc) + for (pred_iterator PI = pred_begin(NewBBSucc), E = pred_end(NewBBSucc); + PI != E; ++PI) + if (*PI != NewBB && !DS.dominates(OnePred, *PI)) { + NewBBDominatesNewBBSucc = false; + break; + } + } + // Update dominator information... The blocks that dominate NewBB are the // intersection of the dominators of predecessors, plus the block itself. // The newly created basic block does not dominate anything except itself. @@ -508,13 +532,22 @@ NewBBDomSet.insert(NewBB); // All blocks dominate themselves... DS.addBasicBlock(NewBB, NewBBDomSet); + // If NewBB dominates some blocks, then it will dominate all blocks that + // PredBlocks[0] used to except for PredBlocks[0] itself. + if (NewBBDominatesNewBBSucc) { + BasicBlock *PredBlock = PredBlocks[0]; + Function *F = NewBB->getParent(); + for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) + if (DS.properlyDominates(PredBlock, I)) + DS.addDominator(I, NewBB); + } + // Update immediate dominator information if we have it... BasicBlock *NewBBIDom = 0; if (ImmediateDominators *ID = getAnalysisToUpdate()) { - // This block does not strictly dominate anything, so it is not an immediate - // dominator. To find the immediate dominator of the new exit node, we - // trace up the immediate dominators of a predecessor until we find a basic - // block that dominates the exit block. + // To find the immediate dominator of the new exit node, we trace up the + // immediate dominators of a predecessor until we find a basic block that + // dominates the exit block. // BasicBlock *Dom = PredBlocks[0]; // Some random predecessor... while (!NewBBDomSet.count(Dom)) { // Loop until we find a dominator... @@ -525,13 +558,21 @@ // Set the immediate dominator now... ID->addNewBlock(NewBB, Dom); NewBBIDom = Dom; // Reuse this if calculating DominatorTree info... + + // If NewBB strictly dominates other blocks, we need to update their idom's + // now. The only block that need adjustment is the NewBBSucc block, whose + // idom should currently be set to PredBlocks[0]. + if (NewBBDominatesNewBBSucc) { + assert(ID->get(NewBBSucc) == PredBlocks[0] && + "Immediate dominator update code broken!"); + ID->setImmediateDominator(NewBBSucc, NewBB); + } } // Update DominatorTree information if it is active. if (DominatorTree *DT = getAnalysisToUpdate()) { - // NewBB doesn't dominate anything, so just create a node and link it into - // its immediate dominator. If we don't have ImmediateDominator info - // around, calculate the idom as above. + // If we don't have ImmediateDominator info around, calculate the idom as + // above. DominatorTree::Node *NewBBIDomNode; if (NewBBIDom) { NewBBIDomNode = DT->getNode(NewBBIDom); @@ -543,27 +584,58 @@ } } - // Create the new dominator tree node... - DT->createNewNode(NewBB, NewBBIDomNode); + // Create the new dominator tree node... and set the idom of NewBB. + DominatorTree::Node *NewBBNode = DT->createNewNode(NewBB, NewBBIDomNode); + + // If NewBB strictly dominates other blocks, then it is now the immediate + // dominator of NewBBSucc. Update the dominator tree as appropriate. + if (NewBBDominatesNewBBSucc) { + DominatorTree::Node *NewBBSuccNode = DT->getNode(NewBBSucc); + assert(NewBBSuccNode->getIDom()->getBlock() == PredBlocks[0] && + "Immediate tree update code broken!"); + DT->changeImmediateDominator(NewBBSuccNode, NewBBNode); + } } // Update dominance frontier information... if (DominanceFrontier *DF = getAnalysisToUpdate()) { - // DF(NewBB) is {Exit} because NewBB does not strictly dominate Exit, but it - // does dominate itself (and there is an edge (NewBB -> Exit)). Exit is the - // single successor of NewBB. - DominanceFrontier::DomSetType NewDFSet; - BasicBlock *Exit = *succ_begin(NewBB); - NewDFSet.insert(Exit); - DF->addBasicBlock(NewBB, NewDFSet); - - // Now we must loop over all of the dominance frontiers in the function, - // replacing occurrences of Exit with NewBB in some cases. All blocks that - // dominate a block in PredBlocks and contained Exit in their dominance - // frontier must be updated to contain NewBB instead. This only occurs if - // there is more than one block in PredBlocks. - // - if (PredBlocks.size() > 1) { + // If NewBB dominates NewBBSucc, then the global dominance frontiers are not + // changed. DF(NewBB) is now going to be the DF(PredBlocks[0]) without the + // stuff that the new block does not dominate a predecessor of. + if (NewBBDominatesNewBBSucc) { + DominanceFrontier::iterator DFI = DF->find(PredBlocks[0]); + if (DFI != DF->end()) { + DominanceFrontier::DomSetType Set = DFI->second; + // Filter out stuff in Set that we do not dominate a predecessor of. + for (DominanceFrontier::DomSetType::iterator SetI = Set.begin(), + E = Set.end(); SetI != E;) { + bool DominatesPred = false; + for (pred_iterator PI = pred_begin(*SetI), E = pred_end(*SetI); + PI != E; ++PI) + if (DS.dominates(NewBB, *PI)) + DominatesPred = true; + if (!DominatesPred) + Set.erase(SetI++); + else + ++SetI; + } + + DF->addBasicBlock(NewBB, Set); + } + + } else { + // DF(NewBB) is {NewBBSucc} because NewBB does not strictly dominate + // NewBBSucc, but it does dominate itself (and there is an edge (NewBB -> + // NewBBSucc)). NewBBSucc is the single successor of NewBB. + DominanceFrontier::DomSetType NewDFSet; + NewDFSet.insert(NewBBSucc); + DF->addBasicBlock(NewBB, NewDFSet); + + // Now we must loop over all of the dominance frontiers in the function, + // replacing occurrences of NewBBSucc with NewBB in some cases. All + // blocks that dominate a block in PredBlocks and contained NewBBSucc in + // their dominance frontier must be updated to contain NewBB instead. + // for (unsigned i = 0, e = PredBlocks.size(); i != e; ++i) { BasicBlock *Pred = PredBlocks[i]; // Get all of the dominators of the predecessor... @@ -572,13 +644,13 @@ PDE = PredDoms.end(); PDI != PDE; ++PDI) { BasicBlock *PredDom = *PDI; - // If the Exit node is in DF(PredDom), then PredDom didn't dominate - // Exit but did dominate a predecessor of it. Now we change this - // entry to include NewBB in the DF instead of Exit. + // If the NewBBSucc node is in DF(PredDom), then PredDom didn't + // dominate NewBBSucc but did dominate a predecessor of it. Now we + // change this entry to include NewBB in the DF instead of NewBBSucc. DominanceFrontier::iterator DFI = DF->find(PredDom); assert(DFI != DF->end() && "No dominance frontier for node?"); - if (DFI->second.count(Exit)) { - DF->removeFromFrontier(DFI, Exit); + if (DFI->second.count(NewBBSucc)) { + DF->removeFromFrontier(DFI, NewBBSucc); DF->addToFrontier(DFI, NewBB); } } From lattner at cs.uiuc.edu Thu Feb 5 15:17:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 5 15:17:01 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402052116.PAA22272@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.110 -> 1.111 --- Log message: Bug fixed --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.110 llvm/docs/ReleaseNotes.html:1.111 --- llvm/docs/ReleaseNotes.html:1.110 Thu Feb 5 11:31:37 2004 +++ llvm/docs/ReleaseNotes.html Thu Feb 5 15:16:42 2004 @@ -167,6 +167,7 @@
  • [bcreader] Bytecode reader misreads 'long -9223372036854775808'!
  • VMCore mishandles double -0.0
  • [X86] X86 backend code generates -0.0 as +0.0
  • +
  • [loopsimplify] Loopsimplify incorrectly updates dominator information
  • @@ -618,7 +619,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/05 17:31:37 $ + Last modified: $Date: 2004/02/05 21:16:42 $ From lattner at cs.uiuc.edu Thu Feb 5 15:18:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 5 15:18:01 2004 Subject: [llvm-commits] CVS: llvm-www/releases/1.1/docs/ReleaseNotes.html Message-ID: <200402052117.PAA22929@zion.cs.uiuc.edu> Changes in directory llvm-www/releases/1.1/docs: ReleaseNotes.html updated: 1.17 -> 1.18 --- Log message: Bug fixed. Also, move another bug from into the 'fixed in 1.2' section --- Diffs of the changes: (+3 -7) Index: llvm-www/releases/1.1/docs/ReleaseNotes.html diff -u llvm-www/releases/1.1/docs/ReleaseNotes.html:1.17 llvm-www/releases/1.1/docs/ReleaseNotes.html:1.18 --- llvm-www/releases/1.1/docs/ReleaseNotes.html:1.17 Tue Feb 3 17:00:20 2004 +++ llvm-www/releases/1.1/docs/ReleaseNotes.html Thu Feb 5 15:17:11 2004 @@ -376,12 +376,6 @@ -
  • - -Tail duplication does not update SSA form correctly. - -
  • - Bugs in 1.1 fixed in 1.2: @@ -767,7 +763,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/03 23:00:20 $ + Last modified: $Date: 2004/02/05 21:17:11 $ From lattner at cs.uiuc.edu Thu Feb 5 16:34:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 5 16:34:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/GCSE.cpp Message-ID: <200402052233.QAA03758@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: GCSE.cpp updated: 1.33 -> 1.34 --- Log message: Add debug output --- Diffs of the changes: (+4 -0) Index: llvm/lib/Transforms/Scalar/GCSE.cpp diff -u llvm/lib/Transforms/Scalar/GCSE.cpp:1.33 llvm/lib/Transforms/Scalar/GCSE.cpp:1.34 --- llvm/lib/Transforms/Scalar/GCSE.cpp:1.33 Fri Jan 9 00:02:20 2004 +++ llvm/lib/Transforms/Scalar/GCSE.cpp Thu Feb 5 16:33:19 2004 @@ -21,6 +21,7 @@ #include "llvm/Analysis/ValueNumbering.h" #include "llvm/Support/InstIterator.h" #include "Support/Statistic.h" +#include "Support/Debug.h" #include using namespace llvm; @@ -165,6 +166,9 @@ // void GCSE::ReplaceInstWithInst(Instruction *First, BasicBlock::iterator SI) { Instruction &Second = *SI; + + DEBUG(std::cerr << "GCSE: Substituting %" << First->getName() << " for: " + << Second); //cerr << "DEL " << (void*)Second << Second; From lattner at cs.uiuc.edu Thu Feb 5 16:34:15 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 5 16:34:15 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopSimplify.cpp Message-ID: <200402052233.QAA04231@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopSimplify.cpp updated: 1.32 -> 1.33 --- Log message: Fix bug updating dominators --- Diffs of the changes: (+2 -2) Index: llvm/lib/Transforms/Scalar/LoopSimplify.cpp diff -u llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.32 llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.33 --- llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.32 Thu Feb 5 15:12:24 2004 +++ llvm/lib/Transforms/Scalar/LoopSimplify.cpp Thu Feb 5 16:33:26 2004 @@ -533,12 +533,12 @@ DS.addBasicBlock(NewBB, NewBBDomSet); // If NewBB dominates some blocks, then it will dominate all blocks that - // PredBlocks[0] used to except for PredBlocks[0] itself. + // NewBBSucc does. if (NewBBDominatesNewBBSucc) { BasicBlock *PredBlock = PredBlocks[0]; Function *F = NewBB->getParent(); for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) - if (DS.properlyDominates(PredBlock, I)) + if (DS.dominates(NewBBSucc, I)) DS.addDominator(I, NewBB); } From alkis at niobe.cs.uiuc.edu Thu Feb 5 16:56:01 2004 From: alkis at niobe.cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Feb 5 16:56:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200402052255.i15MtaO28776@niobe.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.45 -> 1.46 --- Log message: Change live interval representation. Machine instructions now have two slots each. As a concequence they get numbered as 0, 2, 4 and so on. The first slot is used for operand uses and the second for defs. Here's an example: 0: A = ... 2: B = ... 4: C = A + B ;; last use of A The live intervals should look like: A = [1, 5) B = [3, x) C = [5, y) --- Diffs of the changes: (+31 -22) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.45 llvm/lib/CodeGen/LiveIntervals.cpp:1.46 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.45 Thu Feb 5 14:45:40 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Thu Feb 5 16:55:25 2004 @@ -94,7 +94,7 @@ mi != miEnd; ++mi) { inserted = mi2iMap_.insert(std::make_pair(*mi, miIndex)).second; assert(inserted && "multiple MachineInstr -> index mappings"); - ++miIndex; + miIndex += 2; } } @@ -150,8 +150,6 @@ { DEBUG(std::cerr << "\t\tregister: ";printRegName(reg); std::cerr << '\n'); - unsigned instrIndex = getInstructionIndex(*mi); - LiveVariables::VarInfo& vi = lv_->getVarInfo(reg); Interval* interval = 0; @@ -180,6 +178,10 @@ interval = &*r2iit->second; } + // we consider defs to happen at the second time slot of the + // instruction + unsigned instrIndex = getInstructionIndex(*mi) + 1; + bool killedInDefiningBasicBlock = false; for (int i = 0, e = vi.Kills.size(); i != e; ++i) { MachineBasicBlock* killerBlock = vi.Kills[i].first; @@ -187,7 +189,9 @@ unsigned start = (mbb == killerBlock ? instrIndex : getInstructionIndex(killerBlock->front())); - unsigned end = getInstructionIndex(killerInstr) + 1; + unsigned end = (killerInstr == *mi ? + instrIndex + 1 : // dead + getInstructionIndex(killerInstr) + 1); // killed // we do not want to add invalid ranges. these can happen when // a variable has its latest use and is redefined later on in // the same basic block (common with variables introduced by @@ -213,14 +217,17 @@ DEBUG(std::cerr << "\t\tregister: "; printRegName(reg)); MachineBasicBlock::iterator e = mbb->end(); - unsigned start = getInstructionIndex(*mi); - unsigned end = start + 1; + // we consider defs to happen at the second time slot of the + // instruction + unsigned start, end; + start = end = getInstructionIndex(*mi) + 1; // a variable can be dead by the instruction defining it for (KillIter ki = lv_->dead_begin(*mi), ke = lv_->dead_end(*mi); ki != ke; ++ki) { if (reg == ki->second) { DEBUG(std::cerr << " dead\n"); + ++end; goto exit; } } @@ -228,7 +235,7 @@ // a variable can only be killed by subsequent instructions do { ++mi; - ++end; + end += 2; for (KillIter ki = lv_->killed_begin(*mi), ke = lv_->killed_end(*mi); ki != ke; ++ki) { if (reg == ki->second) { @@ -437,15 +444,17 @@ } -// This example is provided becaues liveAt() is non-obvious: +// An example for liveAt(): // -// this = [1,2), liveAt(1) will return false. The idea is that the -// variable is defined in 1 and not live after definition. So it was -// dead to begin with (defined but never used). +// this = [1,2), liveAt(0) will return false. The instruction defining +// this spans slots [0,1]. Since it is a definition we say that it is +// live in the second slot onwards. By ending the lifetime of this +// interval at 2 it means that it is not used at all. liveAt(1) +// returns true which means that this clobbers a register at +// instruction at 0. // -// this = [1,3), liveAt(2) will return false. The variable is used at -// 2 but 2 is the last use so the variable's allocated register is -// available for reuse. +// this = [1,4), liveAt(0) will return false and liveAt(2) will return +// true. The variable is defined at instruction 0 and last used at 2. bool LiveIntervals::Interval::liveAt(unsigned index) const { Range dummy(index, index+1); @@ -456,20 +465,20 @@ return false; --r; - return index >= r->first && index < (r->second - 1); + return index >= r->first && index < r->second; } -// This example is provided because overlaps() is non-obvious: +// An example for overlaps(): // // 0: A = ... -// 1: B = ... -// 2: C = A + B ;; last use of A +// 2: B = ... +// 4: C = A + B ;; last use of A // // The live intervals should look like: // -// A = [0, 3) -// B = [1, x) -// C = [2, y) +// A = [1, 5) +// B = [3, x) +// C = [5, y) // // A->overlaps(C) should return false since we want to be able to join // A and C. @@ -499,7 +508,7 @@ } assert(i->first < j->first); - if ((i->second - 1) > j->first) { + if (i->second > j->first) { return true; } else { From lattner at cs.uiuc.edu Thu Feb 5 17:22:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 5 17:22:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopSimplify.cpp Message-ID: <200402052321.RAA16313@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopSimplify.cpp updated: 1.33 -> 1.34 --- Log message: Fix another dominator update bug. These bugs keep getting exposed because GCSE keeps finding more code motion opportunities now that the dominators are correct! --- Diffs of the changes: (+1 -1) Index: llvm/lib/Transforms/Scalar/LoopSimplify.cpp diff -u llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.33 llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.34 --- llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.33 Thu Feb 5 16:33:26 2004 +++ llvm/lib/Transforms/Scalar/LoopSimplify.cpp Thu Feb 5 17:20:59 2004 @@ -516,7 +516,7 @@ if (NewBBDominatesNewBBSucc) for (pred_iterator PI = pred_begin(NewBBSucc), E = pred_end(NewBBSucc); PI != E; ++PI) - if (*PI != NewBB && !DS.dominates(OnePred, *PI)) { + if (*PI != NewBB && !DS.dominates(NewBBSucc, *PI)) { NewBBDominatesNewBBSucc = false; break; } From alkis at cs.uiuc.edu Thu Feb 5 21:16:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Feb 5 21:16:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <200402060315.VAA18367@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.41 -> 1.42 --- Log message: Eliminate uneeded lookups by passing a Virt2PhysMap::iterator instead of the virtual register to certain functions. --- Diffs of the changes: (+33 -23) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.41 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.42 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.41 Wed Feb 4 16:17:40 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Thu Feb 5 21:15:40 2004 @@ -176,12 +176,13 @@ /// assignVirt2PhysReg - assigns the free physical register to /// the virtual register passed as arguments - void assignVirt2PhysReg(unsigned virtReg, unsigned physReg); + Virt2PhysMap::iterator + assignVirt2PhysReg(unsigned virtReg, unsigned physReg); /// clearVirtReg - free the physical register associated with this /// virtual register and disassociate virtual->physical and /// physical->virtual mappings - void clearVirtReg(unsigned virtReg); + void clearVirtReg(Virt2PhysMap::iterator it); /// assignVirt2StackSlot - assigns this virtual register to a /// stack slot @@ -192,12 +193,13 @@ int getStackSlot(unsigned virtReg); /// spillVirtReg - spills the virtual register - void spillVirtReg(unsigned virtReg); + void spillVirtReg(Virt2PhysMap::iterator it); /// loadPhysReg - loads to the physical register the value of /// the virtual register specifed. Virtual register must have /// an assigned stack slot - void loadVirt2PhysReg(unsigned virtReg, unsigned physReg); + Virt2PhysMap::iterator + loadVirt2PhysReg(unsigned virtReg, unsigned physReg); void printVirtRegAssignment() const { std::cerr << "register assignment:\n"; @@ -460,7 +462,7 @@ continue; } - typedef std::vector Regs; + typedef std::vector Regs; Regs toClear; Regs toSpill; @@ -473,19 +475,19 @@ if (op.isVirtualRegister() && op.isUse()) { unsigned virtReg = op.getAllocatedRegNum(); unsigned physReg = 0; - Virt2PhysMap::const_iterator it = v2pMap_.find(virtReg); + Virt2PhysMap::iterator it = v2pMap_.find(virtReg); if (it != v2pMap_.end()) { physReg = it->second; } else { physReg = getFreeTempPhysReg(virtReg); - loadVirt2PhysReg(virtReg, physReg); + it = loadVirt2PhysReg(virtReg, physReg); // we will clear uses that are not also defs // before we allocate registers the defs if (op.isDef()) - toSpill.push_back(virtReg); + toSpill.push_back(it); else - toClear.push_back(virtReg); + toClear.push_back(it); } (*currentInstr_)->SetMachineOperandReg(i, physReg); } @@ -504,16 +506,16 @@ assert(!op.isUse() && "we should not have uses here!"); unsigned virtReg = op.getAllocatedRegNum(); unsigned physReg = 0; - Virt2PhysMap::const_iterator it = v2pMap_.find(virtReg); + Virt2PhysMap::iterator it = v2pMap_.find(virtReg); if (it != v2pMap_.end()) { physReg = it->second; } else { physReg = getFreeTempPhysReg(virtReg); - assignVirt2PhysReg(virtReg, physReg); + it = assignVirt2PhysReg(virtReg, physReg); // need to spill this after we are done with // this instruction - toSpill.push_back(virtReg); + toSpill.push_back(it); } (*currentInstr_)->SetMachineOperandReg(i, physReg); } @@ -774,17 +776,20 @@ return 0; } -void RA::assignVirt2PhysReg(unsigned virtReg, unsigned physReg) +RA::Virt2PhysMap::iterator +RA::assignVirt2PhysReg(unsigned virtReg, unsigned physReg) { - bool inserted = v2pMap_.insert(std::make_pair(virtReg, physReg)).second; + bool inserted; + Virt2PhysMap::iterator it; + tie(it, inserted) = v2pMap_.insert(std::make_pair(virtReg, physReg)); assert(inserted && "attempting to assign a virt->phys mapping to an " "already mapped register"); prt_.addPhysRegUse(physReg); + return it; } -void RA::clearVirtReg(unsigned virtReg) +void RA::clearVirtReg(Virt2PhysMap::iterator it) { - Virt2PhysMap::iterator it = v2pMap_.find(virtReg); assert(it != v2pMap_.end() && "attempting to clear a not allocated virtual register"); unsigned physReg = it->second; @@ -804,8 +809,9 @@ "attempt to assign stack slot to already assigned register?"); // if the virtual register was previously assigned clear the mapping // and free the virtual register - if (v2pMap_.count(virtReg)) { - clearVirtReg(virtReg); + Virt2PhysMap::iterator it = v2pMap_.find(virtReg); + if (it != v2pMap_.end()) { + clearVirtReg(it); } } @@ -817,19 +823,23 @@ return it->second; } -void RA::spillVirtReg(unsigned virtReg) +void RA::spillVirtReg(Virt2PhysMap::iterator it) { + assert(it != v2pMap_.end() && + "attempt to spill a not allocated virtual register"); + unsigned virtReg = it->first; DEBUG(std::cerr << "\t\t\tspilling register: " << virtReg); const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(virtReg); int frameIndex = getStackSlot(virtReg); DEBUG(std::cerr << " to stack slot #" << frameIndex << '\n'); ++numSpilled; instrAdded_ += mri_->storeRegToStackSlot(*currentMbb_, currentInstr_, - v2pMap_[virtReg], frameIndex, rc); - clearVirtReg(virtReg); + it->second, frameIndex, rc); + clearVirtReg(it); } -void RA::loadVirt2PhysReg(unsigned virtReg, unsigned physReg) +RA::Virt2PhysMap::iterator +RA::loadVirt2PhysReg(unsigned virtReg, unsigned physReg) { DEBUG(std::cerr << "\t\t\tloading register: " << virtReg); const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(virtReg); @@ -838,7 +848,7 @@ ++numReloaded; instrAdded_ += mri_->loadRegFromStackSlot(*currentMbb_, currentInstr_, physReg, frameIndex, rc); - assignVirt2PhysReg(virtReg, physReg); + return assignVirt2PhysReg(virtReg, physReg); } FunctionPass* llvm::createLinearScanRegisterAllocator() { From lattner at cs.uiuc.edu Thu Feb 5 21:20:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 5 21:20:02 2004 Subject: [llvm-commits] CVS: llvm/utils/TableGen/TableGen.cpp Message-ID: <200402060319.VAA18618@zion.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: TableGen.cpp updated: 1.23 -> 1.24 --- Log message: Print the record NAME not the record ADDRESS --- Diffs of the changes: (+1 -1) Index: llvm/utils/TableGen/TableGen.cpp diff -u llvm/utils/TableGen/TableGen.cpp:1.23 llvm/utils/TableGen/TableGen.cpp:1.24 --- llvm/utils/TableGen/TableGen.cpp:1.23 Tue Nov 11 16:41:34 2003 +++ llvm/utils/TableGen/TableGen.cpp Thu Feb 5 21:19:17 2004 @@ -467,7 +467,7 @@ { std::vector Recs = Records.getAllDerivedDefinitions(Class); for (unsigned i = 0, e = Recs.size(); i != e; ++i) - *Out << Recs[i] << ", "; + *Out << Recs[i]->getName() << ", "; *Out << "\n"; break; } From lattner at cs.uiuc.edu Thu Feb 5 23:44:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 5 23:44:00 2004 Subject: [llvm-commits] CVS: llvm/docs/TableGenFundamentals.html index.html Message-ID: <200402060543.XAA19454@zion.cs.uiuc.edu> Changes in directory llvm/docs: TableGenFundamentals.html added (r1.1) index.html updated: 1.6 -> 1.7 --- Log message: Add a new document describing TableGen --- Diffs of the changes: (+569 -0) Index: llvm/docs/TableGenFundamentals.html diff -c /dev/null llvm/docs/TableGenFundamentals.html:1.1 *** /dev/null Thu Feb 5 23:43:03 2004 --- llvm/docs/TableGenFundamentals.html Thu Feb 5 23:42:53 2004 *************** *** 0 **** --- 1,562 ---- + + + + TableGen Fundamentals + + + + +
    TableGen Fundamentals
    + + + + + + + +
    + +

    TableGen's purpose is to help a human develop and maintain records of + domain-specific information. Because there may be a large number of these + records, it is specifically designed to allow writing flexible descriptions and + for common features of these records to be factored out. This reduces the + amount of duplication in the description, reduces the chance of error, and + makes it easier to structure domain specific information.

    + +

    The core part of TableGen parses a file, instantiates + the declarations, and hands the result off to a domain-specific "TableGen backend" for processing. The current major user + of TableGen is the LLVM code generator. +

    + +
    + + + + +
    + +

    + TableGen files consist of two key parts: 'classes' and 'definitions', both of + which are considered 'records'. +

    + +

    + TableGen records have a unique name, a list of values, and a list of + superclasses. The list of values is main data that TableGen builds for each + record, it is this that holds the domain specific information for the + application. The interpretation of this data is left to a specific TableGen backend, but the structure and format rules are + taken care of and fixed by TableGen. +

    + +

    + TableGen definitions are the concrete form of 'records'. These generally + do not have any undefined values, and are marked with the 'def' + keyword. +

    + +

    + TableGen classes are abstract records that are used to build and describe + other records. These 'classes' allow the end-user to build abstractions for + either the domain they are targetting (such as "Register", "RegisterClass", and + "Instruction" in the LLVM code generator) or for the implementor to help factor + out common properties of records (such as "FPInst", which is used to represent + floating point instructions in the X86 backend). TableGen keeps track of all of + the classes that are used to build up a definition, so the backend can find all + definitions of a particular class, such as "Instruction". +

    + +
    + + + + +
    + +

    + With no other arguments, TableGen parses the specified file and prints out all + of the classes, then all of the definitions. This is a good way to see what the + various definitions expand to fully. Running this on the X86.td file + prints this (at the time of this writing): +

    + +

    +

    + ...
    + def ADDrr8 {    // Instruction X86Inst I2A8 Pattern
    +   string Name = "add";
    +   string Namespace = "X86";
    +   list<Register> Uses = [];
    +   list<Register> Defs = [];
    +   bit isReturn = 0;
    +   bit isBranch = 0;
    +   bit isCall = 0;
    +   bit isTwoAddress = 1;
    +   bit isTerminator = 0;
    +   dag Pattern = (set R8, (plus R8, R8));
    +   bits<8> Opcode = { 0, 0, 0, 0, 0, 0, 0, 0 };
    +   Format Form = MRMDestReg;
    +   bits<5> FormBits = { 0, 0, 0, 1, 1 };
    +   ArgType Type = Arg8;
    +   bits<3> TypeBits = { 0, 0, 1 };
    +   bit hasOpSizePrefix = 0;
    +   bit printImplicitUses = 0;
    +   bits<4> Prefix = { 0, 0, 0, 0 };
    +   FPFormat FPForm = ?;
    +   bits<3> FPFormBits = { 0, 0, 0 };
    + }
    + ...
    + 

    + +

    + This definition corresponds to an 8-bit register-register add instruction in the + X86. The string after the 'def' string indicates the name of the + record ("ADDrr8" in this case), and the comment at the end of the line + indicates the superclasses of the definition. The body of the record contains + all of the data that TableGen assembled for the record, indicating that the + instruction is part of the "X86" namespace, should be printed as "add" + in the assembly file, it is a two-address instruction, has a particular + encoding, etc. The contents and semantics of the information in the record is + specific to the needs of the X86 backend, and is only shown as an example. +

    + +

    + As you can see, a lot of information is needed for every instruction supported + by the code generator, and specifying it all manually would be unmaintainble, + prone to bugs, and tiring to do in the first place. Because we are using + TableGen, all of the information was derived from the following definition: +

    + +

    + def ADDrr8   : I2A8<"add", 0x00, MRMDestReg>,
    +                Pattern<(set R8, (plus R8, R8))>;
    + 

    + +

    + This definition makes use of the custom I2A8 (two address instruction with 8-bit + operand) class, which is defined in the X86-specific TableGen file to factor out + the common features that instructions of its class share. A key feature of + TableGen is that it allows the end-user to define the abstractions they prefer + to use when describing their information. +

    + +
    + + + + +
    + +

    + TableGen runs just like any other LLVM tool. The first (optional) argument + specifies the file to read. If a filename is not specified, tblgen + reads from standard input. +

    + +

    + To be useful, one of the TableGen backends must be used. + These backends are selectable on the command line (type 'tblgen --help' + for a list). For example, to get a list of all of the definitions that subclass + a particular type (which can be useful for building up an enum list of these + records), use the --print-enums option: +

    + +

    + $ tblgen X86.td -print-enums -class=Register
    + AH, AL, AX, BH, BL, BP, BX, CH, CL, CX, DH, DI, DL, DX,
    + EAX, EBP, EBX, ECX, EDI, EDX, ESI, ESP, FP0, FP1, FP2, FP3, FP4, FP5, FP6,
    + SI, SP, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, 
    + 
    + $ tblgen X86.td -print-enums -class=Instruction 
    + ADCrr32, ADDri16, ADDri16b, ADDri32, ADDri32b, ADDri8, ADDrr16, ADDrr32,
    + ADDrr8, ADJCALLSTACKDOWN, ADJCALLSTACKUP, ANDri16, ANDri16b, ANDri32, ANDri32b,
    + ANDri8, ANDrr16, ANDrr32, ANDrr8, BSWAPr32, CALLm32, CALLpcrel32, ...
    + 

    + +

    + The default backend prints out all of the records, as described above. +

    + +

    + If you plan to use TableGen for some purpose, you will most likely have to write a backend that extracts the information specific to + what you need and formats it in the appropriate way. +

    + +
    + + + + + + +
    + +

    + TableGen doesn't care about the meaning of data (that is up to the backend to + define), but it does care about syntax, and it enforces a simple type system. + This section describes the syntax and the constructs allowed in a TableGen file. +

    + +
    + + + + + + + +
    + +

    TableGen supports BCPL style "//" comments, which run to the end of + the line, and it also supports nestable "/* */" comments.

    + +
    + + + + + +
    +

    + TableGen files are strongly typed, in a simple (but complete) type-system. + These types are used to perform automatic conversions, check for errors, and to + help interface designers constrain the input that they allow. Every value definition is required to have an associated type. +

    + +

    + TableGen supports a mixture of very low-level types (such as bit) and + very high-level types (such as dag). This flexibility is what allows + it to describe a wide range of information conveniently and compactly. The + TableGen types are: +

    + +

    +

      +
    • "bit" - A 'bit' is a boolean value that can hold either 0 or + 1.
    • + +
    • "int" - The 'int' type represents a simple 32-bit integer value, such as 5.
    • + +
    • "string" - The 'string' type represents an ordered sequence of + characters of arbitrary length.
    • + +
    • "bits<n>" - A 'bits' type is a arbitrary, but fixed, size + integer that is broken up into individual bits. This type is useful because it + can handle some bits being defined while others are undefined.
    • + +
    • "list<ty>" - This type represents a list whose elements are + some other type. The contained type is arbitrary: it can even be another list + type.
    • + +
    • Class type - Specifying a class name in a type context means that the + defined value must be a subclass of the specified class. This is useful in + conjunction with the "list" type, for example, to constrain the elements of the + list to a common base class (e.g., a list<Register> can only + contain definitions derived from the "Register" class).
    • + +
    • "code" - This represents a big hunk of text. NOTE: I don't + remember why this is distinct from string!
    • + +
    • "dag" - This type represents a nestable directed graph of + elements.
    • +
    +

    + +

    + To date, these types have been sufficient for describing things that TableGen + has been used for, but it is straight-forward to extend this list if needed. +

    + +
    + + + + +
    +

    + TableGen allows for a pretty reasonable number of different expression forms + when building up values. These forms allow the TableGen file to be written in a + natural syntax and flavor for the application. The current expression forms + supported include: +

    + +

      +
    • ? - Uninitialized field.
    • +
    • 0b1001011 - Binary integer value.
    • +
    • 07654321 - Octal integer value (indicated by a leading 0).
    • +
    • 7 - Decimal integer value.
    • +
    • 0x7F - Hexadecimal integer value.
    • +
    • "foo" - String value.
    • +
    • [{ .... }] - Code fragment.
    • +
    • [ X, Y, Z ] - List value.
    • +
    • { a, b, c } - Initializer for a "bits<3>" value.
    • +
    • value - Value reference.
    • +
    • value{17} - Access to one or more bits of a value.
    • +
    • DEF - Reference to a record definition.
    • +
    • X.Y - Reference to the subfield of a value.
    • + +
    • (DEF a, b) - A dag value. The first element is required to be a record + definition, the remaining elements in the list may be arbitrary other values, + including nested 'dag' values.
    • + +

    + +

    + Note that all of the values have rules specifying how they convert to to values + for different types. These rules allow you to assign a value like "7" to a + "bits<4>" value, for example. +

    + + + +
    + + + + + +
    +

    + As mentioned in the intro, classes and definitions + (collectively known as 'records') in TableGen are the main high-level unit of + information that TableGen collects. Records are defined with a def or + class keyword, the record name, and an optional list of "template arguments". If the record has superclasses, + they are specified as a comma seperated list that starts with a colon character + (":"). If value definitions or let + expressions are needed for the class they are enclosed in curly braces + ("{}"), otherwise the record ends with a semicolon. Here is a simple TableGen + file: +

    + +

    + class C { bit V = 1; }
    + def X : C;
    + def Y : C {
    +   string Greeting = "hello";
    + }
    + 

    + +

    + This example defines two definitions, X and Y, both of which + derive from the C class. Because of this, they both get the V + bit value. The Y definition also gets the Greeting member as well. +

    + +
    + + + + +
    +

    + Value definitions define named entries in records. A value must be defined + before it can be referred to as the operand for another value definition, or + before the value is reset with a let expression. A + value is defined by specifying a TableGen type and a name. + If an initial value is available, it may be specified after the type with an + equal sign. Value definitions require terminating semicolons. +

    + + + + +
    +

    + A record-level let expression is used to change the value of a value definition + in a record. This is primarily useful when a superclass defines a value that a + derived class or definitions wants to override. Let expressions consist of the + 'let' keyword, followed by a value name, an equal sign ("="), and a new + value for example, a new class could be added to the example above, redefining + the V field for all of its subclasses:

    + +

    + class D : C { let V = 0; }
    + def Z : D;
    + 

    + +

    + In this case, the Z definition will have a zero value for its "V" + value, despite the fact that it derives (indirectly) from the C class, + because the D class overrode its value. +

    + +
    + + + + +
    + and default values... +
    + + + + + + + + + +
    +

    + TableGen supports the 'include' token, which textually substitutes the + specified file in place of the include directive. The filename should be + specified as a double quoted string immediately after the 'include' + keyword. Example: + +

    +   include "foo.td"
    + 

    + +
    + + + + +
    +

    + "let" expressions at file scope are similar to "let" + expressions within a record, except they can specify a value binding for + multiple records at a time, and may be useful in certain other cases. + File-scope let expressions are really just another way that TableGen allows the + end-user to factor out commonality from the records. +

    + +

    + File-scope "let" expressions take a comma-seperated list of bindings to apply, + and one of more records to bind the values in. Here are some examples: +

    + +

    + let isTerminator = 1, isReturn = 1 in
    +   def RET : X86Inst<"ret", 0xC3, RawFrm, NoArg>;
    + 
    + let isCall = 1 in
    +   // All calls clobber the non-callee saved registers...
    +   let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6] in {
    +     def CALLpcrel32 : X86Inst<"call", 0xE8, RawFrm, NoArg>;
    +     def CALLr32     : X86Inst<"call", 0xFF, MRMS2r, Arg32>;
    +     def CALLm32     : X86Inst<"call", 0xFF, MRMS2m, Arg32>;
    +   }
    + 

    + +

    + File-scope "let" expressions are often useful when a couple of definitions need + to be added to several records, and the records do not otherwise need to be + opened, as in the case with the CALL* instructions above. +

    +
    + + + + + + +
    + +

    + How they work, how to write one. This section should not contain details about + any particular backend, except maybe -print-enums as an example. This should + highlight the APIs in TableGen/Record.h. +

    + +
    + + + + + + +
    + +

    + This is just a temporary, convenient, place to put stuff about the code + generator before it gets its own document. This should describe all of the + tablegen backends used by the code generator and the classes/definitions they + expect. +

    + +
    + + + + +
    + + + + Index: llvm/docs/index.html diff -u llvm/docs/index.html:1.6 llvm/docs/index.html:1.7 --- llvm/docs/index.html:1.6 Mon Nov 24 21:32:57 2003 +++ llvm/docs/index.html Thu Feb 5 23:42:53 2004 @@ -183,6 +183,13 @@

    + TableGen Fundamentals: +
    + llvm/docs/TableGenFundamentals.html +

    + + +

    The Stacker Cronicles
    The Stacker Cronicles From lattner at cs.uiuc.edu Thu Feb 5 23:45:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 5 23:45:01 2004 Subject: [llvm-commits] CVS: llvm-www/Documentation.html Message-ID: <200402060544.XAA19826@zion.cs.uiuc.edu> Changes in directory llvm-www: Documentation.html updated: 1.3 -> 1.4 --- Log message: Add link --- Diffs of the changes: (+4 -0) Index: llvm-www/Documentation.html diff -u llvm-www/Documentation.html:1.3 llvm-www/Documentation.html:1.4 --- llvm-www/Documentation.html:1.3 Mon Dec 15 16:23:41 2003 +++ llvm-www/Documentation.html Thu Feb 5 23:44:04 2004 @@ -56,6 +56,10 @@ on how to write a new alias analysis implementation or how to use existing analyses. +
  • TableGen Fundamentals - +Describes the TableGen tool, which is used heavily by the LLVM code +generator.
  • +
  • CommandLine library Reference Manual - Provides information on using the command line parsing library.
  • From lattner at cs.uiuc.edu Fri Feb 6 00:05:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 6 00:05:01 2004 Subject: [llvm-commits] CVS: llvm/docs/TableGenFundamentals.html Message-ID: <200402060604.AAA20273@zion.cs.uiuc.edu> Changes in directory llvm/docs: TableGenFundamentals.html updated: 1.1 -> 1.2 --- Log message: Syntax hilight examples and add note about emacs/vim mode files --- Diffs of the changes: (+59 -52) Index: llvm/docs/TableGenFundamentals.html diff -u llvm/docs/TableGenFundamentals.html:1.1 llvm/docs/TableGenFundamentals.html:1.2 --- llvm/docs/TableGenFundamentals.html:1.1 Thu Feb 5 23:42:53 2004 +++ llvm/docs/TableGenFundamentals.html Fri Feb 6 00:04:25 2004 @@ -38,11 +38,11 @@
  • TableGen backends
    1. -
    2. x
    3. +
    4. todo
  • The LLVM code generator
    1. -
    2. x
    3. +
    4. todo
    @@ -65,6 +65,12 @@ of TableGen is the LLVM code generator.

    +

    +Note that if you work on TableGen much, and use emacs or vim, that you can find +an emacs "TableGen mode" and a vim language file in llvm/utils/emacs +and llvm/utils/vim directory of your LLVM distribution, respectively. +

    + @@ -124,27 +130,27 @@

     ...
    -def ADDrr8 {    // Instruction X86Inst I2A8 Pattern
    -  string Name = "add";
    -  string Namespace = "X86";
    -  list<Register> Uses = [];
    -  list<Register> Defs = [];
    -  bit isReturn = 0;
    -  bit isBranch = 0;
    -  bit isCall = 0;
    -  bit isTwoAddress = 1;
    -  bit isTerminator = 0;
    -  dag Pattern = (set R8, (plus R8, R8));
    -  bits<8> Opcode = { 0, 0, 0, 0, 0, 0, 0, 0 };
    +def ADDrr8 {    // Instruction X86Inst I2A8 Pattern
    +  string Name = "add";
    +  string Namespace = "X86";
    +  list<Register> Uses = [];
    +  list<Register> Defs = [];
    +  bit isReturn = 0;
    +  bit isBranch = 0;
    +  bit isCall = 0;
    +  bit isTwoAddress = 1;
    +  bit isTerminator = 0;
    +  dag Pattern = (set R8, (plus R8, R8));
    +  bits<8> Opcode = { 0, 0, 0, 0, 0, 0, 0, 0 };
       Format Form = MRMDestReg;
    -  bits<5> FormBits = { 0, 0, 0, 1, 1 };
    +  bits<5> FormBits = { 0, 0, 0, 1, 1 };
       ArgType Type = Arg8;
    -  bits<3> TypeBits = { 0, 0, 1 };
    -  bit hasOpSizePrefix = 0;
    -  bit printImplicitUses = 0;
    -  bits<4> Prefix = { 0, 0, 0, 0 };
    +  bits<3> TypeBits = { 0, 0, 1 };
    +  bit hasOpSizePrefix = 0;
    +  bit printImplicitUses = 0;
    +  bits<4> Prefix = { 0, 0, 0, 0 };
       FPFormat FPForm = ?;
    -  bits<3> FPFormBits = { 0, 0, 0 };
    +  bits<3> FPFormBits = { 0, 0, 0 };
     }
     ...
     

    @@ -169,7 +175,7 @@

    -def ADDrr8   : I2A8<"add", 0x00, MRMDestReg>,
    +def ADDrr8   : I2A8<"add", 0x00, MRMDestReg>,
                    Pattern<(set R8, (plus R8, R8))>;
     

    @@ -284,32 +290,33 @@

      -
    • "bit" - A 'bit' is a boolean value that can hold either 0 or +
    • "bit" - A 'bit' is a boolean value that can hold either 0 or 1.
    • -
    • "int" - The 'int' type represents a simple 32-bit integer value, such as 5.
    • +
    • "int" - The 'int' type represents a simple 32-bit integer +value, such as 5.
    • -
    • "string" - The 'string' type represents an ordered sequence of -characters of arbitrary length.
    • +
    • "string" - The 'string' type represents an ordered sequence +of characters of arbitrary length.
    • -
    • "bits<n>" - A 'bits' type is a arbitrary, but fixed, size -integer that is broken up into individual bits. This type is useful because it -can handle some bits being defined while others are undefined.
    • - -
    • "list<ty>" - This type represents a list whose elements are -some other type. The contained type is arbitrary: it can even be another list -type.
    • +
    • "bits<n>" - A 'bits' type is a arbitrary, but fixed, +size integer that is broken up into individual bits. This type is useful +because it can handle some bits being defined while others are undefined.
    • + +
    • "list<ty>" - This type represents a list whose +elements are some other type. The contained type is arbitrary: it can even be +another list type.
    • Class type - Specifying a class name in a type context means that the defined value must be a subclass of the specified class. This is useful in conjunction with the "list" type, for example, to constrain the elements of the -list to a common base class (e.g., a list<Register> can only -contain definitions derived from the "Register" class).
    • +list to a common base class (e.g., a list<Register> can +only contain definitions derived from the "Register" class). -
    • "code" - This represents a big hunk of text. NOTE: I don't +
    • "code" - This represents a big hunk of text. NOTE: I don't remember why this is distinct from string!
    • -
    • "dag" - This type represents a nestable directed graph of +
    • "dag" - This type represents a nestable directed graph of elements.

    @@ -386,10 +393,10 @@

    -class C { bit V = 1; }
    -def X : C;
    -def Y : C {
    -  string Greeting = "hello";
    +class C { bit V = 1; }
    +def X : C;
    +def Y : C {
    +  string Greeting = "hello";
     }
     

    @@ -431,8 +438,8 @@ the V field for all of its subclasses:

    -class D : C { let V = 0; }
    -def Z : D;
    +class D : C { let V = 0; }
    +def Z : D;
     

    @@ -472,7 +479,7 @@ keyword. Example:

    -  include "foo.td"
    +  include "foo.td"
     

    @@ -497,15 +504,15 @@

    -let isTerminator = 1, isReturn = 1 in
    -  def RET : X86Inst<"ret", 0xC3, RawFrm, NoArg>;
    +let isTerminator = 1, isReturn = 1 in
    +  def RET : X86Inst<"ret", 0xC3, RawFrm, NoArg>;
     
    -let isCall = 1 in
    -  // All calls clobber the non-callee saved registers...
    -  let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6] in {
    -    def CALLpcrel32 : X86Inst<"call", 0xE8, RawFrm, NoArg>;
    -    def CALLr32     : X86Inst<"call", 0xFF, MRMS2r, Arg32>;
    -    def CALLm32     : X86Inst<"call", 0xFF, MRMS2m, Arg32>;
    +let isCall = 1 in
    +  // All calls clobber the non-callee saved registers...
    +  let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6] in {
    +    def CALLpcrel32 : X86Inst<"call", 0xE8, RawFrm, NoArg>;
    +    def CALLr32     : X86Inst<"call", 0xFF, MRMS2r, Arg32>;
    +    def CALLm32     : X86Inst<"call", 0xFF, MRMS2m, Arg32>;
       }
     

    @@ -555,7 +562,7 @@
    Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/06 05:42:53 $ + Last modified: $Date: 2004/02/06 06:04:25 $ From lattner at cs.uiuc.edu Fri Feb 6 00:38:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 6 00:38:05 2004 Subject: [llvm-commits] CVS: llvm/docs/TableGenFundamentals.html Message-ID: <200402060637.AAA20732@zion.cs.uiuc.edu> Changes in directory llvm/docs: TableGenFundamentals.html updated: 1.2 -> 1.3 --- Log message: Add information about the piece I forgot to write: parameterized tablegen classes --- Diffs of the changes: (+87 -3) Index: llvm/docs/TableGenFundamentals.html diff -u llvm/docs/TableGenFundamentals.html:1.2 llvm/docs/TableGenFundamentals.html:1.3 --- llvm/docs/TableGenFundamentals.html:1.2 Fri Feb 6 00:04:25 2004 +++ llvm/docs/TableGenFundamentals.html Fri Feb 6 00:37:00 2004 @@ -406,6 +406,13 @@ bit value. The Y definition also gets the Greeting member as well.

    +

    +In general, classes are useful for collecting together the commonality between a +group of records, and isolating it in a single places. Also, classes permit the +specification of default values for their subclasses, allowing the subclasses to +override them as they wish. +

    + @@ -456,7 +463,84 @@
    -and default values... +

    +TableGen permits the definition of parameterized classes as well as normal +concrete classes. Parameterized TableGen classes specify a list of variable +bindings (which may optionally have defaults) that are bound when used. Here is +a simple example:

    + +

    +class FPFormat<bits<3> val> {
    +  bits<3> Value = val;
    +}
    +def NotFP      : FPFormat<0>;
    +def ZeroArgFP  : FPFormat<1>;
    +def OneArgFP   : FPFormat<2>;
    +def OneArgFPRW : FPFormat<3>;
    +def TwoArgFP   : FPFormat<4>;
    +def SpecialFP  : FPFormat<5>;
    +

    + +

    +In this case, template arguments are used as a space efficient way to specify a +list of "enumeration values", each with a "Value" field set to the specified +integer.

    + +

    The more esoteric forms of TableGen expressions are +useful in conjunction with template arguments. As an example:

    + +

    +class ModRefVal<bits<2> val> {
    +  bits<2> Value = val;
    +}
    +
    +def None   : ModRefVal<0>;
    +def Mod    : ModRefVal<1>;
    +def Ref    : ModRefVal<2>;
    +def ModRef : ModRefVal<3>;
    +
    +class Value<ModRefVal MR> {
    +  // decode some information into a more convenient format, while providing
    +  // a nice interface to the user of the "Value" class.
    +  bit isMod = MR.Value{0};
    +  bit isRef = MR.Value{1};
    +
    +  // other stuff...
    +}
    +
    +// Example uses
    +def bork : Value<Mod>;
    +def zork : Value<Ref>;
    +def hork : Value<ModRef>;
    +

    + +

    +This is obviously a contrived example, but it shows how template arguments can +be used to decouple the interface provided to the user of the class from the +actual internal data representation expected by the class. In this case, +running tblgen on the example prints the following definitions:

    + +

    +def bork {      // Value
    +  bit isMod = 1;
    +  bit isRef = 0;
    +}
    +def hork {      // Value
    +  bit isMod = 1;
    +  bit isRef = 1;
    +}
    +def zork {      // Value
    +  bit isMod = 0;
    +  bit isRef = 1;
    +}
    +

    + +

    +This shows that TableGen was able to dig into the argument and extract a piece +of information that was requested by the designer of the "Value" class. For +more realistic examples, please see existing users of TableGen, such as the X86 +backend.

    +
    @@ -479,7 +563,7 @@ keyword. Example:

    -  include "foo.td"
    +include "foo.td"
     

    @@ -562,7 +646,7 @@
    Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/06 06:04:25 $ + Last modified: $Date: 2004/02/06 06:37:00 $ From criswell at cs.uiuc.edu Fri Feb 6 10:36:03 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:36:03 2004 Subject: [llvm-commits] CVS: llvm/runtime/libpng/ Message-ID: <200402061635.KAA15004@choi.cs.uiuc.edu> Changes in directory llvm/runtime/libpng: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/runtime/libpng added to the repository --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Fri Feb 6 10:36:20 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:36:20 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/ Message-ID: <200402061635.KAA15003@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/runtime/zlib added to the repository --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Fri Feb 6 10:37:01 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:37:01 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/old/Make_vms.com Makefile.riscos README descrip.mms zlib.html Message-ID: <200402061636.KAA15711@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/old: Make_vms.com added (r1.1) Makefile.riscos added (r1.1) README added (r1.1) descrip.mms added (r1.1) zlib.html added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+1288 -0) Index: llvm/runtime/zlib/old/Make_vms.com diff -c /dev/null llvm/runtime/zlib/old/Make_vms.com:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/old/Make_vms.com Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,115 ---- + $! make libz under VMS + $! written by Martin P.J. Zinser + $! + $! Look for the compiler used + $! + $ ccopt = "" + $ if f$getsyi("HW_MODEL").ge.1024 + $ then + $ ccopt = "/prefix=all"+ccopt + $ comp = "__decc__=1" + $ if f$trnlnm("SYS").eqs."" then define sys sys$library: + $ else + $ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" + $ then + $ comp = "__vaxc__=1" + $ if f$trnlnm("SYS").eqs."" then define sys sys$library: + $ else + $ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: + $ ccopt = "/decc/prefix=all"+ccopt + $ comp = "__decc__=1" + $ endif + $ endif + $! + $! Build the thing plain or with mms + $! + $ write sys$output "Compiling Zlib sources ..." + $ if f$search("SYS$SYSTEM:MMS.EXE").eqs."" + $ then + $ dele example.obj;*,minigzip.obj;* + $ CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" - + adler32.c zlib.h zconf.h + $ CALL MAKE compress.OBJ "CC ''CCOPT' compress" - + compress.c zlib.h zconf.h + $ CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" - + crc32.c zlib.h zconf.h + $ CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" - + deflate.c deflate.h zutil.h zlib.h zconf.h + $ CALL MAKE gzio.OBJ "CC ''CCOPT' gzio" - + gzio.c zutil.h zlib.h zconf.h + $ CALL MAKE infblock.OBJ "CC ''CCOPT' infblock" - + infblock.c zutil.h zlib.h zconf.h infblock.h + $ CALL MAKE infcodes.OBJ "CC ''CCOPT' infcodes" - + infcodes.c zutil.h zlib.h zconf.h inftrees.h + $ CALL MAKE inffast.OBJ "CC ''CCOPT' inffast" - + inffast.c zutil.h zlib.h zconf.h inffast.h + $ CALL MAKE inflate.OBJ "CC ''CCOPT' inflate" - + inflate.c zutil.h zlib.h zconf.h infblock.h + $ CALL MAKE inftrees.OBJ "CC ''CCOPT' inftrees" - + inftrees.c zutil.h zlib.h zconf.h inftrees.h + $ CALL MAKE infutil.OBJ "CC ''CCOPT' infutil" - + infutil.c zutil.h zlib.h zconf.h inftrees.h infutil.h + $ CALL MAKE trees.OBJ "CC ''CCOPT' trees" - + trees.c deflate.h zutil.h zlib.h zconf.h + $ CALL MAKE uncompr.OBJ "CC ''CCOPT' uncompr" - + uncompr.c zlib.h zconf.h + $ CALL MAKE zutil.OBJ "CC ''CCOPT' zutil" - + zutil.c zutil.h zlib.h zconf.h + $ write sys$output "Building Zlib ..." + $ CALL MAKE libz.OLB "lib/crea libz.olb *.obj" *.OBJ + $ write sys$output "Building example..." + $ CALL MAKE example.OBJ "CC ''CCOPT' example" - + example.c zlib.h zconf.h + $ call make example.exe "LINK example,libz.olb/lib" example.obj libz.olb + $ write sys$output "Building minigzip..." + $ CALL MAKE minigzip.OBJ "CC ''CCOPT' minigzip" - + minigzip.c zlib.h zconf.h + $ call make minigzip.exe - + "LINK minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib" - + minigzip.obj libz.olb + $ else + $ mms/macro=('comp') + $ endif + $ write sys$output "Zlib build completed" + $ exit + $! + $! + $MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES + $ V = 'F$Verify(0) + $! P1 = What we are trying to make + $! P2 = Command to make it + $! P3 - P8 What it depends on + $ + $ If F$Search(P1) .Eqs. "" Then Goto Makeit + $ Time = F$CvTime(F$File(P1,"RDT")) + $arg=3 + $Loop: + $ Argument = P'arg + $ If Argument .Eqs. "" Then Goto Exit + $ El=0 + $Loop2: + $ File = F$Element(El," ",Argument) + $ If File .Eqs. " " Then Goto Endl + $ AFile = "" + $Loop3: + $ OFile = AFile + $ AFile = F$Search(File) + $ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl + $ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit + $ Goto Loop3 + $NextEL: + $ El = El + 1 + $ Goto Loop2 + $EndL: + $ arg=arg+1 + $ If arg .Le. 8 Then Goto Loop + $ Goto Exit + $ + $Makeit: + $ VV=F$VERIFY(0) + $ write sys$output P2 + $ 'P2 + $ VV='F$Verify(VV) + $Exit: + $ If V Then Set Verify + $ENDSUBROUTINE Index: llvm/runtime/zlib/old/Makefile.riscos diff -c /dev/null llvm/runtime/zlib/old/Makefile.riscos:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/old/Makefile.riscos Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,151 ---- + # Project: zlib_1_03 + # Patched for zlib 1.1.2 rw at shadow.org.uk 19980430 + # test works out-of-the-box, installs `somewhere' on demand + + # Toolflags: + CCflags = -c -depend !Depend -IC: -g -throwback -DRISCOS -fah + C++flags = -c -depend !Depend -IC: -throwback + Linkflags = -aif -c++ -o $@ + ObjAsmflags = -throwback -NoCache -depend !Depend + CMHGflags = + LibFileflags = -c -l -o $@ + Squeezeflags = -o $@ + + # change the line below to where _you_ want the library installed. + libdest = lib:zlib + + # Final targets: + @.lib: @.o.adler32 @.o.compress @.o.crc32 @.o.deflate @.o.gzio \ + @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil @.o.trees \ + @.o.uncompr @.o.zutil + LibFile $(LibFileflags) @.o.adler32 @.o.compress @.o.crc32 @.o.deflate \ + @.o.gzio @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil \ + @.o.trees @.o.uncompr @.o.zutil + test: @.minigzip @.example @.lib + @copy @.lib @.libc A~C~DF~L~N~P~Q~RS~TV + @echo running tests: hang on. + @/@.minigzip -f -9 libc + @/@.minigzip -d libc-gz + @/@.minigzip -f -1 libc + @/@.minigzip -d libc-gz + @/@.minigzip -h -9 libc + @/@.minigzip -d libc-gz + @/@.minigzip -h -1 libc + @/@.minigzip -d libc-gz + @/@.minigzip -9 libc + @/@.minigzip -d libc-gz + @/@.minigzip -1 libc + @/@.minigzip -d libc-gz + @diff @.lib @.libc + @echo that should have reported '@.lib and @.libc identical' if you have diff. + @/@.example @.fred @.fred + @echo that will have given lots of hello!'s. + + @.minigzip: @.o.minigzip @.lib C:o.Stubs + Link $(Linkflags) @.o.minigzip @.lib C:o.Stubs + @.example: @.o.example @.lib C:o.Stubs + Link $(Linkflags) @.o.example @.lib C:o.Stubs + + install: @.lib + cdir $(libdest) + cdir $(libdest).h + @copy @.h.zlib $(libdest).h.zlib A~C~DF~L~N~P~Q~RS~TV + @copy @.h.zconf $(libdest).h.zconf A~C~DF~L~N~P~Q~RS~TV + @copy @.lib $(libdest).lib A~C~DF~L~N~P~Q~RS~TV + @echo okay, installed zlib in $(libdest) + + clean:; remove @.minigzip + remove @.example + remove @.libc + -wipe @.o.* F~r~cV + remove @.fred + + # User-editable dependencies: + .c.o: + cc $(ccflags) -o $@ $< + + # Static dependencies: + + # Dynamic dependencies: + o.example: c.example + o.example: h.zlib + o.example: h.zconf + o.minigzip: c.minigzip + o.minigzip: h.zlib + o.minigzip: h.zconf + o.adler32: c.adler32 + o.adler32: h.zlib + o.adler32: h.zconf + o.compress: c.compress + o.compress: h.zlib + o.compress: h.zconf + o.crc32: c.crc32 + o.crc32: h.zlib + o.crc32: h.zconf + o.deflate: c.deflate + o.deflate: h.deflate + o.deflate: h.zutil + o.deflate: h.zlib + o.deflate: h.zconf + o.gzio: c.gzio + o.gzio: h.zutil + o.gzio: h.zlib + o.gzio: h.zconf + o.infblock: c.infblock + o.infblock: h.zutil + o.infblock: h.zlib + o.infblock: h.zconf + o.infblock: h.infblock + o.infblock: h.inftrees + o.infblock: h.infcodes + o.infblock: h.infutil + o.infcodes: c.infcodes + o.infcodes: h.zutil + o.infcodes: h.zlib + o.infcodes: h.zconf + o.infcodes: h.inftrees + o.infcodes: h.infblock + o.infcodes: h.infcodes + o.infcodes: h.infutil + o.infcodes: h.inffast + o.inffast: c.inffast + o.inffast: h.zutil + o.inffast: h.zlib + o.inffast: h.zconf + o.inffast: h.inftrees + o.inffast: h.infblock + o.inffast: h.infcodes + o.inffast: h.infutil + o.inffast: h.inffast + o.inflate: c.inflate + o.inflate: h.zutil + o.inflate: h.zlib + o.inflate: h.zconf + o.inflate: h.infblock + o.inftrees: c.inftrees + o.inftrees: h.zutil + o.inftrees: h.zlib + o.inftrees: h.zconf + o.inftrees: h.inftrees + o.inftrees: h.inffixed + o.infutil: c.infutil + o.infutil: h.zutil + o.infutil: h.zlib + o.infutil: h.zconf + o.infutil: h.infblock + o.infutil: h.inftrees + o.infutil: h.infcodes + o.infutil: h.infutil + o.trees: c.trees + o.trees: h.deflate + o.trees: h.zutil + o.trees: h.zlib + o.trees: h.zconf + o.trees: h.trees + o.uncompr: c.uncompr + o.uncompr: h.zlib + o.uncompr: h.zconf + o.zutil: c.zutil + o.zutil: h.zutil + o.zutil: h.zlib + o.zutil: h.zconf Index: llvm/runtime/zlib/old/README diff -c /dev/null llvm/runtime/zlib/old/README:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/old/README Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,3 ---- + This directory contains files that have not been updated for zlib 1.2.1 + + (Volunteers are encouraged to help clean this up. Thanks.) Index: llvm/runtime/zlib/old/descrip.mms diff -c /dev/null llvm/runtime/zlib/old/descrip.mms:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/old/descrip.mms Fri Feb 6 10:36:42 2004 *************** *** 0 **** --- 1,48 ---- + # descrip.mms: MMS description file for building zlib on VMS + # written by Martin P.J. Zinser + + cc_defs = + c_deb = + + .ifdef __DECC__ + pref = /prefix=all + .endif + + OBJS = adler32.obj, compress.obj, crc32.obj, gzio.obj, uncompr.obj,\ + deflate.obj, trees.obj, zutil.obj, inflate.obj, infblock.obj,\ + inftrees.obj, infcodes.obj, infutil.obj, inffast.obj + + CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF) + + all : example.exe minigzip.exe + @ write sys$output " Example applications available" + libz.olb : libz.olb($(OBJS)) + @ write sys$output " libz available" + + example.exe : example.obj libz.olb + link example,libz.olb/lib + + minigzip.exe : minigzip.obj libz.olb + link minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib + + clean : + delete *.obj;*,libz.olb;* + + + # Other dependencies. + adler32.obj : zutil.h zlib.h zconf.h + compress.obj : zlib.h zconf.h + crc32.obj : zutil.h zlib.h zconf.h + deflate.obj : deflate.h zutil.h zlib.h zconf.h + example.obj : zlib.h zconf.h + gzio.obj : zutil.h zlib.h zconf.h + infblock.obj : zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h + infcodes.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h infcodes.h inffast.h + inffast.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h + inflate.obj : zutil.h zlib.h zconf.h infblock.h + inftrees.obj : zutil.h zlib.h zconf.h inftrees.h + infutil.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h + minigzip.obj : zlib.h zconf.h + trees.obj : deflate.h zutil.h zlib.h zconf.h + uncompr.obj : zlib.h zconf.h + zutil.obj : zutil.h zlib.h zconf.h Index: llvm/runtime/zlib/old/zlib.html diff -c /dev/null llvm/runtime/zlib/old/zlib.html:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/old/zlib.html Fri Feb 6 10:36:42 2004 *************** *** 0 **** --- 1,971 ---- + + + + zlib general purpose compression library version 1.1.4 + + + + + +

    zlib 1.1.4 Manual

    +
    +

    Contents

    +
      +
    1. Prologue +
    2. Introduction +
    3. Utility functions +
    4. Basic functions +
    5. Advanced functions +
    6. Constants +
    7. struct z_stream_s +
    8. Checksum functions +
    9. Misc +
    +
    +

    Prologue

    + 'zlib' general purpose compression library version 1.1.4, March 11th, 2002 +

    + Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler +

    + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. +

    + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: +

      +
    1. The origin of this software must not be misrepresented ; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +
    2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +
    3. This notice may not be removed or altered from any source distribution. +
    + +
    +
    Jean-loup Gailly +
    jloup at gzip.org +
    Mark Adler +
    madler at alumni.caltech.edu +
    + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files + + ftp://ds.internic.net/rfc/rfc1950.txt + (zlib format), + + rfc1951.txt + (deflate format) and + + rfc1952.txt + (gzip format). +

    + This manual is converted from zlib.h by + piaip +

    + Visit + http://ftp.cdrom.com/pub/infozip/zlib/ + for the official zlib web page. +

    + +


    +

    Introduction

    + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. +

    + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. +

    + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio. +

    + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +

    + +


    +

    Utility functions

    + The following utility functions are implemented on top of the +
    basic stream-oriented functions. + To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +

    Function list

    +
      +
    • int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); +
    • int compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level); +
    • int uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); +
    • typedef voidp gzFile; +
    • gzFile gzopen (const char *path, const char *mode); +
    • gzFile gzdopen (int fd, const char *mode); +
    • int gzsetparams (gzFile file, int level, int strategy); +
    • int gzread (gzFile file, voidp buf, unsigned len); +
    • int gzwrite (gzFile file, const voidp buf, unsigned len); +
    • int VA gzprintf (gzFile file, const char *format, ...); +
    • int gzputs (gzFile file, const char *s); +
    • char * gzgets (gzFile file, char *buf, int len); +
    • int gzputc (gzFile file, int c); +
    • int gzgetc (gzFile file); +
    • int gzflush (gzFile file, int flush); +
    • z_off_t gzseek (gzFile file, z_off_t offset, int whence); +
    • z_off_t gztell (gzFile file); +
    • int gzrewind (gzFile file); +
    • int gzeof (gzFile file); +
    • int gzclose (gzFile file); +
    • const char * gzerror (gzFile file, int *errnum); +
    +

    Function description

    +
    +
    int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); +
    + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least 0.1% larger than + sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the + compressed buffer.

    + This function can be used to compress a whole file at once if the + input file is mmap'ed.

    + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer.

    + +

    int compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level); +
    + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. +

    + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +

    + +

    int uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); +
    + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer.

    + This function can be used to decompress a whole file at once if the + input file is mmap'ed. +

    + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +

    + +

    typedef voidp gzFile; +

    + +

    gzFile gzopen (const char *path, const char *mode); +
    + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h". (See the description + of deflateInit2 for more information about the strategy parameter.) +

    + + gzopen can be used to read a file which is not in gzip format ; in this + case gzread will directly read from the file without decompression. +

    + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state ; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). +

    + +

    gzFile gzdopen (int fd, const char *mode); +
    + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. +

    + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). +

    + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +

    + +

    int gzsetparams (gzFile file, int level, int strategy); +
    + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. +

    + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +

    + +

    int gzread (gzFile file, voidp buf, unsigned len); +
    + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. +

    + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). +

    + +

    int gzwrite (gzFile file, const voidp buf, unsigned len); +
    + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +

    + +

    int VA gzprintf (gzFile file, const char *format, ...); +
    + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). +

    + +

    int gzputs (gzFile file, const char *s); +
    + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. +

    + gzputs returns the number of characters written, or -1 in case of error. +

    + +

    char * gzgets (gzFile file, char *buf, int len); +
    + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. +

    + gzgets returns buf, or Z_NULL in case of error. +

    + +

    int gzputc (gzFile file, int c); +
    + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +

    + +

    int gzgetc (gzFile file); +
    + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +

    + +

    int gzflush (gzFile file, int flush); +
    + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. +

    + gzflush should be called only when strictly necessary because it can + degrade compression. +

    + +

    z_off_t gzseek (gzFile file, z_off_t offset, int whence); +
    + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. +

    + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported ; gzseek then compresses a sequence of zeroes up to the new + starting position. +

    + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +

    + +

    int gzrewind (gzFile file); +
    + Rewinds the given file. This function is supported only for reading. +

    + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +

    + +

    z_off_t gztell (gzFile file); +
    + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. +

    + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +

    + +

    int gzeof (gzFile file); +
    + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +

    + +

    int gzclose (gzFile file); +
    + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +

    + +

    const char * gzerror (gzFile file, int *errnum); +
    + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +

    +

    +
    +

    Basic functions

    +

    Function list

    +
    + +

    Function description

    +
    +
    const char * zlibVersion (void); +
    The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. +

    + +

    int deflateInit (z_streamp strm, int level); +
    + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. +

    + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). +

    + + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). +

    + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +

    + +

    int deflate (z_streamp strm, int flush); +
    + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush.

    + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + +

      +
    • Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + +
    • + Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. +

    + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly ; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. +

    + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. +

    + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + the compression. +

    + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). +

    + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space ; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. +

    + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + 0.1% larger than avail_in plus 12 bytes. If deflate does not return + Z_STREAM_END, then it must be called again as described above. +

    + + deflate() sets strm-> adler to the adler32 checksum of all input read + so far (that is, total_in bytes). +

    + + deflate() may update data_type if it can make a good guess about + the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. +

    + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). +

    + +

    int deflateEnd (z_streamp strm); +
    + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. +

    + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +

    + +

    int inflateInit (z_streamp strm); +
    + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly ; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. +

    + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +

    + +

    int inflate (z_streamp strm, int flush); +
    + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may some + introduce some output latency (reading input without producing any output) + except when forced to flush. +

    + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + +

      +
    • Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + +
    • Provide more output starting at next_out and update next_out and + avail_out accordingly. inflate() provides as much output as possible, + until there is no more input data or no more space in the output buffer + (see below about the flush parameter). +

    + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. +

    + + If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much + output as possible to the output buffer. The flushing behavior of inflate is + not specified for values of the flush parameter other than Z_SYNC_FLUSH + and Z_FINISH, but the current implementation actually flushes as much output + as possible anyway. +

    + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed ; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster routine + may be used for the single inflate() call. +

    + + If a preset dictionary is needed at this point (see inflateSetDictionary + below), inflate sets strm-adler to the adler32 checksum of the + dictionary chosen by the compressor and returns Z_NEED_DICT ; otherwise + it sets strm-> adler to the adler32 checksum of all output produced + so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or + an error code as described below. At the end of the stream, inflate() + checks that its computed adler32 checksum is equal to that saved by the + compressor and returns Z_STREAM_END only if the checksum is correct. +

    + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect + adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent + (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if no progress is possible or if there was not + enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR + case, the application may then call inflateSync to look for a good + compression block. +

    + +

    int inflateEnd (z_streamp strm); +
    + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. +

    + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +

    +
    +

    Advanced functions

    + The following functions are needed only in some special applications. +

    Function list

    +
    +

    Function description

    +
    +
    int deflateInit2 (z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy); + +
    This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller.

    + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library.

    + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead.

    + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio ; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel.

    + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match). Filtered data consists mostly of small values with a + somewhat random distribution. In this case, the compression algorithm is + tuned to compress them better. The effect of Z_FILTERED is to force more + Huffman coding and less string matching ; it is somewhat intermediate + between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects + the compression ratio but not the correctness of the compressed output even + if it is not set appropriately.

    + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate().

    + +

    int deflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength); +
    + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary).

    + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy ; the data can then be compressed better than + with the default empty dictionary.

    + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front.

    + + Upon return of this function, strm-> adler is set to the Adler32 value + of the dictionary ; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.)

    + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate().

    + +

    int deflateCopy (z_streamp dest, z_streamp source); +
    + Sets the destination stream as a complete copy of the source stream.

    + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory.

    + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination.

    + +

    int deflateReset (z_streamp strm); +
    This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2.

    + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL).

    + +

    int deflateParams (z_streamp strm, int level, int strategy); +
    + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate().

    + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm-> avail_out must be + non-zero.

    + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero.

    + +

    int inflateInit2 (z_streamp strm, int windowBits); + +
    This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller.

    + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. If a compressed stream with a larger window size is given as + input, inflate() will return with the error code Z_DATA_ERROR instead of + trying to allocate a larger window.

    + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative + memLevel). msg is set to null if there is no error message. inflateInit2 + does not perform any decompression apart from reading the zlib header if + present: this will be done by inflate(). (So next_in and avail_in may be + modified, but next_out and avail_out are unchanged.)

    + +

    int inflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength); +
    + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate + if this call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler32 value returned by this call of + inflate. The compressor and decompressor must use exactly the same + dictionary (see deflateSetDictionary).

    + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate().

    + +

    int inflateSync (z_streamp strm); + +
    Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided.

    + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data.

    + +

    int inflateReset (z_streamp strm); +
    + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. +

    + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +

    +

    + +
    +

    Checksum functions

    + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +

    Function list

    +
    +

    Function description

    +
    +
    uLong adler32 (uLong adler, const Bytef *buf, uInt len); +
    + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. +

    + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: +

    + 
    +      uLong adler = adler32(0L, Z_NULL, 0);
    + 
    +      while (read_buffer(buffer, length) != EOF) {
    +        adler = adler32(adler, buffer, length);
    +      }
    +      if (adler != original_adler) error();
    +    
    + +
    uLong crc32 (uLong crc, const Bytef *buf, uInt len); +
    + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: +
    + 
    +      uLong crc = crc32(0L, Z_NULL, 0);
    + 
    +      while (read_buffer(buffer, length) != EOF) {
    +        crc = crc32(crc, buffer, length);
    +      }
    +      if (crc != original_crc) error();
    +    
    +
    +
    +

    struct z_stream_s

    + +
    +
    + typedef struct z_stream_s {
    +     Bytef    *next_in;  /* next input byte */
    +     uInt     avail_in;  /* number of bytes available at next_in */
    +     uLong    total_in;  /* total nb of input bytes read so far */
    + 
    +     Bytef    *next_out; /* next output byte should be put there */
    +     uInt     avail_out; /* remaining free space at next_out */
    +     uLong    total_out; /* total nb of bytes output so far */
    + 
    +     char     *msg;      /* last error message, NULL if no error */
    +     struct internal_state FAR *state; /* not visible by applications */
    + 
    +     alloc_func zalloc;  /* used to allocate the internal state */
    +     free_func  zfree;   /* used to free the internal state */
    +     voidpf     opaque;  /* private data object passed to zalloc and zfree */
    + 
    +     int     data_type;  /* best guess about the data type: ascii or binary */
    +     uLong   adler;      /* adler32 value of the uncompressed data */
    +     uLong   reserved;   /* reserved for future use */
    + } z_stream ;
    + 
    + typedef z_stream FAR * z_streamp;  ?
    + 
    +
    + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application.

    + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value.

    + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe.

    + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). +

    + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step).

    + +


    +

    Constants

    + +
    + #define Z_NO_FLUSH      0
    + #define Z_PARTIAL_FLUSH 1
    + 	/* will be removed, use Z_SYNC_FLUSH instead */
    + #define Z_SYNC_FLUSH    2
    + #define Z_FULL_FLUSH    3
    + #define Z_FINISH        4
    + /* Allowed flush values ; see deflate() below for details */
    + 
    + #define Z_OK            0
    + #define Z_STREAM_END    1
    + #define Z_NEED_DICT     2
    + #define Z_ERRNO        (-1)
    + #define Z_STREAM_ERROR (-2)
    + #define Z_DATA_ERROR   (-3)
    + #define Z_MEM_ERROR    (-4)
    + #define Z_BUF_ERROR    (-5)
    + #define Z_VERSION_ERROR (-6)
    + /* Return codes for the compression/decompression functions. Negative
    +  * values are errors, positive values are used for special but normal events.
    +  */
    + 
    + #define Z_NO_COMPRESSION         0
    + #define Z_BEST_SPEED             1
    + #define Z_BEST_COMPRESSION       9
    + #define Z_DEFAULT_COMPRESSION  (-1)
    + /* compression levels */
    + 
    + #define Z_FILTERED            1
    + #define Z_HUFFMAN_ONLY        2
    + #define Z_DEFAULT_STRATEGY    0
    + /* compression strategy ; see deflateInit2() below for details */
    + 
    + #define Z_BINARY   0
    + #define Z_ASCII    1
    + #define Z_UNKNOWN  2
    + /* Possible values of the data_type field */
    + 
    + #define Z_DEFLATED   8
    + /* The deflate compression method (the only one supported in this version) */
    + 
    + #define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
    + 
    + #define zlib_version zlibVersion()
    + /* for compatibility with versions less than 1.0.2 */
    + 
    +
    + +
    +

    Misc

    +
    deflateInit and inflateInit are macros to allow checking the zlib version + and the compiler's view of z_stream. +

    + Other functions: +

    +
    const char * zError (int err); +
    int inflateSyncPoint (z_streamp z); +
    const uLongf * get_crc_table (void); +
    +
    + + Last update: Wed Oct 13 20:42:34 1999
    + piapi at csie.ntu.edu.tw +
    + + + From criswell at cs.uiuc.edu Fri Feb 6 10:37:19 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:37:19 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/win32/DLL_FAQ.txt Makefile.bor Makefile.emx Makefile.gcc Makefile.msc zlib.def zlib1.rc Message-ID: <200402061636.KAA15730@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/win32: DLL_FAQ.txt added (r1.1) Makefile.bor added (r1.1) Makefile.emx added (r1.1) Makefile.gcc added (r1.1) Makefile.msc added (r1.1) zlib.def added (r1.1) zlib1.rc added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+913 -0) Index: llvm/runtime/zlib/win32/DLL_FAQ.txt diff -c /dev/null llvm/runtime/zlib/win32/DLL_FAQ.txt:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/win32/DLL_FAQ.txt Fri Feb 6 10:36:42 2004 *************** *** 0 **** --- 1,371 ---- + + Frequently Asked Questions about ZLIB1.DLL + + + This document describes the design, the rationale, and the usage + of the official DLL build of zlib, named ZLIB1.DLL. If you have + general questions about zlib, you should see the file "FAQ" found + in the zlib distribution, or at the following location: + http://www.gzip.org/zlib/zlib_faq.html + + + 1. What is ZLIB1.DLL, and how can I get it? + + - ZLIB1.DLL is the official build of zlib as a DLL. + (Please remark the symbol '1' in the name.) + + Pointers to a precompiled ZLIB1.DLL can be found in the zlib + web site at: + http://www.zlib.org/ + + Applications that link to ZLIB1.DLL can rely on the following + specification: + + * The exported symbols are exclusively defined in the source + files "zlib.h" and "zlib.def", found in an official zlib + source distribution. + * The symbols are exported by name, not by ordinal. + * The exported names are undecorated. + * The calling convention of functions is "C" (CDECL). + * The ZLIB1.DLL binary is linked to MSVCRT.DLL. + + The archive in which ZLIB1.DLL is bundled contains compiled + test programs that must run with a valid build of ZLIB1.DLL. + It is recommended to download the prebuilt DLL from the zlib + web site, instead of building it yourself, to avoid potential + incompatibilities that could be introduced by your compiler + and build settings. If you do build the DLL yourself, please + make sure that it complies with all the above requirements, + and it runs with the precompiled test programs, bundled with + the original ZLIB1.DLL distribution and available at the zlib + web site. + + If, for any reason, you need to build an incompatible DLL, + please use a different name. + + + 2. Why did you change the name of the DLL to ZLIB1.DLL? + What happened to the old ZLIB.DLL? + + - The old ZLIB.DLL, built from zlib-1.1.x and earlier, required + compilation settings that were incompatible to those used by a + static build. The DLL settings were supposed to be enabled by + defining the macro ZLIB_DLL, before including "zlib.h". + Incorrect handling of this macro was silently accepted at + build time, resulting in two major problems: + + * ZLIB_DLL was missing from the old makefile. When building + the DLL, not all people added it to the build options. In + consequence, incompatible incarnations of ZLIB.DLL started + to circulate around the net. + + * When switching from using the static library to using the + DLL, applications had to define the ZLIB_DLL macro and + to recompile all the sources that contained calls to zlib + functions. Failure to do so resulted in creating binaries + that were unable to run with the official ZLIB.DLL build. + + The only possible solution that we could foresee was to make a + binary-incompatible change in the DLL interfacing, in order to + remove the dependency on the ZLIB_DLL macro, and to release + the new DLL under a different name. + + We chose the name ZLIB1.DLL, where '1' indicates the major + zlib version number. We hope that we will not have to break + the binary compatibility again, at least not as long as the + zlib-1.x series will last. + + There is still a ZLIB_DLL macro, that can trigger a more + efficient build and use of the DLL, but compatibility no + longer dependents on it. + + + 3. Can I build ZLIB.DLL from the new zlib sources, and replace + an old ZLIB.DLL, that was built from zlib-1.1.4 or earlier? + + - In principle, you can do it by assigning calling convention + keywords to the macros ZEXPORT and ZEXPORTVA. In practice, + it depends on what you mean by "an old ZLIB.DLL", because + the old DLL exists in several mutually-incompatible versions. + + If you have a compiled application that works with a certain + ZLIB.DLL without any known security issues, there is hardly + a need to rebuild the DLL from new sources only to link it to + the old app binary. But if you really want to do it, you have + to find out first what kind of calling convention uses your + particular ZLIB.DLL build, and to use the same one in the new + build. If you don't know what this is all about, you might be + better off if you would just forget it. + + + 4. Can I compile my application using the new zlib interface, and + link it to an old ZLIB.DLL, that was built from zlib-1.1.4 or + earlier? + + - The official answer is "no"; the real answer depends again on + what kind of ZLIB.DLL you have. Even if you are lucky, this + course of action is unreliable. + + If you rebuild your application and you intend to use a newer + version of zlib (post- 1.1.4), it is strongly recommended to + link it to the new ZLIB1.DLL. + + + 5. Why are the zlib symbols exported by name, and not by ordinal? + + - Although exporting symbols by ordinal is a little faster, it + is risky. Any single glitch in the maintenance or use of the + DEF file that contains the ordinals can result in incompatible + builds and frustrating crashes. Simply put, the benefits of + exporting symbols by ordinal do not justify the risks. + + Technically, it should be possible to maintain ordinals in + the DEF file, and still export the symbols by name. Ordinals + exist in every DLL, and even if the dynamic linking performed + at the DLL startup is searching for names, ordinals serve as + hints, for a faster name lookup. However, if the DEF file + contains ordinals, the Microsoft linker automatically builds + an implib that will cause the executables linked to it to use + those ordinals, and not the names. It is interesting to + notice that the GNU linker for Win32 does not suffer from this + problem. + + It is possible to avoid the DEF file if the exported symbols + are accompanied by a "__declspec(dllexport)" attribute in the + source files. You can do this in zlib by predefining the + ZLIB_DLL macro. + + + 6. I see that the ZLIB1.DLL functions use the "C" (CDECL) calling + convention. Why not use the STDCALL convention? + STDCALL is the standard convention in Win32, and I need it in + my Visual Basic project! + + (For readability, we use CDECL to refer to the convention + triggered by the "__cdecl" keyword, STDCALL to refer to + the convention triggered by "__stdcall", and FASTCALL to + refer to the convention triggered by "__fastcall".) + + - Most of the native Windows API functions (without varargs) use + indeed the WINAPI convention (which translates to STDCALL in + Win32), but the standard C functions use CDECL. If a user + application is intrinsically tied to the Windows API (e.g. + it calls native Windows API functions such as CreateFile()), + sometimes it makes sense to decorate its own functions with + WINAPI. But if ANSI C or POSIX portability is a goal (e.g. + it calls standard C functions such as fopen()), it is not a + sound decision to request the inclusion of , or to + use non-ANSI constructs, for the sole purpose to make the user + functions STDCALL-able. + + The functionality offered by zlib is not in the category of + "Windows functionality", but is more like "C functionality". + + Technically, STDCALL is not bad; in fact, it is slightly + faster than CDECL, and it works with variable-argument + functions, just like CDECL. It is unfortunate that, in spite + of using STDCALL in the Windows API, it is not the default + convention used by the C compilers that run under Windows. + The roots of the problem reside deep inside the unsafety of + the K&R-style function prototypes, where the argument types + are not specified; but that is another story for another day. + + The fact that remains is that CDECL is the default convention. + Even if an explicit convention (such as STDCALL or FASTCALL) + is hard-coded into the function prototypes inside C headers, + problems may appear. One problem, for example, deals with the + necessity to expose the convention in users' callbacks. + + The calling convention issues are also important when using + zlib in other programming languages. Some of them, like Ada + (GNAT) and Fortran (GNU G77), have C bindings implemented + initially on Unix, and relying on the C calling convention. + On the other hand, the pre- .NET versions of Microsoft Visual + Basic require STDCALL, while Borland Delphi prefers (although + it does not require) FASTCALL. + + In fairness to all possible uses of zlib outside the C + programming language, we choose the default "C" convention. + Anyone interested in different bindings or conventions is + encouraged to maintain specialized projects. The "contrib/" + directory from the zlib distribution already holds a couple + of foreign bindings, such as Ada, C++, and Delphi. + + + 7. I need a DLL for my Visual Basic project. What can I do? + + - Define the ZLIB_WINAPI macro before including "zlib.h", when + building both the DLL and the user application (except that + you don't need to define anything when using the DLL in Visual + Basic). The ZLIB_WINAPI macro will switch on the WINAPI + (STDCALL) convention. The name of this DLL must be different + than the official ZLIB1.DLL. + + Gilles Vollant has contributed a build named ZLIBWAPI.DLL, + with the ZLIB_WINAPI macro turned on, and with the minizip + functionality built in. For more information, please read + the notes inside "contrib/vstudio/readme.txt", found in the + zlib distribution. + + + 8. If my application uses ZLIB1.DLL, should I link it to + MSVCRT.DLL? Why? + + - It is not required, but it is recommended to link your + application to MSVCRT.DLL, if it uses ZLIB1.DLL. + + The executables (.EXE, .DLL, etc.) that are involved in the + same process and are using the C run-time library (i.e. they + are calling standard C functions), must link to the same + library. There are several libraries in the Win32 system: + CRTDLL.DLL, MSVCRT.DLL, the static C libraries, etc. + Since ZLIB1.DLL is linked to MSVCRT.DLL, the executables that + depend on it should also be linked to MSVCRT.DLL. + + + 9. Why are you saying that ZLIB1.DLL and my application must be + linked to the same C run-time (CRT) library? I linked my + application and my DLLs to different C libraries (e.g. my + application to a static library, and my DLLs to MSVCRT.DLL), + and everything works fine. + + - If a user library invokes only pure Win32 API (accessible via + and the related headers), its DLL build will work + in any context. But if this library invokes standard C API, + things get more complicated. + + There is a single Win32 library in a Win32 system. Every + function in this library resides in a single DLL module, that + is safe to call from anywhere. On the other hand, there are + multiple versions of the C library, and each of them has its + own separate internal state. Standalone executables and user + DLLs that call standard C functions must link to a C run-time + (CRT) library, be it static or shared (DLL). Intermixing + occurs when an executable (not necessarily standalone) and a + DLL are linked to different CRTs, and both are running in the + same process. + + Intermixing multiple CRTs is possible, as long as their + internal states are kept intact. The Microsoft Knowledge Base + articles KB94248 "HOWTO: Use the C Run-Time" and KB140584 + "HOWTO: Link with the Correct C Run-Time (CRT) Library" + mention the potential problems raised by intermixing. + + If intermixing works for you, it's because your application + and DLLs are avoiding the corruption of each of the CRTs' + internal states, maybe by careful design, or maybe by fortune. + + Also note that linking ZLIB1.DLL to non-Microsoft CRTs (such + as those provided by Borland) raises similar problems. + + + 10. Why are you linking ZLIB1.DLL to MSVCRT.DLL? + + - MSVCRT.DLL exists on every Windows 95 with a new service pack + installed, or with Microsoft Internet Explorer 4 or later, and + on all other Windows 4.x or later (Windows 98, Windows NT 4, + or later). It is freely distributable; if not present in the + system, it can be downloaded from Microsoft or from other + software provider for free. + + The fact that MSVCRT.DLL does not exist on a virgin Windows 95 + is not so problematic. The number of Windows 95 installations + is rapidly decreasing, Microsoft stopped supporting it a long + time ago, and many recent applications from various vendors, + including Microsoft, do not even run on it. Furthermore, no + serious user should run Windows 95 without a proper update + installed. + + There is also the fact that the mainstream C compilers for + Windows are Microsoft Visual C++ 6.0, and gcc/MinGW. Both + are producing executables that link to MSVCRT.DLL by default, + without offering other dynamic CRTs as alternatives easy to + select by users. + + + 11. Why are you not linking ZLIB1.DLL to + <> ? + + - We considered and abandoned the following alternatives: + + * Linking ZLIB1.DLL to a static C library (LIBC.LIB, or + LIBCMT.LIB) is not a good option. People are using the DLL + mainly to save disk space. If you are linking your program + to a static C library, you may as well consider linking zlib + in statically, too. + + * Linking ZLIB1.DLL to CRTDLL.DLL looks very appealing, + because CRTDLL.DLL is present on every Win32 installation. + Unfortunately, it has a series of problems: it raises + difficulties when using it with C++ code, it does not work + with 64-bit file offsets, (and so on...), and Microsoft + discontinued its support a long time ago. + + * Linking ZLIB1.DLL to MSVCR70.DLL, supplied with the + Microsoft .NET platform and Visual C++ 7.0 or newer, is not + a good option. Although it is available for free download + and distribution, its presence is scarce on today's Win32 + installations. If it will ever become more popular than + MSVCRT.DLL and will be pre-installed on the future Win32 + systems, we will probably think again about it. + + * Linking ZLIB1.DLL to NTDLL.DLL is not possible. + NTDLL.DLL exports only a part of the C library, and only on + Windows NT systems. + + + 12. I need to link my own DLL build to a CRT different than + MSVCRT.DLL. What can I do? + + - Feel free to rebuild the DLL from the zlib sources, and link + it the way you want. You should, however, clearly state that + your build is unofficial. You should give it a different file + name, and/or install it in a private directory that can be + accessed by your application only, and is not visible to the + others (e.g. it's not in the SYSTEM or the SYSTEM32 directory, + and it's not in the PATH). Otherwise, your build may clash + with applications that link to the official build. + + For example, in Cygwin, zlib is linked to the Cygwin runtime + CYGWIN1.DLL, and it is distributed under the name CYGZ.DLL. + + + 13. May I include additional pieces of code that I find useful, + link them in ZLIB1.DLL, and export them? + + - No. A legitimate build of ZLIB1.DLL must not include code + that does not originate from the official zlib source code. + But you can make your own private DLL build, under a different + file name, as suggested in the previous answer. + + For example, in Borland Delphi and C++ Builder, zlib is a part + of the standard VCL library. If an application links to VCL + dynamically, the name of the distributable binary (VCLxx.DLL) + does not posess any danger of clashing with a legitimate but + incompatible ZLIB1.DLL. + + + 14. May I remove some functionality out of ZLIB1.DLL, by enabling + macros like NO_GZCOMPRESS or NO_GZIP at compile time? + + - No. A legitimate build of ZLIB1.DLL must provide the complete + zlib functionality, as implemented in the official zlib source + code. But you can make your own private DLL build, under a + different file name, as suggested in the previous answer. + + + 15. I made my own ZLIB1.DLL build. Can I test it for compliance? + + - We prefer that you download the official DLL from the zlib + web site. If you need something peculiar from this DLL, you + can send your suggestion to the zlib mailing list. + + However, in case you do rebuild the DLL yourself, you can run + it with the test programs found in the DLL distribution. + Running these test programs is not a guarantee of compliance, + but a failure can imply a detected problem. + + ** + + This document is written and maintained by + Cosmin Truta Index: llvm/runtime/zlib/win32/Makefile.bor diff -c /dev/null llvm/runtime/zlib/win32/Makefile.bor:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/win32/Makefile.bor Fri Feb 6 10:36:42 2004 *************** *** 0 **** --- 1,107 ---- + # Makefile for zlib + # Borland C++ for Win32 + # + # Updated for zlib 1.2.x by Cosmin Truta, 11-Mar-2003 + # Last updated: 28-Aug-2003 + # + # Usage: + # make -f win32/Makefile.bor + # make -f win32/Makefile.bor LOCAL_ZLIB=-DASMV OBJA=match.obj OBJPA=+match.obj + + # ------------ Borland C++ ------------ + + # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) + # should be added to the environment via "set LOCAL_ZLIB=-DFOO" or + # added to the declaration of LOC here: + LOC = $(LOCAL_ZLIB) + + CC = bcc32 + AS = bcc32 + LD = bcc32 + AR = tlib + CFLAGS = -a -d -k- -O2 $(LOC) + ASFLAGS = $(LOC) + LDFLAGS = $(LOC) + + + # variables + ZLIB_LIB = zlib.lib + + OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj + OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj + #OBJA = + OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj + OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj + #OBJPA= + + + # targets + all: $(ZLIB_LIB) example.exe minigzip.exe + + .c.obj: + $(CC) -c $(CFLAGS) $< + + .asm.obj: + $(AS) -c $(ASFLAGS) $< + + adler32.obj: adler32.c zlib.h zconf.h + + compress.obj: compress.c zlib.h zconf.h + + crc32.obj: crc32.c zlib.h zconf.h crc32.h + + deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h + + gzio.obj: gzio.c zutil.h zlib.h zconf.h + + infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + + inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h + + inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + + inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h + + trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h + + uncompr.obj: uncompr.c zlib.h zconf.h + + zutil.obj: zutil.c zutil.h zlib.h zconf.h + + example.obj: example.c zlib.h zconf.h + + minigzip.obj: minigzip.c zlib.h zconf.h + + + # For the sake of the old Borland make, + # the command line is cut to fit in the MS-DOS 128 byte limit: + $(ZLIB_LIB): $(OBJ1) $(OBJ2) $(OBJA) + -del $(ZLIB_LIB) + $(AR) $(ZLIB_LIB) $(OBJP1) + $(AR) $(ZLIB_LIB) $(OBJP2) + $(AR) $(ZLIB_LIB) $(OBJPA) + + + # testing + test: example.exe minigzip.exe + example + echo hello world | minigzip | minigzip -d + + example.exe: example.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) + + minigzip.exe: minigzip.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) + + + # cleanup + clean: + -del *.obj + -del *.lib + -del *.exe + -del *.tds + -del zlib.bak + -del foo.gz Index: llvm/runtime/zlib/win32/Makefile.emx diff -c /dev/null llvm/runtime/zlib/win32/Makefile.emx:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/win32/Makefile.emx Fri Feb 6 10:36:42 2004 *************** *** 0 **** --- 1,69 ---- + # Makefile for zlib. Modified for emx/rsxnt by Chr. Spieler, 6/16/98. + # Copyright (C) 1995-1998 Jean-loup Gailly. + # For conditions of distribution and use, see copyright notice in zlib.h + + # To compile, or to compile and test, type: + # + # make -fmakefile.emx; make test -fmakefile.emx + # + + CC=gcc -Zwin32 + + #CFLAGS=-MMD -O + #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 + #CFLAGS=-MMD -g -DDEBUG + CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ + -Wstrict-prototypes -Wmissing-prototypes + + # If cp.exe is available, replace "copy /Y" with "cp -fp" . + CP=copy /Y + # If gnu install.exe is available, replace $(CP) with ginstall. + INSTALL=$(CP) + # The default value of RM is "rm -f." If "rm.exe" is found, comment out: + RM=del + LDLIBS=-L. -lzlib + LD=$(CC) -s -o + LDSHARED=$(CC) + + INCL=zlib.h zconf.h + LIBS=zlib.a + + AR=ar rcs + + prefix=/usr/local + exec_prefix = $(prefix) + + OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ + zutil.o inflate.o infback.o inftrees.o inffast.o + + TEST_OBJS = example.o minigzip.o + + all: example.exe minigzip.exe + + test: all + ./example + echo hello world | .\minigzip | .\minigzip -d + + %.o : %.c + $(CC) $(CFLAGS) -c $< -o $@ + + zlib.a: $(OBJS) + $(AR) $@ $(OBJS) + + %.exe : %.o $(LIBS) + $(LD) $@ $< $(LDLIBS) + + + .PHONY : clean + + clean: + $(RM) *.d + $(RM) *.o + $(RM) *.exe + $(RM) zlib.a + $(RM) foo.gz + + DEPS := $(wildcard *.d) + ifneq ($(DEPS),) + include $(DEPS) + endif Index: llvm/runtime/zlib/win32/Makefile.gcc diff -c /dev/null llvm/runtime/zlib/win32/Makefile.gcc:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/win32/Makefile.gcc Fri Feb 6 10:36:42 2004 *************** *** 0 **** --- 1,141 ---- + # Makefile for zlib, derived from Makefile.dj2. + # Modified for mingw32 by C. Spieler, 6/16/98. + # Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003. + # Last updated: 1-Aug-2003. + # Tested under Cygwin and MinGW. + + # Copyright (C) 1995-2003 Jean-loup Gailly. + # For conditions of distribution and use, see copyright notice in zlib.h + + # To compile, or to compile and test, type: + # + # make -fmakefile.gcc; make test testdll -fmakefile.gcc + # + # To use the asm code, type: + # cp contrib/asm?86/match.S ./match.S + # make LOC=-DASMV OBJA=match.o -fmakefile.gcc + # + # To install libz.a, zconf.h and zlib.h in the system directories, type: + # + # make install -fmakefile.gcc + + # Note: + # If the platform is *not* MinGW (e.g. it is Cygwin or UWIN), + # the DLL name should be changed from "zlib1.dll". + + STATICLIB = libz.a + SHAREDLIB = zlib1.dll + IMPLIB = libzdll.a + + #LOC = -DASMV + #LOC = -DDEBUG -g + + CC = gcc + CFLAGS = $(LOC) -O3 -Wall + + AS = $(CC) + ASFLAGS = $(LOC) -Wall + + LD = $(CC) + LDFLAGS = $(LOC) -s + + AR = ar + ARFLAGS = rcs + + RC = windres + RCFLAGS = --define GCC_WINDRES + + CP = cp -fp + # If GNU install is available, replace $(CP) with install. + INSTALL = $(CP) + RM = rm -f + + prefix = /usr/local + exec_prefix = $(prefix) + + OBJS = adler32.o compress.o crc32.o deflate.o gzio.o infback.o \ + inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o + OBJA = + + all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example minigzip example_d minigzip_d + + test: example minigzip + ./example + echo hello world | ./minigzip | ./minigzip -d + + testdll: example_d minigzip_d + ./example_d + echo hello world | ./minigzip_d | ./minigzip_d -d + + .c.o: + $(CC) $(CFLAGS) -c -o $@ $< + + .S.o: + $(AS) $(ASFLAGS) -c -o $@ $< + + $(STATICLIB): $(OBJS) $(OBJA) + $(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA) + + $(IMPLIB): $(SHAREDLIB) + + $(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o + dllwrap --driver-name $(CC) --def win32/zlib.def \ + --implib $(IMPLIB) -o $@ $(OBJS) $(OBJA) zlibrc.o + strip $@ + + example: example.o $(STATICLIB) + $(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB) + + minigzip: minigzip.o $(STATICLIB) + $(LD) $(LDFLAGS) -o $@ minigzip.o $(STATICLIB) + + example_d: example.o $(IMPLIB) + $(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB) + + minigzip_d: minigzip.o $(IMPLIB) + $(LD) $(LDFLAGS) -o $@ minigzip.o $(IMPLIB) + + zlibrc.o: win32/zlib1.rc + $(RC) $(RCFLAGS) -o $@ win32/zlib1.rc + + + # INCLUDE_PATH and LIBRARY_PATH must be set. + + .PHONY: install uninstall clean + + install: zlib.h zconf.h $(LIB) + - at if not exist $(INCLUDE_PATH)/nul mkdir $(INCLUDE_PATH) + - at if not exist $(LIBRARY_PATH)/nul mkdir $(LIBRARY_PATH) + -$(INSTALL) zlib.h $(INCLUDE_PATH) + -$(INSTALL) zconf.h $(INCLUDE_PATH) + -$(INSTALL) $(STATICLIB) $(LIBRARY_PATH) + -$(INSTALL) $(IMPLIB) $(LIBRARY_PATH) + + uninstall: + -$(RM) $(INCLUDE_PATH)/zlib.h + -$(RM) $(INCLUDE_PATH)/zconf.h + -$(RM) $(LIBRARY_PATH)/$(STATICLIB) + -$(RM) $(LIBRARY_PATH)/$(IMPLIB) + + clean: + -$(RM) $(STATICLIB) + -$(RM) $(SHAREDLIB) + -$(RM) $(IMPLIB) + -$(RM) *.o + -$(RM) *.exe + -$(RM) foo.gz + + adler32.o: zlib.h zconf.h + compress.o: zlib.h zconf.h + crc32.o: crc32.h zlib.h zconf.h + deflate.o: deflate.h zutil.h zlib.h zconf.h + example.o: zlib.h zconf.h + gzio.o: zutil.h zlib.h zconf.h + inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h + inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h + infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h + inftrees.o: zutil.h zlib.h zconf.h inftrees.h + minigzip.o: zlib.h zconf.h + trees.o: deflate.h zutil.h zlib.h zconf.h trees.h + uncompr.o: zlib.h zconf.h + zutil.o: zutil.h zlib.h zconf.h Index: llvm/runtime/zlib/win32/Makefile.msc diff -c /dev/null llvm/runtime/zlib/win32/Makefile.msc:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/win32/Makefile.msc Fri Feb 6 10:36:42 2004 *************** *** 0 **** --- 1,126 ---- + # Makefile for zlib -- Microsoft (Visual) C + # + # Authors: + # Cosmin Truta, 11-Mar-2003 + # Christian Spieler, 19-Mar-2003 + # + # Last updated: + # Cosmin Truta, 27-Aug-2003 + # + # Usage: + # nmake -f win32/Makefile.msc (standard build) + # nmake -f win32/Makefile.msc LOC=-DFOO (nonstandard build) + # nmake -f win32/Makefile.msc LOC=-DASMV OBJA=match.obj (use ASM code) + + + # optional build flags + LOC = + + + # variables + STATICLIB = zlib.lib + SHAREDLIB = zlib1.dll + IMPLIB = zdll.lib + + CC = cl + AS = ml + LD = link + AR = lib + RC = rc + CFLAGS = -nologo -MD -O2 $(LOC) + ASFLAGS = -coff + LDFLAGS = -nologo -release + ARFLAGS = -nologo + RCFLAGS = /dWIN32 /r + + OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj \ + inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj + OBJA = + + + # targets + all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \ + example.exe minigzip.exe example_d.exe minigzip_d.exe + + $(STATICLIB): $(OBJS) $(OBJA) + $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(OBJA) + + $(IMPLIB): $(SHAREDLIB) + + $(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlib1.res + $(LD) $(LDFLAGS) -def:win32/zlib.def -dll -implib:$(IMPLIB) \ + -out:$@ $(OBJS) $(OBJA) zlib1.res + + example.exe: example.obj $(STATICLIB) + $(LD) $(LDFLAGS) example.obj $(STATICLIB) + + minigzip.exe: minigzip.obj $(STATICLIB) + $(LD) $(LDFLAGS) minigzip.obj $(STATICLIB) + + example_d.exe: example.obj $(IMPLIB) + $(LD) $(LDFLAGS) -out:$@ example.obj $(IMPLIB) + + minigzip_d.exe: minigzip.obj $(IMPLIB) + $(LD) $(LDFLAGS) -out:$@ minigzip.obj $(IMPLIB) + + .c.obj: + $(CC) -c $(CFLAGS) $< + + .asm.obj: + $(AS) -c $(ASFLAGS) $< + + adler32.obj: adler32.c zlib.h zconf.h + + compress.obj: compress.c zlib.h zconf.h + + crc32.obj: crc32.c zlib.h zconf.h crc32.h + + deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h + + gzio.obj: gzio.c zutil.h zlib.h zconf.h + + infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + + inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h + + inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + + inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h + + trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h + + uncompr.obj: uncompr.c zlib.h zconf.h + + zutil.obj: zutil.c zutil.h zlib.h zconf.h + + example.obj: example.c zlib.h zconf.h + + minigzip.obj: minigzip.c zlib.h zconf.h + + zlib1.res: win32/zlib1.rc + $(RC) $(RCFLAGS) /fo$@ win32/zlib1.rc + + + # testing + test: example.exe minigzip.exe + example + echo hello world | minigzip | minigzip -d + + testdll: example_d.exe minigzip_d.exe + example_d + echo hello world | minigzip_d | minigzip_d -d + + + # cleanup + clean: + -del $(STATICLIB) + -del $(SHAREDLIB) + -del $(IMPLIB) + -del *.obj + -del *.res + -del *.exp + -del *.exe + -del foo.gz Index: llvm/runtime/zlib/win32/zlib.def diff -c /dev/null llvm/runtime/zlib/win32/zlib.def:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/win32/zlib.def Fri Feb 6 10:36:42 2004 *************** *** 0 **** --- 1,60 ---- + LIBRARY + ; zlib data compression library + + EXPORTS + ; basic functions + zlibVersion + deflate + deflateEnd + inflate + inflateEnd + ; advanced functions + deflateSetDictionary + deflateCopy + deflateReset + deflateParams + deflateBound + deflatePrime + inflateSetDictionary + inflateSync + inflateCopy + inflateReset + inflateBack + inflateBackEnd + zlibCompileFlags + ; utility functions + compress + compress2 + compressBound + uncompress + gzopen + gzdopen + gzsetparams + gzread + gzwrite + gzprintf + gzputs + gzgets + gzputc + gzgetc + gzungetc + gzflush + gzseek + gzrewind + gztell + gzeof + gzclose + gzerror + gzclearerr + ; checksum functions + adler32 + crc32 + ; various hacks, don't look :) + deflateInit_ + deflateInit2_ + inflateInit_ + inflateInit2_ + inflateBackInit_ + inflateSyncPoint + get_crc_table + zError Index: llvm/runtime/zlib/win32/zlib1.rc diff -c /dev/null llvm/runtime/zlib/win32/zlib1.rc:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/win32/zlib1.rc Fri Feb 6 10:36:42 2004 *************** *** 0 **** --- 1,39 ---- + #include + + #ifdef GCC_WINDRES + VS_VERSION_INFO VERSIONINFO + #else + VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE + #endif + FILEVERSION 1,2,1,0 + PRODUCTVERSION 1,2,1,0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + #ifdef _DEBUG + FILEFLAGS 1 + #else + FILEFLAGS 0 + #endif + FILEOS VOS_DOS_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0 // not used + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + //language ID = U.S. English, char set = Windows, Multilingual + BEGIN + VALUE "FileDescription", "zlib data compression library\0" + VALUE "FileVersion", "1.2.1\0" + VALUE "InternalName", "zlib1.dll\0" + VALUE "LegalCopyright", "(C) 1995-2003 Jean-loup Gailly & Mark Adler\0" + VALUE "OriginalFilename", "zlib1.dll\0" + VALUE "ProductName", "zlib\0" + VALUE "ProductVersion", "1.2.1\0" + VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END + END From criswell at cs.uiuc.edu Fri Feb 6 10:37:36 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:37:36 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/vstudio/vc7/gvmat32.obj inffas32.obj miniunz.vcproj minizip.vcproj zlib.rc zlibstat.vcproj zlibvc.def zlibvc.sln zlibvc.vcproj Message-ID: <200402061636.KAA15683@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/vstudio/vc7: gvmat32.obj added (r1.1) inffas32.obj added (r1.1) miniunz.vcproj added (r1.1) minizip.vcproj added (r1.1) zlib.rc added (r1.1) zlibstat.vcproj added (r1.1) zlibvc.def added (r1.1) zlibvc.sln added (r1.1) zlibvc.vcproj added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+1116 -0) Index: llvm/runtime/zlib/contrib/vstudio/vc7/gvmat32.obj Index: llvm/runtime/zlib/contrib/vstudio/vc7/inffas32.obj Index: llvm/runtime/zlib/contrib/vstudio/vc7/miniunz.vcproj diff -c /dev/null llvm/runtime/zlib/contrib/vstudio/vc7/miniunz.vcproj:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/vstudio/vc7/miniunz.vcproj Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,124 ---- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: llvm/runtime/zlib/contrib/vstudio/vc7/minizip.vcproj diff -c /dev/null llvm/runtime/zlib/contrib/vstudio/vc7/minizip.vcproj:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/vstudio/vc7/minizip.vcproj Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,124 ---- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: llvm/runtime/zlib/contrib/vstudio/vc7/zlib.rc diff -c /dev/null llvm/runtime/zlib/contrib/vstudio/vc7/zlib.rc:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/vstudio/vc7/zlib.rc Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,32 ---- + #include + + #define IDR_VERSION1 1 + IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE + FILEVERSION 1,2,1,0 + PRODUCTVERSION 1,2,1,0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0 + FILEOS VOS_DOS_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0 // not used + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + //language ID = U.S. English, char set = Windows, Multilingual + + BEGIN + VALUE "FileDescription", "zlib data compression library\0" + VALUE "FileVersion", "1.2.1.0\0" + VALUE "InternalName", "zlib\0" + VALUE "OriginalFilename", "zlib.dll\0" + VALUE "ProductName", "ZLib.DLL\0" + VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" + VALUE "LegalCopyright", "(C) 1995-2003 Jean-loup Gailly & Mark Adler\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END + END Index: llvm/runtime/zlib/contrib/vstudio/vc7/zlibstat.vcproj diff -c /dev/null llvm/runtime/zlib/contrib/vstudio/vc7/zlibstat.vcproj:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/vstudio/vc7/zlibstat.vcproj Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,242 ---- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: llvm/runtime/zlib/contrib/vstudio/vc7/zlibvc.def diff -c /dev/null llvm/runtime/zlib/contrib/vstudio/vc7/zlibvc.def:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/contrib/vstudio/vc7/zlibvc.def Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,92 ---- + + VERSION 1.21 + + HEAPSIZE 1048576,8192 + + EXPORTS + adler32 @1 + compress @2 + crc32 @3 + deflate @4 + deflateCopy @5 + deflateEnd @6 + deflateInit2_ @7 + deflateInit_ @8 + deflateParams @9 + deflateReset @10 + deflateSetDictionary @11 + gzclose @12 + gzdopen @13 + gzerror @14 + gzflush @15 + gzopen @16 + gzread @17 + gzwrite @18 + inflate @19 + inflateEnd @20 + inflateInit2_ @21 + inflateInit_ @22 + inflateReset @23 + inflateSetDictionary @24 + inflateSync @25 + uncompress @26 + zlibVersion @27 + gzprintf @28 + gzputc @29 + gzgetc @30 + gzseek @31 + gzrewind @32 + gztell @33 + gzeof @34 + gzsetparams @35 + zError @36 + inflateSyncPoint @37 + get_crc_table @38 + compress2 @39 + gzputs @40 + gzgets @41 + inflateCopy @42 + inflateBackInit_ @43 + inflateBack @44 + inflateBackEnd @45 + compressBound @46 + deflateBound @47 + gzclearerr @48 + gzungetc @49 + zlibCompileFlags @50 + deflatePrime @51 + + unzOpen @61 + unzClose @62 + unzGetGlobalInfo @63 + unzGetCurrentFileInfo @64 + unzGoToFirstFile @65 + unzGoToNextFile @66 + unzOpenCurrentFile @67 + unzReadCurrentFile @68 + unzOpenCurrentFile3 @69 + unztell @70 + unzeof @71 + unzCloseCurrentFile @72 + unzGetGlobalComment @73 + unzStringFileNameCompare @74 + unzLocateFile @75 + unzGetLocalExtrafield @76 + unzOpen2 @77 + unzOpenCurrentFile2 @78 + unzOpenCurrentFilePassword @79 + + zipOpen @80 + zipOpenNewFileInZip @81 + zipWriteInFileInZip @82 + zipCloseFileInZip @83 + zipClose @84 + zipOpenNewFileInZip2 @86 + zipCloseFileInZipRaw @87 + zipOpen2 @88 + zipOpenNewFileInZip3 @89 + + unzGetFilePos @100 + unzGoToFilePos @101 + + fill_win32_filefunc @110 Index: llvm/runtime/zlib/contrib/vstudio/vc7/zlibvc.sln diff -c /dev/null llvm/runtime/zlib/contrib/vstudio/vc7/zlibvc.sln:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/contrib/vstudio/vc7/zlibvc.sln Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,66 ---- + Microsoft Visual Studio Solution File, Format Version 7.00 + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" + EndProject + Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + ConfigName.2 = ReleaseAxp + ConfigName.3 = ReleaseWithoutAsm + ConfigName.4 = ReleaseWithoutCrtdll + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug.Build.0 = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release.Build.0 = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseAxp.ActiveCfg = ReleaseAxp|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseAxp.Build.0 = ReleaseAxp|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm.Build.0 = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutCrtdll.ActiveCfg = ReleaseAxp|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutCrtdll.Build.0 = ReleaseAxp|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug.Build.0 = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release.Build.0 = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseAxp.ActiveCfg = ReleaseAxp|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseAxp.Build.0 = ReleaseAxp|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm.Build.0 = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutCrtdll.ActiveCfg = ReleaseWithoutCrtdll|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutCrtdll.Build.0 = ReleaseWithoutCrtdll|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug.Build.0 = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release.Build.0 = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseAxp.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseAxp.Build.0 = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm.Build.0 = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutCrtdll.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutCrtdll.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseAxp.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseAxp.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutCrtdll.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutCrtdll.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection + EndGlobal Index: llvm/runtime/zlib/contrib/vstudio/vc7/zlibvc.vcproj diff -c /dev/null llvm/runtime/zlib/contrib/vstudio/vc7/zlibvc.vcproj:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/contrib/vstudio/vc7/zlibvc.vcproj Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,436 ---- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From criswell at cs.uiuc.edu Fri Feb 6 10:37:51 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:37:51 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/msdos/Makefile.bor Makefile.dj2 Makefile.emx Makefile.msc Makefile.tc Message-ID: <200402061636.KAA15680@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/msdos: Makefile.bor added (r1.1) Makefile.dj2 added (r1.1) Makefile.emx added (r1.1) Makefile.msc added (r1.1) Makefile.tc added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+482 -0) Index: llvm/runtime/zlib/msdos/Makefile.bor diff -c /dev/null llvm/runtime/zlib/msdos/Makefile.bor:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/msdos/Makefile.bor Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,109 ---- + # Makefile for zlib + # Borland C++ + # Last updated: 15-Mar-2003 + + # To use, do "make -fmakefile.bor" + # To compile in small model, set below: MODEL=s + + # WARNING: the small model is supported but only for small values of + # MAX_WBITS and MAX_MEM_LEVEL. For example: + # -DMAX_WBITS=11 -DDEF_WBITS=11 -DMAX_MEM_LEVEL=3 + # If you wish to reduce the memory requirements (default 256K for big + # objects plus a few K), you can add to the LOC macro below: + # -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 + # See zconf.h for details about the memory requirements. + + # ------------ Turbo C++, Borland C++ ------------ + + # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) + # should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added + # to the declaration of LOC here: + LOC = $(LOCAL_ZLIB) + + # type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. + CPU_TYP = 0 + + # memory model: one of s, m, c, l (small, medium, compact, large) + MODEL=l + + # replace bcc with tcc for Turbo C++ 1.0, with bcc32 for the 32 bit version + CC=bcc + LD=bcc + AR=tlib + + # compiler flags + # replace "-O2" by "-O -G -a -d" for Turbo C++ 1.0 + CFLAGS=-O2 -Z -m$(MODEL) $(LOC) + + LDFLAGS=-m$(MODEL) -f- + + + # variables + ZLIB_LIB = zlib_$(MODEL).lib + + OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj + OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj + OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj + OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj + + + # targets + all: $(ZLIB_LIB) example.exe minigzip.exe + + .c.obj: + $(CC) -c $(CFLAGS) $*.c + + adler32.obj: adler32.c zlib.h zconf.h + + compress.obj: compress.c zlib.h zconf.h + + crc32.obj: crc32.c zlib.h zconf.h crc32.h + + deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h + + gzio.obj: gzio.c zutil.h zlib.h zconf.h + + infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + + inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h + + inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + + inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h + + trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h + + uncompr.obj: uncompr.c zlib.h zconf.h + + zutil.obj: zutil.c zutil.h zlib.h zconf.h + + example.obj: example.c zlib.h zconf.h + + minigzip.obj: minigzip.c zlib.h zconf.h + + + # the command line is cut to fit in the MS-DOS 128 byte limit: + $(ZLIB_LIB): $(OBJ1) $(OBJ2) + -del $(ZLIB_LIB) + $(AR) $(ZLIB_LIB) $(OBJP1) + $(AR) $(ZLIB_LIB) $(OBJP2) + + example.exe: example.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) + + minigzip.exe: minigzip.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) + + test: example.exe minigzip.exe + example + echo hello world | minigzip | minigzip -d + + clean: + -del *.obj + -del *.lib + -del *.exe + -del zlib_*.bak + -del foo.gz Index: llvm/runtime/zlib/msdos/Makefile.dj2 diff -c /dev/null llvm/runtime/zlib/msdos/Makefile.dj2:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/msdos/Makefile.dj2 Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,104 ---- + # Makefile for zlib. Modified for djgpp v2.0 by F. J. Donahoe, 3/15/96. + # Copyright (C) 1995-1998 Jean-loup Gailly. + # For conditions of distribution and use, see copyright notice in zlib.h + + # To compile, or to compile and test, type: + # + # make -fmakefile.dj2; make test -fmakefile.dj2 + # + # To install libz.a, zconf.h and zlib.h in the djgpp directories, type: + # + # make install -fmakefile.dj2 + # + # after first defining LIBRARY_PATH and INCLUDE_PATH in djgpp.env as + # in the sample below if the pattern of the DJGPP distribution is to + # be followed. Remember that, while 'es around <=> are ignored in + # makefiles, they are *not* in batch files or in djgpp.env. + # - - - - - + # [make] + # INCLUDE_PATH=%\>;INCLUDE_PATH%%\DJDIR%\include + # LIBRARY_PATH=%\>;LIBRARY_PATH%%\DJDIR%\lib + # BUTT=-m486 + # - - - - - + # Alternately, these variables may be defined below, overriding the values + # in djgpp.env, as + # INCLUDE_PATH=c:\usr\include + # LIBRARY_PATH=c:\usr\lib + + CC=gcc + + #CFLAGS=-MMD -O + #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 + #CFLAGS=-MMD -g -DDEBUG + CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ + -Wstrict-prototypes -Wmissing-prototypes + + # If cp.exe is available, replace "copy /Y" with "cp -fp" . + CP=copy /Y + # If gnu install.exe is available, replace $(CP) with ginstall. + INSTALL=$(CP) + # The default value of RM is "rm -f." If "rm.exe" is found, comment out: + RM=del + LDLIBS=-L. -lz + LD=$(CC) -s -o + LDSHARED=$(CC) + + INCL=zlib.h zconf.h + LIBS=libz.a + + AR=ar rcs + + prefix=/usr/local + exec_prefix = $(prefix) + + OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ + zutil.o inflate.o infback.o inftrees.o inffast.o + + OBJA = + # to use the asm code: make OBJA=match.o + + TEST_OBJS = example.o minigzip.o + + all: example.exe minigzip.exe + + check: test + test: all + ./example + echo hello world | .\minigzip | .\minigzip -d + + %.o : %.c + $(CC) $(CFLAGS) -c $< -o $@ + + libz.a: $(OBJS) $(OBJA) + $(AR) $@ $(OBJS) $(OBJA) + + %.exe : %.o $(LIBS) + $(LD) $@ $< $(LDLIBS) + + # INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env . + + .PHONY : uninstall clean + + install: $(INCL) $(LIBS) + - at if not exist $(INCLUDE_PATH)\nul mkdir $(INCLUDE_PATH) + - at if not exist $(LIBRARY_PATH)\nul mkdir $(LIBRARY_PATH) + $(INSTALL) zlib.h $(INCLUDE_PATH) + $(INSTALL) zconf.h $(INCLUDE_PATH) + $(INSTALL) libz.a $(LIBRARY_PATH) + + uninstall: + $(RM) $(INCLUDE_PATH)\zlib.h + $(RM) $(INCLUDE_PATH)\zconf.h + $(RM) $(LIBRARY_PATH)\libz.a + + clean: + $(RM) *.d + $(RM) *.o + $(RM) *.exe + $(RM) libz.a + $(RM) foo.gz + + DEPS := $(wildcard *.d) + ifneq ($(DEPS),) + include $(DEPS) + endif Index: llvm/runtime/zlib/msdos/Makefile.emx diff -c /dev/null llvm/runtime/zlib/msdos/Makefile.emx:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/msdos/Makefile.emx Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,69 ---- + # Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98. + # Copyright (C) 1995-1998 Jean-loup Gailly. + # For conditions of distribution and use, see copyright notice in zlib.h + + # To compile, or to compile and test, type: + # + # make -fmakefile.emx; make test -fmakefile.emx + # + + CC=gcc + + #CFLAGS=-MMD -O + #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 + #CFLAGS=-MMD -g -DDEBUG + CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ + -Wstrict-prototypes -Wmissing-prototypes + + # If cp.exe is available, replace "copy /Y" with "cp -fp" . + CP=copy /Y + # If gnu install.exe is available, replace $(CP) with ginstall. + INSTALL=$(CP) + # The default value of RM is "rm -f." If "rm.exe" is found, comment out: + RM=del + LDLIBS=-L. -lzlib + LD=$(CC) -s -o + LDSHARED=$(CC) + + INCL=zlib.h zconf.h + LIBS=zlib.a + + AR=ar rcs + + prefix=/usr/local + exec_prefix = $(prefix) + + OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ + zutil.o inflate.o infback.o inftrees.o inffast.o + + TEST_OBJS = example.o minigzip.o + + all: example.exe minigzip.exe + + test: all + ./example + echo hello world | .\minigzip | .\minigzip -d + + %.o : %.c + $(CC) $(CFLAGS) -c $< -o $@ + + zlib.a: $(OBJS) + $(AR) $@ $(OBJS) + + %.exe : %.o $(LIBS) + $(LD) $@ $< $(LDLIBS) + + + .PHONY : clean + + clean: + $(RM) *.d + $(RM) *.o + $(RM) *.exe + $(RM) zlib.a + $(RM) foo.gz + + DEPS := $(wildcard *.d) + ifneq ($(DEPS),) + include $(DEPS) + endif Index: llvm/runtime/zlib/msdos/Makefile.msc diff -c /dev/null llvm/runtime/zlib/msdos/Makefile.msc:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/msdos/Makefile.msc Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,106 ---- + # Makefile for zlib + # Microsoft C 5.1 or later + # Last updated: 19-Mar-2003 + + # To use, do "make makefile.msc" + # To compile in small model, set below: MODEL=S + + # If you wish to reduce the memory requirements (default 256K for big + # objects plus a few K), you can add to the LOC macro below: + # -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 + # See zconf.h for details about the memory requirements. + + # ------------- Microsoft C 5.1 and later ------------- + + # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) + # should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added + # to the declaration of LOC here: + LOC = $(LOCAL_ZLIB) + + # Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. + CPU_TYP = 0 + + # Memory model: one of S, M, C, L (small, medium, compact, large) + MODEL=L + + CC=cl + CFLAGS=-nologo -A$(MODEL) -G$(CPU_TYP) -W3 -Oait -Gs $(LOC) + #-Ox generates bad code with MSC 5.1 + LIB_CFLAGS=-Zl $(CFLAGS) + + LD=link + LDFLAGS=/noi/e/st:0x1500/noe/farcall/packcode + # "/farcall/packcode" are only useful for `large code' memory models + # but should be a "no-op" for small code models. + + + # variables + ZLIB_LIB = zlib_$(MODEL).lib + + OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj + OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj + + + # targets + all: $(ZLIB_LIB) example.exe minigzip.exe + + .c.obj: + $(CC) -c $(LIB_CFLAGS) $*.c + + adler32.obj: adler32.c zlib.h zconf.h + + compress.obj: compress.c zlib.h zconf.h + + crc32.obj: crc32.c zlib.h zconf.h crc32.h + + deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h + + gzio.obj: gzio.c zutil.h zlib.h zconf.h + + infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + + inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h + + inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + + inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h + + trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h + + uncompr.obj: uncompr.c zlib.h zconf.h + + zutil.obj: zutil.c zutil.h zlib.h zconf.h + + example.obj: example.c zlib.h zconf.h + $(CC) -c $(CFLAGS) $*.c + + minigzip.obj: minigzip.c zlib.h zconf.h + $(CC) -c $(CFLAGS) $*.c + + + # the command line is cut to fit in the MS-DOS 128 byte limit: + $(ZLIB_LIB): $(OBJ1) $(OBJ2) + if exist $(ZLIB_LIB) del $(ZLIB_LIB) + lib $(ZLIB_LIB) $(OBJ1); + lib $(ZLIB_LIB) $(OBJ2); + + example.exe: example.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) example.obj,,,$(ZLIB_LIB); + + minigzip.exe: minigzip.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) minigzip.obj,,,$(ZLIB_LIB); + + test: example.exe minigzip.exe + example + echo hello world | minigzip | minigzip -d + + clean: + -del *.obj + -del *.lib + -del *.exe + -del *.map + -del zlib_*.bak + -del foo.gz Index: llvm/runtime/zlib/msdos/Makefile.tc diff -c /dev/null llvm/runtime/zlib/msdos/Makefile.tc:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/msdos/Makefile.tc Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,94 ---- + # Makefile for zlib + # Turbo C 2.01, Turbo C++ 1.01 + # Last updated: 15-Mar-2003 + + # To use, do "make -fmakefile.tc" + # To compile in small model, set below: MODEL=s + + # WARNING: the small model is supported but only for small values of + # MAX_WBITS and MAX_MEM_LEVEL. For example: + # -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 + # If you wish to reduce the memory requirements (default 256K for big + # objects plus a few K), you can add to CFLAGS below: + # -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 + # See zconf.h for details about the memory requirements. + + # ------------ Turbo C 2.01, Turbo C++ 1.01 ------------ + MODEL=l + CC=tcc + LD=tcc + AR=tlib + # CFLAGS=-O2 -G -Z -m$(MODEL) -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 + CFLAGS=-O2 -G -Z -m$(MODEL) + LDFLAGS=-m$(MODEL) -f- + + + # variables + ZLIB_LIB = zlib_$(MODEL).lib + + OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj + OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj + OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj + OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj + + + # targets + all: $(ZLIB_LIB) example.exe minigzip.exe + + .c.obj: + $(CC) -c $(CFLAGS) $*.c + + adler32.obj: adler32.c zlib.h zconf.h + + compress.obj: compress.c zlib.h zconf.h + + crc32.obj: crc32.c zlib.h zconf.h crc32.h + + deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h + + gzio.obj: gzio.c zutil.h zlib.h zconf.h + + infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + + inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h + + inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + + inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h + + trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h + + uncompr.obj: uncompr.c zlib.h zconf.h + + zutil.obj: zutil.c zutil.h zlib.h zconf.h + + example.obj: example.c zlib.h zconf.h + + minigzip.obj: minigzip.c zlib.h zconf.h + + + # the command line is cut to fit in the MS-DOS 128 byte limit: + $(ZLIB_LIB): $(OBJ1) $(OBJ2) + -del $(ZLIB_LIB) + $(AR) $(ZLIB_LIB) $(OBJP1) + $(AR) $(ZLIB_LIB) $(OBJP2) + + example.exe: example.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) + + minigzip.exe: minigzip.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) + + test: example.exe minigzip.exe + example + echo hello world | minigzip | minigzip -d + + clean: + -del *.obj + -del *.lib + -del *.exe + -del zlib_*.bak + -del foo.gz From criswell at cs.uiuc.edu Fri Feb 6 10:38:08 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:38:08 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/qnx/package.qpg Message-ID: <200402061636.KAA15702@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/qnx: package.qpg added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+141 -0) Index: llvm/runtime/zlib/qnx/package.qpg diff -c /dev/null llvm/runtime/zlib/qnx/package.qpg:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/qnx/package.qpg Fri Feb 6 10:36:42 2004 *************** *** 0 **** --- 1,141 ---- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Library + + Medium + + 2.0 + + + + zlib + zlib + alain.bonnefoy at icbt.com + Public + public + www.gzip.org/zlib + + + Jean-Loup Gailly,Mark Adler + www.gzip.org/zlib + + zlib at gzip.org + + + A massively spiffy yet delicately unobtrusive compression library. + zlib is designed to be a free, general-purpose, legally unencumbered, lossless data compression library for use on virtually any computer hardware and operating system. + http://www.gzip.org/zlib + + + + + 1.2.1 + Medium + Stable + + + + + + + No License + + + + Software Development/Libraries and Extensions/C Libraries + zlib,compression + qnx6 + qnx6 + None + Developer + + + + + + + + + + + + + + Install + Post + No + Ignore + + No + Optional + + + + + + + + + + + + + InstallOver + zlib + + + + + + + + + + + + + InstallOver + zlib-dev + + + + + + + + + From criswell at cs.uiuc.edu Fri Feb 6 10:38:23 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:38:23 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/minizip/ChangeLogUnzip Makefile crypt.h ioapi.c ioapi.h iowin32.c iowin32.h miniunz.c minizip.c unzip.c unzip.h zip.c zip.h Message-ID: <200402061636.KAA15642@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/minizip: ChangeLogUnzip added (r1.1) Makefile added (r1.1) crypt.h added (r1.1) ioapi.c added (r1.1) ioapi.h added (r1.1) iowin32.c added (r1.1) iowin32.h added (r1.1) miniunz.c added (r1.1) minizip.c added (r1.1) unzip.c added (r1.1) unzip.h added (r1.1) zip.c added (r1.1) zip.h added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+5001 -0) Index: llvm/runtime/zlib/contrib/minizip/ChangeLogUnzip diff -c /dev/null llvm/runtime/zlib/contrib/minizip/ChangeLogUnzip:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/minizip/ChangeLogUnzip Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,55 ---- + Change in 1.00: (10 sept 03) + - rename to 1.00 + - cosmetic code change + + Change in 0.22: (19 May 03) + - crypting support (unless you define NOCRYPT) + - append file in existing zipfile + + Change in 0.21: (10 Mar 03) + - bug fixes + + Change in 0.17: (27 Jan 02) + - bug fixes + + Change in 0.16: (19 Jan 02) + - Support of ioapi for virtualize zip file access + + Change in 0.15: (19 Mar 98) + - fix memory leak in minizip.c + + Change in 0.14: (10 Mar 98) + - fix bugs in minizip.c sample for zipping big file + - fix problem in month in date handling + - fix bug in unzlocal_GetCurrentFileInfoInternal in unzip.c for + comment handling + + Change in 0.13: (6 Mar 98) + - fix bugs in zip.c + - add real minizip sample + + Change in 0.12: (4 Mar 98) + - add zip.c and zip.h for creates .zip file + - fix change_file_date in miniunz.c for Unix (Jean-loup Gailly) + - fix miniunz.c for file without specific record for directory + + Change in 0.11: (3 Mar 98) + - fix bug in unzGetCurrentFileInfo for get extra field and comment + - enhance miniunz sample, remove the bad unztst.c sample + + Change in 0.10: (2 Mar 98) + - fix bug in unzReadCurrentFile + - rename unzip* to unz* function and structure + - remove Windows-like hungary notation variable name + - modify some structure in unzip.h + - add somes comment in source + - remove unzipGetcCurrentFile function + - replace ZUNZEXPORT by ZEXPORT + - add unzGetLocalExtrafield for get the local extrafield info + - add a new sample, miniunz.c + + Change in 0.4: (25 Feb 98) + - suppress the type unzipFileInZip. + Only on file in the zipfile can be open at the same time + - fix somes typo in code + - added tm_unz structure in unzip_file_info (date/time in readable format) Index: llvm/runtime/zlib/contrib/minizip/Makefile diff -c /dev/null llvm/runtime/zlib/contrib/minizip/Makefile:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/minizip/Makefile Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,25 ---- + CC=cc + CFLAGS=-O -I../.. + + UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a + ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a + + .c.o: + $(CC) -c $(CFLAGS) $*.c + + all: miniunz minizip + + miniunz: $(UNZ_OBJS) + $(CC) $(CFLAGS) -o $@ $(UNZ_OBJS) + + minizip: $(ZIP_OBJS) + $(CC) $(CFLAGS) -o $@ $(ZIP_OBJS) + + test: miniunz minizip + ./minizip test readme.txt + ./miniunz -l test.zip + mv readme.txt readme.old + ./miniunz test.zip + + clean: + /bin/rm -f *.o *~ minizip miniunz Index: llvm/runtime/zlib/contrib/minizip/crypt.h diff -c /dev/null llvm/runtime/zlib/contrib/minizip/crypt.h:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/minizip/crypt.h Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,132 ---- + /* crypt.h -- base code for crypt/uncrypt ZIPfile + + + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant + + This code is a modified version of crypting code in Infozip distribution + + The encryption/decryption parts of this source code (as opposed to the + non-echoing password parts) were originally written in Europe. The + whole source package can be freely distributed, including from the USA. + (Prior to January 2000, re-export from the US was a violation of US law.) + + This encryption code is a direct transcription of the algorithm from + Roger Schlafly, described by Phil Katz in the file appnote.txt. This + file (appnote.txt) is distributed with the PKZIP program (even in the + version without encryption capabilities). + + If you don't need crypting in your application, just define symbols + NOCRYPT and NOUNCRYPT. + + This code support the "Traditional PKWARE Encryption". + + The new AES encryption added on Zip format by Winzip (see the page + http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong + Encryption is not supported. + */ + + #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) + + /*********************************************************************** + * Return the next byte in the pseudo-random sequence + */ + static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) + { + unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an + * unpredictable manner on 16-bit systems; not a problem + * with any known compiler so far, though */ + + temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; + return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); + } + + /*********************************************************************** + * Update the encryption keys with the next byte of plain text + */ + static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) + { + (*(pkeys+0)) = CRC32((*(pkeys+0)), c); + (*(pkeys+1)) += (*(pkeys+0)) & 0xff; + (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; + { + register int keyshift = (int)((*(pkeys+1)) >> 24); + (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); + } + return c; + } + + + /*********************************************************************** + * Initialize the encryption keys and the random header according to + * the given password. + */ + static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) + { + *(pkeys+0) = 305419896L; + *(pkeys+1) = 591751049L; + *(pkeys+2) = 878082192L; + while (*passwd != '\0') { + update_keys(pkeys,pcrc_32_tab,(int)*passwd); + passwd++; + } + } + + #define zdecode(pkeys,pcrc_32_tab,c) \ + (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) + + #define zencode(pkeys,pcrc_32_tab,c,t) \ + (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) + + #ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED + + #define RAND_HEAD_LEN 12 + /* "last resort" source for second part of crypt seed pattern */ + # ifndef ZCR_SEED2 + # define ZCR_SEED2 3141592654UL /* use PI as default pattern */ + # endif + + static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) + const char *passwd; /* password string */ + unsigned char *buf; /* where to write header */ + int bufSize; + unsigned long* pkeys; + const unsigned long* pcrc_32_tab; + unsigned long crcForCrypting; + { + int n; /* index in random header */ + int t; /* temporary */ + int c; /* random byte */ + unsigned char header[RAND_HEAD_LEN-2]; /* random header */ + static unsigned calls = 0; /* ensure different random header each time */ + + if (bufSize> 7) & 0xff; + header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); + } + /* Encrypt random header (last two bytes is high word of crc) */ + init_keys(passwd, pkeys, pcrc_32_tab); + for (n = 0; n < RAND_HEAD_LEN-2; n++) + { + buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); + } + buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); + buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); + return n; + } + + #endif Index: llvm/runtime/zlib/contrib/minizip/ioapi.c diff -c /dev/null llvm/runtime/zlib/contrib/minizip/ioapi.c:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/minizip/ioapi.c Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,177 ---- + /* ioapi.c -- IO base function header for compress/uncompress .zip + files using zlib + zip or unzip API + + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant + */ + + #include + #include + #include + + #include "zlib.h" + #include "ioapi.h" + + + + /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ + + #ifndef SEEK_CUR + #define SEEK_CUR 1 + #endif + + #ifndef SEEK_END + #define SEEK_END 2 + #endif + + #ifndef SEEK_SET + #define SEEK_SET 0 + #endif + + voidpf ZCALLBACK fopen_file_func OF(( + voidpf opaque, + const char* filename, + int mode)); + + uLong ZCALLBACK fread_file_func OF(( + voidpf opaque, + voidpf stream, + void* buf, + uLong size)); + + uLong ZCALLBACK fwrite_file_func OF(( + voidpf opaque, + voidpf stream, + const void* buf, + uLong size)); + + long ZCALLBACK ftell_file_func OF(( + voidpf opaque, + voidpf stream)); + + long ZCALLBACK fseek_file_func OF(( + voidpf opaque, + voidpf stream, + uLong offset, + int origin)); + + int ZCALLBACK fclose_file_func OF(( + voidpf opaque, + voidpf stream)); + + int ZCALLBACK ferror_file_func OF(( + voidpf opaque, + voidpf stream)); + + + voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) + voidpf opaque; + const char* filename; + int mode; + { + FILE* file = NULL; + const char* mode_fopen = NULL; + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) + mode_fopen = "rb"; + else + if (mode & ZLIB_FILEFUNC_MODE_EXISTING) + mode_fopen = "r+b"; + else + if (mode & ZLIB_FILEFUNC_MODE_CREATE) + mode_fopen = "wb"; + + if ((filename!=NULL) && (mode_fopen != NULL)) + file = fopen(filename, mode_fopen); + return file; + } + + + uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) + voidpf opaque; + voidpf stream; + void* buf; + uLong size; + { + uLong ret; + ret = fread(buf, 1, (size_t)size, (FILE *)stream); + return ret; + } + + + uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) + voidpf opaque; + voidpf stream; + const void* buf; + uLong size; + { + uLong ret; + ret = fwrite(buf, 1, (size_t)size, (FILE *)stream); + return ret; + } + + long ZCALLBACK ftell_file_func (opaque, stream) + voidpf opaque; + voidpf stream; + { + long ret; + ret = ftell((FILE *)stream); + return ret; + } + + long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) + voidpf opaque; + voidpf stream; + uLong offset; + int origin; + { + int fseek_origin=0; + long ret; + switch (origin) + { + case ZLIB_FILEFUNC_SEEK_CUR : + fseek_origin = SEEK_CUR; + break; + case ZLIB_FILEFUNC_SEEK_END : + fseek_origin = SEEK_END; + break; + case ZLIB_FILEFUNC_SEEK_SET : + fseek_origin = SEEK_SET; + break; + default: return -1; + } + ret = 0; + fseek((FILE *)stream, offset, fseek_origin); + return ret; + } + + int ZCALLBACK fclose_file_func (opaque, stream) + voidpf opaque; + voidpf stream; + { + int ret; + ret = fclose((FILE *)stream); + return ret; + } + + int ZCALLBACK ferror_file_func (opaque, stream) + voidpf opaque; + voidpf stream; + { + int ret; + ret = ferror((FILE *)stream); + return ret; + } + + void fill_fopen_filefunc (pzlib_filefunc_def) + zlib_filefunc_def* pzlib_filefunc_def; + { + pzlib_filefunc_def->zopen_file = fopen_file_func; + pzlib_filefunc_def->zread_file = fread_file_func; + pzlib_filefunc_def->zwrite_file = fwrite_file_func; + pzlib_filefunc_def->ztell_file = ftell_file_func; + pzlib_filefunc_def->zseek_file = fseek_file_func; + pzlib_filefunc_def->zclose_file = fclose_file_func; + pzlib_filefunc_def->zerror_file = ferror_file_func; + pzlib_filefunc_def->opaque = NULL; + } Index: llvm/runtime/zlib/contrib/minizip/ioapi.h diff -c /dev/null llvm/runtime/zlib/contrib/minizip/ioapi.h:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/minizip/ioapi.h Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,75 ---- + /* ioapi.h -- IO base function header for compress/uncompress .zip + files using zlib + zip or unzip API + + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant + */ + + #ifndef _ZLIBIOAPI_H + #define _ZLIBIOAPI_H + + + #define ZLIB_FILEFUNC_SEEK_CUR (1) + #define ZLIB_FILEFUNC_SEEK_END (2) + #define ZLIB_FILEFUNC_SEEK_SET (0) + + #define ZLIB_FILEFUNC_MODE_READ (1) + #define ZLIB_FILEFUNC_MODE_WRITE (2) + #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) + + #define ZLIB_FILEFUNC_MODE_EXISTING (4) + #define ZLIB_FILEFUNC_MODE_CREATE (8) + + + #ifndef ZCALLBACK + + #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) + #define ZCALLBACK CALLBACK + #else + #define ZCALLBACK + #endif + #endif + + #ifdef __cplusplus + extern "C" { + #endif + + typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); + typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); + typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); + typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); + typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); + typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); + typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); + + typedef struct zlib_filefunc_def_s + { + open_file_func zopen_file; + read_file_func zread_file; + write_file_func zwrite_file; + tell_file_func ztell_file; + seek_file_func zseek_file; + close_file_func zclose_file; + testerror_file_func zerror_file; + voidpf opaque; + } zlib_filefunc_def; + + + + void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); + + #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) + #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) + #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) + #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) + #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) + #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) + + + #ifdef __cplusplus + } + #endif + + #endif + Index: llvm/runtime/zlib/contrib/minizip/iowin32.c diff -c /dev/null llvm/runtime/zlib/contrib/minizip/iowin32.c:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/minizip/iowin32.c Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,270 ---- + /* iowin32.c -- IO base function header for compress/uncompress .zip + files using zlib + zip or unzip API + This IO API version uses the Win32 API (for Microsoft Windows) + + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant + */ + + #include + + #include "zlib.h" + #include "ioapi.h" + #include "iowin32.h" + + #ifndef INVALID_HANDLE_VALUE + #define INVALID_HANDLE_VALUE (0xFFFFFFFF) + #endif + + #ifndef INVALID_SET_FILE_POINTER + #define INVALID_SET_FILE_POINTER ((DWORD)-1) + #endif + + voidpf ZCALLBACK win32_open_file_func OF(( + voidpf opaque, + const char* filename, + int mode)); + + uLong ZCALLBACK win32_read_file_func OF(( + voidpf opaque, + voidpf stream, + void* buf, + uLong size)); + + uLong ZCALLBACK win32_write_file_func OF(( + voidpf opaque, + voidpf stream, + const void* buf, + uLong size)); + + long ZCALLBACK win32_tell_file_func OF(( + voidpf opaque, + voidpf stream)); + + long ZCALLBACK win32_seek_file_func OF(( + voidpf opaque, + voidpf stream, + uLong offset, + int origin)); + + int ZCALLBACK win32_close_file_func OF(( + voidpf opaque, + voidpf stream)); + + int ZCALLBACK win32_error_file_func OF(( + voidpf opaque, + voidpf stream)); + + typedef struct + { + HANDLE hf; + int error; + } WIN32FILE_IOWIN; + + voidpf ZCALLBACK win32_open_file_func (opaque, filename, mode) + voidpf opaque; + const char* filename; + int mode; + { + const char* mode_fopen = NULL; + DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; + HANDLE hFile = 0; + voidpf ret=NULL; + + dwDesiredAccess = dwShareMode = dwFlagsAndAttributes = 0; + + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) + { + dwDesiredAccess = GENERIC_READ; + dwCreationDisposition = OPEN_EXISTING; + dwShareMode = FILE_SHARE_READ; + } + else + if (mode & ZLIB_FILEFUNC_MODE_EXISTING) + { + dwDesiredAccess = GENERIC_WRITE | GENERIC_READ; + dwCreationDisposition = OPEN_EXISTING; + } + else + if (mode & ZLIB_FILEFUNC_MODE_CREATE) + { + dwDesiredAccess = GENERIC_WRITE | GENERIC_READ; + dwCreationDisposition = CREATE_ALWAYS; + } + + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, + dwCreationDisposition, dwFlagsAndAttributes, NULL); + + if (hFile == INVALID_HANDLE_VALUE) + hFile = NULL; + + if (hFile != NULL) + { + WIN32FILE_IOWIN w32fiow; + w32fiow.hf = hFile; + w32fiow.error = 0; + ret = malloc(sizeof(WIN32FILE_IOWIN)); + if (ret==NULL) + CloseHandle(hFile); + else *((WIN32FILE_IOWIN*)ret) = w32fiow; + } + return ret; + } + + + uLong ZCALLBACK win32_read_file_func (opaque, stream, buf, size) + voidpf opaque; + voidpf stream; + void* buf; + uLong size; + { + uLong ret=0; + HANDLE hFile = NULL; + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + if (hFile != NULL) + if (!ReadFile(hFile, buf, size, &ret, NULL)) + { + DWORD dwErr = GetLastError(); + if (dwErr == ERROR_HANDLE_EOF) + dwErr = 0; + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + } + + return ret; + } + + + uLong ZCALLBACK win32_write_file_func (opaque, stream, buf, size) + voidpf opaque; + voidpf stream; + const void* buf; + uLong size; + { + uLong ret=0; + HANDLE hFile = NULL; + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + + if (hFile !=NULL) + if (!WriteFile(hFile, buf, size, &ret, NULL)) + { + DWORD dwErr = GetLastError(); + if (dwErr == ERROR_HANDLE_EOF) + dwErr = 0; + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + } + + return ret; + } + + long ZCALLBACK win32_tell_file_func (opaque, stream) + voidpf opaque; + voidpf stream; + { + long ret=-1; + HANDLE hFile = NULL; + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + if (hFile != NULL) + { + DWORD dwSet = SetFilePointer(hFile, 0, NULL, FILE_CURRENT); + if (dwSet == INVALID_SET_FILE_POINTER) + { + DWORD dwErr = GetLastError(); + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + ret = -1; + } + else + ret=(long)dwSet; + } + return ret; + } + + long ZCALLBACK win32_seek_file_func (opaque, stream, offset, origin) + voidpf opaque; + voidpf stream; + uLong offset; + int origin; + { + DWORD dwMoveMethod=0xFFFFFFFF; + HANDLE hFile = NULL; + + long ret=-1; + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + switch (origin) + { + case ZLIB_FILEFUNC_SEEK_CUR : + dwMoveMethod = FILE_CURRENT; + break; + case ZLIB_FILEFUNC_SEEK_END : + dwMoveMethod = FILE_END; + break; + case ZLIB_FILEFUNC_SEEK_SET : + dwMoveMethod = FILE_BEGIN; + break; + default: return -1; + } + + if (hFile != NULL) + { + DWORD dwSet = SetFilePointer(hFile, offset, NULL, dwMoveMethod); + if (dwSet == INVALID_SET_FILE_POINTER) + { + DWORD dwErr = GetLastError(); + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + ret = -1; + } + else + ret=0; + } + return ret; + } + + int ZCALLBACK win32_close_file_func (opaque, stream) + voidpf opaque; + voidpf stream; + { + int ret=-1; + + if (stream!=NULL) + { + HANDLE hFile; + hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + if (hFile != NULL) + { + CloseHandle(hFile); + ret=0; + } + free(stream); + } + return ret; + } + + int ZCALLBACK win32_error_file_func (opaque, stream) + voidpf opaque; + voidpf stream; + { + int ret=-1; + if (stream!=NULL) + { + ret = ((WIN32FILE_IOWIN*)stream) -> error; + } + return ret; + } + + void fill_win32_filefunc (pzlib_filefunc_def) + zlib_filefunc_def* pzlib_filefunc_def; + { + pzlib_filefunc_def->zopen_file = win32_open_file_func; + pzlib_filefunc_def->zread_file = win32_read_file_func; + pzlib_filefunc_def->zwrite_file = win32_write_file_func; + pzlib_filefunc_def->ztell_file = win32_tell_file_func; + pzlib_filefunc_def->zseek_file = win32_seek_file_func; + pzlib_filefunc_def->zclose_file = win32_close_file_func; + pzlib_filefunc_def->zerror_file = win32_error_file_func; + pzlib_filefunc_def->opaque=NULL; + } Index: llvm/runtime/zlib/contrib/minizip/iowin32.h diff -c /dev/null llvm/runtime/zlib/contrib/minizip/iowin32.h:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/minizip/iowin32.h Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,21 ---- + /* iowin32.h -- IO base function header for compress/uncompress .zip + files using zlib + zip or unzip API + This IO API version uses the Win32 API (for Microsoft Windows) + + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant + */ + + #include + + + #ifdef __cplusplus + extern "C" { + #endif + + void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); + + #ifdef __cplusplus + } + #endif Index: llvm/runtime/zlib/contrib/minizip/miniunz.c diff -c /dev/null llvm/runtime/zlib/contrib/minizip/miniunz.c:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/minizip/miniunz.c Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,556 ---- + #include + #include + #include + #include + #include + #include + + #ifdef unix + # include + # include + #else + # include + # include + #endif + + #include "unzip.h" + + #define CASESENSITIVITY (0) + #define WRITEBUFFERSIZE (8192) + #define MAXFILENAME (256) + + #ifdef WIN32 + #define USEWIN32IOAPI + #include "iowin32.h" + #endif + /* + mini unzip, demo of unzip package + + usage : + Usage : miniunz [-exvlo] file.zip [file_to_extract] + + list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT + if it exists + */ + + + /* change_file_date : change the date/time of a file + filename : the filename of the file where date/time must be modified + dosdate : the new date at the MSDos format (4 bytes) + tmu_date : the SAME new date at the tm_unz format */ + void change_file_date(filename,dosdate,tmu_date) + const char *filename; + uLong dosdate; + tm_unz tmu_date; + { + #ifdef WIN32 + HANDLE hFile; + FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; + + hFile = CreateFile(filename,GENERIC_READ | GENERIC_WRITE, + 0,NULL,OPEN_EXISTING,0,NULL); + GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite); + DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal); + LocalFileTimeToFileTime(&ftLocal,&ftm); + SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); + CloseHandle(hFile); + #else + #ifdef unix + struct utimbuf ut; + struct tm newdate; + newdate.tm_sec = tmu_date.tm_sec; + newdate.tm_min=tmu_date.tm_min; + newdate.tm_hour=tmu_date.tm_hour; + newdate.tm_mday=tmu_date.tm_mday; + newdate.tm_mon=tmu_date.tm_mon; + if (tmu_date.tm_year > 1900) + newdate.tm_year=tmu_date.tm_year - 1900; + else + newdate.tm_year=tmu_date.tm_year ; + newdate.tm_isdst=-1; + + ut.actime=ut.modtime=mktime(&newdate); + utime(filename,&ut); + #endif + #endif + } + + + /* mymkdir and change_file_date are not 100 % portable + As I don't know well Unix, I wait feedback for the unix portion */ + + int mymkdir(dirname) + const char* dirname; + { + int ret=0; + #ifdef WIN32 + ret = mkdir(dirname); + #else + #ifdef unix + ret = mkdir (dirname,0775); + #endif + #endif + return ret; + } + + int makedir (newdir) + char *newdir; + { + char *buffer ; + char *p; + int len = (int)strlen(newdir); + + if (len <= 0) + return 0; + + buffer = (char*)malloc(len+1); + strcpy(buffer,newdir); + + if (buffer[len-1] == '/') { + buffer[len-1] = '\0'; + } + if (mymkdir(buffer) == 0) + { + free(buffer); + return 1; + } + + p = buffer+1; + while (1) + { + char hold; + + while(*p && *p != '\\' && *p != '/') + p++; + hold = *p; + *p = 0; + if ((mymkdir(buffer) == -1) && (errno == ENOENT)) + { + printf("couldn't create directory %s\n",buffer); + free(buffer); + return 0; + } + if (hold == 0) + break; + *p++ = hold; + } + free(buffer); + return 1; + } + + void do_banner() + { + printf("MiniUnz 1.00, demo of zLib + Unz package written by Gilles Vollant\n"); + printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); + } + + void do_help() + { + printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.]\n\n" \ + " -e Extract without pathname (junk paths)\n" \ + " -x Extract with pathname\n" \ + " -v list files\n" \ + " -l list files\n" \ + " -o overwrite files without prompting\n" \ + " -p extract crypted file using password\n\n"); + } + + + int do_list(uf) + unzFile uf; + { + uLong i; + unz_global_info gi; + int err; + + err = unzGetGlobalInfo (uf,&gi); + if (err!=UNZ_OK) + printf("error %d with zipfile in unzGetGlobalInfo \n",err); + printf(" Length Method Size Ratio Date Time CRC-32 Name\n"); + printf(" ------ ------ ---- ----- ---- ---- ------ ----\n"); + for (i=0;i0) + ratio = (file_info.compressed_size*100)/file_info.uncompressed_size; + + /* display a '*' if the file is crypted */ + if ((file_info.flag & 1) != 0) + charCrypt='*'; + + if (file_info.compression_method==0) + string_method="Stored"; + else + if (file_info.compression_method==Z_DEFLATED) + { + uInt iLevel=(uInt)((file_info.flag & 0x6)/2); + if (iLevel==0) + string_method="Defl:N"; + else if (iLevel==1) + string_method="Defl:X"; + else if ((iLevel==2) || (iLevel==3)) + string_method="Defl:F"; /* 2:fast , 3 : extra fast*/ + } + else + string_method="Unkn. "; + + printf("%7lu %6s%c%7lu %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n", + file_info.uncompressed_size,string_method, + charCrypt, + file_info.compressed_size, + ratio, + (uLong)file_info.tmu_date.tm_mon + 1, + (uLong)file_info.tmu_date.tm_mday, + (uLong)file_info.tmu_date.tm_year % 100, + (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min, + (uLong)file_info.crc,filename_inzip); + if ((i+1)='a') && (rep<='z')) + rep -= 0x20; + } + while ((rep!='Y') && (rep!='N') && (rep!='A')); + } + + if (rep == 'N') + skip = 1; + + if (rep == 'A') + *popt_overwrite=1; + } + + if ((skip==0) && (err==UNZ_OK)) + { + fout=fopen(write_filename,"wb"); + + /* some zipfile don't contain directory alone before file */ + if ((fout==NULL) && ((*popt_extract_without_path)==0) && + (filename_withoutpath!=(char*)filename_inzip)) + { + char c=*(filename_withoutpath-1); + *(filename_withoutpath-1)='\0'; + makedir(write_filename); + *(filename_withoutpath-1)=c; + fout=fopen(write_filename,"wb"); + } + + if (fout==NULL) + { + printf("error opening %s\n",write_filename); + } + } + + if (fout!=NULL) + { + printf(" extracting: %s\n",write_filename); + + do + { + err = unzReadCurrentFile(uf,buf,size_buf); + if (err<0) + { + printf("error %d with zipfile in unzReadCurrentFile\n",err); + break; + } + if (err>0) + if (fwrite(buf,err,1,fout)!=1) + { + printf("error in writing extracted file\n"); + err=UNZ_ERRNO; + break; + } + } + while (err>0); + if (fout) + fclose(fout); + + if (err==0) + change_file_date(write_filename,file_info.dosDate, + file_info.tmu_date); + } + + if (err==UNZ_OK) + { + err = unzCloseCurrentFile (uf); + if (err!=UNZ_OK) + { + printf("error %d with zipfile in unzCloseCurrentFile\n",err); + } + } + else + unzCloseCurrentFile(uf); /* don't lose the error */ + } + + free(buf); + return err; + } + + + int do_extract(uf,opt_extract_without_path,opt_overwrite,password) + unzFile uf; + int opt_extract_without_path; + int opt_overwrite; + const char* password; + { + uLong i; + unz_global_info gi; + int err; + FILE* fout=NULL; + + err = unzGetGlobalInfo (uf,&gi); + if (err!=UNZ_OK) + printf("error %d with zipfile in unzGetGlobalInfo \n",err); + + for (i=0;i + #include + #include + #include + #include + #include + + #ifdef unix + # include + # include + # include + # include + #else + # include + # include + #endif + + #include "zip.h" + + #ifdef WIN32 + #define USEWIN32IOAPI + #include "iowin32.h" + #endif + + + + #define WRITEBUFFERSIZE (16384) + #define MAXFILENAME (256) + + #ifdef WIN32 + uLong filetime(f, tmzip, dt) + char *f; /* name of file to get info on */ + tm_zip *tmzip; /* return value: access, modific. and creation times */ + uLong *dt; /* dostime */ + { + int ret = 0; + { + FILETIME ftLocal; + HANDLE hFind; + WIN32_FIND_DATA ff32; + + hFind = FindFirstFile(f,&ff32); + if (hFind != INVALID_HANDLE_VALUE) + { + FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal); + FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0); + FindClose(hFind); + ret = 1; + } + } + return ret; + } + #else + #ifdef unix + uLong filetime(f, tmzip, dt) + char *f; /* name of file to get info on */ + tm_zip *tmzip; /* return value: access, modific. and creation times */ + uLong *dt; /* dostime */ + { + int ret=0; + struct stat s; /* results of stat() */ + struct tm* filedate; + time_t tm_t=0; + + if (strcmp(f,"-")!=0) + { + char name[MAXFILENAME+1]; + int len = strlen(f); + + strncpy(name, f,MAXFILENAME-1); + /* strncpy doesnt append the trailing NULL, of the string is too long. */ + name[ MAXFILENAME ] = '\0'; + + if (name[len - 1] == '/') + name[len - 1] = '\0'; + /* not all systems allow stat'ing a file with / appended */ + if (stat(name,&s)==0) + { + tm_t = s.st_mtime; + ret = 1; + } + } + filedate = localtime(&tm_t); + + tmzip->tm_sec = filedate->tm_sec; + tmzip->tm_min = filedate->tm_min; + tmzip->tm_hour = filedate->tm_hour; + tmzip->tm_mday = filedate->tm_mday; + tmzip->tm_mon = filedate->tm_mon ; + tmzip->tm_year = filedate->tm_year; + + return ret; + } + #else + uLong filetime(f, tmzip, dt) + char *f; /* name of file to get info on */ + tm_zip *tmzip; /* return value: access, modific. and creation times */ + uLong *dt; /* dostime */ + { + return 0; + } + #endif + #endif + + + + + int check_exist_file(filename) + const char* filename; + { + FILE* ftestexist; + int ret = 1; + ftestexist = fopen(filename,"rb"); + if (ftestexist==NULL) + ret = 0; + else + fclose(ftestexist); + return ret; + } + + void do_banner() + { + printf("MiniZip 1.00, demo of zLib + Zip package written by Gilles Vollant\n"); + printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); + } + + void do_help() + { + printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] file.zip [files_to_add]\n\n" \ + " -o Overwrite existing file.zip\n" \ + " -a Append to existing file.zip\n" \ + " -0 Store only\n" \ + " -1 Compress faster\n" \ + " -9 Compress better\n\n"); + } + + /* calculate the CRC32 of a file, + because to encrypt a file, we need known the CRC32 of the file before */ + int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc) + { + unsigned long calculate_crc=0; + int err=ZIP_OK; + FILE * fin = fopen(filenameinzip,"rb"); + unsigned long size_read = 0; + unsigned long total_read = 0; + if (fin==NULL) + { + err = ZIP_ERRNO; + } + + if (err == ZIP_OK) + do + { + err = ZIP_OK; + size_read = (int)fread(buf,1,size_buf,fin); + if (size_read < size_buf) + if (feof(fin)==0) + { + printf("error in reading %s\n",filenameinzip); + err = ZIP_ERRNO; + } + + if (size_read>0) + calculate_crc = crc32(calculate_crc,buf,size_read); + total_read += size_read; + + } while ((err == ZIP_OK) && (size_read>0)); + + if (fin) + fclose(fin); + + *result_crc=calculate_crc; + printf("file %s crc %x\n",filenameinzip,calculate_crc); + return err; + } + + int main(argc,argv) + int argc; + char *argv[]; + { + int i; + int opt_overwrite=0; + int opt_compress_level=Z_DEFAULT_COMPRESSION; + int zipfilenamearg = 0; + char filename_try[MAXFILENAME+16]; + int zipok; + int err=0; + int size_buf=0; + void* buf=NULL; + const char* password=NULL; + + + do_banner(); + if (argc==1) + { + do_help(); + return 0; + } + else + { + for (i=1;i='0') && (c<='9')) + opt_compress_level = c-'0'; + + if (((c=='p') || (c=='P')) && (i+1='a') && (rep<='z')) + rep -= 0x20; + } + while ((rep!='Y') && (rep!='N') && (rep!='A')); + if (rep=='N') + zipok = 0; + if (rep=='A') + opt_overwrite = 2; + } + } + + if (zipok==1) + { + zipFile zf; + int errclose; + # ifdef USEWIN32IOAPI + zlib_filefunc_def ffunc; + fill_win32_filefunc(&ffunc); + zf = zipOpen2(filename_try,(opt_overwrite==2) ? 2 : 0,NULL,&ffunc); + # else + zf = zipOpen(filename_try,(opt_overwrite==2) ? 2 : 0); + # endif + + if (zf == NULL) + { + printf("error opening %s\n",filename_try); + err= ZIP_ERRNO; + } + else + printf("creating %s\n",filename_try); + + for (i=zipfilenamearg+1;(i0) + { + err = zipWriteInFileInZip (zf,buf,size_read); + if (err<0) + { + printf("error in writing %s in the zipfile\n", + filenameinzip); + } + + } + } while ((err == ZIP_OK) && (size_read>0)); + + if (fin) + fclose(fin); + + if (err<0) + err=ZIP_ERRNO; + else + { + err = zipCloseFileInZip(zf); + if (err!=ZIP_OK) + printf("error in closing %s in the zipfile\n", + filenameinzip); + } + } + } + errclose = zipClose(zf,NULL); + if (errclose != ZIP_OK) + printf("error in closing %s\n",filename_try); + } + + free(buf); + return 0; + } Index: llvm/runtime/zlib/contrib/minizip/unzip.c diff -c /dev/null llvm/runtime/zlib/contrib/minizip/unzip.c:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/minizip/unzip.c Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,1546 ---- + /* unzip.c -- IO for uncompress .zip files using zlib + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant + + Read unzip.h for more info + */ + + /* Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of + compatibility with older software. The following is from the original crypt.c. Code + woven in by Terry Thorsen 1/2003. + */ + /* + Copyright (c) 1990-2000 Info-ZIP. All rights reserved. + + See the accompanying file LICENSE, version 2000-Apr-09 or later + (the contents of which are also included in zip.h) for terms of use. + If, for some reason, all these files are missing, the Info-ZIP license + also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html + */ + /* + crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] + + The encryption/decryption parts of this source code (as opposed to the + non-echoing password parts) were originally written in Europe. The + whole source package can be freely distributed, including from the USA. + (Prior to January 2000, re-export from the US was a violation of US law.) + */ + + /* + This encryption code is a direct transcription of the algorithm from + Roger Schlafly, described by Phil Katz in the file appnote.txt. This + file (appnote.txt) is distributed with the PKZIP program (even in the + version without encryption capabilities). + */ + + + #include + #include + #include + #include "zlib.h" + #include "unzip.h" + + #ifdef STDC + # include + # include + # include + #endif + #ifdef NO_ERRNO_H + extern int errno; + #else + # include + #endif + + + #ifndef local + # define local static + #endif + /* compile with -Dlocal if your debugger can't find static symbols */ + + + #ifndef CASESENSITIVITYDEFAULT_NO + # if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) + # define CASESENSITIVITYDEFAULT_NO + # endif + #endif + + + #ifndef UNZ_BUFSIZE + #define UNZ_BUFSIZE (16384) + #endif + + #ifndef UNZ_MAXFILENAMEINZIP + #define UNZ_MAXFILENAMEINZIP (256) + #endif + + #ifndef ALLOC + # define ALLOC(size) (malloc(size)) + #endif + #ifndef TRYFREE + # define TRYFREE(p) {if (p) free(p);} + #endif + + #define SIZECENTRALDIRITEM (0x2e) + #define SIZEZIPLOCALHEADER (0x1e) + + + + + const char unz_copyright[] = + " unzip 1.00 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; + + /* unz_file_info_interntal contain internal info about a file in zipfile*/ + typedef struct unz_file_info_internal_s + { + uLong offset_curfile;/* relative offset of local header 4 bytes */ + } unz_file_info_internal; + + + /* file_in_zip_read_info_s contain internal information about a file in zipfile, + when reading and decompress it */ + typedef struct + { + char *read_buffer; /* internal buffer for compressed data */ + z_stream stream; /* zLib stream structure for inflate */ + + uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ + uLong stream_initialised; /* flag set if stream structure is initialised*/ + + uLong offset_local_extrafield;/* offset of the local extra field */ + uInt size_local_extrafield;/* size of the local extra field */ + uLong pos_local_extrafield; /* position in the local extra field in read*/ + + uLong crc32; /* crc32 of all data uncompressed */ + uLong crc32_wait; /* crc32 we must obtain after decompress all */ + uLong rest_read_compressed; /* number of byte to be decompressed */ + uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ + zlib_filefunc_def z_filefunc; + voidpf filestream; /* io structore of the zipfile */ + uLong compression_method; /* compression method (0==store) */ + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + int raw; + } file_in_zip_read_info_s; + + + /* unz_s contain internal information about the zipfile + */ + typedef struct + { + zlib_filefunc_def z_filefunc; + voidpf filestream; /* io structore of the zipfile */ + unz_global_info gi; /* public global information */ + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + uLong num_file; /* number of the current file in the zipfile*/ + uLong pos_in_central_dir; /* pos of the current file in the central dir*/ + uLong current_file_ok; /* flag about the usability of the current file*/ + uLong central_pos; /* position of the beginning of the central dir*/ + + uLong size_central_dir; /* size of the central directory */ + uLong offset_central_dir; /* offset of start of central directory with + respect to the starting disk number */ + + unz_file_info cur_file_info; /* public info about the current file in zip*/ + unz_file_info_internal cur_file_info_internal; /* private info about it*/ + file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current + file if we are decompressing it */ + int encrypted; + # ifndef NOUNCRYPT + unsigned long keys[3]; /* keys defining the pseudo-random sequence */ + const unsigned long* pcrc_32_tab; + # endif + } unz_s; + + + #ifndef NOUNCRYPT + #include "crypt.h" + #endif + + /* =========================================================================== + Read a byte from a gz_stream; update next_in and avail_in. Return EOF + for end of file. + IN assertion: the stream s has been sucessfully opened for reading. + */ + + + local int unzlocal_getByte OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, + int *pi)); + + local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + int *pi; + { + unsigned char c; + int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); + if (err==1) + { + *pi = (int)c; + return UNZ_OK; + } + else + { + if (ZERROR(*pzlib_filefunc_def,filestream)) + return UNZ_ERRNO; + else + return UNZ_EOF; + } + } + + + /* =========================================================================== + Reads a long in LSB order from the given gz_stream. Sets + */ + local int unzlocal_getShort OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, + uLong *pX)); + + local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + uLong *pX; + { + uLong x ; + int i; + int err; + + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<8; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; + } + + local int unzlocal_getLong OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, + uLong *pX)); + + local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + uLong *pX; + { + uLong x ; + int i; + int err; + + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<8; + + if (err==UNZ_OK) + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<16; + + if (err==UNZ_OK) + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<24; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; + } + + + /* My own strcmpi / strcasecmp */ + local int strcmpcasenosensitive_internal (fileName1,fileName2) + const char* fileName1; + const char* fileName2; + { + for (;;) + { + char c1=*(fileName1++); + char c2=*(fileName2++); + if ((c1>='a') && (c1<='z')) + c1 -= 0x20; + if ((c2>='a') && (c2<='z')) + c2 -= 0x20; + if (c1=='\0') + return ((c2=='\0') ? 0 : -1); + if (c2=='\0') + return 1; + if (c1c2) + return 1; + } + } + + + #ifdef CASESENSITIVITYDEFAULT_NO + #define CASESENSITIVITYDEFAULTVALUE 2 + #else + #define CASESENSITIVITYDEFAULTVALUE 1 + #endif + + #ifndef STRCMPCASENOSENTIVEFUNCTION + #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal + #endif + + /* + Compare two filename (fileName1,fileName2). + If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) + If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + or strcasecmp) + If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + (like 1 on Unix, 2 on Windows) + + */ + extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) + const char* fileName1; + const char* fileName2; + int iCaseSensitivity; + { + if (iCaseSensitivity==0) + iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; + + if (iCaseSensitivity==1) + return strcmp(fileName1,fileName2); + + return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); + } + + #ifndef BUFREADCOMMENT + #define BUFREADCOMMENT (0x400) + #endif + + /* + Locate the Central directory of a zipfile (at the end, just before + the global comment) + */ + local uLong unzlocal_SearchCentralDir OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream)); + + local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + { + unsigned char* buf; + uLong uSizeFile; + uLong uBackRead; + uLong uMaxBack=0xffff; /* maximum size of global comment */ + uLong uPosFound=0; + + if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) + return 0; + + + uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; + + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; + + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); + if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) + break; + + if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) + break; + + for (i=(int)uReadSize-3; (i--)>0;) + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) + { + uPosFound = uReadPos+i; + break; + } + + if (uPosFound!=0) + break; + } + TRYFREE(buf); + return uPosFound; + } + + /* + Open a Zip file. path contain the full pathname (by example, + on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer + "zlib/zlib114.zip". + If the zipfile cannot be opened (file doesn't exist or in not valid), the + return value is NULL. + Else, the return value is a unzFile Handle, usable with other function + of this unzip package. + */ + extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def) + const char *path; + zlib_filefunc_def* pzlib_filefunc_def; + { + unz_s us; + unz_s *s; + uLong central_pos,uL; + + uLong number_disk; /* number of the current dist, used for + spaning ZIP, unsupported, always 0*/ + uLong number_disk_with_CD; /* number the the disk with central dir, used + for spaning ZIP, unsupported, always 0*/ + uLong number_entry_CD; /* total number of entries in + the central dir + (same than number_entry on nospan) */ + + int err=UNZ_OK; + + if (unz_copyright[0]!=' ') + return NULL; + + if (pzlib_filefunc_def==NULL) + fill_fopen_filefunc(&us.z_filefunc); + else + us.z_filefunc = *pzlib_filefunc_def; + + us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque, + path, + ZLIB_FILEFUNC_MODE_READ | + ZLIB_FILEFUNC_MODE_EXISTING); + if (us.filestream==NULL) + return NULL; + + central_pos = unzlocal_SearchCentralDir(&us.z_filefunc,us.filestream); + if (central_pos==0) + err=UNZ_ERRNO; + + if (ZSEEK(us.z_filefunc, us.filestream, + central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) + err=UNZ_ERRNO; + + /* the signature, already checked */ + if (unzlocal_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of this disk */ + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of the disk with the start of the central directory */ + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central dir on this disk */ + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central dir */ + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + if ((number_entry_CD!=us.gi.number_entry) || + (number_disk_with_CD!=0) || + (number_disk!=0)) + err=UNZ_BADZIPFILE; + + /* size of the central directory */ + if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; + + /* offset of start of central directory with respect to the + starting disk number */ + if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; + + /* zipfile comment length */ + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK) + err=UNZ_ERRNO; + + if ((central_pospfile_in_zip_read!=NULL) + unzCloseCurrentFile(file); + + ZCLOSE(s->z_filefunc, s->filestream); + TRYFREE(s); + return UNZ_OK; + } + + + /* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. */ + extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) + unzFile file; + unz_global_info *pglobal_info; + { + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + *pglobal_info=s->gi; + return UNZ_OK; + } + + + /* + Translate date/time from Dos format to tm_unz (readable more easilty) + */ + local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) + uLong ulDosDate; + tm_unz* ptm; + { + uLong uDate; + uDate = (uLong)(ulDosDate>>16); + ptm->tm_mday = (uInt)(uDate&0x1f) ; + ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; + ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; + + ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); + ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; + ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; + } + + /* + Get Info about the current file in the zipfile, with internal only info + */ + local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, + unz_file_info *pfile_info, + unz_file_info_internal + *pfile_info_internal, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); + + local int unzlocal_GetCurrentFileInfoInternal (file, + pfile_info, + pfile_info_internal, + szFileName, fileNameBufferSize, + extraField, extraFieldBufferSize, + szComment, commentBufferSize) + unzFile file; + unz_file_info *pfile_info; + unz_file_info_internal *pfile_info_internal; + char *szFileName; + uLong fileNameBufferSize; + void *extraField; + uLong extraFieldBufferSize; + char *szComment; + uLong commentBufferSize; + { + unz_s* s; + unz_file_info file_info; + unz_file_info_internal file_info_internal; + int err=UNZ_OK; + uLong uMagic; + long lSeek=0; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (ZSEEK(s->z_filefunc, s->filestream, + s->pos_in_central_dir+s->byte_before_the_zipfile, + ZLIB_FILEFUNC_SEEK_SET)!=0) + err=UNZ_ERRNO; + + + /* we check the magic */ + if (err==UNZ_OK) + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x02014b50) + err=UNZ_BADZIPFILE; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK) + err=UNZ_ERRNO; + + unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) + err=UNZ_ERRNO; + + lSeek+=file_info.size_filename; + if ((err==UNZ_OK) && (szFileName!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_filename0) && (fileNameBufferSize>0)) + if (ZREAD(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead) + err=UNZ_ERRNO; + lSeek -= uSizeRead; + } + + + if ((err==UNZ_OK) && (extraField!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_extraz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) + if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead) + err=UNZ_ERRNO; + lSeek += file_info.size_file_extra - uSizeRead; + } + else + lSeek+=file_info.size_file_extra; + + + if ((err==UNZ_OK) && (szComment!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_commentz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + if ((file_info.size_file_comment>0) && (commentBufferSize>0)) + if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) + err=UNZ_ERRNO; + lSeek+=file_info.size_file_comment - uSizeRead; + } + else + lSeek+=file_info.size_file_comment; + + if ((err==UNZ_OK) && (pfile_info!=NULL)) + *pfile_info=file_info; + + if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) + *pfile_info_internal=file_info_internal; + + return err; + } + + + + /* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. + */ + extern int ZEXPORT unzGetCurrentFileInfo (file, + pfile_info, + szFileName, fileNameBufferSize, + extraField, extraFieldBufferSize, + szComment, commentBufferSize) + unzFile file; + unz_file_info *pfile_info; + char *szFileName; + uLong fileNameBufferSize; + void *extraField; + uLong extraFieldBufferSize; + char *szComment; + uLong commentBufferSize; + { + return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, + szFileName,fileNameBufferSize, + extraField,extraFieldBufferSize, + szComment,commentBufferSize); + } + + /* + Set the current file of the zipfile to the first file. + return UNZ_OK if there is no problem + */ + extern int ZEXPORT unzGoToFirstFile (file) + unzFile file; + { + int err=UNZ_OK; + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + s->pos_in_central_dir=s->offset_central_dir; + s->num_file=0; + err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; + } + + /* + Set the current file of the zipfile to the next file. + return UNZ_OK if there is no problem + return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. + */ + extern int ZEXPORT unzGoToNextFile (file) + unzFile file; + { + unz_s* s; + int err; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + if (s->num_file+1==s->gi.number_entry) + return UNZ_END_OF_LIST_OF_FILE; + + s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; + s->num_file++; + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; + } + + + /* + Try locate the file szFileName in the zipfile. + For the iCaseSensitivity signification, see unzipStringFileNameCompare + + return value : + UNZ_OK if the file is found. It becomes the current file. + UNZ_END_OF_LIST_OF_FILE if the file is not found + */ + extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) + unzFile file; + const char *szFileName; + int iCaseSensitivity; + { + unz_s* s; + int err; + + /* We remember the 'current' position in the file so that we can jump + * back there if we fail. + */ + unz_file_info cur_file_infoSaved; + unz_file_info_internal cur_file_info_internalSaved; + uLong num_fileSaved; + uLong pos_in_central_dirSaved; + + + if (file==NULL) + return UNZ_PARAMERROR; + + if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) + return UNZ_PARAMERROR; + + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + + /* Save the current state */ + num_fileSaved = s->num_file; + pos_in_central_dirSaved = s->pos_in_central_dir; + cur_file_infoSaved = s->cur_file_info; + cur_file_info_internalSaved = s->cur_file_info_internal; + + err = unzGoToFirstFile(file); + + while (err == UNZ_OK) + { + char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; + err = unzGetCurrentFileInfo(file,NULL, + szCurrentFileName,sizeof(szCurrentFileName)-1, + NULL,0,NULL,0); + if (err == UNZ_OK) + { + if (unzStringFileNameCompare(szCurrentFileName, + szFileName,iCaseSensitivity)==0) + return UNZ_OK; + err = unzGoToNextFile(file); + } + } + + /* We failed, so restore the state of the 'current file' to where we + * were. + */ + s->num_file = num_fileSaved ; + s->pos_in_central_dir = pos_in_central_dirSaved ; + s->cur_file_info = cur_file_infoSaved; + s->cur_file_info_internal = cur_file_info_internalSaved; + return err; + } + + + /* + /////////////////////////////////////////// + // Contributed by Ryan Haksi (mailto://cryogen at infoserve.net) + // I need random access + // + // Further optimization could be realized by adding an ability + // to cache the directory in memory. The goal being a single + // comprehensive file read to put the file I need in a memory. + */ + + /* + typedef struct unz_file_pos_s + { + uLong pos_in_zip_directory; // offset in file + uLong num_of_file; // # of file + } unz_file_pos; + */ + + extern int ZEXPORT unzGetFilePos(file, file_pos) + unzFile file; + unz_file_pos* file_pos; + { + unz_s* s; + + if (file==NULL || file_pos==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + + file_pos->pos_in_zip_directory = s->pos_in_central_dir; + file_pos->num_of_file = s->num_file; + + return UNZ_OK; + } + + extern int ZEXPORT unzGoToFilePos(file, file_pos) + unzFile file; + unz_file_pos* file_pos; + { + unz_s* s; + int err; + + if (file==NULL || file_pos==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + + /* jump to the right spot */ + s->pos_in_central_dir = file_pos->pos_in_zip_directory; + s->num_file = file_pos->num_of_file; + + /* set the current file */ + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + /* return results */ + s->current_file_ok = (err == UNZ_OK); + return err; + } + + /* + // Unzip Helper Functions - should be here? + /////////////////////////////////////////// + */ + + /* + Read the local header of the current zipfile + Check the coherency of the local header and info in the end of central + directory about this file + store in *piSizeVar the size of extra info in local header + (filename and size of extra field data) + */ + local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, + poffset_local_extrafield, + psize_local_extrafield) + unz_s* s; + uInt* piSizeVar; + uLong *poffset_local_extrafield; + uInt *psize_local_extrafield; + { + uLong uMagic,uData,uFlags; + uLong size_filename; + uLong size_extra_field; + int err=UNZ_OK; + + *piSizeVar = 0; + *poffset_local_extrafield = 0; + *psize_local_extrafield = 0; + + if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + + s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) + return UNZ_ERRNO; + + + if (err==UNZ_OK) + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x04034b50) + err=UNZ_BADZIPFILE; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) + err=UNZ_ERRNO; + /* + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) + err=UNZ_BADZIPFILE; + */ + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) + err=UNZ_BADZIPFILE; + + if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && + (s->cur_file_info.compression_method!=Z_DEFLATED)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ + err=UNZ_ERRNO; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) + err=UNZ_BADZIPFILE; + + *piSizeVar += (uInt)size_filename; + + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK) + err=UNZ_ERRNO; + *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + + SIZEZIPLOCALHEADER + size_filename; + *psize_local_extrafield = (uInt)size_extra_field; + + *piSizeVar += (uInt)size_extra_field; + + return err; + } + + /* + Open for reading data the current file in the zipfile. + If there is no error and the file is opened, the return value is UNZ_OK. + */ + extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) + unzFile file; + int* method; + int* level; + int raw; + const char* password; + { + int err=UNZ_OK; + uInt iSizeVar; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uLong offset_local_extrafield; /* offset of the local extra field */ + uInt size_local_extrafield; /* size of the local extra field */ + # ifndef NOUNCRYPT + char source[12]; + # else + if (password != NULL) + return UNZ_PARAMERROR; + # endif + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_PARAMERROR; + + if (s->pfile_in_zip_read != NULL) + unzCloseCurrentFile(file); + + if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, + &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) + return UNZ_BADZIPFILE; + + pfile_in_zip_read_info = (file_in_zip_read_info_s*) + ALLOC(sizeof(file_in_zip_read_info_s)); + if (pfile_in_zip_read_info==NULL) + return UNZ_INTERNALERROR; + + pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); + pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; + pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; + pfile_in_zip_read_info->pos_local_extrafield=0; + pfile_in_zip_read_info->raw=raw; + + if (pfile_in_zip_read_info->read_buffer==NULL) + { + TRYFREE(pfile_in_zip_read_info); + return UNZ_INTERNALERROR; + } + + pfile_in_zip_read_info->stream_initialised=0; + + if (method!=NULL) + *method = (int)s->cur_file_info.compression_method; + + if (level!=NULL) + { + *level = 6; + switch (s->cur_file_info.flag & 0x06) + { + case 6 : *level = 1; break; + case 4 : *level = 2; break; + case 2 : *level = 9; break; + } + } + + if ((s->cur_file_info.compression_method!=0) && + (s->cur_file_info.compression_method!=Z_DEFLATED)) + err=UNZ_BADZIPFILE; + + pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; + pfile_in_zip_read_info->crc32=0; + pfile_in_zip_read_info->compression_method = + s->cur_file_info.compression_method; + pfile_in_zip_read_info->filestream=s->filestream; + pfile_in_zip_read_info->z_filefunc=s->z_filefunc; + pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; + + pfile_in_zip_read_info->stream.total_out = 0; + + if ((s->cur_file_info.compression_method==Z_DEFLATED) && + (!raw)) + { + pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; + pfile_in_zip_read_info->stream.zfree = (free_func)0; + pfile_in_zip_read_info->stream.opaque = (voidpf)0; + pfile_in_zip_read_info->stream.next_in = (voidpf)0; + pfile_in_zip_read_info->stream.avail_in = 0; + + err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); + if (err == Z_OK) + pfile_in_zip_read_info->stream_initialised=1; + else + return err; + /* windowBits is passed < 0 to tell that there is no zlib header. + * Note that in this case inflate *requires* an extra "dummy" byte + * after the compressed stream in order to complete decompression and + * return Z_STREAM_END. + * In unzip, i don't wait absolutely Z_STREAM_END because I known the + * size of both compressed and uncompressed data + */ + } + pfile_in_zip_read_info->rest_read_compressed = + s->cur_file_info.compressed_size ; + pfile_in_zip_read_info->rest_read_uncompressed = + s->cur_file_info.uncompressed_size ; + + + pfile_in_zip_read_info->pos_in_zipfile = + s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + + iSizeVar; + + pfile_in_zip_read_info->stream.avail_in = (uInt)0; + + s->pfile_in_zip_read = pfile_in_zip_read_info; + + # ifndef NOUNCRYPT + if (password != NULL) + { + int i; + s->pcrc_32_tab = get_crc_table(); + init_keys(password,s->keys,s->pcrc_32_tab); + if (ZSEEK(s->z_filefunc, s->filestream, + s->pfile_in_zip_read->pos_in_zipfile + + s->pfile_in_zip_read->byte_before_the_zipfile, + SEEK_SET)!=0) + return UNZ_INTERNALERROR; + if(ZREAD(s->z_filefunc, s->filestream,source, 12)<12) + return UNZ_INTERNALERROR; + + for (i = 0; i<12; i++) + zdecode(s->keys,s->pcrc_32_tab,source[i]); + + s->pfile_in_zip_read->pos_in_zipfile+=12; + s->encrypted=1; + } + # endif + + + return UNZ_OK; + } + + extern int ZEXPORT unzOpenCurrentFile (file) + unzFile file; + { + return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); + } + + extern int ZEXPORT unzOpenCurrentFilePassword (file, password) + unzFile file; + const char* password; + { + return unzOpenCurrentFile3(file, NULL, NULL, 0, password); + } + + extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw) + unzFile file; + int* method; + int* level; + int raw; + { + return unzOpenCurrentFile3(file, method, level, raw, NULL); + } + + /* + Read bytes from the current file. + buf contain buffer where data must be copied + len the size of buf. + + return the number of byte copied if somes bytes are copied + return 0 if the end of file was reached + return <0 with error code if there is an error + (UNZ_ERRNO for IO error, or zLib error for uncompress error) + */ + extern int ZEXPORT unzReadCurrentFile (file, buf, len) + unzFile file; + voidp buf; + unsigned len; + { + int err=UNZ_OK; + uInt iRead = 0; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + + if ((pfile_in_zip_read_info->read_buffer == NULL)) + return UNZ_END_OF_LIST_OF_FILE; + if (len==0) + return 0; + + pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; + + pfile_in_zip_read_info->stream.avail_out = (uInt)len; + + if (len>pfile_in_zip_read_info->rest_read_uncompressed) + pfile_in_zip_read_info->stream.avail_out = + (uInt)pfile_in_zip_read_info->rest_read_uncompressed; + + while (pfile_in_zip_read_info->stream.avail_out>0) + { + if ((pfile_in_zip_read_info->stream.avail_in==0) && + (pfile_in_zip_read_info->rest_read_compressed>0)) + { + uInt uReadThis = UNZ_BUFSIZE; + if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; + if (uReadThis == 0) + return UNZ_EOF; + if (ZSEEK(pfile_in_zip_read_info->z_filefunc, + pfile_in_zip_read_info->filestream, + pfile_in_zip_read_info->pos_in_zipfile + + pfile_in_zip_read_info->byte_before_the_zipfile, + ZLIB_FILEFUNC_SEEK_SET)!=0) + return UNZ_ERRNO; + if (ZREAD(pfile_in_zip_read_info->z_filefunc, + pfile_in_zip_read_info->filestream, + pfile_in_zip_read_info->read_buffer, + uReadThis)!=uReadThis) + return UNZ_ERRNO; + + + # ifndef NOUNCRYPT + if(s->encrypted) + { + uInt i; + for(i=0;iread_buffer[i] = + zdecode(s->keys,s->pcrc_32_tab, + pfile_in_zip_read_info->read_buffer[i]); + } + # endif + + + pfile_in_zip_read_info->pos_in_zipfile += uReadThis; + + pfile_in_zip_read_info->rest_read_compressed-=uReadThis; + + pfile_in_zip_read_info->stream.next_in = + (Bytef*)pfile_in_zip_read_info->read_buffer; + pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; + } + + if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) + { + uInt uDoCopy,i ; + + if ((pfile_in_zip_read_info->stream.avail_in == 0) && + (pfile_in_zip_read_info->rest_read_compressed == 0)) + return (iRead==0) ? UNZ_EOF : iRead; + + if (pfile_in_zip_read_info->stream.avail_out < + pfile_in_zip_read_info->stream.avail_in) + uDoCopy = pfile_in_zip_read_info->stream.avail_out ; + else + uDoCopy = pfile_in_zip_read_info->stream.avail_in ; + + for (i=0;istream.next_out+i) = + *(pfile_in_zip_read_info->stream.next_in+i); + + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, + pfile_in_zip_read_info->stream.next_out, + uDoCopy); + pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; + pfile_in_zip_read_info->stream.avail_in -= uDoCopy; + pfile_in_zip_read_info->stream.avail_out -= uDoCopy; + pfile_in_zip_read_info->stream.next_out += uDoCopy; + pfile_in_zip_read_info->stream.next_in += uDoCopy; + pfile_in_zip_read_info->stream.total_out += uDoCopy; + iRead += uDoCopy; + } + else + { + uLong uTotalOutBefore,uTotalOutAfter; + const Bytef *bufBefore; + uLong uOutThis; + int flush=Z_SYNC_FLUSH; + + uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; + bufBefore = pfile_in_zip_read_info->stream.next_out; + + /* + if ((pfile_in_zip_read_info->rest_read_uncompressed == + pfile_in_zip_read_info->stream.avail_out) && + (pfile_in_zip_read_info->rest_read_compressed == 0)) + flush = Z_FINISH; + */ + err=inflate(&pfile_in_zip_read_info->stream,flush); + + uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; + uOutThis = uTotalOutAfter-uTotalOutBefore; + + pfile_in_zip_read_info->crc32 = + crc32(pfile_in_zip_read_info->crc32,bufBefore, + (uInt)(uOutThis)); + + pfile_in_zip_read_info->rest_read_uncompressed -= + uOutThis; + + iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); + + if (err==Z_STREAM_END) + return (iRead==0) ? UNZ_EOF : iRead; + if (err!=Z_OK) + break; + } + } + + if (err==Z_OK) + return iRead; + return err; + } + + + /* + Give the current position in uncompressed data + */ + extern z_off_t ZEXPORT unztell (file) + unzFile file; + { + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + return (z_off_t)pfile_in_zip_read_info->stream.total_out; + } + + + /* + return 1 if the end of file was reached, 0 elsewhere + */ + extern int ZEXPORT unzeof (file) + unzFile file; + { + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) + return 1; + else + return 0; + } + + + + /* + Read extra field from the current file (opened by unzOpenCurrentFile) + This is the local-header version of the extra field (sometimes, there is + more info in the local-header version than in the central-header) + + if buf==NULL, it return the size of the local extra field that can be read + + if buf!=NULL, len is the size of the buffer, the extra header is copied in + buf. + the return value is the number of bytes copied in buf, or (if <0) + the error code + */ + extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) + unzFile file; + voidp buf; + unsigned len; + { + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uInt read_now; + uLong size_to_read; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + size_to_read = (pfile_in_zip_read_info->size_local_extrafield - + pfile_in_zip_read_info->pos_local_extrafield); + + if (buf==NULL) + return (int)size_to_read; + + if (len>size_to_read) + read_now = (uInt)size_to_read; + else + read_now = (uInt)len ; + + if (read_now==0) + return 0; + + if (ZSEEK(pfile_in_zip_read_info->z_filefunc, + pfile_in_zip_read_info->filestream, + pfile_in_zip_read_info->offset_local_extrafield + + pfile_in_zip_read_info->pos_local_extrafield, + ZLIB_FILEFUNC_SEEK_SET)!=0) + return UNZ_ERRNO; + + if (ZREAD(pfile_in_zip_read_info->z_filefunc, + pfile_in_zip_read_info->filestream, + buf,size_to_read)!=size_to_read) + return UNZ_ERRNO; + + return (int)read_now; + } + + /* + Close the file in zip opened with unzipOpenCurrentFile + Return UNZ_CRCERROR if all the file was read but the CRC is not good + */ + extern int ZEXPORT unzCloseCurrentFile (file) + unzFile file; + { + int err=UNZ_OK; + + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + + if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) && + (!pfile_in_zip_read_info->raw)) + { + if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) + err=UNZ_CRCERROR; + } + + + TRYFREE(pfile_in_zip_read_info->read_buffer); + pfile_in_zip_read_info->read_buffer = NULL; + if (pfile_in_zip_read_info->stream_initialised) + inflateEnd(&pfile_in_zip_read_info->stream); + + pfile_in_zip_read_info->stream_initialised = 0; + TRYFREE(pfile_in_zip_read_info); + + s->pfile_in_zip_read=NULL; + + return err; + } + + + /* + Get the global comment string of the ZipFile, in the szComment buffer. + uSizeBuf is the size of the szComment buffer. + return the number of byte copied or an error code <0 + */ + extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) + unzFile file; + char *szComment; + uLong uSizeBuf; + { + int err=UNZ_OK; + unz_s* s; + uLong uReadThis ; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + + uReadThis = uSizeBuf; + if (uReadThis>s->gi.size_comment) + uReadThis = s->gi.size_comment; + + if (ZSEEK(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0) + return UNZ_ERRNO; + + if (uReadThis>0) + { + *szComment='\0'; + if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis) + return UNZ_ERRNO; + } + + if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) + *(szComment+s->gi.size_comment)='\0'; + return (int)uReadThis; + } Index: llvm/runtime/zlib/contrib/minizip/unzip.h diff -c /dev/null llvm/runtime/zlib/contrib/minizip/unzip.h:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/minizip/unzip.h Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,342 ---- + /* unzip.h -- IO for uncompress .zip files using zlib + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant + + This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g + WinZip, InfoZip tools and compatible. + Encryption and multi volume ZipFile (span) are not supported. + Old compressions used by old PKZip 1.x are not supported + + + I WAIT FEEDBACK at mail info at winimage.com + Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution + + Condition of use and distribution are the same than zlib : + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + + */ + + /* for more info about .ZIP format, see + http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip + http://www.info-zip.org/pub/infozip/doc/ + PkWare has also a specification at : + ftp://ftp.pkware.com/probdesc.zip + */ + + #ifndef _unz_H + #define _unz_H + + #ifdef __cplusplus + extern "C" { + #endif + + #ifndef _ZLIB_H + #include "zlib.h" + #endif + + #ifndef _ZLIBIOAPI_H + #include "ioapi.h" + #endif + + #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) + /* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ + typedef struct TagunzFile__ { int unused; } unzFile__; + typedef unzFile__ *unzFile; + #else + typedef voidp unzFile; + #endif + + + #define UNZ_OK (0) + #define UNZ_END_OF_LIST_OF_FILE (-100) + #define UNZ_ERRNO (Z_ERRNO) + #define UNZ_EOF (0) + #define UNZ_PARAMERROR (-102) + #define UNZ_BADZIPFILE (-103) + #define UNZ_INTERNALERROR (-104) + #define UNZ_CRCERROR (-105) + + /* tm_unz contain date/time info */ + typedef struct tm_unz_s + { + uInt tm_sec; /* seconds after the minute - [0,59] */ + uInt tm_min; /* minutes after the hour - [0,59] */ + uInt tm_hour; /* hours since midnight - [0,23] */ + uInt tm_mday; /* day of the month - [1,31] */ + uInt tm_mon; /* months since January - [0,11] */ + uInt tm_year; /* years - [1980..2044] */ + } tm_unz; + + /* unz_global_info structure contain global data about the ZIPfile + These data comes from the end of central dir */ + typedef struct unz_global_info_s + { + uLong number_entry; /* total number of entries in + the central dir on this disk */ + uLong size_comment; /* size of the global comment of the zipfile */ + } unz_global_info; + + + /* unz_file_info contain information about a file in the zipfile */ + typedef struct unz_file_info_s + { + uLong version; /* version made by 2 bytes */ + uLong version_needed; /* version needed to extract 2 bytes */ + uLong flag; /* general purpose bit flag 2 bytes */ + uLong compression_method; /* compression method 2 bytes */ + uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ + uLong crc; /* crc-32 4 bytes */ + uLong compressed_size; /* compressed size 4 bytes */ + uLong uncompressed_size; /* uncompressed size 4 bytes */ + uLong size_filename; /* filename length 2 bytes */ + uLong size_file_extra; /* extra field length 2 bytes */ + uLong size_file_comment; /* file comment length 2 bytes */ + + uLong disk_num_start; /* disk number start 2 bytes */ + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ + + tm_unz tmu_date; + } unz_file_info; + + extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, + const char* fileName2, + int iCaseSensitivity)); + /* + Compare two filename (fileName1,fileName2). + If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) + If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + or strcasecmp) + If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + (like 1 on Unix, 2 on Windows) + */ + + + extern unzFile ZEXPORT unzOpen OF((const char *path)); + /* + Open a Zip file. path contain the full pathname (by example, + on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer + "zlib/zlib113.zip". + If the zipfile cannot be opened (file don't exist or in not valid), the + return value is NULL. + Else, the return value is a unzFile Handle, usable with other function + of this unzip package. + */ + + extern unzFile ZEXPORT unzOpen2 OF((const char *path, + zlib_filefunc_def* pzlib_filefunc_def)); + /* + Open a Zip file, like unzOpen, but provide a set of file low level API + for read/write the zip file (see ioapi.h) + */ + + extern int ZEXPORT unzClose OF((unzFile file)); + /* + Close a ZipFile opened with unzipOpen. + If there is files inside the .Zip opened with unzOpenCurrentFile (see later), + these files MUST be closed with unzipCloseCurrentFile before call unzipClose. + return UNZ_OK if there is no problem. */ + + extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, + unz_global_info *pglobal_info)); + /* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. */ + + + extern int ZEXPORT unzGetGlobalComment OF((unzFile file, + char *szComment, + uLong uSizeBuf)); + /* + Get the global comment string of the ZipFile, in the szComment buffer. + uSizeBuf is the size of the szComment buffer. + return the number of byte copied or an error code <0 + */ + + + /***************************************************************************/ + /* Unzip package allow you browse the directory of the zipfile */ + + extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); + /* + Set the current file of the zipfile to the first file. + return UNZ_OK if there is no problem + */ + + extern int ZEXPORT unzGoToNextFile OF((unzFile file)); + /* + Set the current file of the zipfile to the next file. + return UNZ_OK if there is no problem + return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. + */ + + extern int ZEXPORT unzLocateFile OF((unzFile file, + const char *szFileName, + int iCaseSensitivity)); + /* + Try locate the file szFileName in the zipfile. + For the iCaseSensitivity signification, see unzStringFileNameCompare + + return value : + UNZ_OK if the file is found. It becomes the current file. + UNZ_END_OF_LIST_OF_FILE if the file is not found + */ + + + /* ****************************************** */ + /* Ryan supplied functions */ + /* unz_file_info contain information about a file in the zipfile */ + typedef struct unz_file_pos_s + { + uLong pos_in_zip_directory; /* offset in zip file directory */ + uLong num_of_file; /* # of file */ + } unz_file_pos; + + extern int ZEXPORT unzGetFilePos( + unzFile file, + unz_file_pos* file_pos); + + extern int ZEXPORT unzGoToFilePos( + unzFile file, + unz_file_pos* file_pos); + + /* ****************************************** */ + + extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, + unz_file_info *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); + /* + Get Info about the current file + if pfile_info!=NULL, the *pfile_info structure will contain somes info about + the current file + if szFileName!=NULL, the filemane string will be copied in szFileName + (fileNameBufferSize is the size of the buffer) + if extraField!=NULL, the extra field information will be copied in extraField + (extraFieldBufferSize is the size of the buffer). + This is the Central-header version of the extra field + if szComment!=NULL, the comment string of the file will be copied in szComment + (commentBufferSize is the size of the buffer) + */ + + /***************************************************************************/ + /* for reading the content of the current zipfile, you can open it, read data + from it, and close it (you can close it before reading all the file) + */ + + extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); + /* + Open for reading data the current file in the zipfile. + If there is no error, the return value is UNZ_OK. + */ + + extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, + const char* password)); + /* + Open for reading data the current file in the zipfile. + password is a crypting password + If there is no error, the return value is UNZ_OK. + */ + + extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, + int* method, + int* level, + int raw)); + /* + Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) + if raw==1 + *method will receive method of compression, *level will receive level of + compression + note : you can set level parameter as NULL (if you did not want known level, + but you CANNOT set method parameter as NULL + */ + + extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, + int* method, + int* level, + int raw, + const char* password)); + /* + Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) + if raw==1 + *method will receive method of compression, *level will receive level of + compression + note : you can set level parameter as NULL (if you did not want known level, + but you CANNOT set method parameter as NULL + */ + + + extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); + /* + Close the file in zip opened with unzOpenCurrentFile + Return UNZ_CRCERROR if all the file was read but the CRC is not good + */ + + extern int ZEXPORT unzReadCurrentFile OF((unzFile file, + voidp buf, + unsigned len)); + /* + Read bytes from the current file (opened by unzOpenCurrentFile) + buf contain buffer where data must be copied + len the size of buf. + + return the number of byte copied if somes bytes are copied + return 0 if the end of file was reached + return <0 with error code if there is an error + (UNZ_ERRNO for IO error, or zLib error for uncompress error) + */ + + extern z_off_t ZEXPORT unztell OF((unzFile file)); + /* + Give the current position in uncompressed data + */ + + extern int ZEXPORT unzeof OF((unzFile file)); + /* + return 1 if the end of file was reached, 0 elsewhere + */ + + extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, + voidp buf, + unsigned len)); + /* + Read extra field from the current file (opened by unzOpenCurrentFile) + This is the local-header version of the extra field (sometimes, there is + more info in the local-header version than in the central-header) + + if buf==NULL, it return the size of the local extra field + + if buf!=NULL, len is the size of the buffer, the extra header is copied in + buf. + the return value is the number of bytes copied in buf, or (if <0) + the error code + */ + + #ifdef __cplusplus + } + #endif + + #endif /* _unz_H */ Index: llvm/runtime/zlib/contrib/minizip/zip.c diff -c /dev/null llvm/runtime/zlib/contrib/minizip/zip.c:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/minizip/zip.c Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,1170 ---- + /* zip.c -- IO on .zip files using zlib + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant + + Read zip.h for more info + */ + + + #include + #include + #include + #include + #include "zlib.h" + #include "zip.h" + + #ifdef STDC + # include + # include + # include + #endif + #ifdef NO_ERRNO_H + extern int errno; + #else + # include + #endif + + + #ifndef local + # define local static + #endif + /* compile with -Dlocal if your debugger can't find static symbols */ + + #ifndef VERSIONMADEBY + # define VERSIONMADEBY (0x0) /* platform depedent */ + #endif + + #ifndef Z_BUFSIZE + #define Z_BUFSIZE (16384) + #endif + + #ifndef Z_MAXFILENAMEINZIP + #define Z_MAXFILENAMEINZIP (256) + #endif + + #ifndef ALLOC + # define ALLOC(size) (malloc(size)) + #endif + #ifndef TRYFREE + # define TRYFREE(p) {if (p) free(p);} + #endif + + /* + #define SIZECENTRALDIRITEM (0x2e) + #define SIZEZIPLOCALHEADER (0x1e) + */ + + /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ + + #ifndef SEEK_CUR + #define SEEK_CUR 1 + #endif + + #ifndef SEEK_END + #define SEEK_END 2 + #endif + + #ifndef SEEK_SET + #define SEEK_SET 0 + #endif + + #ifndef DEF_MEM_LEVEL + #if MAX_MEM_LEVEL >= 8 + # define DEF_MEM_LEVEL 8 + #else + # define DEF_MEM_LEVEL MAX_MEM_LEVEL + #endif + #endif + const char zip_copyright[] = + " zip 1.00 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; + + + #define SIZEDATA_INDATABLOCK (4096-(4*4)) + + #define LOCALHEADERMAGIC (0x04034b50) + #define CENTRALHEADERMAGIC (0x02014b50) + #define ENDHEADERMAGIC (0x06054b50) + + #define FLAG_LOCALHEADER_OFFSET (0x06) + #define CRC_LOCALHEADER_OFFSET (0x0e) + + #define SIZECENTRALHEADER (0x2e) /* 46 */ + + typedef struct linkedlist_datablock_internal_s + { + struct linkedlist_datablock_internal_s* next_datablock; + uLong avail_in_this_block; + uLong filled_in_this_block; + uLong unused; /* for future use and alignement */ + unsigned char data[SIZEDATA_INDATABLOCK]; + } linkedlist_datablock_internal; + + typedef struct linkedlist_data_s + { + linkedlist_datablock_internal* first_block; + linkedlist_datablock_internal* last_block; + } linkedlist_data; + + + typedef struct + { + z_stream stream; /* zLib stream structure for inflate */ + int stream_initialised; /* 1 is stream is initialised */ + uInt pos_in_buffered_data; /* last written byte in buffered_data */ + + uLong pos_local_header; /* offset of the local header of the file + currenty writing */ + char* central_header; /* central header data for the current file */ + uLong size_centralheader; /* size of the central header for cur file */ + uLong flag; /* flag of the file currently writing */ + + int method; /* compression method of file currenty wr.*/ + int raw; /* 1 for directly writing raw data */ + Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ + uLong dosDate; + uLong crc32; + int encrypt; + #ifndef NOCRYPT + unsigned long keys[3]; /* keys defining the pseudo-random sequence */ + const unsigned long* pcrc_32_tab; + int crypt_header_size; + #endif + } curfile_info; + + typedef struct + { + zlib_filefunc_def z_filefunc; + voidpf filestream; /* io structore of the zipfile */ + linkedlist_data central_dir;/* datablock with central dir in construction*/ + int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ + curfile_info ci; /* info on the file curretly writing */ + + uLong begin_pos; /* position of the beginning of the zipfile */ + uLong add_position_when_writting_offset; + uLong number_entry; + } zip_internal; + + + + #ifndef NOCRYPT + #define INCLUDECRYPTINGCODE_IFCRYPTALLOWED + #include "crypt.h" + #endif + + local linkedlist_datablock_internal* allocate_new_datablock() + { + linkedlist_datablock_internal* ldi; + ldi = (linkedlist_datablock_internal*) + ALLOC(sizeof(linkedlist_datablock_internal)); + if (ldi!=NULL) + { + ldi->next_datablock = NULL ; + ldi->filled_in_this_block = 0 ; + ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ; + } + return ldi; + } + + local void free_datablock(ldi) + linkedlist_datablock_internal* ldi; + { + while (ldi!=NULL) + { + linkedlist_datablock_internal* ldinext = ldi->next_datablock; + TRYFREE(ldi); + ldi = ldinext; + } + } + + local void init_linkedlist(ll) + linkedlist_data* ll; + { + ll->first_block = ll->last_block = NULL; + } + + local void free_linkedlist(ll) + linkedlist_data* ll; + { + free_datablock(ll->first_block); + ll->first_block = ll->last_block = NULL; + } + + + local int add_data_in_datablock(ll,buf,len) + linkedlist_data* ll; + const void* buf; + uLong len; + { + linkedlist_datablock_internal* ldi; + const unsigned char* from_copy; + + if (ll==NULL) + return ZIP_INTERNALERROR; + + if (ll->last_block == NULL) + { + ll->first_block = ll->last_block = allocate_new_datablock(); + if (ll->first_block == NULL) + return ZIP_INTERNALERROR; + } + + ldi = ll->last_block; + from_copy = (unsigned char*)buf; + + while (len>0) + { + uInt copy_this; + uInt i; + unsigned char* to_copy; + + if (ldi->avail_in_this_block==0) + { + ldi->next_datablock = allocate_new_datablock(); + if (ldi->next_datablock == NULL) + return ZIP_INTERNALERROR; + ldi = ldi->next_datablock ; + ll->last_block = ldi; + } + + if (ldi->avail_in_this_block < len) + copy_this = (uInt)ldi->avail_in_this_block; + else + copy_this = (uInt)len; + + to_copy = &(ldi->data[ldi->filled_in_this_block]); + + for (i=0;ifilled_in_this_block += copy_this; + ldi->avail_in_this_block -= copy_this; + from_copy += copy_this ; + len -= copy_this; + } + return ZIP_OK; + } + + + + /****************************************************************************/ + + #ifndef NO_ADDFILEINEXISTINGZIP + /* =========================================================================== + Inputs a long in LSB order to the given file + nbByte == 1, 2 or 4 (byte, short or long) + */ + + local int ziplocal_putValue OF((const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, uLong x, int nbByte)); + local int ziplocal_putValue (pzlib_filefunc_def, filestream, x, nbByte) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + uLong x; + int nbByte; + { + unsigned char buf[4]; + int n; + for (n = 0; n < nbByte; n++) { + buf[n] = (unsigned char)(x & 0xff); + x >>= 8; + } + if (ZWRITE(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte) + return ZIP_ERRNO; + else + return ZIP_OK; + } + + local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte)); + local void ziplocal_putValue_inmemory (dest, x, nbByte) + void* dest; + uLong x; + int nbByte; + { + unsigned char* buf=(unsigned char*)dest; + int n; + for (n = 0; n < nbByte; n++) { + buf[n] = (unsigned char)(x & 0xff); + x >>= 8; + } + } + /****************************************************************************/ + + + local uLong ziplocal_TmzDateToDosDate(ptm,dosDate) + const tm_zip* ptm; + uLong dosDate; + { + uLong year = (uLong)ptm->tm_year; + if (year>1980) + year-=1980; + else if (year>80) + year-=80; + return + (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) | + ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); + } + + + /****************************************************************************/ + + local int ziplocal_getByte OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, + int *pi)); + + local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + int *pi; + { + unsigned char c; + int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); + if (err==1) + { + *pi = (int)c; + return ZIP_OK; + } + else + { + if (ZERROR(*pzlib_filefunc_def,filestream)) + return ZIP_ERRNO; + else + return ZIP_EOF; + } + } + + + /* =========================================================================== + Reads a long in LSB order from the given gz_stream. Sets + */ + local int ziplocal_getShort OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, + uLong *pX)); + + local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + uLong *pX; + { + uLong x ; + int i; + int err; + + err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + x = (uLong)i; + + if (err==ZIP_OK) + err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<8; + + if (err==ZIP_OK) + *pX = x; + else + *pX = 0; + return err; + } + + local int ziplocal_getLong OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream, + uLong *pX)); + + local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + uLong *pX; + { + uLong x ; + int i; + int err; + + err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + x = (uLong)i; + + if (err==ZIP_OK) + err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<8; + + if (err==ZIP_OK) + err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<16; + + if (err==ZIP_OK) + err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + x += ((uLong)i)<<24; + + if (err==ZIP_OK) + *pX = x; + else + *pX = 0; + return err; + } + + #ifndef BUFREADCOMMENT + #define BUFREADCOMMENT (0x400) + #endif + /* + Locate the Central directory of a zipfile (at the end, just before + the global comment) + */ + local uLong ziplocal_SearchCentralDir OF(( + const zlib_filefunc_def* pzlib_filefunc_def, + voidpf filestream)); + + local uLong ziplocal_SearchCentralDir(pzlib_filefunc_def,filestream) + const zlib_filefunc_def* pzlib_filefunc_def; + voidpf filestream; + { + unsigned char* buf; + uLong uSizeFile; + uLong uBackRead; + uLong uMaxBack=0xffff; /* maximum size of global comment */ + uLong uPosFound=0; + + if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) + return 0; + + + uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; + + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; + + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); + if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) + break; + + if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) + break; + + for (i=(int)uReadSize-3; (i--)>0;) + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) + { + uPosFound = uReadPos+i; + break; + } + + if (uPosFound!=0) + break; + } + TRYFREE(buf); + return uPosFound; + } + #endif /* !NO_ADDFILEINEXISTINGZIP*/ + + /************************************************************/ + extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc_def) + const char *pathname; + int append; + zipcharpc* globalcomment; + zlib_filefunc_def* pzlib_filefunc_def; + { + zip_internal ziinit; + zip_internal* zi; + int err=ZIP_OK; + + + if (pzlib_filefunc_def==NULL) + fill_fopen_filefunc(&ziinit.z_filefunc); + else + ziinit.z_filefunc = *pzlib_filefunc_def; + + ziinit.filestream = (*(ziinit.z_filefunc.zopen_file)) + (ziinit.z_filefunc.opaque, + pathname, + (append == APPEND_STATUS_CREATE) ? + (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) : + (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING)); + + if (ziinit.filestream == NULL) + return NULL; + ziinit.begin_pos = ZTELL(ziinit.z_filefunc,ziinit.filestream); + ziinit.in_opened_file_inzip = 0; + ziinit.ci.stream_initialised = 0; + ziinit.number_entry = 0; + ziinit.add_position_when_writting_offset = 0; + init_linkedlist(&(ziinit.central_dir)); + + + zi = (zip_internal*)ALLOC(sizeof(zip_internal)); + if (zi==NULL) + { + ZCLOSE(ziinit.z_filefunc,ziinit.filestream); + return NULL; + } + + /* now we add file in a zipfile */ + # ifndef NO_ADDFILEINEXISTINGZIP + if (append == APPEND_STATUS_ADDINZIP) + { + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + + uLong size_central_dir; /* size of the central directory */ + uLong offset_central_dir; /* offset of start of central directory */ + uLong central_pos,uL; + + uLong number_disk; /* number of the current dist, used for + spaning ZIP, unsupported, always 0*/ + uLong number_disk_with_CD; /* number the the disk with central dir, used + for spaning ZIP, unsupported, always 0*/ + uLong number_entry; + uLong number_entry_CD; /* total number of entries in + the central dir + (same than number_entry on nospan) */ + uLong size_comment; + + central_pos = ziplocal_SearchCentralDir(&ziinit.z_filefunc,ziinit.filestream); + if (central_pos==0) + err=ZIP_ERRNO; + + if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, + central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) + err=ZIP_ERRNO; + + /* the signature, already checked */ + if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&uL)!=ZIP_OK) + err=ZIP_ERRNO; + + /* number of this disk */ + if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk)!=ZIP_OK) + err=ZIP_ERRNO; + + /* number of the disk with the start of the central directory */ + if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk_with_CD)!=ZIP_OK) + err=ZIP_ERRNO; + + /* total number of entries in the central dir on this disk */ + if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry)!=ZIP_OK) + err=ZIP_ERRNO; + + /* total number of entries in the central dir */ + if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry_CD)!=ZIP_OK) + err=ZIP_ERRNO; + + if ((number_entry_CD!=number_entry) || + (number_disk_with_CD!=0) || + (number_disk!=0)) + err=ZIP_BADZIPFILE; + + /* size of the central directory */ + if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&size_central_dir)!=ZIP_OK) + err=ZIP_ERRNO; + + /* offset of start of central directory with respect to the + starting disk number */ + if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&offset_central_dir)!=ZIP_OK) + err=ZIP_ERRNO; + + /* zipfile comment length */ + if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&size_comment)!=ZIP_OK) + err=ZIP_ERRNO; + + if ((central_pos0) && (err==ZIP_OK)) + { + uLong read_this = SIZEDATA_INDATABLOCK; + if (read_this > size_central_dir_to_read) + read_this = size_central_dir_to_read; + if (ZREAD(ziinit.z_filefunc, ziinit.filestream,buf_read,read_this) != read_this) + err=ZIP_ERRNO; + + if (err==ZIP_OK) + err = add_data_in_datablock(&ziinit.central_dir,buf_read, + (uLong)read_this); + size_central_dir_to_read-=read_this; + } + TRYFREE(buf_read); + } + ziinit.begin_pos = byte_before_the_zipfile; + ziinit.number_entry = number_entry_CD; + + if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, + offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) + err=ZIP_ERRNO; + } + # endif /* !NO_ADDFILEINEXISTINGZIP*/ + + if (err != ZIP_OK) + { + TRYFREE(zi); + return NULL; + } + else + { + *zi = ziinit; + return (zipFile)zi; + } + } + + extern zipFile ZEXPORT zipOpen (pathname, append) + const char *pathname; + int append; + { + return zipOpen2(pathname,append,NULL,NULL); + } + + extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + windowBits, memLevel, strategy, + password, crcForCrypting) + zipFile file; + const char* filename; + const zip_fileinfo* zipfi; + const void* extrafield_local; + uInt size_extrafield_local; + const void* extrafield_global; + uInt size_extrafield_global; + const char* comment; + int method; + int level; + int raw; + int windowBits; + int memLevel; + int strategy; + const char* password; + uLong crcForCrypting; + { + zip_internal* zi; + uInt size_filename; + uInt size_comment; + uInt i; + int err = ZIP_OK; + + # ifdef NOCRYPT + if (password != NULL) + return ZIP_PARAMERROR; + # endif + + if (file == NULL) + return ZIP_PARAMERROR; + if ((method!=0) && (method!=Z_DEFLATED)) + return ZIP_PARAMERROR; + + zi = (zip_internal*)file; + + if (zi->in_opened_file_inzip == 1) + { + err = zipCloseFileInZip (file); + if (err != ZIP_OK) + return err; + } + + + if (filename==NULL) + filename="-"; + + if (comment==NULL) + size_comment = 0; + else + size_comment = strlen(comment); + + size_filename = strlen(filename); + + if (zipfi == NULL) + zi->ci.dosDate = 0; + else + { + if (zipfi->dosDate != 0) + zi->ci.dosDate = zipfi->dosDate; + else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate); + } + + zi->ci.flag = 0; + if ((level==8) || (level==9)) + zi->ci.flag |= 2; + if ((level==2)) + zi->ci.flag |= 4; + if ((level==1)) + zi->ci.flag |= 6; + if (password != NULL) + zi->ci.flag |= 1; + + zi->ci.crc32 = 0; + zi->ci.method = method; + zi->ci.encrypt = 0; + zi->ci.stream_initialised = 0; + zi->ci.pos_in_buffered_data = 0; + zi->ci.raw = raw; + zi->ci.pos_local_header = ZTELL(zi->z_filefunc,zi->filestream) ; + zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + + size_extrafield_global + size_comment; + zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader); + + ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); + /* version info */ + ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2); + ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2); + ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2); + ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2); + ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4); + ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/ + ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/ + ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/ + ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2); + ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2); + ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2); + ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ + + if (zipfi==NULL) + ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); + else + ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); + + if (zipfi==NULL) + ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); + else + ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); + + ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header- zi->add_position_when_writting_offset,4); + + for (i=0;ici.central_header+SIZECENTRALHEADER+i) = *(filename+i); + + for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+i) = + *(((const char*)extrafield_global)+i); + + for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+ + size_extrafield_global+i) = *(comment+i); + if (zi->ci.central_header == NULL) + return ZIP_INTERNALERROR; + + /* write the local header */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC,4); + + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */ + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2); + + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2); + + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4); + + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */ + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */ + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */ + + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2); + + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield_local,2); + + if ((err==ZIP_OK) && (size_filename>0)) + if (ZWRITE(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename) + err = ZIP_ERRNO; + + if ((err==ZIP_OK) && (size_extrafield_local>0)) + if (ZWRITE(zi->z_filefunc,zi->filestream,extrafield_local,size_extrafield_local) + !=size_extrafield_local) + err = ZIP_ERRNO; + + zi->ci.stream.avail_in = (uInt)0; + zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.stream.next_out = zi->ci.buffered_data; + zi->ci.stream.total_in = 0; + zi->ci.stream.total_out = 0; + + if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) + { + zi->ci.stream.zalloc = (alloc_func)0; + zi->ci.stream.zfree = (free_func)0; + zi->ci.stream.opaque = (voidpf)0; + + if (windowBits>0) + windowBits = -windowBits; + + err = deflateInit2(&zi->ci.stream, level, + Z_DEFLATED, windowBits, memLevel, strategy); + + if (err==Z_OK) + zi->ci.stream_initialised = 1; + } + # ifndef NOCRYPT + zi->ci.crypt_header_size = 0; + if ((err==Z_OK) && (password != NULL)) + { + unsigned char bufHead[RAND_HEAD_LEN]; + unsigned int sizeHead; + zi->ci.encrypt = 1; + zi->ci.pcrc_32_tab = get_crc_table(); + /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/ + + sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting); + zi->ci.crypt_header_size = sizeHead; + + if (ZWRITE(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead) + err = ZIP_ERRNO; + } + # endif + + if (err==Z_OK) + zi->in_opened_file_inzip = 1; + return err; + } + + extern int ZEXPORT zipOpenNewFileInZip2(file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw) + zipFile file; + const char* filename; + const zip_fileinfo* zipfi; + const void* extrafield_local; + uInt size_extrafield_local; + const void* extrafield_global; + uInt size_extrafield_global; + const char* comment; + int method; + int level; + int raw; + { + return zipOpenNewFileInZip3 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0); + } + + extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level) + zipFile file; + const char* filename; + const zip_fileinfo* zipfi; + const void* extrafield_local; + uInt size_extrafield_local; + const void* extrafield_global; + uInt size_extrafield_global; + const char* comment; + int method; + int level; + { + return zipOpenNewFileInZip2 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, 0); + } + + local int zipFlushWriteBuffer(zi) + zip_internal* zi; + { + int err=ZIP_OK; + + if (zi->ci.encrypt != 0) + { + #ifndef NOCRYPT + uInt i; + int t; + for (i=0;ici.pos_in_buffered_data;i++) + zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, + zi->ci.buffered_data[i],t); + #endif + } + if (ZWRITE(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data) + !=zi->ci.pos_in_buffered_data) + err = ZIP_ERRNO; + zi->ci.pos_in_buffered_data = 0; + return err; + } + + extern int ZEXPORT zipWriteInFileInZip (file, buf, len) + zipFile file; + const void* buf; + unsigned len; + { + zip_internal* zi; + int err=ZIP_OK; + + if (file == NULL) + return ZIP_PARAMERROR; + zi = (zip_internal*)file; + + if (zi->in_opened_file_inzip == 0) + return ZIP_PARAMERROR; + + zi->ci.stream.next_in = (void*)buf; + zi->ci.stream.avail_in = len; + zi->ci.crc32 = crc32(zi->ci.crc32,buf,len); + + while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) + { + if (zi->ci.stream.avail_out == 0) + { + if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) + err = ZIP_ERRNO; + zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.stream.next_out = zi->ci.buffered_data; + } + + + if(err != ZIP_OK) + break; + + if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) + { + uLong uTotalOutBefore = zi->ci.stream.total_out; + err=deflate(&zi->ci.stream, Z_NO_FLUSH); + zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; + + } + else + { + uInt copy_this,i; + if (zi->ci.stream.avail_in < zi->ci.stream.avail_out) + copy_this = zi->ci.stream.avail_in; + else + copy_this = zi->ci.stream.avail_out; + for (i=0;ici.stream.next_out)+i) = + *(((const char*)zi->ci.stream.next_in)+i); + { + zi->ci.stream.avail_in -= copy_this; + zi->ci.stream.avail_out-= copy_this; + zi->ci.stream.next_in+= copy_this; + zi->ci.stream.next_out+= copy_this; + zi->ci.stream.total_in+= copy_this; + zi->ci.stream.total_out+= copy_this; + zi->ci.pos_in_buffered_data += copy_this; + } + } + } + + return err; + } + + extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32) + zipFile file; + uLong uncompressed_size; + uLong crc32; + { + zip_internal* zi; + uLong compressed_size; + int err=ZIP_OK; + + if (file == NULL) + return ZIP_PARAMERROR; + zi = (zip_internal*)file; + + if (zi->in_opened_file_inzip == 0) + return ZIP_PARAMERROR; + zi->ci.stream.avail_in = 0; + + if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) + while (err==ZIP_OK) + { + uLong uTotalOutBefore; + if (zi->ci.stream.avail_out == 0) + { + if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) + err = ZIP_ERRNO; + zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.stream.next_out = zi->ci.buffered_data; + } + uTotalOutBefore = zi->ci.stream.total_out; + err=deflate(&zi->ci.stream, Z_FINISH); + zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; + } + + if (err==Z_STREAM_END) + err=ZIP_OK; /* this is normal */ + + if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) + if (zipFlushWriteBuffer(zi)==ZIP_ERRNO) + err = ZIP_ERRNO; + + if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) + { + err=deflateEnd(&zi->ci.stream); + zi->ci.stream_initialised = 0; + } + + if (!zi->ci.raw) + { + crc32 = (uLong)zi->ci.crc32; + uncompressed_size = (uLong)zi->ci.stream.total_in; + } + compressed_size = (uLong)zi->ci.stream.total_out; + # ifndef NOCRYPT + compressed_size += zi->ci.crypt_header_size; + # endif + + ziplocal_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/ + ziplocal_putValue_inmemory(zi->ci.central_header+20, + compressed_size,4); /*compr size*/ + if (zi->ci.stream.data_type == Z_ASCII) + ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2); + ziplocal_putValue_inmemory(zi->ci.central_header+24, + uncompressed_size,4); /*uncompr size*/ + + if (err==ZIP_OK) + err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header, + (uLong)zi->ci.size_centralheader); + free(zi->ci.central_header); + + if (err==ZIP_OK) + { + long cur_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); + if (ZSEEK(zi->z_filefunc,zi->filestream, + zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0) + err = ZIP_ERRNO; + + if (err==ZIP_OK) + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */ + + if (err==ZIP_OK) /* compressed size, unknown */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4); + + if (err==ZIP_OK) /* uncompressed size, unknown */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4); + + if (ZSEEK(zi->z_filefunc,zi->filestream, + cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0) + err = ZIP_ERRNO; + } + + zi->number_entry ++; + zi->in_opened_file_inzip = 0; + + return err; + } + + extern int ZEXPORT zipCloseFileInZip (file) + zipFile file; + { + return zipCloseFileInZipRaw (file,0,0); + } + + extern int ZEXPORT zipClose (file, global_comment) + zipFile file; + const char* global_comment; + { + zip_internal* zi; + int err = 0; + uLong size_centraldir = 0; + uLong centraldir_pos_inzip ; + uInt size_global_comment; + if (file == NULL) + return ZIP_PARAMERROR; + zi = (zip_internal*)file; + + if (zi->in_opened_file_inzip == 1) + { + err = zipCloseFileInZip (file); + } + + if (global_comment==NULL) + size_global_comment = 0; + else + size_global_comment = strlen(global_comment); + + + centraldir_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); + if (err==ZIP_OK) + { + linkedlist_datablock_internal* ldi = zi->central_dir.first_block ; + while (ldi!=NULL) + { + if ((err==ZIP_OK) && (ldi->filled_in_this_block>0)) + if (ZWRITE(zi->z_filefunc,zi->filestream, + ldi->data,ldi->filled_in_this_block) + !=ldi->filled_in_this_block ) + err = ZIP_ERRNO; + + size_centraldir += ldi->filled_in_this_block; + ldi = ldi->next_datablock; + } + } + free_datablock(zi->central_dir.first_block); + + if (err==ZIP_OK) /* Magic End */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4); + + if (err==ZIP_OK) /* number of this disk */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); + + if (err==ZIP_OK) /* number of the disk with the start of the central directory */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); + + if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); + + if (err==ZIP_OK) /* total number of entries in the central dir */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); + + if (err==ZIP_OK) /* size of the central directory */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4); + + if (err==ZIP_OK) /* offset of start of central directory with respect to the + starting disk number */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream, + (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4); + + if (err==ZIP_OK) /* zipfile comment length */ + err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2); + + if ((err==ZIP_OK) && (size_global_comment>0)) + if (ZWRITE(zi->z_filefunc,zi->filestream, + global_comment,size_global_comment) != size_global_comment) + err = ZIP_ERRNO; + + if (ZCLOSE(zi->z_filefunc,zi->filestream) != 0) + if (err == ZIP_OK) + err = ZIP_ERRNO; + + TRYFREE(zi); + + return err; + } Index: llvm/runtime/zlib/contrib/minizip/zip.h diff -c /dev/null llvm/runtime/zlib/contrib/minizip/zip.h:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/minizip/zip.h Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,235 ---- + /* zip.h -- IO for compress .zip files using zlib + Version 1.00, September 10th, 2003 + + Copyright (C) 1998-2003 Gilles Vollant + + This unzip package allow creates .ZIP file, compatible with PKZip 2.04g + WinZip, InfoZip tools and compatible. + Encryption and multi volume ZipFile (span) are not supported. + Old compressions used by old PKZip 1.x are not supported + + For uncompress .zip file, look at unzip.h + + + I WAIT FEEDBACK at mail info at winimage.com + Visit also http://www.winimage.com/zLibDll/unzip.html for evolution + + Condition of use and distribution are the same than zlib : + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + + */ + + /* for more info about .ZIP format, see + http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip + http://www.info-zip.org/pub/infozip/doc/ + PkWare has also a specification at : + ftp://ftp.pkware.com/probdesc.zip + */ + + #ifndef _zip_H + #define _zip_H + + #ifdef __cplusplus + extern "C" { + #endif + + #ifndef _ZLIB_H + #include "zlib.h" + #endif + + #ifndef _ZLIBIOAPI_H + #include "ioapi.h" + #endif + + #if defined(STRICTZIP) || defined(STRICTZIPUNZIP) + /* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ + typedef struct TagzipFile__ { int unused; } zipFile__; + typedef zipFile__ *zipFile; + #else + typedef voidp zipFile; + #endif + + #define ZIP_OK (0) + #define ZIP_EOF (0) + #define ZIP_ERRNO (Z_ERRNO) + #define ZIP_PARAMERROR (-102) + #define ZIP_BADZIPFILE (-103) + #define ZIP_INTERNALERROR (-104) + + #ifndef DEF_MEM_LEVEL + # if MAX_MEM_LEVEL >= 8 + # define DEF_MEM_LEVEL 8 + # else + # define DEF_MEM_LEVEL MAX_MEM_LEVEL + # endif + #endif + /* default memLevel */ + + /* tm_zip contain date/time info */ + typedef struct tm_zip_s + { + uInt tm_sec; /* seconds after the minute - [0,59] */ + uInt tm_min; /* minutes after the hour - [0,59] */ + uInt tm_hour; /* hours since midnight - [0,23] */ + uInt tm_mday; /* day of the month - [1,31] */ + uInt tm_mon; /* months since January - [0,11] */ + uInt tm_year; /* years - [1980..2044] */ + } tm_zip; + + typedef struct + { + tm_zip tmz_date; /* date in understandable format */ + uLong dosDate; /* if dos_date == 0, tmu_date is used */ + /* uLong flag; */ /* general purpose bit flag 2 bytes */ + + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ + } zip_fileinfo; + + typedef const char* zipcharpc; + + + #define APPEND_STATUS_CREATE (0) + #define APPEND_STATUS_CREATEAFTER (1) + #define APPEND_STATUS_ADDINZIP (2) + + extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); + /* + Create a zipfile. + pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on + an Unix computer "zlib/zlib113.zip". + if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip + will be created at the end of the file. + (useful if the file contain a self extractor code) + if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will + add files in existing zip (be sure you don't add file that doesn't exist) + If the zipfile cannot be opened, the return value is NULL. + Else, the return value is a zipFile Handle, usable with other function + of this zip package. + */ + + /* Note : there is no delete function into a zipfile. + If you want delete file into a zipfile, you must open a zipfile, and create another + Of couse, you can use RAW reading and writing to copy the file you did not want delte + */ + + extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, + int append, + zipcharpc* globalcomment, + zlib_filefunc_def* pzlib_filefunc_def)); + + extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level)); + /* + Open a file in the ZIP for writing. + filename : the filename in zip (if NULL, '-' without quote will be used + *zipfi contain supplemental information + if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local + contains the extrafield data the the local header + if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global + contains the extrafield data the the local header + if comment != NULL, comment contain the comment string + method contain the compression method (0 for store, Z_DEFLATED for deflate) + level contain the level of compression (can be Z_DEFAULT_COMPRESSION) + */ + + + extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw)); + + /* + Same than zipOpenNewFileInZip, except if raw=1, we write raw file + */ + + extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCtypting)); + + /* + Same than zipOpenNewFileInZip2, except + windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 + password : crypting password (NULL for no crypting) + crcForCtypting : crc of file to compress (needed for crypting) + */ + + + extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, + const void* buf, + unsigned len)); + /* + Write data in the zipfile + */ + + extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); + /* + Close the current file in the zipfile + */ + + + extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, + uLong uncompressed_size, + uLong crc32)); + /* + Close the current file in the zipfile, for fiel opened with + parameter raw=1 in zipOpenNewFileInZip2 + uncompressed_size and crc32 are value for the uncompressed size + */ + + extern int ZEXPORT zipClose OF((zipFile file, + const char* global_comment)); + /* + Close the zipfile + */ + + #ifdef __cplusplus + } + #endif + + #endif /* _zip_H */ From criswell at cs.uiuc.edu Fri Feb 6 10:38:47 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:38:47 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/old/os2/Makefile.os2 zlib.def Message-ID: <200402061636.KAA15701@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/old/os2: Makefile.os2 added (r1.1) zlib.def added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+187 -0) Index: llvm/runtime/zlib/old/os2/Makefile.os2 diff -c /dev/null llvm/runtime/zlib/old/os2/Makefile.os2:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/old/os2/Makefile.os2 Fri Feb 6 10:36:42 2004 *************** *** 0 **** --- 1,136 ---- + # Makefile for zlib under OS/2 using GCC (PGCC) + # For conditions of distribution and use, see copyright notice in zlib.h + + # To compile and test, type: + # cp Makefile.os2 .. + # cd .. + # make -f Makefile.os2 test + + # This makefile will build a static library z.lib, a shared library + # z.dll and a import library zdll.lib. You can use either z.lib or + # zdll.lib by specifying either -lz or -lzdll on gcc's command line + + CC=gcc -Zomf -s + + CFLAGS=-O6 -Wall + #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 + #CFLAGS=-g -DDEBUG + #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ + # -Wstrict-prototypes -Wmissing-prototypes + + #################### BUG WARNING: ##################### + ## infcodes.c hits a bug in pgcc-1.0, so you have to use either + ## -O# where # <= 4 or one of (-fno-ommit-frame-pointer or -fno-force-mem) + ## This bug is reportedly fixed in pgcc >1.0, but this was not tested + CFLAGS+=-fno-force-mem + + LDFLAGS=-s -L. -lzdll -Zcrtdll + LDSHARED=$(CC) -s -Zomf -Zdll -Zcrtdll + + VER=1.1.0 + ZLIB=z.lib + SHAREDLIB=z.dll + SHAREDLIBIMP=zdll.lib + LIBS=$(ZLIB) $(SHAREDLIB) $(SHAREDLIBIMP) + + AR=emxomfar cr + IMPLIB=emximp + RANLIB=echo + TAR=tar + SHELL=bash + + prefix=/usr/local + exec_prefix = $(prefix) + + OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ + zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o + + TEST_OBJS = example.o minigzip.o + + DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \ + algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ + nt/Makefile.nt nt/zlib.dnt contrib/README.contrib contrib/*.txt \ + contrib/asm386/*.asm contrib/asm386/*.c \ + contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \ + contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \ + contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 + + all: example.exe minigzip.exe + + test: all + @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ + echo hello world | ./minigzip | ./minigzip -d || \ + echo ' *** minigzip test FAILED ***' ; \ + if ./example; then \ + echo ' *** zlib test OK ***'; \ + else \ + echo ' *** zlib test FAILED ***'; \ + fi + + $(ZLIB): $(OBJS) + $(AR) $@ $(OBJS) + -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 + + $(SHAREDLIB): $(OBJS) os2/z.def + $(LDSHARED) -o $@ $^ + + $(SHAREDLIBIMP): os2/z.def + $(IMPLIB) -o $@ $^ + + example.exe: example.o $(LIBS) + $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) + + minigzip.exe: minigzip.o $(LIBS) + $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) + + clean: + rm -f *.o *~ example minigzip libz.a libz.so* foo.gz + + distclean: clean + + zip: + mv Makefile Makefile~; cp -p Makefile.in Makefile + rm -f test.c ztest*.c + v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ + zip -ul9 zlib$$v $(DISTFILES) + mv Makefile~ Makefile + + dist: + mv Makefile Makefile~; cp -p Makefile.in Makefile + rm -f test.c ztest*.c + d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ + rm -f $$d.tar.gz; \ + if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \ + files=""; \ + for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \ + cd ..; \ + GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \ + if test ! -d $$d; then rm -f $$d; fi + mv Makefile~ Makefile + + tags: + etags *.[ch] + + depend: + makedepend -- $(CFLAGS) -- *.[ch] + + # DO NOT DELETE THIS LINE -- make depend depends on it. + + adler32.o: zlib.h zconf.h + compress.o: zlib.h zconf.h + crc32.o: zlib.h zconf.h + deflate.o: deflate.h zutil.h zlib.h zconf.h + example.o: zlib.h zconf.h + gzio.o: zutil.h zlib.h zconf.h + infblock.o: infblock.h inftrees.h infcodes.h infutil.h zutil.h zlib.h zconf.h + infcodes.o: zutil.h zlib.h zconf.h + infcodes.o: inftrees.h infblock.h infcodes.h infutil.h inffast.h + inffast.o: zutil.h zlib.h zconf.h inftrees.h + inffast.o: infblock.h infcodes.h infutil.h inffast.h + inflate.o: zutil.h zlib.h zconf.h infblock.h + inftrees.o: zutil.h zlib.h zconf.h inftrees.h + infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h + minigzip.o: zlib.h zconf.h + trees.o: deflate.h zutil.h zlib.h zconf.h trees.h + uncompr.o: zlib.h zconf.h + zutil.o: zutil.h zlib.h zconf.h Index: llvm/runtime/zlib/old/os2/zlib.def diff -c /dev/null llvm/runtime/zlib/old/os2/zlib.def:1.1 *** /dev/null Fri Feb 6 10:36:52 2004 --- llvm/runtime/zlib/old/os2/zlib.def Fri Feb 6 10:36:42 2004 *************** *** 0 **** --- 1,51 ---- + ; + ; Slightly modified version of ../nt/zlib.dnt :-) + ; + + LIBRARY Z + DESCRIPTION "Zlib compression library for OS/2" + CODE PRELOAD MOVEABLE DISCARDABLE + DATA PRELOAD MOVEABLE MULTIPLE + + EXPORTS + adler32 + compress + crc32 + deflate + deflateCopy + deflateEnd + deflateInit2_ + deflateInit_ + deflateParams + deflateReset + deflateSetDictionary + gzclose + gzdopen + gzerror + gzflush + gzopen + gzread + gzwrite + inflate + inflateEnd + inflateInit2_ + inflateInit_ + inflateReset + inflateSetDictionary + inflateSync + uncompress + zlibVersion + gzprintf + gzputc + gzgetc + gzseek + gzrewind + gztell + gzeof + gzsetparams + zError + inflateSyncPoint + get_crc_table + compress2 + gzputs + gzgets From criswell at cs.uiuc.edu Fri Feb 6 10:39:03 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:39:03 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/untgz/Makefile Makefile.msc untgz.c Message-ID: <200402061636.KAA15637@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/untgz: Makefile added (r1.1) Makefile.msc added (r1.1) untgz.c added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+600 -0) Index: llvm/runtime/zlib/contrib/untgz/Makefile diff -c /dev/null llvm/runtime/zlib/contrib/untgz/Makefile:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/untgz/Makefile Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,14 ---- + CC=cc + CFLAGS=-g + + untgz: untgz.o ../../libz.a + $(CC) $(CFLAGS) -o untgz untgz.o -L../.. -lz + + untgz.o: untgz.c ../../zlib.h + $(CC) $(CFLAGS) -c -I../.. untgz.c + + ../../libz.a: + cd ../..; ./configure; make + + clean: + rm -f untgz untgz.o *~ Index: llvm/runtime/zlib/contrib/untgz/Makefile.msc diff -c /dev/null llvm/runtime/zlib/contrib/untgz/Makefile.msc:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/untgz/Makefile.msc Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,17 ---- + CC=cl + CFLAGS=-MD + + untgz.exe: untgz.obj ..\..\zlib.lib + $(CC) $(CFLAGS) untgz.obj ..\..\zlib.lib + + untgz.obj: untgz.c ..\..\zlib.h + $(CC) $(CFLAGS) -c -I..\.. untgz.c + + ..\..\zlib.lib: + cd ..\.. + $(MAKE) -f win32\makefile.msc + cd contrib\untgz + + clean: + -del untgz.obj + -del untgz.exe Index: llvm/runtime/zlib/contrib/untgz/untgz.c diff -c /dev/null llvm/runtime/zlib/contrib/untgz/untgz.c:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/untgz/untgz.c Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,569 ---- + /* + * untgz.c -- Display contents and extract files from a gzip'd TAR file + * + * written by "Pedro A. Aranda Guti\irrez" + * adaptation to Unix by Jean-loup Gailly + * various fixes by Cosmin Truta + */ + + #include + #include + #include + #include + #include + + #include "zlib.h" + + #ifdef unix + # include + #else + # include + # include + #endif + + #ifdef WIN32 + #include + # ifndef F_OK + # define F_OK 0 + # endif + # define mkdir(dirname,mode) _mkdir(dirname) + # ifdef _MSC_VER + # define strdup(str) _strdup(str) + # define access(path,mode) _access(path,mode) + # endif + #else + # include + #endif + + + /* values used in typeflag field */ + + #define REGTYPE '0' /* regular file */ + #define AREGTYPE '\0' /* regular file */ + #define LNKTYPE '1' /* link */ + #define SYMTYPE '2' /* reserved */ + #define CHRTYPE '3' /* character special */ + #define BLKTYPE '4' /* block special */ + #define DIRTYPE '5' /* directory */ + #define FIFOTYPE '6' /* FIFO special */ + #define CONTTYPE '7' /* reserved */ + + #define BLOCKSIZE 512 + + struct tar_header + { /* byte offset */ + char name[100]; /* 0 */ + char mode[8]; /* 100 */ + char uid[8]; /* 108 */ + char gid[8]; /* 116 */ + char size[12]; /* 124 */ + char mtime[12]; /* 136 */ + char chksum[8]; /* 148 */ + char typeflag; /* 156 */ + char linkname[100]; /* 157 */ + char magic[6]; /* 257 */ + char version[2]; /* 263 */ + char uname[32]; /* 265 */ + char gname[32]; /* 297 */ + char devmajor[8]; /* 329 */ + char devminor[8]; /* 337 */ + char prefix[155]; /* 345 */ + /* 500 */ + }; + + union tar_buffer { + char buffer[BLOCKSIZE]; + struct tar_header header; + }; + + enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID }; + + char *TGZfname OF((const char *)); + void TGZnotfound OF((const char *)); + + int getoct OF((char *, int)); + char *strtime OF((time_t *)); + int setfiletime OF((char *, time_t)); + int ExprMatch OF((char *, char *)); + + int makedir OF((char *)); + int matchname OF((int, int, char **, char *)); + + void error OF((const char *)); + int tar OF((gzFile, int, int, int, char **)); + + void help OF((int)); + int main OF((int, char **)); + + char *prog; + + const char *TGZsuffix[] = { "\0", ".tar", ".tar.gz", ".taz", ".tgz", NULL }; + + /* return the file name of the TGZ archive */ + /* or NULL if it does not exist */ + + char *TGZfname (const char *arcname) + { + static char buffer[1024]; + int origlen,i; + + strcpy(buffer,arcname); + origlen = strlen(buffer); + + for (i=0; TGZsuffix[i]; i++) + { + strcpy(buffer+origlen,TGZsuffix[i]); + if (access(buffer,F_OK) == 0) + return buffer; + } + return NULL; + } + + + /* error message for the filename */ + + void TGZnotfound (const char *arcname) + { + int i; + + fprintf(stderr,"%s: Couldn't find ",prog); + for (i=0;TGZsuffix[i];i++) + fprintf(stderr,(TGZsuffix[i+1]) ? "%s%s, " : "or %s%s\n", + arcname, + TGZsuffix[i]); + exit(1); + } + + + /* convert octal digits to int */ + /* on error return -1 */ + + int getoct (char *p,int width) + { + int result = 0; + char c; + + while (width--) + { + c = *p++; + if (c == 0) + break; + if (c == ' ') + continue; + if (c < '0' || c > '7') + return -1; + result = result * 8 + (c - '0'); + } + return result; + } + + + /* convert time_t to string */ + /* use the "YYYY/MM/DD hh:mm:ss" format */ + + char *strtime (time_t *t) + { + struct tm *local; + static char result[32]; + + local = localtime(t); + sprintf(result,"%4d/%02d/%02d %02d:%02d:%02d", + local->tm_year+1900, local->tm_mon+1, local->tm_mday, + local->tm_hour, local->tm_min, local->tm_sec); + return result; + } + + + /* set file time */ + + int setfiletime (char *fname,time_t ftime) + { + #ifdef WIN32 + static int isWinNT = -1; + SYSTEMTIME st; + FILETIME locft, modft; + struct tm *loctm; + HANDLE hFile; + int result; + + loctm = localtime(&ftime); + if (loctm == NULL) + return -1; + + st.wYear = (WORD)loctm->tm_year + 1900; + st.wMonth = (WORD)loctm->tm_mon + 1; + st.wDayOfWeek = (WORD)loctm->tm_wday; + st.wDay = (WORD)loctm->tm_mday; + st.wHour = (WORD)loctm->tm_hour; + st.wMinute = (WORD)loctm->tm_min; + st.wSecond = (WORD)loctm->tm_sec; + st.wMilliseconds = 0; + if (!SystemTimeToFileTime(&st, &locft) || + !LocalFileTimeToFileTime(&locft, &modft)) + return -1; + + if (isWinNT < 0) + isWinNT = (GetVersion() < 0x80000000) ? 1 : 0; + hFile = CreateFile(fname, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, + (isWinNT ? FILE_FLAG_BACKUP_SEMANTICS : 0), + NULL); + if (hFile == INVALID_HANDLE_VALUE) + return -1; + result = SetFileTime(hFile, NULL, NULL, &modft) ? 0 : -1; + CloseHandle(hFile); + return result; + #else + struct utimbuf settime; + + settime.actime = settime.modtime = ftime; + return utime(fname,&settime); + #endif + } + + + /* regular expression matching */ + + #define ISSPECIAL(c) (((c) == '*') || ((c) == '/')) + + int ExprMatch (char *string,char *expr) + { + while (1) + { + if (ISSPECIAL(*expr)) + { + if (*expr == '/') + { + if (*string != '\\' && *string != '/') + return 0; + string ++; expr++; + } + else if (*expr == '*') + { + if (*expr ++ == 0) + return 1; + while (*++string != *expr) + if (*string == 0) + return 0; + } + } + else + { + if (*string != *expr) + return 0; + if (*expr++ == 0) + return 1; + string++; + } + } + } + + + /* recursive mkdir */ + /* abort on ENOENT; ignore other errors like "directory already exists" */ + /* return 1 if OK */ + /* 0 on error */ + + int makedir (char *newdir) + { + char *buffer = strdup(newdir); + char *p; + int len = strlen(buffer); + + if (len <= 0) { + free(buffer); + return 0; + } + if (buffer[len-1] == '/') { + buffer[len-1] = '\0'; + } + if (mkdir(buffer, 0755) == 0) + { + free(buffer); + return 1; + } + + p = buffer+1; + while (1) + { + char hold; + + while(*p && *p != '\\' && *p != '/') + p++; + hold = *p; + *p = 0; + if ((mkdir(buffer, 0755) == -1) && (errno == ENOENT)) + { + fprintf(stderr,"%s: Couldn't create directory %s\n",prog,buffer); + free(buffer); + return 0; + } + if (hold == 0) + break; + *p++ = hold; + } + free(buffer); + return 1; + } + + + int matchname (int arg,int argc,char **argv,char *fname) + { + if (arg == argc) /* no arguments given (untgz tgzarchive) */ + return 1; + + while (arg < argc) + if (ExprMatch(fname,argv[arg++])) + return 1; + + return 0; /* ignore this for the moment being */ + } + + + /* tar file list or extract */ + + int tar (gzFile in,int action,int arg,int argc,char **argv) + { + union tar_buffer buffer; + int len; + int err; + int getheader = 1; + int remaining = 0; + FILE *outfile = NULL; + char fname[BLOCKSIZE]; + int tarmode; + time_t tartime; + + if (action == TGZ_LIST) + printf(" date time size file\n" + " ---------- -------- --------- -------------------------------------\n"); + while (1) + { + len = gzread(in, &buffer, BLOCKSIZE); + if (len < 0) + error(gzerror(in, &err)); + /* + * Always expect complete blocks to process + * the tar information. + */ + if (len != BLOCKSIZE) + { + action = TGZ_INVALID; /* force error exit */ + remaining = 0; /* force I/O cleanup */ + } + + /* + * If we have to get a tar header + */ + if (getheader == 1) + { + /* + * if we met the end of the tar + * or the end-of-tar block, + * we are done + */ + if ((len == 0) || (buffer.header.name[0] == 0)) break; + + tarmode = getoct(buffer.header.mode,8); + tartime = (time_t)getoct(buffer.header.mtime,12); + if (tarmode == -1 || tartime == (time_t)-1) + { + buffer.header.name[0] = 0; + action = TGZ_INVALID; + } + + strcpy(fname,buffer.header.name); + + switch (buffer.header.typeflag) + { + case DIRTYPE: + if (action == TGZ_LIST) + printf(" %s %s\n",strtime(&tartime),fname); + if (action == TGZ_EXTRACT) + { + makedir(fname); + setfiletime(fname,tartime); + } + break; + case REGTYPE: + case AREGTYPE: + remaining = getoct(buffer.header.size,12); + if (remaining == -1) + { + action = TGZ_INVALID; + break; + } + if (action == TGZ_LIST) + printf(" %s %9d %s\n",strtime(&tartime),remaining,fname); + else if (action == TGZ_EXTRACT) + { + if (matchname(arg,argc,argv,fname)) + { + outfile = fopen(fname,"wb"); + if (outfile == NULL) { + /* try creating directory */ + char *p = strrchr(fname, '/'); + if (p != NULL) { + *p = '\0'; + makedir(fname); + *p = '/'; + outfile = fopen(fname,"wb"); + } + } + if (outfile != NULL) + printf("Extracting %s\n",fname); + else + fprintf(stderr, "%s: Couldn't create %s",prog,fname); + } + else + outfile = NULL; + } + getheader = 0; + break; + default: + if (action == TGZ_LIST) + printf(" %s <---> %s\n",strtime(&tartime),fname); + break; + } + } + else + { + unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining; + + if (outfile != NULL) + { + if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes) + { + fprintf(stderr,"%s: Error writing %s -- skipping\n",prog,fname); + fclose(outfile); + outfile = NULL; + remove(fname); + } + } + remaining -= bytes; + } + + if (remaining == 0) + { + getheader = 1; + if (outfile != NULL) + { + fclose(outfile); + outfile = NULL; + if (action != TGZ_INVALID) + setfiletime(fname,tartime); + } + } + + /* + * Abandon if errors are found + */ + if (action == TGZ_INVALID) + { + error("broken archive"); + break; + } + } + + if (gzclose(in) != Z_OK) + error("failed gzclose"); + + return 0; + } + + + /* ============================================================ */ + + void help(int exitval) + { + printf("untgz version 0.2\n" + " using zlib version %s\n\n", + zlibVersion()); + printf("Usage: untgz file.tgz extract all files\n" + " untgz file.tgz fname ... extract selected files\n" + " untgz -l file.tgz list archive contents\n" + " untgz -h display this help\n"); + exit(exitval); + } + + void error(const char *msg) + { + fprintf(stderr, "%s: %s\n", prog, msg); + exit(1); + } + + + /* ============================================================ */ + + #if defined(WIN32) && defined(__GNUC__) + int _CRT_glob = 0; /* disable argument globbing in MinGW */ + #endif + + int main(int argc,char **argv) + { + int action = TGZ_EXTRACT; + int arg = 1; + char *TGZfile; + gzFile *f; + + prog = strrchr(argv[0],'\\'); + if (prog == NULL) + { + prog = strrchr(argv[0],'/'); + if (prog == NULL) + { + prog = strrchr(argv[0],':'); + if (prog == NULL) + prog = argv[0]; + else + prog++; + } + else + prog++; + } + else + prog++; + + if (argc == 1) + help(0); + + if (strcmp(argv[arg],"-l") == 0) + { + action = TGZ_LIST; + if (argc == ++arg) + help(0); + } + else if (strcmp(argv[arg],"-h") == 0) + { + help(0); + } + + if ((TGZfile = TGZfname(argv[arg])) == NULL) + TGZnotfound(argv[arg]); + + ++arg; + if ((action == TGZ_LIST) && (arg != argc)) + help(1); + + /* + * Process the TGZ file + */ + switch(action) + { + case TGZ_LIST: + case TGZ_EXTRACT: + f = gzopen(TGZfile,"rb"); + if (f == NULL) + { + fprintf(stderr,"%s: Couldn't gzopen %s\n",prog,TGZfile); + return 1; + } + exit(tar(f, action, arg, argc, argv)); + break; + + default: + error("Unknown option"); + exit(1); + } + + return 0; + } From criswell at cs.uiuc.edu Fri Feb 6 10:39:20 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:39:20 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/puff/Makefile README puff.c puff.h zeros.raw Message-ID: <200402061636.KAA15623@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/puff: Makefile added (r1.1) README added (r1.1) puff.c added (r1.1) puff.h added (r1.1) zeros.raw added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+935 -0) Index: llvm/runtime/zlib/contrib/puff/Makefile diff -c /dev/null llvm/runtime/zlib/contrib/puff/Makefile:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/puff/Makefile Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,8 ---- + puff: puff.c puff.h + cc -DTEST -o puff puff.c + + test: puff + puff zeros.raw + + clean: + rm -f puff puff.o Index: llvm/runtime/zlib/contrib/puff/README diff -c /dev/null llvm/runtime/zlib/contrib/puff/README:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/puff/README Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,63 ---- + Puff -- A Simple Inflate + 3 Mar 2003 + Mark Adler + madler at alumni.caltech.edu + + What this is -- + + puff.c provides the routine puff() to decompress the deflate data format. It + does so more slowly than zlib, but the code is about one-fifth the size of the + inflate code in zlib, and written to be very easy to read. + + Why I wrote this -- + + puff.c was written to document the deflate format unambiguously, by virtue of + being working C code. It is meant to supplement RFC 1951, which formally + describes the deflate format. I have received many questions on details of the + deflate format, and I hope that reading this code will answer those questions. + puff.c is heavily commented with details of the deflate format, especially + those little nooks and cranies of the format that might not be obvious from a + specification. + + puff.c may also be useful in applications where code size or memory usage is a + very limited resource, and speed is not as important. + + How to use it -- + + Well, most likely you should just be reading puff.c and using zlib for actual + applications, but if you must ... + + Include puff.h in your code, which provides this prototype: + + int puff(unsigned char *dest, /* pointer to destination pointer */ + unsigned long *destlen, /* amount of output space */ + unsigned char *source, /* pointer to source data pointer */ + unsigned long *sourcelen); /* amount of input available */ + + Then you can call puff() to decompress a deflate stream that is in memory in + its entirety at source, to a sufficiently sized block of memory for the + decompressed data at dest. puff() is the only external symbol in puff.c The + only C library functions that puff.c needs are setjmp() and longjmp(), which + are used to simplify error checking in the code to improve readabilty. puff.c + does no memory allocation, and uses less than 2K bytes off of the stack. + + If destlen is not enough space for the uncompressed data, then inflate will + return an error without writing more than destlen bytes. Note that this means + that in order to decompress the deflate data successfully, you need to know + the size of the uncompressed data ahead of time. + + If needed, puff() can determine the size of the uncompressed data with no + output space. This is done by passing dest equal to (unsigned char *)0. Then + the initial value of *destlen is ignored and *destlen is set to the length of + the uncompressed data. So if the size of the uncompressed data is not known, + then two passes of puff() can be used--first to determine the size, and second + to do the actual inflation after allocating the appropriate memory. Not + pretty, but it works. (This is one of the reasons you should be using zlib.) + + The deflate format is self-terminating. If the deflate stream does not end + in *sourcelen bytes, puff() will return an error without reading at or past + endsource. + + On return, *sourcelen is updated to the amount of input data consumed, and + *destlen is updated to the size of the uncompressed data. See the comments + in puff.c for the possible return codes for puff(). Index: llvm/runtime/zlib/contrib/puff/puff.c diff -c /dev/null llvm/runtime/zlib/contrib/puff/puff.c:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/puff/puff.c Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,833 ---- + /* + * puff.c + * Copyright (C) 2002, 2003 Mark Adler + * For conditions of distribution and use, see copyright notice in puff.h + * version 1.7, 3 Mar 2003 + * + * puff.c is a simple inflate written to be an unambiguous way to specify the + * deflate format. It is not written for speed but rather simplicity. As a + * side benefit, this code might actually be useful when small code is more + * important than speed, such as bootstrap applications. For typical deflate + * data, zlib's inflate() is about four times as fast as puff(). zlib's + * inflate compiles to around 20K on my machine, whereas puff.c compiles to + * around 4K on my machine (a PowerPC using GNU cc). If the faster decode() + * function here is used, then puff() is only twice as slow as zlib's + * inflate(). + * + * All dynamically allocated memory comes from the stack. The stack required + * is less than 2K bytes. This code is compatible with 16-bit int's and + * assumes that long's are at least 32 bits. puff.c uses the short data type, + * assumed to be 16 bits, for arrays in order to to conserve memory. The code + * works whether integers are stored big endian or little endian. + * + * In the comments below are "Format notes" that describe the inflate process + * and document some of the less obvious aspects of the format. This source + * code is meant to supplement RFC 1951, which formally describes the deflate + * format: + * + * http://www.zlib.org/rfc-deflate.html + */ + + /* + * Change history: + * + * 1.0 10 Feb 2002 - First version + * 1.1 17 Feb 2002 - Clarifications of some comments and notes + * - Update puff() dest and source pointers on negative + * errors to facilitate debugging deflators + * - Remove longest from struct huffman -- not needed + * - Simplify offs[] index in construct() + * - Add input size and checking, using longjmp() to + * maintain easy readability + * - Use short data type for large arrays + * - Use pointers instead of long to specify source and + * destination sizes to avoid arbitrary 4 GB limits + * 1.2 17 Mar 2002 - Add faster version of decode(), doubles speed (!), + * but leave simple version for readabilty + * - Make sure invalid distances detected if pointers + * are 16 bits + * - Fix fixed codes table error + * - Provide a scanning mode for determining size of + * uncompressed data + * 1.3 20 Mar 2002 - Go back to lengths for puff() parameters [Jean-loup] + * - Add a puff.h file for the interface + * - Add braces in puff() for else do [Jean-loup] + * - Use indexes instead of pointers for readability + * 1.4 31 Mar 2002 - Simplify construct() code set check + * - Fix some comments + * - Add FIXLCODES #define + * 1.5 6 Apr 2002 - Minor comment fixes + * 1.6 7 Aug 2002 - Minor format changes + * 1.7 3 Mar 2003 - Added test code for distribution + * - Added zlib-like license + */ + + #include /* for setjmp(), longjmp(), and jmp_buf */ + #include "puff.h" /* prototype for puff() */ + + #define local static /* for local function definitions */ + #define NIL ((unsigned char *)0) /* for no output option */ + + /* + * Maximums for allocations and loops. It is not useful to change these -- + * they are fixed by the deflate format. + */ + #define MAXBITS 15 /* maximum bits in a code */ + #define MAXLCODES 286 /* maximum number of literal/length codes */ + #define MAXDCODES 30 /* maximum number of distance codes */ + #define MAXCODES (MAXLCODES+MAXDCODES) /* maximum codes lengths to read */ + #define FIXLCODES 288 /* number of fixed literal/length codes */ + + /* input and output state */ + struct state { + /* output state */ + unsigned char *out; /* output buffer */ + unsigned long outlen; /* available space at out */ + unsigned long outcnt; /* bytes written to out so far */ + + /* input state */ + unsigned char *in; /* input buffer */ + unsigned long inlen; /* available input at in */ + unsigned long incnt; /* bytes read so far */ + int bitbuf; /* bit buffer */ + int bitcnt; /* number of bits in bit buffer */ + + /* input limit error return state for bits() and decode() */ + jmp_buf env; + }; + + /* + * Return need bits from the input stream. This always leaves less than + * eight bits in the buffer. bits() works properly for need == 0. + * + * Format notes: + * + * - Bits are stored in bytes from the least significant bit to the most + * significant bit. Therefore bits are dropped from the bottom of the bit + * buffer, using shift right, and new bytes are appended to the top of the + * bit buffer, using shift left. + */ + local int bits(struct state *s, int need) + { + long val; /* bit accumulator (can use up to 20 bits) */ + + /* load at least need bits into val */ + val = s->bitbuf; + while (s->bitcnt < need) { + if (s->incnt == s->inlen) longjmp(s->env, 1); /* out of input */ + val |= (long)(s->in[s->incnt++]) << s->bitcnt; /* load eight bits */ + s->bitcnt += 8; + } + + /* drop need bits and update buffer, always zero to seven bits left */ + s->bitbuf = (int)(val >> need); + s->bitcnt -= need; + + /* return need bits, zeroing the bits above that */ + return (int)(val & ((1L << need) - 1)); + } + + /* + * Process a stored block. + * + * Format notes: + * + * - After the two-bit stored block type (00), the stored block length and + * stored bytes are byte-aligned for fast copying. Therefore any leftover + * bits in the byte that has the last bit of the type, as many as seven, are + * discarded. The value of the discarded bits are not defined and should not + * be checked against any expectation. + * + * - The second inverted copy of the stored block length does not have to be + * checked, but it's probably a good idea to do so anyway. + * + * - A stored block can have zero length. This is sometimes used to byte-align + * subsets of the compressed data for random access or partial recovery. + */ + local int stored(struct state *s) + { + unsigned len; /* length of stored block */ + + /* discard leftover bits from current byte (assumes s->bitcnt < 8) */ + s->bitbuf = 0; + s->bitcnt = 0; + + /* get length and check against its one's complement */ + if (s->incnt + 4 > s->inlen) return 2; /* not enough input */ + len = s->in[s->incnt++]; + len |= s->in[s->incnt++] << 8; + if (s->in[s->incnt++] != (~len & 0xff) || + s->in[s->incnt++] != ((~len >> 8) & 0xff)) + return -2; /* didn't match complement! */ + + /* copy len bytes from in to out */ + if (s->incnt + len > s->inlen) return 2; /* not enough input */ + if (s->out != NIL) { + if (s->outcnt + len > s->outlen) + return 1; /* not enough output space */ + while (len--) + s->out[s->outcnt++] = s->in[s->incnt++]; + } + else { /* just scanning */ + s->outcnt += len; + s->incnt += len; + } + + /* done with a valid stored block */ + return 0; + } + + /* + * Huffman code decoding tables. count[1..MAXBITS] is the number of symbols of + * each length, which for a canonical code are stepped through in order. + * symbol[] are the symbol values in canonical order, where the number of + * entries is the sum of the counts in count[]. The decoding process can be + * seen in the function decode() below. + */ + struct huffman { + short *count; /* number of symbols of each length */ + short *symbol; /* canonically ordered symbols */ + }; + + /* + * Decode a code from the stream s using huffman table h. Return the symbol or + * a negative value if there is an error. If all of the lengths are zero, i.e. + * an empty code, or if the code is incomplete and an invalid code is received, + * then -9 is returned after reading MAXBITS bits. + * + * Format notes: + * + * - The codes as stored in the compressed data are bit-reversed relative to + * a simple integer ordering of codes of the same lengths. Hence below the + * bits are pulled from the compressed data one at a time and used to + * build the code value reversed from what is in the stream in order to + * permit simple integer comparisons for decoding. A table-based decoding + * scheme (as used in zlib) does not need to do this reversal. + * + * - The first code for the shortest length is all zeros. Subsequent codes of + * the same length are simply integer increments of the previous code. When + * moving up a length, a zero bit is appended to the code. For a complete + * code, the last code of the longest length will be all ones. + * + * - Incomplete codes are handled by this decoder, since they are permitted + * in the deflate format. See the format notes for fixed() and dynamic(). + */ + #ifdef SLOW + local int decode(struct state *s, struct huffman *h) + { + int len; /* current number of bits in code */ + int code; /* len bits being decoded */ + int first; /* first code of length len */ + int count; /* number of codes of length len */ + int index; /* index of first code of length len in symbol table */ + + code = first = index = 0; + for (len = 1; len <= MAXBITS; len++) { + code |= bits(s, 1); /* get next bit */ + count = h->count[len]; + if (code < first + count) /* if length len, return symbol */ + return h->symbol[index + (code - first)]; + index += count; /* else update for next length */ + first += count; + first <<= 1; + code <<= 1; + } + return -9; /* ran out of codes */ + } + + /* + * A faster version of decode() for real applications of this code. It's not + * as readable, but it makes puff() twice as fast. And it only makes the code + * a few percent larger. + */ + #else /* !SLOW */ + local int decode(struct state *s, struct huffman *h) + { + int len; /* current number of bits in code */ + int code; /* len bits being decoded */ + int first; /* first code of length len */ + int count; /* number of codes of length len */ + int index; /* index of first code of length len in symbol table */ + int bitbuf; /* bits from stream */ + int left; /* bits left in next or left to process */ + short *next; /* next number of codes */ + + bitbuf = s->bitbuf; + left = s->bitcnt; + code = first = index = 0; + len = 1; + next = h->count + 1; + while (1) { + while (left--) { + code |= bitbuf & 1; + bitbuf >>= 1; + count = *next++; + if (code < first + count) { /* if length len, return symbol */ + s->bitbuf = bitbuf; + s->bitcnt = (s->bitcnt - len) & 7; + return h->symbol[index + (code - first)]; + } + index += count; /* else update for next length */ + first += count; + first <<= 1; + code <<= 1; + len++; + } + left = (MAXBITS+1) - len; + if (left == 0) break; + if (s->incnt == s->inlen) longjmp(s->env, 1); /* out of input */ + bitbuf = s->in[s->incnt++]; + if (left > 8) left = 8; + } + return -9; /* ran out of codes */ + } + #endif /* SLOW */ + + /* + * Given the list of code lengths length[0..n-1] representing a canonical + * Huffman code for n symbols, construct the tables required to decode those + * codes. Those tables are the number of codes of each length, and the symbols + * sorted by length, retaining their original order within each length. The + * return value is zero for a complete code set, negative for an over- + * subscribed code set, and positive for an incomplete code set. The tables + * can be used if the return value is zero or positive, but they cannot be used + * if the return value is negative. If the return value is zero, it is not + * possible for decode() using that table to return an error--any stream of + * enough bits will resolve to a symbol. If the return value is positive, then + * it is possible for decode() using that table to return an error for received + * codes past the end of the incomplete lengths. + * + * Not used by decode(), but used for error checking, h->count[0] is the number + * of the n symbols not in the code. So n - h->count[0] is the number of + * codes. This is useful for checking for incomplete codes that have more than + * one symbol, which is an error in a dynamic block. + * + * Assumption: for all i in 0..n-1, 0 <= length[i] <= MAXBITS + * This is assured by the construction of the length arrays in dynamic() and + * fixed() and is not verified by construct(). + * + * Format notes: + * + * - Permitted and expected examples of incomplete codes are one of the fixed + * codes and any code with a single symbol which in deflate is coded as one + * bit instead of zero bits. See the format notes for fixed() and dynamic(). + * + * - Within a given code length, the symbols are kept in ascending order for + * the code bits definition. + */ + local int construct(struct huffman *h, short *length, int n) + { + int symbol; /* current symbol when stepping through length[] */ + int len; /* current length when stepping through h->count[] */ + int left; /* number of possible codes left of current length */ + short offs[MAXBITS+1]; /* offsets in symbol table for each length */ + + /* count number of codes of each length */ + for (len = 0; len <= MAXBITS; len++) + h->count[len] = 0; + for (symbol = 0; symbol < n; symbol++) + (h->count[length[symbol]])++; /* assumes lengths are within bounds */ + if (h->count[0] == n) /* no codes! */ + return 0; /* complete, but decode() will fail */ + + /* check for an over-subscribed or incomplete set of lengths */ + left = 1; /* one possible code of zero length */ + for (len = 1; len <= MAXBITS; len++) { + left <<= 1; /* one more bit, double codes left */ + left -= h->count[len]; /* deduct count from possible codes */ + if (left < 0) return left; /* over-subscribed--return negative */ + } /* left > 0 means incomplete */ + + /* generate offsets into symbol table for each length for sorting */ + offs[1] = 0; + for (len = 1; len < MAXBITS; len++) + offs[len + 1] = offs[len] + h->count[len]; + + /* + * put symbols in table sorted by length, by symbol order within each + * length + */ + for (symbol = 0; symbol < n; symbol++) + if (length[symbol] != 0) + h->symbol[offs[length[symbol]]++] = symbol; + + /* return zero for complete set, positive for incomplete set */ + return left; + } + + /* + * Decode literal/length and distance codes until an end-of-block code. + * + * Format notes: + * + * - Compressed data that is after the block type if fixed or after the code + * description if dynamic is a combination of literals and length/distance + * pairs terminated by and end-of-block code. Literals are simply Huffman + * coded bytes. A length/distance pair is a coded length followed by a + * coded distance to represent a string that occurs earlier in the + * uncompressed data that occurs again at the current location. + * + * - Literals, lengths, and the end-of-block code are combined into a single + * code of up to 286 symbols. They are 256 literals (0..255), 29 length + * symbols (257..285), and the end-of-block symbol (256). + * + * - There are 256 possible lengths (3..258), and so 29 symbols are not enough + * to represent all of those. Lengths 3..10 and 258 are in fact represented + * by just a length symbol. Lengths 11..257 are represented as a symbol and + * some number of extra bits that are added as an integer to the base length + * of the length symbol. The number of extra bits is determined by the base + * length symbol. These are in the static arrays below, lens[] for the base + * lengths and lext[] for the corresponding number of extra bits. + * + * - The reason that 258 gets its own symbol is that the longest length is used + * often in highly redundant files. Note that 258 can also be coded as the + * base value 227 plus the maximum extra value of 31. While a good deflate + * should never do this, it is not an error, and should be decoded properly. + * + * - If a length is decoded, including its extra bits if any, then it is + * followed a distance code. There are up to 30 distance symbols. Again + * there are many more possible distances (1..32768), so extra bits are added + * to a base value represented by the symbol. The distances 1..4 get their + * own symbol, but the rest require extra bits. The base distances and + * corresponding number of extra bits are below in the static arrays dist[] + * and dext[]. + * + * - Literal bytes are simply written to the output. A length/distance pair is + * an instruction to copy previously uncompressed bytes to the output. The + * copy is from distance bytes back in the output stream, copying for length + * bytes. + * + * - Distances pointing before the beginning of the output data are not + * permitted. + * + * - Overlapped copies, where the length is greater than the distance, are + * allowed and common. For example, a distance of one and a length of 258 + * simply copies the last byte 258 times. A distance of four and a length of + * twelve copies the last four bytes three times. A simple forward copy + * ignoring whether the length is greater than the distance or not implements + * this correctly. You should not use memcpy() since its behavior is not + * defined for overlapped arrays. You should not use memmove() or bcopy() + * since though their behavior -is- defined for overlapping arrays, it is + * defined to do the wrong thing in this case. + */ + local int codes(struct state *s, + struct huffman *lencode, + struct huffman *distcode) + { + int symbol; /* decoded symbol */ + int len; /* length for copy */ + unsigned dist; /* distance for copy */ + static const short lens[29] = { /* Size base for length codes 257..285 */ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258}; + static const short lext[29] = { /* Extra bits for length codes 257..285 */ + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0}; + static const short dists[30] = { /* Offset base for distance codes 0..29 */ + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577}; + static const short dext[30] = { /* Extra bits for distance codes 0..29 */ + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, + 12, 12, 13, 13}; + + /* decode literals and length/distance pairs */ + do { + symbol = decode(s, lencode); + if (symbol < 0) return symbol; /* invalid symbol */ + if (symbol < 256) { /* literal: symbol is the byte */ + /* write out the literal */ + if (s->out != NIL) { + if (s->outcnt == s->outlen) return 1; + s->out[s->outcnt] = symbol; + } + s->outcnt++; + } + else if (symbol > 256) { /* length */ + /* get and compute length */ + symbol -= 257; + if (symbol >= 29) return -9; /* invalid fixed code */ + len = lens[symbol] + bits(s, lext[symbol]); + + /* get and check distance */ + symbol = decode(s, distcode); + if (symbol < 0) return symbol; /* invalid symbol */ + dist = dists[symbol] + bits(s, dext[symbol]); + if (dist > s->outcnt) + return -10; /* distance too far back */ + + /* copy length bytes from distance bytes back */ + if (s->out != NIL) { + if (s->outcnt + len > s->outlen) return 1; + while (len--) { + s->out[s->outcnt] = s->out[s->outcnt - dist]; + s->outcnt++; + } + } + else + s->outcnt += len; + } + } while (symbol != 256); /* end of block symbol */ + + /* done with a valid fixed or dynamic block */ + return 0; + } + + /* + * Process a fixed codes block. + * + * Format notes: + * + * - This block type can be useful for compressing small amounts of data for + * which the size of the code descriptions in a dynamic block exceeds the + * benefit of custom codes for that block. For fixed codes, no bits are + * spent on code descriptions. Instead the code lengths for literal/length + * codes and distance codes are fixed. The specific lengths for each symbol + * can be seen in the "for" loops below. + * + * - The literal/length code is complete, but has two symbols that are invalid + * and should result in an error if received. This cannot be implemented + * simply as an incomplete code since those two symbols are in the "middle" + * of the code. They are eight bits long and the longest literal/length\ + * code is nine bits. Therefore the code must be constructed with those + * symbols, and the invalid symbols must be detected after decoding. + * + * - The fixed distance codes also have two invalid symbols that should result + * in an error if received. Since all of the distance codes are the same + * length, this can be implemented as an incomplete code. Then the invalid + * codes are detected while decoding. + */ + local int fixed(struct state *s) + { + static int virgin = 1; + static short lencnt[MAXBITS+1], lensym[FIXLCODES]; + static short distcnt[MAXBITS+1], distsym[MAXDCODES]; + static struct huffman lencode = {lencnt, lensym}; + static struct huffman distcode = {distcnt, distsym}; + + /* build fixed huffman tables if first call (may not be thread safe) */ + if (virgin) { + int symbol; + short lengths[FIXLCODES]; + + /* literal/length table */ + for (symbol = 0; symbol < 144; symbol++) + lengths[symbol] = 8; + for (; symbol < 256; symbol++) + lengths[symbol] = 9; + for (; symbol < 280; symbol++) + lengths[symbol] = 7; + for (; symbol < FIXLCODES; symbol++) + lengths[symbol] = 8; + construct(&lencode, lengths, FIXLCODES); + + /* distance table */ + for (symbol = 0; symbol < MAXDCODES; symbol++) + lengths[symbol] = 5; + construct(&distcode, lengths, MAXDCODES); + + /* do this just once */ + virgin = 0; + } + + /* decode data until end-of-block code */ + return codes(s, &lencode, &distcode); + } + + /* + * Process a dynamic codes block. + * + * Format notes: + * + * - A dynamic block starts with a description of the literal/length and + * distance codes for that block. New dynamic blocks allow the compressor to + * rapidly adapt to changing data with new codes optimized for that data. + * + * - The codes used by the deflate format are "canonical", which means that + * the actual bits of the codes are generated in an unambiguous way simply + * from the number of bits in each code. Therefore the code descriptions + * are simply a list of code lengths for each symbol. + * + * - The code lengths are stored in order for the symbols, so lengths are + * provided for each of the literal/length symbols, and for each of the + * distance symbols. + * + * - If a symbol is not used in the block, this is represented by a zero as + * as the code length. This does not mean a zero-length code, but rather + * that no code should be created for this symbol. There is no way in the + * deflate format to represent a zero-length code. + * + * - The maximum number of bits in a code is 15, so the possible lengths for + * any code are 1..15. + * + * - The fact that a length of zero is not permitted for a code has an + * interesting consequence. Normally if only one symbol is used for a given + * code, then in fact that code could be represented with zero bits. However + * in deflate, that code has to be at least one bit. So for example, if + * only a single distance base symbol appears in a block, then it will be + * represented by a single code of length one, in particular one 0 bit. This + * is an incomplete code, since if a 1 bit is received, it has no meaning, + * and should result in an error. So incomplete distance codes of one symbol + * should be permitted, and the receipt of invalid codes should be handled. + * + * - It is also possible to have a single literal/length code, but that code + * must be the end-of-block code, since every dynamic block has one. This + * is not the most efficient way to create an empty block (an empty fixed + * block is fewer bits), but it is allowed by the format. So incomplete + * literal/length codes of one symbol should also be permitted. + * + * - The list of up to 286 length/literal lengths and up to 30 distance lengths + * are themselves compressed using Huffman codes and run-length encoding. In + * the list of code lengths, a 0 symbol means no code, a 1..15 symbol means + * that length, and the symbols 16, 17, and 18 are run-length instructions. + * Each of 16, 17, and 18 are follwed by extra bits to define the length of + * the run. 16 copies the last length 3 to 6 times. 17 represents 3 to 10 + * zero lengths, and 18 represents 11 to 138 zero lengths. Unused symbols + * are common, hence the special coding for zero lengths. + * + * - The symbols for 0..18 are Huffman coded, and so that code must be + * described first. This is simply a sequence of up to 19 three-bit values + * representing no code (0) or the code length for that symbol (1..7). + * + * - A dynamic block starts with three fixed-size counts from which is computed + * the number of literal/length code lengths, the number of distance code + * lengths, and the number of code length code lengths (ok, you come up with + * a better name!) in the code descriptions. For the literal/length and + * distance codes, lengths after those provided are considered zero, i.e. no + * code. The code length code lengths are received in a permuted order (see + * the order[] array below) to make a short code length code length list more + * likely. As it turns out, very short and very long codes are less likely + * to be seen in a dynamic code description, hence what may appear initially + * to be a peculiar ordering. + * + * - Given the number of literal/length code lengths (nlen) and distance code + * lengths (ndist), then they are treated as one long list of nlen + ndist + * code lengths. Therefore run-length coding can and often does cross the + * boundary between the two sets of lengths. + * + * - So to summarize, the code description at the start of a dynamic block is + * three counts for the number of code lengths for the literal/length codes, + * the distance codes, and the code length codes. This is followed by the + * code length code lengths, three bits each. This is used to construct the + * code length code which is used to read the remainder of the lengths. Then + * the literal/length code lengths and distance lengths are read as a single + * set of lengths using the code length codes. Codes are constructed from + * the resulting two sets of lengths, and then finally you can start + * decoding actual compressed data in the block. + * + * - For reference, a "typical" size for the code description in a dynamic + * block is around 80 bytes. + */ + local int dynamic(struct state *s) + { + int nlen, ndist, ncode; /* number of lengths in descriptor */ + int index; /* index of lengths[] */ + int err; /* construct() return value */ + short lengths[MAXCODES]; /* descriptor code lengths */ + short lencnt[MAXBITS+1], lensym[MAXLCODES]; /* lencode memory */ + short distcnt[MAXBITS+1], distsym[MAXDCODES]; /* distcode memory */ + struct huffman lencode = {lencnt, lensym}; /* length code */ + struct huffman distcode = {distcnt, distsym}; /* distance code */ + static const short order[19] = /* permutation of code length codes */ + {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + + /* get number of lengths in each table, check lengths */ + nlen = bits(s, 5) + 257; + ndist = bits(s, 5) + 1; + ncode = bits(s, 4) + 4; + if (nlen > MAXLCODES || ndist > MAXDCODES) + return -3; /* bad counts */ + + /* read code length code lengths (really), missing lengths are zero */ + for (index = 0; index < ncode; index++) + lengths[order[index]] = bits(s, 3); + for (; index < 19; index++) + lengths[order[index]] = 0; + + /* build huffman table for code lengths codes (use lencode temporarily) */ + err = construct(&lencode, lengths, 19); + if (err != 0) return -4; /* require complete code set here */ + + /* read length/literal and distance code length tables */ + index = 0; + while (index < nlen + ndist) { + int symbol; /* decoded value */ + int len; /* last length to repeat */ + + symbol = decode(s, &lencode); + if (symbol < 16) /* length in 0..15 */ + lengths[index++] = symbol; + else { /* repeat instruction */ + len = 0; /* assume repeating zeros */ + if (symbol == 16) { /* repeat last length 3..6 times */ + if (index == 0) return -5; /* no last length! */ + len = lengths[index - 1]; /* last length */ + symbol = 3 + bits(s, 2); + } + else if (symbol == 17) /* repeat zero 3..10 times */ + symbol = 3 + bits(s, 3); + else /* == 18, repeat zero 11..138 times */ + symbol = 11 + bits(s, 7); + if (index + symbol > nlen + ndist) + return -6; /* too many lengths! */ + while (symbol--) /* repeat last or zero symbol times */ + lengths[index++] = len; + } + } + + /* build huffman table for literal/length codes */ + err = construct(&lencode, lengths, nlen); + if (err < 0 || (err > 0 && nlen - lencode.count[0] != 1)) + return -7; /* only allow incomplete codes if just one code */ + + /* build huffman table for distance codes */ + err = construct(&distcode, lengths + nlen, ndist); + if (err < 0 || (err > 0 && ndist - distcode.count[0] != 1)) + return -8; /* only allow incomplete codes if just one code */ + + /* decode data until end-of-block code */ + return codes(s, &lencode, &distcode); + } + + /* + * Inflate source to dest. On return, destlen and sourcelen are updated to the + * size of the uncompressed data and the size of the deflate data respectively. + * On success, the return value of puff() is zero. If there is an error in the + * source data, i.e. it is not in the deflate format, then a negative value is + * returned. If there is not enough input available or there is not enough + * output space, then a positive error is returned. In that case, destlen and + * sourcelen are not updated to facilitate retrying from the beginning with the + * provision of more input data or more output space. In the case of invalid + * inflate data (a negative error), the dest and source pointers are updated to + * facilitate the debugging of deflators. + * + * puff() also has a mode to determine the size of the uncompressed output with + * no output written. For this dest must be (unsigned char *)0. In this case, + * the input value of *destlen is ignored, and on return *destlen is set to the + * size of the uncompressed output. + * + * The return codes are: + * + * 2: available inflate data did not terminate + * 1: output space exhausted before completing inflate + * 0: successful inflate + * -1: invalid block type (type == 3) + * -2: stored block length did not match one's complement + * -3: dynamic block code description: too many length or distance codes + * -4: dynamic block code description: code lengths codes incomplete + * -5: dynamic block code description: repeat lengths with no first length + * -6: dynamic block code description: repeat more than specified lengths + * -7: dynamic block code description: invalid literal/length code lengths + * -8: dynamic block code description: invalid distance code lengths + * -9: invalid literal/length or distance code in fixed or dynamic block + * -10: distance is too far back in fixed or dynamic block + * + * Format notes: + * + * - Three bits are read for each block to determine the kind of block and + * whether or not it is the last block. Then the block is decoded and the + * process repeated if it was not the last block. + * + * - The leftover bits in the last byte of the deflate data after the last + * block (if it was a fixed or dynamic block) are undefined and have no + * expected values to check. + */ + int puff(unsigned char *dest, /* pointer to destination pointer */ + unsigned long *destlen, /* amount of output space */ + unsigned char *source, /* pointer to source data pointer */ + unsigned long *sourcelen) /* amount of input available */ + { + struct state s; /* input/output state */ + int last, type; /* block information */ + int err; /* return value */ + + /* initialize output state */ + s.out = dest; + s.outlen = *destlen; /* ignored if dest is NIL */ + s.outcnt = 0; + + /* initialize input state */ + s.in = source; + s.inlen = *sourcelen; + s.incnt = 0; + s.bitbuf = 0; + s.bitcnt = 0; + + /* return if bits() or decode() tries to read past available input */ + if (setjmp(s.env) != 0) /* if came back here via longjmp() */ + err = 2; /* then skip do-loop, return error */ + else { + /* process blocks until last block or error */ + do { + last = bits(&s, 1); /* one if last block */ + type = bits(&s, 2); /* block type 0..3 */ + err = type == 0 ? stored(&s) : + (type == 1 ? fixed(&s) : + (type == 2 ? dynamic(&s) : + -1)); /* type == 3, invalid */ + if (err != 0) break; /* return with error */ + } while (!last); + } + + /* update the lengths and return */ + if (err <= 0) { + *destlen = s.outcnt; + *sourcelen = s.incnt; + } + return err; + } + + #ifdef TEST + /* Example of how to use puff() */ + #include + #include + #include + #include + + local unsigned char *yank(char *name, unsigned long *len) + { + unsigned long size; + unsigned char *buf; + FILE *in; + struct stat s; + + *len = 0; + if (stat(name, &s)) return NULL; + if ((s.st_mode & S_IFMT) != S_IFREG) return NULL; + size = (unsigned long)(s.st_size); + if (size == 0 || (off_t)size != s.st_size) return NULL; + in = fopen(name, "r"); + if (in == NULL) return NULL; + buf = malloc(size); + if (buf != NULL && fread(buf, 1, size, in) != size) { + free(buf); + buf = NULL; + } + fclose(in); + *len = size; + return buf; + } + + int main(int argc, char **argv) + { + int ret; + unsigned char *source; + unsigned long len, sourcelen, destlen; + + if (argc < 2) return 2; + source = yank(argv[1], &len); + if (source == NULL) return 2; + sourcelen = len; + ret = puff(NIL, &destlen, source, &sourcelen); + if (ret) + printf("puff() failed with return code %d\n", ret); + else { + printf("puff() succeeded uncompressing %lu bytes\n", destlen); + if (sourcelen < len) printf("%lu compressed bytes unused\n", + len - sourcelen); + } + free(source); + return ret; + } + #endif Index: llvm/runtime/zlib/contrib/puff/puff.h diff -c /dev/null llvm/runtime/zlib/contrib/puff/puff.h:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/puff/puff.h Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,31 ---- + /* puff.h + Copyright (C) 2002, 2003 Mark Adler, all rights reserved + version 1.7, 3 Mar 2002 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Mark Adler madler at alumni.caltech.edu + */ + + + /* + * See puff.c for purpose and usage. + */ + int puff(unsigned char *dest, /* pointer to destination pointer */ + unsigned long *destlen, /* amount of output space */ + unsigned char *source, /* pointer to source data pointer */ + unsigned long *sourcelen); /* amount of input available */ Index: llvm/runtime/zlib/contrib/puff/zeros.raw From criswell at cs.uiuc.edu Fri Feb 6 10:39:37 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:39:37 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/masmx86/gvmat32.asm gvmat32c.c inffas32.asm mkasm.bat readme.txt Message-ID: <200402061636.KAA15554@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/masmx86: gvmat32.asm added (r1.1) gvmat32c.c added (r1.1) inffas32.asm added (r1.1) mkasm.bat added (r1.1) readme.txt added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+2168 -0) Index: llvm/runtime/zlib/contrib/masmx86/gvmat32.asm diff -c /dev/null llvm/runtime/zlib/contrib/masmx86/gvmat32.asm:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/masmx86/gvmat32.asm Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,905 ---- + ; + ; gvmat32.asm -- Asm portion of the optimized longest_match for 32 bits x86 + ; Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. + ; File written by Gilles Vollant, by modifiying the longest_match + ; from Jean-loup Gailly in deflate.c + ; It need wmask == 0x7fff + ; (assembly code is faster with a fixed wmask) + ; + ; For Visual C++ 4.2 and ML 6.11c (version in directory \MASM611C of Win95 DDK) + ; I compile with : "ml /coff /Zi /c gvmat32.asm" + ; + + ;uInt longest_match_7fff(s, cur_match) + ; deflate_state *s; + ; IPos cur_match; /* current match */ + + NbStack equ 76 + cur_match equ dword ptr[esp+NbStack-0] + str_s equ dword ptr[esp+NbStack-4] + ; 5 dword on top (ret,ebp,esi,edi,ebx) + adrret equ dword ptr[esp+NbStack-8] + pushebp equ dword ptr[esp+NbStack-12] + pushedi equ dword ptr[esp+NbStack-16] + pushesi equ dword ptr[esp+NbStack-20] + pushebx equ dword ptr[esp+NbStack-24] + + chain_length equ dword ptr [esp+NbStack-28] + limit equ dword ptr [esp+NbStack-32] + best_len equ dword ptr [esp+NbStack-36] + window equ dword ptr [esp+NbStack-40] + prev equ dword ptr [esp+NbStack-44] + scan_start equ word ptr [esp+NbStack-48] + wmask equ dword ptr [esp+NbStack-52] + match_start_ptr equ dword ptr [esp+NbStack-56] + nice_match equ dword ptr [esp+NbStack-60] + scan equ dword ptr [esp+NbStack-64] + + windowlen equ dword ptr [esp+NbStack-68] + match_start equ dword ptr [esp+NbStack-72] + strend equ dword ptr [esp+NbStack-76] + NbStackAdd equ (NbStack-24) + + .386p + + name gvmatch + .MODEL FLAT + + + + ; all the +4 offsets are due to the addition of pending_buf_size (in zlib + ; in the deflate_state structure since the asm code was first written + ; (if you compile with zlib 1.0.4 or older, remove the +4). + ; Note : these value are good with a 8 bytes boundary pack structure + dep_chain_length equ 70h+4 + dep_window equ 2ch+4 + dep_strstart equ 60h+4 + dep_prev_length equ 6ch+4 + dep_nice_match equ 84h+4 + dep_w_size equ 20h+4 + dep_prev equ 34h+4 + dep_w_mask equ 28h+4 + dep_good_match equ 80h+4 + dep_match_start equ 64h+4 + dep_lookahead equ 68h+4 + + + _TEXT segment + + IFDEF NOUNDERLINE + public longest_match_7fff + public longest_match_686 + ; public match_init + ELSE + public _longest_match_7fff + public _longest_match_686 + ; public _match_init + ENDIF + + MAX_MATCH equ 258 + MIN_MATCH equ 3 + MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) + + + + IFDEF NOUNDERLINE + ;match_init proc near + ; ret + ;match_init endp + ELSE + ;_match_init proc near + ; ret + ;_match_init endp + ENDIF + + + IFDEF NOUNDERLINE + longest_match_7fff proc near + ELSE + _longest_match_7fff proc near + ENDIF + + mov edx,[esp+4] + + + + push ebp + push edi + push esi + push ebx + + sub esp,NbStackAdd + + ; initialize or check the variables used in match.asm. + mov ebp,edx + + ; chain_length = s->max_chain_length + ; if (prev_length>=good_match) chain_length >>= 2 + mov edx,[ebp+dep_chain_length] + mov ebx,[ebp+dep_prev_length] + cmp [ebp+dep_good_match],ebx + ja noshr + shr edx,2 + noshr: + ; we increment chain_length because in the asm, the --chain_lenght is in the beginning of the loop + inc edx + mov edi,[ebp+dep_nice_match] + mov chain_length,edx + mov eax,[ebp+dep_lookahead] + cmp eax,edi + ; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + jae nolookaheadnicematch + mov edi,eax + nolookaheadnicematch: + ; best_len = s->prev_length + mov best_len,ebx + + ; window = s->window + mov esi,[ebp+dep_window] + mov ecx,[ebp+dep_strstart] + mov window,esi + + mov nice_match,edi + ; scan = window + strstart + add esi,ecx + mov scan,esi + ; dx = *window + mov dx,word ptr [esi] + ; bx = *(window+best_len-1) + mov bx,word ptr [esi+ebx-1] + add esi,MAX_MATCH-1 + ; scan_start = *scan + mov scan_start,dx + ; strend = scan + MAX_MATCH-1 + mov strend,esi + ; bx = scan_end = *(window+best_len-1) + + ; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? + ; s->strstart - (IPos)MAX_DIST(s) : NIL; + + mov esi,[ebp+dep_w_size] + sub esi,MIN_LOOKAHEAD + ; here esi = MAX_DIST(s) + sub ecx,esi + ja nodist + xor ecx,ecx + nodist: + mov limit,ecx + + ; prev = s->prev + mov edx,[ebp+dep_prev] + mov prev,edx + + ; + mov edx,dword ptr [ebp+dep_match_start] + mov bp,scan_start + mov eax,cur_match + mov match_start,edx + + mov edx,window + mov edi,edx + add edi,best_len + mov esi,prev + dec edi + ; windowlen = window + best_len -1 + mov windowlen,edi + + jmp beginloop2 + align 4 + + ; here, in the loop + ; eax = ax = cur_match + ; ecx = limit + ; bx = scan_end + ; bp = scan_start + ; edi = windowlen (window + best_len -1) + ; esi = prev + + + ;// here; chain_length <=16 + normalbeg0add16: + add chain_length,16 + jz exitloop + normalbeg0: + cmp word ptr[edi+eax],bx + je normalbeg2noroll + rcontlabnoroll: + ; cur_match = prev[cur_match & wmask] + and eax,7fffh + mov ax,word ptr[esi+eax*2] + ; if cur_match > limit, go to exitloop + cmp ecx,eax + jnb exitloop + ; if --chain_length != 0, go to exitloop + dec chain_length + jnz normalbeg0 + jmp exitloop + + normalbeg2noroll: + ; if (scan_start==*(cur_match+window)) goto normalbeg2 + cmp bp,word ptr[edx+eax] + jne rcontlabnoroll + jmp normalbeg2 + + contloop3: + mov edi,windowlen + + ; cur_match = prev[cur_match & wmask] + and eax,7fffh + mov ax,word ptr[esi+eax*2] + ; if cur_match > limit, go to exitloop + cmp ecx,eax + jnbexitloopshort1: + jnb exitloop + ; if --chain_length != 0, go to exitloop + + + ; begin the main loop + beginloop2: + sub chain_length,16+1 + ; if chain_length <=16, don't use the unrolled loop + jna normalbeg0add16 + + do16: + cmp word ptr[edi+eax],bx + je normalbeg2dc0 + + maccn MACRO lab + and eax,7fffh + mov ax,word ptr[esi+eax*2] + cmp ecx,eax + jnb exitloop + cmp word ptr[edi+eax],bx + je lab + ENDM + + rcontloop0: + maccn normalbeg2dc1 + + rcontloop1: + maccn normalbeg2dc2 + + rcontloop2: + maccn normalbeg2dc3 + + rcontloop3: + maccn normalbeg2dc4 + + rcontloop4: + maccn normalbeg2dc5 + + rcontloop5: + maccn normalbeg2dc6 + + rcontloop6: + maccn normalbeg2dc7 + + rcontloop7: + maccn normalbeg2dc8 + + rcontloop8: + maccn normalbeg2dc9 + + rcontloop9: + maccn normalbeg2dc10 + + rcontloop10: + maccn short normalbeg2dc11 + + rcontloop11: + maccn short normalbeg2dc12 + + rcontloop12: + maccn short normalbeg2dc13 + + rcontloop13: + maccn short normalbeg2dc14 + + rcontloop14: + maccn short normalbeg2dc15 + + rcontloop15: + and eax,7fffh + mov ax,word ptr[esi+eax*2] + cmp ecx,eax + jnb exitloop + + sub chain_length,16 + ja do16 + jmp normalbeg0add16 + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + normbeg MACRO rcontlab,valsub + ; if we are here, we know that *(match+best_len-1) == scan_end + cmp bp,word ptr[edx+eax] + ; if (match != scan_start) goto rcontlab + jne rcontlab + ; calculate the good chain_length, and we'll compare scan and match string + add chain_length,16-valsub + jmp iseq + ENDM + + + normalbeg2dc11: + normbeg rcontloop11,11 + + normalbeg2dc12: + normbeg short rcontloop12,12 + + normalbeg2dc13: + normbeg short rcontloop13,13 + + normalbeg2dc14: + normbeg short rcontloop14,14 + + normalbeg2dc15: + normbeg short rcontloop15,15 + + normalbeg2dc10: + normbeg rcontloop10,10 + + normalbeg2dc9: + normbeg rcontloop9,9 + + normalbeg2dc8: + normbeg rcontloop8,8 + + normalbeg2dc7: + normbeg rcontloop7,7 + + normalbeg2dc6: + normbeg rcontloop6,6 + + normalbeg2dc5: + normbeg rcontloop5,5 + + normalbeg2dc4: + normbeg rcontloop4,4 + + normalbeg2dc3: + normbeg rcontloop3,3 + + normalbeg2dc2: + normbeg rcontloop2,2 + + normalbeg2dc1: + normbeg rcontloop1,1 + + normalbeg2dc0: + normbeg rcontloop0,0 + + + ; we go in normalbeg2 because *(ushf*)(match+best_len-1) == scan_end + + normalbeg2: + mov edi,window + + cmp bp,word ptr[edi+eax] + jne contloop3 ; if *(ushf*)match != scan_start, continue + + iseq: + ; if we are here, we know that *(match+best_len-1) == scan_end + ; and (match == scan_start) + + mov edi,edx + mov esi,scan ; esi = scan + add edi,eax ; edi = window + cur_match = match + + mov edx,[esi+3] ; compare manually dword at match+3 + xor edx,[edi+3] ; and scan +3 + + jz begincompare ; if equal, go to long compare + + ; we will determine the unmatch byte and calculate len (in esi) + or dl,dl + je eq1rr + mov esi,3 + jmp trfinval + eq1rr: + or dx,dx + je eq1 + + mov esi,4 + jmp trfinval + eq1: + and edx,0ffffffh + jz eq11 + mov esi,5 + jmp trfinval + eq11: + mov esi,6 + jmp trfinval + + begincompare: + ; here we now scan and match begin same + add edi,6 + add esi,6 + mov ecx,(MAX_MATCH-(2+4))/4 ; scan for at most MAX_MATCH bytes + repe cmpsd ; loop until mismatch + + je trfin ; go to trfin if not unmatch + ; we determine the unmatch byte + sub esi,4 + mov edx,[edi-4] + xor edx,[esi] + + or dl,dl + jnz trfin + inc esi + + or dx,dx + jnz trfin + inc esi + + and edx,0ffffffh + jnz trfin + inc esi + + trfin: + sub esi,scan ; esi = len + trfinval: + ; here we have finised compare, and esi contain len of equal string + cmp esi,best_len ; if len > best_len, go newbestlen + ja short newbestlen + ; now we restore edx, ecx and esi, for the big loop + mov esi,prev + mov ecx,limit + mov edx,window + jmp contloop3 + + newbestlen: + mov best_len,esi ; len become best_len + + mov match_start,eax ; save new position as match_start + cmp esi,nice_match ; if best_len >= nice_match, exit + jae exitloop + mov ecx,scan + mov edx,window ; restore edx=window + add ecx,esi + add esi,edx + + dec esi + mov windowlen,esi ; windowlen = window + best_len-1 + mov bx,[ecx-1] ; bx = *(scan+best_len-1) = scan_end + + ; now we restore ecx and esi, for the big loop : + mov esi,prev + mov ecx,limit + jmp contloop3 + + exitloop: + ; exit : s->match_start=match_start + mov ebx,match_start + mov ebp,str_s + mov ecx,best_len + mov dword ptr [ebp+dep_match_start],ebx + mov eax,dword ptr [ebp+dep_lookahead] + cmp ecx,eax + ja minexlo + mov eax,ecx + minexlo: + ; return min(best_len,s->lookahead) + + ; restore stack and register ebx,esi,edi,ebp + add esp,NbStackAdd + + pop ebx + pop esi + pop edi + pop ebp + ret + InfoAuthor: + ; please don't remove this string ! + ; Your are free use gvmat32 in any fre or commercial apps if you don't remove the string in the binary! + db 0dh,0ah,"GVMat32 optimised assembly code written 1996-98 by Gilles Vollant",0dh,0ah + + + + IFDEF NOUNDERLINE + longest_match_7fff endp + ELSE + _longest_match_7fff endp + ENDIF + + + IFDEF NOUNDERLINE + cpudetect32 proc near + ELSE + _cpudetect32 proc near + ENDIF + + push ebx + + pushfd ; push original EFLAGS + pop eax ; get original EFLAGS + mov ecx, eax ; save original EFLAGS + xor eax, 40000h ; flip AC bit in EFLAGS + push eax ; save new EFLAGS value on stack + popfd ; replace current EFLAGS value + pushfd ; get new EFLAGS + pop eax ; store new EFLAGS in EAX + xor eax, ecx ; can?t toggle AC bit, processor=80386 + jz end_cpu_is_386 ; jump if 80386 processor + push ecx + popfd ; restore AC bit in EFLAGS first + + pushfd + pushfd + pop ecx + + mov eax, ecx ; get original EFLAGS + xor eax, 200000h ; flip ID bit in EFLAGS + push eax ; save new EFLAGS value on stack + popfd ; replace current EFLAGS value + pushfd ; get new EFLAGS + pop eax ; store new EFLAGS in EAX + popfd ; restore original EFLAGS + xor eax, ecx ; can?t toggle ID bit, + je is_old_486 ; processor=old + + mov eax,1 + db 0fh,0a2h ;CPUID + + exitcpudetect: + pop ebx + ret + + end_cpu_is_386: + mov eax,0300h + jmp exitcpudetect + + is_old_486: + mov eax,0400h + jmp exitcpudetect + + IFDEF NOUNDERLINE + cpudetect32 endp + ELSE + _cpudetect32 endp + ENDIF + + + + + MAX_MATCH equ 258 + MIN_MATCH equ 3 + MIN_LOOKAHEAD equ (MAX_MATCH + MIN_MATCH + 1) + MAX_MATCH_8_ equ ((MAX_MATCH + 7) AND 0FFF0h) + + + ;;; stack frame offsets + + chainlenwmask equ esp + 0 ; high word: current chain len + ; low word: s->wmask + window equ esp + 4 ; local copy of s->window + windowbestlen equ esp + 8 ; s->window + bestlen + scanstart equ esp + 16 ; first two bytes of string + scanend equ esp + 12 ; last two bytes of string + scanalign equ esp + 20 ; dword-misalignment of string + nicematch equ esp + 24 ; a good enough match size + bestlen equ esp + 28 ; size of best match so far + scan equ esp + 32 ; ptr to string wanting match + + LocalVarsSize equ 36 + ; saved ebx byte esp + 36 + ; saved edi byte esp + 40 + ; saved esi byte esp + 44 + ; saved ebp byte esp + 48 + ; return address byte esp + 52 + deflatestate equ esp + 56 ; the function arguments + curmatch equ esp + 60 + + ;;; Offsets for fields in the deflate_state structure. These numbers + ;;; are calculated from the definition of deflate_state, with the + ;;; assumption that the compiler will dword-align the fields. (Thus, + ;;; changing the definition of deflate_state could easily cause this + ;;; program to crash horribly, without so much as a warning at + ;;; compile time. Sigh.) + + dsWSize equ 36 + dsWMask equ 44 + dsWindow equ 48 + dsPrev equ 56 + dsMatchLen equ 88 + dsPrevMatch equ 92 + dsStrStart equ 100 + dsMatchStart equ 104 + dsLookahead equ 108 + dsPrevLen equ 112 + dsMaxChainLen equ 116 + dsGoodMatch equ 132 + dsNiceMatch equ 136 + + + ;;; match.asm -- Pentium-Pro-optimized version of longest_match() + ;;; Written for zlib 1.1.2 + ;;; Copyright (C) 1998 Brian Raiter + ;;; You can look at http://www.muppetlabs.com/~breadbox/software/assembly.html + ;;; + ;;; This is free software; you can redistribute it and/or modify it + ;;; under the terms of the GNU General Public License. + + ;GLOBAL _longest_match, _match_init + + + ;SECTION .text + + ;;; uInt longest_match(deflate_state *deflatestate, IPos curmatch) + + ;_longest_match: + IFDEF NOUNDERLINE + longest_match_686 proc near + ELSE + _longest_match_686 proc near + ENDIF + + + ;;; Save registers that the compiler may be using, and adjust esp to + ;;; make room for our stack frame. + + push ebp + push edi + push esi + push ebx + sub esp, LocalVarsSize + + ;;; Retrieve the function arguments. ecx will hold cur_match + ;;; throughout the entire function. edx will hold the pointer to the + ;;; deflate_state structure during the function's setup (before + ;;; entering the main loop. + + mov edx, [deflatestate] + mov ecx, [curmatch] + + ;;; uInt wmask = s->w_mask; + ;;; unsigned chain_length = s->max_chain_length; + ;;; if (s->prev_length >= s->good_match) { + ;;; chain_length >>= 2; + ;;; } + + mov eax, [edx + dsPrevLen] + mov ebx, [edx + dsGoodMatch] + cmp eax, ebx + mov eax, [edx + dsWMask] + mov ebx, [edx + dsMaxChainLen] + jl LastMatchGood + shr ebx, 2 + LastMatchGood: + + ;;; chainlen is decremented once beforehand so that the function can + ;;; use the sign flag instead of the zero flag for the exit test. + ;;; It is then shifted into the high word, to make room for the wmask + ;;; value, which it will always accompany. + + dec ebx + shl ebx, 16 + or ebx, eax + mov [chainlenwmask], ebx + + ;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + + mov eax, [edx + dsNiceMatch] + mov ebx, [edx + dsLookahead] + cmp ebx, eax + jl LookaheadLess + mov ebx, eax + LookaheadLess: mov [nicematch], ebx + + ;;; register Bytef *scan = s->window + s->strstart; + + mov esi, [edx + dsWindow] + mov [window], esi + mov ebp, [edx + dsStrStart] + lea edi, [esi + ebp] + mov [scan], edi + + ;;; Determine how many bytes the scan ptr is off from being + ;;; dword-aligned. + + mov eax, edi + neg eax + and eax, 3 + mov [scanalign], eax + + ;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? + ;;; s->strstart - (IPos)MAX_DIST(s) : NIL; + + mov eax, [edx + dsWSize] + sub eax, MIN_LOOKAHEAD + sub ebp, eax + jg LimitPositive + xor ebp, ebp + LimitPositive: + + ;;; int best_len = s->prev_length; + + mov eax, [edx + dsPrevLen] + mov [bestlen], eax + + ;;; Store the sum of s->window + best_len in esi locally, and in esi. + + add esi, eax + mov [windowbestlen], esi + + ;;; register ush scan_start = *(ushf*)scan; + ;;; register ush scan_end = *(ushf*)(scan+best_len-1); + ;;; Posf *prev = s->prev; + + movzx ebx, word ptr [edi] + mov [scanstart], ebx + movzx ebx, word ptr [edi + eax - 1] + mov [scanend], ebx + mov edi, [edx + dsPrev] + + ;;; Jump into the main loop. + + mov edx, [chainlenwmask] + jmp short LoopEntry + + align 4 + + ;;; do { + ;;; match = s->window + cur_match; + ;;; if (*(ushf*)(match+best_len-1) != scan_end || + ;;; *(ushf*)match != scan_start) continue; + ;;; [...] + ;;; } while ((cur_match = prev[cur_match & wmask]) > limit + ;;; && --chain_length != 0); + ;;; + ;;; Here is the inner loop of the function. The function will spend the + ;;; majority of its time in this loop, and majority of that time will + ;;; be spent in the first ten instructions. + ;;; + ;;; Within this loop: + ;;; ebx = scanend + ;;; ecx = curmatch + ;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) + ;;; esi = windowbestlen - i.e., (window + bestlen) + ;;; edi = prev + ;;; ebp = limit + + LookupLoop: + and ecx, edx + movzx ecx, word ptr [edi + ecx*2] + cmp ecx, ebp + jbe LeaveNow + sub edx, 00010000h + js LeaveNow + LoopEntry: movzx eax, word ptr [esi + ecx - 1] + cmp eax, ebx + jnz LookupLoop + mov eax, [window] + movzx eax, word ptr [eax + ecx] + cmp eax, [scanstart] + jnz LookupLoop + + ;;; Store the current value of chainlen. + + mov [chainlenwmask], edx + + ;;; Point edi to the string under scrutiny, and esi to the string we + ;;; are hoping to match it up with. In actuality, esi and edi are + ;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is + ;;; initialized to -(MAX_MATCH_8 - scanalign). + + mov esi, [window] + mov edi, [scan] + add esi, ecx + mov eax, [scanalign] + mov edx, 0fffffef8h; -(MAX_MATCH_8) + lea edi, [edi + eax + 0108h] ;MAX_MATCH_8] + lea esi, [esi + eax + 0108h] ;MAX_MATCH_8] + + ;;; Test the strings for equality, 8 bytes at a time. At the end, + ;;; adjust edx so that it is offset to the exact byte that mismatched. + ;;; + ;;; We already know at this point that the first three bytes of the + ;;; strings match each other, and they can be safely passed over before + ;;; starting the compare loop. So what this code does is skip over 0-3 + ;;; bytes, as much as necessary in order to dword-align the edi + ;;; pointer. (esi will still be misaligned three times out of four.) + ;;; + ;;; It should be confessed that this loop usually does not represent + ;;; much of the total running time. Replacing it with a more + ;;; straightforward "rep cmpsb" would not drastically degrade + ;;; performance. + + LoopCmps: + mov eax, [esi + edx] + xor eax, [edi + edx] + jnz LeaveLoopCmps + mov eax, [esi + edx + 4] + xor eax, [edi + edx + 4] + jnz LeaveLoopCmps4 + add edx, 8 + jnz LoopCmps + jmp short LenMaximum + LeaveLoopCmps4: add edx, 4 + LeaveLoopCmps: test eax, 0000FFFFh + jnz LenLower + add edx, 2 + shr eax, 16 + LenLower: sub al, 1 + adc edx, 0 + + ;;; Calculate the length of the match. If it is longer than MAX_MATCH, + ;;; then automatically accept it as the best possible match and leave. + + lea eax, [edi + edx] + mov edi, [scan] + sub eax, edi + cmp eax, MAX_MATCH + jge LenMaximum + + ;;; If the length of the match is not longer than the best match we + ;;; have so far, then forget it and return to the lookup loop. + + mov edx, [deflatestate] + mov ebx, [bestlen] + cmp eax, ebx + jg LongerMatch + mov esi, [windowbestlen] + mov edi, [edx + dsPrev] + mov ebx, [scanend] + mov edx, [chainlenwmask] + jmp LookupLoop + + ;;; s->match_start = cur_match; + ;;; best_len = len; + ;;; if (len >= nice_match) break; + ;;; scan_end = *(ushf*)(scan+best_len-1); + + LongerMatch: mov ebx, [nicematch] + mov [bestlen], eax + mov [edx + dsMatchStart], ecx + cmp eax, ebx + jge LeaveNow + mov esi, [window] + add esi, eax + mov [windowbestlen], esi + movzx ebx, word ptr [edi + eax - 1] + mov edi, [edx + dsPrev] + mov [scanend], ebx + mov edx, [chainlenwmask] + jmp LookupLoop + + ;;; Accept the current string, with the maximum possible length. + + LenMaximum: mov edx, [deflatestate] + mov dword ptr [bestlen], MAX_MATCH + mov [edx + dsMatchStart], ecx + + ;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len; + ;;; return s->lookahead; + + LeaveNow: + mov edx, [deflatestate] + mov ebx, [bestlen] + mov eax, [edx + dsLookahead] + cmp ebx, eax + jg LookaheadRet + mov eax, ebx + LookaheadRet: + + ;;; Restore the stack and return from whence we came. + + add esp, LocalVarsSize + pop ebx + pop esi + pop edi + pop ebp + + ret + ; please don't remove this string ! + ; Your can freely use gvmat32 in any free or commercial app if you don't remove the string in the binary! + db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998",0dh,0ah + + IFDEF NOUNDERLINE + longest_match_686 endp + ELSE + _longest_match_686 endp + ENDIF + + _TEXT ends + end Index: llvm/runtime/zlib/contrib/masmx86/gvmat32c.c diff -c /dev/null llvm/runtime/zlib/contrib/masmx86/gvmat32c.c:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/masmx86/gvmat32c.c Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,206 ---- + /* gvmat32.c -- C portion of the optimized longest_match for 32 bits x86 + * Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. + * File written by Gilles Vollant, by modifiying the longest_match + * from Jean-loup Gailly in deflate.c + * it prepare all parameters and call the assembly longest_match_gvasm + * longest_match execute standard C code is wmask != 0x7fff + * (assembly code is faster with a fixed wmask) + * + */ + + #include "deflate.h" + + #ifdef ASMV + #define NIL 0 + + #define UNALIGNED_OK + + + /* if your C compiler don't add underline before function name, + define ADD_UNDERLINE_ASMFUNC */ + #ifdef ADD_UNDERLINE_ASMFUNC + #define longest_match_7fff _longest_match_7fff + #define longest_match_686 _longest_match_686 + #define cpudetect32 _cpudetect32 + #endif + + + + void match_init() + { + } + + unsigned long cpudetect32(); + + uInt longest_match_c( + deflate_state *s, + IPos cur_match); /* current match */ + + + uInt longest_match_7fff( + deflate_state *s, + IPos cur_match); /* current match */ + + uInt longest_match_686( + deflate_state *s, + IPos cur_match); /* current match */ + + uInt longest_match( + deflate_state *s, + IPos cur_match) /* current match */ + { + static uInt iIsPPro=2; + + if ((s->w_mask == 0x7fff) && (iIsPPro==0)) + return longest_match_7fff(s,cur_match); + + if (iIsPPro==1) + return longest_match_686(s,cur_match); + + if (iIsPPro==2) + iIsPPro = (((cpudetect32()/0x100)&0xf)>=6) ? 1 : 0; + + return longest_match_c(s,cur_match); + } + + + + uInt longest_match_c(s, cur_match) + deflate_state *s; + IPos cur_match; /* current match */ + { + unsigned chain_length = s->max_chain_length;/* max hash chain length */ + register Bytef *scan = s->window + s->strstart; /* current string */ + register Bytef *match; /* matched string */ + register int len; /* length of current match */ + int best_len = s->prev_length; /* best match length so far */ + int nice_match = s->nice_match; /* stop if match long enough */ + IPos limit = s->strstart > (IPos)MAX_DIST(s) ? + s->strstart - (IPos)MAX_DIST(s) : NIL; + /* Stop when cur_match becomes <= limit. To simplify the code, + * we prevent matches with the string of window index 0. + */ + Posf *prev = s->prev; + uInt wmask = s->w_mask; + + #ifdef UNALIGNED_OK + /* Compare two bytes at a time. Note: this is not always beneficial. + * Try with and without -DUNALIGNED_OK to check. + */ + register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; + register ush scan_start = *(ushf*)scan; + register ush scan_end = *(ushf*)(scan+best_len-1); + #else + register Bytef *strend = s->window + s->strstart + MAX_MATCH; + register Byte scan_end1 = scan[best_len-1]; + register Byte scan_end = scan[best_len]; + #endif + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + /* Do not waste too much time if we already have a good match: */ + if (s->prev_length >= s->good_match) { + chain_length >>= 2; + } + /* Do not look for matches beyond the end of the input. This is necessary + * to make deflate deterministic. + */ + if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + do { + Assert(cur_match < s->strstart, "no future"); + match = s->window + cur_match; + + /* Skip to next match if the match length cannot increase + * or if the match length is less than 2: + */ + #if (defined(UNALIGNED_OK) && MAX_MATCH == 258) + /* This code assumes sizeof(unsigned short) == 2. Do not use + * UNALIGNED_OK if your compiler uses a different size. + */ + if (*(ushf*)(match+best_len-1) != scan_end || + *(ushf*)match != scan_start) continue; + + /* It is not necessary to compare scan[2] and match[2] since they are + * always equal when the other bytes match, given that the hash keys + * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at + * strstart+3, +5, ... up to strstart+257. We check for insufficient + * lookahead only every 4th comparison; the 128th check will be made + * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is + * necessary to put more guard bytes at the end of the window, or + * to check more often for insufficient lookahead. + */ + Assert(scan[2] == match[2], "scan[2]?"); + scan++, match++; + do { + } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + scan < strend); + /* The funny "do {}" generates better code on most compilers */ + + /* Here, scan <= window+strstart+257 */ + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + if (*scan == *match) scan++; + + len = (MAX_MATCH - 1) - (int)(strend-scan); + scan = strend - (MAX_MATCH-1); + + #else /* UNALIGNED_OK */ + + if (match[best_len] != scan_end || + match[best_len-1] != scan_end1 || + *match != *scan || + *++match != scan[1]) continue; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match++; + Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + scan = strend - MAX_MATCH; + + #endif /* UNALIGNED_OK */ + + if (len > best_len) { + s->match_start = cur_match; + best_len = len; + if (len >= nice_match) break; + #ifdef UNALIGNED_OK + scan_end = *(ushf*)(scan+best_len-1); + #else + scan_end1 = scan[best_len-1]; + scan_end = scan[best_len]; + #endif + } + } while ((cur_match = prev[cur_match & wmask]) > limit + && --chain_length != 0); + + if ((uInt)best_len <= s->lookahead) return (uInt)best_len; + return s->lookahead; + } + + #endif /* ASMV */ Index: llvm/runtime/zlib/contrib/masmx86/inffas32.asm diff -c /dev/null llvm/runtime/zlib/contrib/masmx86/inffas32.asm:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/masmx86/inffas32.asm Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,1033 ---- + ; 75 "inffast.S" + ;FILE "inffast.S" + + ;;;GLOBAL _inflate_fast + + ;;;SECTION .text + + + + .586p + .mmx + + name inflate_fast_x86 + .MODEL FLAT + + _DATA segment + inflate_fast_use_mmx: + dd 1 + + + _TEXT segment + PUBLIC _inflate_fast + + ALIGN 4 + _inflate_fast: + jmp inflate_fast_entry + + + + ALIGN 4 + db 'Fast decoding Code from Chris Anderson' + db 0 + + ALIGN 4 + invalid_literal_length_code_msg: + db 'invalid literal/length code' + db 0 + + ALIGN 4 + invalid_distance_code_msg: + db 'invalid distance code' + db 0 + + ALIGN 4 + invalid_distance_too_far_msg: + db 'invalid distance too far back' + db 0 + + + ALIGN 4 + inflate_fast_mask: + dd 0 + dd 1 + dd 3 + dd 7 + dd 15 + dd 31 + dd 63 + dd 127 + dd 255 + dd 511 + dd 1023 + dd 2047 + dd 4095 + dd 8191 + dd 16383 + dd 32767 + dd 65535 + dd 131071 + dd 262143 + dd 524287 + dd 1048575 + dd 2097151 + dd 4194303 + dd 8388607 + dd 16777215 + dd 33554431 + dd 67108863 + dd 134217727 + dd 268435455 + dd 536870911 + dd 1073741823 + dd 2147483647 + dd 4294967295 + + + + mode_state equ 0 ;/* state->mode */ + wsize_state equ 32 ;/* state->wsize */ + write_state equ (36+4) ;/* state->write */ + window_state equ (40+4) ;/* state->window */ + hold_state equ (44+4) ;/* state->hold */ + bits_state equ (48+4) ;/* state->bits */ + lencode_state equ (64+4) ;/* state->lencode */ + distcode_state equ (68+4) ;/* state->distcode */ + lenbits_state equ (72+4) ;/* state->lenbits */ + distbits_state equ (76+4) ;/* state->distbits */ + + + ;;SECTION .text + ; 205 "inffast.S" + ;GLOBAL inflate_fast_use_mmx + + ;SECTION .data + + + ; GLOBAL inflate_fast_use_mmx:object + ;.size inflate_fast_use_mmx, 4 + ; 226 "inffast.S" + ;SECTION .text + + ALIGN 4 + inflate_fast_entry: + push edi + push esi + push ebp + push ebx + pushfd + sub esp,64 + cld + + + + + mov esi, [esp+88] + mov edi, [esi+28] + + + + + + + + mov edx, [esi+4] + mov eax, [esi+0] + + add edx,eax + sub edx,11 + + mov [esp+44],eax + mov [esp+20],edx + + mov ebp, [esp+92] + mov ecx, [esi+16] + mov ebx, [esi+12] + + sub ebp,ecx + neg ebp + add ebp,ebx + + sub ecx,257 + add ecx,ebx + + mov [esp+60],ebx + mov [esp+40],ebp + mov [esp+16],ecx + ; 285 "inffast.S" + mov eax, [edi+lencode_state] + mov ecx, [edi+distcode_state] + + mov [esp+8],eax + mov [esp+12],ecx + + mov eax,1 + mov ecx, [edi+lenbits_state] + shl eax,cl + dec eax + mov [esp+0],eax + + mov eax,1 + mov ecx, [edi+distbits_state] + shl eax,cl + dec eax + mov [esp+4],eax + + mov eax, [edi+wsize_state] + mov ecx, [edi+write_state] + mov edx, [edi+window_state] + + mov [esp+52],eax + mov [esp+48],ecx + mov [esp+56],edx + + mov ebp, [edi+hold_state] + mov ebx, [edi+bits_state] + ; 321 "inffast.S" + mov esi, [esp+44] + mov ecx, [esp+20] + cmp ecx,esi + ja L_align_long + + add ecx,11 + sub ecx,esi + mov eax,12 + sub eax,ecx + lea edi, [esp+28] + rep movsb + mov ecx,eax + xor eax,eax + rep stosb + lea esi, [esp+28] + mov [esp+20],esi + jmp L_is_aligned + + + L_align_long: + test esi,3 + jz L_is_aligned + xor eax,eax + mov al, [esi] + inc esi + mov ecx,ebx + add ebx,8 + shl eax,cl + or ebp,eax + jmp L_align_long + + L_is_aligned: + mov edi, [esp+60] + ; 366 "inffast.S" + L_check_mmx: + cmp dword ptr [inflate_fast_use_mmx],2 + je L_init_mmx + ja L_do_loop + + push eax + push ebx + push ecx + push edx + pushfd + mov eax, [esp] + xor dword ptr [esp],0200000h + + + + + popfd + pushfd + pop edx + xor edx,eax + jz L_dont_use_mmx + xor eax,eax + cpuid + cmp ebx,0756e6547h + jne L_dont_use_mmx + cmp ecx,06c65746eh + jne L_dont_use_mmx + cmp edx,049656e69h + jne L_dont_use_mmx + mov eax,1 + cpuid + shr eax,8 + and eax,15 + cmp eax,6 + jne L_dont_use_mmx + test edx,0800000h + jnz L_use_mmx + jmp L_dont_use_mmx + L_use_mmx: + mov dword ptr [inflate_fast_use_mmx],2 + jmp L_check_mmx_pop + L_dont_use_mmx: + mov dword ptr [inflate_fast_use_mmx],3 + L_check_mmx_pop: + pop edx + pop ecx + pop ebx + pop eax + jmp L_check_mmx + ; 426 "inffast.S" + ALIGN 4 + L_do_loop: + ; 437 "inffast.S" + cmp bl,15 + ja L_get_length_code + + xor eax,eax + lodsw + mov cl,bl + add bl,16 + shl eax,cl + or ebp,eax + + L_get_length_code: + mov edx, [esp+0] + mov ecx, [esp+8] + and edx,ebp + mov eax, [ecx+edx*4] + + L_dolen: + + + + + + + mov cl,ah + sub bl,ah + shr ebp,cl + + + + + + + test al,al + jnz L_test_for_length_base + + shr eax,16 + stosb + + L_while_test: + + + cmp [esp+16],edi + jbe L_break_loop + + cmp [esp+20],esi + ja L_do_loop + jmp L_break_loop + + L_test_for_length_base: + ; 502 "inffast.S" + mov edx,eax + shr edx,16 + mov cl,al + + test al,16 + jz L_test_for_second_level_length + and cl,15 + jz L_save_len + cmp bl,cl + jae L_add_bits_to_len + + mov ch,cl + xor eax,eax + lodsw + mov cl,bl + add bl,16 + shl eax,cl + or ebp,eax + mov cl,ch + + L_add_bits_to_len: + mov eax,1 + shl eax,cl + dec eax + sub bl,cl + and eax,ebp + shr ebp,cl + add edx,eax + + L_save_len: + mov [esp+24],edx + + + L_decode_distance: + ; 549 "inffast.S" + cmp bl,15 + ja L_get_distance_code + + xor eax,eax + lodsw + mov cl,bl + add bl,16 + shl eax,cl + or ebp,eax + + L_get_distance_code: + mov edx, [esp+4] + mov ecx, [esp+12] + and edx,ebp + mov eax, [ecx+edx*4] + + + L_dodist: + mov edx,eax + shr edx,16 + mov cl,ah + sub bl,ah + shr ebp,cl + ; 584 "inffast.S" + mov cl,al + + test al,16 + jz L_test_for_second_level_dist + and cl,15 + jz L_check_dist_one + cmp bl,cl + jae L_add_bits_to_dist + + mov ch,cl + xor eax,eax + lodsw + mov cl,bl + add bl,16 + shl eax,cl + or ebp,eax + mov cl,ch + + L_add_bits_to_dist: + mov eax,1 + shl eax,cl + dec eax + sub bl,cl + and eax,ebp + shr ebp,cl + add edx,eax + jmp L_check_window + + L_check_window: + ; 625 "inffast.S" + mov [esp+44],esi + mov eax,edi + sub eax, [esp+40] + + cmp eax,edx + jb L_clip_window + + mov ecx, [esp+24] + mov esi,edi + sub esi,edx + + sub ecx,3 + mov al, [esi] + mov [edi],al + mov al, [esi+1] + mov dl, [esi+2] + add esi,3 + mov [edi+1],al + mov [edi+2],dl + add edi,3 + rep movsb + + mov esi, [esp+44] + jmp L_while_test + + ALIGN 4 + L_check_dist_one: + cmp edx,1 + jne L_check_window + cmp [esp+40],edi + je L_check_window + + dec edi + mov ecx, [esp+24] + mov al, [edi] + sub ecx,3 + + mov [edi+1],al + mov [edi+2],al + mov [edi+3],al + add edi,4 + rep stosb + + jmp L_while_test + + ALIGN 4 + L_test_for_second_level_length: + + + + + test al,64 + jnz L_test_for_end_of_block + + mov eax,1 + shl eax,cl + dec eax + and eax,ebp + add eax,edx + mov edx, [esp+8] + mov eax, [edx+eax*4] + jmp L_dolen + + ALIGN 4 + L_test_for_second_level_dist: + + + + + test al,64 + jnz L_invalid_distance_code + + mov eax,1 + shl eax,cl + dec eax + and eax,ebp + add eax,edx + mov edx, [esp+12] + mov eax, [edx+eax*4] + jmp L_dodist + + ALIGN 4 + L_clip_window: + ; 721 "inffast.S" + mov ecx,eax + mov eax, [esp+52] + neg ecx + mov esi, [esp+56] + + cmp eax,edx + jb L_invalid_distance_too_far + + add ecx,edx + cmp dword ptr [esp+48],0 + jne L_wrap_around_window + + sub eax,ecx + add esi,eax + ; 749 "inffast.S" + mov eax, [esp+24] + cmp eax,ecx + jbe L_do_copy1 + + sub eax,ecx + rep movsb + mov esi,edi + sub esi,edx + jmp L_do_copy1 + + cmp eax,ecx + jbe L_do_copy1 + + sub eax,ecx + rep movsb + mov esi,edi + sub esi,edx + jmp L_do_copy1 + + L_wrap_around_window: + ; 793 "inffast.S" + mov eax, [esp+48] + cmp ecx,eax + jbe L_contiguous_in_window + + add esi, [esp+52] + add esi,eax + sub esi,ecx + sub ecx,eax + + + mov eax, [esp+24] + cmp eax,ecx + jbe L_do_copy1 + + sub eax,ecx + rep movsb + mov esi, [esp+56] + mov ecx, [esp+48] + cmp eax,ecx + jbe L_do_copy1 + + sub eax,ecx + rep movsb + mov esi,edi + sub esi,edx + jmp L_do_copy1 + + L_contiguous_in_window: + ; 836 "inffast.S" + add esi,eax + sub esi,ecx + + + mov eax, [esp+24] + cmp eax,ecx + jbe L_do_copy1 + + sub eax,ecx + rep movsb + mov esi,edi + sub esi,edx + + L_do_copy1: + ; 862 "inffast.S" + mov ecx,eax + rep movsb + + mov esi, [esp+44] + jmp L_while_test + ; 878 "inffast.S" + ALIGN 4 + L_init_mmx: + emms + + + + + + movd mm0,ebp + mov ebp,ebx + ; 896 "inffast.S" + movd mm4,[esp+0] + movq mm3,mm4 + movd mm5,[esp+4] + movq mm2,mm5 + pxor mm1,mm1 + mov ebx, [esp+8] + jmp L_do_loop_mmx + + ALIGN 4 + L_do_loop_mmx: + psrlq mm0,mm1 + + cmp ebp,32 + ja L_get_length_code_mmx + + movd mm6,ebp + movd mm7,[esi] + add esi,4 + psllq mm7,mm6 + add ebp,32 + por mm0,mm7 + + L_get_length_code_mmx: + pand mm4,mm0 + movd eax,mm4 + movq mm4,mm3 + mov eax, [ebx+eax*4] + + L_dolen_mmx: + movzx ecx,ah + movd mm1,ecx + sub ebp,ecx + + test al,al + jnz L_test_for_length_base_mmx + + shr eax,16 + stosb + + L_while_test_mmx: + + + cmp [esp+16],edi + jbe L_break_loop + + cmp [esp+20],esi + ja L_do_loop_mmx + jmp L_break_loop + + L_test_for_length_base_mmx: + + mov edx,eax + shr edx,16 + + test al,16 + jz L_test_for_second_level_length_mmx + and eax,15 + jz L_decode_distance_mmx + + psrlq mm0,mm1 + movd mm1,eax + movd ecx,mm0 + sub ebp,eax + and ecx, [inflate_fast_mask+eax*4] + add edx,ecx + + L_decode_distance_mmx: + psrlq mm0,mm1 + + cmp ebp,32 + ja L_get_dist_code_mmx + + movd mm6,ebp + movd mm7,[esi] + add esi,4 + psllq mm7,mm6 + add ebp,32 + por mm0,mm7 + + L_get_dist_code_mmx: + mov ebx, [esp+12] + pand mm5,mm0 + movd eax,mm5 + movq mm5,mm2 + mov eax, [ebx+eax*4] + + L_dodist_mmx: + + movzx ecx,ah + mov ebx,eax + shr ebx,16 + sub ebp,ecx + movd mm1,ecx + + test al,16 + jz L_test_for_second_level_dist_mmx + and eax,15 + jz L_check_dist_one_mmx + + L_add_bits_to_dist_mmx: + psrlq mm0,mm1 + movd mm1,eax + movd ecx,mm0 + sub ebp,eax + and ecx, [inflate_fast_mask+eax*4] + add ebx,ecx + + L_check_window_mmx: + mov [esp+44],esi + mov eax,edi + sub eax, [esp+40] + + cmp eax,ebx + jb L_clip_window_mmx + + mov ecx,edx + mov esi,edi + sub esi,ebx + + sub ecx,3 + mov al, [esi] + mov [edi],al + mov al, [esi+1] + mov dl, [esi+2] + add esi,3 + mov [edi+1],al + mov [edi+2],dl + add edi,3 + rep movsb + + mov esi, [esp+44] + mov ebx, [esp+8] + jmp L_while_test_mmx + + ALIGN 4 + L_check_dist_one_mmx: + cmp ebx,1 + jne L_check_window_mmx + cmp [esp+40],edi + je L_check_window_mmx + + dec edi + mov ecx,edx + mov al, [edi] + sub ecx,3 + + mov [edi+1],al + mov [edi+2],al + mov [edi+3],al + add edi,4 + rep stosb + + mov ebx, [esp+8] + jmp L_while_test_mmx + + ALIGN 4 + L_test_for_second_level_length_mmx: + test al,64 + jnz L_test_for_end_of_block + + and eax,15 + psrlq mm0,mm1 + movd ecx,mm0 + and ecx, [inflate_fast_mask+eax*4] + add ecx,edx + mov eax, [ebx+ecx*4] + jmp L_dolen_mmx + + ALIGN 4 + L_test_for_second_level_dist_mmx: + test al,64 + jnz L_invalid_distance_code + + and eax,15 + psrlq mm0,mm1 + movd ecx,mm0 + and ecx, [inflate_fast_mask+eax*4] + mov eax, [esp+12] + add ecx,ebx + mov eax, [eax+ecx*4] + jmp L_dodist_mmx + + ALIGN 4 + L_clip_window_mmx: + + mov ecx,eax + mov eax, [esp+52] + neg ecx + mov esi, [esp+56] + + cmp eax,ebx + jb L_invalid_distance_too_far + + add ecx,ebx + cmp dword ptr [esp+48],0 + jne L_wrap_around_window_mmx + + sub eax,ecx + add esi,eax + + cmp edx,ecx + jbe L_do_copy1_mmx + + sub edx,ecx + rep movsb + mov esi,edi + sub esi,ebx + jmp L_do_copy1_mmx + + cmp edx,ecx + jbe L_do_copy1_mmx + + sub edx,ecx + rep movsb + mov esi,edi + sub esi,ebx + jmp L_do_copy1_mmx + + L_wrap_around_window_mmx: + + mov eax, [esp+48] + cmp ecx,eax + jbe L_contiguous_in_window_mmx + + add esi, [esp+52] + add esi,eax + sub esi,ecx + sub ecx,eax + + + cmp edx,ecx + jbe L_do_copy1_mmx + + sub edx,ecx + rep movsb + mov esi, [esp+56] + mov ecx, [esp+48] + cmp edx,ecx + jbe L_do_copy1_mmx + + sub edx,ecx + rep movsb + mov esi,edi + sub esi,ebx + jmp L_do_copy1_mmx + + L_contiguous_in_window_mmx: + + add esi,eax + sub esi,ecx + + + cmp edx,ecx + jbe L_do_copy1_mmx + + sub edx,ecx + rep movsb + mov esi,edi + sub esi,ebx + + L_do_copy1_mmx: + + + mov ecx,edx + rep movsb + + mov esi, [esp+44] + mov ebx, [esp+8] + jmp L_while_test_mmx + ; 1174 "inffast.S" + L_invalid_distance_code: + + + + + + mov ecx, invalid_distance_code_msg + mov edx,26 + jmp L_update_stream_state + + L_test_for_end_of_block: + + + + + + test al,32 + jz L_invalid_literal_length_code + + mov ecx,0 + mov edx,11 + jmp L_update_stream_state + + L_invalid_literal_length_code: + + + + + + mov ecx, invalid_literal_length_code_msg + mov edx,26 + jmp L_update_stream_state + + L_invalid_distance_too_far: + + + + mov esi, [esp+44] + mov ecx, invalid_distance_too_far_msg + mov edx,26 + jmp L_update_stream_state + + L_update_stream_state: + + mov eax, [esp+88] + test ecx,ecx + jz L_skip_msg + mov [eax+24],ecx + L_skip_msg: + mov eax, [eax+28] + mov [eax+mode_state],edx + jmp L_break_loop + + ALIGN 4 + L_break_loop: + ; 1243 "inffast.S" + cmp dword ptr [inflate_fast_use_mmx],2 + jne L_update_next_in + + + + mov ebx,ebp + + L_update_next_in: + ; 1266 "inffast.S" + mov eax, [esp+88] + mov ecx,ebx + mov edx, [eax+28] + shr ecx,3 + sub esi,ecx + shl ecx,3 + sub ebx,ecx + mov [eax+12],edi + mov [edx+bits_state],ebx + mov ecx,ebx + + lea ebx, [esp+28] + cmp [esp+20],ebx + jne L_buf_not_used + + sub esi,ebx + mov ebx, [eax+0] + mov [esp+20],ebx + add esi,ebx + mov ebx, [eax+4] + sub ebx,11 + add [esp+20],ebx + + L_buf_not_used: + mov [eax+0],esi + + mov ebx,1 + shl ebx,cl + dec ebx + + + + + + cmp dword ptr [inflate_fast_use_mmx],2 + jne L_update_hold + + + + psrlq mm0,mm1 + movd ebp,mm0 + + emms + + L_update_hold: + + + + and ebp,ebx + mov [edx+hold_state],ebp + + + + + mov ebx, [esp+20] + cmp ebx,esi + jbe L_last_is_smaller + + sub ebx,esi + add ebx,11 + mov [eax+4],ebx + jmp L_fixup_out + L_last_is_smaller: + sub esi,ebx + neg esi + add esi,11 + mov [eax+4],esi + + + + + L_fixup_out: + + mov ebx, [esp+16] + cmp ebx,edi + jbe L_end_is_smaller + + sub ebx,edi + add ebx,257 + mov [eax+16],ebx + jmp L_done + L_end_is_smaller: + sub edi,ebx + neg edi + add edi,257 + mov [eax+16],edi + + + + + + L_done: + add esp,64 + popfd + pop ebx + pop ebp + pop esi + pop edi + ret + + + + + _TEXT ends + end Index: llvm/runtime/zlib/contrib/masmx86/mkasm.bat diff -c /dev/null llvm/runtime/zlib/contrib/masmx86/mkasm.bat:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/masmx86/mkasm.bat Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,3 ---- + cl /I..\.. /O2 /c gvmat32c.c + ml /coff /Zi /c /Flgvmat32.lst gvmat32.asm + ml /coff /Zi /c /Flinffas32.lst inffas32.asm Index: llvm/runtime/zlib/contrib/masmx86/readme.txt diff -c /dev/null llvm/runtime/zlib/contrib/masmx86/readme.txt:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/masmx86/readme.txt Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,21 ---- + + Summary + ------- + This directory contains ASM implementations of the functions + longest_match() and inflate_fast(). + + + Use instructions + ---------------- + Copy these files into the zlib source directory, then run the + appropriate makefile, as suggested below. + + + Build instructions + ------------------ + * With Microsoft C and MASM: + nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="gvmat32c.obj gvmat32.obj inffas32.obj" + + * With Borland C and TASM: + make -f win32/Makefile.bor LOCAL_ZLIB="-DASMV -DASMINF" OBJA="gvmat32c.obj gvmat32.obj inffas32.obj" OBJPA="+gvmat32c.obj+gvmat32.obj+inffas32.obj" + From criswell at cs.uiuc.edu Fri Feb 6 10:39:55 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:39:55 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/vstudio/readme.txt Message-ID: <200402061636.KAA15626@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/vstudio: readme.txt added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+55 -0) Index: llvm/runtime/zlib/contrib/vstudio/readme.txt diff -c /dev/null llvm/runtime/zlib/contrib/vstudio/readme.txt:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/vstudio/readme.txt Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,55 ---- + Building instructions for the DLL versions of Zlib 1.21 + ======================================================= + + This directory contains projects that build zlib and minizip using + Microsoft Visual C++ 7.0/7.1. + + You don't need to build these projects yourself. You can download the + binaries from: + http://www.winimage.com/zLibDll + + More information can be found at this site. + + + Build instructions + ------------------ + - Unzip zlib*.zip and copy the files from contrib\vstudio\vc7, + from contrib\vstudio\masmx86 and from contrib\minizip into the same + directory. + - Download the crtdll library from + http://www.winimage.com/zLibDll/crtdll.zip + Unzip crtdll.zip to extract crtdll.lib. + - If you are using x86, use the Release target. + - Open zlibvc.sln with Microsoft Visual C++ 7.0 or 7.1 + (Visual Studio .Net 2002 or 2003). + + + Important + --------- + - To use zlibwapi.dll in your application, you must define the + macro ZLIB_WINAPI when compiling your application's source files. + + + Additional notes + ---------------- + - This DLL, named zlibwapi.dll, is compatible to the old zlib.dll built + by Gilles Vollant from the zlib 1.1.x sources, and distributed at + http://www.winimage.com/zLibDll + It uses the WINAPI calling convention for the exported functions, and + includes the minizip functionality. If your application needs that + particular build of zlib.dll, you can rename zlibwapi.dll to zlib.dll. + + - The new DLL was renamed because there exist several incompatible + versions of zlib.dll on the Internet. + + - There is also an official DLL build of zlib, named zlib1.dll. This one + is exporting the functions using the CDECL convention. See the file + win32\DLL_FAQ.txt found in this zlib distribution. + + - There used to be a ZLIB_DLL macro in zlib 1.1.x, but now this symbol + has a slightly different effect. To avoid compatibility problems, do + not define it here. + + + Gilles Vollant + info at winimage.com From criswell at cs.uiuc.edu Fri Feb 6 10:40:13 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:40:13 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/testzlib/testzlib.c testzlib.sln testzlib.vcproj Message-ID: <200402061636.KAA15620@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/testzlib: testzlib.c added (r1.1) testzlib.sln added (r1.1) testzlib.vcproj added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+294 -0) Index: llvm/runtime/zlib/contrib/testzlib/testzlib.c diff -c /dev/null llvm/runtime/zlib/contrib/testzlib/testzlib.c:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/testzlib/testzlib.c Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,149 ---- + + #include + #include + #include + #include "zlib.h" + + int ReadFileMemory(const char* filename,long* plFileSize,void** pFilePtr) + { + FILE* stream; + void* ptr; + int retVal=1; + stream=fopen(filename, "rb"); + if (stream==NULL) + return 0; + + fseek(stream,0,SEEK_END); + + *plFileSize=ftell(stream); + fseek(stream,0,SEEK_SET); + ptr=malloc((*plFileSize)+1); + if (ptr==NULL) + retVal=0; + else + { + if (fread(ptr, 1, *plFileSize,stream) != (*plFileSize)) + retVal=0; + } + fclose(stream); + *pFilePtr=ptr; + return retVal; + } + + int main(int argc, char *argv[]) + { + int BlockSizeCompress=0x8000; + int BlockSizeUncompress=0x8000; + int cprLevel=Z_DEFAULT_COMPRESSION ; + long lFileSize; + unsigned char* FilePtr; + long lBufferSizeCpr; + long lBufferSizeUncpr; + long lCompressedSize=0; + unsigned char* CprPtr; + unsigned char* UncprPtr; + long lSizeCpr,lSizeUncpr; + DWORD dwGetTick; + + if (argc<=1) + { + printf("run TestZlib [BlockSizeCompress] [BlockSizeUncompress] [compres. level]\n"); + return 0; + } + + if (ReadFileMemory(argv[1],&lFileSize,&FilePtr)==0) + { + printf("error reading %s\n",argv[1]); + return 1; + } + else printf("file %s read, %u bytes\n",argv[1],lFileSize); + + if (argc>=3) + BlockSizeCompress=atol(argv[2]); + + if (argc>=4) + BlockSizeUncompress=atol(argv[3]); + + if (argc>=5) + cprLevel=(int)atol(argv[4]); + + lBufferSizeCpr = lFileSize + (lFileSize/0x10) + 0x200; + lBufferSizeUncpr = lBufferSizeCpr; + + CprPtr=(unsigned char*)malloc(lBufferSizeCpr + BlockSizeCompress); + UncprPtr=(unsigned char*)malloc(lBufferSizeUncpr + BlockSizeUncompress); + + dwGetTick=GetTickCount(); + { + z_stream zcpr; + int ret=Z_OK; + long lOrigToDo = lFileSize; + long lOrigDone = 0; + int step=0; + memset(&zcpr,0,sizeof(z_stream)); + deflateInit(&zcpr,cprLevel); + + zcpr.next_in = FilePtr; + zcpr.next_out = CprPtr; + + + do + { + long all_read_before = zcpr.total_in; + zcpr.avail_in = min(lOrigToDo,BlockSizeCompress); + zcpr.avail_out = BlockSizeCompress; + ret=deflate(&zcpr,(zcpr.avail_in==lOrigToDo) ? Z_FINISH : Z_SYNC_FLUSH); + lOrigDone += (zcpr.total_in-all_read_before); + lOrigToDo -= (zcpr.total_in-all_read_before); + step++; + } while (ret==Z_OK); + + lSizeCpr=zcpr.total_out; + deflateEnd(&zcpr); + dwGetTick=GetTickCount()-dwGetTick; + printf("total compress size = %u, in %u step\n",lSizeCpr,step); + printf("time = %u msec = %f sec\n\n",dwGetTick,dwGetTick/(double)1000.); + } + + dwGetTick=GetTickCount(); + { + z_stream zcpr; + int ret=Z_OK; + long lOrigToDo = lSizeCpr; + long lOrigDone = 0; + int step=0; + memset(&zcpr,0,sizeof(z_stream)); + inflateInit(&zcpr); + + zcpr.next_in = CprPtr; + zcpr.next_out = UncprPtr; + + + do + { + long all_read_before = zcpr.total_in; + zcpr.avail_in = min(lOrigToDo,BlockSizeUncompress); + zcpr.avail_out = BlockSizeUncompress; + ret=inflate(&zcpr,Z_SYNC_FLUSH); + lOrigDone += (zcpr.total_in-all_read_before); + lOrigToDo -= (zcpr.total_in-all_read_before); + step++; + } while (ret==Z_OK); + + lSizeUncpr=zcpr.total_out; + inflateEnd(&zcpr); + dwGetTick=GetTickCount()-dwGetTick; + printf("total uncompress size = %u, in %u step\n",lSizeUncpr,step); + printf("time = %u msec = %f sec\n\n",dwGetTick,dwGetTick/(double)1000.); + } + + if (lSizeUncpr==lFileSize) + { + if (memcmp(FilePtr,UncprPtr,lFileSize)==0) + printf("compare ok\n"); + + } + + return 0; + + } Index: llvm/runtime/zlib/contrib/testzlib/testzlib.sln diff -c /dev/null llvm/runtime/zlib/contrib/testzlib/testzlib.sln:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/testzlib/testzlib.sln Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,21 ---- + Microsoft Visual Studio Solution File, Format Version 7.00 + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" + EndProject + Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug.Build.0 = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection + EndGlobal Index: llvm/runtime/zlib/contrib/testzlib/testzlib.vcproj diff -c /dev/null llvm/runtime/zlib/contrib/testzlib/testzlib.vcproj:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/testzlib/testzlib.vcproj Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,124 ---- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From criswell at cs.uiuc.edu Fri Feb 6 10:40:29 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:40:29 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/pascal/example.pas readme.txt zlibd32.mak zlibpas.pas Message-ID: <200402061636.KAA15590@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/pascal: example.pas added (r1.1) readme.txt added (r1.1) zlibd32.mak added (r1.1) zlibpas.pas added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+1004 -0) Index: llvm/runtime/zlib/contrib/pascal/example.pas diff -c /dev/null llvm/runtime/zlib/contrib/pascal/example.pas:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/pascal/example.pas Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,599 ---- + (* example.c -- usage example of the zlib compression library + * Copyright (C) 1995-2003 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Pascal translation + * Copyright (C) 1998 by Jacques Nomssi Nzali. + * For conditions of distribution and use, see copyright notice in readme.txt + * + * Adaptation to the zlibpas interface + * Copyright (C) 2003 by Cosmin Truta. + * For conditions of distribution and use, see copyright notice in readme.txt + *) + + program example; + + {$DEFINE TEST_COMPRESS} + {DO NOT $DEFINE TEST_GZIO} + {$DEFINE TEST_DEFLATE} + {$DEFINE TEST_INFLATE} + {$DEFINE TEST_FLUSH} + {$DEFINE TEST_SYNC} + {$DEFINE TEST_DICT} + + uses SysUtils, zlibpas; + + const TESTFILE = 'foo.gz'; + + (* "hello world" would be more standard, but the repeated "hello" + * stresses the compression code better, sorry... + *) + const hello: PChar = 'hello, hello!'; + + const dictionary: PChar = 'hello'; + + var dictId: LongInt; (* Adler32 value of the dictionary *) + + procedure CHECK_ERR(err: Integer; msg: String); + begin + if err <> Z_OK then + begin + WriteLn(msg, ' error: ', err); + Halt(1); + end; + end; + + procedure EXIT_ERR(const msg: String); + begin + WriteLn('Error: ', msg); + Halt(1); + end; + + (* =========================================================================== + * Test compress and uncompress + *) + {$IFDEF TEST_COMPRESS} + procedure test_compress(compr: Pointer; comprLen: LongInt; + uncompr: Pointer; uncomprLen: LongInt); + var err: Integer; + len: LongInt; + begin + len := StrLen(hello)+1; + + err := compress(compr, comprLen, hello, len); + CHECK_ERR(err, 'compress'); + + StrCopy(PChar(uncompr), 'garbage'); + + err := uncompress(uncompr, uncomprLen, compr, comprLen); + CHECK_ERR(err, 'uncompress'); + + if StrComp(PChar(uncompr), hello) <> 0 then + EXIT_ERR('bad uncompress') + else + WriteLn('uncompress(): ', PChar(uncompr)); + end; + {$ENDIF} + + (* =========================================================================== + * Test read/write of .gz files + *) + {$IFDEF TEST_GZIO} + procedure test_gzio(const fname: PChar; (* compressed file name *) + uncompr: Pointer; + uncomprLen: LongInt); + var err: Integer; + len: Integer; + zfile: gzFile; + pos: LongInt; + begin + len := StrLen(hello)+1; + + zfile := gzopen(fname, 'wb'); + if zfile = NIL then + begin + WriteLn('gzopen error'); + Halt(1); + end; + gzputc(zfile, 'h'); + if gzputs(zfile, 'ello') <> 4 then + begin + WriteLn('gzputs err: ', gzerror(zfile, err)); + Halt(1); + end; + {$IFDEF GZ_FORMAT_STRING} + if gzprintf(zfile, ', %s!', 'hello') <> 8 then + begin + WriteLn('gzprintf err: ', gzerror(zfile, err)); + Halt(1); + end; + {$ELSE} + if gzputs(zfile, ', hello!') <> 8 then + begin + WriteLn('gzputs err: ', gzerror(zfile, err)); + Halt(1); + end; + {$ENDIF} + gzseek(zfile, 1, SEEK_CUR); (* add one zero byte *) + gzclose(zfile); + + zfile := gzopen(fname, 'rb'); + if zfile = NIL then + begin + WriteLn('gzopen error'); + Halt(1); + end; + + StrCopy(PChar(uncompr), 'garbage'); + + if gzread(zfile, uncompr, uncomprLen) <> len then + begin + WriteLn('gzread err: ', gzerror(zfile, err)); + Halt(1); + end; + if StrComp(PChar(uncompr), hello) <> 0 then + begin + WriteLn('bad gzread: ', PChar(uncompr)); + Halt(1); + end + else + WriteLn('gzread(): ', PChar(uncompr)); + + pos := gzseek(zfile, -8, SEEK_CUR); + if (pos <> 6) or (gztell(zfile) <> pos) then + begin + WriteLn('gzseek error, pos=', pos, ', gztell=', gztell(zfile)); + Halt(1); + end; + + if gzgetc(zfile) <> ' ' then + begin + WriteLn('gzgetc error'); + Halt(1); + end; + + if gzungetc(' ', zfile) <> ' ' then + begin + WriteLn('gzungetc error'); + Halt(1); + end; + + gzgets(zfile, PChar(uncompr), uncomprLen); + uncomprLen := StrLen(PChar(uncompr)); + if uncomprLen <> 7 then (* " hello!" *) + begin + WriteLn('gzgets err after gzseek: ', gzerror(zfile, err)); + Halt(1); + end; + if StrComp(PChar(uncompr), hello + 6) <> 0 then + begin + WriteLn('bad gzgets after gzseek'); + Halt(1); + end + else + WriteLn('gzgets() after gzseek: ', PChar(uncompr)); + + gzclose(zfile); + end; + {$ENDIF} + + (* =========================================================================== + * Test deflate with small buffers + *) + {$IFDEF TEST_DEFLATE} + procedure test_deflate(compr: Pointer; comprLen: LongInt); + var c_stream: z_stream; (* compression stream *) + err: Integer; + len: LongInt; + begin + len := StrLen(hello)+1; + + c_stream.zalloc := NIL; + c_stream.zfree := NIL; + c_stream.opaque := NIL; + + err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION); + CHECK_ERR(err, 'deflateInit'); + + c_stream.next_in := hello; + c_stream.next_out := compr; + + while (c_stream.total_in <> len) and + (c_stream.total_out < comprLen) do + begin + c_stream.avail_out := 1; { force small buffers } + c_stream.avail_in := 1; + err := deflate(c_stream, Z_NO_FLUSH); + CHECK_ERR(err, 'deflate'); + end; + + (* Finish the stream, still forcing small buffers: *) + while TRUE do + begin + c_stream.avail_out := 1; + err := deflate(c_stream, Z_FINISH); + if err = Z_STREAM_END then + break; + CHECK_ERR(err, 'deflate'); + end; + + err := deflateEnd(c_stream); + CHECK_ERR(err, 'deflateEnd'); + end; + {$ENDIF} + + (* =========================================================================== + * Test inflate with small buffers + *) + {$IFDEF TEST_INFLATE} + procedure test_inflate(compr: Pointer; comprLen : LongInt; + uncompr: Pointer; uncomprLen : LongInt); + var err: Integer; + d_stream: z_stream; (* decompression stream *) + begin + StrCopy(PChar(uncompr), 'garbage'); + + d_stream.zalloc := NIL; + d_stream.zfree := NIL; + d_stream.opaque := NIL; + + d_stream.next_in := compr; + d_stream.avail_in := 0; + d_stream.next_out := uncompr; + + err := inflateInit(d_stream); + CHECK_ERR(err, 'inflateInit'); + + while (d_stream.total_out < uncomprLen) and + (d_stream.total_in < comprLen) do + begin + d_stream.avail_out := 1; (* force small buffers *) + d_stream.avail_in := 1; + err := inflate(d_stream, Z_NO_FLUSH); + if err = Z_STREAM_END then + break; + CHECK_ERR(err, 'inflate'); + end; + + err := inflateEnd(d_stream); + CHECK_ERR(err, 'inflateEnd'); + + if StrComp(PChar(uncompr), hello) <> 0 then + EXIT_ERR('bad inflate') + else + WriteLn('inflate(): ', PChar(uncompr)); + end; + {$ENDIF} + + (* =========================================================================== + * Test deflate with large buffers and dynamic change of compression level + *) + {$IFDEF TEST_DEFLATE} + procedure test_large_deflate(compr: Pointer; comprLen: LongInt; + uncompr: Pointer; uncomprLen: LongInt); + var c_stream: z_stream; (* compression stream *) + err: Integer; + begin + c_stream.zalloc := NIL; + c_stream.zfree := NIL; + c_stream.opaque := NIL; + + err := deflateInit(c_stream, Z_BEST_SPEED); + CHECK_ERR(err, 'deflateInit'); + + c_stream.next_out := compr; + c_stream.avail_out := Integer(comprLen); + + (* At this point, uncompr is still mostly zeroes, so it should compress + * very well: + *) + c_stream.next_in := uncompr; + c_stream.avail_in := Integer(uncomprLen); + err := deflate(c_stream, Z_NO_FLUSH); + CHECK_ERR(err, 'deflate'); + if c_stream.avail_in <> 0 then + EXIT_ERR('deflate not greedy'); + + (* Feed in already compressed data and switch to no compression: *) + deflateParams(c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); + c_stream.next_in := compr; + c_stream.avail_in := Integer(comprLen div 2); + err := deflate(c_stream, Z_NO_FLUSH); + CHECK_ERR(err, 'deflate'); + + (* Switch back to compressing mode: *) + deflateParams(c_stream, Z_BEST_COMPRESSION, Z_FILTERED); + c_stream.next_in := uncompr; + c_stream.avail_in := Integer(uncomprLen); + err := deflate(c_stream, Z_NO_FLUSH); + CHECK_ERR(err, 'deflate'); + + err := deflate(c_stream, Z_FINISH); + if err <> Z_STREAM_END then + EXIT_ERR('deflate should report Z_STREAM_END'); + + err := deflateEnd(c_stream); + CHECK_ERR(err, 'deflateEnd'); + end; + {$ENDIF} + + (* =========================================================================== + * Test inflate with large buffers + *) + {$IFDEF TEST_INFLATE} + procedure test_large_inflate(compr: Pointer; comprLen: LongInt; + uncompr: Pointer; uncomprLen: LongInt); + var err: Integer; + d_stream: z_stream; (* decompression stream *) + begin + StrCopy(PChar(uncompr), 'garbage'); + + d_stream.zalloc := NIL; + d_stream.zfree := NIL; + d_stream.opaque := NIL; + + d_stream.next_in := compr; + d_stream.avail_in := Integer(comprLen); + + err := inflateInit(d_stream); + CHECK_ERR(err, 'inflateInit'); + + while TRUE do + begin + d_stream.next_out := uncompr; (* discard the output *) + d_stream.avail_out := Integer(uncomprLen); + err := inflate(d_stream, Z_NO_FLUSH); + if err = Z_STREAM_END then + break; + CHECK_ERR(err, 'large inflate'); + end; + + err := inflateEnd(d_stream); + CHECK_ERR(err, 'inflateEnd'); + + if d_stream.total_out <> 2 * uncomprLen + comprLen div 2 then + begin + WriteLn('bad large inflate: ', d_stream.total_out); + Halt(1); + end + else + WriteLn('large_inflate(): OK'); + end; + {$ENDIF} + + (* =========================================================================== + * Test deflate with full flush + *) + {$IFDEF TEST_FLUSH} + procedure test_flush(compr: Pointer; var comprLen : LongInt); + var c_stream: z_stream; (* compression stream *) + err: Integer; + len: Integer; + begin + len := StrLen(hello)+1; + + c_stream.zalloc := NIL; + c_stream.zfree := NIL; + c_stream.opaque := NIL; + + err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION); + CHECK_ERR(err, 'deflateInit'); + + c_stream.next_in := hello; + c_stream.next_out := compr; + c_stream.avail_in := 3; + c_stream.avail_out := Integer(comprLen); + err := deflate(c_stream, Z_FULL_FLUSH); + CHECK_ERR(err, 'deflate'); + + Inc(PByteArray(compr)^[3]); (* force an error in first compressed block *) + c_stream.avail_in := len - 3; + + err := deflate(c_stream, Z_FINISH); + if err <> Z_STREAM_END then + CHECK_ERR(err, 'deflate'); + + err := deflateEnd(c_stream); + CHECK_ERR(err, 'deflateEnd'); + + comprLen := c_stream.total_out; + end; + {$ENDIF} + + (* =========================================================================== + * Test inflateSync() + *) + {$IFDEF TEST_SYNC} + procedure test_sync(compr: Pointer; comprLen: LongInt; + uncompr: Pointer; uncomprLen : LongInt); + var err: Integer; + d_stream: z_stream; (* decompression stream *) + begin + StrCopy(PChar(uncompr), 'garbage'); + + d_stream.zalloc := NIL; + d_stream.zfree := NIL; + d_stream.opaque := NIL; + + d_stream.next_in := compr; + d_stream.avail_in := 2; (* just read the zlib header *) + + err := inflateInit(d_stream); + CHECK_ERR(err, 'inflateInit'); + + d_stream.next_out := uncompr; + d_stream.avail_out := Integer(uncomprLen); + + inflate(d_stream, Z_NO_FLUSH); + CHECK_ERR(err, 'inflate'); + + d_stream.avail_in := Integer(comprLen-2); (* read all compressed data *) + err := inflateSync(d_stream); (* but skip the damaged part *) + CHECK_ERR(err, 'inflateSync'); + + err := inflate(d_stream, Z_FINISH); + if err <> Z_DATA_ERROR then + EXIT_ERR('inflate should report DATA_ERROR'); + (* Because of incorrect adler32 *) + + err := inflateEnd(d_stream); + CHECK_ERR(err, 'inflateEnd'); + + WriteLn('after inflateSync(): hel', PChar(uncompr)); + end; + {$ENDIF} + + (* =========================================================================== + * Test deflate with preset dictionary + *) + {$IFDEF TEST_DICT} + procedure test_dict_deflate(compr: Pointer; comprLen: LongInt); + var c_stream: z_stream; (* compression stream *) + err: Integer; + begin + c_stream.zalloc := NIL; + c_stream.zfree := NIL; + c_stream.opaque := NIL; + + err := deflateInit(c_stream, Z_BEST_COMPRESSION); + CHECK_ERR(err, 'deflateInit'); + + err := deflateSetDictionary(c_stream, dictionary, StrLen(dictionary)); + CHECK_ERR(err, 'deflateSetDictionary'); + + dictId := c_stream.adler; + c_stream.next_out := compr; + c_stream.avail_out := Integer(comprLen); + + c_stream.next_in := hello; + c_stream.avail_in := StrLen(hello)+1; + + err := deflate(c_stream, Z_FINISH); + if err <> Z_STREAM_END then + EXIT_ERR('deflate should report Z_STREAM_END'); + + err := deflateEnd(c_stream); + CHECK_ERR(err, 'deflateEnd'); + end; + {$ENDIF} + + (* =========================================================================== + * Test inflate with a preset dictionary + *) + {$IFDEF TEST_DICT} + procedure test_dict_inflate(compr: Pointer; comprLen: LongInt; + uncompr: Pointer; uncomprLen: LongInt); + var err: Integer; + d_stream: z_stream; (* decompression stream *) + begin + StrCopy(PChar(uncompr), 'garbage'); + + d_stream.zalloc := NIL; + d_stream.zfree := NIL; + d_stream.opaque := NIL; + + d_stream.next_in := compr; + d_stream.avail_in := Integer(comprLen); + + err := inflateInit(d_stream); + CHECK_ERR(err, 'inflateInit'); + + d_stream.next_out := uncompr; + d_stream.avail_out := Integer(uncomprLen); + + while TRUE do + begin + err := inflate(d_stream, Z_NO_FLUSH); + if err = Z_STREAM_END then + break; + if err = Z_NEED_DICT then + begin + if d_stream.adler <> dictId then + EXIT_ERR('unexpected dictionary'); + err := inflateSetDictionary(d_stream, dictionary, StrLen(dictionary)); + end; + CHECK_ERR(err, 'inflate with dict'); + end; + + err := inflateEnd(d_stream); + CHECK_ERR(err, 'inflateEnd'); + + if StrComp(PChar(uncompr), hello) <> 0 then + EXIT_ERR('bad inflate with dict') + else + WriteLn('inflate with dictionary: ', PChar(uncompr)); + end; + {$ENDIF} + + var compr, uncompr: Pointer; + comprLen, uncomprLen: LongInt; + + begin + if zlibVersion^ <> ZLIB_VERSION[1] then + EXIT_ERR('Incompatible zlib version'); + + WriteLn('zlib version: ', zlibVersion); + WriteLn('zlib compile flags: ', Format('0x%x', [zlibCompileFlags])); + + comprLen := 10000 * SizeOf(Integer); (* don't overflow on MSDOS *) + uncomprLen := comprLen; + GetMem(compr, comprLen); + GetMem(uncompr, uncomprLen); + if (compr = NIL) or (uncompr = NIL) then + EXIT_ERR('Out of memory'); + (* compr and uncompr are cleared to avoid reading uninitialized + * data and to ensure that uncompr compresses well. + *) + FillChar(compr^, comprLen, 0); + FillChar(uncompr^, uncomprLen, 0); + + {$IFDEF TEST_COMPRESS} + WriteLn('** Testing compress'); + test_compress(compr, comprLen, uncompr, uncomprLen); + {$ENDIF} + + {$IFDEF TEST_GZIO} + WriteLn('** Testing gzio'); + if ParamCount >= 1 then + test_gzio(ParamStr(1), uncompr, uncomprLen) + else + test_gzio(TESTFILE, uncompr, uncomprLen); + {$ENDIF} + + {$IFDEF TEST_DEFLATE} + WriteLn('** Testing deflate with small buffers'); + test_deflate(compr, comprLen); + {$ENDIF} + {$IFDEF TEST_INFLATE} + WriteLn('** Testing inflate with small buffers'); + test_inflate(compr, comprLen, uncompr, uncomprLen); + {$ENDIF} + + {$IFDEF TEST_DEFLATE} + WriteLn('** Testing deflate with large buffers'); + test_large_deflate(compr, comprLen, uncompr, uncomprLen); + {$ENDIF} + {$IFDEF TEST_INFLATE} + WriteLn('** Testing inflate with large buffers'); + test_large_inflate(compr, comprLen, uncompr, uncomprLen); + {$ENDIF} + + {$IFDEF TEST_FLUSH} + WriteLn('** Testing deflate with full flush'); + test_flush(compr, comprLen); + {$ENDIF} + {$IFDEF TEST_SYNC} + WriteLn('** Testing inflateSync'); + test_sync(compr, comprLen, uncompr, uncomprLen); + {$ENDIF} + comprLen := uncomprLen; + + {$IFDEF TEST_DICT} + WriteLn('** Testing deflate and inflate with preset dictionary'); + test_dict_deflate(compr, comprLen); + test_dict_inflate(compr, comprLen, uncompr, uncomprLen); + {$ENDIF} + + FreeMem(compr, comprLen); + FreeMem(uncompr, uncomprLen); + end. Index: llvm/runtime/zlib/contrib/pascal/readme.txt diff -c /dev/null llvm/runtime/zlib/contrib/pascal/readme.txt:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/pascal/readme.txt Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,76 ---- + + This directory contains a Pascal (Delphi, Kylix) interface to the + zlib data compression library. + + + Directory listing + ================= + + zlibd32.mak makefile for Borland C++ + example.pas usage example of zlib + zlibpas.pas the Pascal interface to zlib + readme.txt this file + + + Compatibility notes + =================== + + - Although the name "zlib" would have been more normal for the + zlibpas unit, this name is already taken by Borland's ZLib unit. + This is somehow unfortunate, because that unit is not a genuine + interface to the full-fledged zlib functionality, but a suite of + class wrappers around zlib streams. Other essential features, + such as checksums, are missing. + It would have been more appropriate for that unit to have a name + like "ZStreams", or something similar. + + - The C and zlib-supplied types int, uInt, long, uLong, etc. are + translated directly into Pascal types of similar sizes (Integer, + LongInt, etc.), to avoid namespace pollution. In particular, + there is no conversion of unsigned int into a Pascal unsigned + integer. The Word type is non-portable and has the same size + (16 bits) both in a 16-bit and in a 32-bit environment, unlike + Integer. Even if there is a 32-bit Cardinal type, there is no + real need for unsigned int in zlib under a 32-bit environment. + + - Except for the callbacks, the zlib function interfaces are + assuming the calling convention normally used in Pascal + (__pascal for DOS and Windows16, __fastcall for Windows32). + Since the cdecl keyword is used, the old Turbo Pascal does + not work with this interface. + + - The gz* function interfaces are not translated, to avoid + interfacing problems with the C runtime library. Besides, + gzprintf(gzFile file, const char *format, ...) + cannot be translated into Pascal. + + + Legal issues + ============ + + The zlibpas interface is: + Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler. + Copyright (C) 1998 by Bob Dellaca. + Copyright (C) 2003 by Cosmin Truta. + + The example program is: + Copyright (C) 1995-2003 by Jean-loup Gailly. + Copyright (C) 1998,1999,2000 by Jacques Nomssi Nzali. + Copyright (C) 2003 by Cosmin Truta. + + This software is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + Index: llvm/runtime/zlib/contrib/pascal/zlibd32.mak diff -c /dev/null llvm/runtime/zlib/contrib/pascal/zlibd32.mak:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/pascal/zlibd32.mak Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,93 ---- + # Makefile for zlib + # For use with Delphi and C++ Builder under Win32 + # Updated for zlib 1.2.x by Cosmin Truta + + # ------------ Borland C++ ------------ + + # This project uses the Delphi (fastcall/register) calling convention: + LOC = -DZEXPORT=__fastcall -DZEXPORTVA=__cdecl + + CC = bcc32 + LD = bcc32 + AR = tlib + # do not use "-pr" in CFLAGS + CFLAGS = -a -d -k- -O2 $(LOC) + LDFLAGS = + + + # variables + ZLIB_LIB = zlib.lib + + OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj + OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj + OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj + OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj + + + # targets + all: $(ZLIB_LIB) example.exe minigzip.exe + + .c.obj: + $(CC) -c $(CFLAGS) $*.c + + adler32.obj: adler32.c zlib.h zconf.h + + compress.obj: compress.c zlib.h zconf.h + + crc32.obj: crc32.c zlib.h zconf.h crc32.h + + deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h + + gzio.obj: gzio.c zutil.h zlib.h zconf.h + + infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + + inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h + + inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + + inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h + + trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h + + uncompr.obj: uncompr.c zlib.h zconf.h + + zutil.obj: zutil.c zutil.h zlib.h zconf.h + + example.obj: example.c zlib.h zconf.h + + minigzip.obj: minigzip.c zlib.h zconf.h + + + # For the sake of the old Borland make, + # the command line is cut to fit in the MS-DOS 128 byte limit: + $(ZLIB_LIB): $(OBJ1) $(OBJ2) + -del $(ZLIB_LIB) + $(AR) $(ZLIB_LIB) $(OBJP1) + $(AR) $(ZLIB_LIB) $(OBJP2) + + + # testing + test: example.exe minigzip.exe + example + echo hello world | minigzip | minigzip -d + + example.exe: example.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) + + minigzip.exe: minigzip.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) + + + # cleanup + clean: + -del *.obj + -del *.exe + -del *.lib + -del *.tds + -del zlib.bak + -del foo.gz + Index: llvm/runtime/zlib/contrib/pascal/zlibpas.pas diff -c /dev/null llvm/runtime/zlib/contrib/pascal/zlibpas.pas:1.1 *** /dev/null Fri Feb 6 10:36:51 2004 --- llvm/runtime/zlib/contrib/pascal/zlibpas.pas Fri Feb 6 10:36:41 2004 *************** *** 0 **** --- 1,236 ---- + (* zlibpas -- Pascal interface to the zlib data compression library + * + * Copyright (C) 2003 Cosmin Truta. + * Derived from original sources by Bob Dellaca. + * For conditions of distribution and use, see copyright notice in readme.txt + *) + + unit zlibpas; + + interface + + const + ZLIB_VERSION = '1.2.1'; + + type + alloc_func = function(opaque: Pointer; items, size: Integer): Pointer; + cdecl; + free_func = procedure(opaque, address: Pointer); + cdecl; + + in_func = function(opaque: Pointer; var buf: PByte): Integer; + cdecl; + out_func = function(opaque: Pointer; buf: PByte; size: Integer): Integer; + cdecl; + + z_streamp = ^z_stream; + z_stream = packed record + next_in: PChar; (* next input byte *) + avail_in: Integer; (* number of bytes available at next_in *) + total_in: LongInt; (* total nb of input bytes read so far *) + + next_out: PChar; (* next output byte should be put there *) + avail_out: Integer; (* remaining free space at next_out *) + total_out: LongInt; (* total nb of bytes output so far *) + + msg: PChar; (* last error message, NULL if no error *) + state: Pointer; (* not visible by applications *) + + zalloc: alloc_func; (* used to allocate the internal state *) + zfree: free_func; (* used to free the internal state *) + opaque: Pointer; (* private data object passed to zalloc and zfree *) + + data_type: Integer; (* best guess about the data type: ascii or binary *) + adler: LongInt; (* adler32 value of the uncompressed data *) + reserved: LongInt; (* reserved for future use *) + end; + + (* constants *) + const + Z_NO_FLUSH = 0; + Z_PARTIAL_FLUSH = 1; + Z_SYNC_FLUSH = 2; + Z_FULL_FLUSH = 3; + Z_FINISH = 4; + + Z_OK = 0; + Z_STREAM_END = 1; + Z_NEED_DICT = 2; + Z_ERRNO = -1; + Z_STREAM_ERROR = -2; + Z_DATA_ERROR = -3; + Z_MEM_ERROR = -4; + Z_BUF_ERROR = -5; + Z_VERSION_ERROR = -6; + + Z_NO_COMPRESSION = 0; + Z_BEST_SPEED = 1; + Z_BEST_COMPRESSION = 9; + Z_DEFAULT_COMPRESSION = -1; + + Z_FILTERED = 1; + Z_HUFFMAN_ONLY = 2; + Z_RLE = 3; + Z_DEFAULT_STRATEGY = 0; + + Z_BINARY = 0; + Z_ASCII = 1; + Z_UNKNOWN = 2; + + Z_DEFLATED = 8; + + (* basic functions *) + function zlibVersion: PChar; + function deflateInit(var strm: z_stream; level: Integer): Integer; + function deflate(var strm: z_stream; flush: Integer): Integer; + function deflateEnd(var strm: z_stream): Integer; + function inflateInit(var strm: z_stream): Integer; + function inflate(var strm: z_stream; flush: Integer): Integer; + function inflateEnd(var strm: z_stream): Integer; + + (* advanced functions *) + function deflateInit2(var strm: z_stream; level, method, windowBits, + memLevel, strategy: Integer): Integer; + function deflateSetDictionary(var strm: z_stream; const dictionary: PChar; + dictLength: Integer): Integer; + function deflateCopy(var dest, source: z_stream): Integer; + function deflateReset(var strm: z_stream): Integer; + function deflateParams(var strm: z_stream; level, strategy: Integer): Integer; + function deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt; + function deflatePrime(var strm: z_stream; bits, value: Integer): Integer; + function inflateInit2(var strm: z_stream; windowBits: Integer): Integer; + function inflateSetDictionary(var strm: z_stream; const dictionary: PChar; + dictLength: Integer): Integer; + function inflateSync(var strm: z_stream): Integer; + function inflateCopy(var dest, source: z_stream): Integer; + function inflateReset(var strm: z_stream): Integer; + function inflateBackInit(var strm: z_stream; + windowBits: Integer; window: PChar): Integer; + function inflateBack(var strm: z_stream; in_fn: in_func; in_desc: Pointer; + out_fn: out_func; out_desc: Pointer): Integer; + function inflateBackEnd(var strm: z_stream): Integer; + function zlibCompileFlags: LongInt; + + (* utility functions *) + function compress(dest: PChar; var destLen: LongInt; + const source: PChar; sourceLen: LongInt): Integer; + function compress2(dest: PChar; var destLen: LongInt; + const source: PChar; sourceLen: LongInt; + level: Integer): Integer; + function compressBound(sourceLen: LongInt): LongInt; + function uncompress(dest: PChar; var destLen: LongInt; + const source: PChar; sourceLen: LongInt): Integer; + + (* checksum functions *) + function adler32(adler: LongInt; const buf: PChar; len: Integer): LongInt; + function crc32(crc: LongInt; const buf: PChar; len: Integer): LongInt; + + (* various hacks, don't look :) *) + function deflateInit_(var strm: z_stream; level: Integer; + const version: PChar; stream_size: Integer): Integer; + function inflateInit_(var strm: z_stream; const version: PChar; + stream_size: Integer): Integer; + function deflateInit2_(var strm: z_stream; + level, method, windowBits, memLevel, strategy: Integer; + const version: PChar; stream_size: Integer): Integer; + function inflateInit2_(var strm: z_stream; windowBits: Integer; + const version: PChar; stream_size: Integer): Integer; + function inflateBackInit_(var strm: z_stream; + windowBits: Integer; window: PChar; + const version: PChar; stream_size: Integer): Integer; + + + implementation + + {$L adler32.obj} + {$L compress.obj} + {$L crc32.obj} + {$L deflate.obj} + {$L infback.obj} + {$L inffast.obj} + {$L inflate.obj} + {$L inftrees.obj} + {$L trees.obj} + {$L uncompr.obj} + {$L zutil.obj} + + function adler32; external; + function compress; external; + function compress2; external; + function compressBound; external; + function crc32; external; + function deflate; external; + function deflateBound; external; + function deflateCopy; external; + function deflateEnd; external; + function deflateInit_; external; + function deflateInit2_; external; + function deflateParams; external; + function deflatePrime; external; + function deflateReset; external; + function deflateSetDictionary; external; + function inflate; external; + function inflateBack; external; + function inflateBackEnd; external; + function inflateBackInit_; external; + function inflateCopy; external; + function inflateEnd; external; + function inflateInit_; external; + function inflateInit2_; external; + function inflateReset; external; + function inflateSetDictionary; external; + function inflateSync; external; + function uncompress; external; + function zlibCompileFlags; external; + function zlibVersion; external; + + function deflateInit(var strm: z_stream; level: Integer): Integer; + begin + Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream)); + end; + + function deflateInit2(var strm: z_stream; level, method, windowBits, memLevel, + strategy: Integer): Integer; + begin + Result := deflateInit2_(strm, level, method, windowBits, memLevel, strategy, + ZLIB_VERSION, sizeof(z_stream)); + end; + + function inflateInit(var strm: z_stream): Integer; + begin + Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream)); + end; + + function inflateInit2(var strm: z_stream; windowBits: Integer): Integer; + begin + Result := inflateInit2_(strm, windowBits, ZLIB_VERSION, sizeof(z_stream)); + end; + + function inflateBackInit(var strm: z_stream; + windowBits: Integer; window: PChar): Integer; + begin + Result := inflateBackInit_(strm, windowBits, window, + ZLIB_VERSION, sizeof(z_stream)); + end; + + function _malloc(Size: Integer): Pointer; cdecl; + begin + GetMem(Result, Size); + end; + + procedure _free(Block: Pointer); cdecl; + begin + FreeMem(Block); + end; + + procedure _memset(P: Pointer; B: Byte; count: Integer); cdecl; + begin + FillChar(P^, count, B); + end; + + procedure _memcpy(dest, source: Pointer; count: Integer); cdecl; + begin + Move(source^, dest^, count); + end; + + end. From criswell at cs.uiuc.edu Fri Feb 6 10:40:47 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:40:47 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/masm686/match.asm Message-ID: <200402061636.KAA15532@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/masm686: match.asm added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+408 -0) Index: llvm/runtime/zlib/contrib/masm686/match.asm diff -c /dev/null llvm/runtime/zlib/contrib/masm686/match.asm:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/masm686/match.asm Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,408 ---- + + ; match.asm -- Pentium-Pro optimized version of longest_match() + ; + ; Updated for zlib 1.1.3 and converted to MASM 6.1x + ; Copyright (C) 2000 Dan Higdon + ; and Chuck Walbourn + ; Corrections by Cosmin Truta + ; + ; This is free software; you can redistribute it and/or modify it + ; under the terms of the GNU General Public License. + + ; Based on match.S + ; Written for zlib 1.1.2 + ; Copyright (C) 1998 Brian Raiter + + .686P + .MODEL FLAT + + ;=========================================================================== + ; EQUATES + ;=========================================================================== + + MAX_MATCH EQU 258 + MIN_MATCH EQU 3 + MIN_LOOKAHEAD EQU (MAX_MATCH + MIN_MATCH + 1) + MAX_MATCH_8 EQU ((MAX_MATCH + 7) AND (NOT 7)) + + ;=========================================================================== + ; STRUCTURES + ;=========================================================================== + + ; This STRUCT assumes a 4-byte alignment + + DEFLATE_STATE STRUCT + ds_strm dd ? + ds_status dd ? + ds_pending_buf dd ? + ds_pending_buf_size dd ? + ds_pending_out dd ? + ds_pending dd ? + ds_wrap dd ? + ds_data_type db ? + ds_method db ? + db ? ; padding + db ? ; padding + ds_last_flush dd ? + ds_w_size dd ? ; used + ds_w_bits dd ? + ds_w_mask dd ? ; used + ds_window dd ? ; used + ds_window_size dd ? + ds_prev dd ? ; used + ds_head dd ? + ds_ins_h dd ? + ds_hash_size dd ? + ds_hash_bits dd ? + ds_hash_mask dd ? + ds_hash_shift dd ? + ds_block_start dd ? + ds_match_length dd ? ; used + ds_prev_match dd ? ; used + ds_match_available dd ? + ds_strstart dd ? ; used + ds_match_start dd ? ; used + ds_lookahead dd ? ; used + ds_prev_length dd ? ; used + ds_max_chain_length dd ? ; used + ds_max_laxy_match dd ? + ds_level dd ? + ds_strategy dd ? + ds_good_match dd ? ; used + ds_nice_match dd ? ; used + + ; Don't need anymore of the struct for match + DEFLATE_STATE ENDS + + ;=========================================================================== + ; CODE + ;=========================================================================== + _TEXT SEGMENT + + ;--------------------------------------------------------------------------- + ; match_init + ;--------------------------------------------------------------------------- + ALIGN 4 + PUBLIC _match_init + _match_init PROC + ; no initialization needed + ret + _match_init ENDP + + ;--------------------------------------------------------------------------- + ; uInt longest_match(deflate_state *deflatestate, IPos curmatch) + ;--------------------------------------------------------------------------- + ALIGN 4 + + PUBLIC _longest_match + _longest_match PROC + + ; Since this code uses EBP for a scratch register, the stack frame must + ; be manually constructed and referenced relative to the ESP register. + + ; Stack image + ; Variables + chainlenwmask = 0 ; high word: current chain len + ; low word: s->wmask + window = 4 ; local copy of s->window + windowbestlen = 8 ; s->window + bestlen + scanend = 12 ; last two bytes of string + scanstart = 16 ; first two bytes of string + scanalign = 20 ; dword-misalignment of string + nicematch = 24 ; a good enough match size + bestlen = 28 ; size of best match so far + scan = 32 ; ptr to string wanting match + varsize = 36 ; number of bytes (also offset to last saved register) + + ; Saved Registers (actually pushed into place) + ebx_save = 36 + edi_save = 40 + esi_save = 44 + ebp_save = 48 + + ; Parameters + retaddr = 52 + deflatestate = 56 + curmatch = 60 + + ; Save registers that the compiler may be using + push ebp + push edi + push esi + push ebx + + ; Allocate local variable space + sub esp,varsize + + ; Retrieve the function arguments. ecx will hold cur_match + ; throughout the entire function. edx will hold the pointer to the + ; deflate_state structure during the function's setup (before + ; entering the main loop). + + mov edx, [esp+deflatestate] + ASSUME edx:PTR DEFLATE_STATE + + mov ecx, [esp+curmatch] + + ; uInt wmask = s->w_mask; + ; unsigned chain_length = s->max_chain_length; + ; if (s->prev_length >= s->good_match) { + ; chain_length >>= 2; + ; } + + mov eax, [edx].ds_prev_length + mov ebx, [edx].ds_good_match + cmp eax, ebx + mov eax, [edx].ds_w_mask + mov ebx, [edx].ds_max_chain_length + jl SHORT LastMatchGood + shr ebx, 2 + LastMatchGood: + + ; chainlen is decremented once beforehand so that the function can + ; use the sign flag instead of the zero flag for the exit test. + ; It is then shifted into the high word, to make room for the wmask + ; value, which it will always accompany. + + dec ebx + shl ebx, 16 + or ebx, eax + mov [esp+chainlenwmask], ebx + + ; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + + mov eax, [edx].ds_nice_match + mov ebx, [edx].ds_lookahead + cmp ebx, eax + jl SHORT LookaheadLess + mov ebx, eax + LookaheadLess: + mov [esp+nicematch], ebx + + ;/* register Bytef *scan = s->window + s->strstart; */ + + mov esi, [edx].ds_window + mov [esp+window], esi + mov ebp, [edx].ds_strstart + lea edi, [esi+ebp] + mov [esp+scan],edi + + ;/* Determine how many bytes the scan ptr is off from being */ + ;/* dword-aligned. */ + + mov eax, edi + neg eax + and eax, 3 + mov [esp+scanalign], eax + + ;/* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */ + ;/* s->strstart - (IPos)MAX_DIST(s) : NIL; */ + + mov eax, [edx].ds_w_size + sub eax, MIN_LOOKAHEAD + sub ebp, eax + jg SHORT LimitPositive + xor ebp, ebp + LimitPositive: + + ;/* int best_len = s->prev_length; */ + + mov eax, [edx].ds_prev_length + mov [esp+bestlen], eax + + ;/* Store the sum of s->window + best_len in %esi locally, and in %esi. */ + + add esi, eax + mov [esp+windowbestlen], esi + + ;/* register ush scan_start = *(ushf*)scan; */ + ;/* register ush scan_end = *(ushf*)(scan+best_len-1); */ + ;/* Posf *prev = s->prev; */ + + movzx ebx, WORD PTR[edi] + mov [esp+scanstart], ebx + movzx ebx, WORD PTR[eax+edi-1] + mov [esp+scanend], ebx + mov edi, [edx].ds_prev + + ;/* Jump into the main loop. */ + + mov edx, [esp+chainlenwmask] + jmp SHORT LoopEntry + + ;/* do { + ; * match = s->window + cur_match; + ; * if (*(ushf*)(match+best_len-1) != scan_end || + ; * *(ushf*)match != scan_start) continue; + ; * [...] + ; * } while ((cur_match = prev[cur_match & wmask]) > limit + ; * && --chain_length != 0); + ; * + ; * Here is the inner loop of the function. The function will spend the + ; * majority of its time in this loop, and majority of that time will + ; * be spent in the first ten instructions. + ; * + ; * Within this loop: + ; * %ebx = scanend + ; * %ecx = curmatch + ; * %edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) + ; * %esi = windowbestlen - i.e., (window + bestlen) + ; * %edi = prev + ; * %ebp = limit + ; */ + + ALIGN 4 + LookupLoop: + and ecx, edx + movzx ecx, WORD PTR[edi+ecx*2] + cmp ecx, ebp + jbe LeaveNow + sub edx, 000010000H + js LeaveNow + + LoopEntry: + movzx eax, WORD PTR[esi+ecx-1] + cmp eax, ebx + jnz SHORT LookupLoop + + mov eax, [esp+window] + movzx eax, WORD PTR[eax+ecx] + cmp eax, [esp+scanstart] + jnz SHORT LookupLoop + + ;/* Store the current value of chainlen. */ + + mov [esp+chainlenwmask], edx + + ;/* Point %edi to the string under scrutiny, and %esi to the string we */ + ;/* are hoping to match it up with. In actuality, %esi and %edi are */ + ;/* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */ + ;/* initialized to -(MAX_MATCH_8 - scanalign). */ + + mov esi, [esp+window] + mov edi, [esp+scan] + add esi, ecx + mov eax, [esp+scanalign] + mov edx, -MAX_MATCH_8 + lea edi, [edi+eax+MAX_MATCH_8] + lea esi, [esi+eax+MAX_MATCH_8] + + ;/* Test the strings for equality, 8 bytes at a time. At the end, + ; * adjust %edx so that it is offset to the exact byte that mismatched. + ; * + ; * We already know at this point that the first three bytes of the + ; * strings match each other, and they can be safely passed over before + ; * starting the compare loop. So what this code does is skip over 0-3 + ; * bytes, as much as necessary in order to dword-align the %edi + ; * pointer. (%esi will still be misaligned three times out of four.) + ; * + ; * It should be confessed that this loop usually does not represent + ; * much of the total running time. Replacing it with a more + ; * straightforward "rep cmpsb" would not drastically degrade + ; * performance. + ; */ + + LoopCmps: + mov eax, DWORD PTR[esi+edx] + xor eax, DWORD PTR[edi+edx] + jnz SHORT LeaveLoopCmps + + mov eax, DWORD PTR[esi+edx+4] + xor eax, DWORD PTR[edi+edx+4] + jnz SHORT LeaveLoopCmps4 + + add edx, 8 + jnz SHORT LoopCmps + jmp LenMaximum + ALIGN 4 + + LeaveLoopCmps4: + add edx, 4 + + LeaveLoopCmps: + test eax, 00000FFFFH + jnz SHORT LenLower + + add edx, 2 + shr eax, 16 + + LenLower: + sub al, 1 + adc edx, 0 + + ;/* Calculate the length of the match. If it is longer than MAX_MATCH, */ + ;/* then automatically accept it as the best possible match and leave. */ + + lea eax, [edi+edx] + mov edi, [esp+scan] + sub eax, edi + cmp eax, MAX_MATCH + jge SHORT LenMaximum + + ;/* If the length of the match is not longer than the best match we */ + ;/* have so far, then forget it and return to the lookup loop. */ + + mov edx, [esp+deflatestate] + mov ebx, [esp+bestlen] + cmp eax, ebx + jg SHORT LongerMatch + mov esi, [esp+windowbestlen] + mov edi, [edx].ds_prev + mov ebx, [esp+scanend] + mov edx, [esp+chainlenwmask] + jmp LookupLoop + ALIGN 4 + + ;/* s->match_start = cur_match; */ + ;/* best_len = len; */ + ;/* if (len >= nice_match) break; */ + ;/* scan_end = *(ushf*)(scan+best_len-1); */ + + LongerMatch: + mov ebx, [esp+nicematch] + mov [esp+bestlen], eax + mov [edx].ds_match_start, ecx + cmp eax, ebx + jge SHORT LeaveNow + mov esi, [esp+window] + add esi, eax + mov [esp+windowbestlen], esi + movzx ebx, WORD PTR[edi+eax-1] + mov edi, [edx].ds_prev + mov [esp+scanend], ebx + mov edx, [esp+chainlenwmask] + jmp LookupLoop + ALIGN 4 + + ;/* Accept the current string, with the maximum possible length. */ + + LenMaximum: + mov edx, [esp+deflatestate] + mov DWORD PTR[esp+bestlen], MAX_MATCH + mov [edx].ds_match_start, ecx + + ;/* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */ + ;/* return s->lookahead; */ + + LeaveNow: + mov edx, [esp+deflatestate] + mov ebx, [esp+bestlen] + mov eax, [edx].ds_lookahead + cmp ebx, eax + jg SHORT LookaheadRet + mov eax, ebx + LookaheadRet: + + ; Restore the stack and return from whence we came. + + add esp, varsize + pop ebx + pop esi + pop edi + pop ebp + ret + + _longest_match ENDP + + _TEXT ENDS + END From criswell at cs.uiuc.edu Fri Feb 6 10:41:06 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:41:06 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/iostream2/zstream.h zstream_test.cpp Message-ID: <200402061636.KAA15515@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/iostream2: zstream.h added (r1.1) zstream_test.cpp added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+332 -0) Index: llvm/runtime/zlib/contrib/iostream2/zstream.h diff -c /dev/null llvm/runtime/zlib/contrib/iostream2/zstream.h:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/iostream2/zstream.h Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,307 ---- + /* + * + * Copyright (c) 1997 + * Christian Michelsen Research AS + * Advanced Computing + * Fantoftvegen 38, 5036 BERGEN, Norway + * http://www.cmr.no + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Christian Michelsen Research AS makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + + #ifndef ZSTREAM__H + #define ZSTREAM__H + + /* + * zstream.h - C++ interface to the 'zlib' general purpose compression library + * $Id: zstream.h,v 1.1 2004/02/06 16:36:40 criswell Exp $ + */ + + #include + #include + #include + #include "zlib.h" + + #if defined(_WIN32) + # include + # include + # define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) + #else + # define SET_BINARY_MODE(file) + #endif + + class zstringlen { + public: + zstringlen(class izstream&); + zstringlen(class ozstream&, const char*); + size_t value() const { return val.word; } + private: + struct Val { unsigned char byte; size_t word; } val; + }; + + // ----------------------------- izstream ----------------------------- + + class izstream + { + public: + izstream() : m_fp(0) {} + izstream(FILE* fp) : m_fp(0) { open(fp); } + izstream(const char* name) : m_fp(0) { open(name); } + ~izstream() { close(); } + + /* Opens a gzip (.gz) file for reading. + * open() can be used to read a file which is not in gzip format; + * in this case read() will directly read from the file without + * decompression. errno can be checked to distinguish two error + * cases (if errno is zero, the zlib error is Z_MEM_ERROR). + */ + void open(const char* name) { + if (m_fp) close(); + m_fp = ::gzopen(name, "rb"); + } + + void open(FILE* fp) { + SET_BINARY_MODE(fp); + if (m_fp) close(); + m_fp = ::gzdopen(fileno(fp), "rb"); + } + + /* Flushes all pending input if necessary, closes the compressed file + * and deallocates all the (de)compression state. The return value is + * the zlib error number (see function error() below). + */ + int close() { + int r = ::gzclose(m_fp); + m_fp = 0; return r; + } + + /* Binary read the given number of bytes from the compressed file. + */ + int read(void* buf, size_t len) { + return ::gzread(m_fp, buf, len); + } + + /* Returns the error message for the last error which occurred on the + * given compressed file. errnum is set to zlib error number. If an + * error occurred in the file system and not in the compression library, + * errnum is set to Z_ERRNO and the application may consult errno + * to get the exact error code. + */ + const char* error(int* errnum) { + return ::gzerror(m_fp, errnum); + } + + gzFile fp() { return m_fp; } + + private: + gzFile m_fp; + }; + + /* + * Binary read the given (array of) object(s) from the compressed file. + * If the input file was not in gzip format, read() copies the objects number + * of bytes into the buffer. + * returns the number of uncompressed bytes actually read + * (0 for end of file, -1 for error). + */ + template + inline int read(izstream& zs, T* x, Items items) { + return ::gzread(zs.fp(), x, items*sizeof(T)); + } + + /* + * Binary input with the '>' operator. + */ + template + inline izstream& operator>(izstream& zs, T& x) { + ::gzread(zs.fp(), &x, sizeof(T)); + return zs; + } + + + inline zstringlen::zstringlen(izstream& zs) { + zs > val.byte; + if (val.byte == 255) zs > val.word; + else val.word = val.byte; + } + + /* + * Read length of string + the string with the '>' operator. + */ + inline izstream& operator>(izstream& zs, char* x) { + zstringlen len(zs); + ::gzread(zs.fp(), x, len.value()); + x[len.value()] = '\0'; + return zs; + } + + inline char* read_string(izstream& zs) { + zstringlen len(zs); + char* x = new char[len.value()+1]; + ::gzread(zs.fp(), x, len.value()); + x[len.value()] = '\0'; + return x; + } + + // ----------------------------- ozstream ----------------------------- + + class ozstream + { + public: + ozstream() : m_fp(0), m_os(0) { + } + ozstream(FILE* fp, int level = Z_DEFAULT_COMPRESSION) + : m_fp(0), m_os(0) { + open(fp, level); + } + ozstream(const char* name, int level = Z_DEFAULT_COMPRESSION) + : m_fp(0), m_os(0) { + open(name, level); + } + ~ozstream() { + close(); + } + + /* Opens a gzip (.gz) file for writing. + * The compression level parameter should be in 0..9 + * errno can be checked to distinguish two error cases + * (if errno is zero, the zlib error is Z_MEM_ERROR). + */ + void open(const char* name, int level = Z_DEFAULT_COMPRESSION) { + char mode[4] = "wb\0"; + if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level; + if (m_fp) close(); + m_fp = ::gzopen(name, mode); + } + + /* open from a FILE pointer. + */ + void open(FILE* fp, int level = Z_DEFAULT_COMPRESSION) { + SET_BINARY_MODE(fp); + char mode[4] = "wb\0"; + if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level; + if (m_fp) close(); + m_fp = ::gzdopen(fileno(fp), mode); + } + + /* Flushes all pending output if necessary, closes the compressed file + * and deallocates all the (de)compression state. The return value is + * the zlib error number (see function error() below). + */ + int close() { + if (m_os) { + ::gzwrite(m_fp, m_os->str(), m_os->pcount()); + delete[] m_os->str(); delete m_os; m_os = 0; + } + int r = ::gzclose(m_fp); m_fp = 0; return r; + } + + /* Binary write the given number of bytes into the compressed file. + */ + int write(const void* buf, size_t len) { + return ::gzwrite(m_fp, (voidp) buf, len); + } + + /* Flushes all pending output into the compressed file. The parameter + * _flush is as in the deflate() function. The return value is the zlib + * error number (see function gzerror below). flush() returns Z_OK if + * the flush_ parameter is Z_FINISH and all output could be flushed. + * flush() should be called only when strictly necessary because it can + * degrade compression. + */ + int flush(int _flush) { + os_flush(); + return ::gzflush(m_fp, _flush); + } + + /* Returns the error message for the last error which occurred on the + * given compressed file. errnum is set to zlib error number. If an + * error occurred in the file system and not in the compression library, + * errnum is set to Z_ERRNO and the application may consult errno + * to get the exact error code. + */ + const char* error(int* errnum) { + return ::gzerror(m_fp, errnum); + } + + gzFile fp() { return m_fp; } + + ostream& os() { + if (m_os == 0) m_os = new ostrstream; + return *m_os; + } + + void os_flush() { + if (m_os && m_os->pcount()>0) { + ostrstream* oss = new ostrstream; + oss->fill(m_os->fill()); + oss->flags(m_os->flags()); + oss->precision(m_os->precision()); + oss->width(m_os->width()); + ::gzwrite(m_fp, m_os->str(), m_os->pcount()); + delete[] m_os->str(); delete m_os; m_os = oss; + } + } + + private: + gzFile m_fp; + ostrstream* m_os; + }; + + /* + * Binary write the given (array of) object(s) into the compressed file. + * returns the number of uncompressed bytes actually written + * (0 in case of error). + */ + template + inline int write(ozstream& zs, const T* x, Items items) { + return ::gzwrite(zs.fp(), (voidp) x, items*sizeof(T)); + } + + /* + * Binary output with the '<' operator. + */ + template + inline ozstream& operator<(ozstream& zs, const T& x) { + ::gzwrite(zs.fp(), (voidp) &x, sizeof(T)); + return zs; + } + + inline zstringlen::zstringlen(ozstream& zs, const char* x) { + val.byte = 255; val.word = ::strlen(x); + if (val.word < 255) zs < (val.byte = val.word); + else zs < val; + } + + /* + * Write length of string + the string with the '<' operator. + */ + inline ozstream& operator<(ozstream& zs, const char* x) { + zstringlen len(zs, x); + ::gzwrite(zs.fp(), (voidp) x, len.value()); + return zs; + } + + #ifdef _MSC_VER + inline ozstream& operator<(ozstream& zs, char* const& x) { + return zs < (const char*) x; + } + #endif + + /* + * Ascii write with the << operator; + */ + template + inline ostream& operator<<(ozstream& zs, const T& x) { + zs.os_flush(); + return zs.os() << x; + } + + #endif Index: llvm/runtime/zlib/contrib/iostream2/zstream_test.cpp diff -c /dev/null llvm/runtime/zlib/contrib/iostream2/zstream_test.cpp:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/iostream2/zstream_test.cpp Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,25 ---- + #include "zstream.h" + #include + #include + #include + + void main() { + char h[256] = "Hello"; + char* g = "Goodbye"; + ozstream out("temp.gz"); + out < "This works well" < h < g; + out.close(); + + izstream in("temp.gz"); // read it back + char *x = read_string(in), *y = new char[256], z[256]; + in > y > z; + in.close(); + cout << x << endl << y << endl << z << endl; + + out.open("temp.gz"); // try ascii output; zcat temp.gz to see the results + out << setw(50) << setfill('#') << setprecision(20) << x << endl << y << endl << z << endl; + out << z << endl << y << endl << x << endl; + out << 1.1234567890123456789 << endl; + + delete[] x; delete[] y; + } From criswell at cs.uiuc.edu Fri Feb 6 10:41:26 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:41:26 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/iostream3/README TODO test.cc zfstream.cc zfstream.h Message-ID: <200402061636.KAA15539@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/iostream3: README added (r1.1) TODO added (r1.1) test.cc added (r1.1) zfstream.cc added (r1.1) zfstream.h added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+1047 -0) Index: llvm/runtime/zlib/contrib/iostream3/README diff -c /dev/null llvm/runtime/zlib/contrib/iostream3/README:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/iostream3/README Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,35 ---- + These classes provide a C++ stream interface to the zlib library. It allows you + to do things like: + + gzofstream outf("blah.gz"); + outf << "These go into the gzip file " << 123 << endl; + + It does this by deriving a specialized stream buffer for gzipped files, which is + the way Stroustrup would have done it. :-> + + The gzifstream and gzofstream classes were originally written by Kevin Ruland + and made available in the zlib contrib/iostream directory. The older version still + compiles under gcc 2.xx, but not under gcc 3.xx, which sparked the development of + this version. + + The new classes are as standard-compliant as possible, closely following the + approach of the standard library's fstream classes. It compiles under gcc versions + 3.2 and 3.3, but not under gcc 2.xx. This is mainly due to changes in the standard + library naming scheme. The new version of gzifstream/gzofstream/gzfilebuf differs + from the previous one in the following respects: + - added showmanyc + - added setbuf, with support for unbuffered output via setbuf(0,0) + - a few bug fixes of stream behavior + - gzipped output file opened with default compression level instead of maximum level + - setcompressionlevel()/strategy() members replaced by single setcompression() + + The code is provided "as is", with the permission to use, copy, modify, distribute + and sell it for any purpose without fee. + + Ludwig Schwardt + + + DSP Lab + Electrical & Electronic Engineering Department + University of Stellenbosch + South Africa Index: llvm/runtime/zlib/contrib/iostream3/TODO diff -c /dev/null llvm/runtime/zlib/contrib/iostream3/TODO:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/iostream3/TODO Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,17 ---- + Possible upgrades to gzfilebuf: + + - The ability to do putback (e.g. putbackfail) + + - The ability to seek (zlib supports this, but could be slow/tricky) + + - Simultaneous read/write access (does it make sense?) + + - Support for ios_base::ate open mode + + - Locale support? + + - Check public interface to see which calls give problems + (due to dependence on library internals) + + - Override operator<<(ostream&, gzfilebuf*) to allow direct copying + of stream buffer to stream ( i.e. os << is.rdbuf(); ) Index: llvm/runtime/zlib/contrib/iostream3/test.cc diff -c /dev/null llvm/runtime/zlib/contrib/iostream3/test.cc:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/iostream3/test.cc Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,50 ---- + /* + * Test program for gzifstream and gzofstream + * + * by Ludwig Schwardt + * original version by Kevin Ruland + */ + + #include "zfstream.h" + #include // for cout + + int main() { + + gzofstream outf; + gzifstream inf; + char buf[80]; + + outf.open("test1.txt.gz"); + outf << "The quick brown fox sidestepped the lazy canine\n" + << 1.3 << "\nPlan " << 9 << std::endl; + outf.close(); + std::cout << "Wrote the following message to 'test1.txt.gz' (check with zcat or zless):\n" + << "The quick brown fox sidestepped the lazy canine\n" + << 1.3 << "\nPlan " << 9 << std::endl; + + std::cout << "\nReading 'test1.txt.gz' (buffered) produces:\n"; + inf.open("test1.txt.gz"); + while (inf.getline(buf,80,'\n')) { + std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n"; + } + inf.close(); + + outf.rdbuf()->pubsetbuf(0,0); + outf.open("test2.txt.gz"); + outf << setcompression(Z_NO_COMPRESSION) + << "The quick brown fox sidestepped the lazy canine\n" + << 1.3 << "\nPlan " << 9 << std::endl; + outf.close(); + std::cout << "\nWrote the same message to 'test2.txt.gz' in uncompressed form"; + + std::cout << "\nReading 'test2.txt.gz' (unbuffered) produces:\n"; + inf.rdbuf()->pubsetbuf(0,0); + inf.open("test2.txt.gz"); + while (inf.getline(buf,80,'\n')) { + std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n"; + } + inf.close(); + + return 0; + + } Index: llvm/runtime/zlib/contrib/iostream3/zfstream.cc diff -c /dev/null llvm/runtime/zlib/contrib/iostream3/zfstream.cc:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/iostream3/zfstream.cc Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,479 ---- + /* + * A C++ I/O streams interface to the zlib gz* functions + * + * by Ludwig Schwardt + * original version by Kevin Ruland + * + * This version is standard-compliant and compatible with gcc 3.x. + */ + + #include "zfstream.h" + #include // for strcpy, strcat, strlen (mode strings) + #include // for BUFSIZ + + // Internal buffer sizes (default and "unbuffered" versions) + #define BIGBUFSIZE BUFSIZ + #define SMALLBUFSIZE 1 + + /*****************************************************************************/ + + // Default constructor + gzfilebuf::gzfilebuf() + : file(NULL), io_mode(std::ios_base::openmode(0)), own_fd(false), + buffer(NULL), buffer_size(BIGBUFSIZE), own_buffer(true) + { + // No buffers to start with + this->disable_buffer(); + } + + // Destructor + gzfilebuf::~gzfilebuf() + { + // Sync output buffer and close only if responsible for file + // (i.e. attached streams should be left open at this stage) + this->sync(); + if (own_fd) + this->close(); + // Make sure internal buffer is deallocated + this->disable_buffer(); + } + + // Set compression level and strategy + int + gzfilebuf::setcompression(int comp_level, + int comp_strategy) + { + return gzsetparams(file, comp_level, comp_strategy); + } + + // Open gzipped file + gzfilebuf* + gzfilebuf::open(const char *name, + std::ios_base::openmode mode) + { + // Fail if file already open + if (this->is_open()) + return NULL; + // Don't support simultaneous read/write access (yet) + if ((mode & std::ios_base::in) && (mode & std::ios_base::out)) + return NULL; + + // Build mode string for gzopen and check it [27.8.1.3.2] + char char_mode[6] = "\0\0\0\0\0"; + if (!this->open_mode(mode, char_mode)) + return NULL; + + // Attempt to open file + if ((file = gzopen(name, char_mode)) == NULL) + return NULL; + + // On success, allocate internal buffer and set flags + this->enable_buffer(); + io_mode = mode; + own_fd = true; + return this; + } + + // Attach to gzipped file + gzfilebuf* + gzfilebuf::attach(int fd, + std::ios_base::openmode mode) + { + // Fail if file already open + if (this->is_open()) + return NULL; + // Don't support simultaneous read/write access (yet) + if ((mode & std::ios_base::in) && (mode & std::ios_base::out)) + return NULL; + + // Build mode string for gzdopen and check it [27.8.1.3.2] + char char_mode[6] = "\0\0\0\0\0"; + if (!this->open_mode(mode, char_mode)) + return NULL; + + // Attempt to attach to file + if ((file = gzdopen(fd, char_mode)) == NULL) + return NULL; + + // On success, allocate internal buffer and set flags + this->enable_buffer(); + io_mode = mode; + own_fd = false; + return this; + } + + // Close gzipped file + gzfilebuf* + gzfilebuf::close() + { + // Fail immediately if no file is open + if (!this->is_open()) + return NULL; + // Assume success + gzfilebuf* retval = this; + // Attempt to sync and close gzipped file + if (this->sync() == -1) + retval = NULL; + if (gzclose(file) < 0) + retval = NULL; + // File is now gone anyway (postcondition [27.8.1.3.8]) + file = NULL; + own_fd = false; + // Destroy internal buffer if it exists + this->disable_buffer(); + return retval; + } + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + // Convert int open mode to mode string + bool + gzfilebuf::open_mode(std::ios_base::openmode mode, + char* c_mode) const + { + bool testb = mode & std::ios_base::binary; + bool testi = mode & std::ios_base::in; + bool testo = mode & std::ios_base::out; + bool testt = mode & std::ios_base::trunc; + bool testa = mode & std::ios_base::app; + + // Check for valid flag combinations - see [27.8.1.3.2] (Table 92) + // Original zfstream hardcoded the compression level to maximum here... + // Double the time for less than 1% size improvement seems + // excessive though - keeping it at the default level + // To change back, just append "9" to the next three mode strings + if (!testi && testo && !testt && !testa) + strcpy(c_mode, "w"); + if (!testi && testo && !testt && testa) + strcpy(c_mode, "a"); + if (!testi && testo && testt && !testa) + strcpy(c_mode, "w"); + if (testi && !testo && !testt && !testa) + strcpy(c_mode, "r"); + // No read/write mode yet + // if (testi && testo && !testt && !testa) + // strcpy(c_mode, "r+"); + // if (testi && testo && testt && !testa) + // strcpy(c_mode, "w+"); + + // Mode string should be empty for invalid combination of flags + if (strlen(c_mode) == 0) + return false; + if (testb) + strcat(c_mode, "b"); + return true; + } + + // Determine number of characters in internal get buffer + std::streamsize + gzfilebuf::showmanyc() + { + // Calls to underflow will fail if file not opened for reading + if (!this->is_open() || !(io_mode & std::ios_base::in)) + return -1; + // Make sure get area is in use + if (this->gptr() && (this->gptr() < this->egptr())) + return std::streamsize(this->egptr() - this->gptr()); + else + return 0; + } + + // Fill get area from gzipped file + gzfilebuf::int_type + gzfilebuf::underflow() + { + // If something is left in the get area by chance, return it + // (this shouldn't normally happen, as underflow is only supposed + // to be called when gptr >= egptr, but it serves as error check) + if (this->gptr() && (this->gptr() < this->egptr())) + return traits_type::to_int_type(*(this->gptr())); + + // If the file hasn't been opened for reading, produce error + if (!this->is_open() || !(io_mode & std::ios_base::in)) + return traits_type::eof(); + + // Attempt to fill internal buffer from gzipped file + // (buffer must be guaranteed to exist...) + int bytes_read = gzread(file, buffer, buffer_size); + // Indicates error or EOF + if (bytes_read <= 0) + { + // Reset get area + this->setg(buffer, buffer, buffer); + return traits_type::eof(); + } + // Make all bytes read from file available as get area + this->setg(buffer, buffer, buffer + bytes_read); + + // Return next character in get area + return traits_type::to_int_type(*(this->gptr())); + } + + // Write put area to gzipped file + gzfilebuf::int_type + gzfilebuf::overflow(int_type c) + { + // Determine whether put area is in use + if (this->pbase()) + { + // Double-check pointer range + if (this->pptr() > this->epptr() || this->pptr() < this->pbase()) + return traits_type::eof(); + // Add extra character to buffer if not EOF + if (!traits_type::eq_int_type(c, traits_type::eof())) + { + *(this->pptr()) = traits_type::to_char_type(c); + this->pbump(1); + } + // Number of characters to write to file + int bytes_to_write = this->pptr() - this->pbase(); + // Overflow doesn't fail if nothing is to be written + if (bytes_to_write > 0) + { + // If the file hasn't been opened for writing, produce error + if (!this->is_open() || !(io_mode & std::ios_base::out)) + return traits_type::eof(); + // If gzipped file won't accept all bytes written to it, fail + if (gzwrite(file, this->pbase(), bytes_to_write) != bytes_to_write) + return traits_type::eof(); + // Reset next pointer to point to pbase on success + this->pbump(-bytes_to_write); + } + } + // Write extra character to file if not EOF + else if (!traits_type::eq_int_type(c, traits_type::eof())) + { + // If the file hasn't been opened for writing, produce error + if (!this->is_open() || !(io_mode & std::ios_base::out)) + return traits_type::eof(); + // Impromptu char buffer (allows "unbuffered" output) + char_type last_char = traits_type::to_char_type(c); + // If gzipped file won't accept this character, fail + if (gzwrite(file, &last_char, 1) != 1) + return traits_type::eof(); + } + + // If you got here, you have succeeded (even if c was EOF) + // The return value should therefore be non-EOF + if (traits_type::eq_int_type(c, traits_type::eof())) + return traits_type::not_eof(c); + else + return c; + } + + // Assign new buffer + std::streambuf* + gzfilebuf::setbuf(char_type* p, + std::streamsize n) + { + // First make sure stuff is sync'ed, for safety + if (this->sync() == -1) + return NULL; + // If buffering is turned off on purpose via setbuf(0,0), still allocate one... + // "Unbuffered" only really refers to put [27.8.1.4.10], while get needs at + // least a buffer of size 1 (very inefficient though, therefore make it bigger?) + // This follows from [27.5.2.4.3]/12 (gptr needs to point at something, it seems) + if (!p || !n) + { + // Replace existing buffer (if any) with small internal buffer + this->disable_buffer(); + buffer = NULL; + buffer_size = 0; + own_buffer = true; + this->enable_buffer(); + } + else + { + // Replace existing buffer (if any) with external buffer + this->disable_buffer(); + buffer = p; + buffer_size = n; + own_buffer = false; + this->enable_buffer(); + } + return this; + } + + // Write put area to gzipped file (i.e. ensures that put area is empty) + int + gzfilebuf::sync() + { + return traits_type::eq_int_type(this->overflow(), traits_type::eof()) ? -1 : 0; + } + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + // Allocate internal buffer + void + gzfilebuf::enable_buffer() + { + // If internal buffer required, allocate one + if (own_buffer && !buffer) + { + // Check for buffered vs. "unbuffered" + if (buffer_size > 0) + { + // Allocate internal buffer + buffer = new char_type[buffer_size]; + // Get area starts empty and will be expanded by underflow as need arises + this->setg(buffer, buffer, buffer); + // Setup entire internal buffer as put area. + // The one-past-end pointer actually points to the last element of the buffer, + // so that overflow(c) can safely add the extra character c to the sequence. + // These pointers remain in place for the duration of the buffer + this->setp(buffer, buffer + buffer_size - 1); + } + else + { + // Even in "unbuffered" case, (small?) get buffer is still required + buffer_size = SMALLBUFSIZE; + buffer = new char_type[buffer_size]; + this->setg(buffer, buffer, buffer); + // "Unbuffered" means no put buffer + this->setp(0, 0); + } + } + else + { + // If buffer already allocated, reset buffer pointers just to make sure no + // stale chars are lying around + this->setg(buffer, buffer, buffer); + this->setp(buffer, buffer + buffer_size - 1); + } + } + + // Destroy internal buffer + void + gzfilebuf::disable_buffer() + { + // If internal buffer exists, deallocate it + if (own_buffer && buffer) + { + // Preserve unbuffered status by zeroing size + if (!this->pbase()) + buffer_size = 0; + delete[] buffer; + buffer = NULL; + this->setg(0, 0, 0); + this->setp(0, 0); + } + else + { + // Reset buffer pointers to initial state if external buffer exists + this->setg(buffer, buffer, buffer); + if (buffer) + this->setp(buffer, buffer + buffer_size - 1); + else + this->setp(0, 0); + } + } + + /*****************************************************************************/ + + // Default constructor initializes stream buffer + gzifstream::gzifstream() + : std::istream(NULL), sb() + { this->init(&sb); } + + // Initialize stream buffer and open file + gzifstream::gzifstream(const char* name, + std::ios_base::openmode mode) + : std::istream(NULL), sb() + { + this->init(&sb); + this->open(name, mode); + } + + // Initialize stream buffer and attach to file + gzifstream::gzifstream(int fd, + std::ios_base::openmode mode) + : std::istream(NULL), sb() + { + this->init(&sb); + this->attach(fd, mode); + } + + // Open file and go into fail() state if unsuccessful + void + gzifstream::open(const char* name, + std::ios_base::openmode mode) + { + if (!sb.open(name, mode | std::ios_base::in)) + this->setstate(std::ios_base::failbit); + else + this->clear(); + } + + // Attach to file and go into fail() state if unsuccessful + void + gzifstream::attach(int fd, + std::ios_base::openmode mode) + { + if (!sb.attach(fd, mode | std::ios_base::in)) + this->setstate(std::ios_base::failbit); + else + this->clear(); + } + + // Close file + void + gzifstream::close() + { + if (!sb.close()) + this->setstate(std::ios_base::failbit); + } + + /*****************************************************************************/ + + // Default constructor initializes stream buffer + gzofstream::gzofstream() + : std::ostream(NULL), sb() + { this->init(&sb); } + + // Initialize stream buffer and open file + gzofstream::gzofstream(const char* name, + std::ios_base::openmode mode) + : std::ostream(NULL), sb() + { + this->init(&sb); + this->open(name, mode); + } + + // Initialize stream buffer and attach to file + gzofstream::gzofstream(int fd, + std::ios_base::openmode mode) + : std::ostream(NULL), sb() + { + this->init(&sb); + this->attach(fd, mode); + } + + // Open file and go into fail() state if unsuccessful + void + gzofstream::open(const char* name, + std::ios_base::openmode mode) + { + if (!sb.open(name, mode | std::ios_base::out)) + this->setstate(std::ios_base::failbit); + else + this->clear(); + } + + // Attach to file and go into fail() state if unsuccessful + void + gzofstream::attach(int fd, + std::ios_base::openmode mode) + { + if (!sb.attach(fd, mode | std::ios_base::out)) + this->setstate(std::ios_base::failbit); + else + this->clear(); + } + + // Close file + void + gzofstream::close() + { + if (!sb.close()) + this->setstate(std::ios_base::failbit); + } Index: llvm/runtime/zlib/contrib/iostream3/zfstream.h diff -c /dev/null llvm/runtime/zlib/contrib/iostream3/zfstream.h:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/iostream3/zfstream.h Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,466 ---- + /* + * A C++ I/O streams interface to the zlib gz* functions + * + * by Ludwig Schwardt + * original version by Kevin Ruland + * + * This version is standard-compliant and compatible with gcc 3.x. + */ + + #ifndef ZFSTREAM_H + #define ZFSTREAM_H + + #include // not iostream, since we don't need cin/cout + #include + #include "zlib.h" + + /*****************************************************************************/ + + /** + * @brief Gzipped file stream buffer class. + * + * This class implements basic_filebuf for gzipped files. It doesn't yet support + * seeking (allowed by zlib but slow/limited), putback and read/write access + * (tricky). Otherwise, it attempts to be a drop-in replacement for the standard + * file streambuf. + */ + class gzfilebuf : public std::streambuf + { + public: + // Default constructor. + gzfilebuf(); + + // Destructor. + virtual + ~gzfilebuf(); + + /** + * @brief Set compression level and strategy on the fly. + * @param comp_level Compression level (see zlib.h for allowed values) + * @param comp_strategy Compression strategy (see zlib.h for allowed values) + * @return Z_OK on success, Z_STREAM_ERROR otherwise. + * + * Unfortunately, these parameters cannot be modified separately, as the + * previous zfstream version assumed. Since the strategy is seldom changed, + * it can default and setcompression(level) then becomes like the old + * setcompressionlevel(level). + */ + int + setcompression(int comp_level, + int comp_strategy = Z_DEFAULT_STRATEGY); + + /** + * @brief Check if file is open. + * @return True if file is open. + */ + bool + is_open() const { return (file != NULL); } + + /** + * @brief Open gzipped file. + * @param name File name. + * @param mode Open mode flags. + * @return @c this on success, NULL on failure. + */ + gzfilebuf* + open(const char* name, + std::ios_base::openmode mode); + + /** + * @brief Attach to already open gzipped file. + * @param fd File descriptor. + * @param mode Open mode flags. + * @return @c this on success, NULL on failure. + */ + gzfilebuf* + attach(int fd, + std::ios_base::openmode mode); + + /** + * @brief Close gzipped file. + * @return @c this on success, NULL on failure. + */ + gzfilebuf* + close(); + + protected: + /** + * @brief Convert ios open mode int to mode string used by zlib. + * @return True if valid mode flag combination. + */ + bool + open_mode(std::ios_base::openmode mode, + char* c_mode) const; + + /** + * @brief Number of characters available in stream buffer. + * @return Number of characters. + * + * This indicates number of characters in get area of stream buffer. + * These characters can be read without accessing the gzipped file. + */ + virtual std::streamsize + showmanyc(); + + /** + * @brief Fill get area from gzipped file. + * @return First character in get area on success, EOF on error. + * + * This actually reads characters from gzipped file to stream + * buffer. Always buffered. + */ + virtual int_type + underflow(); + + /** + * @brief Write put area to gzipped file. + * @param c Extra character to add to buffer contents. + * @return Non-EOF on success, EOF on error. + * + * This actually writes characters in stream buffer to + * gzipped file. With unbuffered output this is done one + * character at a time. + */ + virtual int_type + overflow(int_type c = traits_type::eof()); + + /** + * @brief Installs external stream buffer. + * @param p Pointer to char buffer. + * @param n Size of external buffer. + * @return @c this on success, NULL on failure. + * + * Call setbuf(0,0) to enable unbuffered output. + */ + virtual std::streambuf* + setbuf(char_type* p, + std::streamsize n); + + /** + * @brief Flush stream buffer to file. + * @return 0 on success, -1 on error. + * + * This calls underflow(EOF) to do the job. + */ + virtual int + sync(); + + // + // Some future enhancements + // + // virtual int_type uflow(); + // virtual int_type pbackfail(int_type c = traits_type::eof()); + // virtual pos_type + // seekoff(off_type off, + // std::ios_base::seekdir way, + // std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); + // virtual pos_type + // seekpos(pos_type sp, + // std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); + + private: + /** + * @brief Allocate internal buffer. + * + * This function is safe to call multiple times. It will ensure + * that a proper internal buffer exists if it is required. If the + * buffer already exists or is external, the buffer pointers will be + * reset to their original state. + */ + void + enable_buffer(); + + /** + * @brief Destroy internal buffer. + * + * This function is safe to call multiple times. It will ensure + * that the internal buffer is deallocated if it exists. In any + * case, it will also reset the buffer pointers. + */ + void + disable_buffer(); + + /** + * Underlying file pointer. + */ + gzFile file; + + /** + * Mode in which file was opened. + */ + std::ios_base::openmode io_mode; + + /** + * @brief True if this object owns file descriptor. + * + * This makes the class responsible for closing the file + * upon destruction. + */ + bool own_fd; + + /** + * @brief Stream buffer. + * + * For simplicity this remains allocated on the free store for the + * entire life span of the gzfilebuf object, unless replaced by setbuf. + */ + char_type* buffer; + + /** + * @brief Stream buffer size. + * + * Defaults to system default buffer size (typically 8192 bytes). + * Modified by setbuf. + */ + std::streamsize buffer_size; + + /** + * @brief True if this object owns stream buffer. + * + * This makes the class responsible for deleting the buffer + * upon destruction. + */ + bool own_buffer; + }; + + /*****************************************************************************/ + + /** + * @brief Gzipped file input stream class. + * + * This class implements ifstream for gzipped files. Seeking and putback + * is not supported yet. + */ + class gzifstream : public std::istream + { + public: + // Default constructor + gzifstream(); + + /** + * @brief Construct stream on gzipped file to be opened. + * @param name File name. + * @param mode Open mode flags (forced to contain ios::in). + */ + explicit + gzifstream(const char* name, + std::ios_base::openmode mode = std::ios_base::in); + + /** + * @brief Construct stream on already open gzipped file. + * @param fd File descriptor. + * @param mode Open mode flags (forced to contain ios::in). + */ + explicit + gzifstream(int fd, + std::ios_base::openmode mode = std::ios_base::in); + + /** + * Obtain underlying stream buffer. + */ + gzfilebuf* + rdbuf() const + { return const_cast(&sb); } + + /** + * @brief Check if file is open. + * @return True if file is open. + */ + bool + is_open() { return sb.is_open(); } + + /** + * @brief Open gzipped file. + * @param name File name. + * @param mode Open mode flags (forced to contain ios::in). + * + * Stream will be in state good() if file opens successfully; + * otherwise in state fail(). This differs from the behavior of + * ifstream, which never sets the state to good() and therefore + * won't allow you to reuse the stream for a second file unless + * you manually clear() the state. The choice is a matter of + * convenience. + */ + void + open(const char* name, + std::ios_base::openmode mode = std::ios_base::in); + + /** + * @brief Attach to already open gzipped file. + * @param fd File descriptor. + * @param mode Open mode flags (forced to contain ios::in). + * + * Stream will be in state good() if attach succeeded; otherwise + * in state fail(). + */ + void + attach(int fd, + std::ios_base::openmode mode = std::ios_base::in); + + /** + * @brief Close gzipped file. + * + * Stream will be in state fail() if close failed. + */ + void + close(); + + private: + /** + * Underlying stream buffer. + */ + gzfilebuf sb; + }; + + /*****************************************************************************/ + + /** + * @brief Gzipped file output stream class. + * + * This class implements ofstream for gzipped files. Seeking and putback + * is not supported yet. + */ + class gzofstream : public std::ostream + { + public: + // Default constructor + gzofstream(); + + /** + * @brief Construct stream on gzipped file to be opened. + * @param name File name. + * @param mode Open mode flags (forced to contain ios::out). + */ + explicit + gzofstream(const char* name, + std::ios_base::openmode mode = std::ios_base::out); + + /** + * @brief Construct stream on already open gzipped file. + * @param fd File descriptor. + * @param mode Open mode flags (forced to contain ios::out). + */ + explicit + gzofstream(int fd, + std::ios_base::openmode mode = std::ios_base::out); + + /** + * Obtain underlying stream buffer. + */ + gzfilebuf* + rdbuf() const + { return const_cast(&sb); } + + /** + * @brief Check if file is open. + * @return True if file is open. + */ + bool + is_open() { return sb.is_open(); } + + /** + * @brief Open gzipped file. + * @param name File name. + * @param mode Open mode flags (forced to contain ios::out). + * + * Stream will be in state good() if file opens successfully; + * otherwise in state fail(). This differs from the behavior of + * ofstream, which never sets the state to good() and therefore + * won't allow you to reuse the stream for a second file unless + * you manually clear() the state. The choice is a matter of + * convenience. + */ + void + open(const char* name, + std::ios_base::openmode mode = std::ios_base::out); + + /** + * @brief Attach to already open gzipped file. + * @param fd File descriptor. + * @param mode Open mode flags (forced to contain ios::out). + * + * Stream will be in state good() if attach succeeded; otherwise + * in state fail(). + */ + void + attach(int fd, + std::ios_base::openmode mode = std::ios_base::out); + + /** + * @brief Close gzipped file. + * + * Stream will be in state fail() if close failed. + */ + void + close(); + + private: + /** + * Underlying stream buffer. + */ + gzfilebuf sb; + }; + + /*****************************************************************************/ + + /** + * @brief Gzipped file output stream manipulator class. + * + * This class defines a two-argument manipulator for gzofstream. It is used + * as base for the setcompression(int,int) manipulator. + */ + template + class gzomanip2 + { + public: + // Allows insertor to peek at internals + template + friend gzofstream& + operator<<(gzofstream&, + const gzomanip2&); + + // Constructor + gzomanip2(gzofstream& (*f)(gzofstream&, T1, T2), + T1 v1, + T2 v2); + private: + // Underlying manipulator function + gzofstream& + (*func)(gzofstream&, T1, T2); + + // Arguments for manipulator function + T1 val1; + T2 val2; + }; + + /*****************************************************************************/ + + // Manipulator function thunks through to stream buffer + inline gzofstream& + setcompression(gzofstream &gzs, int l, int s = Z_DEFAULT_STRATEGY) + { + (gzs.rdbuf())->setcompression(l, s); + return gzs; + } + + // Manipulator constructor stores arguments + template + inline + gzomanip2::gzomanip2(gzofstream &(*f)(gzofstream &, T1, T2), + T1 v1, + T2 v2) + : func(f), val1(v1), val2(v2) + { } + + // Insertor applies underlying manipulator function to stream + template + inline gzofstream& + operator<<(gzofstream& s, const gzomanip2& m) + { return (*m.func)(s, m.val1, m.val2); } + + // Insert this onto stream to simplify setting of compression level + inline gzomanip2 + setcompression(int l, int s = Z_DEFAULT_STRATEGY) + { return gzomanip2(&setcompression, l, s); } + + #endif // ZFSTREAM_H From criswell at cs.uiuc.edu Fri Feb 6 10:41:44 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:41:44 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/inflate86/inffas86.c inffast.S Message-ID: <200402061636.KAA15496@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/inflate86: inffas86.c added (r1.1) inffast.S added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+2160 -0) Index: llvm/runtime/zlib/contrib/inflate86/inffas86.c diff -c /dev/null llvm/runtime/zlib/contrib/inflate86/inffas86.c:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/inflate86/inffas86.c Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,783 ---- + /* inffas86.c is a hand tuned assembler version of + * + * inffast.c -- fast decoding + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Copyright (C) 2003 Chris Anderson + * Please use the copyright conditions above. + * + * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from + * the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at + * the moment. I have successfully compiled and tested this code with gcc2.96, + * gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S + * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX + * enabled. I will attempt to merge the MMX code into this version. Newer + * versions of this and inffast.S can be found at + * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/ + */ + + #include "zutil.h" + #include "inftrees.h" + #include "inflate.h" + #include "inffast.h" + + /* Mark Adler's comments from inffast.c: */ + + /* + Decode literal, length, and distance codes and write out the resulting + literal and match bytes until either not enough input or output is + available, an end-of-block is encountered, or a data error is encountered. + When large enough input and output buffers are supplied to inflate(), for + example, a 16K input buffer and a 64K output buffer, more than 95% of the + inflate execution time is spent in this routine. + + Entry assumptions: + + state->mode == LEN + strm->avail_in >= 6 + strm->avail_out >= 258 + start >= strm->avail_out + state->bits < 8 + + On return, state->mode is one of: + + LEN -- ran out of enough output space or enough available input + TYPE -- reached end of block code, inflate() to interpret next block + BAD -- error in block data + + Notes: + + - The maximum input bits used by a length/distance pair is 15 bits for the + length code, 5 bits for the length extra, 15 bits for the distance code, + and 13 bits for the distance extra. This totals 48 bits, or six bytes. + Therefore if strm->avail_in >= 6, then there is enough input to avoid + checking for available input while decoding. + + - The maximum bytes that a single length/distance pair can output is 258 + bytes, which is the maximum length that can be coded. inflate_fast() + requires strm->avail_out >= 258 for each loop to avoid checking for + output space. + */ + void inflate_fast(strm, start) + z_streamp strm; + unsigned start; /* inflate()'s starting value for strm->avail_out */ + { + struct inflate_state FAR *state; + struct inffast_ar { + void *esp; /* esp save */ + unsigned char FAR *in; /* local strm->next_in */ + unsigned char FAR *last; /* while in < last, enough input available */ + unsigned char FAR *out; /* local strm->next_out */ + unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ + unsigned char FAR *end; /* while out < end, enough space available */ + unsigned wsize; /* window size or zero if not using window */ + unsigned write; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ + unsigned long hold; /* local strm->hold */ + unsigned bits; /* local strm->bits */ + code const FAR *lcode; /* local strm->lencode */ + code const FAR *dcode; /* local strm->distcode */ + unsigned lmask; /* mask for first level of length codes */ + unsigned dmask; /* mask for first level of distance codes */ + unsigned len; /* match length, unused bytes */ + unsigned dist; /* match distance */ + unsigned status; /* this is set when state changes */ + } ar; + + /* copy state to local variables */ + state = (struct inflate_state FAR *)strm->state; + ar.in = strm->next_in; + ar.last = ar.in + (strm->avail_in - 5); + ar.out = strm->next_out; + ar.beg = ar.out - (start - strm->avail_out); + ar.end = ar.out + (strm->avail_out - 257); + ar.wsize = state->wsize; + ar.write = state->write; + ar.window = state->window; + ar.hold = state->hold; + ar.bits = state->bits; + ar.lcode = state->lencode; + ar.dcode = state->distcode; + ar.lmask = (1U << state->lenbits) - 1; + ar.dmask = (1U << state->distbits) - 1; + + /* decode literals and length/distances until end-of-block or not enough + input data or output space */ + + /* align in on 2 byte boundary */ + if (((unsigned long)(void *)ar.in & 0x1) != 0) { + ar.hold += (unsigned long)*ar.in++ << ar.bits; + ar.bits += 8; + } + + #if defined( __GNUC__ ) || defined( __ICC ) + __asm__ __volatile__ ( + " leal %0, %%eax\n" + " pushf\n" + " pushl %%ebp\n" + " movl %%esp, (%%eax)\n" + " movl %%eax, %%esp\n" + " movl 4(%%esp), %%esi\n" /* esi = in */ + " movl 12(%%esp), %%edi\n" /* edi = out */ + " movl 36(%%esp), %%edx\n" /* edx = hold */ + " movl 40(%%esp), %%ebx\n" /* ebx = bits */ + " movl 44(%%esp), %%ebp\n" /* ebp = lcode */ + + " cld\n" + " jmp .L_do_loop\n" + + ".L_while_test:\n" + " cmpl %%edi, 20(%%esp)\n" + " jbe .L_break_loop\n" + " cmpl %%esi, 8(%%esp)\n" + " jbe .L_break_loop\n" + + ".L_do_loop:\n" + " cmpb $15, %%bl\n" + " ja .L_get_length_code\n" /* if (15 < bits) */ + + " xorl %%eax, %%eax\n" + " lodsw\n" /* al = *(ushort *)in++ */ + " movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ + " addb $16, %%bl\n" /* bits += 16 */ + " shll %%cl, %%eax\n" + " orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ + + ".L_get_length_code:\n" + " movl 52(%%esp), %%eax\n" /* eax = lmask */ + " andl %%edx, %%eax\n" /* eax &= hold */ + " movl (%%ebp,%%eax,4), %%eax\n" /* eax = lcode[hold & lmask] */ + + ".L_dolen:\n" + " movb %%ah, %%cl\n" /* cl = this.bits */ + " subb %%ah, %%bl\n" /* bits -= this.bits */ + " shrl %%cl, %%edx\n" /* hold >>= this.bits */ + + " testb %%al, %%al\n" + " jnz .L_test_for_length_base\n" /* if (op != 0) 45.7% */ + + " shrl $16, %%eax\n" /* output this.val char */ + " stosb\n" + " jmp .L_while_test\n" + + ".L_test_for_length_base:\n" + " movl %%eax, %%ecx\n" /* len = this */ + " shrl $16, %%ecx\n" /* len = this.val */ + " movl %%ecx, 60(%%esp)\n" /* len = this */ + " movb %%al, %%cl\n" + + " testb $16, %%al\n" + " jz .L_test_for_second_level_length\n" /* if ((op & 16) == 0) 8% */ + " andb $15, %%cl\n" /* op &= 15 */ + " jz .L_decode_distance\n" /* if (!op) */ + " cmpb %%cl, %%bl\n" + " jae .L_add_bits_to_len\n" /* if (op <= bits) */ + + " movb %%cl, %%ch\n" /* stash op in ch, freeing cl */ + " xorl %%eax, %%eax\n" + " lodsw\n" /* al = *(ushort *)in++ */ + " movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ + " addb $16, %%bl\n" /* bits += 16 */ + " shll %%cl, %%eax\n" + " orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ + " movb %%ch, %%cl\n" /* move op back to ecx */ + + ".L_add_bits_to_len:\n" + " movl $1, %%eax\n" + " shll %%cl, %%eax\n" + " decl %%eax\n" + " subb %%cl, %%bl\n" + " andl %%edx, %%eax\n" /* eax &= hold */ + " shrl %%cl, %%edx\n" + " addl %%eax, 60(%%esp)\n" /* len += hold & mask[op] */ + + ".L_decode_distance:\n" + " cmpb $15, %%bl\n" + " ja .L_get_distance_code\n" /* if (15 < bits) */ + + " xorl %%eax, %%eax\n" + " lodsw\n" /* al = *(ushort *)in++ */ + " movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ + " addb $16, %%bl\n" /* bits += 16 */ + " shll %%cl, %%eax\n" + " orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ + + ".L_get_distance_code:\n" + " movl 56(%%esp), %%eax\n" /* eax = dmask */ + " movl 48(%%esp), %%ecx\n" /* ecx = dcode */ + " andl %%edx, %%eax\n" /* eax &= hold */ + " movl (%%ecx,%%eax,4), %%eax\n"/* eax = dcode[hold & dmask] */ + + ".L_dodist:\n" + " movl %%eax, %%ebp\n" /* dist = this */ + " shrl $16, %%ebp\n" /* dist = this.val */ + " movb %%ah, %%cl\n" + " subb %%ah, %%bl\n" /* bits -= this.bits */ + " shrl %%cl, %%edx\n" /* hold >>= this.bits */ + " movb %%al, %%cl\n" /* cl = this.op */ + + " testb $16, %%al\n" /* if ((op & 16) == 0) */ + " jz .L_test_for_second_level_dist\n" + " andb $15, %%cl\n" /* op &= 15 */ + " jz .L_check_dist_one\n" + " cmpb %%cl, %%bl\n" + " jae .L_add_bits_to_dist\n" /* if (op <= bits) 97.6% */ + + " movb %%cl, %%ch\n" /* stash op in ch, freeing cl */ + " xorl %%eax, %%eax\n" + " lodsw\n" /* al = *(ushort *)in++ */ + " movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ + " addb $16, %%bl\n" /* bits += 16 */ + " shll %%cl, %%eax\n" + " orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ + " movb %%ch, %%cl\n" /* move op back to ecx */ + + ".L_add_bits_to_dist:\n" + " movl $1, %%eax\n" + " shll %%cl, %%eax\n" + " decl %%eax\n" /* (1 << op) - 1 */ + " subb %%cl, %%bl\n" + " andl %%edx, %%eax\n" /* eax &= hold */ + " shrl %%cl, %%edx\n" + " addl %%eax, %%ebp\n" /* dist += hold & ((1 << op) - 1) */ + + ".L_check_window:\n" + " movl %%esi, 4(%%esp)\n" /* save in so from can use it's reg */ + " movl %%edi, %%eax\n" + " subl 16(%%esp), %%eax\n" /* nbytes = out - beg */ + + " cmpl %%ebp, %%eax\n" + " jb .L_clip_window\n" /* if (dist > nbytes) 4.2% */ + + " movl 60(%%esp), %%ecx\n" + " movl %%edi, %%esi\n" + " subl %%ebp, %%esi\n" /* from = out - dist */ + + " subl $3, %%ecx\n" /* copy from to out */ + " movb (%%esi), %%al\n" + " movb %%al, (%%edi)\n" + " movb 1(%%esi), %%al\n" + " movb 2(%%esi), %%ah\n" + " addl $3, %%esi\n" + " movb %%al, 1(%%edi)\n" + " movb %%ah, 2(%%edi)\n" + " addl $3, %%edi\n" + " rep movsb\n" + + " movl 4(%%esp), %%esi\n" /* move in back to %esi, toss from */ + " movl 44(%%esp), %%ebp\n" /* ebp = lcode */ + " jmp .L_while_test\n" + + ".L_check_dist_one:\n" + " cmpl $1, %%ebp\n" /* if dist 1, is a memset */ + " jne .L_check_window\n" + " cmpl %%edi, 16(%%esp)\n" + " je .L_check_window\n" + + " decl %%edi\n" + " movl 60(%%esp), %%ecx\n" + " movb (%%edi), %%al\n" + " subl $3, %%ecx\n" + + " movb %%al, 1(%%edi)\n" /* memset out with from[-1] */ + " movb %%al, 2(%%edi)\n" + " movb %%al, 3(%%edi)\n" + " addl $4, %%edi\n" + " rep stosb\n" + " movl 44(%%esp), %%ebp\n" /* ebp = lcode */ + " jmp .L_while_test\n" + + ".L_test_for_second_level_length:\n" + " testb $64, %%al\n" + " jnz .L_test_for_end_of_block\n" /* if ((op & 64) != 0) */ + + " movl $1, %%eax\n" + " shll %%cl, %%eax\n" + " decl %%eax\n" + " andl %%edx, %%eax\n" /* eax &= hold */ + " addl 60(%%esp), %%eax\n" /* eax += this.val */ + " movl (%%ebp,%%eax,4), %%eax\n" /* eax = lcode[val+(hold&mask[op])]*/ + " jmp .L_dolen\n" + + ".L_test_for_second_level_dist:\n" + " testb $64, %%al\n" + " jnz .L_invalid_distance_code\n" /* if ((op & 64) != 0) */ + + " movl $1, %%eax\n" + " shll %%cl, %%eax\n" + " decl %%eax\n" + " andl %%edx, %%eax\n" /* eax &= hold */ + " addl %%ebp, %%eax\n" /* eax += this.val */ + " movl 48(%%esp), %%ecx\n" /* ecx = dcode */ + " movl (%%ecx,%%eax,4), %%eax\n" /* eax = dcode[val+(hold&mask[op])]*/ + " jmp .L_dodist\n" + + ".L_clip_window:\n" + " movl %%eax, %%ecx\n" + " movl 24(%%esp), %%eax\n" /* prepare for dist compare */ + " negl %%ecx\n" /* nbytes = -nbytes */ + " movl 32(%%esp), %%esi\n" /* from = window */ + + " cmpl %%ebp, %%eax\n" + " jb .L_invalid_distance_too_far\n" /* if (dist > wsize) */ + + " addl %%ebp, %%ecx\n" /* nbytes = dist - nbytes */ + " cmpl $0, 28(%%esp)\n" + " jne .L_wrap_around_window\n" /* if (write != 0) */ + + " subl %%ecx, %%eax\n" + " addl %%eax, %%esi\n" /* from += wsize - nbytes */ + + " movl 60(%%esp), %%eax\n" + " cmpl %%ecx, %%eax\n" + " jbe .L_do_copy1\n" /* if (nbytes >= len) */ + + " subl %%ecx, %%eax\n" /* len -= nbytes */ + " rep movsb\n" + " movl %%edi, %%esi\n" + " subl %%ebp, %%esi\n" /* from = out - dist */ + " jmp .L_do_copy1\n" + + " cmpl %%ecx, %%eax\n" + " jbe .L_do_copy1\n" /* if (nbytes >= len) */ + + " subl %%ecx, %%eax\n" /* len -= nbytes */ + " rep movsb\n" + " movl %%edi, %%esi\n" + " subl %%ebp, %%esi\n" /* from = out - dist */ + " jmp .L_do_copy1\n" + + ".L_wrap_around_window:\n" + " movl 28(%%esp), %%eax\n" + " cmpl %%eax, %%ecx\n" + " jbe .L_contiguous_in_window\n" /* if (write >= nbytes) */ + + " addl 24(%%esp), %%esi\n" + " addl %%eax, %%esi\n" + " subl %%ecx, %%esi\n" /* from += wsize + write - nbytes */ + " subl %%eax, %%ecx\n" /* nbytes -= write */ + + " movl 60(%%esp), %%eax\n" + " cmpl %%ecx, %%eax\n" + " jbe .L_do_copy1\n" /* if (nbytes >= len) */ + + " subl %%ecx, %%eax\n" /* len -= nbytes */ + " rep movsb\n" + " movl 32(%%esp), %%esi\n" /* from = window */ + " movl 28(%%esp), %%ecx\n" /* nbytes = write */ + " cmpl %%ecx, %%eax\n" + " jbe .L_do_copy1\n" /* if (nbytes >= len) */ + + " subl %%ecx, %%eax\n" /* len -= nbytes */ + " rep movsb\n" + " movl %%edi, %%esi\n" + " subl %%ebp, %%esi\n" /* from = out - dist */ + " jmp .L_do_copy1\n" + + ".L_contiguous_in_window:\n" + " addl %%eax, %%esi\n" + " subl %%ecx, %%esi\n" /* from += write - nbytes */ + + " movl 60(%%esp), %%eax\n" + " cmpl %%ecx, %%eax\n" + " jbe .L_do_copy1\n" /* if (nbytes >= len) */ + + " subl %%ecx, %%eax\n" /* len -= nbytes */ + " rep movsb\n" + " movl %%edi, %%esi\n" + " subl %%ebp, %%esi\n" /* from = out - dist */ + + ".L_do_copy1:\n" + " movl %%eax, %%ecx\n" + " rep movsb\n" + + " movl 4(%%esp), %%esi\n" /* move in back to %esi, toss from */ + " movl 44(%%esp), %%ebp\n" /* ebp = lcode */ + " jmp .L_while_test\n" + + ".L_test_for_end_of_block:\n" + " testb $32, %%al\n" + " jz .L_invalid_literal_length_code\n" + " movl $1, 68(%%esp)\n" + " jmp .L_break_loop_with_status\n" + + ".L_invalid_literal_length_code:\n" + " movl $2, 68(%%esp)\n" + " jmp .L_break_loop_with_status\n" + + ".L_invalid_distance_code:\n" + " movl $3, 68(%%esp)\n" + " jmp .L_break_loop_with_status\n" + + ".L_invalid_distance_too_far:\n" + " movl 4(%%esp), %%esi\n" + " movl $4, 68(%%esp)\n" + " jmp .L_break_loop_with_status\n" + + ".L_break_loop:\n" + " movl $0, 68(%%esp)\n" + + ".L_break_loop_with_status:\n" + /* put in, out, bits, and hold back into ar and pop esp */ + " movl %%esi, 4(%%esp)\n" + " movl %%edi, 12(%%esp)\n" + " movl %%ebx, 40(%%esp)\n" + " movl %%edx, 36(%%esp)\n" + " movl (%%esp), %%esp\n" + " popl %%ebp\n" + " popf\n" + : + : "m" (ar) + : "memory", "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi" + ); + #elif defined( _MSC_VER ) + __asm { + lea eax, ar + pushfd + push ebp + mov [eax], esp + mov esp, eax + mov esi, [esp+4] /* esi = in */ + mov edi, [esp+12] /* edi = out */ + mov edx, [esp+36] /* edx = hold */ + mov ebx, [esp+40] /* ebx = bits */ + mov ebp, [esp+44] /* ebp = lcode */ + + cld + jmp L_do_loop + + L_while_test: + cmp [esp+20], edi + jbe L_break_loop + cmp [esp+8], esi + jbe L_break_loop + + L_do_loop: + cmp bl, 15 + ja L_get_length_code /* if (15 < bits) */ + + xor eax, eax + lodsw /* al = *(ushort *)in++ */ + mov cl, bl /* cl = bits, needs it for shifting */ + add bl, 16 /* bits += 16 */ + shl eax, cl + or edx, eax /* hold |= *((ushort *)in)++ << bits */ + + L_get_length_code: + mov eax, [esp+52] /* eax = lmask */ + and eax, edx /* eax &= hold */ + mov eax, [ebp+eax*4] /* eax = lcode[hold & lmask] */ + + L_dolen: + mov cl, ah /* cl = this.bits */ + sub bl, ah /* bits -= this.bits */ + shr edx, cl /* hold >>= this.bits */ + + test al, al + jnz L_test_for_length_base /* if (op != 0) 45.7% */ + + shr eax, 16 /* output this.val char */ + stosb + jmp L_while_test + + L_test_for_length_base: + mov ecx, eax /* len = this */ + shr ecx, 16 /* len = this.val */ + mov [esp+60], ecx /* len = this */ + mov cl, al + + test al, 16 + jz L_test_for_second_level_length /* if ((op & 16) == 0) 8% */ + and cl, 15 /* op &= 15 */ + jz L_decode_distance /* if (!op) */ + cmp bl, cl + jae L_add_bits_to_len /* if (op <= bits) */ + + mov ch, cl /* stash op in ch, freeing cl */ + xor eax, eax + lodsw /* al = *(ushort *)in++ */ + mov cl, bl /* cl = bits, needs it for shifting */ + add bl, 16 /* bits += 16 */ + shl eax, cl + or edx, eax /* hold |= *((ushort *)in)++ << bits */ + mov cl, ch /* move op back to ecx */ + + L_add_bits_to_len: + mov eax, 1 + shl eax, cl + dec eax + sub bl, cl + and eax, edx /* eax &= hold */ + shr edx, cl + add [esp+60], eax /* len += hold & mask[op] */ + + L_decode_distance: + cmp bl, 15 + ja L_get_distance_code /* if (15 < bits) */ + + xor eax, eax + lodsw /* al = *(ushort *)in++ */ + mov cl, bl /* cl = bits, needs it for shifting */ + add bl, 16 /* bits += 16 */ + shl eax, cl + or edx, eax /* hold |= *((ushort *)in)++ << bits */ + + L_get_distance_code: + mov eax, [esp+56] /* eax = dmask */ + mov ecx, [esp+48] /* ecx = dcode */ + and eax, edx /* eax &= hold */ + mov eax, [ecx+eax*4]/* eax = dcode[hold & dmask] */ + + L_dodist: + mov ebp, eax /* dist = this */ + shr ebp, 16 /* dist = this.val */ + mov cl, ah + sub bl, ah /* bits -= this.bits */ + shr edx, cl /* hold >>= this.bits */ + mov cl, al /* cl = this.op */ + + test al, 16 /* if ((op & 16) == 0) */ + jz L_test_for_second_level_dist + and cl, 15 /* op &= 15 */ + jz L_check_dist_one + cmp bl, cl + jae L_add_bits_to_dist /* if (op <= bits) 97.6% */ + + mov ch, cl /* stash op in ch, freeing cl */ + xor eax, eax + lodsw /* al = *(ushort *)in++ */ + mov cl, bl /* cl = bits, needs it for shifting */ + add bl, 16 /* bits += 16 */ + shl eax, cl + or edx, eax /* hold |= *((ushort *)in)++ << bits */ + mov cl, ch /* move op back to ecx */ + + L_add_bits_to_dist: + mov eax, 1 + shl eax, cl + dec eax /* (1 << op) - 1 */ + sub bl, cl + and eax, edx /* eax &= hold */ + shr edx, cl + add ebp, eax /* dist += hold & ((1 << op) - 1) */ + + L_check_window: + mov [esp+4], esi /* save in so from can use it's reg */ + mov eax, edi + sub eax, [esp+16] /* nbytes = out - beg */ + + cmp eax, ebp + jb L_clip_window /* if (dist > nbytes) 4.2% */ + + mov ecx, [esp+60] + mov esi, edi + sub esi, ebp /* from = out - dist */ + + sub ecx, 3 /* copy from to out */ + mov al, [esi] + mov [edi], al + mov al, [esi+1] + mov ah, [esi+2] + add esi, 3 + mov [edi+1], al + mov [edi+2], ah + add edi, 3 + rep movsb + + mov esi, [esp+4] /* move in back to %esi, toss from */ + mov ebp, [esp+44] /* ebp = lcode */ + jmp L_while_test + + L_check_dist_one: + cmp ebp, 1 /* if dist 1, is a memset */ + jne L_check_window + cmp [esp+16], edi + je L_check_window + + dec edi + mov ecx, [esp+60] + mov al, [edi] + sub ecx, 3 + + mov [edi+1], al /* memset out with from[-1] */ + mov [edi+2], al + mov [edi+3], al + add edi, 4 + rep stosb + mov ebp, [esp+44] /* ebp = lcode */ + jmp L_while_test + + L_test_for_second_level_length: + test al, 64 + jnz L_test_for_end_of_block /* if ((op & 64) != 0) */ + + mov eax, 1 + shl eax, cl + dec eax + and eax, edx /* eax &= hold */ + add eax, [esp+60] /* eax += this.val */ + mov eax, [ebp+eax*4] /* eax = lcode[val+(hold&mask[op])]*/ + jmp L_dolen + + L_test_for_second_level_dist: + test al, 64 + jnz L_invalid_distance_code /* if ((op & 64) != 0) */ + + mov eax, 1 + shl eax, cl + dec eax + and eax, edx /* eax &= hold */ + add eax, ebp /* eax += this.val */ + mov ecx, [esp+48] /* ecx = dcode */ + mov eax, [ecx+eax*4] /* eax = dcode[val+(hold&mask[op])]*/ + jmp L_dodist + + L_clip_window: + mov ecx, eax + mov eax, [esp+24] /* prepare for dist compare */ + neg ecx /* nbytes = -nbytes */ + mov esi, [esp+32] /* from = window */ + + cmp eax, ebp + jb L_invalid_distance_too_far /* if (dist > wsize) */ + + add ecx, ebp /* nbytes = dist - nbytes */ + cmp dword ptr [esp+28], 0 + jne L_wrap_around_window /* if (write != 0) */ + + sub eax, ecx + add esi, eax /* from += wsize - nbytes */ + + mov eax, [esp+60] + cmp eax, ecx + jbe L_do_copy1 /* if (nbytes >= len) */ + + sub eax, ecx /* len -= nbytes */ + rep movsb + mov esi, edi + sub esi, ebp /* from = out - dist */ + jmp L_do_copy1 + + cmp eax, ecx + jbe L_do_copy1 /* if (nbytes >= len) */ + + sub eax, ecx /* len -= nbytes */ + rep movsb + mov esi, edi + sub esi, ebp /* from = out - dist */ + jmp L_do_copy1 + + L_wrap_around_window: + mov eax, [esp+28] + cmp ecx, eax + jbe L_contiguous_in_window /* if (write >= nbytes) */ + + add esi, [esp+24] + add esi, eax + sub esi, ecx /* from += wsize + write - nbytes */ + sub ecx, eax /* nbytes -= write */ + + mov eax, [esp+60] + cmp eax, ecx + jbe L_do_copy1 /* if (nbytes >= len) */ + + sub eax, ecx /* len -= nbytes */ + rep movsb + mov esi, [esp+32] /* from = window */ + mov ecx, [esp+28] /* nbytes = write */ + cmp eax, ecx + jbe L_do_copy1 /* if (nbytes >= len) */ + + sub eax, ecx /* len -= nbytes */ + rep movsb + mov esi, edi + sub esi, ebp /* from = out - dist */ + jmp L_do_copy1 + + L_contiguous_in_window: + add esi, eax + sub esi, ecx /* from += write - nbytes */ + + mov eax, [esp+60] + cmp eax, ecx + jbe L_do_copy1 /* if (nbytes >= len) */ + + sub eax, ecx /* len -= nbytes */ + rep movsb + mov esi, edi + sub esi, ebp /* from = out - dist */ + + L_do_copy1: + mov ecx, eax + rep movsb + + mov esi, [esp+4] /* move in back to %esi, toss from */ + mov ebp, [esp+44] /* ebp = lcode */ + jmp L_while_test + + L_test_for_end_of_block: + test al, 32 + jz L_invalid_literal_length_code + mov dword ptr [esp+68], 1 + jmp L_break_loop_with_status + + L_invalid_literal_length_code: + mov dword ptr [esp+68], 2 + jmp L_break_loop_with_status + + L_invalid_distance_code: + mov dword ptr [esp+68], 3 + jmp L_break_loop_with_status + + L_invalid_distance_too_far: + mov esi, [esp+4] + mov dword ptr [esp+68], 4 + jmp L_break_loop_with_status + + L_break_loop: + mov dword ptr [esp+68], 0 + + L_break_loop_with_status: + /* put in, out, bits, and hold back into ar and pop esp */ + mov [esp+4], esi + mov [esp+12], edi + mov [esp+40], ebx + mov [esp+36], edx + mov esp, [esp] + pop ebp + popfd + } + #endif + + if (ar.status > 1) { + if (ar.status == 2) + strm->msg = "invalid literal/length code"; + else if (ar.status == 3) + strm->msg = "invalid distance code"; + else + strm->msg = "invalid distance too far back"; + state->mode = BAD; + } + else if ( ar.status == 1 ) { + state->mode = TYPE; + } + + /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ + ar.len = ar.bits >> 3; + ar.in -= ar.len; + ar.bits -= ar.len << 3; + ar.hold &= (1U << ar.bits) - 1; + + /* update state and return */ + strm->next_in = ar.in; + strm->next_out = ar.out; + strm->avail_in = (unsigned)(ar.in < ar.last ? 5 + (ar.last - ar.in) : + 5 - (ar.in - ar.last)); + strm->avail_out = (unsigned)(ar.out < ar.end ? 257 + (ar.end - ar.out) : + 257 - (ar.out - ar.end)); + state->hold = ar.hold; + state->bits = ar.bits; + return; + } + Index: llvm/runtime/zlib/contrib/inflate86/inffast.S diff -c /dev/null llvm/runtime/zlib/contrib/inflate86/inffast.S:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/inflate86/inffast.S Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,1377 ---- + /* + * inffast.S is a hand tuned assembler version of: + * + * inffast.c -- fast decoding + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Copyright (C) 2003 Chris Anderson + * Please use the copyright conditions above. + * + * This version (Jan-23-2003) of inflate_fast was coded and tested under + * GNU/Linux on a pentium 3, using the gcc-3.2 compiler distribution. On that + * machine, I found that gzip style archives decompressed about 20% faster than + * the gcc-3.2 -O3 -fomit-frame-pointer compiled version. Your results will + * depend on how large of a buffer is used for z_stream.next_in & next_out + * (8K-32K worked best for my 256K cpu cache) and how much overhead there is in + * stream processing I/O and crc32/addler32. In my case, this routine used + * 70% of the cpu time and crc32 used 20%. + * + * I am confident that this version will work in the general case, but I have + * not tested a wide variety of datasets or a wide variety of platforms. + * + * Jan-24-2003 -- Added -DUSE_MMX define for slightly faster inflating. + * It should be a runtime flag instead of compile time flag... + * + * Jan-26-2003 -- Added runtime check for MMX support with cpuid instruction. + * With -DUSE_MMX, only MMX code is compiled. With -DNO_MMX, only non-MMX code + * is compiled. Without either option, runtime detection is enabled. Runtime + * detection should work on all modern cpus and the recomended algorithm (flip + * ID bit on eflags and then use the cpuid instruction) is used in many + * multimedia applications. Tested under win2k with gcc-2.95 and gas-2.12 + * distributed with cygwin3. Compiling with gcc-2.95 -c inffast.S -o + * inffast.obj generates a COFF object which can then be linked with MSVC++ + * compiled code. Tested under FreeBSD 4.7 with gcc-2.95. + * + * Jan-28-2003 -- Tested Athlon XP... MMX mode is slower than no MMX (and + * slower than compiler generated code). Adjusted cpuid check to use the MMX + * code only for Pentiums < P4 until I have more data on the P4. Speed + * improvment is only about 15% on the Athlon when compared with code generated + * with MSVC++. Not sure yet, but I think the P4 will also be slower using the + * MMX mode because many of it's x86 ALU instructions execute in .5 cycles and + * have less latency than MMX ops. Added code to buffer the last 11 bytes of + * the input stream since the MMX code grabs bits in chunks of 32, which + * differs from the inffast.c algorithm. I don't think there would have been + * read overruns where a page boundary was crossed (a segfault), but there + * could have been overruns when next_in ends on unaligned memory (unintialized + * memory read). + * + * Mar-13-2003 -- P4 MMX is slightly slower than P4 NO_MMX. I created a C + * version of the non-MMX code so that it doesn't depend on zstrm and zstate + * structure offsets which are hard coded in this file. This was last tested + * with zlib-1.2.0 which is currently in beta testing, newer versions of this + * and inffas86.c can be found at http://www.eetbeetee.com/zlib/ and + * http://www.charm.net/~christop/zlib/ + */ + + + /* + * if you have underscore linking problems (_inflate_fast undefined), try + * using -DGAS_COFF + */ + #if ! defined( GAS_COFF ) && ! defined( GAS_ELF ) + + #if defined( WIN32 ) || defined( __CYGWIN__ ) + #define GAS_COFF /* windows object format */ + #else + #define GAS_ELF + #endif + + #endif /* ! GAS_COFF && ! GAS_ELF */ + + + #if defined( GAS_COFF ) + + /* coff externals have underscores */ + #define inflate_fast _inflate_fast + #define inflate_fast_use_mmx _inflate_fast_use_mmx + + #endif /* GAS_COFF */ + + + .file "inffast.S" + + .globl inflate_fast + + .text + .align 4,0 + .L_invalid_literal_length_code_msg: + .string "invalid literal/length code" + + .align 4,0 + .L_invalid_distance_code_msg: + .string "invalid distance code" + + .align 4,0 + .L_invalid_distance_too_far_msg: + .string "invalid distance too far back" + + #if ! defined( NO_MMX ) + .align 4,0 + .L_mask: /* mask[N] = ( 1 << N ) - 1 */ + .long 0 + .long 1 + .long 3 + .long 7 + .long 15 + .long 31 + .long 63 + .long 127 + .long 255 + .long 511 + .long 1023 + .long 2047 + .long 4095 + .long 8191 + .long 16383 + .long 32767 + .long 65535 + .long 131071 + .long 262143 + .long 524287 + .long 1048575 + .long 2097151 + .long 4194303 + .long 8388607 + .long 16777215 + .long 33554431 + .long 67108863 + .long 134217727 + .long 268435455 + .long 536870911 + .long 1073741823 + .long 2147483647 + .long 4294967295 + #endif /* NO_MMX */ + + .text + + /* + * struct z_stream offsets, in zlib.h + */ + #define next_in_strm 0 /* strm->next_in */ + #define avail_in_strm 4 /* strm->avail_in */ + #define next_out_strm 12 /* strm->next_out */ + #define avail_out_strm 16 /* strm->avail_out */ + #define msg_strm 24 /* strm->msg */ + #define state_strm 28 /* strm->state */ + + /* + * struct inflate_state offsets, in inflate.h + */ + #define mode_state 0 /* state->mode */ + #define wsize_state 32 /* state->wsize */ + #define write_state 40 /* state->write */ + #define window_state 44 /* state->window */ + #define hold_state 48 /* state->hold */ + #define bits_state 52 /* state->bits */ + #define lencode_state 68 /* state->lencode */ + #define distcode_state 72 /* state->distcode */ + #define lenbits_state 76 /* state->lenbits */ + #define distbits_state 80 /* state->distbits */ + + /* + * inflate_fast's activation record + */ + #define local_var_size 64 /* how much local space for vars */ + #define strm_sp 88 /* first arg: z_stream * (local_var_size + 24) */ + #define start_sp 92 /* second arg: unsigned int (local_var_size + 28) */ + + /* + * offsets for local vars on stack + */ + #define out 60 /* unsigned char* */ + #define window 56 /* unsigned char* */ + #define wsize 52 /* unsigned int */ + #define write 48 /* unsigned int */ + #define in 44 /* unsigned char* */ + #define beg 40 /* unsigned char* */ + #define buf 28 /* char[ 12 ] */ + #define len 24 /* unsigned int */ + #define last 20 /* unsigned char* */ + #define end 16 /* unsigned char* */ + #define dcode 12 /* code* */ + #define lcode 8 /* code* */ + #define dmask 4 /* unsigned int */ + #define lmask 0 /* unsigned int */ + + /* + * typedef enum inflate_mode consts, in inflate.h + */ + #ifndef NO_GUNZIP + #define GUNZIP + #endif + + #ifdef GUNZIP + #define INFLATE_MODE_TYPE 11 /* state->mode flags enum-ed in inflate.h */ + #define INFLATE_MODE_BAD 26 + #else + #define INFLATE_MODE_TYPE 3 + #define INFLATE_MODE_BAD 17 + #endif + + + #if ! defined( USE_MMX ) && ! defined( NO_MMX ) + + #define RUN_TIME_MMX + + #define CHECK_MMX 1 + #define DO_USE_MMX 2 + #define DONT_USE_MMX 3 + + .globl inflate_fast_use_mmx + + .data + + .align 4,0 + inflate_fast_use_mmx: /* integer flag for run time control 1=check,2=mmx,3=no */ + .long CHECK_MMX + + #if defined( GAS_ELF ) + /* elf info */ + .type inflate_fast_use_mmx, at object + .size inflate_fast_use_mmx,4 + #endif + + #endif /* RUN_TIME_MMX */ + + #if defined( GAS_COFF ) + /* coff info: scl 2 = extern, type 32 = function */ + .def inflate_fast; .scl 2; .type 32; .endef + #endif + + .text + + .align 32,0x90 + inflate_fast: + pushl %edi + pushl %esi + pushl %ebp + pushl %ebx + pushf /* save eflags (strm_sp, state_sp assumes this is 32 bits) */ + subl $local_var_size, %esp + cld + + #define strm_r %esi + #define state_r %edi + + movl strm_sp(%esp), strm_r + movl state_strm(strm_r), state_r + + /* in = strm->next_in; + * out = strm->next_out; + * last = in + strm->avail_in - 11; + * beg = out - (start - strm->avail_out); + * end = out + (strm->avail_out - 257); + */ + movl avail_in_strm(strm_r), %edx + movl next_in_strm(strm_r), %eax + + addl %eax, %edx /* avail_in += next_in */ + subl $11, %edx /* avail_in -= 11 */ + + movl %eax, in(%esp) + movl %edx, last(%esp) + + movl start_sp(%esp), %ebp + movl avail_out_strm(strm_r), %ecx + movl next_out_strm(strm_r), %ebx + + subl %ecx, %ebp /* start -= avail_out */ + negl %ebp /* start = -start */ + addl %ebx, %ebp /* start += next_out */ + + subl $257, %ecx /* avail_out -= 257 */ + addl %ebx, %ecx /* avail_out += out */ + + movl %ebx, out(%esp) + movl %ebp, beg(%esp) + movl %ecx, end(%esp) + + /* wsize = state->wsize; + * write = state->write; + * window = state->window; + * hold = state->hold; + * bits = state->bits; + * lcode = state->lencode; + * dcode = state->distcode; + * lmask = ( 1 << state->lenbits ) - 1; + * dmask = ( 1 << state->distbits ) - 1; + */ + + movl lencode_state(state_r), %eax + movl distcode_state(state_r), %ecx + + movl %eax, lcode(%esp) + movl %ecx, dcode(%esp) + + movl $1, %eax + movl lenbits_state(state_r), %ecx + shll %cl, %eax + decl %eax + movl %eax, lmask(%esp) + + movl $1, %eax + movl distbits_state(state_r), %ecx + shll %cl, %eax + decl %eax + movl %eax, dmask(%esp) + + movl wsize_state(state_r), %eax + movl write_state(state_r), %ecx + movl window_state(state_r), %edx + + movl %eax, wsize(%esp) + movl %ecx, write(%esp) + movl %edx, window(%esp) + + movl hold_state(state_r), %ebp + movl bits_state(state_r), %ebx + + #undef strm_r + #undef state_r + + #define in_r %esi + #define from_r %esi + #define out_r %edi + + movl in(%esp), in_r + movl last(%esp), %ecx + cmpl in_r, %ecx + ja .L_align_long /* if in < last */ + + addl $11, %ecx /* ecx = &in[ avail_in ] */ + subl in_r, %ecx /* ecx = avail_in */ + movl $12, %eax + subl %ecx, %eax /* eax = 12 - avail_in */ + leal buf(%esp), %edi + rep movsb /* memcpy( buf, in, avail_in ) */ + movl %eax, %ecx + xorl %eax, %eax + rep stosb /* memset( &buf[ avail_in ], 0, 12 - avail_in ) */ + leal buf(%esp), in_r /* in = buf */ + movl in_r, last(%esp) /* last = in, do just one iteration */ + jmp .L_is_aligned + + /* align in_r on long boundary */ + .L_align_long: + testl $3, in_r + jz .L_is_aligned + xorl %eax, %eax + movb (in_r), %al + incl in_r + movl %ebx, %ecx + addl $8, %ebx + shll %cl, %eax + orl %eax, %ebp + jmp .L_align_long + + .L_is_aligned: + movl out(%esp), out_r + + #if defined( NO_MMX ) + jmp .L_do_loop + #endif + + #if defined( USE_MMX ) + jmp .L_init_mmx + #endif + + /*** Runtime MMX check ***/ + + #if defined( RUN_TIME_MMX ) + .L_check_mmx: + cmpl $DO_USE_MMX, inflate_fast_use_mmx + je .L_init_mmx + ja .L_do_loop /* > 2 */ + + pushl %eax + pushl %ebx + pushl %ecx + pushl %edx + pushf + movl (%esp), %eax /* copy eflags to eax */ + xorl $0x200000, (%esp) /* try toggling ID bit of eflags (bit 21) + * to see if cpu supports cpuid... + * ID bit method not supported by NexGen but + * bios may load a cpuid instruction and + * cpuid may be disabled on Cyrix 5-6x86 */ + popf + pushf + popl %edx /* copy new eflags to edx */ + xorl %eax, %edx /* test if ID bit is flipped */ + jz .L_dont_use_mmx /* not flipped if zero */ + xorl %eax, %eax + cpuid + cmpl $0x756e6547, %ebx /* check for GenuineIntel in ebx,ecx,edx */ + jne .L_dont_use_mmx + cmpl $0x6c65746e, %ecx + jne .L_dont_use_mmx + cmpl $0x49656e69, %edx + jne .L_dont_use_mmx + movl $1, %eax + cpuid /* get cpu features */ + shrl $8, %eax + andl $15, %eax + cmpl $6, %eax /* check for Pentium family, is 0xf for P4 */ + jne .L_dont_use_mmx + testl $0x800000, %edx /* test if MMX feature is set (bit 23) */ + jnz .L_use_mmx + jmp .L_dont_use_mmx + .L_use_mmx: + movl $DO_USE_MMX, inflate_fast_use_mmx + jmp .L_check_mmx_pop + .L_dont_use_mmx: + movl $DONT_USE_MMX, inflate_fast_use_mmx + .L_check_mmx_pop: + popl %edx + popl %ecx + popl %ebx + popl %eax + jmp .L_check_mmx + #endif + + + /*** Non-MMX code ***/ + + #if defined ( NO_MMX ) || defined( RUN_TIME_MMX ) + + #define hold_r %ebp + #define bits_r %bl + #define bitslong_r %ebx + + .align 32,0x90 + .L_while_test: + /* while (in < last && out < end) + */ + cmpl out_r, end(%esp) + jbe .L_break_loop /* if (out >= end) */ + + cmpl in_r, last(%esp) + jbe .L_break_loop + + .L_do_loop: + /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out + * + * do { + * if (bits < 15) { + * hold |= *((unsigned short *)in)++ << bits; + * bits += 16 + * } + * this = lcode[hold & lmask] + */ + cmpb $15, bits_r + ja .L_get_length_code /* if (15 < bits) */ + + xorl %eax, %eax + lodsw /* al = *(ushort *)in++ */ + movb bits_r, %cl /* cl = bits, needs it for shifting */ + addb $16, bits_r /* bits += 16 */ + shll %cl, %eax + orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ + + .L_get_length_code: + movl lmask(%esp), %edx /* edx = lmask */ + movl lcode(%esp), %ecx /* ecx = lcode */ + andl hold_r, %edx /* edx &= hold */ + movl (%ecx,%edx,4), %eax /* eax = lcode[hold & lmask] */ + + .L_dolen: + /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out + * + * dolen: + * bits -= this.bits; + * hold >>= this.bits + */ + movb %ah, %cl /* cl = this.bits */ + subb %ah, bits_r /* bits -= this.bits */ + shrl %cl, hold_r /* hold >>= this.bits */ + + /* check if op is a literal + * if (op == 0) { + * PUP(out) = this.val; + * } + */ + testb %al, %al + jnz .L_test_for_length_base /* if (op != 0) 45.7% */ + + shrl $16, %eax /* output this.val char */ + stosb + jmp .L_while_test + + .L_test_for_length_base: + /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out, %edx = len + * + * else if (op & 16) { + * len = this.val + * op &= 15 + * if (op) { + * if (op > bits) { + * hold |= *((unsigned short *)in)++ << bits; + * bits += 16 + * } + * len += hold & mask[op]; + * bits -= op; + * hold >>= op; + * } + */ + #define len_r %edx + movl %eax, len_r /* len = this */ + shrl $16, len_r /* len = this.val */ + movb %al, %cl + + testb $16, %al + jz .L_test_for_second_level_length /* if ((op & 16) == 0) 8% */ + andb $15, %cl /* op &= 15 */ + jz .L_save_len /* if (!op) */ + cmpb %cl, bits_r + jae .L_add_bits_to_len /* if (op <= bits) */ + + movb %cl, %ch /* stash op in ch, freeing cl */ + xorl %eax, %eax + lodsw /* al = *(ushort *)in++ */ + movb bits_r, %cl /* cl = bits, needs it for shifting */ + addb $16, bits_r /* bits += 16 */ + shll %cl, %eax + orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ + movb %ch, %cl /* move op back to ecx */ + + .L_add_bits_to_len: + movl $1, %eax + shll %cl, %eax + decl %eax + subb %cl, bits_r + andl hold_r, %eax /* eax &= hold */ + shrl %cl, hold_r + addl %eax, len_r /* len += hold & mask[op] */ + + .L_save_len: + movl len_r, len(%esp) /* save len */ + #undef len_r + + .L_decode_distance: + /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out, %edx = dist + * + * if (bits < 15) { + * hold |= *((unsigned short *)in)++ << bits; + * bits += 16 + * } + * this = dcode[hold & dmask]; + * dodist: + * bits -= this.bits; + * hold >>= this.bits; + * op = this.op; + */ + + cmpb $15, bits_r + ja .L_get_distance_code /* if (15 < bits) */ + + xorl %eax, %eax + lodsw /* al = *(ushort *)in++ */ + movb bits_r, %cl /* cl = bits, needs it for shifting */ + addb $16, bits_r /* bits += 16 */ + shll %cl, %eax + orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ + + .L_get_distance_code: + movl dmask(%esp), %edx /* edx = dmask */ + movl dcode(%esp), %ecx /* ecx = dcode */ + andl hold_r, %edx /* edx &= hold */ + movl (%ecx,%edx,4), %eax /* eax = dcode[hold & dmask] */ + + #define dist_r %edx + .L_dodist: + movl %eax, dist_r /* dist = this */ + shrl $16, dist_r /* dist = this.val */ + movb %ah, %cl + subb %ah, bits_r /* bits -= this.bits */ + shrl %cl, hold_r /* hold >>= this.bits */ + + /* if (op & 16) { + * dist = this.val + * op &= 15 + * if (op > bits) { + * hold |= *((unsigned short *)in)++ << bits; + * bits += 16 + * } + * dist += hold & mask[op]; + * bits -= op; + * hold >>= op; + */ + movb %al, %cl /* cl = this.op */ + + testb $16, %al /* if ((op & 16) == 0) */ + jz .L_test_for_second_level_dist + andb $15, %cl /* op &= 15 */ + jz .L_check_dist_one + cmpb %cl, bits_r + jae .L_add_bits_to_dist /* if (op <= bits) 97.6% */ + + movb %cl, %ch /* stash op in ch, freeing cl */ + xorl %eax, %eax + lodsw /* al = *(ushort *)in++ */ + movb bits_r, %cl /* cl = bits, needs it for shifting */ + addb $16, bits_r /* bits += 16 */ + shll %cl, %eax + orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ + movb %ch, %cl /* move op back to ecx */ + + .L_add_bits_to_dist: + movl $1, %eax + shll %cl, %eax + decl %eax /* (1 << op) - 1 */ + subb %cl, bits_r + andl hold_r, %eax /* eax &= hold */ + shrl %cl, hold_r + addl %eax, dist_r /* dist += hold & ((1 << op) - 1) */ + jmp .L_check_window + + .L_check_window: + /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist + * %ecx = nbytes + * + * nbytes = out - beg; + * if (dist <= nbytes) { + * from = out - dist; + * do { + * PUP(out) = PUP(from); + * } while (--len > 0) { + * } + */ + + movl in_r, in(%esp) /* save in so from can use it's reg */ + movl out_r, %eax + subl beg(%esp), %eax /* nbytes = out - beg */ + + cmpl dist_r, %eax + jb .L_clip_window /* if (dist > nbytes) 4.2% */ + + movl len(%esp), %ecx + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + + subl $3, %ecx + movb (from_r), %al + movb %al, (out_r) + movb 1(from_r), %al + movb 2(from_r), %dl + addl $3, from_r + movb %al, 1(out_r) + movb %dl, 2(out_r) + addl $3, out_r + rep movsb + + movl in(%esp), in_r /* move in back to %esi, toss from */ + jmp .L_while_test + + .align 16,0x90 + .L_check_dist_one: + cmpl $1, dist_r + jne .L_check_window + cmpl out_r, beg(%esp) + je .L_check_window + + decl out_r + movl len(%esp), %ecx + movb (out_r), %al + subl $3, %ecx + + movb %al, 1(out_r) + movb %al, 2(out_r) + movb %al, 3(out_r) + addl $4, out_r + rep stosb + + jmp .L_while_test + + .align 16,0x90 + .L_test_for_second_level_length: + /* else if ((op & 64) == 0) { + * this = lcode[this.val + (hold & mask[op])]; + * } + */ + testb $64, %al + jnz .L_test_for_end_of_block /* if ((op & 64) != 0) */ + + movl $1, %eax + shll %cl, %eax + decl %eax + andl hold_r, %eax /* eax &= hold */ + addl %edx, %eax /* eax += this.val */ + movl lcode(%esp), %edx /* edx = lcode */ + movl (%edx,%eax,4), %eax /* eax = lcode[val + (hold&mask[op])] */ + jmp .L_dolen + + .align 16,0x90 + .L_test_for_second_level_dist: + /* else if ((op & 64) == 0) { + * this = dcode[this.val + (hold & mask[op])]; + * } + */ + testb $64, %al + jnz .L_invalid_distance_code /* if ((op & 64) != 0) */ + + movl $1, %eax + shll %cl, %eax + decl %eax + andl hold_r, %eax /* eax &= hold */ + addl %edx, %eax /* eax += this.val */ + movl dcode(%esp), %edx /* edx = dcode */ + movl (%edx,%eax,4), %eax /* eax = dcode[val + (hold&mask[op])] */ + jmp .L_dodist + + .align 16,0x90 + .L_clip_window: + /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist + * %ecx = nbytes + * + * else { + * if (dist > wsize) { + * invalid distance + * } + * from = window; + * nbytes = dist - nbytes; + * if (write == 0) { + * from += wsize - nbytes; + */ + #define nbytes_r %ecx + movl %eax, nbytes_r + movl wsize(%esp), %eax /* prepare for dist compare */ + negl nbytes_r /* nbytes = -nbytes */ + movl window(%esp), from_r /* from = window */ + + cmpl dist_r, %eax + jb .L_invalid_distance_too_far /* if (dist > wsize) */ + + addl dist_r, nbytes_r /* nbytes = dist - nbytes */ + cmpl $0, write(%esp) + jne .L_wrap_around_window /* if (write != 0) */ + + subl nbytes_r, %eax + addl %eax, from_r /* from += wsize - nbytes */ + + /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist + * %ecx = nbytes, %eax = len + * + * if (nbytes < len) { + * len -= nbytes; + * do { + * PUP(out) = PUP(from); + * } while (--nbytes); + * from = out - dist; + * } + * } + */ + #define len_r %eax + movl len(%esp), len_r + cmpl nbytes_r, len_r + jbe .L_do_copy1 /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + jmp .L_do_copy1 + + cmpl nbytes_r, len_r + jbe .L_do_copy1 /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + jmp .L_do_copy1 + + .L_wrap_around_window: + /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist + * %ecx = nbytes, %eax = write, %eax = len + * + * else if (write < nbytes) { + * from += wsize + write - nbytes; + * nbytes -= write; + * if (nbytes < len) { + * len -= nbytes; + * do { + * PUP(out) = PUP(from); + * } while (--nbytes); + * from = window; + * nbytes = write; + * if (nbytes < len) { + * len -= nbytes; + * do { + * PUP(out) = PUP(from); + * } while(--nbytes); + * from = out - dist; + * } + * } + * } + */ + #define write_r %eax + movl write(%esp), write_r + cmpl write_r, nbytes_r + jbe .L_contiguous_in_window /* if (write >= nbytes) */ + + addl wsize(%esp), from_r + addl write_r, from_r + subl nbytes_r, from_r /* from += wsize + write - nbytes */ + subl write_r, nbytes_r /* nbytes -= write */ + #undef write_r + + movl len(%esp), len_r + cmpl nbytes_r, len_r + jbe .L_do_copy1 /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl window(%esp), from_r /* from = window */ + movl write(%esp), nbytes_r /* nbytes = write */ + cmpl nbytes_r, len_r + jbe .L_do_copy1 /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + jmp .L_do_copy1 + + .L_contiguous_in_window: + /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist + * %ecx = nbytes, %eax = write, %eax = len + * + * else { + * from += write - nbytes; + * if (nbytes < len) { + * len -= nbytes; + * do { + * PUP(out) = PUP(from); + * } while (--nbytes); + * from = out - dist; + * } + * } + */ + #define write_r %eax + addl write_r, from_r + subl nbytes_r, from_r /* from += write - nbytes */ + #undef write_r + + movl len(%esp), len_r + cmpl nbytes_r, len_r + jbe .L_do_copy1 /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + + .L_do_copy1: + /* regs: %esi = from, %esi = in, %ebp = hold, %bl = bits, %edi = out + * %eax = len + * + * while (len > 0) { + * PUP(out) = PUP(from); + * len--; + * } + * } + * } while (in < last && out < end); + */ + #undef nbytes_r + #define in_r %esi + movl len_r, %ecx + rep movsb + + movl in(%esp), in_r /* move in back to %esi, toss from */ + jmp .L_while_test + + #undef len_r + #undef dist_r + + #endif /* NO_MMX || RUN_TIME_MMX */ + + + /*** MMX code ***/ + + #if defined( USE_MMX ) || defined( RUN_TIME_MMX ) + + .align 32,0x90 + .L_init_mmx: + emms + + #undef bits_r + #undef bitslong_r + #define bitslong_r %ebp + #define hold_mm %mm0 + movd %ebp, hold_mm + movl %ebx, bitslong_r + + #define used_mm %mm1 + #define dmask2_mm %mm2 + #define lmask2_mm %mm3 + #define lmask_mm %mm4 + #define dmask_mm %mm5 + #define tmp_mm %mm6 + + movd lmask(%esp), lmask_mm + movq lmask_mm, lmask2_mm + movd dmask(%esp), dmask_mm + movq dmask_mm, dmask2_mm + pxor used_mm, used_mm + movl lcode(%esp), %ebx /* ebx = lcode */ + jmp .L_do_loop_mmx + + .align 32,0x90 + .L_while_test_mmx: + /* while (in < last && out < end) + */ + cmpl out_r, end(%esp) + jbe .L_break_loop /* if (out >= end) */ + + cmpl in_r, last(%esp) + jbe .L_break_loop + + .L_do_loop_mmx: + psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ + + cmpl $32, bitslong_r + ja .L_get_length_code_mmx /* if (32 < bits) */ + + movd bitslong_r, tmp_mm + movd (in_r), %mm7 + addl $4, in_r + psllq tmp_mm, %mm7 + addl $32, bitslong_r + por %mm7, hold_mm /* hold_mm |= *((uint *)in)++ << bits */ + + .L_get_length_code_mmx: + pand hold_mm, lmask_mm + movd lmask_mm, %eax + movq lmask2_mm, lmask_mm + movl (%ebx,%eax,4), %eax /* eax = lcode[hold & lmask] */ + + .L_dolen_mmx: + movzbl %ah, %ecx /* ecx = this.bits */ + movd %ecx, used_mm + subl %ecx, bitslong_r /* bits -= this.bits */ + + testb %al, %al + jnz .L_test_for_length_base_mmx /* if (op != 0) 45.7% */ + + shrl $16, %eax /* output this.val char */ + stosb + jmp .L_while_test_mmx + + .L_test_for_length_base_mmx: + #define len_r %edx + movl %eax, len_r /* len = this */ + shrl $16, len_r /* len = this.val */ + + testb $16, %al + jz .L_test_for_second_level_length_mmx /* if ((op & 16) == 0) 8% */ + andl $15, %eax /* op &= 15 */ + jz .L_decode_distance_mmx /* if (!op) */ + + psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ + movd %eax, used_mm + movd hold_mm, %ecx + subl %eax, bitslong_r + andl .L_mask(,%eax,4), %ecx + addl %ecx, len_r /* len += hold & mask[op] */ + + .L_decode_distance_mmx: + psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ + + cmpl $32, bitslong_r + ja .L_get_dist_code_mmx /* if (32 < bits) */ + + movd bitslong_r, tmp_mm + movd (in_r), %mm7 + addl $4, in_r + psllq tmp_mm, %mm7 + addl $32, bitslong_r + por %mm7, hold_mm /* hold_mm |= *((uint *)in)++ << bits */ + + .L_get_dist_code_mmx: + movl dcode(%esp), %ebx /* ebx = dcode */ + pand hold_mm, dmask_mm + movd dmask_mm, %eax + movq dmask2_mm, dmask_mm + movl (%ebx,%eax,4), %eax /* eax = dcode[hold & lmask] */ + + .L_dodist_mmx: + #define dist_r %ebx + movzbl %ah, %ecx /* ecx = this.bits */ + movl %eax, dist_r + shrl $16, dist_r /* dist = this.val */ + subl %ecx, bitslong_r /* bits -= this.bits */ + movd %ecx, used_mm + + testb $16, %al /* if ((op & 16) == 0) */ + jz .L_test_for_second_level_dist_mmx + andl $15, %eax /* op &= 15 */ + jz .L_check_dist_one_mmx + + .L_add_bits_to_dist_mmx: + psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ + movd %eax, used_mm /* save bit length of current op */ + movd hold_mm, %ecx /* get the next bits on input stream */ + subl %eax, bitslong_r /* bits -= op bits */ + andl .L_mask(,%eax,4), %ecx /* ecx = hold & mask[op] */ + addl %ecx, dist_r /* dist += hold & mask[op] */ + + .L_check_window_mmx: + movl in_r, in(%esp) /* save in so from can use it's reg */ + movl out_r, %eax + subl beg(%esp), %eax /* nbytes = out - beg */ + + cmpl dist_r, %eax + jb .L_clip_window_mmx /* if (dist > nbytes) 4.2% */ + + movl len_r, %ecx + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + + subl $3, %ecx + movb (from_r), %al + movb %al, (out_r) + movb 1(from_r), %al + movb 2(from_r), %dl + addl $3, from_r + movb %al, 1(out_r) + movb %dl, 2(out_r) + addl $3, out_r + rep movsb + + movl in(%esp), in_r /* move in back to %esi, toss from */ + movl lcode(%esp), %ebx /* move lcode back to %ebx, toss dist */ + jmp .L_while_test_mmx + + .align 16,0x90 + .L_check_dist_one_mmx: + cmpl $1, dist_r + jne .L_check_window_mmx + cmpl out_r, beg(%esp) + je .L_check_window_mmx + + decl out_r + movl len_r, %ecx + movb (out_r), %al + subl $3, %ecx + + movb %al, 1(out_r) + movb %al, 2(out_r) + movb %al, 3(out_r) + addl $4, out_r + rep stosb + + movl lcode(%esp), %ebx /* move lcode back to %ebx, toss dist */ + jmp .L_while_test_mmx + + .align 16,0x90 + .L_test_for_second_level_length_mmx: + testb $64, %al + jnz .L_test_for_end_of_block /* if ((op & 64) != 0) */ + + andl $15, %eax + psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ + movd hold_mm, %ecx + andl .L_mask(,%eax,4), %ecx + addl len_r, %ecx + movl (%ebx,%ecx,4), %eax /* eax = lcode[hold & lmask] */ + jmp .L_dolen_mmx + + .align 16,0x90 + .L_test_for_second_level_dist_mmx: + testb $64, %al + jnz .L_invalid_distance_code /* if ((op & 64) != 0) */ + + andl $15, %eax + psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ + movd hold_mm, %ecx + andl .L_mask(,%eax,4), %ecx + movl dcode(%esp), %eax /* ecx = dcode */ + addl dist_r, %ecx + movl (%eax,%ecx,4), %eax /* eax = lcode[hold & lmask] */ + jmp .L_dodist_mmx + + .align 16,0x90 + .L_clip_window_mmx: + #define nbytes_r %ecx + movl %eax, nbytes_r + movl wsize(%esp), %eax /* prepare for dist compare */ + negl nbytes_r /* nbytes = -nbytes */ + movl window(%esp), from_r /* from = window */ + + cmpl dist_r, %eax + jb .L_invalid_distance_too_far /* if (dist > wsize) */ + + addl dist_r, nbytes_r /* nbytes = dist - nbytes */ + cmpl $0, write(%esp) + jne .L_wrap_around_window_mmx /* if (write != 0) */ + + subl nbytes_r, %eax + addl %eax, from_r /* from += wsize - nbytes */ + + cmpl nbytes_r, len_r + jbe .L_do_copy1_mmx /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + jmp .L_do_copy1_mmx + + cmpl nbytes_r, len_r + jbe .L_do_copy1_mmx /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + jmp .L_do_copy1_mmx + + .L_wrap_around_window_mmx: + #define write_r %eax + movl write(%esp), write_r + cmpl write_r, nbytes_r + jbe .L_contiguous_in_window_mmx /* if (write >= nbytes) */ + + addl wsize(%esp), from_r + addl write_r, from_r + subl nbytes_r, from_r /* from += wsize + write - nbytes */ + subl write_r, nbytes_r /* nbytes -= write */ + #undef write_r + + cmpl nbytes_r, len_r + jbe .L_do_copy1_mmx /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl window(%esp), from_r /* from = window */ + movl write(%esp), nbytes_r /* nbytes = write */ + cmpl nbytes_r, len_r + jbe .L_do_copy1_mmx /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + jmp .L_do_copy1_mmx + + .L_contiguous_in_window_mmx: + #define write_r %eax + addl write_r, from_r + subl nbytes_r, from_r /* from += write - nbytes */ + #undef write_r + + cmpl nbytes_r, len_r + jbe .L_do_copy1_mmx /* if (nbytes >= len) */ + + subl nbytes_r, len_r /* len -= nbytes */ + rep movsb + movl out_r, from_r + subl dist_r, from_r /* from = out - dist */ + + .L_do_copy1_mmx: + #undef nbytes_r + #define in_r %esi + movl len_r, %ecx + rep movsb + + movl in(%esp), in_r /* move in back to %esi, toss from */ + movl lcode(%esp), %ebx /* move lcode back to %ebx, toss dist */ + jmp .L_while_test_mmx + + #undef hold_r + #undef bitslong_r + + #endif /* USE_MMX || RUN_TIME_MMX */ + + + /*** USE_MMX, NO_MMX, and RUNTIME_MMX from here on ***/ + + .L_invalid_distance_code: + /* else { + * strm->msg = "invalid distance code"; + * state->mode = BAD; + * } + */ + movl $.L_invalid_distance_code_msg, %ecx + movl $INFLATE_MODE_BAD, %edx + jmp .L_update_stream_state + + .L_test_for_end_of_block: + /* else if (op & 32) { + * state->mode = TYPE; + * break; + * } + */ + testb $32, %al + jz .L_invalid_literal_length_code /* if ((op & 32) == 0) */ + + movl $0, %ecx + movl $INFLATE_MODE_TYPE, %edx + jmp .L_update_stream_state + + .L_invalid_literal_length_code: + /* else { + * strm->msg = "invalid literal/length code"; + * state->mode = BAD; + * } + */ + movl $.L_invalid_literal_length_code_msg, %ecx + movl $INFLATE_MODE_BAD, %edx + jmp .L_update_stream_state + + .L_invalid_distance_too_far: + /* strm->msg = "invalid distance too far back"; + * state->mode = BAD; + */ + movl in(%esp), in_r /* from_r has in's reg, put in back */ + movl $.L_invalid_distance_too_far_msg, %ecx + movl $INFLATE_MODE_BAD, %edx + jmp .L_update_stream_state + + .L_update_stream_state: + /* set strm->msg = %ecx, strm->state->mode = %edx */ + movl strm_sp(%esp), %eax + testl %ecx, %ecx /* if (msg != NULL) */ + jz .L_skip_msg + movl %ecx, msg_strm(%eax) /* strm->msg = msg */ + .L_skip_msg: + movl state_strm(%eax), %eax /* state = strm->state */ + movl %edx, mode_state(%eax) /* state->mode = edx (BAD | TYPE) */ + jmp .L_break_loop + + .align 32,0x90 + .L_break_loop: + + /* + * Regs: + * + * bits = %ebp when mmx, and in %ebx when non-mmx + * hold = %hold_mm when mmx, and in %ebp when non-mmx + * in = %esi + * out = %edi + */ + + #if defined( USE_MMX ) || defined( RUN_TIME_MMX ) + + #if defined( RUN_TIME_MMX ) + + cmpl $DO_USE_MMX, inflate_fast_use_mmx + jne .L_update_next_in + + #endif /* RUN_TIME_MMX */ + + movl %ebp, %ebx + + .L_update_next_in: + + #endif + + #define strm_r %eax + #define state_r %edx + + /* len = bits >> 3; + * in -= len; + * bits -= len << 3; + * hold &= (1U << bits) - 1; + * state->hold = hold; + * state->bits = bits; + * strm->next_in = in; + * strm->next_out = out; + */ + movl strm_sp(%esp), strm_r + movl %ebx, %ecx + movl state_strm(strm_r), state_r + shrl $3, %ecx + subl %ecx, in_r + shll $3, %ecx + subl %ecx, %ebx + movl out_r, next_out_strm(strm_r) + movl %ebx, bits_state(state_r) + movl %ebx, %ecx + + leal buf(%esp), %ebx + cmpl %ebx, last(%esp) + jne .L_buf_not_used /* if buf != last */ + + subl %ebx, in_r /* in -= buf */ + movl next_in_strm(strm_r), %ebx + movl %ebx, last(%esp) /* last = strm->next_in */ + addl %ebx, in_r /* in += strm->next_in */ + movl avail_in_strm(strm_r), %ebx + subl $11, %ebx + addl %ebx, last(%esp) /* last = &strm->next_in[ avail_in - 11 ] */ + + .L_buf_not_used: + movl in_r, next_in_strm(strm_r) + + movl $1, %ebx + shll %cl, %ebx + decl %ebx + + #if defined( USE_MMX ) || defined( RUN_TIME_MMX ) + + #if defined( RUN_TIME_MMX ) + + cmpl $DO_USE_MMX, inflate_fast_use_mmx + jne .L_update_hold + + #endif /* RUN_TIME_MMX */ + + psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ + movd hold_mm, %ebp + + emms + + .L_update_hold: + + #endif /* USE_MMX || RUN_TIME_MMX */ + + andl %ebx, %ebp + movl %ebp, hold_state(state_r) + + #define last_r %ebx + + /* strm->avail_in = in < last ? 11 + (last - in) : 11 - (in - last) */ + movl last(%esp), last_r + cmpl in_r, last_r + jbe .L_last_is_smaller /* if (in >= last) */ + + subl in_r, last_r /* last -= in */ + addl $11, last_r /* last += 11 */ + movl last_r, avail_in_strm(strm_r) + jmp .L_fixup_out + .L_last_is_smaller: + subl last_r, in_r /* in -= last */ + negl in_r /* in = -in */ + addl $11, in_r /* in += 11 */ + movl in_r, avail_in_strm(strm_r) + + #undef last_r + #define end_r %ebx + + .L_fixup_out: + /* strm->avail_out = out < end ? 257 + (end - out) : 257 - (out - end)*/ + movl end(%esp), end_r + cmpl out_r, end_r + jbe .L_end_is_smaller /* if (out >= end) */ + + subl out_r, end_r /* end -= out */ + addl $257, end_r /* end += 257 */ + movl end_r, avail_out_strm(strm_r) + jmp .L_done + .L_end_is_smaller: + subl end_r, out_r /* out -= end */ + negl out_r /* out = -out */ + addl $257, out_r /* out += 257 */ + movl out_r, avail_out_strm(strm_r) + + #undef end_r + #undef strm_r + #undef state_r + + .L_done: + addl $local_var_size, %esp + popf + popl %ebx + popl %ebp + popl %esi + popl %edi + ret + + #if defined( GAS_ELF ) + /* elf info */ + .type inflate_fast, at function + .size inflate_fast,.-inflate_fast + #endif From criswell at cs.uiuc.edu Fri Feb 6 10:42:05 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:42:05 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/iostream/test.cpp zfstream.cpp zfstream.h Message-ID: <200402061636.KAA15514@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/iostream: test.cpp added (r1.1) zfstream.cpp added (r1.1) zfstream.h added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+481 -0) Index: llvm/runtime/zlib/contrib/iostream/test.cpp diff -c /dev/null llvm/runtime/zlib/contrib/iostream/test.cpp:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/iostream/test.cpp Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,24 ---- + + #include "zfstream.h" + + int main() { + + // Construct a stream object with this filebuffer. Anything sent + // to this stream will go to standard out. + gzofstream os( 1, ios::out ); + + // This text is getting compressed and sent to stdout. + // To prove this, run 'test | zcat'. + os << "Hello, Mommy" << endl; + + os << setcompressionlevel( Z_NO_COMPRESSION ); + os << "hello, hello, hi, ho!" << endl; + + setcompressionlevel( os, Z_DEFAULT_COMPRESSION ) + << "I'm compressing again" << endl; + + os.close(); + + return 0; + + } Index: llvm/runtime/zlib/contrib/iostream/zfstream.cpp diff -c /dev/null llvm/runtime/zlib/contrib/iostream/zfstream.cpp:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/iostream/zfstream.cpp Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,329 ---- + + #include "zfstream.h" + + gzfilebuf::gzfilebuf() : + file(NULL), + mode(0), + own_file_descriptor(0) + { } + + gzfilebuf::~gzfilebuf() { + + sync(); + if ( own_file_descriptor ) + close(); + + } + + gzfilebuf *gzfilebuf::open( const char *name, + int io_mode ) { + + if ( is_open() ) + return NULL; + + char char_mode[10]; + char *p = char_mode; + + if ( io_mode & ios::in ) { + mode = ios::in; + *p++ = 'r'; + } else if ( io_mode & ios::app ) { + mode = ios::app; + *p++ = 'a'; + } else { + mode = ios::out; + *p++ = 'w'; + } + + if ( io_mode & ios::binary ) { + mode |= ios::binary; + *p++ = 'b'; + } + + // Hard code the compression level + if ( io_mode & (ios::out|ios::app )) { + *p++ = '9'; + } + + // Put the end-of-string indicator + *p = '\0'; + + if ( (file = gzopen(name, char_mode)) == NULL ) + return NULL; + + own_file_descriptor = 1; + + return this; + + } + + gzfilebuf *gzfilebuf::attach( int file_descriptor, + int io_mode ) { + + if ( is_open() ) + return NULL; + + char char_mode[10]; + char *p = char_mode; + + if ( io_mode & ios::in ) { + mode = ios::in; + *p++ = 'r'; + } else if ( io_mode & ios::app ) { + mode = ios::app; + *p++ = 'a'; + } else { + mode = ios::out; + *p++ = 'w'; + } + + if ( io_mode & ios::binary ) { + mode |= ios::binary; + *p++ = 'b'; + } + + // Hard code the compression level + if ( io_mode & (ios::out|ios::app )) { + *p++ = '9'; + } + + // Put the end-of-string indicator + *p = '\0'; + + if ( (file = gzdopen(file_descriptor, char_mode)) == NULL ) + return NULL; + + own_file_descriptor = 0; + + return this; + + } + + gzfilebuf *gzfilebuf::close() { + + if ( is_open() ) { + + sync(); + gzclose( file ); + file = NULL; + + } + + return this; + + } + + int gzfilebuf::setcompressionlevel( int comp_level ) { + + return gzsetparams(file, comp_level, -2); + + } + + int gzfilebuf::setcompressionstrategy( int comp_strategy ) { + + return gzsetparams(file, -2, comp_strategy); + + } + + + streampos gzfilebuf::seekoff( streamoff off, ios::seek_dir dir, int which ) { + + return streampos(EOF); + + } + + int gzfilebuf::underflow() { + + // If the file hasn't been opened for reading, error. + if ( !is_open() || !(mode & ios::in) ) + return EOF; + + // if a buffer doesn't exists, allocate one. + if ( !base() ) { + + if ( (allocate()) == EOF ) + return EOF; + setp(0,0); + + } else { + + if ( in_avail() ) + return (unsigned char) *gptr(); + + if ( out_waiting() ) { + if ( flushbuf() == EOF ) + return EOF; + } + + } + + // Attempt to fill the buffer. + + int result = fillbuf(); + if ( result == EOF ) { + // disable get area + setg(0,0,0); + return EOF; + } + + return (unsigned char) *gptr(); + + } + + int gzfilebuf::overflow( int c ) { + + if ( !is_open() || !(mode & ios::out) ) + return EOF; + + if ( !base() ) { + if ( allocate() == EOF ) + return EOF; + setg(0,0,0); + } else { + if (in_avail()) { + return EOF; + } + if (out_waiting()) { + if (flushbuf() == EOF) + return EOF; + } + } + + int bl = blen(); + setp( base(), base() + bl); + + if ( c != EOF ) { + + *pptr() = c; + pbump(1); + + } + + return 0; + + } + + int gzfilebuf::sync() { + + if ( !is_open() ) + return EOF; + + if ( out_waiting() ) + return flushbuf(); + + return 0; + + } + + int gzfilebuf::flushbuf() { + + int n; + char *q; + + q = pbase(); + n = pptr() - q; + + if ( gzwrite( file, q, n) < n ) + return EOF; + + setp(0,0); + + return 0; + + } + + int gzfilebuf::fillbuf() { + + int required; + char *p; + + p = base(); + + required = blen(); + + int t = gzread( file, p, required ); + + if ( t <= 0) return EOF; + + setg( base(), base(), base()+t); + + return t; + + } + + gzfilestream_common::gzfilestream_common() : + ios( gzfilestream_common::rdbuf() ) + { } + + gzfilestream_common::~gzfilestream_common() + { } + + void gzfilestream_common::attach( int fd, int io_mode ) { + + if ( !buffer.attach( fd, io_mode) ) + clear( ios::failbit | ios::badbit ); + else + clear(); + + } + + void gzfilestream_common::open( const char *name, int io_mode ) { + + if ( !buffer.open( name, io_mode ) ) + clear( ios::failbit | ios::badbit ); + else + clear(); + + } + + void gzfilestream_common::close() { + + if ( !buffer.close() ) + clear( ios::failbit | ios::badbit ); + + } + + gzfilebuf *gzfilestream_common::rdbuf() + { + return &buffer; + } + + gzifstream::gzifstream() : + ios( gzfilestream_common::rdbuf() ) + { + clear( ios::badbit ); + } + + gzifstream::gzifstream( const char *name, int io_mode ) : + ios( gzfilestream_common::rdbuf() ) + { + gzfilestream_common::open( name, io_mode ); + } + + gzifstream::gzifstream( int fd, int io_mode ) : + ios( gzfilestream_common::rdbuf() ) + { + gzfilestream_common::attach( fd, io_mode ); + } + + gzifstream::~gzifstream() { } + + gzofstream::gzofstream() : + ios( gzfilestream_common::rdbuf() ) + { + clear( ios::badbit ); + } + + gzofstream::gzofstream( const char *name, int io_mode ) : + ios( gzfilestream_common::rdbuf() ) + { + gzfilestream_common::open( name, io_mode ); + } + + gzofstream::gzofstream( int fd, int io_mode ) : + ios( gzfilestream_common::rdbuf() ) + { + gzfilestream_common::attach( fd, io_mode ); + } + + gzofstream::~gzofstream() { } Index: llvm/runtime/zlib/contrib/iostream/zfstream.h diff -c /dev/null llvm/runtime/zlib/contrib/iostream/zfstream.h:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/iostream/zfstream.h Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,128 ---- + + #ifndef zfstream_h + #define zfstream_h + + #include + #include "zlib.h" + + class gzfilebuf : public streambuf { + + public: + + gzfilebuf( ); + virtual ~gzfilebuf(); + + gzfilebuf *open( const char *name, int io_mode ); + gzfilebuf *attach( int file_descriptor, int io_mode ); + gzfilebuf *close(); + + int setcompressionlevel( int comp_level ); + int setcompressionstrategy( int comp_strategy ); + + inline int is_open() const { return (file !=NULL); } + + virtual streampos seekoff( streamoff, ios::seek_dir, int ); + + virtual int sync(); + + protected: + + virtual int underflow(); + virtual int overflow( int = EOF ); + + private: + + gzFile file; + short mode; + short own_file_descriptor; + + int flushbuf(); + int fillbuf(); + + }; + + class gzfilestream_common : virtual public ios { + + friend class gzifstream; + friend class gzofstream; + friend gzofstream &setcompressionlevel( gzofstream &, int ); + friend gzofstream &setcompressionstrategy( gzofstream &, int ); + + public: + virtual ~gzfilestream_common(); + + void attach( int fd, int io_mode ); + void open( const char *name, int io_mode ); + void close(); + + protected: + gzfilestream_common(); + + private: + gzfilebuf *rdbuf(); + + gzfilebuf buffer; + + }; + + class gzifstream : public gzfilestream_common, public istream { + + public: + + gzifstream(); + gzifstream( const char *name, int io_mode = ios::in ); + gzifstream( int fd, int io_mode = ios::in ); + + virtual ~gzifstream(); + + }; + + class gzofstream : public gzfilestream_common, public ostream { + + public: + + gzofstream(); + gzofstream( const char *name, int io_mode = ios::out ); + gzofstream( int fd, int io_mode = ios::out ); + + virtual ~gzofstream(); + + }; + + template class gzomanip { + friend gzofstream &operator<<(gzofstream &, const gzomanip &); + public: + gzomanip(gzofstream &(*f)(gzofstream &, T), T v) : func(f), val(v) { } + private: + gzofstream &(*func)(gzofstream &, T); + T val; + }; + + template gzofstream &operator<<(gzofstream &s, const gzomanip &m) + { + return (*m.func)(s, m.val); + } + + inline gzofstream &setcompressionlevel( gzofstream &s, int l ) + { + (s.rdbuf())->setcompressionlevel(l); + return s; + } + + inline gzofstream &setcompressionstrategy( gzofstream &s, int l ) + { + (s.rdbuf())->setcompressionstrategy(l); + return s; + } + + inline gzomanip setcompressionlevel(int l) + { + return gzomanip(&setcompressionlevel,l); + } + + inline gzomanip setcompressionstrategy(int l) + { + return gzomanip(&setcompressionstrategy,l); + } + + #endif From criswell at cs.uiuc.edu Fri Feb 6 10:42:25 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:42:25 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/delphi/ZLib.pas ZLibConst.pas readme.txt zlibd32.mak Message-ID: <200402061636.KAA15469@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/delphi: ZLib.pas added (r1.1) ZLibConst.pas added (r1.1) readme.txt added (r1.1) zlibd32.mak added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+737 -0) Index: llvm/runtime/zlib/contrib/delphi/ZLib.pas diff -c /dev/null llvm/runtime/zlib/contrib/delphi/ZLib.pas:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/delphi/ZLib.pas Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,557 ---- + {*******************************************************} + { } + { Borland Delphi Supplemental Components } + { ZLIB Data Compression Interface Unit } + { } + { Copyright (c) 1997,99 Borland Corporation } + { } + {*******************************************************} + + { Updated for zlib 1.2.x by Cosmin Truta } + + unit ZLib; + + interface + + uses SysUtils, Classes; + + type + TAlloc = function (AppData: Pointer; Items, Size: Integer): Pointer; cdecl; + TFree = procedure (AppData, Block: Pointer); cdecl; + + // Internal structure. Ignore. + TZStreamRec = packed record + next_in: PChar; // next input byte + avail_in: Integer; // number of bytes available at next_in + total_in: Longint; // total nb of input bytes read so far + + next_out: PChar; // next output byte should be put here + avail_out: Integer; // remaining free space at next_out + total_out: Longint; // total nb of bytes output so far + + msg: PChar; // last error message, NULL if no error + internal: Pointer; // not visible by applications + + zalloc: TAlloc; // used to allocate the internal state + zfree: TFree; // used to free the internal state + AppData: Pointer; // private data object passed to zalloc and zfree + + data_type: Integer; // best guess about the data type: ascii or binary + adler: Longint; // adler32 value of the uncompressed data + reserved: Longint; // reserved for future use + end; + + // Abstract ancestor class + TCustomZlibStream = class(TStream) + private + FStrm: TStream; + FStrmPos: Integer; + FOnProgress: TNotifyEvent; + FZRec: TZStreamRec; + FBuffer: array [Word] of Char; + protected + procedure Progress(Sender: TObject); dynamic; + property OnProgress: TNotifyEvent read FOnProgress write FOnProgress; + constructor Create(Strm: TStream); + end; + + { TCompressionStream compresses data on the fly as data is written to it, and + stores the compressed data to another stream. + + TCompressionStream is write-only and strictly sequential. Reading from the + stream will raise an exception. Using Seek to move the stream pointer + will raise an exception. + + Output data is cached internally, written to the output stream only when + the internal output buffer is full. All pending output data is flushed + when the stream is destroyed. + + The Position property returns the number of uncompressed bytes of + data that have been written to the stream so far. + + CompressionRate returns the on-the-fly percentage by which the original + data has been compressed: (1 - (CompressedBytes / UncompressedBytes)) * 100 + If raw data size = 100 and compressed data size = 25, the CompressionRate + is 75% + + The OnProgress event is called each time the output buffer is filled and + written to the output stream. This is useful for updating a progress + indicator when you are writing a large chunk of data to the compression + stream in a single call.} + + + TCompressionLevel = (clNone, clFastest, clDefault, clMax); + + TCompressionStream = class(TCustomZlibStream) + private + function GetCompressionRate: Single; + public + constructor Create(CompressionLevel: TCompressionLevel; Dest: TStream); + destructor Destroy; override; + function Read(var Buffer; Count: Longint): Longint; override; + function Write(const Buffer; Count: Longint): Longint; override; + function Seek(Offset: Longint; Origin: Word): Longint; override; + property CompressionRate: Single read GetCompressionRate; + property OnProgress; + end; + + { TDecompressionStream decompresses data on the fly as data is read from it. + + Compressed data comes from a separate source stream. TDecompressionStream + is read-only and unidirectional; you can seek forward in the stream, but not + backwards. The special case of setting the stream position to zero is + allowed. Seeking forward decompresses data until the requested position in + the uncompressed data has been reached. Seeking backwards, seeking relative + to the end of the stream, requesting the size of the stream, and writing to + the stream will raise an exception. + + The Position property returns the number of bytes of uncompressed data that + have been read from the stream so far. + + The OnProgress event is called each time the internal input buffer of + compressed data is exhausted and the next block is read from the input stream. + This is useful for updating a progress indicator when you are reading a + large chunk of data from the decompression stream in a single call.} + + TDecompressionStream = class(TCustomZlibStream) + public + constructor Create(Source: TStream); + destructor Destroy; override; + function Read(var Buffer; Count: Longint): Longint; override; + function Write(const Buffer; Count: Longint): Longint; override; + function Seek(Offset: Longint; Origin: Word): Longint; override; + property OnProgress; + end; + + + + { CompressBuf compresses data, buffer to buffer, in one call. + In: InBuf = ptr to compressed data + InBytes = number of bytes in InBuf + Out: OutBuf = ptr to newly allocated buffer containing decompressed data + OutBytes = number of bytes in OutBuf } + procedure CompressBuf(const InBuf: Pointer; InBytes: Integer; + out OutBuf: Pointer; out OutBytes: Integer); + + + { DecompressBuf decompresses data, buffer to buffer, in one call. + In: InBuf = ptr to compressed data + InBytes = number of bytes in InBuf + OutEstimate = zero, or est. size of the decompressed data + Out: OutBuf = ptr to newly allocated buffer containing decompressed data + OutBytes = number of bytes in OutBuf } + procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer; + OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer); + + { DecompressToUserBuf decompresses data, buffer to buffer, in one call. + In: InBuf = ptr to compressed data + InBytes = number of bytes in InBuf + Out: OutBuf = ptr to user-allocated buffer to contain decompressed data + BufSize = number of bytes in OutBuf } + procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer; + const OutBuf: Pointer; BufSize: Integer); + + const + zlib_version = '1.2.1'; + + type + EZlibError = class(Exception); + ECompressionError = class(EZlibError); + EDecompressionError = class(EZlibError); + + implementation + + uses ZLibConst; + + const + Z_NO_FLUSH = 0; + Z_PARTIAL_FLUSH = 1; + Z_SYNC_FLUSH = 2; + Z_FULL_FLUSH = 3; + Z_FINISH = 4; + + Z_OK = 0; + Z_STREAM_END = 1; + Z_NEED_DICT = 2; + Z_ERRNO = (-1); + Z_STREAM_ERROR = (-2); + Z_DATA_ERROR = (-3); + Z_MEM_ERROR = (-4); + Z_BUF_ERROR = (-5); + Z_VERSION_ERROR = (-6); + + Z_NO_COMPRESSION = 0; + Z_BEST_SPEED = 1; + Z_BEST_COMPRESSION = 9; + Z_DEFAULT_COMPRESSION = (-1); + + Z_FILTERED = 1; + Z_HUFFMAN_ONLY = 2; + Z_RLE = 3; + Z_DEFAULT_STRATEGY = 0; + + Z_BINARY = 0; + Z_ASCII = 1; + Z_UNKNOWN = 2; + + Z_DEFLATED = 8; + + + {$L adler32.obj} + {$L compress.obj} + {$L crc32.obj} + {$L deflate.obj} + {$L infback.obj} + {$L inffast.obj} + {$L inflate.obj} + {$L inftrees.obj} + {$L trees.obj} + {$L uncompr.obj} + {$L zutil.obj} + + procedure adler32; external; + procedure compressBound; external; + procedure crc32; external; + procedure deflateInit2_; external; + procedure deflateParams; external; + + function _malloc(Size: Integer): Pointer; cdecl; + begin + Result := AllocMem(Size); + end; + + procedure _free(Block: Pointer); cdecl; + begin + FreeMem(Block); + end; + + procedure _memset(P: Pointer; B: Byte; count: Integer); cdecl; + begin + FillChar(P^, count, B); + end; + + procedure _memcpy(dest, source: Pointer; count: Integer); cdecl; + begin + Move(source^, dest^, count); + end; + + + + // deflate compresses data + function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar; + recsize: Integer): Integer; external; + function deflate(var strm: TZStreamRec; flush: Integer): Integer; external; + function deflateEnd(var strm: TZStreamRec): Integer; external; + + // inflate decompresses data + function inflateInit_(var strm: TZStreamRec; version: PChar; + recsize: Integer): Integer; external; + function inflate(var strm: TZStreamRec; flush: Integer): Integer; external; + function inflateEnd(var strm: TZStreamRec): Integer; external; + function inflateReset(var strm: TZStreamRec): Integer; external; + + + function zlibAllocMem(AppData: Pointer; Items, Size: Integer): Pointer; cdecl; + begin + // GetMem(Result, Items*Size); + Result := AllocMem(Items * Size); + end; + + procedure zlibFreeMem(AppData, Block: Pointer); cdecl; + begin + FreeMem(Block); + end; + + {function zlibCheck(code: Integer): Integer; + begin + Result := code; + if code < 0 then + raise EZlibError.Create('error'); //!! + end;} + + function CCheck(code: Integer): Integer; + begin + Result := code; + if code < 0 then + raise ECompressionError.Create('error'); //!! + end; + + function DCheck(code: Integer): Integer; + begin + Result := code; + if code < 0 then + raise EDecompressionError.Create('error'); //!! + end; + + procedure CompressBuf(const InBuf: Pointer; InBytes: Integer; + out OutBuf: Pointer; out OutBytes: Integer); + var + strm: TZStreamRec; + P: Pointer; + begin + FillChar(strm, sizeof(strm), 0); + strm.zalloc := zlibAllocMem; + strm.zfree := zlibFreeMem; + OutBytes := ((InBytes + (InBytes div 10) + 12) + 255) and not 255; + GetMem(OutBuf, OutBytes); + try + strm.next_in := InBuf; + strm.avail_in := InBytes; + strm.next_out := OutBuf; + strm.avail_out := OutBytes; + CCheck(deflateInit_(strm, Z_BEST_COMPRESSION, zlib_version, sizeof(strm))); + try + while CCheck(deflate(strm, Z_FINISH)) <> Z_STREAM_END do + begin + P := OutBuf; + Inc(OutBytes, 256); + ReallocMem(OutBuf, OutBytes); + strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P))); + strm.avail_out := 256; + end; + finally + CCheck(deflateEnd(strm)); + end; + ReallocMem(OutBuf, strm.total_out); + OutBytes := strm.total_out; + except + FreeMem(OutBuf); + raise + end; + end; + + + procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer; + OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer); + var + strm: TZStreamRec; + P: Pointer; + BufInc: Integer; + begin + FillChar(strm, sizeof(strm), 0); + strm.zalloc := zlibAllocMem; + strm.zfree := zlibFreeMem; + BufInc := (InBytes + 255) and not 255; + if OutEstimate = 0 then + OutBytes := BufInc + else + OutBytes := OutEstimate; + GetMem(OutBuf, OutBytes); + try + strm.next_in := InBuf; + strm.avail_in := InBytes; + strm.next_out := OutBuf; + strm.avail_out := OutBytes; + DCheck(inflateInit_(strm, zlib_version, sizeof(strm))); + try + while DCheck(inflate(strm, Z_FINISH)) <> Z_STREAM_END do + begin + P := OutBuf; + Inc(OutBytes, BufInc); + ReallocMem(OutBuf, OutBytes); + strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P))); + strm.avail_out := BufInc; + end; + finally + DCheck(inflateEnd(strm)); + end; + ReallocMem(OutBuf, strm.total_out); + OutBytes := strm.total_out; + except + FreeMem(OutBuf); + raise + end; + end; + + procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer; + const OutBuf: Pointer; BufSize: Integer); + var + strm: TZStreamRec; + begin + FillChar(strm, sizeof(strm), 0); + strm.zalloc := zlibAllocMem; + strm.zfree := zlibFreeMem; + strm.next_in := InBuf; + strm.avail_in := InBytes; + strm.next_out := OutBuf; + strm.avail_out := BufSize; + DCheck(inflateInit_(strm, zlib_version, sizeof(strm))); + try + if DCheck(inflate(strm, Z_FINISH)) <> Z_STREAM_END then + raise EZlibError.CreateRes(@sTargetBufferTooSmall); + finally + DCheck(inflateEnd(strm)); + end; + end; + + // TCustomZlibStream + + constructor TCustomZLibStream.Create(Strm: TStream); + begin + inherited Create; + FStrm := Strm; + FStrmPos := Strm.Position; + FZRec.zalloc := zlibAllocMem; + FZRec.zfree := zlibFreeMem; + end; + + procedure TCustomZLibStream.Progress(Sender: TObject); + begin + if Assigned(FOnProgress) then FOnProgress(Sender); + end; + + + // TCompressionStream + + constructor TCompressionStream.Create(CompressionLevel: TCompressionLevel; + Dest: TStream); + const + Levels: array [TCompressionLevel] of ShortInt = + (Z_NO_COMPRESSION, Z_BEST_SPEED, Z_DEFAULT_COMPRESSION, Z_BEST_COMPRESSION); + begin + inherited Create(Dest); + FZRec.next_out := FBuffer; + FZRec.avail_out := sizeof(FBuffer); + CCheck(deflateInit_(FZRec, Levels[CompressionLevel], zlib_version, sizeof(FZRec))); + end; + + destructor TCompressionStream.Destroy; + begin + FZRec.next_in := nil; + FZRec.avail_in := 0; + try + if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; + while (CCheck(deflate(FZRec, Z_FINISH)) <> Z_STREAM_END) + and (FZRec.avail_out = 0) do + begin + FStrm.WriteBuffer(FBuffer, sizeof(FBuffer)); + FZRec.next_out := FBuffer; + FZRec.avail_out := sizeof(FBuffer); + end; + if FZRec.avail_out < sizeof(FBuffer) then + FStrm.WriteBuffer(FBuffer, sizeof(FBuffer) - FZRec.avail_out); + finally + deflateEnd(FZRec); + end; + inherited Destroy; + end; + + function TCompressionStream.Read(var Buffer; Count: Longint): Longint; + begin + raise ECompressionError.CreateRes(@sInvalidStreamOp); + end; + + function TCompressionStream.Write(const Buffer; Count: Longint): Longint; + begin + FZRec.next_in := @Buffer; + FZRec.avail_in := Count; + if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; + while (FZRec.avail_in > 0) do + begin + CCheck(deflate(FZRec, 0)); + if FZRec.avail_out = 0 then + begin + FStrm.WriteBuffer(FBuffer, sizeof(FBuffer)); + FZRec.next_out := FBuffer; + FZRec.avail_out := sizeof(FBuffer); + FStrmPos := FStrm.Position; + Progress(Self); + end; + end; + Result := Count; + end; + + function TCompressionStream.Seek(Offset: Longint; Origin: Word): Longint; + begin + if (Offset = 0) and (Origin = soFromCurrent) then + Result := FZRec.total_in + else + raise ECompressionError.CreateRes(@sInvalidStreamOp); + end; + + function TCompressionStream.GetCompressionRate: Single; + begin + if FZRec.total_in = 0 then + Result := 0 + else + Result := (1.0 - (FZRec.total_out / FZRec.total_in)) * 100.0; + end; + + + // TDecompressionStream + + constructor TDecompressionStream.Create(Source: TStream); + begin + inherited Create(Source); + FZRec.next_in := FBuffer; + FZRec.avail_in := 0; + DCheck(inflateInit_(FZRec, zlib_version, sizeof(FZRec))); + end; + + destructor TDecompressionStream.Destroy; + begin + FStrm.Seek(-FZRec.avail_in, 1); + inflateEnd(FZRec); + inherited Destroy; + end; + + function TDecompressionStream.Read(var Buffer; Count: Longint): Longint; + begin + FZRec.next_out := @Buffer; + FZRec.avail_out := Count; + if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; + while (FZRec.avail_out > 0) do + begin + if FZRec.avail_in = 0 then + begin + FZRec.avail_in := FStrm.Read(FBuffer, sizeof(FBuffer)); + if FZRec.avail_in = 0 then + begin + Result := Count - FZRec.avail_out; + Exit; + end; + FZRec.next_in := FBuffer; + FStrmPos := FStrm.Position; + Progress(Self); + end; + CCheck(inflate(FZRec, 0)); + end; + Result := Count; + end; + + function TDecompressionStream.Write(const Buffer; Count: Longint): Longint; + begin + raise EDecompressionError.CreateRes(@sInvalidStreamOp); + end; + + function TDecompressionStream.Seek(Offset: Longint; Origin: Word): Longint; + var + I: Integer; + Buf: array [0..4095] of Char; + begin + if (Offset = 0) and (Origin = soFromBeginning) then + begin + DCheck(inflateReset(FZRec)); + FZRec.next_in := FBuffer; + FZRec.avail_in := 0; + FStrm.Position := 0; + FStrmPos := 0; + end + else if ( (Offset >= 0) and (Origin = soFromCurrent)) or + ( ((Offset - FZRec.total_out) > 0) and (Origin = soFromBeginning)) then + begin + if Origin = soFromBeginning then Dec(Offset, FZRec.total_out); + if Offset > 0 then + begin + for I := 1 to Offset div sizeof(Buf) do + ReadBuffer(Buf, sizeof(Buf)); + ReadBuffer(Buf, Offset mod sizeof(Buf)); + end; + end + else + raise EDecompressionError.CreateRes(@sInvalidStreamOp); + Result := FZRec.total_out; + end; + + + end. Index: llvm/runtime/zlib/contrib/delphi/ZLibConst.pas diff -c /dev/null llvm/runtime/zlib/contrib/delphi/ZLibConst.pas:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/delphi/ZLibConst.pas Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,11 ---- + unit ZLibConst; + + interface + + resourcestring + sTargetBufferTooSmall = 'ZLib error: target buffer may be too small'; + sInvalidStreamOp = 'Invalid stream operation'; + + implementation + + end. Index: llvm/runtime/zlib/contrib/delphi/readme.txt diff -c /dev/null llvm/runtime/zlib/contrib/delphi/readme.txt:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/delphi/readme.txt Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,76 ---- + + Overview + ======== + + This directory contains an update to the ZLib interface unit, + distributed by Borland as a Delphi supplemental component. + + The original ZLib unit is Copyright (c) 1997,99 Borland Corp., + and is based on zlib version 1.0.4. There are a series of bugs + and security problems associated with that old zlib version, and + we recommend the users to update their ZLib unit. + + + Summary of modifications + ======================== + + - Improved makefile, adapted to zlib version 1.2.1. + + - Some field types from TZStreamRec are changed from Integer to + Longint, for consistency with the zlib.h header, and for 64-bit + readiness. + + - The zlib_version constant is updated. + + - The new Z_RLE strategy has its corresponding symbolic constant. + + - The allocation and deallocation functions and function types + (TAlloc, TFree, zlibAllocMem and zlibFreeMem) are now cdecl, + and _malloc and _free are added as C RTL stubs. As a result, + the original C sources of zlib can be compiled out of the box, + and linked to the ZLib unit. + + + Suggestions for improvements + ============================ + + Currently, the ZLib unit provides only a limited wrapper around + the zlib library, and much of the original zlib functionality is + missing. Handling compressed file formats like ZIP/GZIP or PNG + cannot be implemented without having this functionality. + Applications that handle these formats are either using their own, + duplicated code, or not using the ZLib unit at all. + + Here are a few suggestions: + + - Checksum class wrappers around adler32() and crc32(), similar + to the Java classes that implement the java.util.zip.Checksum + interface. + + - The ability to read and write raw deflate streams, without the + zlib stream header and trailer. Raw deflate streams are used + in the ZIP file format. + + - The ability to read and write gzip streams, used in the GZIP + file format, and normally produced by the gzip program. + + - The ability to select a different compression strategy, useful + to PNG and MNG image compression, and to multimedia compression + in general. Besides the compression level + + TCompressionLevel = (clNone, clFastest, clDefault, clMax); + + which, in fact, could have used the 'z' prefix and avoided + TColor-like symbols + + TCompressionLevel = (zcNone, zcFastest, zcDefault, zcMax); + + there could be a compression strategy + + TCompressionStrategy = (zsDefault, zsFiltered, zsHuffmanOnly, zsRle); + + - ZIP and GZIP stream handling via TStreams. + + + -- + Cosmin Truta Index: llvm/runtime/zlib/contrib/delphi/zlibd32.mak diff -c /dev/null llvm/runtime/zlib/contrib/delphi/zlibd32.mak:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/delphi/zlibd32.mak Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,93 ---- + # Makefile for zlib + # For use with Delphi and C++ Builder under Win32 + # Updated for zlib 1.2.x by Cosmin Truta + + # ------------ Borland C++ ------------ + + # This project uses the Delphi (fastcall/register) calling convention: + LOC = -DZEXPORT=__fastcall -DZEXPORTVA=__cdecl + + CC = bcc32 + LD = bcc32 + AR = tlib + # do not use "-pr" in CFLAGS + CFLAGS = -a -d -k- -O2 $(LOC) + LDFLAGS = + + + # variables + ZLIB_LIB = zlib.lib + + OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj + OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj + OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj + OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj + + + # targets + all: $(ZLIB_LIB) example.exe minigzip.exe + + .c.obj: + $(CC) -c $(CFLAGS) $*.c + + adler32.obj: adler32.c zlib.h zconf.h + + compress.obj: compress.c zlib.h zconf.h + + crc32.obj: crc32.c zlib.h zconf.h crc32.h + + deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h + + gzio.obj: gzio.c zutil.h zlib.h zconf.h + + infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + + inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h + + inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ + inffast.h inffixed.h + + inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h + + trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h + + uncompr.obj: uncompr.c zlib.h zconf.h + + zutil.obj: zutil.c zutil.h zlib.h zconf.h + + example.obj: example.c zlib.h zconf.h + + minigzip.obj: minigzip.c zlib.h zconf.h + + + # For the sake of the old Borland make, + # the command line is cut to fit in the MS-DOS 128 byte limit: + $(ZLIB_LIB): $(OBJ1) $(OBJ2) + -del $(ZLIB_LIB) + $(AR) $(ZLIB_LIB) $(OBJP1) + $(AR) $(ZLIB_LIB) $(OBJP2) + + + # testing + test: example.exe minigzip.exe + example + echo hello world | minigzip | minigzip -d + + example.exe: example.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) + + minigzip.exe: minigzip.obj $(ZLIB_LIB) + $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) + + + # cleanup + clean: + -del *.obj + -del *.exe + -del *.lib + -del *.tds + -del zlib.bak + -del foo.gz + From criswell at cs.uiuc.edu Fri Feb 6 10:42:44 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:42:44 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/infback9/README infback9.c infback9.h inffix9.h inflate9.h inftree9.c inftree9.h Message-ID: <200402061636.KAA15501@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/infback9: README added (r1.1) infback9.c added (r1.1) infback9.h added (r1.1) inffix9.h added (r1.1) inflate9.h added (r1.1) inftree9.c added (r1.1) inftree9.h added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+1167 -0) Index: llvm/runtime/zlib/contrib/infback9/README diff -c /dev/null llvm/runtime/zlib/contrib/infback9/README:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/infback9/README Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1 ---- + See infback9.h for what this is and how to use it. Index: llvm/runtime/zlib/contrib/infback9/infback9.c diff -c /dev/null llvm/runtime/zlib/contrib/infback9/infback9.c:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/infback9/infback9.c Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,605 ---- + /* infback9.c -- inflate deflate64 data using a call-back interface + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + + #include "zutil.h" + #include "infback9.h" + #include "inftree9.h" + #include "inflate9.h" + + #define WSIZE 65536UL + + /* + strm provides memory allocation functions in zalloc and zfree, or + Z_NULL to use the library memory allocation functions. + + window is a user-supplied window and output buffer that is 64K bytes. + */ + int ZEXPORT inflateBack9Init_(strm, window, version, stream_size) + z_stream FAR *strm; + unsigned char FAR *window; + const char *version; + int stream_size; + { + struct inflate_state FAR *state; + + if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || + stream_size != (int)(sizeof(z_stream))) + return Z_VERSION_ERROR; + if (strm == Z_NULL || window == Z_NULL) + return Z_STREAM_ERROR; + strm->msg = Z_NULL; /* in case we return an error */ + if (strm->zalloc == (alloc_func)0) { + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; + } + if (strm->zfree == (free_func)0) strm->zfree = zcfree; + state = (struct inflate_state FAR *)ZALLOC(strm, 1, + sizeof(struct inflate_state)); + if (state == Z_NULL) return Z_MEM_ERROR; + Tracev((stderr, "inflate: allocated\n")); + strm->state = (voidpf)state; + state->window = window; + return Z_OK; + } + + /* + Build and output length and distance decoding tables for fixed code + decoding. + */ + #ifdef MAKEFIXED + #include + + void makefixed9(void) + { + unsigned sym, bits, low, size; + code *next, *lenfix, *distfix; + struct inflate_state state; + code fixed[544]; + + /* literal/length table */ + sym = 0; + while (sym < 144) state.lens[sym++] = 8; + while (sym < 256) state.lens[sym++] = 9; + while (sym < 280) state.lens[sym++] = 7; + while (sym < 288) state.lens[sym++] = 8; + next = fixed; + lenfix = next; + bits = 9; + inflate_table9(LENS, state.lens, 288, &(next), &(bits), state.work); + + /* distance table */ + sym = 0; + while (sym < 32) state.lens[sym++] = 5; + distfix = next; + bits = 5; + inflate_table9(DISTS, state.lens, 32, &(next), &(bits), state.work); + + /* write tables */ + puts(" /* inffix9.h -- table for decoding deflate64 fixed codes"); + puts(" * Generated automatically by makefixed9()."); + puts(" */"); + puts(""); + puts(" /* WARNING: this file should *not* be used by applications."); + puts(" It is part of the implementation of this library and is"); + puts(" subject to change. Applications should only use zlib.h."); + puts(" */"); + puts(""); + size = 1U << 9; + printf(" static const code lenfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 6) == 0) printf("\n "); + printf("{%u,%u,%d}", lenfix[low].op, lenfix[low].bits, + lenfix[low].val); + if (++low == size) break; + putchar(','); + } + puts("\n };"); + size = 1U << 5; + printf("\n static const code distfix[%u] = {", size); + low = 0; + for (;;) { + if ((low % 5) == 0) printf("\n "); + printf("{%u,%u,%d}", distfix[low].op, distfix[low].bits, + distfix[low].val); + if (++low == size) break; + putchar(','); + } + puts("\n };"); + } + #endif /* MAKEFIXED */ + + /* Macros for inflateBack(): */ + + /* Clear the input bit accumulator */ + #define INITBITS() \ + do { \ + hold = 0; \ + bits = 0; \ + } while (0) + + /* Assure that some input is available. If input is requested, but denied, + then return a Z_BUF_ERROR from inflateBack(). */ + #define PULL() \ + do { \ + if (have == 0) { \ + have = in(in_desc, &next); \ + if (have == 0) { \ + next = Z_NULL; \ + ret = Z_BUF_ERROR; \ + goto inf_leave; \ + } \ + } \ + } while (0) + + /* Get a byte of input into the bit accumulator, or return from inflateBack() + with an error if there is no input available. */ + #define PULLBYTE() \ + do { \ + PULL(); \ + have--; \ + hold += (unsigned long)(*next++) << bits; \ + bits += 8; \ + } while (0) + + /* Assure that there are at least n bits in the bit accumulator. If there is + not enough available input to do that, then return from inflateBack() with + an error. */ + #define NEEDBITS(n) \ + do { \ + while (bits < (unsigned)(n)) \ + PULLBYTE(); \ + } while (0) + + /* Return the low n bits of the bit accumulator (n <= 16) */ + #define BITS(n) \ + ((unsigned)hold & ((1U << (n)) - 1)) + + /* Remove n bits from the bit accumulator */ + #define DROPBITS(n) \ + do { \ + hold >>= (n); \ + bits -= (unsigned)(n); \ + } while (0) + + /* Remove zero to seven bits as needed to go to a byte boundary */ + #define BYTEBITS() \ + do { \ + hold >>= bits & 7; \ + bits -= bits & 7; \ + } while (0) + + /* Assure that some output space is available, by writing out the window + if it's full. If the write fails, return from inflateBack() with a + Z_BUF_ERROR. */ + #define ROOM() \ + do { \ + if (left == 0) { \ + put = window; \ + left = WSIZE; \ + wrap = 1; \ + if (out(out_desc, put, (unsigned)left)) { \ + ret = Z_BUF_ERROR; \ + goto inf_leave; \ + } \ + } \ + } while (0) + + /* + strm provides the memory allocation functions and window buffer on input, + and provides information on the unused input on return. For Z_DATA_ERROR + returns, strm will also provide an error message. + + in() and out() are the call-back input and output functions. When + inflateBack() needs more input, it calls in(). When inflateBack() has + filled the window with output, or when it completes with data in the + window, it calls out() to write out the data. The application must not + change the provided input until in() is called again or inflateBack() + returns. The application must not change the window/output buffer until + inflateBack() returns. + + in() and out() are called with a descriptor parameter provided in the + inflateBack() call. This parameter can be a structure that provides the + information required to do the read or write, as well as accumulated + information on the input and output such as totals and check values. + + in() should return zero on failure. out() should return non-zero on + failure. If either in() or out() fails, than inflateBack() returns a + Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it + was in() or out() that caused in the error. Otherwise, inflateBack() + returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format + error, or Z_MEM_ERROR if it could not allocate memory for the state. + inflateBack() can also return Z_STREAM_ERROR if the input parameters + are not correct, i.e. strm is Z_NULL or the state was not initialized. + */ + int ZEXPORT inflateBack9(strm, in, in_desc, out, out_desc) + z_stream FAR *strm; + in_func in; + void FAR *in_desc; + out_func out; + void FAR *out_desc; + { + struct inflate_state FAR *state; + unsigned char FAR *next; /* next input */ + unsigned char FAR *put; /* next output */ + unsigned have; /* available input */ + unsigned long left; /* available output */ + inflate_mode mode; /* current inflate mode */ + int lastblock; /* true if processing last block */ + int wrap; /* true if the window has wrapped */ + unsigned long write; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if needed */ + unsigned long hold; /* bit buffer */ + unsigned bits; /* bits in bit buffer */ + unsigned extra; /* extra bits needed */ + unsigned long length; /* literal or length of data to copy */ + unsigned long offset; /* distance back to copy string from */ + unsigned long copy; /* number of stored or match bytes to copy */ + unsigned char FAR *from; /* where to copy match bytes from */ + code const FAR *lencode; /* starting table for length/literal codes */ + code const FAR *distcode; /* starting table for distance codes */ + unsigned lenbits; /* index bits for lencode */ + unsigned distbits; /* index bits for distcode */ + code this; /* current decoding table entry */ + code last; /* parent table entry */ + unsigned len; /* length to copy for repeats, bits to drop */ + int ret; /* return code */ + static const unsigned short order[19] = /* permutation of code lengths */ + {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + #include "inffix9.h" + + /* Check that the strm exists and that the state was initialized */ + if (strm == Z_NULL || strm->state == Z_NULL) + return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + + /* Reset the state */ + strm->msg = Z_NULL; + mode = TYPE; + lastblock = 0; + write = 0; + wrap = 0; + window = state->window; + next = strm->next_in; + have = next != Z_NULL ? strm->avail_in : 0; + hold = 0; + bits = 0; + put = window; + left = WSIZE; + lencode = Z_NULL; + distcode = Z_NULL; + + /* Inflate until end of block marked as last */ + for (;;) + switch (mode) { + case TYPE: + /* determine and dispatch block type */ + if (lastblock) { + BYTEBITS(); + mode = DONE; + break; + } + NEEDBITS(3); + lastblock = BITS(1); + DROPBITS(1); + switch (BITS(2)) { + case 0: /* stored block */ + Tracev((stderr, "inflate: stored block%s\n", + lastblock ? " (last)" : "")); + mode = STORED; + break; + case 1: /* fixed block */ + lencode = lenfix; + lenbits = 9; + distcode = distfix; + distbits = 5; + Tracev((stderr, "inflate: fixed codes block%s\n", + lastblock ? " (last)" : "")); + mode = LEN; /* decode codes */ + break; + case 2: /* dynamic block */ + Tracev((stderr, "inflate: dynamic codes block%s\n", + lastblock ? " (last)" : "")); + mode = TABLE; + break; + case 3: + strm->msg = (char *)"invalid block type"; + mode = BAD; + } + DROPBITS(2); + break; + + case STORED: + /* get and verify stored block length */ + BYTEBITS(); /* go to byte boundary */ + NEEDBITS(32); + if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { + strm->msg = (char *)"invalid stored block lengths"; + mode = BAD; + break; + } + length = (unsigned)hold & 0xffff; + Tracev((stderr, "inflate: stored length %lu\n", + length)); + INITBITS(); + + /* copy stored block from input to output */ + while (length != 0) { + copy = length; + PULL(); + ROOM(); + if (copy > have) copy = have; + if (copy > left) copy = left; + zmemcpy(put, next, copy); + have -= copy; + next += copy; + left -= copy; + put += copy; + length -= copy; + } + Tracev((stderr, "inflate: stored end\n")); + mode = TYPE; + break; + + case TABLE: + /* get dynamic table entries descriptor */ + NEEDBITS(14); + state->nlen = BITS(5) + 257; + DROPBITS(5); + state->ndist = BITS(5) + 1; + DROPBITS(5); + state->ncode = BITS(4) + 4; + DROPBITS(4); + if (state->nlen > 286) { + strm->msg = (char *)"too many length symbols"; + mode = BAD; + break; + } + Tracev((stderr, "inflate: table sizes ok\n")); + + /* get code length code lengths (not a typo) */ + state->have = 0; + while (state->have < state->ncode) { + NEEDBITS(3); + state->lens[order[state->have++]] = (unsigned short)BITS(3); + DROPBITS(3); + } + while (state->have < 19) + state->lens[order[state->have++]] = 0; + state->next = state->codes; + lencode = (code const FAR *)(state->next); + lenbits = 7; + ret = inflate_table9(CODES, state->lens, 19, &(state->next), + &(lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid code lengths set"; + mode = BAD; + break; + } + Tracev((stderr, "inflate: code lengths ok\n")); + + /* get length and distance code code lengths */ + state->have = 0; + while (state->have < state->nlen + state->ndist) { + for (;;) { + this = lencode[BITS(lenbits)]; + if ((unsigned)(this.bits) <= bits) break; + PULLBYTE(); + } + if (this.val < 16) { + NEEDBITS(this.bits); + DROPBITS(this.bits); + state->lens[state->have++] = this.val; + } + else { + if (this.val == 16) { + NEEDBITS(this.bits + 2); + DROPBITS(this.bits); + if (state->have == 0) { + strm->msg = (char *)"invalid bit length repeat"; + mode = BAD; + break; + } + len = (unsigned)(state->lens[state->have - 1]); + copy = 3 + BITS(2); + DROPBITS(2); + } + else if (this.val == 17) { + NEEDBITS(this.bits + 3); + DROPBITS(this.bits); + len = 0; + copy = 3 + BITS(3); + DROPBITS(3); + } + else { + NEEDBITS(this.bits + 7); + DROPBITS(this.bits); + len = 0; + copy = 11 + BITS(7); + DROPBITS(7); + } + if (state->have + copy > state->nlen + state->ndist) { + strm->msg = (char *)"invalid bit length repeat"; + mode = BAD; + break; + } + while (copy--) + state->lens[state->have++] = (unsigned short)len; + } + } + + /* build code tables */ + state->next = state->codes; + lencode = (code const FAR *)(state->next); + lenbits = 9; + ret = inflate_table9(LENS, state->lens, state->nlen, + &(state->next), &(lenbits), state->work); + if (ret) { + strm->msg = (char *)"invalid literal/lengths set"; + mode = BAD; + break; + } + distcode = (code const FAR *)(state->next); + distbits = 6; + ret = inflate_table9(DISTS, state->lens + state->nlen, + state->ndist, &(state->next), &(distbits), + state->work); + if (ret) { + strm->msg = (char *)"invalid distances set"; + mode = BAD; + break; + } + Tracev((stderr, "inflate: codes ok\n")); + mode = LEN; + + case LEN: + /* get a literal, length, or end-of-block code */ + for (;;) { + this = lencode[BITS(lenbits)]; + if ((unsigned)(this.bits) <= bits) break; + PULLBYTE(); + } + if (this.op && (this.op & 0xf0) == 0) { + last = this; + for (;;) { + this = lencode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + this.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(this.bits); + length = (unsigned)this.val; + + /* process literal */ + if (this.op == 0) { + Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", this.val)); + ROOM(); + *put++ = (unsigned char)(length); + left--; + mode = LEN; + break; + } + + /* process end of block */ + if (this.op & 32) { + Tracevv((stderr, "inflate: end of block\n")); + mode = TYPE; + break; + } + + /* invalid code */ + if (this.op & 64) { + strm->msg = (char *)"invalid literal/length code"; + mode = BAD; + break; + } + + /* length code -- get extra bits, if any */ + extra = (unsigned)(this.op) & 31; + if (extra != 0) { + NEEDBITS(extra); + length += BITS(extra); + DROPBITS(extra); + } + Tracevv((stderr, "inflate: length %lu\n", length)); + + /* get distance code */ + for (;;) { + this = distcode[BITS(distbits)]; + if ((unsigned)(this.bits) <= bits) break; + PULLBYTE(); + } + if ((this.op & 0xf0) == 0) { + last = this; + for (;;) { + this = distcode[last.val + + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + this.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(this.bits); + if (this.op & 64) { + strm->msg = (char *)"invalid distance code"; + mode = BAD; + break; + } + offset = (unsigned)this.val; + + /* get distance extra bits, if any */ + extra = (unsigned)(this.op) & 15; + if (extra != 0) { + NEEDBITS(extra); + offset += BITS(extra); + DROPBITS(extra); + } + if (offset > WSIZE - (wrap ? 0: left)) { + strm->msg = (char *)"invalid distance too far back"; + mode = BAD; + break; + } + Tracevv((stderr, "inflate: distance %lu\n", offset)); + + /* copy match from window to output */ + do { + ROOM(); + copy = WSIZE - offset; + if (copy < left) { + from = put + copy; + copy = left - copy; + } + else { + from = put - offset; + copy = left; + } + if (copy > length) copy = length; + length -= copy; + left -= copy; + do { + *put++ = *from++; + } while (--copy); + } while (length != 0); + break; + + case DONE: + /* inflate stream terminated properly -- write leftover output */ + ret = Z_STREAM_END; + if (left < WSIZE) { + if (out(out_desc, window, (unsigned)(WSIZE - left))) + ret = Z_BUF_ERROR; + } + goto inf_leave; + + case BAD: + ret = Z_DATA_ERROR; + goto inf_leave; + + default: /* can't happen, but makes compilers happy */ + ret = Z_STREAM_ERROR; + goto inf_leave; + } + + /* Return unused input */ + inf_leave: + strm->next_in = next; + strm->avail_in = have; + return ret; + } + + int ZEXPORT inflateBack9End(strm) + z_stream FAR *strm; + { + if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) + return Z_STREAM_ERROR; + ZFREE(strm, strm->state); + strm->state = Z_NULL; + Tracev((stderr, "inflate: end\n")); + return Z_OK; + } Index: llvm/runtime/zlib/contrib/infback9/infback9.h diff -c /dev/null llvm/runtime/zlib/contrib/infback9/infback9.h:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/infback9/infback9.h Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,29 ---- + /* infback9.h -- header for using inflateBack9 functions + * Copyright (C) 2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + + /* + * This header file and associated patches provide a decoder for PKWare's + * undocumented deflate64 compression method (method 9). Use with infback9.c, + * inftree9.h, inftree9.c, and inffix9.h. These patches are not supported. + * This should be compiled with zlib, since it uses zutil.h and zutil.o. + * This code has not yet been tested on 16-bit architectures. See the + * comments in zlib.h for inflateBack() usage. These functions are used + * identically, except that there is no windowBits parameter, and a 64K + * window must be provided. Also if int's are 16 bits, then a zero for + * the third parameter of the "out" function actually means 65536UL. + * zlib.h must be included before this header file. + */ + + ZEXTERN int ZEXPORT inflateBack9 OF((z_stream FAR *strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); + ZEXTERN int ZEXPORT inflateBack9End OF((z_stream FAR *strm)); + ZEXTERN int ZEXPORT inflateBack9Init_ OF((z_stream FAR *strm, + unsigned char FAR *window, + const char *version, + int stream_size)); + #define inflateBack9Init(strm, window) \ + inflateBack9Init_((strm), (window), \ + ZLIB_VERSION, sizeof(z_stream)) Index: llvm/runtime/zlib/contrib/infback9/inffix9.h diff -c /dev/null llvm/runtime/zlib/contrib/infback9/inffix9.h:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/infback9/inffix9.h Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,107 ---- + /* inffix9.h -- table for decoding deflate64 fixed codes + * Generated automatically by makefixed9(). + */ + + /* WARNING: this file should *not* be used by applications. + It is part of the implementation of this library and is + subject to change. Applications should only use zlib.h. + */ + + static const code lenfix[512] = { + {96,7,0},{0,8,80},{0,8,16},{132,8,115},{130,7,31},{0,8,112}, + {0,8,48},{0,9,192},{128,7,10},{0,8,96},{0,8,32},{0,9,160}, + {0,8,0},{0,8,128},{0,8,64},{0,9,224},{128,7,6},{0,8,88}, + {0,8,24},{0,9,144},{131,7,59},{0,8,120},{0,8,56},{0,9,208}, + {129,7,17},{0,8,104},{0,8,40},{0,9,176},{0,8,8},{0,8,136}, + {0,8,72},{0,9,240},{128,7,4},{0,8,84},{0,8,20},{133,8,227}, + {131,7,43},{0,8,116},{0,8,52},{0,9,200},{129,7,13},{0,8,100}, + {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232}, + {128,7,8},{0,8,92},{0,8,28},{0,9,152},{132,7,83},{0,8,124}, + {0,8,60},{0,9,216},{130,7,23},{0,8,108},{0,8,44},{0,9,184}, + {0,8,12},{0,8,140},{0,8,76},{0,9,248},{128,7,3},{0,8,82}, + {0,8,18},{133,8,163},{131,7,35},{0,8,114},{0,8,50},{0,9,196}, + {129,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},{0,8,130}, + {0,8,66},{0,9,228},{128,7,7},{0,8,90},{0,8,26},{0,9,148}, + {132,7,67},{0,8,122},{0,8,58},{0,9,212},{130,7,19},{0,8,106}, + {0,8,42},{0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244}, + {128,7,5},{0,8,86},{0,8,22},{65,8,0},{131,7,51},{0,8,118}, + {0,8,54},{0,9,204},{129,7,15},{0,8,102},{0,8,38},{0,9,172}, + {0,8,6},{0,8,134},{0,8,70},{0,9,236},{128,7,9},{0,8,94}, + {0,8,30},{0,9,156},{132,7,99},{0,8,126},{0,8,62},{0,9,220}, + {130,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, + {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{133,8,131}, + {130,7,31},{0,8,113},{0,8,49},{0,9,194},{128,7,10},{0,8,97}, + {0,8,33},{0,9,162},{0,8,1},{0,8,129},{0,8,65},{0,9,226}, + {128,7,6},{0,8,89},{0,8,25},{0,9,146},{131,7,59},{0,8,121}, + {0,8,57},{0,9,210},{129,7,17},{0,8,105},{0,8,41},{0,9,178}, + {0,8,9},{0,8,137},{0,8,73},{0,9,242},{128,7,4},{0,8,85}, + {0,8,21},{144,8,3},{131,7,43},{0,8,117},{0,8,53},{0,9,202}, + {129,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133}, + {0,8,69},{0,9,234},{128,7,8},{0,8,93},{0,8,29},{0,9,154}, + {132,7,83},{0,8,125},{0,8,61},{0,9,218},{130,7,23},{0,8,109}, + {0,8,45},{0,9,186},{0,8,13},{0,8,141},{0,8,77},{0,9,250}, + {128,7,3},{0,8,83},{0,8,19},{133,8,195},{131,7,35},{0,8,115}, + {0,8,51},{0,9,198},{129,7,11},{0,8,99},{0,8,35},{0,9,166}, + {0,8,3},{0,8,131},{0,8,67},{0,9,230},{128,7,7},{0,8,91}, + {0,8,27},{0,9,150},{132,7,67},{0,8,123},{0,8,59},{0,9,214}, + {130,7,19},{0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139}, + {0,8,75},{0,9,246},{128,7,5},{0,8,87},{0,8,23},{77,8,0}, + {131,7,51},{0,8,119},{0,8,55},{0,9,206},{129,7,15},{0,8,103}, + {0,8,39},{0,9,174},{0,8,7},{0,8,135},{0,8,71},{0,9,238}, + {128,7,9},{0,8,95},{0,8,31},{0,9,158},{132,7,99},{0,8,127}, + {0,8,63},{0,9,222},{130,7,27},{0,8,111},{0,8,47},{0,9,190}, + {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80}, + {0,8,16},{132,8,115},{130,7,31},{0,8,112},{0,8,48},{0,9,193}, + {128,7,10},{0,8,96},{0,8,32},{0,9,161},{0,8,0},{0,8,128}, + {0,8,64},{0,9,225},{128,7,6},{0,8,88},{0,8,24},{0,9,145}, + {131,7,59},{0,8,120},{0,8,56},{0,9,209},{129,7,17},{0,8,104}, + {0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},{0,9,241}, + {128,7,4},{0,8,84},{0,8,20},{133,8,227},{131,7,43},{0,8,116}, + {0,8,52},{0,9,201},{129,7,13},{0,8,100},{0,8,36},{0,9,169}, + {0,8,4},{0,8,132},{0,8,68},{0,9,233},{128,7,8},{0,8,92}, + {0,8,28},{0,9,153},{132,7,83},{0,8,124},{0,8,60},{0,9,217}, + {130,7,23},{0,8,108},{0,8,44},{0,9,185},{0,8,12},{0,8,140}, + {0,8,76},{0,9,249},{128,7,3},{0,8,82},{0,8,18},{133,8,163}, + {131,7,35},{0,8,114},{0,8,50},{0,9,197},{129,7,11},{0,8,98}, + {0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, + {128,7,7},{0,8,90},{0,8,26},{0,9,149},{132,7,67},{0,8,122}, + {0,8,58},{0,9,213},{130,7,19},{0,8,106},{0,8,42},{0,9,181}, + {0,8,10},{0,8,138},{0,8,74},{0,9,245},{128,7,5},{0,8,86}, + {0,8,22},{65,8,0},{131,7,51},{0,8,118},{0,8,54},{0,9,205}, + {129,7,15},{0,8,102},{0,8,38},{0,9,173},{0,8,6},{0,8,134}, + {0,8,70},{0,9,237},{128,7,9},{0,8,94},{0,8,30},{0,9,157}, + {132,7,99},{0,8,126},{0,8,62},{0,9,221},{130,7,27},{0,8,110}, + {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253}, + {96,7,0},{0,8,81},{0,8,17},{133,8,131},{130,7,31},{0,8,113}, + {0,8,49},{0,9,195},{128,7,10},{0,8,97},{0,8,33},{0,9,163}, + {0,8,1},{0,8,129},{0,8,65},{0,9,227},{128,7,6},{0,8,89}, + {0,8,25},{0,9,147},{131,7,59},{0,8,121},{0,8,57},{0,9,211}, + {129,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},{0,8,137}, + {0,8,73},{0,9,243},{128,7,4},{0,8,85},{0,8,21},{144,8,3}, + {131,7,43},{0,8,117},{0,8,53},{0,9,203},{129,7,13},{0,8,101}, + {0,8,37},{0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235}, + {128,7,8},{0,8,93},{0,8,29},{0,9,155},{132,7,83},{0,8,125}, + {0,8,61},{0,9,219},{130,7,23},{0,8,109},{0,8,45},{0,9,187}, + {0,8,13},{0,8,141},{0,8,77},{0,9,251},{128,7,3},{0,8,83}, + {0,8,19},{133,8,195},{131,7,35},{0,8,115},{0,8,51},{0,9,199}, + {129,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, + {0,8,67},{0,9,231},{128,7,7},{0,8,91},{0,8,27},{0,9,151}, + {132,7,67},{0,8,123},{0,8,59},{0,9,215},{130,7,19},{0,8,107}, + {0,8,43},{0,9,183},{0,8,11},{0,8,139},{0,8,75},{0,9,247}, + {128,7,5},{0,8,87},{0,8,23},{77,8,0},{131,7,51},{0,8,119}, + {0,8,55},{0,9,207},{129,7,15},{0,8,103},{0,8,39},{0,9,175}, + {0,8,7},{0,8,135},{0,8,71},{0,9,239},{128,7,9},{0,8,95}, + {0,8,31},{0,9,159},{132,7,99},{0,8,127},{0,8,63},{0,9,223}, + {130,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143}, + {0,8,79},{0,9,255} + }; + + static const code distfix[32] = { + {128,5,1},{135,5,257},{131,5,17},{139,5,4097},{129,5,5}, + {137,5,1025},{133,5,65},{141,5,16385},{128,5,3},{136,5,513}, + {132,5,33},{140,5,8193},{130,5,9},{138,5,2049},{134,5,129}, + {142,5,32769},{128,5,2},{135,5,385},{131,5,25},{139,5,6145}, + {129,5,7},{137,5,1537},{133,5,97},{141,5,24577},{128,5,4}, + {136,5,769},{132,5,49},{140,5,12289},{130,5,13},{138,5,3073}, + {134,5,193},{142,5,49153} + }; Index: llvm/runtime/zlib/contrib/infback9/inflate9.h diff -c /dev/null llvm/runtime/zlib/contrib/infback9/inflate9.h:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/infback9/inflate9.h Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,47 ---- + /* inflate9.h -- internal inflate state definition + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + + /* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + + /* Possible inflate modes between inflate() calls */ + typedef enum { + TYPE, /* i: waiting for type bits, including last-flag bit */ + STORED, /* i: waiting for stored size (length and complement) */ + TABLE, /* i: waiting for dynamic block table lengths */ + LEN, /* i: waiting for length/lit code */ + DONE, /* finished check, done -- remain here until reset */ + BAD /* got a data error -- remain here until reset */ + } inflate_mode; + + /* + State transitions between above modes - + + (most modes can go to the BAD mode -- not shown for clarity) + + Read deflate blocks: + TYPE -> STORED or TABLE or LEN or DONE + STORED -> TYPE + TABLE -> LENLENS -> CODELENS -> LEN + Read deflate codes: + LEN -> LEN or TYPE + */ + + /* state maintained between inflate() calls. Approximately 7K bytes. */ + struct inflate_state { + /* sliding window */ + unsigned char FAR *window; /* allocated sliding window, if needed */ + /* dynamic table building */ + unsigned ncode; /* number of code length code lengths */ + unsigned nlen; /* number of length code lengths */ + unsigned ndist; /* number of distance code lengths */ + unsigned have; /* number of code lengths in lens[] */ + code FAR *next; /* next available space in codes[] */ + unsigned short lens[320]; /* temporary storage for code lengths */ + unsigned short work[288]; /* work area for code table building */ + code codes[ENOUGH]; /* space for code tables */ + }; Index: llvm/runtime/zlib/contrib/infback9/inftree9.c diff -c /dev/null llvm/runtime/zlib/contrib/infback9/inftree9.c:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/infback9/inftree9.c Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,323 ---- + /* inftree9.c -- generate Huffman trees for efficient decoding + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + + #include "zutil.h" + #include "inftree9.h" + + #define MAXBITS 15 + + const char inflate9_copyright[] = + " inflate9 1.2.1 Copyright 1995-2003 Mark Adler "; + /* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ + + /* + Build a set of tables to decode the provided canonical Huffman code. + The code lengths are lens[0..codes-1]. The result starts at *table, + whose indices are 0..2^bits-1. work is a writable array of at least + lens shorts, which is used as a work area. type is the type of code + to be generated, CODES, LENS, or DISTS. On return, zero is success, + -1 is an invalid code, and +1 means that ENOUGH isn't enough. table + on return points to the next available entry's address. bits is the + requested root table index bits, and on return it is the actual root + table index bits. It will differ if the request is greater than the + longest code or if it is less than the shortest code. + */ + int inflate_table9(type, lens, codes, table, bits, work) + codetype type; + unsigned short FAR *lens; + unsigned codes; + code FAR * FAR *table; + unsigned FAR *bits; + unsigned short FAR *work; + { + unsigned len; /* a code's length in bits */ + unsigned sym; /* index of code symbols */ + unsigned min, max; /* minimum and maximum code lengths */ + unsigned root; /* number of index bits for root table */ + unsigned curr; /* number of index bits for current table */ + unsigned drop; /* code bits to drop for sub-table */ + int left; /* number of prefix codes available */ + unsigned used; /* code entries in table used */ + unsigned huff; /* Huffman code */ + unsigned incr; /* for incrementing code, index */ + unsigned fill; /* index for replicating entries */ + unsigned low; /* low bits for current root entry */ + unsigned mask; /* mask for low root bits */ + code this; /* table entry for duplication */ + code FAR *next; /* next available space in table */ + const unsigned short FAR *base; /* base value table to use */ + const unsigned short FAR *extra; /* extra bits table to use */ + int end; /* use base and extra for symbol > end */ + unsigned short count[MAXBITS+1]; /* number of codes of each length */ + unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ + static const unsigned short lbase[31] = { /* Length codes 257..285 base */ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, + 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, + 131, 163, 195, 227, 3, 0, 0}; + static const unsigned short lext[31] = { /* Length codes 257..285 extra */ + 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, + 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, + 133, 133, 133, 133, 144, 76, 66}; + static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, + 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, + 4097, 6145, 8193, 12289, 16385, 24577, 32769, 49153}; + static const unsigned short dext[32] = { /* Distance codes 0..31 extra */ + 128, 128, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, + 133, 133, 134, 134, 135, 135, 136, 136, 137, 137, 138, 138, + 139, 139, 140, 140, 141, 141, 142, 142}; + + /* + Process a set of code lengths to create a canonical Huffman code. The + code lengths are lens[0..codes-1]. Each length corresponds to the + symbols 0..codes-1. The Huffman code is generated by first sorting the + symbols by length from short to long, and retaining the symbol order + for codes with equal lengths. Then the code starts with all zero bits + for the first code of the shortest length, and the codes are integer + increments for the same length, and zeros are appended as the length + increases. For the deflate format, these bits are stored backwards + from their more natural integer increment ordering, and so when the + decoding tables are built in the large loop below, the integer codes + are incremented backwards. + + This routine assumes, but does not check, that all of the entries in + lens[] are in the range 0..MAXBITS. The caller must assure this. + 1..MAXBITS is interpreted as that code length. zero means that that + symbol does not occur in this code. + + The codes are sorted by computing a count of codes for each length, + creating from that a table of starting indices for each length in the + sorted table, and then entering the symbols in order in the sorted + table. The sorted table is work[], with that space being provided by + the caller. + + The length counts are used for other purposes as well, i.e. finding + the minimum and maximum length codes, determining if there are any + codes at all, checking for a valid set of lengths, and looking ahead + at length counts to determine sub-table sizes when building the + decoding tables. + */ + + /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ + for (len = 0; len <= MAXBITS; len++) + count[len] = 0; + for (sym = 0; sym < codes; sym++) + count[lens[sym]]++; + + /* bound code lengths, force root to be within code lengths */ + root = *bits; + for (max = MAXBITS; max >= 1; max--) + if (count[max] != 0) break; + if (root > max) root = max; + if (max == 0) return -1; /* no codes! */ + for (min = 1; min <= MAXBITS; min++) + if (count[min] != 0) break; + if (root < min) root = min; + + /* check for an over-subscribed or incomplete set of lengths */ + left = 1; + for (len = 1; len <= MAXBITS; len++) { + left <<= 1; + left -= count[len]; + if (left < 0) return -1; /* over-subscribed */ + } + if (left > 0 && (type == CODES || (codes - count[0] != 1))) + return -1; /* incomplete set */ + + /* generate offsets into symbol table for each length for sorting */ + offs[1] = 0; + for (len = 1; len < MAXBITS; len++) + offs[len + 1] = offs[len] + count[len]; + + /* sort symbols by length, by symbol order within each length */ + for (sym = 0; sym < codes; sym++) + if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; + + /* + Create and fill in decoding tables. In this loop, the table being + filled is at next and has curr index bits. The code being used is huff + with length len. That code is converted to an index by dropping drop + bits off of the bottom. For codes where len is less than drop + curr, + those top drop + curr - len bits are incremented through all values to + fill the table with replicated entries. + + root is the number of index bits for the root table. When len exceeds + root, sub-tables are created pointed to by the root entry with an index + of the low root bits of huff. This is saved in low to check for when a + new sub-table should be started. drop is zero when the root table is + being filled, and drop is root when sub-tables are being filled. + + When a new sub-table is needed, it is necessary to look ahead in the + code lengths to determine what size sub-table is needed. The length + counts are used for this, and so count[] is decremented as codes are + entered in the tables. + + used keeps track of how many table entries have been allocated from the + provided *table space. It is checked when a LENS table is being made + against the space in *table, ENOUGH, minus the maximum space needed by + the worst case distance code, MAXD. This should never happen, but the + sufficiency of ENOUGH has not been proven exhaustively, hence the check. + This assumes that when type == LENS, bits == 9. + + sym increments through all symbols, and the loop terminates when + all codes of length max, i.e. all codes, have been processed. This + routine permits incomplete codes, so another loop after this one fills + in the rest of the decoding tables with invalid code markers. + */ + + /* set up for code type */ + switch (type) { + case CODES: + base = extra = work; /* dummy value--not used */ + end = 19; + break; + case LENS: + base = lbase; + base -= 257; + extra = lext; + extra -= 257; + end = 256; + break; + default: /* DISTS */ + base = dbase; + extra = dext; + end = -1; + } + + /* initialize state for loop */ + huff = 0; /* starting code */ + sym = 0; /* starting code symbol */ + len = min; /* starting code length */ + next = *table; /* current table to fill in */ + curr = root; /* current table index bits */ + drop = 0; /* current bits to drop from code for index */ + low = (unsigned)(-1); /* trigger new sub-table when len > root */ + used = 1U << root; /* use root table entries */ + mask = used - 1; /* mask for comparing low */ + + /* check available table space */ + if (type == LENS && used >= ENOUGH - MAXD) + return 1; + + /* process all codes and make table entries */ + for (;;) { + /* create table entry */ + this.bits = (unsigned char)(len - drop); + if ((int)(work[sym]) < end) { + this.op = (unsigned char)0; + this.val = work[sym]; + } + else if ((int)(work[sym]) > end) { + this.op = (unsigned char)(extra[work[sym]]); + this.val = base[work[sym]]; + } + else { + this.op = (unsigned char)(32 + 64); /* end of block */ + this.val = 0; + } + + /* replicate for those indices with low len bits equal to huff */ + incr = 1U << (len - drop); + fill = 1U << curr; + do { + fill -= incr; + next[(huff >> drop) + fill] = this; + } while (fill != 0); + + /* backwards increment the len-bit code huff */ + incr = 1U << (len - 1); + while (huff & incr) + incr >>= 1; + if (incr != 0) { + huff &= incr - 1; + huff += incr; + } + else + huff = 0; + + /* go to next symbol, update count, len */ + sym++; + if (--(count[len]) == 0) { + if (len == max) break; + len = lens[work[sym]]; + } + + /* create new sub-table if needed */ + if (len > root && (huff & mask) != low) { + /* if first time, transition to sub-tables */ + if (drop == 0) + drop = root; + + /* increment past last table */ + next += 1U << curr; + + /* determine length of next table */ + curr = len - drop; + left = (int)(1 << curr); + while (curr + drop < max) { + left -= count[curr + drop]; + if (left <= 0) break; + curr++; + left <<= 1; + } + + /* check for enough space */ + used += 1U << curr; + if (type == LENS && used >= ENOUGH - MAXD) + return 1; + + /* point entry in root table to sub-table */ + low = huff & mask; + (*table)[low].op = (unsigned char)curr; + (*table)[low].bits = (unsigned char)root; + (*table)[low].val = (unsigned short)(next - *table); + } + } + + /* + Fill in rest of table for incomplete codes. This loop is similar to the + loop above in incrementing huff for table indices. It is assumed that + len is equal to curr + drop, so there is no loop needed to increment + through high index bits. When the current sub-table is filled, the loop + drops back to the root table to fill in any remaining entries there. + */ + this.op = (unsigned char)64; /* invalid code marker */ + this.bits = (unsigned char)(len - drop); + this.val = (unsigned short)0; + while (huff != 0) { + /* when done with sub-table, drop back to root table */ + if (drop != 0 && (huff & mask) != low) { + drop = 0; + len = root; + next = *table; + curr = root; + this.bits = (unsigned char)len; + } + + /* put invalid code marker in table */ + next[huff >> drop] = this; + + /* backwards increment the len-bit code huff */ + incr = 1U << (len - 1); + while (huff & incr) + incr >>= 1; + if (incr != 0) { + huff &= incr - 1; + huff += incr; + } + else + huff = 0; + } + + /* set return parameters */ + *table += used; + *bits = root; + return 0; + } Index: llvm/runtime/zlib/contrib/infback9/inftree9.h diff -c /dev/null llvm/runtime/zlib/contrib/infback9/inftree9.h:1.1 *** /dev/null Fri Feb 6 10:36:50 2004 --- llvm/runtime/zlib/contrib/infback9/inftree9.h Fri Feb 6 10:36:40 2004 *************** *** 0 **** --- 1,55 ---- + /* inftree9.h -- header to use inftree9.c + * Copyright (C) 1995-2003 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + + /* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + + /* Structure for decoding tables. Each entry provides either the + information needed to do the operation requested by the code that + indexed that table entry, or it provides a pointer to another + table that indexes more bits of the code. op indicates whether + the entry is a pointer to another table, a literal, a length or + distance, an end-of-block, or an invalid code. For a table + pointer, the low four bits of op is the number of index bits of + that table. For a length or distance, the low four bits of op + is the number of extra bits to get after the code. bits is + the number of bits in this code or part of the code to drop off + of the bit buffer. val is the actual byte to output in the case + of a literal, the base length or distance, or the offset from + the current table to the next table. Each entry is four bytes. */ + typedef struct { + unsigned char op; /* operation, extra bits, table bits */ + unsigned char bits; /* bits in this part of the code */ + unsigned short val; /* offset in table or code value */ + } code; + + /* op values as set by inflate_table(): + 00000000 - literal + 0000tttt - table link, tttt != 0 is the number of table index bits + 100eeeee - length or distance, eeee is the number of extra bits + 01100000 - end of block + 01000000 - invalid code + */ + + /* Maximum size of dynamic tree. The maximum found in a long but non- + exhaustive search was 1004 code structures (850 for length/literals + and 154 for distances, the latter actually the result of an + exhaustive search). The true maximum is not known, but the value + below is more than safe. */ + #define ENOUGH 1440 + #define MAXD 154 + + /* Type of code to build for inftable() */ + typedef enum { + CODES, + LENS, + DISTS + } codetype; + + extern int inflate_table9 OF((codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work)); From criswell at cs.uiuc.edu Fri Feb 6 10:43:04 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:43:04 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/blast/Makefile README blast.c blast.h test.pk test.txt Message-ID: <200402061636.KAA15461@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/blast: Makefile added (r1.1) README added (r1.1) blast.c added (r1.1) blast.h added (r1.1) test.pk added (r1.1) test.txt added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+528 -0) Index: llvm/runtime/zlib/contrib/blast/Makefile diff -c /dev/null llvm/runtime/zlib/contrib/blast/Makefile:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/blast/Makefile Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,8 ---- + blast: blast.c blast.h + cc -DTEST -o blast blast.c + + test: blast + blast < test.pk | cmp - test.txt + + clean: + rm -f blast blast.o Index: llvm/runtime/zlib/contrib/blast/README diff -c /dev/null llvm/runtime/zlib/contrib/blast/README:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/blast/README Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,4 ---- + Read blast.h for purpose and usage. + + Mark Adler + madler at alumni.caltech.edu Index: llvm/runtime/zlib/contrib/blast/blast.c diff -c /dev/null llvm/runtime/zlib/contrib/blast/blast.c:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/blast/blast.c Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,444 ---- + /* blast.c + * Copyright (C) 2003 Mark Adler + * For conditions of distribution and use, see copyright notice in blast.h + * version 1.1, 16 Feb 2003 + * + * blast.c decompresses data compressed by the PKWare Compression Library. + * This function provides functionality similar to the explode() function of + * the PKWare library, hence the name "blast". + * + * This decompressor is based on the excellent format description provided by + * Ben Rudiak-Gould in comp.compression on August 13, 2001. Interestingly, the + * example Ben provided in the post is incorrect. The distance 110001 should + * instead be 111000. When corrected, the example byte stream becomes: + * + * 00 04 82 24 25 8f 80 7f + * + * which decompresses to "AIAIAIAIAIAIA" (without the quotes). + */ + + /* + * Change history: + * + * 1.0 12 Feb 2003 - First version + * 1.1 16 Feb 2003 - Fixed distance check for > 4 GB uncompressed data + */ + + #include /* for setjmp(), longjmp(), and jmp_buf */ + #include "blast.h" /* prototype for blast() */ + + #define local static /* for local function definitions */ + #define MAXBITS 13 /* maximum code length */ + #define MAXWIN 4096 /* maximum window size */ + + /* input and output state */ + struct state { + /* input state */ + blast_in infun; /* input function provided by user */ + void *inhow; /* opaque information passed to infun() */ + unsigned char *in; /* next input location */ + unsigned left; /* available input at in */ + int bitbuf; /* bit buffer */ + int bitcnt; /* number of bits in bit buffer */ + + /* input limit error return state for bits() and decode() */ + jmp_buf env; + + /* output state */ + blast_out outfun; /* output function provided by user */ + void *outhow; /* opaque information passed to outfun() */ + unsigned next; /* index of next write location in out[] */ + int first; /* true to check distances (for first 4K) */ + unsigned char out[MAXWIN]; /* output buffer and sliding window */ + }; + + /* + * Return need bits from the input stream. This always leaves less than + * eight bits in the buffer. bits() works properly for need == 0. + * + * Format notes: + * + * - Bits are stored in bytes from the least significant bit to the most + * significant bit. Therefore bits are dropped from the bottom of the bit + * buffer, using shift right, and new bytes are appended to the top of the + * bit buffer, using shift left. + */ + local int bits(struct state *s, int need) + { + int val; /* bit accumulator */ + + /* load at least need bits into val */ + val = s->bitbuf; + while (s->bitcnt < need) { + if (s->left == 0) { + s->left = s->infun(s->inhow, &(s->in)); + if (s->left == 0) longjmp(s->env, 1); /* out of input */ + } + val |= (int)(*(s->in)++) << s->bitcnt; /* load eight bits */ + s->left--; + s->bitcnt += 8; + } + + /* drop need bits and update buffer, always zero to seven bits left */ + s->bitbuf = val >> need; + s->bitcnt -= need; + + /* return need bits, zeroing the bits above that */ + return val & ((1 << need) - 1); + } + + /* + * Huffman code decoding tables. count[1..MAXBITS] is the number of symbols of + * each length, which for a canonical code are stepped through in order. + * symbol[] are the symbol values in canonical order, where the number of + * entries is the sum of the counts in count[]. The decoding process can be + * seen in the function decode() below. + */ + struct huffman { + short *count; /* number of symbols of each length */ + short *symbol; /* canonically ordered symbols */ + }; + + /* + * Decode a code from the stream s using huffman table h. Return the symbol or + * a negative value if there is an error. If all of the lengths are zero, i.e. + * an empty code, or if the code is incomplete and an invalid code is received, + * then -9 is returned after reading MAXBITS bits. + * + * Format notes: + * + * - The codes as stored in the compressed data are bit-reversed relative to + * a simple integer ordering of codes of the same lengths. Hence below the + * bits are pulled from the compressed data one at a time and used to + * build the code value reversed from what is in the stream in order to + * permit simple integer comparisons for decoding. + * + * - The first code for the shortest length is all ones. Subsequent codes of + * the same length are simply integer decrements of the previous code. When + * moving up a length, a one bit is appended to the code. For a complete + * code, the last code of the longest length will be all zeros. To support + * this ordering, the bits pulled during decoding are inverted to apply the + * more "natural" ordering starting with all zeros and incrementing. + */ + local int decode(struct state *s, struct huffman *h) + { + int len; /* current number of bits in code */ + int code; /* len bits being decoded */ + int first; /* first code of length len */ + int count; /* number of codes of length len */ + int index; /* index of first code of length len in symbol table */ + int bitbuf; /* bits from stream */ + int left; /* bits left in next or left to process */ + short *next; /* next number of codes */ + + bitbuf = s->bitbuf; + left = s->bitcnt; + code = first = index = 0; + len = 1; + next = h->count + 1; + while (1) { + while (left--) { + code |= (bitbuf & 1) ^ 1; /* invert code */ + bitbuf >>= 1; + count = *next++; + if (code < first + count) { /* if length len, return symbol */ + s->bitbuf = bitbuf; + s->bitcnt = (s->bitcnt - len) & 7; + return h->symbol[index + (code - first)]; + } + index += count; /* else update for next length */ + first += count; + first <<= 1; + code <<= 1; + len++; + } + left = (MAXBITS+1) - len; + if (left == 0) break; + if (s->left == 0) { + s->left = s->infun(s->inhow, &(s->in)); + if (s->left == 0) longjmp(s->env, 1); /* out of input */ + } + bitbuf = *(s->in)++; + s->left--; + if (left > 8) left = 8; + } + return -9; /* ran out of codes */ + } + + /* + * Given a list of repeated code lengths rep[0..n-1], where each byte is a + * count (high four bits + 1) and a code length (low four bits), generate the + * list of code lengths. This compaction reduces the size of the object code. + * Then given the list of code lengths length[0..n-1] representing a canonical + * Huffman code for n symbols, construct the tables required to decode those + * codes. Those tables are the number of codes of each length, and the symbols + * sorted by length, retaining their original order within each length. The + * return value is zero for a complete code set, negative for an over- + * subscribed code set, and positive for an incomplete code set. The tables + * can be used if the return value is zero or positive, but they cannot be used + * if the return value is negative. If the return value is zero, it is not + * possible for decode() using that table to return an error--any stream of + * enough bits will resolve to a symbol. If the return value is positive, then + * it is possible for decode() using that table to return an error for received + * codes past the end of the incomplete lengths. + */ + local int construct(struct huffman *h, const unsigned char *rep, int n) + { + int symbol; /* current symbol when stepping through length[] */ + int len; /* current length when stepping through h->count[] */ + int left; /* number of possible codes left of current length */ + short offs[MAXBITS+1]; /* offsets in symbol table for each length */ + short length[256]; /* code lengths */ + + /* convert compact repeat counts into symbol bit length list */ + symbol = 0; + do { + len = *rep++; + left = (len >> 4) + 1; + len &= 15; + do { + length[symbol++] = len; + } while (--left); + } while (--n); + n = symbol; + + /* count number of codes of each length */ + for (len = 0; len <= MAXBITS; len++) + h->count[len] = 0; + for (symbol = 0; symbol < n; symbol++) + (h->count[length[symbol]])++; /* assumes lengths are within bounds */ + if (h->count[0] == n) /* no codes! */ + return 0; /* complete, but decode() will fail */ + + /* check for an over-subscribed or incomplete set of lengths */ + left = 1; /* one possible code of zero length */ + for (len = 1; len <= MAXBITS; len++) { + left <<= 1; /* one more bit, double codes left */ + left -= h->count[len]; /* deduct count from possible codes */ + if (left < 0) return left; /* over-subscribed--return negative */ + } /* left > 0 means incomplete */ + + /* generate offsets into symbol table for each length for sorting */ + offs[1] = 0; + for (len = 1; len < MAXBITS; len++) + offs[len + 1] = offs[len] + h->count[len]; + + /* + * put symbols in table sorted by length, by symbol order within each + * length + */ + for (symbol = 0; symbol < n; symbol++) + if (length[symbol] != 0) + h->symbol[offs[length[symbol]]++] = symbol; + + /* return zero for complete set, positive for incomplete set */ + return left; + } + + /* + * Decode PKWare Compression Library stream. + * + * Format notes: + * + * - First byte is 0 if literals are uncoded or 1 if they are coded. Second + * byte is 4, 5, or 6 for the number of extra bits in the distance code. + * This is the base-2 logarithm of the dictionary size minus six. + * + * - Compressed data is a combination of literals and length/distance pairs + * terminated by an end code. Literals are either Huffman coded or + * uncoded bytes. A length/distance pair is a coded length followed by a + * coded distance to represent a string that occurs earlier in the + * uncompressed data that occurs again at the current location. + * + * - A bit preceding a literal or length/distance pair indicates which comes + * next, 0 for literals, 1 for length/distance. + * + * - If literals are uncoded, then the next eight bits are the literal, in the + * normal bit order in th stream, i.e. no bit-reversal is needed. Similarly, + * no bit reversal is needed for either the length extra bits or the distance + * extra bits. + * + * - Literal bytes are simply written to the output. A length/distance pair is + * an instruction to copy previously uncompressed bytes to the output. The + * copy is from distance bytes back in the output stream, copying for length + * bytes. + * + * - Distances pointing before the beginning of the output data are not + * permitted. + * + * - Overlapped copies, where the length is greater than the distance, are + * allowed and common. For example, a distance of one and a length of 518 + * simply copies the last byte 518 times. A distance of four and a length of + * twelve copies the last four bytes three times. A simple forward copy + * ignoring whether the length is greater than the distance or not implements + * this correctly. + */ + local int decomp(struct state *s) + { + int lit; /* true if literals are coded */ + int dict; /* log2(dictionary size) - 6 */ + int symbol; /* decoded symbol, extra bits for distance */ + int len; /* length for copy */ + int dist; /* distance for copy */ + int copy; /* copy counter */ + unsigned char *from, *to; /* copy pointers */ + static int virgin = 1; /* build tables once */ + static short litcnt[MAXBITS+1], litsym[256]; /* litcode memory */ + static short lencnt[MAXBITS+1], lensym[16]; /* lencode memory */ + static short distcnt[MAXBITS+1], distsym[64]; /* distcode memory */ + static struct huffman litcode = {litcnt, litsym}; /* length code */ + static struct huffman lencode = {lencnt, lensym}; /* length code */ + static struct huffman distcode = {distcnt, distsym};/* distance code */ + /* bit lengths of literal codes */ + static const unsigned char litlen[] = { + 11, 124, 8, 7, 28, 7, 188, 13, 76, 4, 10, 8, 12, 10, 12, 10, 8, 23, 8, + 9, 7, 6, 7, 8, 7, 6, 55, 8, 23, 24, 12, 11, 7, 9, 11, 12, 6, 7, 22, 5, + 7, 24, 6, 11, 9, 6, 7, 22, 7, 11, 38, 7, 9, 8, 25, 11, 8, 11, 9, 12, + 8, 12, 5, 38, 5, 38, 5, 11, 7, 5, 6, 21, 6, 10, 53, 8, 7, 24, 10, 27, + 44, 253, 253, 253, 252, 252, 252, 13, 12, 45, 12, 45, 12, 61, 12, 45, + 44, 173}; + /* bit lengths of length codes 0..15 */ + static const unsigned char lenlen[] = {2, 35, 36, 53, 38, 23}; + /* bit lengths of distance codes 0..63 */ + static const unsigned char distlen[] = {2, 20, 53, 230, 247, 151, 248}; + static const short base[16] = { /* base for length codes */ + 3, 2, 4, 5, 6, 7, 8, 9, 10, 12, 16, 24, 40, 72, 136, 264}; + static const char extra[16] = { /* extra bits for length codes */ + 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8}; + + /* set up decoding tables (once--might not be thread-safe) */ + if (virgin) { + construct(&litcode, litlen, sizeof(litlen)); + construct(&lencode, lenlen, sizeof(lenlen)); + construct(&distcode, distlen, sizeof(distlen)); + virgin = 0; + } + + /* read header */ + lit = bits(s, 8); + if (lit > 1) return -1; + dict = bits(s, 8); + if (dict < 4 || dict > 6) return -2; + + /* decode literals and length/distance pairs */ + do { + if (bits(s, 1)) { + /* get length */ + symbol = decode(s, &lencode); + len = base[symbol] + bits(s, extra[symbol]); + if (len == 519) break; /* end code */ + + /* get distance */ + symbol = len == 2 ? 2 : dict; + dist = decode(s, &distcode) << symbol; + dist += bits(s, symbol); + dist++; + if (s->first && dist > s->next) + return -3; /* distance too far back */ + + /* copy length bytes from distance bytes back */ + do { + to = s->out + s->next; + from = to - dist; + copy = MAXWIN; + if (s->next < dist) { + from += copy; + copy = dist; + } + copy -= s->next; + if (copy > len) copy = len; + len -= copy; + s->next += copy; + do { + *to++ = *from++; + } while (--copy); + if (s->next == MAXWIN) { + if (s->outfun(s->outhow, s->out, s->next)) return 1; + s->next = 0; + s->first = 0; + } + } while (len != 0); + } + else { + /* get literal and write it */ + symbol = lit ? decode(s, &litcode) : bits(s, 8); + s->out[s->next++] = symbol; + if (s->next == MAXWIN) { + if (s->outfun(s->outhow, s->out, s->next)) return 1; + s->next = 0; + s->first = 0; + } + } + } while (1); + return 0; + } + + /* See comments in blast.h */ + int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow) + { + struct state s; /* input/output state */ + int err; /* return value */ + + /* initialize input state */ + s.infun = infun; + s.inhow = inhow; + s.left = 0; + s.bitbuf = 0; + s.bitcnt = 0; + + /* initialize output state */ + s.outfun = outfun; + s.outhow = outhow; + s.next = 0; + s.first = 1; + + /* return if bits() or decode() tries to read past available input */ + if (setjmp(s.env) != 0) /* if came back here via longjmp(), */ + err = 2; /* then skip decomp(), return error */ + else + err = decomp(&s); /* decompress */ + + /* write any leftover output and update the error code if needed */ + if (err != 1 && s.next && s.outfun(s.outhow, s.out, s.next) && err == 0) + err = 1; + return err; + } + + #ifdef TEST + /* Example of how to use blast() */ + #include + #include + + #define CHUNK 16384 + + local unsigned inf(void *how, unsigned char **buf) + { + static unsigned char hold[CHUNK]; + + *buf = hold; + return fread(hold, 1, CHUNK, (FILE *)how); + } + + local int outf(void *how, unsigned char *buf, unsigned len) + { + return fwrite(buf, 1, len, (FILE *)how) != len; + } + + /* Decompress a PKWare Compression Library stream from stdin to stdout */ + int main(void) + { + int ret, n; + + /* decompress to stdout */ + ret = blast(inf, stdin, outf, stdout); + if (ret != 0) fprintf(stderr, "blast error: %d\n", ret); + + /* see if there are any leftover bytes */ + n = 0; + while (getchar() != EOF) n++; + if (n) fprintf(stderr, "blast warning: %d unused bytes of input\n", n); + + /* return blast() error code */ + return ret; + } + #endif Index: llvm/runtime/zlib/contrib/blast/blast.h diff -c /dev/null llvm/runtime/zlib/contrib/blast/blast.h:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/blast/blast.h Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,71 ---- + /* blast.h -- interface for blast.c + Copyright (C) 2003 Mark Adler + version 1.1, 16 Feb 2003 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Mark Adler madler at alumni.caltech.edu + */ + + + /* + * blast() decompresses the PKWare Data Compression Library (DCL) compressed + * format. It provides the same functionality as the explode() function in + * that library. (Note: PKWare overused the "implode" verb, and the format + * used by their library implode() function is completely different and + * incompatible with the implode compression method supported by PKZIP.) + */ + + + typedef unsigned (*blast_in)(void *how, unsigned char **buf); + typedef int (*blast_out)(void *how, unsigned char *buf, unsigned len); + /* Definitions for input/output functions passed to blast(). See below for + * what the provided functions need to do. + */ + + + int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow); + /* Decompress input to output using the provided infun() and outfun() calls. + * On success, the return value of blast() is zero. If there is an error in + * the source data, i.e. it is not in the proper format, then a negative value + * is returned. If there is not enough input available or there is not enough + * output space, then a positive error is returned. + * + * The input function is invoked: len = infun(how, &buf), where buf is set by + * infun() to point to the input buffer, and infun() returns the number of + * available bytes there. If infun() returns zero, then blast() returns with + * an input error. (blast() only asks for input if it needs it.) inhow is for + * use by the application to pass an input descriptor to infun(), if desired. + * + * The output function is invoked: err = outfun(how, buf, len), where the bytes + * to be written are buf[0..len-1]. If err is not zero, then blast() returns + * with an output error. outfun() is always called with len <= 4096. outhow + * is for use by the application to pass an output descriptor to outfun(), if + * desired. + * + * The return codes are: + * + * 2: ran out of input before completing decompression + * 1: output error before completing decompression + * 0: successful decompression + * -1: literal flag not zero or one + * -2: dictionary size not in 4..6 + * -3: distance is too far back + * + * At the bottom of blast.c is an example program that uses blast() that can be + * compiled to produce a command-line decompression filter by defining TEST. + */ Index: llvm/runtime/zlib/contrib/blast/test.pk Index: llvm/runtime/zlib/contrib/blast/test.txt diff -c /dev/null llvm/runtime/zlib/contrib/blast/test.txt:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/blast/test.txt Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1 ---- + AIAIAIAIAIAIA \ No newline at end of file From criswell at cs.uiuc.edu Fri Feb 6 10:43:23 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:43:23 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/gzappend/gzappend.c Message-ID: <200402061636.KAA15462@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/gzappend: gzappend.c added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+500 -0) Index: llvm/runtime/zlib/contrib/gzappend/gzappend.c diff -c /dev/null llvm/runtime/zlib/contrib/gzappend/gzappend.c:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/gzappend/gzappend.c Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,500 ---- + /* gzappend -- command to append to a gzip file + + Copyright (C) 2003 Mark Adler, all rights reserved + version 1.1, 4 Nov 2003 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Mark Adler madler at alumni.caltech.edu + */ + + /* + * Change history: + * + * 1.0 19 Oct 2003 - First version + * 1.1 4 Nov 2003 - Expand and clarify some comments and notes + * - Add version and copyright to help + * - Send help to stdout instead of stderr + * - Add some preemptive typecasts + * - Add L to constants in lseek() calls + * - Remove some debugging information in error messages + * - Use new data_type definition for zlib 1.2.1 + * - Simplfy and unify file operations + * - Finish off gzip file in gztack() + * - Use deflatePrime() instead of adding empty blocks + * - Keep gzip file clean on appended file read errors + * - Use in-place rotate instead of auxiliary buffer + * (Why you ask? Because it was fun to write!) + */ + + /* + gzappend takes a gzip file and appends to it, compressing files from the + command line or data from stdin. The gzip file is written to directly, to + avoid copying that file, in case it's large. Note that this results in the + unfriendly behavior that if gzappend fails, the gzip file is corrupted. + + This program was written to illustrate the use of the new Z_BLOCK option of + zlib 1.2.1's inflate() function. This option returns from inflate() at each + block boundary to facilitate locating and modifying the last block bit at + the start of the final deflate block. Also whether using Z_BLOCK or not, + another required feature of zlib 1.2.1 is that inflate() now provides the + number of unusued bits in the last input byte used. gzappend will not work + with versions of zlib earlier than 1.2.1. + + gzappend first decompresses the gzip file internally, discarding all but + the last 32K of uncompressed data, and noting the location of the last block + bit and the number of unused bits in the last byte of the compressed data. + The gzip trailer containing the CRC-32 and length of the uncompressed data + is verified. This trailer will be later overwritten. + + Then the last block bit is cleared by seeking back in the file and rewriting + the byte that contains it. Seeking forward, the last byte of the compressed + data is saved along with the number of unused bits to initialize deflate. + + A deflate process is initialized, using the last 32K of the uncompressed + data from the gzip file to initialize the dictionary. If the total + uncompressed data was less than 32K, then all of it is used to initialize + the dictionary. The deflate output bit buffer is also initialized with the + last bits from the original deflate stream. From here on, the data to + append is simply compressed using deflate, and written to the gzip file. + When that is complete, the new CRC-32 and uncompressed length are written + as the trailer of the gzip file. + */ + + #include + #include + #include + #include + #include + #include "zlib.h" + + #define local static + #define LGCHUNK 14 + #define CHUNK (1U << LGCHUNK) + #define DSIZE 32768U + + /* print an error message and terminate with extreme prejudice */ + local void bye(char *msg1, char *msg2) + { + fprintf(stderr, "gzappend error: %s%s\n", msg1, msg2); + exit(1); + } + + /* return the greatest common divisor of a and b using Euclid's algorithm, + modified to be fast when one argument much greater than the other, and + coded to avoid unnecessary swapping */ + local unsigned gcd(unsigned a, unsigned b) + { + unsigned c; + + while (a && b) + if (a > b) { + c = b; + while (a - c >= c) + c <<= 1; + a -= c; + } + else { + c = a; + while (b - c >= c) + c <<= 1; + b -= c; + } + return a + b; + } + + /* rotate list[0..len-1] left by rot positions, in place */ + local void rotate(unsigned char *list, unsigned len, unsigned rot) + { + unsigned char tmp; + unsigned cycles; + unsigned char *start, *last, *to, *from; + + /* normalize rot and handle degenerate cases */ + if (len < 2) return; + if (rot >= len) rot %= len; + if (rot == 0) return; + + /* pointer to last entry in list */ + last = list + (len - 1); + + /* do simple left shift by one */ + if (rot == 1) { + tmp = *list; + memcpy(list, list + 1, len - 1); + *last = tmp; + return; + } + + /* do simple right shift by one */ + if (rot == len - 1) { + tmp = *last; + memmove(list + 1, list, len - 1); + *list = tmp; + return; + } + + /* otherwise do rotate as a set of cycles in place */ + cycles = gcd(len, rot); /* number of cycles */ + do { + start = from = list + cycles; /* start index is arbitrary */ + tmp = *from; /* save entry to be overwritten */ + for (;;) { + to = from; /* next step in cycle */ + from += rot; /* go right rot positions */ + if (from > last) from -= len; /* (pointer better not wrap) */ + if (from == start) break; /* all but one shifted */ + *to = *from; /* shift left */ + } + *to = tmp; /* complete the circle */ + } while (--cycles); + } + + /* structure for gzip file read operations */ + typedef struct { + int fd; /* file descriptor */ + int size; /* 1 << size is bytes in buf */ + unsigned left; /* bytes available at next */ + unsigned char *buf; /* buffer */ + unsigned char *next; /* next byte in buffer */ + char *name; /* file name for error messages */ + } file; + + /* reload buffer */ + local int readin(file *in) + { + int len; + + len = read(in->fd, in->buf, 1 << in->size); + if (len == -1) bye("error reading ", in->name); + in->left = (unsigned)len; + in->next = in->buf; + return len; + } + + /* read from file in, exit if end-of-file */ + local int readmore(file *in) + { + if (readin(in) == 0) bye("unexpected end of ", in->name); + return 0; + } + + #define read1(in) (in->left == 0 ? readmore(in) : 0, \ + in->left--, *(in->next)++) + + /* skip over n bytes of in */ + local void skip(file *in, unsigned n) + { + unsigned bypass; + + if (n > in->left) { + n -= in->left; + bypass = n & ~((1U << in->size) - 1); + if (bypass) { + if (lseek(in->fd, (off_t)bypass, SEEK_CUR) == -1) + bye("seeking ", in->name); + n -= bypass; + } + readmore(in); + if (n > in->left) + bye("unexpected end of ", in->name); + } + in->left -= n; + in->next += n; + } + + /* read a four-byte unsigned integer, little-endian, from in */ + unsigned long read4(file *in) + { + unsigned long val; + + val = read1(in); + val += (unsigned)read1(in) << 8; + val += (unsigned long)read1(in) << 16; + val += (unsigned long)read1(in) << 24; + return val; + } + + /* skip over gzip header */ + local void gzheader(file *in) + { + int flags; + unsigned n; + + if (read1(in) != 31 || read1(in) != 139) bye(in->name, " not a gzip file"); + if (read1(in) != 8) bye("unknown compression method in", in->name); + flags = read1(in); + if (flags & 0xe0) bye("unknown header flags set in", in->name); + skip(in, 6); + if (flags & 4) { + n = read1(in); + n += (unsigned)(read1(in)) << 8; + skip(in, n); + } + if (flags & 8) while (read1(in) != 0) ; + if (flags & 16) while (read1(in) != 0) ; + if (flags & 2) skip(in, 2); + } + + /* decompress gzip file "name", return strm with a deflate stream ready to + continue compression of the data in the gzip file, and return a file + descriptor pointing to where to write the compressed data -- the deflate + stream is initialized to compress using level "level" */ + local int gzscan(char *name, z_stream *strm, int level) + { + int ret, lastbit, left, full; + unsigned have; + unsigned long crc, tot; + unsigned char *window; + off_t lastoff, end; + file gz; + + /* open gzip file */ + gz.name = name; + gz.fd = open(name, O_RDWR, 0); + if (gz.fd == -1) bye("cannot open ", name); + gz.buf = malloc(CHUNK); + if (gz.buf == NULL) bye("out of memory", ""); + gz.size = LGCHUNK; + gz.left = 0; + + /* skip gzip header */ + gzheader(&gz); + + /* prepare to decompress */ + window = malloc(DSIZE); + if (window == NULL) bye("out of memory", ""); + strm->zalloc = Z_NULL; + strm->zfree = Z_NULL; + strm->opaque = Z_NULL; + ret = inflateInit2(strm, -15); + if (ret != Z_OK) bye("out of memory", " or library mismatch"); + + /* decompress the deflate stream, saving append information */ + lastbit = 0; + lastoff = lseek(gz.fd, 0L, SEEK_CUR) - gz.left; + left = 0; + strm->avail_in = gz.left; + strm->next_in = gz.next; + crc = crc32(0L, Z_NULL, 0); + have = full = 0; + do { + /* if needed, get more input */ + if (strm->avail_in == 0) { + readmore(&gz); + strm->avail_in = gz.left; + strm->next_in = gz.next; + } + + /* set up output to next available section of sliding window */ + strm->avail_out = DSIZE - have; + strm->next_out = window + have; + + /* inflate and check for errors */ + ret = inflate(strm, Z_BLOCK); + if (ret == Z_STREAM_ERROR) bye("internal stream error!", ""); + if (ret == Z_MEM_ERROR) bye("out of memory", ""); + if (ret == Z_DATA_ERROR) + bye("invalid compressed data--format violated in", name); + + /* update crc and sliding window pointer */ + crc = crc32(crc, window + have, DSIZE - have - strm->avail_out); + if (strm->avail_out) + have = DSIZE - strm->avail_out; + else { + have = 0; + full = 1; + } + + /* process end of block */ + if (strm->data_type & 128) { + if (strm->data_type & 64) + left = strm->data_type & 0x1f; + else { + lastbit = strm->data_type & 0x1f; + lastoff = lseek(gz.fd, 0L, SEEK_CUR) - strm->avail_in; + } + } + } while (ret != Z_STREAM_END); + inflateEnd(strm); + gz.left = strm->avail_in; + gz.next = strm->next_in; + + /* save the location of the end of the compressed data */ + end = lseek(gz.fd, 0L, SEEK_CUR) - gz.left; + + /* check gzip trailer and save total for deflate */ + if (crc != read4(&gz)) + bye("invalid compressed data--crc mismatch in ", name); + tot = strm->total_out; + if ((tot & 0xffffffffUL) != read4(&gz)) + bye("invalid compressed data--length mismatch in", name); + + /* if not at end of file, warn */ + if (gz.left || readin(&gz)) + fprintf(stderr, + "gzappend warning: junk at end of gzip file overwritten\n"); + + /* clear last block bit */ + lseek(gz.fd, lastoff - (lastbit != 0), SEEK_SET); + if (read(gz.fd, gz.buf, 1) != 1) bye("reading after seek on ", name); + *gz.buf = (unsigned char)(*gz.buf ^ (1 << ((8 - lastbit) & 7))); + lseek(gz.fd, -1L, SEEK_CUR); + if (write(gz.fd, gz.buf, 1) != 1) bye("writing after seek to ", name); + + /* if window wrapped, build dictionary from window by rotating */ + if (full) { + rotate(window, DSIZE, have); + have = DSIZE; + } + + /* set up deflate stream with window, crc, total_in, and leftover bits */ + ret = deflateInit2(strm, level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY); + if (ret != Z_OK) bye("out of memory", ""); + deflateSetDictionary(strm, window, have); + strm->adler = crc; + strm->total_in = tot; + if (left) { + lseek(gz.fd, --end, SEEK_SET); + if (read(gz.fd, gz.buf, 1) != 1) bye("reading after seek on ", name); + deflatePrime(strm, 8 - left, *gz.buf); + } + lseek(gz.fd, end, SEEK_SET); + + /* clean up and return */ + free(window); + free(gz.buf); + return gz.fd; + } + + /* append file "name" to gzip file gd using deflate stream strm -- if last + is true, then finish off the deflate stream at the end */ + local void gztack(char *name, int gd, z_stream *strm, int last) + { + int fd, len, ret; + unsigned left; + unsigned char *in, *out; + + /* open file to compress and append */ + fd = 0; + if (name != NULL) { + fd = open(name, O_RDONLY, 0); + if (fd == -1) + fprintf(stderr, "gzappend warning: %s not found, skipping ...\n", + name); + } + + /* allocate buffers */ + in = fd == -1 ? NULL : malloc(CHUNK); + out = malloc(CHUNK); + if (out == NULL) bye("out of memory", ""); + + /* compress input file and append to gzip file */ + do { + /* get more input */ + len = fd == -1 ? 0 : read(fd, in, CHUNK); + if (len == -1) { + fprintf(stderr, + "gzappend warning: error reading %s, skipping rest ...\n", + name); + len = 0; + } + strm->avail_in = (unsigned)len; + strm->next_in = in; + if (len) strm->adler = crc32(strm->adler, in, (unsigned)len); + + /* compress and write all available output */ + do { + strm->avail_out = CHUNK; + strm->next_out = out; + ret = deflate(strm, last && len == 0 ? Z_FINISH : Z_NO_FLUSH); + left = CHUNK - strm->avail_out; + while (left) { + len = write(gd, out + CHUNK - strm->avail_out - left, left); + if (len == -1) bye("writing gzip file", ""); + left -= (unsigned)len; + } + } while (strm->avail_out == 0 && ret != Z_STREAM_END); + } while (len != 0); + + /* write trailer after last entry */ + if (last) { + deflateEnd(strm); + out[0] = (unsigned char)(strm->adler); + out[1] = (unsigned char)(strm->adler >> 8); + out[2] = (unsigned char)(strm->adler >> 16); + out[3] = (unsigned char)(strm->adler >> 24); + out[4] = (unsigned char)(strm->total_in); + out[5] = (unsigned char)(strm->total_in >> 8); + out[6] = (unsigned char)(strm->total_in >> 16); + out[7] = (unsigned char)(strm->total_in >> 24); + len = 8; + do { + ret = write(gd, out + 8 - len, len); + if (ret == -1) bye("writing gzip file", ""); + len -= ret; + } while (len); + close(gd); + } + + /* clean up and return */ + free(out); + if (in != NULL) free(in); + if (fd > 0) close(fd); + } + + /* process the compression level option if present, scan the gzip file, and + append the specified files, or append the data from stdin if no other file + names are provided on the command line -- the gzip file must be writable + and seekable */ + int main(int argc, char **argv) + { + int gd, level; + z_stream strm; + + /* ignore command name */ + argv++; + + /* provide usage if no arguments */ + if (*argv == NULL) { + printf("gzappend 1.1 (4 Nov 2003) Copyright (C) 2003 Mark Adler\n"); + printf( + "usage: gzappend [-level] file.gz [ addthis [ andthis ... ]]\n"); + return 0; + } + + /* set compression level */ + level = Z_DEFAULT_COMPRESSION; + if (argv[0][0] == '-') { + if (argv[0][1] < '0' || argv[0][1] > '9' || argv[0][2] != 0) + bye("invalid compression level", ""); + level = argv[0][1] - '0'; + if (*++argv == NULL) bye("no gzip file name after options", ""); + } + + /* prepare to append to gzip file */ + gd = gzscan(*argv++, &strm, level); + + /* append files on command line, or from stdin if none */ + if (*argv == NULL) + gztack(NULL, gd, &strm, 1); + else + do { + gztack(*argv, gd, &strm, argv[1] == NULL); + } while (*++argv != NULL); + return 0; + } From criswell at cs.uiuc.edu Fri Feb 6 10:43:43 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 6 10:43:43 2004 Subject: [llvm-commits] CVS: llvm/runtime/zlib/contrib/ada/mtest.adb read.adb readme.txt test.adb zlib-streams.adb zlib-streams.ads zlib-thin.adb zlib-thin.ads zlib.adb zlib.ads zlib.gpr Message-ID: <200402061636.KAA15436@choi.cs.uiuc.edu> Changes in directory llvm/runtime/zlib/contrib/ada: mtest.adb added (r1.1) read.adb added (r1.1) readme.txt added (r1.1) test.adb added (r1.1) zlib-streams.adb added (r1.1) zlib-streams.ads added (r1.1) zlib-thin.adb added (r1.1) zlib-thin.ads added (r1.1) zlib.adb added (r1.1) zlib.ads added (r1.1) zlib.gpr added (r1.1) --- Log message: Initial checking of the zlib library. --- Diffs of the changes: (+2822 -0) Index: llvm/runtime/zlib/contrib/ada/mtest.adb diff -c /dev/null llvm/runtime/zlib/contrib/ada/mtest.adb:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/ada/mtest.adb Fri Feb 6 10:36:38 2004 *************** *** 0 **** --- 1,153 ---- + ---------------------------------------------------------------- + -- ZLib for Ada thick binding. -- + -- -- + -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- + -- -- + -- Open source license information is in the zlib.ads file. -- + ---------------------------------------------------------------- + -- Continuous test for ZLib multithreading. If the test is fail + -- Wou should provide thread safe allocation routines for the Z_Stream. + -- + -- $Id: mtest.adb,v 1.1 2004/02/06 16:36:38 criswell Exp $ + + with ZLib; + with Ada.Streams; + with Ada.Numerics.Discrete_Random; + with Ada.Text_IO; + with Ada.Exceptions; + with Ada.Task_Identification; + + procedure MTest is + use Ada.Streams; + use ZLib; + + Stop : Boolean := False; + + pragma Atomic (Stop); + + subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; + + package Random_Elements is + new Ada.Numerics.Discrete_Random (Visible_Symbols); + + task type Test_Task; + + task body Test_Task is + Buffer : Stream_Element_Array (1 .. 100_000); + Gen : Random_Elements.Generator; + + Buffer_First : Stream_Element_Offset; + Compare_First : Stream_Element_Offset; + + Deflate : Filter_Type; + Inflate : Filter_Type; + + procedure Further (Item : in Stream_Element_Array); + + procedure Read_Buffer + (Item : out Ada.Streams.Stream_Element_Array; + Last : out Ada.Streams.Stream_Element_Offset); + + ------------- + -- Further -- + ------------- + + procedure Further (Item : in Stream_Element_Array) is + + procedure Compare (Item : in Stream_Element_Array); + + ------------- + -- Compare -- + ------------- + + procedure Compare (Item : in Stream_Element_Array) is + Next_First : Stream_Element_Offset := Compare_First + Item'Length; + begin + if Buffer (Compare_First .. Next_First - 1) /= Item then + raise Program_Error; + end if; + + Compare_First := Next_First; + end Compare; + + procedure Compare_Write is new ZLib.Write (Write => Compare); + begin + Compare_Write (Inflate, Item, No_Flush); + end Further; + + ----------------- + -- Read_Buffer -- + ----------------- + + procedure Read_Buffer + (Item : out Ada.Streams.Stream_Element_Array; + Last : out Ada.Streams.Stream_Element_Offset) + is + Buff_Diff : Stream_Element_Offset := Buffer'Last - Buffer_First; + Next_First : Stream_Element_Offset; + begin + if Item'Length <= Buff_Diff then + Last := Item'Last; + + Next_First := Buffer_First + Item'Length; + + Item := Buffer (Buffer_First .. Next_First - 1); + + Buffer_First := Next_First; + else + Last := Item'First + Buff_Diff; + Item (Item'First .. Last) := Buffer (Buffer_First .. Buffer'Last); + Buffer_First := Buffer'Last + 1; + end if; + end Read_Buffer; + + procedure Translate is new Generic_Translate + (Data_In => Read_Buffer, + Data_Out => Further); + + begin + Random_Elements.Reset (Gen); + + Buffer := (others => 20); + + Main : loop + for J in Buffer'Range loop + Buffer (J) := Random_Elements.Random (Gen); + + Deflate_Init (Deflate); + Inflate_Init (Inflate); + + Buffer_First := Buffer'First; + Compare_First := Buffer'First; + + Translate (Deflate); + + if Compare_First /= Buffer'Last + 1 then + raise Program_Error; + end if; + + Ada.Text_IO.Put_Line + (Ada.Task_Identification.Image + (Ada.Task_Identification.Current_Task) + & Stream_Element_Offset'Image (J) + & ZLib.Count'Image (Total_Out (Deflate))); + + Close (Deflate); + Close (Inflate); + + exit Main when Stop; + end loop; + end loop Main; + exception + when E : others => + Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E)); + Stop := True; + end Test_Task; + + Test : array (1 .. 4) of Test_Task; + + pragma Unreferenced (Test); + + begin + null; + end MTest; Index: llvm/runtime/zlib/contrib/ada/read.adb diff -c /dev/null llvm/runtime/zlib/contrib/ada/read.adb:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/ada/read.adb Fri Feb 6 10:36:38 2004 *************** *** 0 **** --- 1,151 ---- + ---------------------------------------------------------------- + -- ZLib for Ada thick binding. -- + -- -- + -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- + -- -- + -- Open source license information is in the zlib.ads file. -- + ---------------------------------------------------------------- + + -- $Id: read.adb,v 1.1 2004/02/06 16:36:38 criswell Exp $ + + -- Test/demo program for the generic read interface. + + with Ada.Numerics.Discrete_Random; + with Ada.Streams; + with Ada.Text_IO; + + with ZLib; + + procedure Read is + + use Ada.Streams; + + ------------------------------------ + -- Test configuration parameters -- + ------------------------------------ + + File_Size : Stream_Element_Offset := 100_000; + + Continuous : constant Boolean := False; + -- If this constant is True, the test would be repeated again and again, + -- with increment File_Size for every iteration. + + Header : constant ZLib.Header_Type := ZLib.Default; + -- Do not use Header other than Default in ZLib versions 1.1.4 and older. + + Init_Random : constant := 8; + -- We are using the same random sequence, in case of we catch bug, + -- so we would be able to reproduce it. + + -- End -- + + Pack_Size : Stream_Element_Offset; + Offset : Stream_Element_Offset; + + Filter : ZLib.Filter_Type; + + subtype Visible_Symbols + is Stream_Element range 16#20# .. 16#7E#; + + package Random_Elements is new + Ada.Numerics.Discrete_Random (Visible_Symbols); + + Gen : Random_Elements.Generator; + Period : constant Stream_Element_Offset := 200; + -- Period constant variable for random generator not to be very random. + -- Bigger period, harder random. + + Read_Buffer : Stream_Element_Array (1 .. 2048); + Read_First : Stream_Element_Offset; + Read_Last : Stream_Element_Offset; + + procedure Reset; + + procedure Read + (Item : out Stream_Element_Array; + Last : out Stream_Element_Offset); + -- this procedure is for generic instantiation of + -- ZLib.Read + -- reading data from the File_In. + + procedure Read is new ZLib.Read (Read, Read_Buffer, Read_First, Read_Last); + + ---------- + -- Read -- + ---------- + + procedure Read + (Item : out Stream_Element_Array; + Last : out Stream_Element_Offset) is + begin + Last := Stream_Element_Offset'Min + (Item'Last, + Item'First + File_Size - Offset); + + for J in Item'First .. Last loop + if J < Item'First + Period then + Item (J) := Random_Elements.Random (Gen); + else + Item (J) := Item (J - Period); + end if; + + Offset := Offset + 1; + end loop; + end Read; + + ----------- + -- Reset -- + ----------- + + procedure Reset is + begin + Random_Elements.Reset (Gen, Init_Random); + Pack_Size := 0; + Offset := 1; + Read_First := Read_Buffer'Last + 1; + end Reset; + + begin + Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version); + + loop + for Level in ZLib.Compression_Level'Range loop + + Ada.Text_IO.Put ("Level =" + & ZLib.Compression_Level'Image (Level)); + + -- Deflate using generic instantiation. + + ZLib.Deflate_Init + (Filter, + Level, + Header => Header); + + Reset; + + Ada.Text_IO.Put + (Stream_Element_Offset'Image (File_Size) & " ->"); + + loop + declare + Buffer : Stream_Element_Array (1 .. 1024); + Last : Stream_Element_Offset; + begin + Read (Filter, Buffer, Last); + + Pack_Size := Pack_Size + Last - Buffer'First + 1; + + exit when Last < Buffer'Last; + end; + end loop; + + Ada.Text_IO.Put_Line (Stream_Element_Offset'Image (Pack_Size)); + + ZLib.Close (Filter); + end loop; + + exit when not Continuous; + + File_Size := File_Size + 1; + end loop; + end Read; Index: llvm/runtime/zlib/contrib/ada/readme.txt diff -c /dev/null llvm/runtime/zlib/contrib/ada/readme.txt:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/ada/readme.txt Fri Feb 6 10:36:38 2004 *************** *** 0 **** --- 1,52 ---- + + ZLib for Ada thick binding (ZLib.Ada) + Release 1.2 + + ZLib.Ada is a thick binding interface to the popular ZLib data + compression library, available at http://www.gzip.org/zlib/. + It provides Ada-style access to the ZLib C library. + + + Here are the main changes since ZLib.Ada 1.1: + + - The default header type has a name "Default" now. Auto is used only for + automatic GZip/ZLib header detection. + + - Added test for multitasking mtest.adb. + + - Added GNAT project file zlib.gpr. + + + How to build ZLib.Ada under GNAT + + You should have the ZLib library already build on your computer, before + building ZLib.Ada. Make the directory of ZLib.Ada sources current and + issue the command: + + gnatmake test -largs -L -lz + + Or use the GNAT project file build for GNAT 3.15 or later: + + gnatmake -Pzlib.gpr -L + + + How to build ZLib.Ada under Aonix ObjectAda for Win32 7.2.2 + + 1. Make a project with all *.ads and *.adb files from the distribution. + 2. Build the libz.a library from the ZLib C sources. + 3. Rename libz.a to z.lib. + 4. Add the library z.lib to the project. + 5. Add the libc.lib library from the ObjectAda distribution to the project. + 6. Build the executable using test.adb as a main procedure. + + + How to use ZLib.Ada + + The source files test.adb and read.adb are small demo programs that show + the main functionality of ZLib.Ada. + + The routines from the package specifications are commented. + + + Homepage: http://zlib-ada.sourceforge.net/ + Author: Dmitriy Anisimkov Index: llvm/runtime/zlib/contrib/ada/test.adb diff -c /dev/null llvm/runtime/zlib/contrib/ada/test.adb:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/ada/test.adb Fri Feb 6 10:36:38 2004 *************** *** 0 **** --- 1,463 ---- + ---------------------------------------------------------------- + -- ZLib for Ada thick binding. -- + -- -- + -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- + -- -- + -- Open source license information is in the zlib.ads file. -- + ---------------------------------------------------------------- + + -- $Id: test.adb,v 1.1 2004/02/06 16:36:38 criswell Exp $ + + -- The program has a few aims. + -- 1. Test ZLib.Ada95 thick binding functionality. + -- 2. Show the example of use main functionality of the ZLib.Ada95 binding. + -- 3. Build this program automatically compile all ZLib.Ada95 packages under + -- GNAT Ada95 compiler. + + with ZLib.Streams; + with Ada.Streams.Stream_IO; + with Ada.Numerics.Discrete_Random; + + with Ada.Text_IO; + + with Ada.Calendar; + + procedure Test is + + use Ada.Streams; + use Stream_IO; + + ------------------------------------ + -- Test configuration parameters -- + ------------------------------------ + + File_Size : Count := 100_000; + Continuous : constant Boolean := False; + + Header : constant ZLib.Header_Type := ZLib.Default; + -- ZLib.None; + -- ZLib.Auto; + -- ZLib.GZip; + -- Do not use Header other then Default in ZLib versions 1.1.4 + -- and older. + + Strategy : constant ZLib.Strategy_Type := ZLib.Default_Strategy; + Init_Random : constant := 10; + + -- End -- + + In_File_Name : constant String := "testzlib.in"; + -- Name of the input file + + Z_File_Name : constant String := "testzlib.zlb"; + -- Name of the compressed file. + + Out_File_Name : constant String := "testzlib.out"; + -- Name of the decompressed file. + + File_In : File_Type; + File_Out : File_Type; + File_Back : File_Type; + File_Z : ZLib.Streams.Stream_Type; + + Filter : ZLib.Filter_Type; + + Time_Stamp : Ada.Calendar.Time; + + procedure Generate_File; + -- Generate file of spetsified size with some random data. + -- The random data is repeatable, for the good compression. + + procedure Compare_Streams + (Left, Right : in out Root_Stream_Type'Class); + -- The procedure compearing data in 2 streams. + -- It is for compare data before and after compression/decompression. + + procedure Compare_Files (Left, Right : String); + -- Compare files. Based on the Compare_Streams. + + procedure Copy_Streams + (Source, Target : in out Root_Stream_Type'Class; + Buffer_Size : in Stream_Element_Offset := 1024); + -- Copying data from one stream to another. It is for test stream + -- interface of the library. + + procedure Data_In + (Item : out Stream_Element_Array; + Last : out Stream_Element_Offset); + -- this procedure is for generic instantiation of + -- ZLib.Generic_Translate. + -- reading data from the File_In. + + procedure Data_Out (Item : in Stream_Element_Array); + -- this procedure is for generic instantiation of + -- ZLib.Generic_Translate. + -- writing data to the File_Out. + + procedure Stamp; + -- Store the timestamp to the local variable. + + procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count); + -- Print the time statistic with the message. + + procedure Translate is new ZLib.Generic_Translate + (Data_In => Data_In, + Data_Out => Data_Out); + -- This procedure is moving data from File_In to File_Out + -- with compression or decompression, depend on initialization of + -- Filter parameter. + + ------------------- + -- Compare_Files -- + ------------------- + + procedure Compare_Files (Left, Right : String) is + Left_File, Right_File : File_Type; + begin + Open (Left_File, In_File, Left); + Open (Right_File, In_File, Right); + Compare_Streams (Stream (Left_File).all, Stream (Right_File).all); + Close (Left_File); + Close (Right_File); + end Compare_Files; + + --------------------- + -- Compare_Streams -- + --------------------- + + procedure Compare_Streams + (Left, Right : in out Ada.Streams.Root_Stream_Type'Class) + is + Left_Buffer, Right_Buffer : Stream_Element_Array (0 .. 16#FFF#); + Left_Last, Right_Last : Stream_Element_Offset; + begin + loop + Read (Left, Left_Buffer, Left_Last); + Read (Right, Right_Buffer, Right_Last); + + if Left_Last /= Right_Last then + Ada.Text_IO.Put_Line ("Compare error :" + & Stream_Element_Offset'Image (Left_Last) + & " /= " + & Stream_Element_Offset'Image (Right_Last)); + + raise Constraint_Error; + + elsif Left_Buffer (0 .. Left_Last) + /= Right_Buffer (0 .. Right_Last) + then + Ada.Text_IO.Put_Line ("ERROR: IN and OUT files is not equal."); + raise Constraint_Error; + + end if; + + exit when Left_Last < Left_Buffer'Last; + end loop; + end Compare_Streams; + + ------------------ + -- Copy_Streams -- + ------------------ + + procedure Copy_Streams + (Source, Target : in out Ada.Streams.Root_Stream_Type'Class; + Buffer_Size : in Stream_Element_Offset := 1024) + is + Buffer : Stream_Element_Array (1 .. Buffer_Size); + Last : Stream_Element_Offset; + begin + loop + Read (Source, Buffer, Last); + Write (Target, Buffer (1 .. Last)); + + exit when Last < Buffer'Last; + end loop; + end Copy_Streams; + + ------------- + -- Data_In -- + ------------- + + procedure Data_In + (Item : out Stream_Element_Array; + Last : out Stream_Element_Offset) is + begin + Read (File_In, Item, Last); + end Data_In; + + -------------- + -- Data_Out -- + -------------- + + procedure Data_Out (Item : in Stream_Element_Array) is + begin + Write (File_Out, Item); + end Data_Out; + + ------------------- + -- Generate_File -- + ------------------- + + procedure Generate_File is + subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; + + package Random_Elements is + new Ada.Numerics.Discrete_Random (Visible_Symbols); + + Gen : Random_Elements.Generator; + Buffer : Stream_Element_Array := (1 .. 77 => 16#20#) & 10; + + Buffer_Count : constant Count := File_Size / Buffer'Length; + -- Number of same buffers in the packet. + + Density : constant Count := 30; -- from 0 to Buffer'Length - 2; + + procedure Fill_Buffer (J, D : in Count); + -- Change the part of the buffer. + + ----------------- + -- Fill_Buffer -- + ----------------- + + procedure Fill_Buffer (J, D : in Count) is + begin + for K in 0 .. D loop + Buffer + (Stream_Element_Offset ((J + K) mod (Buffer'Length - 1) + 1)) + := Random_Elements.Random (Gen); + + end loop; + end Fill_Buffer; + + begin + Random_Elements.Reset (Gen, Init_Random); + + Create (File_In, Out_File, In_File_Name); + + Fill_Buffer (1, Buffer'Length - 2); + + for J in 1 .. Buffer_Count loop + Write (File_In, Buffer); + + Fill_Buffer (J, Density); + end loop; + + -- fill remain size. + + Write + (File_In, + Buffer + (1 .. Stream_Element_Offset + (File_Size - Buffer'Length * Buffer_Count))); + + Flush (File_In); + Close (File_In); + end Generate_File; + + --------------------- + -- Print_Statistic -- + --------------------- + + procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count) is + use Ada.Calendar; + use Ada.Text_IO; + + package Count_IO is new Integer_IO (ZLib.Count); + + Curr_Dur : Duration := Clock - Time_Stamp; + begin + Put (Msg); + + Set_Col (20); + Ada.Text_IO.Put ("size ="); + + Count_IO.Put + (Data_Size, + Width => Stream_IO.Count'Image (File_Size)'Length); + + Put_Line (" duration =" & Duration'Image (Curr_Dur)); + end Print_Statistic; + + ----------- + -- Stamp -- + ----------- + + procedure Stamp is + begin + Time_Stamp := Ada.Calendar.Clock; + end Stamp; + + begin + Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version); + + loop + Generate_File; + + for Level in ZLib.Compression_Level'Range loop + + Ada.Text_IO.Put_Line ("Level =" + & ZLib.Compression_Level'Image (Level)); + + -- Test generic interface. + Open (File_In, In_File, In_File_Name); + Create (File_Out, Out_File, Z_File_Name); + + Stamp; + + -- Deflate using generic instantiation. + + ZLib.Deflate_Init + (Filter => Filter, + Level => Level, + Strategy => Strategy, + Header => Header); + + Translate (Filter); + Print_Statistic ("Generic compress", ZLib.Total_Out (Filter)); + ZLib.Close (Filter); + + Close (File_In); + Close (File_Out); + + Open (File_In, In_File, Z_File_Name); + Create (File_Out, Out_File, Out_File_Name); + + Stamp; + + -- Inflate using generic instantiation. + + ZLib.Inflate_Init (Filter, Header => Header); + + Translate (Filter); + Print_Statistic ("Generic decompress", ZLib.Total_Out (Filter)); + + ZLib.Close (Filter); + + Close (File_In); + Close (File_Out); + + Compare_Files (In_File_Name, Out_File_Name); + + -- Test stream interface. + + -- Compress to the back stream. + + Open (File_In, In_File, In_File_Name); + Create (File_Back, Out_File, Z_File_Name); + + Stamp; + + ZLib.Streams.Create + (Stream => File_Z, + Mode => ZLib.Streams.Out_Stream, + Back => ZLib.Streams.Stream_Access + (Stream (File_Back)), + Back_Compressed => True, + Level => Level, + Strategy => Strategy, + Header => Header); + + Copy_Streams + (Source => Stream (File_In).all, + Target => File_Z); + + -- Flushing internal buffers to the back stream. + + ZLib.Streams.Flush (File_Z, ZLib.Finish); + + Print_Statistic ("Write compress", + ZLib.Streams.Write_Total_Out (File_Z)); + + ZLib.Streams.Close (File_Z); + + Close (File_In); + Close (File_Back); + + -- Compare reading from original file and from + -- decompression stream. + + Open (File_In, In_File, In_File_Name); + Open (File_Back, In_File, Z_File_Name); + + ZLib.Streams.Create + (Stream => File_Z, + Mode => ZLib.Streams.In_Stream, + Back => ZLib.Streams.Stream_Access + (Stream (File_Back)), + Back_Compressed => True, + Header => Header); + + Stamp; + Compare_Streams (Stream (File_In).all, File_Z); + + Print_Statistic ("Read decompress", + ZLib.Streams.Read_Total_Out (File_Z)); + + ZLib.Streams.Close (File_Z); + Close (File_In); + Close (File_Back); + + -- Compress by reading from compression stream. + + Open (File_Back, In_File, In_File_Name); + Create (File_Out, Out_File, Z_File_Name); + + ZLib.Streams.Create + (Stream => File_Z, + Mode => ZLib.Streams.In_Stream, + Back => ZLib.Streams.Stream_Access + (Stream (File_Back)), + Back_Compressed => False, + Level => Level, + Strategy => Strategy, + Header => Header); + + Stamp; + Copy_Streams + (Source => File_Z, + Target => Stream (File_Out).all); + + Print_Statistic ("Read compress", + ZLib.Streams.Read_Total_Out (File_Z)); + + ZLib.Streams.Close (File_Z); + + Close (File_Out); + Close (File_Back); + + -- Decompress to decompression stream. + + Open (File_In, In_File, Z_File_Name); + Create (File_Back, Out_File, Out_File_Name); + + ZLib.Streams.Create + (Stream => File_Z, + Mode => ZLib.Streams.Out_Stream, + Back => ZLib.Streams.Stream_Access + (Stream (File_Back)), + Back_Compressed => False, + Header => Header); + + Stamp; + + Copy_Streams + (Source => Stream (File_In).all, + Target => File_Z); + + Print_Statistic ("Write decompress", + ZLib.Streams.Write_Total_Out (File_Z)); + + ZLib.Streams.Close (File_Z); + Close (File_In); + Close (File_Back); + + Compare_Files (In_File_Name, Out_File_Name); + end loop; + + Ada.Text_IO.Put_Line (Count'Image (File_Size) & " Ok."); + + exit when not Continuous; + + File_Size := File_Size + 1; + end loop; + end Test; Index: llvm/runtime/zlib/contrib/ada/zlib-streams.adb diff -c /dev/null llvm/runtime/zlib/contrib/ada/zlib-streams.adb:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/ada/zlib-streams.adb Fri Feb 6 10:36:38 2004 *************** *** 0 **** --- 1,215 ---- + ---------------------------------------------------------------- + -- ZLib for Ada thick binding. -- + -- -- + -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- + -- -- + -- Open source license information is in the zlib.ads file. -- + ---------------------------------------------------------------- + + -- $Id: zlib-streams.adb,v 1.1 2004/02/06 16:36:38 criswell Exp $ + + with Ada.Unchecked_Deallocation; + + package body ZLib.Streams is + + ----------- + -- Close -- + ----------- + + procedure Close (Stream : in out Stream_Type) is + procedure Free is new Ada.Unchecked_Deallocation + (Stream_Element_Array, Buffer_Access); + begin + if Stream.Mode = Out_Stream or Stream.Mode = Duplex then + -- We should flush the data written by the writer. + + Flush (Stream, Finish); + + Close (Stream.Writer); + end if; + + if Stream.Mode = In_Stream or Stream.Mode = Duplex then + Close (Stream.Reader); + Free (Stream.Buffer); + end if; + end Close; + + ------------ + -- Create -- + ------------ + + procedure Create + (Stream : out Stream_Type; + Mode : in Stream_Mode; + Back : in Stream_Access; + Back_Compressed : in Boolean; + Level : in Compression_Level := Default_Compression; + Strategy : in Strategy_Type := Default_Strategy; + Header : in Header_Type := Default; + Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset + := Default_Buffer_Size; + Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset + := Default_Buffer_Size) + is + + subtype Buffer_Subtype is Stream_Element_Array (1 .. Read_Buffer_Size); + + procedure Init_Filter + (Filter : in out Filter_Type; + Compress : in Boolean); + + ----------------- + -- Init_Filter -- + ----------------- + + procedure Init_Filter + (Filter : in out Filter_Type; + Compress : in Boolean) is + begin + if Compress then + Deflate_Init + (Filter, Level, Strategy, Header => Header); + else + Inflate_Init (Filter, Header => Header); + end if; + end Init_Filter; + + begin + Stream.Back := Back; + Stream.Mode := Mode; + + if Mode = Out_Stream or Mode = Duplex then + Init_Filter (Stream.Writer, Back_Compressed); + Stream.Buffer_Size := Write_Buffer_Size; + else + Stream.Buffer_Size := 0; + end if; + + if Mode = In_Stream or Mode = Duplex then + Init_Filter (Stream.Reader, not Back_Compressed); + + Stream.Buffer := new Buffer_Subtype; + Stream.Rest_First := Stream.Buffer'Last + 1; + end if; + end Create; + + ----------- + -- Flush -- + ----------- + + procedure Flush + (Stream : in out Stream_Type; + Mode : in Flush_Mode := Sync_Flush) + is + Buffer : Stream_Element_Array (1 .. Stream.Buffer_Size); + Last : Stream_Element_Offset; + begin + loop + Flush (Stream.Writer, Buffer, Last, Mode); + + Ada.Streams.Write (Stream.Back.all, Buffer (1 .. Last)); + + exit when Last < Buffer'Last; + end loop; + end Flush; + + ---------- + -- Read -- + ---------- + + procedure Read + (Stream : in out Stream_Type; + Item : out Stream_Element_Array; + Last : out Stream_Element_Offset) + is + + procedure Read + (Item : out Stream_Element_Array; + Last : out Stream_Element_Offset); + + ---------- + -- Read -- + ---------- + + procedure Read + (Item : out Stream_Element_Array; + Last : out Stream_Element_Offset) is + begin + Ada.Streams.Read (Stream.Back.all, Item, Last); + end Read; + + procedure Read is new ZLib.Read + (Read => Read, + Buffer => Stream.Buffer.all, + Rest_First => Stream.Rest_First, + Rest_Last => Stream.Rest_Last); + + begin + Read (Stream.Reader, Item, Last); + end Read; + + ------------------- + -- Read_Total_In -- + ------------------- + + function Read_Total_In (Stream : in Stream_Type) return Count is + begin + return Total_In (Stream.Reader); + end Read_Total_In; + + -------------------- + -- Read_Total_Out -- + -------------------- + + function Read_Total_Out (Stream : in Stream_Type) return Count is + begin + return Total_Out (Stream.Reader); + end Read_Total_Out; + + ----------- + -- Write -- + ----------- + + procedure Write + (Stream : in out Stream_Type; + Item : in Stream_Element_Array) + is + + procedure Write (Item : in Stream_Element_Array); + + ----------- + -- Write -- + ----------- + + procedure Write (Item : in Stream_Element_Array) is + begin + Ada.Streams.Write (Stream.Back.all, Item); + end Write; + + procedure Write is new ZLib.Write + (Write => Write, + Buffer_Size => Stream.Buffer_Size); + + begin + Write (Stream.Writer, Item, No_Flush); + end Write; + + -------------------- + -- Write_Total_In -- + -------------------- + + function Write_Total_In (Stream : in Stream_Type) return Count is + begin + return Total_In (Stream.Writer); + end Write_Total_In; + + --------------------- + -- Write_Total_Out -- + --------------------- + + function Write_Total_Out (Stream : in Stream_Type) return Count is + begin + return Total_Out (Stream.Writer); + end Write_Total_Out; + + end ZLib.Streams; Index: llvm/runtime/zlib/contrib/ada/zlib-streams.ads diff -c /dev/null llvm/runtime/zlib/contrib/ada/zlib-streams.ads:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/ada/zlib-streams.ads Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,112 ---- + ---------------------------------------------------------------- + -- ZLib for Ada thick binding. -- + -- -- + -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- + -- -- + -- Open source license information is in the zlib.ads file. -- + ---------------------------------------------------------------- + + -- $Id: zlib-streams.ads,v 1.1 2004/02/06 16:36:39 criswell Exp $ + + package ZLib.Streams is + + type Stream_Mode is (In_Stream, Out_Stream, Duplex); + + type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class; + + type Stream_Type is + new Ada.Streams.Root_Stream_Type with private; + + procedure Read + (Stream : in out Stream_Type; + Item : out Ada.Streams.Stream_Element_Array; + Last : out Ada.Streams.Stream_Element_Offset); + + procedure Write + (Stream : in out Stream_Type; + Item : in Ada.Streams.Stream_Element_Array); + + procedure Flush + (Stream : in out Stream_Type; + Mode : in Flush_Mode := Sync_Flush); + -- Flush the written data to the back stream, + -- all data placed to the compressor is flushing to the Back stream. + -- Should not be used untill necessary, becouse it is decreasing + -- compression. + + function Read_Total_In (Stream : in Stream_Type) return Count; + pragma Inline (Read_Total_In); + -- Return total number of bytes read from back stream so far. + + function Read_Total_Out (Stream : in Stream_Type) return Count; + pragma Inline (Read_Total_Out); + -- Return total number of bytes read so far. + + function Write_Total_In (Stream : in Stream_Type) return Count; + pragma Inline (Write_Total_In); + -- Return total number of bytes written so far. + + function Write_Total_Out (Stream : in Stream_Type) return Count; + pragma Inline (Write_Total_Out); + -- Return total number of bytes written to the back stream. + + procedure Create + (Stream : out Stream_Type; + Mode : in Stream_Mode; + Back : in Stream_Access; + Back_Compressed : in Boolean; + Level : in Compression_Level := Default_Compression; + Strategy : in Strategy_Type := Default_Strategy; + Header : in Header_Type := Default; + Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset + := Default_Buffer_Size; + Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset + := Default_Buffer_Size); + -- Create the Comression/Decompression stream. + -- If mode is In_Stream then Write operation is disabled. + -- If mode is Out_Stream then Read operation is disabled. + + -- If Back_Compressed is true then + -- Data written to the Stream is compressing to the Back stream + -- and data read from the Stream is decompressed data from the Back stream. + + -- If Back_Compressed is false then + -- Data written to the Stream is decompressing to the Back stream + -- and data read from the Stream is compressed data from the Back stream. + + -- !!! When the Need_Header is False ZLib-Ada is using undocumented + -- ZLib 1.1.4 functionality to do not create/wait for ZLib headers. + + procedure Close (Stream : in out Stream_Type); + + private + + use Ada.Streams; + + type Buffer_Access is access all Stream_Element_Array; + + type Stream_Type + is new Root_Stream_Type with + record + Mode : Stream_Mode; + + Buffer : Buffer_Access; + Rest_First : Stream_Element_Offset; + Rest_Last : Stream_Element_Offset; + -- Buffer for Read operation. + -- We need to have this buffer in the record + -- becouse not all read data from back stream + -- could be processed during the read operation. + + Buffer_Size : Stream_Element_Offset; + -- Buffer size for write operation. + -- We do not need to have this buffer + -- in the record becouse all data could be + -- processed in the write operation. + + Back : Stream_Access; + Reader : Filter_Type; + Writer : Filter_Type; + end record; + + end ZLib.Streams; Index: llvm/runtime/zlib/contrib/ada/zlib-thin.adb diff -c /dev/null llvm/runtime/zlib/contrib/ada/zlib-thin.adb:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/ada/zlib-thin.adb Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,185 ---- + ---------------------------------------------------------------- + -- ZLib for Ada thick binding. -- + -- -- + -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- + -- -- + -- Open source license information is in the zlib.ads file. -- + ---------------------------------------------------------------- + + -- $Id: zlib-thin.adb,v 1.1 2004/02/06 16:36:39 criswell Exp $ + + package body ZLib.Thin is + + ZLIB_VERSION : constant Chars_Ptr := + Interfaces.C.Strings.New_String ("1.1.4"); + + Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit; + + -------------- + -- Avail_In -- + -------------- + + function Avail_In (Strm : in Z_Stream) return UInt is + begin + return Strm.Avail_In; + end Avail_In; + + --------------- + -- Avail_Out -- + --------------- + + function Avail_Out (Strm : in Z_Stream) return UInt is + begin + return Strm.Avail_Out; + end Avail_Out; + + ------------------ + -- Deflate_Init -- + ------------------ + + function Deflate_Init + (strm : in Z_Streamp; + level : in Int := Z_DEFAULT_COMPRESSION) + return Int is + begin + return deflateInit (strm, level, ZLIB_VERSION, Z_Stream_Size); + end Deflate_Init; + + function Deflate_Init + (strm : Z_Streamp; + level : Int; + method : Int; + windowBits : Int; + memLevel : Int; + strategy : Int) + return Int is + begin + return deflateInit2 + (strm, + level, + method, + windowBits, + memLevel, + strategy, + ZLIB_VERSION, + Z_Stream_Size); + end Deflate_Init; + + ------------------ + -- Inflate_Init -- + ------------------ + + function Inflate_Init (strm : Z_Streamp) return Int is + begin + return inflateInit (strm, ZLIB_VERSION, Z_Stream_Size); + end Inflate_Init; + + function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int is + begin + return inflateInit2 (strm, windowBits, ZLIB_VERSION, Z_Stream_Size); + end Inflate_Init; + + function Last_Error_Message (Strm : in Z_Stream) return String is + use Interfaces.C.Strings; + begin + if Strm.msg = Null_Ptr then + return ""; + else + return Value (Strm.msg); + end if; + end Last_Error_Message; + + ------------- + -- Need_In -- + ------------- + + function Need_In (strm : Z_Stream) return Boolean is + begin + return strm.Avail_In = 0; + end Need_In; + + -------------- + -- Need_Out -- + -------------- + + function Need_Out (strm : Z_Stream) return Boolean is + begin + return strm.Avail_Out = 0; + end Need_Out; + + ------------ + -- Set_In -- + ------------ + + procedure Set_In + (Strm : in out Z_Stream; + Buffer : in Byte_Access; + Size : in UInt) is + begin + Strm.Next_In := Buffer; + Strm.Avail_In := Size; + end Set_In; + + procedure Set_In + (Strm : in out Z_Stream; + Buffer : in Voidp; + Size : in UInt) is + begin + Set_In (Strm, Bytes.To_Pointer (Buffer), Size); + end Set_In; + + ------------------ + -- Set_Mem_Func -- + ------------------ + + procedure Set_Mem_Func + (Strm : in out Z_Stream; + Opaque : in Voidp; + Alloc : in alloc_func; + Free : in free_func) is + begin + Strm.opaque := Opaque; + Strm.zalloc := Alloc; + Strm.zfree := Free; + end Set_Mem_Func; + + ------------- + -- Set_Out -- + ------------- + + procedure Set_Out + (Strm : in out Z_Stream; + Buffer : in Byte_Access; + Size : in UInt) is + begin + Strm.Next_Out := Buffer; + Strm.Avail_Out := Size; + end Set_Out; + + procedure Set_Out + (Strm : in out Z_Stream; + Buffer : in Voidp; + Size : in UInt) is + begin + Set_Out (Strm, Bytes.To_Pointer (Buffer), Size); + end Set_Out; + + -------------- + -- Total_In -- + -------------- + + function Total_In (Strm : in Z_Stream) return ULong is + begin + return Strm.Total_In; + end Total_In; + + --------------- + -- Total_Out -- + --------------- + + function Total_Out (Strm : in Z_Stream) return ULong is + begin + return Strm.Total_Out; + end Total_Out; + + end ZLib.Thin; Index: llvm/runtime/zlib/contrib/ada/zlib-thin.ads diff -c /dev/null llvm/runtime/zlib/contrib/ada/zlib-thin.ads:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/ada/zlib-thin.ads Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,485 ---- + ---------------------------------------------------------------- + -- ZLib for Ada thick binding. -- + -- -- + -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- + -- -- + -- Open source license information is in the zlib.ads file. -- + ---------------------------------------------------------------- + + -- $Id: zlib-thin.ads,v 1.1 2004/02/06 16:36:39 criswell Exp $ + + with Interfaces.C.Strings; + with System.Address_To_Access_Conversions; + + private package ZLib.Thin is + + -- From zconf.h + + MAX_MEM_LEVEL : constant := 9; -- zconf.h:105 + -- zconf.h:105 + MAX_WBITS : constant := 15; -- zconf.h:115 + -- 32K LZ77 window + -- zconf.h:115 + SEEK_SET : constant := 8#0000#; -- zconf.h:244 + -- Seek from beginning of file. + -- zconf.h:244 + SEEK_CUR : constant := 1; -- zconf.h:245 + -- Seek from current position. + -- zconf.h:245 + SEEK_END : constant := 2; -- zconf.h:246 + -- Set file pointer to EOF plus "offset" + -- zconf.h:246 + + type Byte is new Interfaces.C.unsigned_char; -- 8 bits + -- zconf.h:214 + type UInt is new Interfaces.C.unsigned; -- 16 bits or more + -- zconf.h:216 + type Int is new Interfaces.C.int; + + type ULong is new Interfaces.C.unsigned; -- 32 bits or more + -- zconf.h:217 + subtype Chars_Ptr is Interfaces.C.Strings.chars_ptr; + + type ULong_Access is access ULong; + type Int_Access is access Int; + subtype Voidp is System.Address; -- zconf.h:232 + + package Bytes is new System.Address_To_Access_Conversions (Byte); + + subtype Byte_Access is Bytes.Object_Pointer; + + -- end from zconf + + Z_NO_FLUSH : constant := 8#0000#; -- zlib.h:125 + -- zlib.h:125 + Z_PARTIAL_FLUSH : constant := 1; -- zlib.h:126 + -- will be removed, use + -- Z_SYNC_FLUSH instead + -- zlib.h:126 + Z_SYNC_FLUSH : constant := 2; -- zlib.h:127 + -- zlib.h:127 + Z_FULL_FLUSH : constant := 3; -- zlib.h:128 + -- zlib.h:128 + Z_FINISH : constant := 4; -- zlib.h:129 + -- zlib.h:129 + Z_OK : constant := 8#0000#; -- zlib.h:132 + -- zlib.h:132 + Z_STREAM_END : constant := 1; -- zlib.h:133 + -- zlib.h:133 + Z_NEED_DICT : constant := 2; -- zlib.h:134 + -- zlib.h:134 + Z_ERRNO : constant := -1; -- zlib.h:135 + -- zlib.h:135 + Z_STREAM_ERROR : constant := -2; -- zlib.h:136 + -- zlib.h:136 + Z_DATA_ERROR : constant := -3; -- zlib.h:137 + -- zlib.h:137 + Z_MEM_ERROR : constant := -4; -- zlib.h:138 + -- zlib.h:138 + Z_BUF_ERROR : constant := -5; -- zlib.h:139 + -- zlib.h:139 + Z_VERSION_ERROR : constant := -6; -- zlib.h:140 + -- zlib.h:140 + Z_NO_COMPRESSION : constant := 8#0000#; -- zlib.h:145 + -- zlib.h:145 + Z_BEST_SPEED : constant := 1; -- zlib.h:146 + -- zlib.h:146 + Z_BEST_COMPRESSION : constant := 9; -- zlib.h:147 + -- zlib.h:147 + Z_DEFAULT_COMPRESSION : constant := -1; -- zlib.h:148 + -- zlib.h:148 + Z_FILTERED : constant := 1; -- zlib.h:151 + -- zlib.h:151 + Z_HUFFMAN_ONLY : constant := 2; -- zlib.h:152 + -- zlib.h:152 + Z_DEFAULT_STRATEGY : constant := 8#0000#; -- zlib.h:153 + -- zlib.h:153 + Z_BINARY : constant := 8#0000#; -- zlib.h:156 + -- zlib.h:156 + Z_ASCII : constant := 1; -- zlib.h:157 + -- zlib.h:157 + Z_UNKNOWN : constant := 2; -- zlib.h:158 + -- zlib.h:158 + Z_DEFLATED : constant := 8; -- zlib.h:161 + -- zlib.h:161 + Z_NULL : constant := 8#0000#; -- zlib.h:164 + -- for initializing zalloc, zfree, opaque + -- zlib.h:164 + type gzFile is new Voidp; -- zlib.h:646 + + type Z_Stream is private; + + type Z_Streamp is access all Z_Stream; -- zlib.h:89 + + type alloc_func is access function + (Opaque : Voidp; + Items : UInt; + Size : UInt) + return Voidp; -- zlib.h:63 + + type free_func is access procedure (opaque : Voidp; address : Voidp); + + function zlibVersion return Chars_Ptr; + + function Deflate (strm : Z_Streamp; flush : Int) return Int; + + function DeflateEnd (strm : Z_Streamp) return Int; + + function Inflate (strm : Z_Streamp; flush : Int) return Int; + + function InflateEnd (strm : Z_Streamp) return Int; + + function deflateSetDictionary + (strm : Z_Streamp; + dictionary : Byte_Access; + dictLength : UInt) + return Int; + + function deflateCopy (dest : Z_Streamp; source : Z_Streamp) return Int; + -- zlib.h:478 + + function deflateReset (strm : Z_Streamp) return Int; -- zlib.h:495 + + function deflateParams + (strm : Z_Streamp; + level : Int; + strategy : Int) + return Int; -- zlib.h:506 + + function inflateSetDictionary + (strm : Z_Streamp; + dictionary : Byte_Access; + dictLength : UInt) + return Int; -- zlib.h:548 + + function inflateSync (strm : Z_Streamp) return Int; -- zlib.h:565 + + function inflateReset (strm : Z_Streamp) return Int; -- zlib.h:580 + + function compress + (dest : Byte_Access; + destLen : ULong_Access; + source : Byte_Access; + sourceLen : ULong) + return Int; -- zlib.h:601 + + function compress2 + (dest : Byte_Access; + destLen : ULong_Access; + source : Byte_Access; + sourceLen : ULong; + level : Int) + return Int; -- zlib.h:615 + + function uncompress + (dest : Byte_Access; + destLen : ULong_Access; + source : Byte_Access; + sourceLen : ULong) + return Int; + + function gzopen (path : Chars_Ptr; mode : Chars_Ptr) return gzFile; + + function gzdopen (fd : Int; mode : Chars_Ptr) return gzFile; + + function gzsetparams + (file : gzFile; + level : Int; + strategy : Int) + return Int; + + function gzread + (file : gzFile; + buf : Voidp; + len : UInt) + return Int; + + function gzwrite + (file : in gzFile; + buf : in Voidp; + len : in UInt) + return Int; + + function gzprintf (file : in gzFile; format : in Chars_Ptr) return Int; + + function gzputs (file : in gzFile; s : in Chars_Ptr) return Int; + + function gzgets + (file : gzFile; + buf : Chars_Ptr; + len : Int) + return Chars_Ptr; + + function gzputc (file : gzFile; char : Int) return Int; + + function gzgetc (file : gzFile) return Int; + + function gzflush (file : gzFile; flush : Int) return Int; + + function gzseek + (file : gzFile; + offset : Int; + whence : Int) + return Int; + + function gzrewind (file : gzFile) return Int; + + function gztell (file : gzFile) return Int; + + function gzeof (file : gzFile) return Int; + + function gzclose (file : gzFile) return Int; + + function gzerror (file : gzFile; errnum : Int_Access) return Chars_Ptr; + + function adler32 + (adler : ULong; + buf : Byte_Access; + len : UInt) + return ULong; + + function crc32 + (crc : ULong; + buf : Byte_Access; + len : UInt) + return ULong; + + function deflateInit + (strm : Z_Streamp; + level : Int; + version : Chars_Ptr; + stream_size : Int) + return Int; + + function Deflate_Init + (strm : in Z_Streamp; + level : in Int := Z_DEFAULT_COMPRESSION) + return Int; + pragma Inline (Deflate_Init); + + function deflateInit2 + (strm : Z_Streamp; + level : Int; + method : Int; + windowBits : Int; + memLevel : Int; + strategy : Int; + version : Chars_Ptr; + stream_size : Int) + return Int; + + function Deflate_Init + (strm : Z_Streamp; + level : Int; + method : Int; + windowBits : Int; + memLevel : Int; + strategy : Int) + return Int; + pragma Inline (Deflate_Init); + + function inflateInit + (strm : Z_Streamp; + version : Chars_Ptr; + stream_size : Int) + return Int; + + function Inflate_Init (strm : Z_Streamp) return Int; + pragma Inline (Inflate_Init); + + function inflateInit2 + (strm : in Z_Streamp; + windowBits : in Int; + version : in Chars_Ptr; + stream_size : in Int) + return Int; + + function inflateBackInit + (strm : in Z_Streamp; + windowBits : in Int; + window : in Byte_Access; + version : in Chars_Ptr; + stream_size : in Int) + return Int; + -- Size of window have to be 2**windowBits. + + function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int; + pragma Inline (Inflate_Init); + + function zError (err : Int) return Chars_Ptr; + + function inflateSyncPoint (z : Z_Streamp) return Int; + + function get_crc_table return ULong_Access; + + -- Interface to the available fields of the z_stream structure. + -- The application must update next_in and avail_in when avail_in has + -- dropped to zero. It must update next_out and avail_out when avail_out + -- has dropped to zero. The application must initialize zalloc, zfree and + -- opaque before calling the init function. + + function Need_In (strm : in Z_Stream) return Boolean; + -- return true when we do not need to setup Next_In and Avail_In fields. + pragma Inline (Need_In); + + function Need_Out (strm : in Z_Stream) return Boolean; + -- return true when we do not need to setup Next_Out and Avail_Out field. + pragma Inline (Need_Out); + + procedure Set_In + (Strm : in out Z_Stream; + Buffer : in Byte_Access; + Size : in UInt); + pragma Inline (Set_In); + + procedure Set_In + (Strm : in out Z_Stream; + Buffer : in Voidp; + Size : in UInt); + pragma Inline (Set_In); + + procedure Set_Out + (Strm : in out Z_Stream; + Buffer : in Byte_Access; + Size : in UInt); + pragma Inline (Set_Out); + + procedure Set_Out + (Strm : in out Z_Stream; + Buffer : in Voidp; + Size : in UInt); + pragma Inline (Set_Out); + + procedure Set_Mem_Func + (Strm : in out Z_Stream; + Opaque : in Voidp; + Alloc : in alloc_func; + Free : in free_func); + pragma Inline (Set_Mem_Func); + + function Last_Error_Message (Strm : in Z_Stream) return String; + pragma Inline (Last_Error_Message); + + function Avail_Out (Strm : in Z_Stream) return UInt; + pragma Inline (Avail_Out); + + function Avail_In (Strm : in Z_Stream) return UInt; + pragma Inline (Avail_In); + + function Total_In (Strm : in Z_Stream) return ULong; + pragma Inline (Total_In); + + function Total_Out (Strm : in Z_Stream) return ULong; + pragma Inline (Total_Out); + + function inflateCopy + (dest : in Z_Streamp; + Source : in Z_Streamp) + return Int; + + function compressBound (Source_Len : in ULong) return ULong; + + function deflateBound + (Strm : in Z_Streamp; + Source_Len : in ULong) + return ULong; + + function gzungetc (C : in Int; File : in gzFile) return Int; + + function zlibCompileFlags return ULong; + + function deflatePrime + (strm : Z_Streamp; + bits : Int; + value : Int) + return Int; + + private + + type Z_Stream is record -- zlib.h:68 + Next_In : Byte_Access; -- next input byte + Avail_In : UInt := 0; -- number of bytes available at next_in + Total_In : ULong := 0; -- total nb of input bytes read so far + Next_Out : Byte_Access; -- next output byte should be put there + Avail_Out : UInt := 0; -- remaining free space at next_out + Total_Out : ULong := 0; -- total nb of bytes output so far + msg : Chars_Ptr; -- last error message, NULL if no error + state : Voidp; -- not visible by applications + zalloc : alloc_func := null; -- used to allocate the internal state + zfree : free_func := null; -- used to free the internal state + opaque : Voidp; -- private data object passed to + -- zalloc and zfree + data_type : Int; -- best guess about the data type: + -- ascii or binary + adler : ULong; -- adler32 value of the uncompressed + -- data + reserved : ULong; -- reserved for future use + end record; + + pragma Convention (C, Z_Stream); + + pragma Import (C, zlibVersion, "zlibVersion"); + pragma Import (C, Deflate, "deflate"); + pragma Import (C, DeflateEnd, "deflateEnd"); + pragma Import (C, Inflate, "inflate"); + pragma Import (C, InflateEnd, "inflateEnd"); + pragma Import (C, deflateSetDictionary, "deflateSetDictionary"); + pragma Import (C, deflateCopy, "deflateCopy"); + pragma Import (C, deflateReset, "deflateReset"); + pragma Import (C, deflateParams, "deflateParams"); + pragma Import (C, inflateSetDictionary, "inflateSetDictionary"); + pragma Import (C, inflateSync, "inflateSync"); + pragma Import (C, inflateReset, "inflateReset"); + pragma Import (C, compress, "compress"); + pragma Import (C, compress2, "compress2"); + pragma Import (C, uncompress, "uncompress"); + pragma Import (C, gzopen, "gzopen"); + pragma Import (C, gzdopen, "gzdopen"); + pragma Import (C, gzsetparams, "gzsetparams"); + pragma Import (C, gzread, "gzread"); + pragma Import (C, gzwrite, "gzwrite"); + pragma Import (C, gzprintf, "gzprintf"); + pragma Import (C, gzputs, "gzputs"); + pragma Import (C, gzgets, "gzgets"); + pragma Import (C, gzputc, "gzputc"); + pragma Import (C, gzgetc, "gzgetc"); + pragma Import (C, gzflush, "gzflush"); + pragma Import (C, gzseek, "gzseek"); + pragma Import (C, gzrewind, "gzrewind"); + pragma Import (C, gztell, "gztell"); + pragma Import (C, gzeof, "gzeof"); + pragma Import (C, gzclose, "gzclose"); + pragma Import (C, gzerror, "gzerror"); + pragma Import (C, adler32, "adler32"); + pragma Import (C, crc32, "crc32"); + pragma Import (C, deflateInit, "deflateInit_"); + pragma Import (C, inflateInit, "inflateInit_"); + pragma Import (C, deflateInit2, "deflateInit2_"); + pragma Import (C, inflateInit2, "inflateInit2_"); + pragma Import (C, zError, "zError"); + pragma Import (C, inflateSyncPoint, "inflateSyncPoint"); + pragma Import (C, get_crc_table, "get_crc_table"); + + -- added in zlib 1.2.1: + + pragma Import (C, inflateCopy, "inflateCopy"); + pragma Import (C, compressBound, "compressBound"); + pragma Import (C, deflateBound, "deflateBound"); + pragma Import (C, gzungetc, "gzungetc"); + pragma Import (C, zlibCompileFlags, "zlibCompileFlags"); + pragma Import (C, deflatePrime, "deflatePrime"); + + pragma Import (C, inflateBackInit, "inflateBackInit_"); + + -- I stopped binding the inflateBack routines, becouse realize that + -- it does not support zlib and gzip headers for now, and have no + -- symmetric deflateBack routines. + -- ZLib-Ada is symmetric regarding deflate/inflate data transformation + -- and has a similar generic callback interface for the + -- deflate/inflate transformation based on the regular Deflate/Inflate + -- routines. + + -- pragma Import (C, inflateBack, "inflateBack"); + -- pragma Import (C, inflateBackEnd, "inflateBackEnd"); + + end ZLib.Thin; Index: llvm/runtime/zlib/contrib/ada/zlib.adb diff -c /dev/null llvm/runtime/zlib/contrib/ada/zlib.adb:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/ada/zlib.adb Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,674 ---- + ---------------------------------------------------------------- + -- ZLib for Ada thick binding. -- + -- -- + -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- + -- -- + -- Open source license information is in the zlib.ads file. -- + ---------------------------------------------------------------- + + -- $Id: zlib.adb,v 1.1 2004/02/06 16:36:39 criswell Exp $ + + with Ada.Exceptions; + with Ada.Unchecked_Conversion; + with Ada.Unchecked_Deallocation; + + with Interfaces.C.Strings; + + with ZLib.Thin; + + package body ZLib is + + use type Thin.Int; + + type Z_Stream is new Thin.Z_Stream; + + type Return_Code_Enum is + (OK, + STREAM_END, + NEED_DICT, + ERRNO, + STREAM_ERROR, + DATA_ERROR, + MEM_ERROR, + BUF_ERROR, + VERSION_ERROR); + + type Flate_Step_Function is access + function (Strm : Thin.Z_Streamp; flush : Thin.Int) return Thin.Int; + pragma Convention (C, Flate_Step_Function); + + type Flate_End_Function is access + function (Ctrm : in Thin.Z_Streamp) return Thin.Int; + pragma Convention (C, Flate_End_Function); + + type Flate_Type is record + Step : Flate_Step_Function; + Done : Flate_End_Function; + end record; + + subtype Footer_Array is Stream_Element_Array (1 .. 8); + + Simple_GZip_Header : constant Stream_Element_Array (1 .. 10) + := (16#1f#, 16#8b#, -- Magic header + 16#08#, -- Z_DEFLATED + 16#00#, -- Flags + 16#00#, 16#00#, 16#00#, 16#00#, -- Time + 16#00#, -- XFlags + 16#03# -- OS code + ); + -- The simplest gzip header is not for informational, but just for + -- gzip format compatibility. + -- Note that some code below is using assumption + -- Simple_GZip_Header'Last > Footer_Array'Last, so do not make + -- Simple_GZip_Header'Last <= Footer_Array'Last. + + Return_Code : constant array (Thin.Int range <>) of Return_Code_Enum + := (0 => OK, + 1 => STREAM_END, + 2 => NEED_DICT, + -1 => ERRNO, + -2 => STREAM_ERROR, + -3 => DATA_ERROR, + -4 => MEM_ERROR, + -5 => BUF_ERROR, + -6 => VERSION_ERROR); + + Flate : constant array (Boolean) of Flate_Type + := (True => (Step => Thin.Deflate'Access, + Done => Thin.DeflateEnd'Access), + False => (Step => Thin.Inflate'Access, + Done => Thin.InflateEnd'Access)); + + Flush_Finish : constant array (Boolean) of Flush_Mode + := (True => Finish, False => No_Flush); + + procedure Raise_Error (Stream : Z_Stream); + pragma Inline (Raise_Error); + + procedure Raise_Error (Message : String); + pragma Inline (Raise_Error); + + procedure Check_Error (Stream : Z_Stream; Code : Thin.Int); + + procedure Free is new Ada.Unchecked_Deallocation + (Z_Stream, Z_Stream_Access); + + function To_Thin_Access is new Ada.Unchecked_Conversion + (Z_Stream_Access, Thin.Z_Streamp); + + procedure Translate_GZip + (Filter : in out Filter_Type; + In_Data : in Ada.Streams.Stream_Element_Array; + In_Last : out Ada.Streams.Stream_Element_Offset; + Out_Data : out Ada.Streams.Stream_Element_Array; + Out_Last : out Ada.Streams.Stream_Element_Offset; + Flush : in Flush_Mode); + -- Separate translate routine for make gzip header. + + procedure Translate_Auto + (Filter : in out Filter_Type; + In_Data : in Ada.Streams.Stream_Element_Array; + In_Last : out Ada.Streams.Stream_Element_Offset; + Out_Data : out Ada.Streams.Stream_Element_Array; + Out_Last : out Ada.Streams.Stream_Element_Offset; + Flush : in Flush_Mode); + -- translate routine without additional headers. + + ----------------- + -- Check_Error -- + ----------------- + + procedure Check_Error (Stream : Z_Stream; Code : Thin.Int) is + use type Thin.Int; + begin + if Code /= Thin.Z_OK then + Raise_Error + (Return_Code_Enum'Image (Return_Code (Code)) + & ": " & Last_Error_Message (Stream)); + end if; + end Check_Error; + + ----------- + -- Close -- + ----------- + + procedure Close + (Filter : in out Filter_Type; + Ignore_Error : in Boolean := False) + is + Code : Thin.Int; + begin + Code := Flate (Filter.Compression).Done + (To_Thin_Access (Filter.Strm)); + + Filter.Opened := False; + + if Ignore_Error or else Code = Thin.Z_OK then + Free (Filter.Strm); + else + declare + Error_Message : constant String + := Last_Error_Message (Filter.Strm.all); + begin + Free (Filter.Strm); + Ada.Exceptions.Raise_Exception + (ZLib_Error'Identity, + Return_Code_Enum'Image (Return_Code (Code)) + & ": " & Error_Message); + end; + end if; + end Close; + + ----------- + -- CRC32 -- + ----------- + + function CRC32 + (CRC : in Unsigned_32; + Data : in Ada.Streams.Stream_Element_Array) + return Unsigned_32 + is + use Thin; + begin + return Unsigned_32 (crc32 + (ULong (CRC), + Bytes.To_Pointer (Data'Address), + Data'Length)); + end CRC32; + + procedure CRC32 + (CRC : in out Unsigned_32; + Data : in Ada.Streams.Stream_Element_Array) is + begin + CRC := CRC32 (CRC, Data); + end CRC32; + + ------------------ + -- Deflate_Init -- + ------------------ + + procedure Deflate_Init + (Filter : in out Filter_Type; + Level : in Compression_Level := Default_Compression; + Strategy : in Strategy_Type := Default_Strategy; + Method : in Compression_Method := Deflated; + Window_Bits : in Window_Bits_Type := 15; + Memory_Level : in Memory_Level_Type := 8; + Header : in Header_Type := Default) + is + use type Thin.Int; + Win_Bits : Thin.Int := Thin.Int (Window_Bits); + begin + -- We allow ZLib to make header only in case of default header type. + -- Otherwise we would either do header by ourselfs, or do not do + -- header at all. + + if Header = None or else Header = GZip then + Win_Bits := -Win_Bits; + end if; + + -- For the GZip CRC calculation and make headers. + + if Header = GZip then + Filter.CRC := 0; + Filter.Offset := Simple_GZip_Header'First; + else + Filter.Offset := Simple_GZip_Header'Last + 1; + end if; + + Filter.Strm := new Z_Stream; + Filter.Compression := True; + Filter.Stream_End := False; + Filter.Opened := True; + Filter.Header := Header; + + if Thin.Deflate_Init + (To_Thin_Access (Filter.Strm), + Level => Thin.Int (Level), + method => Thin.Int (Method), + windowBits => Win_Bits, + memLevel => Thin.Int (Memory_Level), + strategy => Thin.Int (Strategy)) /= Thin.Z_OK + then + Raise_Error (Filter.Strm.all); + end if; + end Deflate_Init; + + ----------- + -- Flush -- + ----------- + + procedure Flush + (Filter : in out Filter_Type; + Out_Data : out Ada.Streams.Stream_Element_Array; + Out_Last : out Ada.Streams.Stream_Element_Offset; + Flush : in Flush_Mode) + is + No_Data : Stream_Element_Array := (1 .. 0 => 0); + Last : Stream_Element_Offset; + begin + Translate (Filter, No_Data, Last, Out_Data, Out_Last, Flush); + end Flush; + + ----------------------- + -- Generic_Translate -- + ----------------------- + + procedure Generic_Translate + (Filter : in out ZLib.Filter_Type; + In_Buffer_Size : Integer := Default_Buffer_Size; + Out_Buffer_Size : Integer := Default_Buffer_Size) + is + In_Buffer : Stream_Element_Array + (1 .. Stream_Element_Offset (In_Buffer_Size)); + Out_Buffer : Stream_Element_Array + (1 .. Stream_Element_Offset (Out_Buffer_Size)); + Last : Stream_Element_Offset; + In_Last : Stream_Element_Offset; + In_First : Stream_Element_Offset; + Out_Last : Stream_Element_Offset; + begin + Main : loop + Data_In (In_Buffer, Last); + + In_First := In_Buffer'First; + + loop + Translate + (Filter, + In_Buffer (In_First .. Last), + In_Last, + Out_Buffer, + Out_Last, + Flush_Finish (Last < In_Buffer'First)); + + Data_Out (Out_Buffer (Out_Buffer'First .. Out_Last)); + + exit Main when Stream_End (Filter); + + -- The end of in buffer. + exit when In_Last = Last; + + In_First := In_Last + 1; + end loop; + end loop Main; + + end Generic_Translate; + + ------------------ + -- Inflate_Init -- + ------------------ + + procedure Inflate_Init + (Filter : in out Filter_Type; + Window_Bits : in Window_Bits_Type := 15; + Header : in Header_Type := Default) + is + use type Thin.Int; + Win_Bits : Thin.Int := Thin.Int (Window_Bits); + + procedure Check_Version; + -- Check the latest header types compatibility. + + procedure Check_Version is + begin + if Version <= "1.1.4" then + Raise_Error + ("Inflate header type " & Header_Type'Image (Header) + & " incompatible with ZLib version " & Version); + end if; + end Check_Version; + + begin + case Header is + when None => + Check_Version; + + -- Inflate data without headers determined + -- by negative Win_Bits. + + Win_Bits := -Win_Bits; + when GZip => + Check_Version; + + -- Inflate gzip data defined by flag 16. + + Win_Bits := Win_Bits + 16; + when Auto => + Check_Version; + + -- Inflate with automatic detection + -- of gzip or native header defined by flag 32. + + Win_Bits := Win_Bits + 32; + when Default => null; + end case; + + Filter.Strm := new Z_Stream; + Filter.Compression := False; + Filter.Stream_End := False; + Filter.Opened := True; + Filter.Header := Header; + + if Thin.Inflate_Init + (To_Thin_Access (Filter.Strm), Win_Bits) /= Thin.Z_OK + then + Raise_Error (Filter.Strm.all); + end if; + end Inflate_Init; + + ----------------- + -- Raise_Error -- + ----------------- + + procedure Raise_Error (Message : String) is + begin + Ada.Exceptions.Raise_Exception (ZLib_Error'Identity, Message); + end Raise_Error; + + procedure Raise_Error (Stream : Z_Stream) is + begin + Raise_Error (Last_Error_Message (Stream)); + end Raise_Error; + + ---------- + -- Read -- + ---------- + + procedure Read + (Filter : in out Filter_Type; + Item : out Ada.Streams.Stream_Element_Array; + Last : out Ada.Streams.Stream_Element_Offset) + is + In_Last : Stream_Element_Offset; + Item_First : Ada.Streams.Stream_Element_Offset := Item'First; + + begin + pragma Assert (Rest_First in Buffer'First .. Buffer'Last + 1); + + loop + if Rest_First > Buffer'Last then + Read (Buffer, Rest_Last); + Rest_First := Buffer'First; + end if; + + pragma Assert (Rest_Last in Buffer'First - 1 .. Buffer'Last); + + Translate + (Filter => Filter, + In_Data => Buffer (Rest_First .. Rest_Last), + In_Last => In_Last, + Out_Data => Item (Item_First .. Item'Last), + Out_Last => Last, + Flush => Flush_Finish (Rest_Last < Rest_First)); + + Rest_First := In_Last + 1; + + exit when Last = Item'Last or else Stream_End (Filter); + + Item_First := Last + 1; + end loop; + end Read; + + ---------------- + -- Stream_End -- + ---------------- + + function Stream_End (Filter : in Filter_Type) return Boolean is + begin + if Filter.Header = GZip and Filter.Compression then + return Filter.Stream_End + and then Filter.Offset = Footer_Array'Last + 1; + else + return Filter.Stream_End; + end if; + end Stream_End; + + -------------- + -- Total_In -- + -------------- + + function Total_In (Filter : in Filter_Type) return Count is + begin + return Count (Thin.Total_In (To_Thin_Access (Filter.Strm).all)); + end Total_In; + + --------------- + -- Total_Out -- + --------------- + + function Total_Out (Filter : in Filter_Type) return Count is + begin + return Count (Thin.Total_Out (To_Thin_Access (Filter.Strm).all)); + end Total_Out; + + --------------- + -- Translate -- + --------------- + + procedure Translate + (Filter : in out Filter_Type; + In_Data : in Ada.Streams.Stream_Element_Array; + In_Last : out Ada.Streams.Stream_Element_Offset; + Out_Data : out Ada.Streams.Stream_Element_Array; + Out_Last : out Ada.Streams.Stream_Element_Offset; + Flush : in Flush_Mode) is + begin + if Filter.Header = GZip and then Filter.Compression then + Translate_GZip + (Filter => Filter, + In_Data => In_Data, + In_Last => In_Last, + Out_Data => Out_Data, + Out_Last => Out_Last, + Flush => Flush); + else + Translate_Auto + (Filter => Filter, + In_Data => In_Data, + In_Last => In_Last, + Out_Data => Out_Data, + Out_Last => Out_Last, + Flush => Flush); + end if; + end Translate; + + -------------------- + -- Translate_Auto -- + -------------------- + + procedure Translate_Auto + (Filter : in out Filter_Type; + In_Data : in Ada.Streams.Stream_Element_Array; + In_Last : out Ada.Streams.Stream_Element_Offset; + Out_Data : out Ada.Streams.Stream_Element_Array; + Out_Last : out Ada.Streams.Stream_Element_Offset; + Flush : in Flush_Mode) + is + use type Thin.Int; + Code : Thin.Int; + + begin + if Filter.Opened = False then + raise ZLib_Error; + end if; + + if Out_Data'Length = 0 then + raise Constraint_Error; + end if; + + Set_Out (Filter.Strm.all, Out_Data'Address, Out_Data'Length); + Set_In (Filter.Strm.all, In_Data'Address, In_Data'Length); + + Code := Flate (Filter.Compression).Step + (To_Thin_Access (Filter.Strm), + Thin.Int (Flush)); + + if Code = Thin.Z_STREAM_END then + Filter.Stream_End := True; + else + Check_Error (Filter.Strm.all, Code); + end if; + + In_Last := In_Data'Last + - Stream_Element_Offset (Avail_In (Filter.Strm.all)); + Out_Last := Out_Data'Last + - Stream_Element_Offset (Avail_Out (Filter.Strm.all)); + + end Translate_Auto; + + -------------------- + -- Translate_GZip -- + -------------------- + + procedure Translate_GZip + (Filter : in out Filter_Type; + In_Data : in Ada.Streams.Stream_Element_Array; + In_Last : out Ada.Streams.Stream_Element_Offset; + Out_Data : out Ada.Streams.Stream_Element_Array; + Out_Last : out Ada.Streams.Stream_Element_Offset; + Flush : in Flush_Mode) + is + Out_First : Stream_Element_Offset; + + procedure Add_Data (Data : in Stream_Element_Array); + -- Add data to stream from the Filter.Offset till necessary, + -- used for add gzip headr/footer. + + procedure Put_32 + (Item : in out Stream_Element_Array; + Data : in Unsigned_32); + pragma Inline (Put_32); + + -------------- + -- Add_Data -- + -------------- + + procedure Add_Data (Data : in Stream_Element_Array) is + Data_First : Stream_Element_Offset renames Filter.Offset; + Data_Last : Stream_Element_Offset; + Data_Len : Stream_Element_Offset; -- -1 + Out_Len : Stream_Element_Offset; -- -1 + begin + Out_First := Out_Last + 1; + + if Data_First > Data'Last then + return; + end if; + + Data_Len := Data'Last - Data_First; + Out_Len := Out_Data'Last - Out_First; + + if Data_Len <= Out_Len then + Out_Last := Out_First + Data_Len; + Data_Last := Data'Last; + else + Out_Last := Out_Data'Last; + Data_Last := Data_First + Out_Len; + end if; + + Out_Data (Out_First .. Out_Last) := Data (Data_First .. Data_Last); + + Data_First := Data_Last + 1; + Out_First := Out_Last + 1; + end Add_Data; + + ------------ + -- Put_32 -- + ------------ + + procedure Put_32 + (Item : in out Stream_Element_Array; + Data : in Unsigned_32) + is + D : Unsigned_32 := Data; + begin + for J in Item'First .. Item'First + 3 loop + Item (J) := Stream_Element (D and 16#FF#); + D := Shift_Right (D, 8); + end loop; + end Put_32; + + begin + Out_Last := Out_Data'First - 1; + + if not Filter.Stream_End then + Add_Data (Simple_GZip_Header); + + Translate_Auto + (Filter => Filter, + In_Data => In_Data, + In_Last => In_Last, + Out_Data => Out_Data (Out_First .. Out_Data'Last), + Out_Last => Out_Last, + Flush => Flush); + + CRC32 (Filter.CRC, In_Data (In_Data'First .. In_Last)); + + end if; + + if Filter.Stream_End and then Out_Last <= Out_Data'Last then + -- This detection method would work only when + -- Simple_GZip_Header'Last > Footer_Array'Last + + if Filter.Offset = Simple_GZip_Header'Last + 1 then + Filter.Offset := Footer_Array'First; + end if; + + declare + Footer : Footer_Array; + begin + Put_32 (Footer, Filter.CRC); + Put_32 (Footer (Footer'First + 4 .. Footer'Last), + Unsigned_32 (Total_In (Filter))); + Add_Data (Footer); + end; + end if; + end Translate_GZip; + + ------------- + -- Version -- + ------------- + + function Version return String is + begin + return Interfaces.C.Strings.Value (Thin.zlibVersion); + end Version; + + ----------- + -- Write -- + ----------- + + procedure Write + (Filter : in out Filter_Type; + Item : in Ada.Streams.Stream_Element_Array; + Flush : in Flush_Mode) + is + Buffer : Stream_Element_Array (1 .. Buffer_Size); + In_Last, Out_Last : Stream_Element_Offset; + In_First : Stream_Element_Offset := Item'First; + begin + if Item'Length = 0 and Flush = No_Flush then + return; + end if; + + loop + Translate + (Filter => Filter, + In_Data => Item (In_First .. Item'Last), + In_Last => In_Last, + Out_Data => Buffer, + Out_Last => Out_Last, + Flush => Flush); + + if Out_Last >= Buffer'First then + Write (Buffer (1 .. Out_Last)); + end if; + + exit when In_Last = Item'Last or Stream_End (Filter); + + In_First := In_Last + 1; + end loop; + end Write; + + end ZLib; Index: llvm/runtime/zlib/contrib/ada/zlib.ads diff -c /dev/null llvm/runtime/zlib/contrib/ada/zlib.ads:1.1 *** /dev/null Fri Feb 6 10:36:49 2004 --- llvm/runtime/zlib/contrib/ada/zlib.ads Fri Feb 6 10:36:39 2004 *************** *** 0 **** --- 1,311 ---- + ------------------------------------------------------------------------------ + -- ZLib for Ada thick binding. -- + -- -- + -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- + -- -- + -- This library is free software; you can redistribute it and/or modify -- + -- it under the terms of the GNU General Public License as published by -- + -- the Free Software Foundation; either version 2 of the License, or (at -- + -- your option) any later version. -- + -- -- + -- This library is distributed in the hope that it will be useful, but -- + -- WITHOUT ANY WARRANTY; without even the implied warranty of -- + -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- + -- General Public License for more details. -- + -- -- + -- You should have received a copy of the GNU General Public License -- + -- along with this library; if not, write to the Free Software Foundation, -- + -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- + -- -- + -- As a special exception, if other files instantiate generics from this -- + -- unit, or you link this unit with other files to produce an executable, -- + -- this unit does not by itself cause the resulting executable to be -- + -- covered by the GNU General Public License. This exception does not -- + -- however invalidate any other reasons why the executable file might be -- + -- covered by the GNU Public License. -- + ------------------------------------------------------------------------------ + + -- $Id: zlib.ads,v 1.1 2004/02/06 16:36:39 criswell Exp $ + + with Ada.Streams; + + with Interfaces; + + package ZLib is + + ZLib_Error : exception; + + type Compression_Level is new Integer range -1 .. 9; + + type Flush_Mode is private; + + type Compression_Method is private; + + type Window_Bits_Type is new Integer range 8 .. 15; + + type Memory_Level_Type is new Integer range 1 .. 9; + + type Unsigned_32 is new Interfaces.Unsigned_32; + + type Strategy_Type is private; + + type Header_Type is (None, Auto, Default, GZip); + -- Header type usage have a some limitation for inflate. + -- See comment for Inflate_Init. + + subtype Count is Ada.Streams.Stream_Element_Count; + + ---------------------------------- + -- Compression method constants -- + ---------------------------------- + + Deflated : constant Compression_Method; + -- Only one method allowed in this ZLib version. + + --------------------------------- + -- Compression level constants -- + --------------------------------- + + No_Compression : constant Compression_Level := 0; + Best_Speed : constant Compression_Level := 1; + Best_Compression : constant Compression_Level := 9; + Default_Compression : constant Compression_Level := -1; + + -------------------------- + -- Flush mode constants -- + -------------------------- + + No_Flush : constant Flush_Mode; + -- Regular way for compression, no flush + + Partial_Flush : constant Flush_Mode; + -- will be removed, use Z_SYNC_FLUSH instead + + Sync_Flush : constant Flush_Mode; + -- all pending output is flushed to the output buffer and the output + -- is aligned on a byte boundary, so that the decompressor can get all + -- input data available so far. (In particular avail_in is zero after the + -- call if enough output space has been provided before the call.) + -- Flushing may degrade compression for some compression algorithms and so + -- it should be used only when necessary. + + Full_Flush : constant Flush_Mode; + -- all output is flushed as with SYNC_FLUSH, and the compression state + -- is reset so that decompression can restart from this point if previous + -- compressed data has been damaged or if random access is desired. Using + -- FULL_FLUSH too often can seriously degrade the compression. + + Finish : constant Flush_Mode; + -- Just for tell the compressor that input data is complete. + + ------------------------------------ + -- Compression strategy constants -- + ------------------------------------ + + -- RLE stategy could be used only in version 1.2.0 and later. + + Filtered : constant Strategy_Type; + Huffman_Only : constant Strategy_Type; + RLE : constant Strategy_Type; + Default_Strategy : constant Strategy_Type; + + Default_Buffer_Size : constant := 4096; + + type Filter_Type is limited private; + -- The filter is for compression and for decompression. + -- The usage of the type is depend of its initialization. + + function Version return String; + pragma Inline (Version); + -- Return string representation of the ZLib version. + + procedure Deflate_Init + (Filter : in out Filter_Type; + Level : in Compression_Level := Default_Compression; + Strategy : in Strategy_Type := Default_Strategy; + Method : in Compression_Method := Deflated; + Window_Bits : in Window_Bits_Type := 15; + Memory_Level : in Memory_Level_Type := 8; + Header : in Header_Type := Default); + -- Compressor initialization. + -- When Header parameter is Auto or Default, then default zlib header + -- would be provided for compressed data. + -- When Header is GZip, then gzip header would be set instead of + -- default header. + -- When Header is None, no header would be set for compressed data. + + procedure Inflate_Init + (Filter : in out Filter_Type; + Window_Bits : in Window_Bits_Type := 15; + Header : in Header_Type := Default); + -- Decompressor initialization. + -- Default header type mean that ZLib default header is expecting in the + -- input compressed stream. + -- Header type None mean that n