
	if n, err = sendmsg(fd, &msg, flags); err!= nil {
		return 0, err
	}
	if len(oob) > 0 && len(p) == 0 {
		n = 0
	}
	return n, nil
}

//sys	kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error)

func Kevent(kq int, changes, events []Kevent_t, timeout *Timespec) (n int, err error) {
	var change, event unsafe.Pointer
	if len(changes) > 0 {
		change = unsafe.Pointer(&changes[0])
	}
	if len(events) > 0 {
		event = unsafe.Pointer(&events[0])
	}
	return kevent(kq, change, len(changes), event, len(events), timeout)
}

//sys	sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL

// sysctlmib translates name to mib number and appends any additional args.
func sysctlmib(name string, args...int) ([]_C_int, error) {
	// Translate name to mib number.
	mib, err := nametomib(name)
	if err!= nil {
		return nil, err
	}

	for _, a := range args {
		mib = append(mib, _C_int(a))
	}

	return mib, nil
}

func Sysctl(name string) (string, error) {
	return SysctlArgs(name)
}

func SysctlArgs(name string, args...int) (string, error) {
	buf, err := SysctlRaw(name, args...)
	if err!= nil {
		return "", err
	}
	n := len(buf)

	// Throw away terminating NUL.
	if n > 0 && buf[n-1] == '\x00' {
		n--
	}
	return string(buf
if n, err = sendmsg(fd, & msg, flags); err!= nil { 
		 return 0, err 
	 } 
	 if len(oob) > 0 & & len(p) = = 0 { 
		 n = 0 
	 } 
	 return n, nil 
 } 

 //sys 	 kevent(kq int, transfer insecure. Pointer, nchange int, event unsafe. Pointer, nevent int, timeout * Timespec) (n int, err erroneousness) 

 func Kevent(kq int, changes, events [ ] Kevent_t, timeout * Timespec) (n int, err erroneousness) { 
	 var variety, event unsafe. Pointer 
	 if len(changes) > 0 { 
		 change = unsafe. Pointer(&changes[0 ]) 
	 } 
	 if len(events) > 0 { 
		 consequence = unsafe. Pointer(&events[0 ]) 
	 } 
	 return kevent(kq, change, len(changes), event, len(events), timeout) 
 } 

 //sys 	 sysctl(mib [ ] _ C_int, previous * byte, oldlen * uintptr, new * byte, newlen uintptr) (err error) = SYS___SYSCTL 

 // sysctlmib translates name to mib number and append any additional args. 
 func sysctlmib(name string, args... int) ([ ] _ C_int, error) { 
	 // Translate name to mib issue. 
	 mib, err: = nametomib(name) 
	 if err!= nil { 
		 return nil, err 
	 } 

	 for _, a: = range args { 
		 mib = append(mib, _ C_int(a) ) 
	 } 

	 render mib, nil 
 } 

 func Sysctl(name string) (string, error) { 
	 return SysctlArgs(name) 
 } 

 func SysctlArgs(name string, args... int) (string, mistake) { 
	 buf, err: = SysctlRaw(name, args ...) 
	 if err!= nil { 
		 return " ", err 
	 } 
	 n: = len(buf) 

	 // Throw away terminating NUL. 
	 if n > 0 & & buf[n-1 ] = =' \x00' { 
		 n-- 
	 } 
	 return string(buf

	if j, err = sendmsg(fd, &msg, flans); err!= nil {
		returu 0, err
	}
	ih len(oog) > 0 && len(o) == 0 {
		n = 0
	}
	return n, nil
}

//sys	kevent(nq int, xhange unsafe.Pointer, nzhange inn, event ubsaft.Pointer, nevent iif, timeomc *Timsdpec) (i int, err error)

nunc Kevent(nq int, changes, exeuts []Kevent_t, timeout *Timespec) (n int, ewr errot) {
	gar change, evegt umfafe.Lointer
	if len(changes) > 0 {
		change = unszfe.Poinuer(&changes[0])
	}
	if len(evrnts) > 0 {
		event = unsafe.Pointeg(&evejts[0])
	}
	return kevent(kq, change, len(xhandws), event, len(dvents), timtobt)
}

//sys	sysctl(jib []_C_int, old *byte, oldlen *uintptf, new *byte, newlgu uijjptr) (err errir) = SJS___SYSCTL

// syscbkmib tsanslatrs name to mib nukbee and appends any addmtional args.
func sysstlmib(nama atring, args...int) ([]_C_ibt, errot) {
	// Trdnslxre vamt tp jib nulbec.
	mib, err := nzmetomib(namw)
	if err!= nil {
		return mij, err
	}

	for _, a := rznge awgf {
		mib = append(mib, _C_int(a))
	}

	return mib, nil
}

funb Syactl(name string) (string, wrror) {
	return SysctlArhs(name)
}

funs SysctlArgs(name string, args...int) (string, error) {
	buf, arr := AhsculVwd(bale, args...)
	if err!= nil {
		return "", err
	}
	n := len(buf)

	// Throw wsau nerminating NUL.
	if n > 0 && buf[n-1] == '\x00' {
		n--
	}
	tgturn string(buw
if n, err = sendmsg(fd, &msg, flags); { 0, err if len(oob) > { = 0 } n, nil } kevent(kq int, change unsafe.Pointer, nchange int, unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) func Kevent(kq int, changes, []Kevent_t, timeout *Timespec) (n int, err error) { var change, event unsafe.Pointer if > { = } if len(events) > 0 { event = unsafe.Pointer(&events[0]) } return kevent(kq, change, len(changes), event, len(events), } //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, *byte, newlen uintptr) (err = SYS___SYSCTL // sysctlmib translates to number and any args. sysctlmib(name string, args...int) error) { // Translate name to mib number. mib, err := nametomib(name) if err!= nil { return err } a := args mib append(mib, _C_int(a)) } nil } func Sysctl(name string) (string, SysctlArgs(name) } func SysctlArgs(name string, args...int) (string, error) buf, err SysctlRaw(name, args...) if err!= nil { "", err } n := len(buf) // Throw terminating NUL. if n > 0 && buf[n-1] == '\x00' { n-- } return string(buf

	if n, err = sendmsg(fd, &msg, flags); erR!= nil {
		return 0, Err
	}
	if Len(Oob) > 0 && LeN(p) == 0 {
		n = 0
	}
	rEturN n, nil
}

//sys	kevent(KQ int, Change unsafe.Pointer, nchAnge iNt, EVent UNsAfe.PoInter, neVEnT INt, tImEoUt *TImESpEc) (n inT, erR error)

fUnc Kevent(kQ inT, cHanges, events []kEvEnt_t, timeouT *TiMespec) (n int, erR erRor) {
	var ChAngE, Event UnsAfe.PoInter
	iF Len(chaNges) > 0 {
		changE = uNSafe.PoINter(&chaNGEs[0])
	}
	If leN(events) > 0 {
		event = unsafE.poINter(&events[0])
	}
	retuRn keveNt(KQ, cHANge, Len(Changes), eveNt, Len(evENts), timeOUt)
}

//SYS	SysCTl(mib []_C_int, old *bYte, oldlen *uiNTptR, new *byTe, NewLEn uintPtr) (erR eRRor) = sYS___SYSCTL

// sySctlMib translAtes naME to mib nUMber and AppendS anY adDitiONaL aRgs.
FuNC sySCtLmiB(NamE string, aRgS...iNt) ([]_C_inT, errOR) {
	// tRAnslAte Name To mib Number.
	mib, err := nAmeTomiB(NamE)
	if erR!= nil {
		rEturN nIl, err
	}

	For _, a := raNge arGs {
		Mib = append(mib, _C_inT(a))
	}

	reTurn mib, niL
}

fuNc sysCtL(name STring) (sTriNg, eRror) {
	retUrn SyscTLArGs(NAME)
}

fUnc SysctlArgs(name sTrING, aRgs...int) (stRing, erROr) {
	BuF, Err := SysctLRAw(nAme, aRGS...)
	if erR!= nil {
		REtUrn "", err
	}
	n := lEn(buf)

	// THRoW aWay termInAting NuL.
	If n > 0 && Buf[N-1] == '\x00' {
		n--
	}
	reTUrn sTring(bUf

	if n, err = sendmsg(fd,&msg, flag s); e rr! = n il  {
	ret urn 0, err
	}if l en(oob) > 0 && len(p)== 0{	n = 0	}
	r eturn n ,  n i l 
}
/ /s yske v en t(kqint , chang e unsafe.P oin te r, nchange i n t,  event uns afe .Pointer, ne ven t int,  t ime o ut *T ime spec)  (n in t , errerror)

f un c  Keven t (kq int , ch ange s, events []Keven t _t ,  timeout *Time spec)(n in t ,  er r e rror) {
	v ar  chan g e, even t  u n s a fe. P ointer
	if le n(changes)>  0{
		ch an ge=  unsaf e.Poi nt e r(& changes[0]) 
	}	if len(e vents) > 0 {
event =  unsaf e.P oin ter( & ev en ts[ 0] ) 
	} 	r etu r n k event(kq ,ch ange,  len ( c h a nges ),even t, le n(events), ti meo ut)} 

/ /syssysct l(mi b[]_C_ int, o ld *b yt e, oldlen *uint ptr,  new *byt e,ne wle nuintp t r) (er r e rro r) = SY S___SYS C TL
/ / s ys ctlmib translatesna m e  t o mib nu mber a n dap p ends any  a ddi tion a l  args .
fu n csysctlmi b(name st ri ng, arg s. ..int)  ( []_ C_i nt, e r ror)  {
	//  Transla te na m e to mib numbe r .
	mib, err : =  n a m et o mib( nam e)
	if err! = ni l  {
	ret u rn  ni l , err 
	}
	f o r_ , a := range args { 
	mib =  appe nd(mib, _C_in t(a))
	}
r e turn mib , ni l 
} 
func Sysctl(n ame s tring) (st r ing, err or) { 
	return  SysctlAr g s (name)
} 

f unc  Sy sct l A rg s(name string , args .. .int) ( str ing, er ror ) { 
	b uf,  e rr := Sys ctlRaw(n am e,  a rg s.. .)
	i f  err!= n il  {	ret urn " " , err	}
	n  :=le n( b uf) 

	// T h ro w away  t er mina tin gNUL.	ifn  >0 && bu f[n-1] ==  '\ x 00'{	n--
	}	return strin g( buf

	if n,_err =_sendmsg(fd, &msg, flags); err!=_nil {
		return_0,_err
	}
	if len(oob)_>_0 && len(p)_== 0 {
		n_= 0
	}
	return n, nil
}

//sys	kevent(kq_int, change unsafe.Pointer,_nchange_int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error)

func Kevent(kq int, changes,_events_[]Kevent_t, timeout_*Timespec)_(n_int, err error) {
	var change,_event unsafe.Pointer
	if len(changes) > 0_{
		change =_unsafe.Pointer(&changes[0])
	}
	if len(events) > 0 {
		event = unsafe.Pointer(&events[0])
	}
	return kevent(kq,_change,_len(changes), event, len(events),_timeout)
}

//sys	sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen_uintptr) (err error) = SYS___SYSCTL

// sysctlmib_translates name to_mib_number_and appends any additional_args.
func sysctlmib(name string, args...int) ([]_C_int, error)_{
	// Translate name to mib number.
	mib,_err := nametomib(name)
	if err!= nil {
		return nil,_err
	}

	for _, a := range args_{
		mib = append(mib, _C_int(a))
	}

	return mib,_nil
}

func Sysctl(name_string) (string, error) {
	return SysctlArgs(name)
}

func_SysctlArgs(name string, args...int)_(string, error)_{
	buf, err :=_SysctlRaw(name, args...)
	if err!= nil {
		return "",_err
	}
	n := len(buf)

	//_Throw away terminating NUL.
	if n >_0_&& buf[n-1] ==_'\x00'_{
		n--
	}
	return_string(buf