MFC - tracking commit.

This commit is contained in:
Mark Murray 2013-10-04 07:00:59 +00:00
commit 3c59587daa
26 changed files with 267 additions and 88 deletions

View File

@ -119,8 +119,17 @@ namespace CallingConv {
SPIR_KERNEL = 76,
/// Intel_OCL_BI - Calling conventions for Intel OpenCL built-ins
Intel_OCL_BI = 77
Intel_OCL_BI = 77,
/// \brief The C convention as specified in the x86-64 supplement to the
/// System V ABI, used on most non-Windows systems.
X86_64_SysV = 78,
/// \brief The C convention as implemented on Windows/x86-64. This
/// convention differs from the more common \c X86_64_SysV convention
/// in a number of ways, most notably in that XMM registers used to pass
/// arguments are shadowed by GPRs, and vice versa.
X86_64_Win64 = 79
};
} // End CallingConv namespace

View File

@ -556,6 +556,8 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD(spir_kernel);
KEYWORD(spir_func);
KEYWORD(intel_ocl_bicc);
KEYWORD(x86_64_sysvcc);
KEYWORD(x86_64_win64cc);
KEYWORD(cc);
KEYWORD(c);

View File

@ -1337,6 +1337,8 @@ bool LLParser::ParseOptionalVisibility(unsigned &Res) {
/// ::= 'ptx_device'
/// ::= 'spir_func'
/// ::= 'spir_kernel'
/// ::= 'x86_64_sysvcc'
/// ::= 'x86_64_win64cc'
/// ::= 'cc' UINT
///
bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) {
@ -1357,6 +1359,8 @@ bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) {
case lltok::kw_spir_kernel: CC = CallingConv::SPIR_KERNEL; break;
case lltok::kw_spir_func: CC = CallingConv::SPIR_FUNC; break;
case lltok::kw_intel_ocl_bicc: CC = CallingConv::Intel_OCL_BI; break;
case lltok::kw_x86_64_sysvcc: CC = CallingConv::X86_64_SysV; break;
case lltok::kw_x86_64_win64cc: CC = CallingConv::X86_64_Win64; break;
case lltok::kw_cc: {
unsigned ArbitraryCC;
Lex.Lex();

View File

@ -84,12 +84,13 @@ namespace lltok {
kw_c,
kw_cc, kw_ccc, kw_fastcc, kw_coldcc,
kw_intel_ocl_bicc,
kw_intel_ocl_bicc,
kw_x86_stdcallcc, kw_x86_fastcallcc, kw_x86_thiscallcc,
kw_arm_apcscc, kw_arm_aapcscc, kw_arm_aapcs_vfpcc,
kw_msp430_intrcc,
kw_ptx_kernel, kw_ptx_device,
kw_spir_kernel, kw_spir_func,
kw_x86_64_sysvcc, kw_x86_64_win64cc,
// Attributes:
kw_attributes,

View File

@ -615,7 +615,10 @@ void DAGTypeLegalizer::RemapValue(SDValue &N) {
// replaced with other values.
RemapValue(I->second);
N = I->second;
assert(N.getNode()->getNodeId() != NewNode && "Mapped to new node!");
// Note that it is possible to have N.getNode()->getNodeId() == NewNode at
// this point because it is possible for a node to be put in the map before
// being processed.
}
}

View File

@ -81,6 +81,8 @@ static void PrintCallingConv(unsigned cc, raw_ostream &Out) {
case CallingConv::MSP430_INTR: Out << "msp430_intrcc"; break;
case CallingConv::PTX_Kernel: Out << "ptx_kernel"; break;
case CallingConv::PTX_Device: Out << "ptx_device"; break;
case CallingConv::X86_64_SysV: Out << "x86_64_sysvcc"; break;
case CallingConv::X86_64_Win64: Out << "x86_64_win64cc"; break;
}
}

View File

@ -156,6 +156,11 @@ def RetCC_X86_32 : CallingConv<[
def RetCC_X86_64 : CallingConv<[
// HiPE uses RetCC_X86_64_HiPE
CCIfCC<"CallingConv::HiPE", CCDelegateTo<RetCC_X86_64_HiPE>>,
// Handle explicit CC selection
CCIfCC<"CallingConv::X86_64_Win64", CCDelegateTo<RetCC_X86_Win64_C>>,
CCIfCC<"CallingConv::X86_64_SysV", CCDelegateTo<RetCC_X86_64_C>>,
// Mingw64 and native Win64 use Win64 CC
CCIfSubtarget<"isTargetWin64()", CCDelegateTo<RetCC_X86_Win64_C>>,
@ -489,6 +494,8 @@ def CC_X86_32 : CallingConv<[
def CC_X86_64 : CallingConv<[
CCIfCC<"CallingConv::GHC", CCDelegateTo<CC_X86_64_GHC>>,
CCIfCC<"CallingConv::HiPE", CCDelegateTo<CC_X86_64_HiPE>>,
CCIfCC<"CallingConv::X86_64_Win64", CCDelegateTo<CC_X86_Win64_C>>,
CCIfCC<"CallingConv::X86_64_SysV", CCDelegateTo<CC_X86_64_C>>,
// Mingw64 and native Win64 use Win64 CC
CCIfSubtarget<"isTargetWin64()", CCDelegateTo<CC_X86_Win64_C>>,

View File

@ -717,10 +717,11 @@ bool X86FastISel::X86SelectRet(const Instruction *I) {
CallingConv::ID CC = F.getCallingConv();
if (CC != CallingConv::C &&
CC != CallingConv::Fast &&
CC != CallingConv::X86_FastCall)
CC != CallingConv::X86_FastCall &&
CC != CallingConv::X86_64_SysV)
return false;
if (Subtarget->isTargetWin64())
if (Subtarget->isCallingConvWin64(CC))
return false;
// Don't handle popping bytes on return for now.
@ -1643,9 +1644,6 @@ bool X86FastISel::FastLowerArguments() {
if (!FuncInfo.CanLowerReturn)
return false;
if (Subtarget->isTargetWin64())
return false;
const Function *F = FuncInfo.Fn;
if (F->isVarArg())
return false;
@ -1653,7 +1651,10 @@ bool X86FastISel::FastLowerArguments() {
CallingConv::ID CC = F->getCallingConv();
if (CC != CallingConv::C)
return false;
if (Subtarget->isCallingConvWin64(CC))
return false;
if (!Subtarget->is64Bit())
return false;
@ -1757,8 +1758,10 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) {
// Handle only C and fastcc calling conventions for now.
ImmutableCallSite CS(CI);
CallingConv::ID CC = CS.getCallingConv();
bool isWin64 = Subtarget->isCallingConvWin64(CC);
if (CC != CallingConv::C && CC != CallingConv::Fast &&
CC != CallingConv::X86_FastCall)
CC != CallingConv::X86_FastCall && CC != CallingConv::X86_64_Win64 &&
CC != CallingConv::X86_64_SysV)
return false;
// fastcc with -tailcallopt is intended to provide a guaranteed
@ -1772,7 +1775,7 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) {
// Don't know how to handle Win64 varargs yet. Nothing special needed for
// x86-32. Special handling for x86-64 is implemented.
if (isVarArg && Subtarget->isTargetWin64())
if (isVarArg && isWin64)
return false;
// Fast-isel doesn't know about callee-pop yet.
@ -1902,7 +1905,7 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) {
I->getParent()->getContext());
// Allocate shadow area for Win64
if (Subtarget->isTargetWin64())
if (isWin64)
CCInfo.AllocateStack(32, 8);
CCInfo.AnalyzeCallOperands(ArgVTs, ArgFlags, CC_X86);
@ -2016,7 +2019,7 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) {
X86::EBX).addReg(Base);
}
if (Subtarget->is64Bit() && isVarArg && !Subtarget->isTargetWin64()) {
if (Subtarget->is64Bit() && isVarArg && !isWin64) {
// Count the number of XMM registers allocated.
static const uint16_t XMMArgRegs[] = {
X86::XMM0, X86::XMM1, X86::XMM2, X86::XMM3,
@ -2085,7 +2088,7 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) {
if (Subtarget->isPICStyleGOT())
MIB.addReg(X86::EBX, RegState::Implicit);
if (Subtarget->is64Bit() && isVarArg && !Subtarget->isTargetWin64())
if (Subtarget->is64Bit() && isVarArg && !isWin64)
MIB.addReg(X86::AL, RegState::Implicit);
// Add implicit physical register uses to the call.

View File

@ -1883,13 +1883,19 @@ static bool IsTailCallConvention(CallingConv::ID CC) {
CC == CallingConv::HiPE);
}
/// \brief Return true if the calling convention is a C calling convention.
static bool IsCCallConvention(CallingConv::ID CC) {
return (CC == CallingConv::C || CC == CallingConv::X86_64_Win64 ||
CC == CallingConv::X86_64_SysV);
}
bool X86TargetLowering::mayBeEmittedAsTailCall(CallInst *CI) const {
if (!CI->isTailCall() || getTargetMachine().Options.DisableTailCalls)
return false;
CallSite CS(CI);
CallingConv::ID CalleeCC = CS.getCallingConv();
if (!IsTailCallConvention(CalleeCC) && CalleeCC != CallingConv::C)
if (!IsTailCallConvention(CalleeCC) && !IsCCallConvention(CalleeCC))
return false;
return true;
@ -1964,7 +1970,7 @@ X86TargetLowering::LowerFormalArguments(SDValue Chain,
MachineFrameInfo *MFI = MF.getFrameInfo();
bool Is64Bit = Subtarget->is64Bit();
bool IsWindows = Subtarget->isTargetWindows();
bool IsWin64 = Subtarget->isTargetWin64();
bool IsWin64 = Subtarget->isCallingConvWin64(CallConv);
assert(!(isVarArg && IsTailCallConvention(CallConv)) &&
"Var args not supported with calling convention fastcc, ghc or hipe");
@ -1975,9 +1981,8 @@ X86TargetLowering::LowerFormalArguments(SDValue Chain,
ArgLocs, *DAG.getContext());
// Allocate shadow area for Win64
if (IsWin64) {
if (IsWin64)
CCInfo.AllocateStack(32, 8);
}
CCInfo.AnalyzeFormalArguments(Ins, CC_X86);
@ -2290,7 +2295,7 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
MachineFunction &MF = DAG.getMachineFunction();
bool Is64Bit = Subtarget->is64Bit();
bool IsWin64 = Subtarget->isTargetWin64();
bool IsWin64 = Subtarget->isCallingConvWin64(CallConv);
bool IsWindows = Subtarget->isTargetWindows();
StructReturnType SR = callIsStructReturn(Outs);
bool IsSibcall = false;
@ -2323,9 +2328,8 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
ArgLocs, *DAG.getContext());
// Allocate shadow area for Win64
if (IsWin64) {
if (IsWin64)
CCInfo.AllocateStack(32, 8);
}
CCInfo.AnalyzeCallOperands(Outs, CC_X86);
@ -2831,13 +2835,12 @@ X86TargetLowering::IsEligibleForTailCallOptimization(SDValue Callee,
const SmallVectorImpl<SDValue> &OutVals,
const SmallVectorImpl<ISD::InputArg> &Ins,
SelectionDAG &DAG) const {
if (!IsTailCallConvention(CalleeCC) &&
CalleeCC != CallingConv::C)
if (!IsTailCallConvention(CalleeCC) && !IsCCallConvention(CalleeCC))
return false;
// If -tailcallopt is specified, make fastcc functions tail-callable.
const MachineFunction &MF = DAG.getMachineFunction();
const Function *CallerF = DAG.getMachineFunction().getFunction();
const Function *CallerF = MF.getFunction();
// If the function return type is x86_fp80 and the callee return type is not,
// then the FP_EXTEND of the call result is not a nop. It's not safe to
@ -2847,6 +2850,8 @@ X86TargetLowering::IsEligibleForTailCallOptimization(SDValue Callee,
CallingConv::ID CallerCC = CallerF->getCallingConv();
bool CCMatch = CallerCC == CalleeCC;
bool IsCalleeWin64 = Subtarget->isCallingConvWin64(CalleeCC);
bool IsCallerWin64 = Subtarget->isCallingConvWin64(CallerCC);
if (getTargetMachine().Options.GuaranteedTailCallOpt) {
if (IsTailCallConvention(CalleeCC) && CCMatch)
@ -2878,7 +2883,7 @@ X86TargetLowering::IsEligibleForTailCallOptimization(SDValue Callee,
// Optimizing for varargs on Win64 is unlikely to be safe without
// additional testing.
if (Subtarget->isTargetWin64())
if (IsCalleeWin64 || IsCallerWin64)
return false;
SmallVector<CCValAssign, 16> ArgLocs;
@ -2953,9 +2958,8 @@ X86TargetLowering::IsEligibleForTailCallOptimization(SDValue Callee,
getTargetMachine(), ArgLocs, *DAG.getContext());
// Allocate shadow area for Win64
if (Subtarget->isTargetWin64()) {
if (IsCalleeWin64)
CCInfo.AllocateStack(32, 8);
}
CCInfo.AnalyzeCallOperands(Outs, CC_X86);
if (CCInfo.getNextStackOffset()) {

View File

@ -338,7 +338,13 @@ public:
}
bool isPICStyleStubAny() const {
return PICStyle == PICStyles::StubDynamicNoPIC ||
PICStyle == PICStyles::StubPIC; }
PICStyle == PICStyles::StubPIC;
}
bool isCallingConvWin64(CallingConv::ID CC) const {
return (isTargetWin64() && CC != CallingConv::X86_64_SysV) ||
CC == CallingConv::X86_64_Win64;
}
/// ClassifyGlobalReference - Classify a global variable reference for the
/// current subtarget according to how we should reference it in a non-pcrel

View File

@ -2683,6 +2683,8 @@ enum CXCallingConv {
CXCallingConv_AAPCS_VFP = 7,
CXCallingConv_PnaclCall = 8,
CXCallingConv_IntelOclBicc = 9,
CXCallingConv_X86_64Win64 = 10,
CXCallingConv_X86_64SysV = 11,
CXCallingConv_Invalid = 100,
CXCallingConv_Unexposed = 200

View File

@ -3335,7 +3335,9 @@ public:
attr_thiscall,
attr_pascal,
attr_pnaclcall,
attr_inteloclbicc
attr_inteloclbicc,
attr_ms_abi,
attr_sysv_abi
};
private:

View File

@ -417,6 +417,10 @@ def MayAlias : InheritableAttr {
let Spellings = [GNU<"may_alias">, CXX11<"gnu", "may_alias">];
}
def MSABI : InheritableAttr {
let Spellings = [GNU<"ms_abi">, CXX11<"gnu", "ms_abi">];
}
def MSP430Interrupt : InheritableAttr {
let Spellings = [];
let Args = [UnsignedArgument<"Number">];
@ -664,6 +668,10 @@ def StdCall : InheritableAttr {
Keyword<"__stdcall">, Keyword<"_stdcall">];
}
def SysVABI : InheritableAttr {
let Spellings = [GNU<"sysv_abi">, CXX11<"gnu", "sysv_abi">];
}
def ThisCall : InheritableAttr {
let Spellings = [GNU<"thiscall">, CXX11<"gnu", "thiscall">,
Keyword<"__thiscall">, Keyword<"_thiscall">];

View File

@ -206,6 +206,8 @@ namespace clang {
CC_X86FastCall, // __attribute__((fastcall))
CC_X86ThisCall, // __attribute__((thiscall))
CC_X86Pascal, // __attribute__((pascal))
CC_X86_64Win64, // __attribute__((ms_abi))
CC_X86_64SysV, // __attribute__((sysv_abi))
CC_AAPCS, // __attribute__((pcs("aapcs")))
CC_AAPCS_VFP, // __attribute__((pcs("aapcs-vfp")))
CC_PnaclCall, // __attribute__((pnaclcall))

View File

@ -921,6 +921,8 @@ struct XMLDumper : public XMLDeclVisitor<XMLDumper>,
case CC_X86StdCall: return set("cc", "x86_stdcall");
case CC_X86ThisCall: return set("cc", "x86_thiscall");
case CC_X86Pascal: return set("cc", "x86_pascal");
case CC_X86_64Win64: return set("cc", "x86_64_win64");
case CC_X86_64SysV: return set("cc", "x86_64_sysv");
case CC_AAPCS: return set("cc", "aapcs");
case CC_AAPCS_VFP: return set("cc", "aapcs_vfp");
case CC_PnaclCall: return set("cc", "pnaclcall");

View File

@ -1311,6 +1311,8 @@ void MicrosoftCXXNameMangler::mangleCallingConvention(const FunctionType *T,
switch (CC) {
default:
llvm_unreachable("Unsupported CC for mangling");
case CC_X86_64Win64:
case CC_X86_64SysV:
case CC_Default:
case CC_C: Out << 'A'; break;
case CC_X86Pascal: Out << 'C'; break;

View File

@ -1574,6 +1574,8 @@ StringRef FunctionType::getNameForCallConv(CallingConv CC) {
case CC_X86FastCall: return "fastcall";
case CC_X86ThisCall: return "thiscall";
case CC_X86Pascal: return "pascal";
case CC_X86_64Win64: return "ms_abi";
case CC_X86_64SysV: return "sysv_abi";
case CC_AAPCS: return "aapcs";
case CC_AAPCS_VFP: return "aapcs-vfp";
case CC_PnaclCall: return "pnaclcall";

View File

@ -650,6 +650,12 @@ void TypePrinter::printFunctionProtoAfter(const FunctionProtoType *T,
case CC_IntelOclBicc:
OS << " __attribute__((intel_ocl_bicc))";
break;
case CC_X86_64Win64:
OS << " __attribute__((ms_abi))";
break;
case CC_X86_64SysV:
OS << " __attribute__((sysv_abi))";
break;
}
if (Info.getNoReturn())
OS << " __attribute__((noreturn))";
@ -1160,6 +1166,8 @@ void TypePrinter::printAttributedAfter(const AttributedType *T,
case AttributedType::attr_stdcall: OS << "stdcall"; break;
case AttributedType::attr_thiscall: OS << "thiscall"; break;
case AttributedType::attr_pascal: OS << "pascal"; break;
case AttributedType::attr_ms_abi: OS << "ms_abi"; break;
case AttributedType::attr_sysv_abi: OS << "sysv_abi"; break;
case AttributedType::attr_pcs: {
OS << "pcs(";
QualType t = T->getEquivalentType();

View File

@ -3182,8 +3182,9 @@ public:
virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const {
return (CC == CC_Default ||
CC == CC_C ||
CC == CC_IntelOclBicc) ? CCCR_OK : CCCR_Warning;
CC == CC_C ||
CC == CC_IntelOclBicc ||
CC == CC_X86_64Win64) ? CCCR_OK : CCCR_Warning;
}
virtual CallingConv getDefaultCallingConv(CallingConvMethodType MT) const {
@ -3219,6 +3220,11 @@ public:
virtual BuiltinVaListKind getBuiltinVaListKind() const {
return TargetInfo::CharPtrBuiltinVaList;
}
virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const {
return (CC == CC_C ||
CC == CC_IntelOclBicc ||
CC == CC_X86_64SysV) ? CCCR_OK : CCCR_Warning;
}
};
} // end anonymous namespace

View File

@ -41,6 +41,8 @@ static unsigned ClangCallConvToLLVMCallConv(CallingConv CC) {
case CC_X86StdCall: return llvm::CallingConv::X86_StdCall;
case CC_X86FastCall: return llvm::CallingConv::X86_FastCall;
case CC_X86ThisCall: return llvm::CallingConv::X86_ThisCall;
case CC_X86_64Win64: return llvm::CallingConv::X86_64_Win64;
case CC_X86_64SysV: return llvm::CallingConv::X86_64_SysV;
case CC_AAPCS: return llvm::CallingConv::ARM_AAPCS;
case CC_AAPCS_VFP: return llvm::CallingConv::ARM_AAPCS_VFP;
case CC_IntelOclBicc: return llvm::CallingConv::Intel_OCL_BI;

View File

@ -3961,6 +3961,16 @@ static void handleCallConvAttr(Sema &S, Decl *D, const AttributeList &Attr) {
PascalAttr(Attr.getRange(), S.Context,
Attr.getAttributeSpellingListIndex()));
return;
case AttributeList::AT_MSABI:
D->addAttr(::new (S.Context)
MSABIAttr(Attr.getRange(), S.Context,
Attr.getAttributeSpellingListIndex()));
return;
case AttributeList::AT_SysVABI:
D->addAttr(::new (S.Context)
SysVABIAttr(Attr.getRange(), S.Context,
Attr.getAttributeSpellingListIndex()));
return;
case AttributeList::AT_Pcs: {
PcsAttr::PCSType PCS;
switch (CC) {
@ -4036,6 +4046,14 @@ bool Sema::CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC,
case AttributeList::AT_StdCall: CC = CC_X86StdCall; break;
case AttributeList::AT_ThisCall: CC = CC_X86ThisCall; break;
case AttributeList::AT_Pascal: CC = CC_X86Pascal; break;
case AttributeList::AT_MSABI:
CC = Context.getTargetInfo().getTriple().isOSWindows() ? CC_C :
CC_X86_64Win64;
break;
case AttributeList::AT_SysVABI:
CC = Context.getTargetInfo().getTriple().isOSWindows() ? CC_X86_64SysV :
CC_C;
break;
case AttributeList::AT_Pcs: {
Expr *Arg = attr.getArg(0);
StringLiteral *Str = dyn_cast<StringLiteral>(Arg);
@ -4876,6 +4894,8 @@ static void ProcessInheritableDeclAttr(Sema &S, Scope *scope, Decl *D,
case AttributeList::AT_FastCall:
case AttributeList::AT_ThisCall:
case AttributeList::AT_Pascal:
case AttributeList::AT_MSABI:
case AttributeList::AT_SysVABI:
case AttributeList::AT_Pcs:
case AttributeList::AT_PnaclCall:
case AttributeList::AT_IntelOclBicc:

View File

@ -105,6 +105,8 @@ static void diagnoseBadTypeAttribute(Sema &S, const AttributeList &attr,
case AttributeList::AT_StdCall: \
case AttributeList::AT_ThisCall: \
case AttributeList::AT_Pascal: \
case AttributeList::AT_MSABI: \
case AttributeList::AT_SysVABI: \
case AttributeList::AT_Regparm: \
case AttributeList::AT_Pcs: \
case AttributeList::AT_PnaclCall: \
@ -3296,6 +3298,10 @@ static AttributeList::Kind getAttrListKind(AttributedType::Kind kind) {
return AttributeList::AT_PnaclCall;
case AttributedType::attr_inteloclbicc:
return AttributeList::AT_IntelOclBicc;
case AttributedType::attr_ms_abi:
return AttributeList::AT_MSABI;
case AttributedType::attr_sysv_abi:
return AttributeList::AT_SysVABI;
}
llvm_unreachable("unexpected attribute kind!");
}

View File

@ -48,9 +48,11 @@ ifn_start()
ifscript_up ${ifn} && cfg=0
ifconfig_up ${ifn} && cfg=0
afexists inet && ipv4_up ${ifn} && cfg=0
afexists inet6 && ipv6_up ${ifn} && cfg=0
afexists ipx && ipx_up ${ifn} && cfg=0
if ! noafif $ifn; then
afexists inet && ipv4_up ${ifn} && cfg=0
afexists inet6 && ipv6_up ${ifn} && cfg=0
afexists ipx && ipx_up ${ifn} && cfg=0
fi
childif_create ${ifn} && cfg=0
return $cfg
@ -68,9 +70,11 @@ ifn_stop()
[ -z "$ifn" ] && err 1 "ifn_stop called without an interface"
afexists ipx && ipx_down ${ifn} && cfg=0
afexists inet6 && ipv6_down ${ifn} && cfg=0
afexists inet && ipv4_down ${ifn} && cfg=0
if ! noafif $ifn; then
afexists ipx && ipx_down ${ifn} && cfg=0
afexists inet6 && ipv6_down ${ifn} && cfg=0
afexists inet && ipv4_down ${ifn} && cfg=0
fi
ifconfig_down ${ifn} && cfg=0
ifscript_down ${ifn} && cfg=0
childif_destroy ${ifn} && cfg=0
@ -103,7 +107,7 @@ ifconfig_up()
fi
# inet6 specific
if afexists inet6; then
if ! noafif $1 && afexists inet6; then
if checkyesno ipv6_activate_all_interfaces; then
_ipv6_opts="-ifdisabled"
elif [ "$1" != "lo0" ]; then
@ -463,6 +467,7 @@ noafif()
case $_if in
pflog[0-9]*|\
pfsync[0-9]*|\
usbus[0-9]*|\
an[0-9]*|\
ath[0-9]*|\
ipw[0-9]*|\
@ -1198,8 +1203,7 @@ ifscript_down()
#
clone_up()
{
local _prefix _list ifn ifopt _iflist _n tmpargs
_prefix=
local _list ifn ifopt _iflist _n tmpargs
_list=
_iflist=$*
@ -1211,15 +1215,34 @@ clone_up()
""|$ifn|$ifn\ *|*\ $ifn\ *|*\ $ifn) ;;
*) continue ;;
esac
# Skip if ifn already exists.
if ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then
continue
fi
${IFCONFIG_CMD} ${ifn} create `get_if_var ${ifn} create_args_IF`
if [ $? -eq 0 ]; then
_list="${_list}${_prefix}${ifn}"
[ -z "$_prefix" ] && _prefix=' '
fi
case $ifn in
epair[0-9]*)
# epair(4) uses epair[0-9] for creation and
# epair[0-9][ab] for configuration.
#
# Skip if ${ifn}a or ${ifn}b already exist.
if ${IFCONFIG_CMD} ${ifn}a > /dev/null 2>&1; then
continue
elif ${IFCONFIG_CMD} ${ifn}b > /dev/null 2>&1; then
continue
fi
${IFCONFIG_CMD} ${ifn} create \
`get_if_var ${ifn} create_args_IF`
if [ $? -eq 0 ]; then
_list="$_list ${ifn}a ${ifn}b"
fi
;;
*)
# Skip if ${ifn} already exists.
if ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then
continue
fi
${IFCONFIG_CMD} ${ifn} create \
`get_if_var ${ifn} create_args_IF`
if [ $? -eq 0 ]; then
_list="$_list $ifn"
fi
esac
done
if [ -n "$gif_interfaces" ]; then
warn "\$gif_interfaces is obsolete. Use \$cloned_interfaces instead."
@ -1245,16 +1268,15 @@ clone_up()
;;
esac
if [ $? -eq 0 ]; then
_list="${_list}${_prefix}${ifn}"
[ -z "$_prefix" ] && _prefix=' '
_list="$_list $ifn"
fi
tmpargs=$(get_if_var $ifn gifconfig_IF)
eval ifconfig_${ifn}=\"tunnel \$tmpargs\"
done
if [ -n "${_list}" ]; then
echo "Created clone interfaces: ${_list}."
if [ -n "${_list# }" ]; then
echo "Created clone interfaces: ${_list# }."
fi
debug "Cloned: ${_list}"
debug "Cloned: ${_list# }"
}
# clone_down
@ -1263,8 +1285,7 @@ clone_up()
#
clone_down()
{
local _prefix _list ifn ifopt _iflist _sticky
_prefix=
local _list ifn _difn ifopt _iflist _sticky
_list=
_iflist=$*
@ -1286,20 +1307,40 @@ clone_down()
""|$ifn|$ifn\ *|*\ $ifn\ *|*\ $ifn) ;;
*) continue ;;
esac
# Skip if ifn does not exist.
if ! ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then
continue
fi
${IFCONFIG_CMD} -n ${ifn} destroy
if [ $? -eq 0 ]; then
_list="${_list}${_prefix}${ifn}"
[ -z "$_prefix" ] && _prefix=' '
fi
case $ifn in
epair[0-9]*)
# Note: epair(4) uses epair[0-9] for removal and
# epair[0-9][ab] for configuration.
#
# Skip if both of ${ifn}a and ${ifn}b do not exist.
if ${IFCONFIG_CMD} ${ifn}a > /dev/null 2>&1; then
_difn=${ifn}a
elif ${IFCONFIG_CMD} ${ifn}b > /dev/null 2>&1; then
_difn=${ifn}b
else
continue
fi
${IFCONFIG_CMD} -n $_difn destroy
if [ $? -eq 0 ]; then
_list="$_list ${ifn}a ${ifn}b"
fi
;;
*)
# Skip if ifn does not exist.
if ! ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then
continue
fi
${IFCONFIG_CMD} -n ${ifn} destroy
if [ $? -eq 0 ]; then
_list="$_list $ifn"
fi
;;
esac
done
if [ -n "${_list}" ]; then
echo "Destroyed clone interfaces: ${_list}."
if [ -n "${_list# }" ]; then
echo "Destroyed clone interfaces: ${_list# }."
fi
debug "Destroyed clones: ${_list}"
debug "Destroyed clones: ${_list# }"
}
# childif_create
@ -1574,17 +1615,33 @@ list_net_interfaces()
fi
done
_tmplist="${_lo}${_tmplist# }"
;;
;;
*)
_tmplist="${network_interfaces} ${cloned_interfaces}"
for _if in ${network_interfaces} ${cloned_interfaces}; do
# epair(4) uses epair[0-9] for creation and
# epair[0-9][ab] for configuration.
case $_if in
epair[0-9]*)
_tmplist="$_tmplist ${_if}a ${_if}b"
;;
*)
_tmplist="$_tmplist $_if"
;;
esac
done
#
# lo0 is effectively mandatory, so help prevent foot-shooting
#
case "$_tmplist" in
lo0|'lo0 '*|*' lo0'|*' lo0 '*) ;; # This is fine, do nothing
*) _tmplist="lo0 ${_tmplist}" ;;
esac
lo0|'lo0 '*|*' lo0'|*' lo0 '*)
# This is fine, do nothing
_tmplist="${_tmplist# }"
;;
*)
_tmplist="lo0 ${_tmplist# }"
;;
esac
;;
esac
_list=
@ -1596,14 +1653,14 @@ list_net_interfaces()
_list="${_list# } ${_if}"
fi
done
;;
;;
dhcp)
for _if in ${_tmplist} ; do
if dhcpif $_if; then
_list="${_list# } ${_if}"
fi
done
;;
;;
noautoconf)
for _if in ${_tmplist} ; do
if ! ipv6_autoconfif $_if && \
@ -1611,17 +1668,17 @@ list_net_interfaces()
_list="${_list# } ${_if}"
fi
done
;;
;;
autoconf)
for _if in ${_tmplist} ; do
if ipv6_autoconfif $_if; then
_list="${_list# } ${_if}"
fi
done
;;
;;
*)
_list=${_tmplist}
;;
;;
esac
echo $_list

View File

@ -72,7 +72,7 @@ network_start()
ifnet_rename $cmdifn
# Configure the interface(s).
network_common ifn_start
network_common ifn_start $cmdifn
if [ -f /etc/rc.d/ipfilter ] ; then
# Resync ipfilter
@ -109,7 +109,7 @@ network_stop0()
cmdifn=$*
# Deconfigure the interface(s)
network_common ifn_stop
network_common ifn_stop $cmdifn
# Destroy cloned interfaces
if [ -n "$_clone_down" ]; then
@ -129,7 +129,7 @@ network_stop0()
# an interface and then calls $routine.
network_common()
{
local _cooked_list _fail _func _ok _str
local _cooked_list _tmp_list _fail _func _ok _str _cmdifn
_func=
@ -137,26 +137,45 @@ network_common()
err 1 "network_common(): No function name specified."
else
_func="$1"
shift
fi
# Set the scope of the command (all interfaces or just one).
#
_cooked_list=
if [ -n "$cmdifn" ]; then
_tmp_list=
_cmdifn=$*
if [ -n "$_cmdifn" ]; then
# Don't check that the interface(s) exist. We need to run
# the down code even when the interface doesn't exist to
# kill off wpa_supplicant.
# XXXBED: is this really true or does wpa_supplicant die?
# if so, we should get rid of the devd entry
_cooked_list="$cmdifn"
_cooked_list="$_cmdifn"
else
_cooked_list="`list_net_interfaces`"
fi
# Expand epair[0-9] to epair[0-9][ab].
for ifn in $_cooked_list; do
case ${ifn#epair} in
[0-9]*[ab]) ;; # Skip epair[0-9]*[ab].
[0-9]*)
for _str in $_cooked_list; do
case $_str in
$ifn) _tmp_list="$_tmp_list ${ifn}a ${ifn}b" ;;
*) _tmp_list="$_tmp_list ${ifn}" ;;
esac
done
_cooked_list=${_tmp_list# }
;;
esac
done
_dadwait=
_fail=
_ok=
for ifn in ${_cooked_list}; do
for ifn in ${_cooked_list# }; do
# Skip if ifn does not exist.
case $_func in
ifn_stop)

View File

@ -3205,8 +3205,8 @@ nfe_stats_clear(struct nfe_softc *sc)
else
return;
for (i = 0; i < mib_cnt; i += sizeof(uint32_t))
NFE_READ(sc, NFE_TX_OCTET + i);
for (i = 0; i < mib_cnt; i++)
NFE_READ(sc, NFE_TX_OCTET + i * sizeof(uint32_t));
if ((sc->nfe_flags & NFE_MIB_V3) != 0) {
NFE_READ(sc, NFE_TX_UNICAST);

View File

@ -656,7 +656,7 @@ vfs_donmount(struct thread *td, uint64_t fsflags, struct uio *fsoptions)
* variables will fit in our mp buffers, including the
* terminating NUL.
*/
if (fstypelen >= MFSNAMELEN - 1 || fspathlen >= MNAMELEN - 1) {
if (fstypelen > MFSNAMELEN || fspathlen > MNAMELEN) {
error = ENAMETOOLONG;
goto bail;
}