http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/mkerrors.sh
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/mkerrors.sh 
b/newtmgr/vendor/golang.org/x/sys/unix/mkerrors.sh
new file mode 100755
index 0000000..c40d788
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/mkerrors.sh
@@ -0,0 +1,476 @@
+#!/usr/bin/env bash
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# Generate Go code listing errors and other #defined constant
+# values (ENAMETOOLONG etc.), by asking the preprocessor
+# about the definitions.
+
+unset LANG
+export LC_ALL=C
+export LC_CTYPE=C
+
+if test -z "$GOARCH" -o -z "$GOOS"; then
+       echo 1>&2 "GOARCH or GOOS not defined in environment"
+       exit 1
+fi
+
+CC=${CC:-cc}
+
+if [[ "$GOOS" -eq "solaris" ]]; then
+       # Assumes GNU versions of utilities in PATH.
+       export PATH=/usr/gnu/bin:$PATH
+fi
+
+uname=$(uname)
+
+includes_Darwin='
+#define _DARWIN_C_SOURCE
+#define KERNEL
+#define _DARWIN_USE_64_BIT_INODE
+#include <sys/types.h>
+#include <sys/event.h>
+#include <sys/ptrace.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/sysctl.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <net/bpf.h>
+#include <net/if.h>
+#include <net/if_types.h>
+#include <net/route.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <termios.h>
+'
+
+includes_DragonFly='
+#include <sys/types.h>
+#include <sys/event.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/sysctl.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <sys/ioctl.h>
+#include <net/bpf.h>
+#include <net/if.h>
+#include <net/if_types.h>
+#include <net/route.h>
+#include <netinet/in.h>
+#include <termios.h>
+#include <netinet/ip.h>
+#include <net/ip_mroute/ip_mroute.h>
+'
+
+includes_FreeBSD='
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/event.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/sysctl.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <sys/ioctl.h>
+#include <net/bpf.h>
+#include <net/if.h>
+#include <net/if_types.h>
+#include <net/route.h>
+#include <netinet/in.h>
+#include <termios.h>
+#include <netinet/ip.h>
+#include <netinet/ip_mroute.h>
+#include <sys/extattr.h>
+
+#if __FreeBSD__ >= 10
+#define IFT_CARP       0xf8    // IFT_CARP is deprecated in FreeBSD 10
+#undef SIOCAIFADDR
+#define SIOCAIFADDR    _IOW(105, 26, struct oifaliasreq)       // ifaliasreq 
contains if_data
+#undef SIOCSIFPHYADDR
+#define SIOCSIFPHYADDR _IOW(105, 70, struct oifaliasreq)       // ifaliasreq 
contains if_data
+#endif
+'
+
+includes_Linux='
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+#ifndef __LP64__
+#define _FILE_OFFSET_BITS 64
+#endif
+#define _GNU_SOURCE
+
+#include <bits/sockaddr.h>
+#include <sys/epoll.h>
+#include <sys/inotify.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/prctl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/if_arp.h>
+#include <linux/if_ether.h>
+#include <linux/if_tun.h>
+#include <linux/if_packet.h>
+#include <linux/if_addr.h>
+#include <linux/filter.h>
+#include <linux/netlink.h>
+#include <linux/reboot.h>
+#include <linux/rtnetlink.h>
+#include <linux/ptrace.h>
+#include <linux/sched.h>
+#include <linux/wait.h>
+#include <linux/icmpv6.h>
+#include <net/route.h>
+#include <asm/termbits.h>
+
+#ifndef MSG_FASTOPEN
+#define MSG_FASTOPEN    0x20000000
+#endif
+
+#ifndef PTRACE_GETREGS
+#define PTRACE_GETREGS 0xc
+#endif
+
+#ifndef PTRACE_SETREGS
+#define PTRACE_SETREGS 0xd
+#endif
+'
+
+includes_NetBSD='
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/event.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/sysctl.h>
+#include <sys/termios.h>
+#include <sys/ttycom.h>
+#include <sys/wait.h>
+#include <net/bpf.h>
+#include <net/if.h>
+#include <net/if_types.h>
+#include <net/route.h>
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_mroute.h>
+#include <netinet/if_ether.h>
+
+// Needed since <sys/param.h> refers to it...
+#define schedppq 1
+'
+
+includes_OpenBSD='
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/event.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/sysctl.h>
+#include <sys/termios.h>
+#include <sys/ttycom.h>
+#include <sys/wait.h>
+#include <net/bpf.h>
+#include <net/if.h>
+#include <net/if_types.h>
+#include <net/if_var.h>
+#include <net/route.h>
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_mroute.h>
+#include <netinet/if_ether.h>
+#include <net/if_bridge.h>
+
+// We keep some constants not supported in OpenBSD 5.5 and beyond for
+// the promise of compatibility.
+#define EMUL_ENABLED           0x1
+#define EMUL_NATIVE            0x2
+#define IPV6_FAITH             0x1d
+#define IPV6_OPTIONS           0x1
+#define IPV6_RTHDR_STRICT      0x1
+#define IPV6_SOCKOPT_RESERVED1 0x3
+#define SIOCGIFGENERIC         0xc020693a
+#define SIOCSIFGENERIC         0x80206939
+#define WALTSIG                        0x4
+'
+
+includes_SunOS='
+#include <limits.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <sys/ioctl.h>
+#include <net/bpf.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <net/if_types.h>
+#include <net/route.h>
+#include <netinet/in.h>
+#include <termios.h>
+#include <netinet/ip.h>
+#include <netinet/ip_mroute.h>
+'
+
+
+includes='
+#include <sys/types.h>
+#include <sys/file.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <netinet/ip6.h>
+#include <netinet/tcp.h>
+#include <errno.h>
+#include <sys/signal.h>
+#include <signal.h>
+#include <sys/resource.h>
+#include <time.h>
+'
+ccflags="$@"
+
+# Write go tool cgo -godefs input.
+(
+       echo package unix
+       echo
+       echo '/*'
+       indirect="includes_$(uname)"
+       echo "${!indirect} $includes"
+       echo '*/'
+       echo 'import "C"'
+       echo 'import "syscall"'
+       echo
+       echo 'const ('
+
+       # The gcc command line prints all the #defines
+       # it encounters while processing the input
+       echo "${!indirect} $includes" | $CC -x c - -E -dM $ccflags |
+       awk '
+               $1 != "#define" || $2 ~ /\(/ || $3 == "" {next}
+
+               $2 ~ /^E([ABCD]X|[BIS]P|[SD]I|S|FL)$/ {next}  # 386 registers
+               $2 ~ /^(SIGEV_|SIGSTKSZ|SIGRT(MIN|MAX))/ {next}
+               $2 ~ /^(SCM_SRCRT)$/ {next}
+               $2 ~ /^(MAP_FAILED)$/ {next}
+               $2 ~ /^ELF_.*$/ {next}# <asm/elf.h> contains ELF_ARCH, etc.
+
+               $2 ~ /^EXTATTR_NAMESPACE_NAMES/ ||
+               $2 ~ /^EXTATTR_NAMESPACE_[A-Z]+_STRING/ {next}
+
+               $2 !~ /^ETH_/ &&
+               $2 !~ /^EPROC_/ &&
+               $2 !~ /^EQUIV_/ &&
+               $2 !~ /^EXPR_/ &&
+               $2 ~ /^E[A-Z0-9_]+$/ ||
+               $2 ~ /^B[0-9_]+$/ ||
+               $2 == "BOTHER" ||
+               $2 ~ /^CI?BAUD(EX)?$/ ||
+               $2 == "IBSHIFT" ||
+               $2 ~ /^V[A-Z0-9]+$/ ||
+               $2 ~ /^CS[A-Z0-9]/ ||
+               $2 ~ /^I(SIG|CANON|CRNL|UCLC|EXTEN|MAXBEL|STRIP|UTF8)$/ ||
+               $2 ~ /^IGN/ ||
+               $2 ~ /^IX(ON|ANY|OFF)$/ ||
+               $2 ~ /^IN(LCR|PCK)$/ ||
+               $2 ~ /(^FLU?SH)|(FLU?SH$)/ ||
+               $2 ~ /^C(LOCAL|READ|MSPAR|RTSCTS)$/ ||
+               $2 == "BRKINT" ||
+               $2 == "HUPCL" ||
+               $2 == "PENDIN" ||
+               $2 == "TOSTOP" ||
+               $2 == "XCASE" ||
+               $2 == "ALTWERASE" ||
+               $2 == "NOKERNINFO" ||
+               $2 ~ /^PAR/ ||
+               $2 ~ /^SIG[^_]/ ||
+               $2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ ||
+               $2 ~ /^(NL|CR|TAB|BS|VT|FF)DLY$/ ||
+               $2 ~ /^(NL|CR|TAB|BS|VT|FF)[0-9]$/ ||
+               $2 ~ /^O?XTABS$/ ||
+               $2 ~ /^TC[IO](ON|OFF)$/ ||
+               $2 ~ /^IN_/ ||
+               $2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
+               $2 ~ 
/^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|PACKET|MSG|SCM|MCL|DT|MADV|PR)_/
 ||
+               $2 == "ICMPV6_FILTER" ||
+               $2 == "SOMAXCONN" ||
+               $2 == "NAME_MAX" ||
+               $2 == "IFNAMSIZ" ||
+               $2 ~ /^CTL_(MAXNAME|NET|QUERY)$/ ||
+               $2 ~ /^SYSCTL_VERS/ ||
+               $2 ~ /^(MS|MNT)_/ ||
+               $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
+               $2 ~ /^(O|F|FD|NAME|S|PTRACE|PT)_/ ||
+               $2 ~ /^LINUX_REBOOT_CMD_/ ||
+               $2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
+               $2 !~ "NLA_TYPE_MASK" &&
+               $2 ~ 
/^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P)_/ ||
+               $2 ~ /^SIOC/ ||
+               $2 ~ /^TIOC/ ||
+               $2 ~ /^TCGET/ ||
+               $2 ~ /^TCSET/ ||
+               $2 ~ /^TC(FLSH|SBRKP?|XONC)$/ ||
+               $2 !~ "RTF_BITS" &&
+               $2 ~ /^(IFF|IFT|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ ||
+               $2 ~ /^BIOC/ ||
+               $2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
+               $2 ~ 
/^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|NOFILE|STACK)|RLIM_INFINITY/ ||
+               $2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
+               $2 ~ /^CLONE_[A-Z_]+/ ||
+               $2 !~ /^(BPF_TIMEVAL)$/ &&
+               $2 ~ /^(BPF|DLT)_/ ||
+               $2 ~ /^CLOCK_/ ||
+               $2 !~ "WMESGLEN" &&
+               $2 ~ /^W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", $2, $2)}
+               $2 ~ /^__WCOREFLAG$/ {next}
+               $2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), 
$2)}
+
+               {next}
+       ' | sort
+
+       echo ')'
+) >_const.go
+
+# Pull out the error names for later.
+errors=$(
+       echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
+       awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print $2 }' |
+       sort
+)
+
+# Pull out the signal names for later.
+signals=$(
+       echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
+       awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
+       egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
+       sort
+)
+
+# Again, writing regexps to a file.
+echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
+       awk '$1=="#define" && $2 ~ /^E[A-Z0-9_]+$/ { print "^\t" $2 "[ \t]*=" 
}' |
+       sort >_error.grep
+echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
+       awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" 
}' |
+       egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' |
+       sort >_signal.grep
+
+echo '// mkerrors.sh' "$@"
+echo '// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT'
+echo
+echo "// +build ${GOARCH},${GOOS}"
+echo
+go tool cgo -godefs -- "$@" _const.go >_error.out
+cat _error.out | grep -vf _error.grep | grep -vf _signal.grep
+echo
+echo '// Errors'
+echo 'const ('
+cat _error.out | grep -f _error.grep | sed 's/=\(.*\)/= syscall.Errno(\1)/'
+echo ')'
+
+echo
+echo '// Signals'
+echo 'const ('
+cat _error.out | grep -f _signal.grep | sed 's/=\(.*\)/= syscall.Signal(\1)/'
+echo ')'
+
+# Run C program to print error and syscall strings.
+(
+       echo -E "
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <ctype.h>
+#include <string.h>
+#include <signal.h>
+
+#define nelem(x) (sizeof(x)/sizeof((x)[0]))
+
+enum { A = 'A', Z = 'Z', a = 'a', z = 'z' }; // avoid need for single quotes 
below
+
+int errors[] = {
+"
+       for i in $errors
+       do
+               echo -E '       '$i,
+       done
+
+       echo -E "
+};
+
+int signals[] = {
+"
+       for i in $signals
+       do
+               echo -E '       '$i,
+       done
+
+       # Use -E because on some systems bash builtin interprets \n itself.
+       echo -E '
+};
+
+static int
+intcmp(const void *a, const void *b)
+{
+       return *(int*)a - *(int*)b;
+}
+
+int
+main(void)
+{
+       int i, j, e;
+       char buf[1024], *p;
+
+       printf("\n\n// Error table\n");
+       printf("var errors = [...]string {\n");
+       qsort(errors, nelem(errors), sizeof errors[0], intcmp);
+       for(i=0; i<nelem(errors); i++) {
+               e = errors[i];
+               if(i > 0 && errors[i-1] == e)
+                       continue;
+               strcpy(buf, strerror(e));
+               // lowercase first letter: Bad -> bad, but STREAM -> STREAM.
+               if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
+                       buf[0] += a - A;
+               printf("\t%d: \"%s\",\n", e, buf);
+       }
+       printf("}\n\n");
+       
+       printf("\n\n// Signal table\n");
+       printf("var signals = [...]string {\n");
+       qsort(signals, nelem(signals), sizeof signals[0], intcmp);
+       for(i=0; i<nelem(signals); i++) {
+               e = signals[i];
+               if(i > 0 && signals[i-1] == e)
+                       continue;
+               strcpy(buf, strsignal(e));
+               // lowercase first letter: Bad -> bad, but STREAM -> STREAM.
+               if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z)
+                       buf[0] += a - A;
+               // cut trailing : number.
+               p = strrchr(buf, ":"[0]);
+               if(p)
+                       *p = '\0';
+               printf("\t%d: \"%s\",\n", e, buf);
+       }
+       printf("}\n\n");
+
+       return 0;
+}
+
+'
+) >_errors.c
+
+$CC $ccflags -o _errors _errors.c && $GORUN ./_errors && rm -f _errors.c 
_errors _const.go _error.grep _signal.grep _error.out

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/mkpost.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/mkpost.go 
b/newtmgr/vendor/golang.org/x/sys/unix/mkpost.go
new file mode 100644
index 0000000..ed50d90
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/mkpost.go
@@ -0,0 +1,62 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build ignore
+
+// mkpost processes the output of cgo -godefs to
+// modify the generated types. It is used to clean up
+// the sys API in an architecture specific manner.
+//
+// mkpost is run after cgo -godefs by mkall.sh.
+package main
+
+import (
+       "fmt"
+       "go/format"
+       "io/ioutil"
+       "log"
+       "os"
+       "regexp"
+)
+
+func main() {
+       b, err := ioutil.ReadAll(os.Stdin)
+       if err != nil {
+               log.Fatal(err)
+       }
+       s := string(b)
+
+       goarch := os.Getenv("GOARCH")
+       goos := os.Getenv("GOOS")
+       if goarch == "s390x" && goos == "linux" {
+               // Export the types of PtraceRegs fields.
+               re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)")
+               s = re.ReplaceAllString(s, "Ptrace$1")
+
+               // Replace padding fields inserted by cgo with blank 
identifiers.
+               re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*")
+               s = re.ReplaceAllString(s, "_")
+
+               // Replace other unwanted fields with blank identifiers.
+               re = regexp.MustCompile("X_[A-Za-z0-9_]*")
+               s = re.ReplaceAllString(s, "_")
+
+               // Replace the control_regs union with a blank identifier for 
now.
+               re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64")
+               s = re.ReplaceAllString(s, "_ [0]uint64")
+       }
+
+       // gofmt
+       b, err = format.Source([]byte(s))
+       if err != nil {
+               log.Fatal(err)
+       }
+
+       // Append this command to the header to show where the new file
+       // came from.
+       re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)")
+       b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go"))
+
+       fmt.Printf("%s", b)
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/mksyscall.pl
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/mksyscall.pl 
b/newtmgr/vendor/golang.org/x/sys/unix/mksyscall.pl
new file mode 100755
index 0000000..b1e7766
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/mksyscall.pl
@@ -0,0 +1,323 @@
+#!/usr/bin/env perl
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# This program reads a file containing function prototypes
+# (like syscall_darwin.go) and generates system call bodies.
+# The prototypes are marked by lines beginning with "//sys"
+# and read like func declarations if //sys is replaced by func, but:
+#      * The parameter lists must give a name for each argument.
+#        This includes return parameters.
+#      * The parameter lists must give a type for each argument:
+#        the (x, y, z int) shorthand is not allowed.
+#      * If the return parameter is an error number, it must be named errno.
+
+# A line beginning with //sysnb is like //sys, except that the
+# goroutine will not be suspended during the execution of the system
+# call.  This must only be used for system calls which can never
+# block, as otherwise the system call could cause all goroutines to
+# hang.
+
+use strict;
+
+my $cmdline = "mksyscall.pl " . join(' ', @ARGV);
+my $errors = 0;
+my $_32bit = "";
+my $plan9 = 0;
+my $openbsd = 0;
+my $netbsd = 0;
+my $dragonfly = 0;
+my $arm = 0; # 64-bit value should use (even, odd)-pair
+
+if($ARGV[0] eq "-b32") {
+       $_32bit = "big-endian";
+       shift;
+} elsif($ARGV[0] eq "-l32") {
+       $_32bit = "little-endian";
+       shift;
+}
+if($ARGV[0] eq "-plan9") {
+       $plan9 = 1;
+       shift;
+}
+if($ARGV[0] eq "-openbsd") {
+       $openbsd = 1;
+       shift;
+}
+if($ARGV[0] eq "-netbsd") {
+       $netbsd = 1;
+       shift;
+}
+if($ARGV[0] eq "-dragonfly") {
+       $dragonfly = 1;
+       shift;
+}
+if($ARGV[0] eq "-arm") {
+       $arm = 1;
+       shift;
+}
+
+if($ARGV[0] =~ /^-/) {
+       print STDERR "usage: mksyscall.pl [-b32 | -l32] [file ...]\n";
+       exit 1;
+}
+
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
+       print STDERR "GOARCH or GOOS not defined in environment\n";
+       exit 1;
+}
+
+sub parseparamlist($) {
+       my ($list) = @_;
+       $list =~ s/^\s*//;
+       $list =~ s/\s*$//;
+       if($list eq "") {
+               return ();
+       }
+       return split(/\s*,\s*/, $list);
+}
+
+sub parseparam($) {
+       my ($p) = @_;
+       if($p !~ /^(\S*) (\S*)$/) {
+               print STDERR "$ARGV:$.: malformed parameter: $p\n";
+               $errors = 1;
+               return ("xx", "int");
+       }
+       return ($1, $2);
+}
+
+my $text = "";
+while(<>) {
+       chomp;
+       s/\s+/ /g;
+       s/^\s+//;
+       s/\s+$//;
+       my $nonblock = /^\/\/sysnb /;
+       next if !/^\/\/sys / && !$nonblock;
+
+       # Line must be of the form
+       #       func Open(path string, mode int, perm int) (fd int, errno error)
+       # Split into name, in params, out params.
+       if(!/^\/\/sys(nb)? 
(\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$/) {
+               print STDERR "$ARGV:$.: malformed //sys declaration\n";
+               $errors = 1;
+               next;
+       }
+       my ($func, $in, $out, $sysname) = ($2, $3, $4, $5);
+
+       # Split argument lists on comma.
+       my @in = parseparamlist($in);
+       my @out = parseparamlist($out);
+
+       # Try in vain to keep people from editing this file.
+       # The theory is that they jump into the middle of the file
+       # without reading the header.
+       $text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT 
EDIT\n\n";
+
+       # Go function header.
+       my $out_decl = @out ? sprintf(" (%s)", join(', ', @out)) : "";
+       $text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out_decl;
+
+       # Check if err return available
+       my $errvar = "";
+       foreach my $p (@out) {
+               my ($name, $type) = parseparam($p);
+               if($type eq "error") {
+                       $errvar = $name;
+                       last;
+               }
+       }
+
+       # Prepare arguments to Syscall.
+       my @args = ();
+       my @uses = ();
+       my $n = 0;
+       foreach my $p (@in) {
+               my ($name, $type) = parseparam($p);
+               if($type =~ /^\*/) {
+                       push @args, "uintptr(unsafe.Pointer($name))";
+               } elsif($type eq "string" && $errvar ne "") {
+                       $text .= "\tvar _p$n *byte\n";
+                       $text .= "\t_p$n, $errvar = BytePtrFromString($name)\n";
+                       $text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
+                       push @args, "uintptr(unsafe.Pointer(_p$n))";
+                       push @uses, "use(unsafe.Pointer(_p$n))";
+                       $n++;
+               } elsif($type eq "string") {
+                       print STDERR "$ARGV:$.: $func uses string arguments, 
but has no error return\n";
+                       $text .= "\tvar _p$n *byte\n";
+                       $text .= "\t_p$n, _ = BytePtrFromString($name)\n";
+                       push @args, "uintptr(unsafe.Pointer(_p$n))";
+                       push @uses, "use(unsafe.Pointer(_p$n))";
+                       $n++;
+               } elsif($type =~ /^\[\](.*)/) {
+                       # Convert slice into pointer, length.
+                       # Have to be careful not to take address of &a[0] if 
len == 0:
+                       # pass dummy pointer in that case.
+                       # Used to pass nil, but some OSes or simulators reject 
write(fd, nil, 0).
+                       $text .= "\tvar _p$n unsafe.Pointer\n";
+                       $text .= "\tif len($name) > 0 {\n\t\t_p$n = 
unsafe.Pointer(\&${name}[0])\n\t}";
+                       $text .= " else {\n\t\t_p$n = 
unsafe.Pointer(&_zero)\n\t}";
+                       $text .= "\n";
+                       push @args, "uintptr(_p$n)", "uintptr(len($name))";
+                       $n++;
+               } elsif($type eq "int64" && ($openbsd || $netbsd)) {
+                       push @args, "0";
+                       if($_32bit eq "big-endian") {
+                               push @args, "uintptr($name>>32)", 
"uintptr($name)";
+                       } elsif($_32bit eq "little-endian") {
+                               push @args, "uintptr($name)", 
"uintptr($name>>32)";
+                       } else {
+                               push @args, "uintptr($name)";
+                       }
+               } elsif($type eq "int64" && $dragonfly) {
+                       if ($func !~ /^extp(read|write)/i) {
+                               push @args, "0";
+                       }
+                       if($_32bit eq "big-endian") {
+                               push @args, "uintptr($name>>32)", 
"uintptr($name)";
+                       } elsif($_32bit eq "little-endian") {
+                               push @args, "uintptr($name)", 
"uintptr($name>>32)";
+                       } else {
+                               push @args, "uintptr($name)";
+                       }
+               } elsif($type eq "int64" && $_32bit ne "") {
+                       if(@args % 2 && $arm) {
+                               # arm abi specifies 64-bit argument uses 
+                               # (even, odd) pair
+                               push @args, "0"
+                       }
+                       if($_32bit eq "big-endian") {
+                               push @args, "uintptr($name>>32)", 
"uintptr($name)";
+                       } else {
+                               push @args, "uintptr($name)", 
"uintptr($name>>32)";
+                       }
+               } else {
+                       push @args, "uintptr($name)";
+               }
+       }
+
+       # Determine which form to use; pad args with zeros.
+       my $asm = "Syscall";
+       if ($nonblock) {
+               $asm = "RawSyscall";
+       }
+       if(@args <= 3) {
+               while(@args < 3) {
+                       push @args, "0";
+               }
+       } elsif(@args <= 6) {
+               $asm .= "6";
+               while(@args < 6) {
+                       push @args, "0";
+               }
+       } elsif(@args <= 9) {
+               $asm .= "9";
+               while(@args < 9) {
+                       push @args, "0";
+               }
+       } else {
+               print STDERR "$ARGV:$.: too many arguments to system call\n";
+       }
+
+       # System call number.
+       if($sysname eq "") {
+               $sysname = "SYS_$func";
+               $sysname =~ s/([a-z])([A-Z])/${1}_$2/g; # turn FooBar into 
Foo_Bar
+               $sysname =~ y/a-z/A-Z/;
+       }
+
+       # Actual call.
+       my $args = join(', ', @args);
+       my $call = "$asm($sysname, $args)";
+
+       # Assign return values.
+       my $body = "";
+       my @ret = ("_", "_", "_");
+       my $do_errno = 0;
+       for(my $i=0; $i<@out; $i++) {
+               my $p = $out[$i];
+               my ($name, $type) = parseparam($p);
+               my $reg = "";
+               if($name eq "err" && !$plan9) {
+                       $reg = "e1";
+                       $ret[2] = $reg;
+                       $do_errno = 1;
+               } elsif($name eq "err" && $plan9) {
+                       $ret[0] = "r0";
+                       $ret[2] = "e1";
+                       next;
+               } else {
+                       $reg = sprintf("r%d", $i);
+                       $ret[$i] = $reg;
+               }
+               if($type eq "bool") {
+                       $reg = "$reg != 0";
+               }
+               if($type eq "int64" && $_32bit ne "") {
+                       # 64-bit number in r1:r0 or r0:r1.
+                       if($i+2 > @out) {
+                               print STDERR "$ARGV:$.: not enough registers 
for int64 return\n";
+                       }
+                       if($_32bit eq "big-endian") {
+                               $reg = sprintf("int64(r%d)<<32 | int64(r%d)", 
$i, $i+1);
+                       } else {
+                               $reg = sprintf("int64(r%d)<<32 | int64(r%d)", 
$i+1, $i);
+                       }
+                       $ret[$i] = sprintf("r%d", $i);
+                       $ret[$i+1] = sprintf("r%d", $i+1);
+               }
+               if($reg ne "e1" || $plan9) {
+                       $body .= "\t$name = $type($reg)\n";
+               }
+       }
+       if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
+               $text .= "\t$call\n";
+       } else {
+               $text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
+       }
+       foreach my $use (@uses) {
+               $text .= "\t$use\n";
+       }
+       $text .= $body;
+       
+       if ($plan9 && $ret[2] eq "e1") {
+               $text .= "\tif int32(r0) == -1 {\n";
+               $text .= "\t\terr = e1\n";
+               $text .= "\t}\n";
+       } elsif ($do_errno) {
+               $text .= "\tif e1 != 0 {\n";
+               $text .= "\t\terr = errnoErr(e1)\n";
+               $text .= "\t}\n";
+       }
+       $text .= "\treturn\n";
+       $text .= "}\n\n";
+}
+
+chomp $text;
+chomp $text;
+
+if($errors) {
+       exit 1;
+}
+
+print <<EOF;
+// $cmdline
+// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
+
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
+
+package unix
+
+import (
+       "syscall"
+       "unsafe"
+)
+
+var _ syscall.Errno
+
+$text
+EOF
+exit 0;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl 
b/newtmgr/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl
new file mode 100755
index 0000000..06bade7
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl
@@ -0,0 +1,294 @@
+#!/usr/bin/env perl
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# This program reads a file containing function prototypes
+# (like syscall_solaris.go) and generates system call bodies.
+# The prototypes are marked by lines beginning with "//sys"
+# and read like func declarations if //sys is replaced by func, but:
+#      * The parameter lists must give a name for each argument.
+#        This includes return parameters.
+#      * The parameter lists must give a type for each argument:
+#        the (x, y, z int) shorthand is not allowed.
+#      * If the return parameter is an error number, it must be named err.
+#      * If go func name needs to be different than its libc name, 
+#      * or the function is not in libc, name could be specified
+#      * at the end, after "=" sign, like
+#        //sys getsockopt(s int, level int, name int, val uintptr, vallen 
*_Socklen) (err error) = libsocket.getsockopt
+
+use strict;
+
+my $cmdline = "mksyscall_solaris.pl " . join(' ', @ARGV);
+my $errors = 0;
+my $_32bit = "";
+
+binmode STDOUT;
+
+if($ARGV[0] eq "-b32") {
+       $_32bit = "big-endian";
+       shift;
+} elsif($ARGV[0] eq "-l32") {
+       $_32bit = "little-endian";
+       shift;
+}
+
+if($ARGV[0] =~ /^-/) {
+       print STDERR "usage: mksyscall_solaris.pl [-b32 | -l32] [file ...]\n";
+       exit 1;
+}
+
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
+       print STDERR "GOARCH or GOOS not defined in environment\n";
+       exit 1;
+}
+
+sub parseparamlist($) {
+       my ($list) = @_;
+       $list =~ s/^\s*//;
+       $list =~ s/\s*$//;
+       if($list eq "") {
+               return ();
+       }
+       return split(/\s*,\s*/, $list);
+}
+
+sub parseparam($) {
+       my ($p) = @_;
+       if($p !~ /^(\S*) (\S*)$/) {
+               print STDERR "$ARGV:$.: malformed parameter: $p\n";
+               $errors = 1;
+               return ("xx", "int");
+       }
+       return ($1, $2);
+}
+
+my $package = "";
+my $text = "";
+my $dynimports = "";
+my $linknames = "";
+my @vars = ();
+while(<>) {
+       chomp;
+       s/\s+/ /g;
+       s/^\s+//;
+       s/\s+$//;
+       $package = $1 if !$package && /^package (\S+)$/;
+       my $nonblock = /^\/\/sysnb /;
+       next if !/^\/\/sys / && !$nonblock;
+
+       # Line must be of the form
+       #       func Open(path string, mode int, perm int) (fd int, err error)
+       # Split into name, in params, out params.
+       if(!/^\/\/sys(nb)? 
(\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$/) {
+               print STDERR "$ARGV:$.: malformed //sys declaration\n";
+               $errors = 1;
+               next;
+       }
+       my ($nb, $func, $in, $out, $modname, $sysname) = ($1, $2, $3, $4, $5, 
$6);
+
+       # Split argument lists on comma.
+       my @in = parseparamlist($in);
+       my @out = parseparamlist($out);
+
+       # So file name.
+       if($modname eq "") {
+               $modname = "libc";
+       }
+
+       # System call name.
+       if($sysname eq "") {
+               $sysname = "$func";
+       }
+
+       # System call pointer variable name.
+       my $sysvarname = "proc$sysname";
+
+       my $strconvfunc = "BytePtrFromString";
+       my $strconvtype = "*byte";
+
+       $sysname =~ y/A-Z/a-z/; # All libc functions are lowercase.
+
+       # Runtime import of function to allow cross-platform builds.
+       $dynimports .= "//go:cgo_import_dynamic libc_${sysname} ${sysname} 
\"$modname.so\"\n";
+       # Link symbol to proc address variable.
+       $linknames .= "//go:linkname ${sysvarname} libc_${sysname}\n";
+       # Library proc address variable.
+       push @vars, $sysvarname;
+
+       # Go function header.
+       $out = join(', ', @out);
+       if($out ne "") {
+               $out = " ($out)";
+       }
+       if($text ne "") {
+               $text .= "\n"
+       }
+       $text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out;
+
+       # Check if err return available
+       my $errvar = "";
+       foreach my $p (@out) {
+               my ($name, $type) = parseparam($p);
+               if($type eq "error") {
+                       $errvar = $name;
+                       last;
+               }
+       }
+
+       # Prepare arguments to Syscall.
+       my @args = ();
+       my @uses = ();
+       my $n = 0;
+       foreach my $p (@in) {
+               my ($name, $type) = parseparam($p);
+               if($type =~ /^\*/) {
+                       push @args, "uintptr(unsafe.Pointer($name))";
+               } elsif($type eq "string" && $errvar ne "") {
+                       $text .= "\tvar _p$n $strconvtype\n";
+                       $text .= "\t_p$n, $errvar = $strconvfunc($name)\n";
+                       $text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
+                       push @args, "uintptr(unsafe.Pointer(_p$n))";
+                       push @uses, "use(unsafe.Pointer(_p$n))";
+                       $n++;
+               } elsif($type eq "string") {
+                       print STDERR "$ARGV:$.: $func uses string arguments, 
but has no error return\n";
+                       $text .= "\tvar _p$n $strconvtype\n";
+                       $text .= "\t_p$n, _ = $strconvfunc($name)\n";
+                       push @args, "uintptr(unsafe.Pointer(_p$n))";
+                       push @uses, "use(unsafe.Pointer(_p$n))";
+                       $n++;
+               } elsif($type =~ /^\[\](.*)/) {
+                       # Convert slice into pointer, length.
+                       # Have to be careful not to take address of &a[0] if 
len == 0:
+                       # pass nil in that case.
+                       $text .= "\tvar _p$n *$1\n";
+                       $text .= "\tif len($name) > 0 {\n\t\t_p$n = 
\&$name\[0]\n\t}\n";
+                       push @args, "uintptr(unsafe.Pointer(_p$n))", 
"uintptr(len($name))";
+                       $n++;
+               } elsif($type eq "int64" && $_32bit ne "") {
+                       if($_32bit eq "big-endian") {
+                               push @args, "uintptr($name >> 32)", 
"uintptr($name)";
+                       } else {
+                               push @args, "uintptr($name)", "uintptr($name >> 
32)";
+                       }
+               } elsif($type eq "bool") {
+                       $text .= "\tvar _p$n uint32\n";
+                       $text .= "\tif $name {\n\t\t_p$n = 1\n\t} else 
{\n\t\t_p$n = 0\n\t}\n";
+                       push @args, "uintptr(_p$n)";
+                       $n++;
+               } else {
+                       push @args, "uintptr($name)";
+               }
+       }
+       my $nargs = @args;
+
+       # Determine which form to use; pad args with zeros.
+       my $asm = "sysvicall6";
+       if ($nonblock) {
+               $asm = "rawSysvicall6";
+       }
+       if(@args <= 6) {
+               while(@args < 6) {
+                       push @args, "0";
+               }
+       } else {
+               print STDERR "$ARGV:$.: too many arguments to system call\n";
+       }
+
+       # Actual call.
+       my $args = join(', ', @args);
+       my $call = "$asm(uintptr(unsafe.Pointer(&$sysvarname)), $nargs, $args)";
+
+       # Assign return values.
+       my $body = "";
+       my $failexpr = "";
+       my @ret = ("_", "_", "_");
+       my @pout= ();
+       my $do_errno = 0;
+       for(my $i=0; $i<@out; $i++) {
+               my $p = $out[$i];
+               my ($name, $type) = parseparam($p);
+               my $reg = "";
+               if($name eq "err") {
+                       $reg = "e1";
+                       $ret[2] = $reg;
+                       $do_errno = 1;
+               } else {
+                       $reg = sprintf("r%d", $i);
+                       $ret[$i] = $reg;
+               }
+               if($type eq "bool") {
+                       $reg = "$reg != 0";
+               }
+               if($type eq "int64" && $_32bit ne "") {
+                       # 64-bit number in r1:r0 or r0:r1.
+                       if($i+2 > @out) {
+                               print STDERR "$ARGV:$.: not enough registers 
for int64 return\n";
+                       }
+                       if($_32bit eq "big-endian") {
+                               $reg = sprintf("int64(r%d)<<32 | int64(r%d)", 
$i, $i+1);
+                       } else {
+                               $reg = sprintf("int64(r%d)<<32 | int64(r%d)", 
$i+1, $i);
+                       }
+                       $ret[$i] = sprintf("r%d", $i);
+                       $ret[$i+1] = sprintf("r%d", $i+1);
+               }
+               if($reg ne "e1") {
+                       $body .= "\t$name = $type($reg)\n";
+               }
+       }
+       if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
+               $text .= "\t$call\n";
+       } else {
+               $text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
+       }
+       foreach my $use (@uses) {
+               $text .= "\t$use\n";
+       }
+       $text .= $body;
+
+       if ($do_errno) {
+               $text .= "\tif e1 != 0 {\n";
+               $text .= "\t\terr = e1\n";
+               $text .= "\t}\n";
+       }
+       $text .= "\treturn\n";
+       $text .= "}\n";
+}
+
+if($errors) {
+       exit 1;
+}
+
+print <<EOF;
+// $cmdline
+// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
+
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
+
+package $package
+
+import (
+       "syscall"
+       "unsafe"
+)
+EOF
+
+print "import \"golang.org/x/sys/unix\"\n" if $package ne "unix";
+
+my $vardecls = "\t" . join(",\n\t", @vars);
+$vardecls .= " syscallFunc";
+
+chomp($_=<<EOF);
+
+$dynimports
+$linknames
+var (
+$vardecls
+)
+
+$text
+EOF
+print $_;
+exit 0;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl 
b/newtmgr/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl
new file mode 100755
index 0000000..be67afa
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl
@@ -0,0 +1,264 @@
+#!/usr/bin/env perl
+
+# Copyright 2011 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+#
+# Parse the header files for OpenBSD and generate a Go usable sysctl MIB.
+#
+# Build a MIB with each entry being an array containing the level, type and
+# a hash that will contain additional entries if the current entry is a node.
+# We then walk this MIB and create a flattened sysctl name to OID hash.
+#
+
+use strict;
+
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
+       print STDERR "GOARCH or GOOS not defined in environment\n";
+       exit 1;
+}
+
+my $debug = 0;
+my %ctls = ();
+
+my @headers = qw (
+       sys/sysctl.h
+       sys/socket.h
+       sys/tty.h
+       sys/malloc.h
+       sys/mount.h
+       sys/namei.h
+       sys/sem.h
+       sys/shm.h
+       sys/vmmeter.h
+       uvm/uvm_param.h
+       uvm/uvm_swap_encrypt.h
+       ddb/db_var.h
+       net/if.h
+       net/if_pfsync.h
+       net/pipex.h
+       netinet/in.h
+       netinet/icmp_var.h
+       netinet/igmp_var.h
+       netinet/ip_ah.h
+       netinet/ip_carp.h
+       netinet/ip_divert.h
+       netinet/ip_esp.h
+       netinet/ip_ether.h
+       netinet/ip_gre.h
+       netinet/ip_ipcomp.h
+       netinet/ip_ipip.h
+       netinet/pim_var.h
+       netinet/tcp_var.h
+       netinet/udp_var.h
+       netinet6/in6.h
+       netinet6/ip6_divert.h
+       netinet6/pim6_var.h
+       netinet/icmp6.h
+       netmpls/mpls.h
+);
+
+my @ctls = qw (
+       kern
+       vm
+       fs
+       net
+       #debug                          # Special handling required
+       hw
+       #machdep                        # Arch specific
+       user
+       ddb
+       #vfs                            # Special handling required
+       fs.posix
+       kern.forkstat
+       kern.intrcnt
+       kern.malloc
+       kern.nchstats
+       kern.seminfo
+       kern.shminfo
+       kern.timecounter
+       kern.tty
+       kern.watchdog
+       net.bpf
+       net.ifq
+       net.inet
+       net.inet.ah
+       net.inet.carp
+       net.inet.divert
+       net.inet.esp
+       net.inet.etherip
+       net.inet.gre
+       net.inet.icmp
+       net.inet.igmp
+       net.inet.ip
+       net.inet.ip.ifq
+       net.inet.ipcomp
+       net.inet.ipip
+       net.inet.mobileip
+       net.inet.pfsync
+       net.inet.pim
+       net.inet.tcp
+       net.inet.udp
+       net.inet6
+       net.inet6.divert
+       net.inet6.ip6
+       net.inet6.icmp6
+       net.inet6.pim6
+       net.inet6.tcp6
+       net.inet6.udp6
+       net.mpls
+       net.mpls.ifq
+       net.key
+       net.pflow
+       net.pfsync
+       net.pipex
+       net.rt
+       vm.swapencrypt
+       #vfsgenctl                      # Special handling required
+);
+
+# Node name "fixups"
+my %ctl_map = (
+       "ipproto" => "net.inet",
+       "net.inet.ipproto" => "net.inet",
+       "net.inet6.ipv6proto" => "net.inet6",
+       "net.inet6.ipv6" => "net.inet6.ip6",
+       "net.inet.icmpv6" => "net.inet6.icmp6",
+       "net.inet6.divert6" => "net.inet6.divert",
+       "net.inet6.tcp6" => "net.inet.tcp",
+       "net.inet6.udp6" => "net.inet.udp",
+       "mpls" => "net.mpls",
+       "swpenc" => "vm.swapencrypt"
+);
+
+# Node mappings
+my %node_map = (
+       "net.inet.ip.ifq" => "net.ifq",
+       "net.inet.pfsync" => "net.pfsync",
+       "net.mpls.ifq" => "net.ifq"
+);
+
+my $ctlname;
+my %mib = ();
+my %sysctl = ();
+my $node;
+
+sub debug() {
+       print STDERR "$_[0]\n" if $debug;
+}
+
+# Walk the MIB and build a sysctl name to OID mapping.
+sub build_sysctl() {
+       my ($node, $name, $oid) = @_;
+       my %node = %{$node};
+       my @oid = @{$oid};
+
+       foreach my $key (sort keys %node) {
+               my @node = @{$node{$key}};
+               my $nodename = $name.($name ne '' ? '.' : '').$key;
+               my @nodeoid = (@oid, $node[0]);
+               if ($node[1] eq 'CTLTYPE_NODE') {
+                       if (exists $node_map{$nodename}) {
+                               $node = \%mib;
+                               $ctlname = $node_map{$nodename};
+                               foreach my $part (split /\./, $ctlname) {
+                                       $node = \%{@{$$node{$part}}[2]};
+                               }
+                       } else {
+                               $node = $node[2];
+                       }
+                       &build_sysctl($node, $nodename, \@nodeoid);
+               } elsif ($node[1] ne '') {
+                       $sysctl{$nodename} = \@nodeoid;
+               }
+       }
+}
+
+foreach my $ctl (@ctls) {
+       $ctls{$ctl} = $ctl;
+}
+
+# Build MIB
+foreach my $header (@headers) {
+       &debug("Processing $header...");
+       open HEADER, "/usr/include/$header" ||
+           print STDERR "Failed to open $header\n";
+       while (<HEADER>) {
+               if ($_ =~ /^#define\s+(CTL_NAMES)\s+{/ ||
+                   $_ =~ /^#define\s+(CTL_(.*)_NAMES)\s+{/ ||
+                   $_ =~ /^#define\s+((.*)CTL_NAMES)\s+{/) {
+                       if ($1 eq 'CTL_NAMES') {
+                               # Top level.
+                               $node = \%mib;
+                       } else {
+                               # Node.
+                               my $nodename = lc($2);
+                               if ($header =~ /^netinet\//) {
+                                       $ctlname = "net.inet.$nodename";
+                               } elsif ($header =~ /^netinet6\//) {
+                                       $ctlname = "net.inet6.$nodename";
+                               } elsif ($header =~ /^net\//) {
+                                       $ctlname = "net.$nodename";
+                               } else {
+                                       $ctlname = "$nodename";
+                                       $ctlname =~ s/^(fs|net|kern)_/$1\./;
+                               }
+                               if (exists $ctl_map{$ctlname}) {
+                                       $ctlname = $ctl_map{$ctlname};
+                               }
+                               if (not exists $ctls{$ctlname}) {
+                                       &debug("Ignoring $ctlname...");
+                                       next;
+                               }
+
+                               # Walk down from the top of the MIB.
+                               $node = \%mib;
+                               foreach my $part (split /\./, $ctlname) {
+                                       if (not exists $$node{$part}) {
+                                               &debug("Missing node $part");
+                                               $$node{$part} = [ 0, '', {} ];
+                                       }
+                                       $node = \%{@{$$node{$part}}[2]};
+                               }
+                       }
+
+                       # Populate current node with entries.
+                       my $i = -1;
+                       while (defined($_) && $_ !~ /^}/) {
+                               $_ = <HEADER>;
+                               $i++ if $_ =~ /{.*}/;
+                               next if $_ !~ 
/{\s+"(\w+)",\s+(CTLTYPE_[A-Z]+)\s+}/;
+                               $$node{$1} = [ $i, $2, {} ];
+                       }
+               }
+       }
+       close HEADER;
+}
+
+&build_sysctl(\%mib, "", []);
+
+print <<EOF;
+// mksysctl_openbsd.pl
+// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
+
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
+
+package unix;
+
+type mibentry struct {
+       ctlname string
+       ctloid []_C_int
+}
+
+var sysctlMib = []mibentry {
+EOF
+
+foreach my $name (sort keys %sysctl) {
+       my @oid = @{$sysctl{$name}};
+       print "\t{ \"$name\", []_C_int{ ", join(', ', @oid), " } }, \n";
+}
+
+print <<EOF;
+}
+EOF

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_darwin.pl
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_darwin.pl 
b/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_darwin.pl
new file mode 100755
index 0000000..d3e5147
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_darwin.pl
@@ -0,0 +1,39 @@
+#!/usr/bin/env perl
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+#
+# Generate system call table for Darwin from sys/syscall.h
+
+use strict;
+
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
+       print STDERR "GOARCH or GOOS not defined in environment\n";
+       exit 1;
+}
+
+my $command = "mksysnum_darwin.pl " . join(' ', @ARGV);
+
+print <<EOF;
+// $command
+// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
+
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
+
+package unix
+
+const (
+EOF
+
+while(<>){
+       if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){
+               my $name = $1;
+               my $num = $2;
+               $name =~ y/a-z/A-Z/;
+               print " SYS_$name = $num;"
+       }
+}
+
+print <<EOF;
+)
+EOF

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl 
b/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl
new file mode 100755
index 0000000..266a248
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl
@@ -0,0 +1,50 @@
+#!/usr/bin/env perl
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+#
+# Generate system call table for DragonFly from master list
+# (for example, /usr/src/sys/kern/syscalls.master).
+
+use strict;
+
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
+       print STDERR "GOARCH or GOOS not defined in environment\n";
+       exit 1;
+}
+
+my $command = "mksysnum_dragonfly.pl " . join(' ', @ARGV);
+
+print <<EOF;
+// $command
+// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
+
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
+
+package unix
+
+const (
+EOF
+
+while(<>){
+       if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){
+               my $num = $1;
+               my $proto = $2;
+               my $name = "SYS_$3";
+               $name =~ y/a-z/A-Z/;
+
+               # There are multiple entries for enosys and nosys, so comment 
them out.
+               if($name =~ /^SYS_E?NOSYS$/){
+                       $name = "// $name";
+               }
+               if($name eq 'SYS_SYS_EXIT'){
+                       $name = 'SYS_EXIT';
+               }
+
+               print " $name = $num;  // $proto\n";
+       }
+}
+
+print <<EOF;
+)
+EOF

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl 
b/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl
new file mode 100755
index 0000000..b767e12
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl
@@ -0,0 +1,63 @@
+#!/usr/bin/env perl
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+#
+# Generate system call table for FreeBSD from master list
+# (for example, /usr/src/sys/kern/syscalls.master).
+
+use strict;
+
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
+       print STDERR "GOARCH or GOOS not defined in environment\n";
+       exit 1;
+}
+
+my $command = "mksysnum_freebsd.pl " . join(' ', @ARGV);
+
+print <<EOF;
+// $command
+// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
+
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
+
+package unix
+
+const (
+EOF
+
+while(<>){
+       if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){
+               my $num = $1;
+               my $proto = $2;
+               my $name = "SYS_$3";
+               $name =~ y/a-z/A-Z/;
+
+               # There are multiple entries for enosys and nosys, so comment 
them out.
+               if($name =~ /^SYS_E?NOSYS$/){
+                       $name = "// $name";
+               }
+               if($name eq 'SYS_SYS_EXIT'){
+                       $name = 'SYS_EXIT';
+               }
+               if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){
+                       next
+               }
+
+               print " $name = $num;  // $proto\n";
+
+               # We keep Capsicum syscall numbers for FreeBSD
+               # 9-STABLE here because we are not sure whether they
+               # are mature and stable.
+               if($num == 513){
+                       print " SYS_CAP_NEW = 514 // { int cap_new(int fd, 
uint64_t rights); }\n";
+                       print " SYS_CAP_GETRIGHTS = 515 // { int 
cap_getrights(int fd, \\\n";
+                       print " SYS_CAP_ENTER = 516 // { int cap_enter(void); 
}\n";
+                       print " SYS_CAP_GETMODE = 517 // { int 
cap_getmode(u_int *modep); }\n";
+               }
+       }
+}
+
+print <<EOF;
+)
+EOF

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_linux.pl
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_linux.pl 
b/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_linux.pl
new file mode 100755
index 0000000..4d4017d
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_linux.pl
@@ -0,0 +1,58 @@
+#!/usr/bin/env perl
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+use strict;
+
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
+       print STDERR "GOARCH or GOOS not defined in environment\n";
+       exit 1;
+}
+
+my $command = "mksysnum_linux.pl ". join(' ', @ARGV);
+
+print <<EOF;
+// $command
+// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
+
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
+
+package unix
+
+const(
+EOF
+
+sub fmt {
+       my ($name, $num) = @_;
+       if($num > 999){
+               # ignore deprecated syscalls that are no longer implemented
+               # 
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716
+               return;
+       }
+       $name =~ y/a-z/A-Z/;
+       print " SYS_$name = $num;\n";
+}
+
+my $prev;
+open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc";
+while(<GCC>){
+       if(/^#define __NR_syscalls\s+/) {
+               # ignore redefinitions of __NR_syscalls
+       }
+       elsif(/^#define __NR_(\w+)\s+([0-9]+)/){
+               $prev = $2;
+               fmt($1, $2);
+       }
+       elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){
+               $prev = $2;
+               fmt($1, $2);
+       }
+       elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){
+               fmt($1, $prev+$2)
+       }
+}
+
+print <<EOF;
+)
+EOF

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl 
b/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl
new file mode 100755
index 0000000..e74616a
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl
@@ -0,0 +1,58 @@
+#!/usr/bin/env perl
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+#
+# Generate system call table for OpenBSD from master list
+# (for example, /usr/src/sys/kern/syscalls.master).
+
+use strict;
+
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
+       print STDERR "GOARCH or GOOS not defined in environment\n";
+       exit 1;
+}
+
+my $command = "mksysnum_netbsd.pl " . join(' ', @ARGV);
+
+print <<EOF;
+// $command
+// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
+
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
+
+package unix
+
+const (
+EOF
+
+my $line = '';
+while(<>){
+       if($line =~ /^(.*)\\$/) {
+               # Handle continuation
+               $line = $1;
+               $_ =~ s/^\s+//;
+               $line .= $_;
+       } else {
+               # New line
+               $line = $_;
+       }
+       next if $line =~ /\\$/;
+       if($line =~ 
/^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/)
 {
+               my $num = $1;
+               my $proto = $6;
+               my $compat = $8;
+               my $name = "$7_$9";
+
+               $name = "$7_$11" if $11 ne '';
+               $name =~ y/a-z/A-Z/;
+
+               if($compat eq '' || $compat eq '30' || $compat eq '50') {
+                       print " $name = $num;  // $proto\n";
+               }
+       }
+}
+
+print <<EOF;
+)
+EOF

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl 
b/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl
new file mode 100755
index 0000000..ae5aad5
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl
@@ -0,0 +1,50 @@
+#!/usr/bin/env perl
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+#
+# Generate system call table for OpenBSD from master list
+# (for example, /usr/src/sys/kern/syscalls.master).
+
+use strict;
+
+if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
+       print STDERR "GOARCH or GOOS not defined in environment\n";
+       exit 1;
+}
+
+my $command = "mksysnum_openbsd.pl " . join(' ', @ARGV);
+
+print <<EOF;
+// $command
+// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
+
+// +build $ENV{'GOARCH'},$ENV{'GOOS'}
+
+package unix
+
+const (
+EOF
+
+while(<>){
+       if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){
+               my $num = $1;
+               my $proto = $3;
+               my $name = $4;
+               $name =~ y/a-z/A-Z/;
+
+               # There are multiple entries for enosys and nosys, so comment 
them out.
+               if($name =~ /^SYS_E?NOSYS$/){
+                       $name = "// $name";
+               }
+               if($name eq 'SYS_SYS_EXIT'){
+                       $name = 'SYS_EXIT';
+               }
+
+               print " $name = $num;  // $proto\n";
+       }
+}
+
+print <<EOF;
+)
+EOF

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/race.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/race.go 
b/newtmgr/vendor/golang.org/x/sys/unix/race.go
new file mode 100644
index 0000000..3c7627e
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/race.go
@@ -0,0 +1,30 @@
+// Copyright 2012 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin,race linux,race freebsd,race
+
+package unix
+
+import (
+       "runtime"
+       "unsafe"
+)
+
+const raceenabled = true
+
+func raceAcquire(addr unsafe.Pointer) {
+       runtime.RaceAcquire(addr)
+}
+
+func raceReleaseMerge(addr unsafe.Pointer) {
+       runtime.RaceReleaseMerge(addr)
+}
+
+func raceReadRange(addr unsafe.Pointer, len int) {
+       runtime.RaceReadRange(addr, len)
+}
+
+func raceWriteRange(addr unsafe.Pointer, len int) {
+       runtime.RaceWriteRange(addr, len)
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/race0.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/race0.go 
b/newtmgr/vendor/golang.org/x/sys/unix/race0.go
new file mode 100644
index 0000000..f8678e0
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/race0.go
@@ -0,0 +1,25 @@
+// Copyright 2012 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin,!race linux,!race freebsd,!race netbsd openbsd solaris 
dragonfly
+
+package unix
+
+import (
+       "unsafe"
+)
+
+const raceenabled = false
+
+func raceAcquire(addr unsafe.Pointer) {
+}
+
+func raceReleaseMerge(addr unsafe.Pointer) {
+}
+
+func raceReadRange(addr unsafe.Pointer, len int) {
+}
+
+func raceWriteRange(addr unsafe.Pointer, len int) {
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/sockcmsg_linux.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/sockcmsg_linux.go 
b/newtmgr/vendor/golang.org/x/sys/unix/sockcmsg_linux.go
new file mode 100644
index 0000000..d9ff473
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/sockcmsg_linux.go
@@ -0,0 +1,36 @@
+// Copyright 2011 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Socket control messages
+
+package unix
+
+import "unsafe"
+
+// UnixCredentials encodes credentials into a socket control message
+// for sending to another process. This can be used for
+// authentication.
+func UnixCredentials(ucred *Ucred) []byte {
+       b := make([]byte, CmsgSpace(SizeofUcred))
+       h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
+       h.Level = SOL_SOCKET
+       h.Type = SCM_CREDENTIALS
+       h.SetLen(CmsgLen(SizeofUcred))
+       *((*Ucred)(cmsgData(h))) = *ucred
+       return b
+}
+
+// ParseUnixCredentials decodes a socket control message that contains
+// credentials in a Ucred structure. To receive such a message, the
+// SO_PASSCRED option must be enabled on the socket.
+func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) {
+       if m.Header.Level != SOL_SOCKET {
+               return nil, EINVAL
+       }
+       if m.Header.Type != SCM_CREDENTIALS {
+               return nil, EINVAL
+       }
+       ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0]))
+       return &ucred, nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/sockcmsg_unix.go 
b/newtmgr/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
new file mode 100644
index 0000000..f1493a3
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
@@ -0,0 +1,103 @@
+// Copyright 2011 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
+
+// Socket control messages
+
+package unix
+
+import "unsafe"
+
+// Round the length of a raw sockaddr up to align it properly.
+func cmsgAlignOf(salen int) int {
+       salign := sizeofPtr
+       // NOTE: It seems like 64-bit Darwin and DragonFly BSD kernels
+       // still require 32-bit aligned access to network subsystem.
+       if darwin64Bit || dragonfly64Bit {
+               salign = 4
+       }
+       return (salen + salign - 1) & ^(salign - 1)
+}
+
+// CmsgLen returns the value to store in the Len field of the Cmsghdr
+// structure, taking into account any necessary alignment.
+func CmsgLen(datalen int) int {
+       return cmsgAlignOf(SizeofCmsghdr) + datalen
+}
+
+// CmsgSpace returns the number of bytes an ancillary element with
+// payload of the passed data length occupies.
+func CmsgSpace(datalen int) int {
+       return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen)
+}
+
+func cmsgData(h *Cmsghdr) unsafe.Pointer {
+       return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + 
uintptr(cmsgAlignOf(SizeofCmsghdr)))
+}
+
+// SocketControlMessage represents a socket control message.
+type SocketControlMessage struct {
+       Header Cmsghdr
+       Data   []byte
+}
+
+// ParseSocketControlMessage parses b as an array of socket control
+// messages.
+func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) {
+       var msgs []SocketControlMessage
+       i := 0
+       for i+CmsgLen(0) <= len(b) {
+               h, dbuf, err := socketControlMessageHeaderAndData(b[i:])
+               if err != nil {
+                       return nil, err
+               }
+               m := SocketControlMessage{Header: *h, Data: dbuf}
+               msgs = append(msgs, m)
+               i += cmsgAlignOf(int(h.Len))
+       }
+       return msgs, nil
+}
+
+func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) {
+       h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
+       if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) {
+               return nil, nil, EINVAL
+       }
+       return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil
+}
+
+// UnixRights encodes a set of open file descriptors into a socket
+// control message for sending to another process.
+func UnixRights(fds ...int) []byte {
+       datalen := len(fds) * 4
+       b := make([]byte, CmsgSpace(datalen))
+       h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
+       h.Level = SOL_SOCKET
+       h.Type = SCM_RIGHTS
+       h.SetLen(CmsgLen(datalen))
+       data := cmsgData(h)
+       for _, fd := range fds {
+               *(*int32)(data) = int32(fd)
+               data = unsafe.Pointer(uintptr(data) + 4)
+       }
+       return b
+}
+
+// ParseUnixRights decodes a socket control message that contains an
+// integer array of open file descriptors from another process.
+func ParseUnixRights(m *SocketControlMessage) ([]int, error) {
+       if m.Header.Level != SOL_SOCKET {
+               return nil, EINVAL
+       }
+       if m.Header.Type != SCM_RIGHTS {
+               return nil, EINVAL
+       }
+       fds := make([]int, len(m.Data)>>2)
+       for i, j := 0, 0; i < len(m.Data); i += 4 {
+               fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i])))
+               j++
+       }
+       return fds, nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/str.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/str.go 
b/newtmgr/vendor/golang.org/x/sys/unix/str.go
new file mode 100644
index 0000000..35ed664
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/str.go
@@ -0,0 +1,26 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
+
+package unix
+
+func itoa(val int) string { // do it here rather than with fmt to avoid 
dependency
+       if val < 0 {
+               return "-" + uitoa(uint(-val))
+       }
+       return uitoa(uint(val))
+}
+
+func uitoa(val uint) string {
+       var buf [32]byte // big enough for int64
+       i := len(buf) - 1
+       for val >= 10 {
+               buf[i] = byte(val%10 + '0')
+               i--
+               val /= 10
+       }
+       buf[i] = byte(val + '0')
+       return string(buf[i:])
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/syscall.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/syscall.go 
b/newtmgr/vendor/golang.org/x/sys/unix/syscall.go
new file mode 100644
index 0000000..571e699
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/syscall.go
@@ -0,0 +1,76 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
+
+// Package unix contains an interface to the low-level operating system
+// primitives.  OS details vary depending on the underlying system, and
+// by default, godoc will display OS-specific documentation for the current
+// system.  If you want godoc to display OS documentation for another
+// system, set $GOOS and $GOARCH to the desired system.  For example, if
+// you want to view documentation for freebsd/arm on linux/amd64, set $GOOS
+// to freebsd and $GOARCH to arm.
+// The primary use of this package is inside other packages that provide a more
+// portable interface to the system, such as "os", "time" and "net".  Use
+// those packages rather than this one if you can.
+// For details of the functions and data types in this package consult
+// the manuals for the appropriate operating system.
+// These calls return err == nil to indicate success; otherwise
+// err represents an operating system error describing the failure and
+// holds a value of type syscall.Errno.
+package unix
+
+import "unsafe"
+
+// ByteSliceFromString returns a NUL-terminated slice of bytes
+// containing the text of s. If s contains a NUL byte at any
+// location, it returns (nil, EINVAL).
+func ByteSliceFromString(s string) ([]byte, error) {
+       for i := 0; i < len(s); i++ {
+               if s[i] == 0 {
+                       return nil, EINVAL
+               }
+       }
+       a := make([]byte, len(s)+1)
+       copy(a, s)
+       return a, nil
+}
+
+// BytePtrFromString returns a pointer to a NUL-terminated array of
+// bytes containing the text of s. If s contains a NUL byte at any
+// location, it returns (nil, EINVAL).
+func BytePtrFromString(s string) (*byte, error) {
+       a, err := ByteSliceFromString(s)
+       if err != nil {
+               return nil, err
+       }
+       return &a[0], nil
+}
+
+// Single-word zero for use when we need a valid pointer to 0 bytes.
+// See mkunix.pl.
+var _zero uintptr
+
+func (ts *Timespec) Unix() (sec int64, nsec int64) {
+       return int64(ts.Sec), int64(ts.Nsec)
+}
+
+func (tv *Timeval) Unix() (sec int64, nsec int64) {
+       return int64(tv.Sec), int64(tv.Usec) * 1000
+}
+
+func (ts *Timespec) Nano() int64 {
+       return int64(ts.Sec)*1e9 + int64(ts.Nsec)
+}
+
+func (tv *Timeval) Nano() int64 {
+       return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000
+}
+
+func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + 
int64(tv.Usec)*1e3 }
+
+// use is a no-op, but the compiler cannot see that it is.
+// Calling use(p) ensures that p is kept live until that point.
+//go:noescape
+func use(p unsafe.Pointer)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/syscall_bsd.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/syscall_bsd.go 
b/newtmgr/vendor/golang.org/x/sys/unix/syscall_bsd.go
new file mode 100644
index 0000000..e967176
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/syscall_bsd.go
@@ -0,0 +1,628 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin dragonfly freebsd netbsd openbsd
+
+// BSD system call wrappers shared by *BSD based systems
+// including OS X (Darwin) and FreeBSD.  Like the other
+// syscall_*.go files it is compiled as Go code but also
+// used as input to mksyscall which parses the //sys
+// lines and generates system call stubs.
+
+package unix
+
+import (
+       "runtime"
+       "syscall"
+       "unsafe"
+)
+
+/*
+ * Wrapped
+ */
+
+//sysnb        getgroups(ngid int, gid *_Gid_t) (n int, err error)
+//sysnb        setgroups(ngid int, gid *_Gid_t) (err error)
+
+func Getgroups() (gids []int, err error) {
+       n, err := getgroups(0, nil)
+       if err != nil {
+               return nil, err
+       }
+       if n == 0 {
+               return nil, nil
+       }
+
+       // Sanity check group count.  Max is 16 on BSD.
+       if n < 0 || n > 1000 {
+               return nil, EINVAL
+       }
+
+       a := make([]_Gid_t, n)
+       n, err = getgroups(n, &a[0])
+       if err != nil {
+               return nil, err
+       }
+       gids = make([]int, n)
+       for i, v := range a[0:n] {
+               gids[i] = int(v)
+       }
+       return
+}
+
+func Setgroups(gids []int) (err error) {
+       if len(gids) == 0 {
+               return setgroups(0, nil)
+       }
+
+       a := make([]_Gid_t, len(gids))
+       for i, v := range gids {
+               a[i] = _Gid_t(v)
+       }
+       return setgroups(len(a), &a[0])
+}
+
+func ReadDirent(fd int, buf []byte) (n int, err error) {
+       // Final argument is (basep *uintptr) and the syscall doesn't take nil.
+       // 64 bits should be enough. (32 bits isn't even on 386). Since the
+       // actual system call is getdirentries64, 64 is a good guess.
+       // TODO(rsc): Can we use a single global basep for all calls?
+       var base = (*uintptr)(unsafe.Pointer(new(uint64)))
+       return Getdirentries(fd, buf, base)
+}
+
+// Wait status is 7 bits at bottom, either 0 (exited),
+// 0x7F (stopped), or a signal number that caused an exit.
+// The 0x80 bit is whether there was a core dump.
+// An extra number (exit code, signal causing a stop)
+// is in the high bits.
+
+type WaitStatus uint32
+
+const (
+       mask  = 0x7F
+       core  = 0x80
+       shift = 8
+
+       exited  = 0
+       stopped = 0x7F
+)
+
+func (w WaitStatus) Exited() bool { return w&mask == exited }
+
+func (w WaitStatus) ExitStatus() int {
+       if w&mask != exited {
+               return -1
+       }
+       return int(w >> shift)
+}
+
+func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != 0 }
+
+func (w WaitStatus) Signal() syscall.Signal {
+       sig := syscall.Signal(w & mask)
+       if sig == stopped || sig == 0 {
+               return -1
+       }
+       return sig
+}
+
+func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 }
+
+func (w WaitStatus) Stopped() bool { return w&mask == stopped && 
syscall.Signal(w>>shift) != SIGSTOP }
+
+func (w WaitStatus) Continued() bool { return w&mask == stopped && 
syscall.Signal(w>>shift) == SIGSTOP }
+
+func (w WaitStatus) StopSignal() syscall.Signal {
+       if !w.Stopped() {
+               return -1
+       }
+       return syscall.Signal(w>>shift) & 0xFF
+}
+
+func (w WaitStatus) TrapCause() int { return -1 }
+
+//sys  wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, 
err error)
+
+func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid 
int, err error) {
+       var status _C_int
+       wpid, err = wait4(pid, &status, options, rusage)
+       if wstatus != nil {
+               *wstatus = WaitStatus(status)
+       }
+       return
+}
+
+//sys  accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err 
error)
+//sys  bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
+//sys  connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
+//sysnb        socket(domain int, typ int, proto int) (fd int, err error)
+//sys  getsockopt(s int, level int, name int, val unsafe.Pointer, vallen 
*_Socklen) (err error)
+//sys  setsockopt(s int, level int, name int, val unsafe.Pointer, vallen 
uintptr) (err error)
+//sysnb        getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) 
(err error)
+//sysnb        getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) 
(err error)
+//sys  Shutdown(s int, how int) (err error)
+
+func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
+       if sa.Port < 0 || sa.Port > 0xFFFF {
+               return nil, 0, EINVAL
+       }
+       sa.raw.Len = SizeofSockaddrInet4
+       sa.raw.Family = AF_INET
+       p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
+       p[0] = byte(sa.Port >> 8)
+       p[1] = byte(sa.Port)
+       for i := 0; i < len(sa.Addr); i++ {
+               sa.raw.Addr[i] = sa.Addr[i]
+       }
+       return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
+}
+
+func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) {
+       if sa.Port < 0 || sa.Port > 0xFFFF {
+               return nil, 0, EINVAL
+       }
+       sa.raw.Len = SizeofSockaddrInet6
+       sa.raw.Family = AF_INET6
+       p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
+       p[0] = byte(sa.Port >> 8)
+       p[1] = byte(sa.Port)
+       sa.raw.Scope_id = sa.ZoneId
+       for i := 0; i < len(sa.Addr); i++ {
+               sa.raw.Addr[i] = sa.Addr[i]
+       }
+       return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
+}
+
+func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
+       name := sa.Name
+       n := len(name)
+       if n >= len(sa.raw.Path) || n == 0 {
+               return nil, 0, EINVAL
+       }
+       sa.raw.Len = byte(3 + n) // 2 for Family, Len; 1 for NUL
+       sa.raw.Family = AF_UNIX
+       for i := 0; i < n; i++ {
+               sa.raw.Path[i] = int8(name[i])
+       }
+       return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
+}
+
+func (sa *SockaddrDatalink) sockaddr() (unsafe.Pointer, _Socklen, error) {
+       if sa.Index == 0 {
+               return nil, 0, EINVAL
+       }
+       sa.raw.Len = sa.Len
+       sa.raw.Family = AF_LINK
+       sa.raw.Index = sa.Index
+       sa.raw.Type = sa.Type
+       sa.raw.Nlen = sa.Nlen
+       sa.raw.Alen = sa.Alen
+       sa.raw.Slen = sa.Slen
+       for i := 0; i < len(sa.raw.Data); i++ {
+               sa.raw.Data[i] = sa.Data[i]
+       }
+       return unsafe.Pointer(&sa.raw), SizeofSockaddrDatalink, nil
+}
+
+func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
+       switch rsa.Addr.Family {
+       case AF_LINK:
+               pp := (*RawSockaddrDatalink)(unsafe.Pointer(rsa))
+               sa := new(SockaddrDatalink)
+               sa.Len = pp.Len
+               sa.Family = pp.Family
+               sa.Index = pp.Index
+               sa.Type = pp.Type
+               sa.Nlen = pp.Nlen
+               sa.Alen = pp.Alen
+               sa.Slen = pp.Slen
+               for i := 0; i < len(sa.Data); i++ {
+                       sa.Data[i] = pp.Data[i]
+               }
+               return sa, nil
+
+       case AF_UNIX:
+               pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
+               if pp.Len < 2 || pp.Len > SizeofSockaddrUnix {
+                       return nil, EINVAL
+               }
+               sa := new(SockaddrUnix)
+
+               // Some BSDs include the trailing NUL in the length, whereas
+               // others do not. Work around this by subtracting the leading
+               // family and len. The path is then scanned to see if a NUL
+               // terminator still exists within the length.
+               n := int(pp.Len) - 2 // subtract leading Family, Len
+               for i := 0; i < n; i++ {
+                       if pp.Path[i] == 0 {
+                               // found early NUL; assume Len included the NUL
+                               // or was overestimating.
+                               n = i
+                               break
+                       }
+               }
+               bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
+               sa.Name = string(bytes)
+               return sa, nil
+
+       case AF_INET:
+               pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
+               sa := new(SockaddrInet4)
+               p := (*[2]byte)(unsafe.Pointer(&pp.Port))
+               sa.Port = int(p[0])<<8 + int(p[1])
+               for i := 0; i < len(sa.Addr); i++ {
+                       sa.Addr[i] = pp.Addr[i]
+               }
+               return sa, nil
+
+       case AF_INET6:
+               pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
+               sa := new(SockaddrInet6)
+               p := (*[2]byte)(unsafe.Pointer(&pp.Port))
+               sa.Port = int(p[0])<<8 + int(p[1])
+               sa.ZoneId = pp.Scope_id
+               for i := 0; i < len(sa.Addr); i++ {
+                       sa.Addr[i] = pp.Addr[i]
+               }
+               return sa, nil
+       }
+       return nil, EAFNOSUPPORT
+}
+
+func Accept(fd int) (nfd int, sa Sockaddr, err error) {
+       var rsa RawSockaddrAny
+       var len _Socklen = SizeofSockaddrAny
+       nfd, err = accept(fd, &rsa, &len)
+       if err != nil {
+               return
+       }
+       if runtime.GOOS == "darwin" && len == 0 {
+               // Accepted socket has no address.
+               // This is likely due to a bug in xnu kernels,
+               // where instead of ECONNABORTED error socket
+               // is accepted, but has no address.
+               Close(nfd)
+               return 0, nil, ECONNABORTED
+       }
+       sa, err = anyToSockaddr(&rsa)
+       if err != nil {
+               Close(nfd)
+               nfd = 0
+       }
+       return
+}
+
+func Getsockname(fd int) (sa Sockaddr, err error) {
+       var rsa RawSockaddrAny
+       var len _Socklen = SizeofSockaddrAny
+       if err = getsockname(fd, &rsa, &len); err != nil {
+               return
+       }
+       // TODO(jsing): DragonFly has a "bug" (see issue 3349), which should be
+       // reported upstream.
+       if runtime.GOOS == "dragonfly" && rsa.Addr.Family == AF_UNSPEC && 
rsa.Addr.Len == 0 {
+               rsa.Addr.Family = AF_UNIX
+               rsa.Addr.Len = SizeofSockaddrUnix
+       }
+       return anyToSockaddr(&rsa)
+}
+
+//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
+
+func GetsockoptByte(fd, level, opt int) (value byte, err error) {
+       var n byte
+       vallen := _Socklen(1)
+       err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen)
+       return n, err
+}
+
+func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) {
+       vallen := _Socklen(4)
+       err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
+       return value, err
+}
+
+func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) {
+       var value IPMreq
+       vallen := _Socklen(SizeofIPMreq)
+       err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+       return &value, err
+}
+
+func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) {
+       var value IPv6Mreq
+       vallen := _Socklen(SizeofIPv6Mreq)
+       err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+       return &value, err
+}
+
+func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
+       var value IPv6MTUInfo
+       vallen := _Socklen(SizeofIPv6MTUInfo)
+       err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+       return &value, err
+}
+
+func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) {
+       var value ICMPv6Filter
+       vallen := _Socklen(SizeofICMPv6Filter)
+       err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+       return &value, err
+}
+
+//sys   recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen 
*_Socklen) (n int, err error)
+//sys   sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen 
_Socklen) (err error)
+//sys  recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
+
+func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, 
from Sockaddr, err error) {
+       var msg Msghdr
+       var rsa RawSockaddrAny
+       msg.Name = (*byte)(unsafe.Pointer(&rsa))
+       msg.Namelen = uint32(SizeofSockaddrAny)
+       var iov Iovec
+       if len(p) > 0 {
+               iov.Base = (*byte)(unsafe.Pointer(&p[0]))
+               iov.SetLen(len(p))
+       }
+       var dummy byte
+       if len(oob) > 0 {
+               // receive at least one normal byte
+               if len(p) == 0 {
+                       iov.Base = &dummy
+                       iov.SetLen(1)
+               }
+               msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
+               msg.SetControllen(len(oob))
+       }
+       msg.Iov = &iov
+       msg.Iovlen = 1
+       if n, err = recvmsg(fd, &msg, flags); err != nil {
+               return
+       }
+       oobn = int(msg.Controllen)
+       recvflags = int(msg.Flags)
+       // source address is only specified if the socket is unconnected
+       if rsa.Addr.Family != AF_UNSPEC {
+               from, err = anyToSockaddr(&rsa)
+       }
+       return
+}
+
+//sys  sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
+
+func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
+       _, err = SendmsgN(fd, p, oob, to, flags)
+       return
+}
+
+func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err 
error) {
+       var ptr unsafe.Pointer
+       var salen _Socklen
+       if to != nil {
+               ptr, salen, err = to.sockaddr()
+               if err != nil {
+                       return 0, err
+               }
+       }
+       var msg Msghdr
+       msg.Name = (*byte)(unsafe.Pointer(ptr))
+       msg.Namelen = uint32(salen)
+       var iov Iovec
+       if len(p) > 0 {
+               iov.Base = (*byte)(unsafe.Pointer(&p[0]))
+               iov.SetLen(len(p))
+       }
+       var dummy byte
+       if len(oob) > 0 {
+               // send at least one normal byte
+               if len(p) == 0 {
+                       iov.Base = &dummy
+                       iov.SetLen(1)
+               }
+               msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
+               msg.SetControllen(len(oob))
+       }
+       msg.Iov = &iov
+       msg.Iovlen = 1
+       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) {
+       mib, err := sysctlmib(name, args...)
+       if err != nil {
+               return "", err
+       }
+
+       // Find size.
+       n := uintptr(0)
+       if err := sysctl(mib, nil, &n, nil, 0); err != nil {
+               return "", err
+       }
+       if n == 0 {
+               return "", nil
+       }
+
+       // Read into buffer of that size.
+       buf := make([]byte, n)
+       if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
+               return "", err
+       }
+
+       // Throw away terminating NUL.
+       if n > 0 && buf[n-1] == '\x00' {
+               n--
+       }
+       return string(buf[0:n]), nil
+}
+
+func SysctlUint32(name string) (uint32, error) {
+       return SysctlUint32Args(name)
+}
+
+func SysctlUint32Args(name string, args ...int) (uint32, error) {
+       mib, err := sysctlmib(name, args...)
+       if err != nil {
+               return 0, err
+       }
+
+       n := uintptr(4)
+       buf := make([]byte, 4)
+       if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
+               return 0, err
+       }
+       if n != 4 {
+               return 0, EIO
+       }
+       return *(*uint32)(unsafe.Pointer(&buf[0])), nil
+}
+
+func SysctlUint64(name string, args ...int) (uint64, error) {
+       mib, err := sysctlmib(name, args...)
+       if err != nil {
+               return 0, err
+       }
+
+       n := uintptr(8)
+       buf := make([]byte, 8)
+       if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
+               return 0, err
+       }
+       if n != 8 {
+               return 0, EIO
+       }
+       return *(*uint64)(unsafe.Pointer(&buf[0])), nil
+}
+
+func SysctlRaw(name string, args ...int) ([]byte, error) {
+       mib, err := sysctlmib(name, args...)
+       if err != nil {
+               return nil, err
+       }
+
+       // Find size.
+       n := uintptr(0)
+       if err := sysctl(mib, nil, &n, nil, 0); err != nil {
+               return nil, err
+       }
+       if n == 0 {
+               return nil, nil
+       }
+
+       // Read into buffer of that size.
+       buf := make([]byte, n)
+       if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
+               return nil, err
+       }
+
+       // The actual call may return less than the original reported required
+       // size so ensure we deal with that.
+       return buf[:n], nil
+}
+
+//sys  utimes(path string, timeval *[2]Timeval) (err error)
+
+func Utimes(path string, tv []Timeval) error {
+       if tv == nil {
+               return utimes(path, nil)
+       }
+       if len(tv) != 2 {
+               return EINVAL
+       }
+       return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
+}
+
+func UtimesNano(path string, ts []Timespec) error {
+       if ts == nil {
+               return utimes(path, nil)
+       }
+       // TODO: The BSDs can do utimensat with SYS_UTIMENSAT but it
+       // isn't supported by darwin so this uses utimes instead
+       if len(ts) != 2 {
+               return EINVAL
+       }
+       // Not as efficient as it could be because Timespec and
+       // Timeval have different types in the different OSes
+       tv := [2]Timeval{
+               NsecToTimeval(TimespecToNsec(ts[0])),
+               NsecToTimeval(TimespecToNsec(ts[1])),
+       }
+       return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
+}
+
+//sys  futimes(fd int, timeval *[2]Timeval) (err error)
+
+func Futimes(fd int, tv []Timeval) error {
+       if tv == nil {
+               return futimes(fd, nil)
+       }
+       if len(tv) != 2 {
+               return EINVAL
+       }
+       return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
+}
+
+//sys  fcntl(fd int, cmd int, arg int) (val int, err error)
+
+// TODO: wrap
+//     Acct(name nil-string) (err error)
+//     Gethostuuid(uuid *byte, timeout *Timespec) (err error)
+//     Madvise(addr *byte, len int, behav int) (err error)
+//     Mprotect(addr *byte, len int, prot int) (err error)
+//     Msync(addr *byte, len int, flags int) (err error)
+//     Ptrace(req int, pid int, addr uintptr, data int) (ret uintptr, err 
error)
+
+var mapper = &mmapper{
+       active: make(map[*byte][]byte),
+       mmap:   mmap,
+       munmap: munmap,
+}
+
+func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, 
err error) {
+       return mapper.Mmap(fd, offset, length, prot, flags)
+}
+
+func Munmap(b []byte) (err error) {
+       return mapper.Munmap(b)
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/syscall_darwin.go
----------------------------------------------------------------------
diff --git a/newtmgr/vendor/golang.org/x/sys/unix/syscall_darwin.go 
b/newtmgr/vendor/golang.org/x/sys/unix/syscall_darwin.go
new file mode 100644
index 0000000..3d534d2
--- /dev/null
+++ b/newtmgr/vendor/golang.org/x/sys/unix/syscall_darwin.go
@@ -0,0 +1,511 @@
+// Copyright 2009,2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Darwin system calls.
+// This file is compiled as ordinary Go code,
+// but it is also input to mksyscall,
+// which parses the //sys lines and generates system call stubs.
+// Note that sometimes we use a lowercase //sys name and wrap
+// it in our own nicer implementation, either here or in
+// syscall_bsd.go or syscall_unix.go.
+
+package unix
+
+import (
+       errorspkg "errors"
+       "syscall"
+       "unsafe"
+)
+
+const ImplementsGetwd = true
+
+func Getwd() (string, error) {
+       buf := make([]byte, 2048)
+       attrs, err := getAttrList(".", attrList{CommonAttr: attrCmnFullpath}, 
buf, 0)
+       if err == nil && len(attrs) == 1 && len(attrs[0]) >= 2 {
+               wd := string(attrs[0])
+               // Sanity check that it's an absolute path and ends
+               // in a null byte, which we then strip.
+               if wd[0] == '/' && wd[len(wd)-1] == 0 {
+                       return wd[:len(wd)-1], nil
+               }
+       }
+       // If pkg/os/getwd.go gets ENOTSUP, it will fall back to the
+       // slow algorithm.
+       return "", ENOTSUP
+}
+
+type SockaddrDatalink struct {
+       Len    uint8
+       Family uint8
+       Index  uint16
+       Type   uint8
+       Nlen   uint8
+       Alen   uint8
+       Slen   uint8
+       Data   [12]int8
+       raw    RawSockaddrDatalink
+}
+
+// Translate "kern.hostname" to []_C_int{0,1,2,3}.
+func nametomib(name string) (mib []_C_int, err error) {
+       const siz = unsafe.Sizeof(mib[0])
+
+       // NOTE(rsc): It seems strange to set the buffer to have
+       // size CTL_MAXNAME+2 but use only CTL_MAXNAME
+       // as the size.  I don't know why the +2 is here, but the
+       // kernel uses +2 for its own implementation of this function.
+       // I am scared that if we don't include the +2 here, the kernel
+       // will silently write 2 words farther than we specify
+       // and we'll get memory corruption.
+       var buf [CTL_MAXNAME + 2]_C_int
+       n := uintptr(CTL_MAXNAME) * siz
+
+       p := (*byte)(unsafe.Pointer(&buf[0]))
+       bytes, err := ByteSliceFromString(name)
+       if err != nil {
+               return nil, err
+       }
+
+       // Magic sysctl: "setting" 0.3 to a string name
+       // lets you read back the array of integers form.
+       if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); 
err != nil {
+               return nil, err
+       }
+       return buf[0 : n/siz], nil
+}
+
+// ParseDirent parses up to max directory entries in buf,
+// appending the names to names.  It returns the number
+// bytes consumed from buf, the number of entries added
+// to names, and the new names slice.
+func ParseDirent(buf []byte, max int, names []string) (consumed int, count 
int, newnames []string) {
+       origlen := len(buf)
+       for max != 0 && len(buf) > 0 {
+               dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
+               if dirent.Reclen == 0 {
+                       buf = nil
+                       break
+               }
+               buf = buf[dirent.Reclen:]
+               if dirent.Ino == 0 { // File absent in directory.
+                       continue
+               }
+               bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
+               var name = string(bytes[0:dirent.Namlen])
+               if name == "." || name == ".." { // Useless names
+                       continue
+               }
+               max--
+               count++
+               names = append(names, name)
+       }
+       return origlen - len(buf), count, names
+}
+
+//sys   ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
+func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
+func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
+
+const (
+       attrBitMapCount = 5
+       attrCmnFullpath = 0x08000000
+)
+
+type attrList struct {
+       bitmapCount uint16
+       _           uint16
+       CommonAttr  uint32
+       VolAttr     uint32
+       DirAttr     uint32
+       FileAttr    uint32
+       Forkattr    uint32
+}
+
+func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) 
(attrs [][]byte, err error) {
+       if len(attrBuf) < 4 {
+               return nil, errorspkg.New("attrBuf too small")
+       }
+       attrList.bitmapCount = attrBitMapCount
+
+       var _p0 *byte
+       _p0, err = BytePtrFromString(path)
+       if err != nil {
+               return nil, err
+       }
+
+       _, _, e1 := Syscall6(
+               SYS_GETATTRLIST,
+               uintptr(unsafe.Pointer(_p0)),
+               uintptr(unsafe.Pointer(&attrList)),
+               uintptr(unsafe.Pointer(&attrBuf[0])),
+               uintptr(len(attrBuf)),
+               uintptr(options),
+               0,
+       )
+       use(unsafe.Pointer(_p0))
+       if e1 != 0 {
+               return nil, e1
+       }
+       size := *(*uint32)(unsafe.Pointer(&attrBuf[0]))
+
+       // dat is the section of attrBuf that contains valid data,
+       // without the 4 byte length header. All attribute offsets
+       // are relative to dat.
+       dat := attrBuf
+       if int(size) < len(attrBuf) {
+               dat = dat[:size]
+       }
+       dat = dat[4:] // remove length prefix
+
+       for i := uint32(0); int(i) < len(dat); {
+               header := dat[i:]
+               if len(header) < 8 {
+                       return attrs, errorspkg.New("truncated attribute 
header")
+               }
+               datOff := *(*int32)(unsafe.Pointer(&header[0]))
+               attrLen := *(*uint32)(unsafe.Pointer(&header[4]))
+               if datOff < 0 || uint32(datOff)+attrLen > uint32(len(dat)) {
+                       return attrs, errorspkg.New("truncated results; attrBuf 
too small")
+               }
+               end := uint32(datOff) + attrLen
+               attrs = append(attrs, dat[datOff:end])
+               i = end
+               if r := i % 4; r != 0 {
+                       i += (4 - r)
+               }
+       }
+       return
+}
+
+//sysnb pipe() (r int, w int, err error)
+
+func Pipe(p []int) (err error) {
+       if len(p) != 2 {
+               return EINVAL
+       }
+       p[0], p[1], err = pipe()
+       return
+}
+
+func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
+       var _p0 unsafe.Pointer
+       var bufsize uintptr
+       if len(buf) > 0 {
+               _p0 = unsafe.Pointer(&buf[0])
+               bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
+       }
+       r0, _, e1 := Syscall(SYS_GETFSSTAT64, uintptr(_p0), bufsize, 
uintptr(flags))
+       use(unsafe.Pointer(_p0))
+       n = int(r0)
+       if e1 != 0 {
+               err = e1
+       }
+       return
+}
+
+/*
+ * Wrapped
+ */
+
+//sys  kill(pid int, signum int, posix int) (err error)
+
+func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, 
int(signum), 1) }
+
+/*
+ * Exposed directly
+ */
+//sys  Access(path string, mode uint32) (err error)
+//sys  Adjtime(delta *Timeval, olddelta *Timeval) (err error)
+//sys  Chdir(path string) (err error)
+//sys  Chflags(path string, flags int) (err error)
+//sys  Chmod(path string, mode uint32) (err error)
+//sys  Chown(path string, uid int, gid int) (err error)
+//sys  Chroot(path string) (err error)
+//sys  Close(fd int) (err error)
+//sys  Dup(fd int) (nfd int, err error)
+//sys  Dup2(from int, to int) (err error)
+//sys  Exchangedata(path1 string, path2 string, options int) (err error)
+//sys  Exit(code int)
+//sys  Fchdir(fd int) (err error)
+//sys  Fchflags(fd int, flags int) (err error)
+//sys  Fchmod(fd int, mode uint32) (err error)
+//sys  Fchown(fd int, uid int, gid int) (err error)
+//sys  Flock(fd int, how int) (err error)
+//sys  Fpathconf(fd int, name int) (val int, err error)
+//sys  Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
+//sys  Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
+//sys  Fsync(fd int) (err error)
+//sys  Ftruncate(fd int, length int64) (err error)
+//sys  Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = 
SYS_GETDIRENTRIES64
+//sys  Getdtablesize() (size int)
+//sysnb        Getegid() (egid int)
+//sysnb        Geteuid() (uid int)
+//sysnb        Getgid() (gid int)
+//sysnb        Getpgid(pid int) (pgid int, err error)
+//sysnb        Getpgrp() (pgrp int)
+//sysnb        Getpid() (pid int)
+//sysnb        Getppid() (ppid int)
+//sys  Getpriority(which int, who int) (prio int, err error)
+//sysnb        Getrlimit(which int, lim *Rlimit) (err error)
+//sysnb        Getrusage(who int, rusage *Rusage) (err error)
+//sysnb        Getsid(pid int) (sid int, err error)
+//sysnb        Getuid() (uid int)
+//sysnb        Issetugid() (tainted bool)
+//sys  Kqueue() (fd int, err error)
+//sys  Lchown(path string, uid int, gid int) (err error)
+//sys  Link(path string, link string) (err error)
+//sys  Listen(s int, backlog int) (err error)
+//sys  Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
+//sys  Mkdir(path string, mode uint32) (err error)
+//sys  Mkfifo(path string, mode uint32) (err error)
+//sys  Mknod(path string, mode uint32, dev int) (err error)
+//sys  Mlock(b []byte) (err error)
+//sys  Mlockall(flags int) (err error)
+//sys  Mprotect(b []byte, prot int) (err error)
+//sys  Munlock(b []byte) (err error)
+//sys  Munlockall() (err error)
+//sys  Open(path string, mode int, perm uint32) (fd int, err error)
+//sys  Pathconf(path string, name int) (val int, err error)
+//sys  Pread(fd int, p []byte, offset int64) (n int, err error)
+//sys  Pwrite(fd int, p []byte, offset int64) (n int, err error)
+//sys  read(fd int, p []byte) (n int, err error)
+//sys  Readlink(path string, buf []byte) (n int, err error)
+//sys  Rename(from string, to string) (err error)
+//sys  Revoke(path string) (err error)
+//sys  Rmdir(path string) (err error)
+//sys  Seek(fd int, offset int64, whence int) (newoffset int64, err error) = 
SYS_LSEEK
+//sys  Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err 
error)
+//sys  Setegid(egid int) (err error)
+//sysnb        Seteuid(euid int) (err error)
+//sysnb        Setgid(gid int) (err error)
+//sys  Setlogin(name string) (err error)
+//sysnb        Setpgid(pid int, pgid int) (err error)
+//sys  Setpriority(which int, who int, prio int) (err error)
+//sys  Setprivexec(flag int) (err error)
+//sysnb        Setregid(rgid int, egid int) (err error)
+//sysnb        Setreuid(ruid int, euid int) (err error)
+//sysnb        Setrlimit(which int, lim *Rlimit) (err error)
+//sysnb        Setsid() (pid int, err error)
+//sysnb        Settimeofday(tp *Timeval) (err error)
+//sysnb        Setuid(uid int) (err error)
+//sys  Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
+//sys  Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
+//sys  Symlink(path string, link string) (err error)
+//sys  Sync() (err error)
+//sys  Truncate(path string, length int64) (err error)
+//sys  Umask(newmask int) (oldmask int)
+//sys  Undelete(path string) (err error)
+//sys  Unlink(path string) (err error)
+//sys  Unmount(path string, flags int) (err error)
+//sys  write(fd int, p []byte) (n int, err error)
+//sys   mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos 
int64) (ret uintptr, err error)
+//sys   munmap(addr uintptr, length uintptr) (err error)
+//sys  readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
+//sys  writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
+
+/*
+ * Unimplemented
+ */
+// Profil
+// Sigaction
+// Sigprocmask
+// Getlogin
+// Sigpending
+// Sigaltstack
+// Ioctl
+// Reboot
+// Execve
+// Vfork
+// Sbrk
+// Sstk
+// Ovadvise
+// Mincore
+// Setitimer
+// Swapon
+// Select
+// Sigsuspend
+// Readv
+// Writev
+// Nfssvc
+// Getfh
+// Quotactl
+// Mount
+// Csops
+// Waitid
+// Add_profil
+// Kdebug_trace
+// Sigreturn
+// Mmap
+// Mlock
+// Munlock
+// Atsocket
+// Kqueue_from_portset_np
+// Kqueue_portset
+// Getattrlist
+// Setattrlist
+// Getdirentriesattr
+// Searchfs
+// Delete
+// Copyfile
+// Poll
+// Watchevent
+// Waitevent
+// Modwatch
+// Getxattr
+// Fgetxattr
+// Setxattr
+// Fsetxattr
+// Removexattr
+// Fremovexattr
+// Listxattr
+// Flistxattr
+// Fsctl
+// Initgroups
+// Posix_spawn
+// Nfsclnt
+// Fhopen
+// Minherit
+// Semsys
+// Msgsys
+// Shmsys
+// Semctl
+// Semget
+// Semop
+// Msgctl
+// Msgget
+// Msgsnd
+// Msgrcv
+// Shmat
+// Shmctl
+// Shmdt
+// Shmget
+// Shm_open
+// Shm_unlink
+// Sem_open
+// Sem_close
+// Sem_unlink
+// Sem_wait
+// Sem_trywait
+// Sem_post
+// Sem_getvalue
+// Sem_init
+// Sem_destroy
+// Open_extended
+// Umask_extended
+// Stat_extended
+// Lstat_extended
+// Fstat_extended
+// Chmod_extended
+// Fchmod_extended
+// Access_extended
+// Settid
+// Gettid
+// Setsgroups
+// Getsgroups
+// Setwgroups
+// Getwgroups
+// Mkfifo_extended
+// Mkdir_extended
+// Identitysvc
+// Shared_region_check_np
+// Shared_region_map_np
+// __pthread_mutex_destroy
+// __pthread_mutex_init
+// __pthread_mutex_lock
+// __pthread_mutex_trylock
+// __pthread_mutex_unlock
+// __pthread_cond_init
+// __pthread_cond_destroy
+// __pthread_cond_broadcast
+// __pthread_cond_signal
+// Setsid_with_pid
+// __pthread_cond_timedwait
+// Aio_fsync
+// Aio_return
+// Aio_suspend
+// Aio_cancel
+// Aio_error
+// Aio_read
+// Aio_write
+// Lio_listio
+// __pthread_cond_wait
+// Iopolicysys
+// Mlockall
+// Munlockall
+// __pthread_kill
+// __pthread_sigmask
+// __sigwait
+// __disable_threadsignal
+// __pthread_markcancel
+// __pthread_canceled
+// __semwait_signal
+// Proc_info
+// sendfile
+// Stat64_extended
+// Lstat64_extended
+// Fstat64_extended
+// __pthread_chdir
+// __pthread_fchdir
+// Audit
+// Auditon
+// Getauid
+// Setauid
+// Getaudit
+// Setaudit
+// Getaudit_addr
+// Setaudit_addr
+// Auditctl
+// Bsdthread_create
+// Bsdthread_terminate
+// Stack_snapshot
+// Bsdthread_register
+// Workq_open
+// Workq_ops
+// __mac_execve
+// __mac_syscall
+// __mac_get_file
+// __mac_set_file
+// __mac_get_link
+// __mac_set_link
+// __mac_get_proc
+// __mac_set_proc
+// __mac_get_fd
+// __mac_set_fd
+// __mac_get_pid
+// __mac_get_lcid
+// __mac_get_lctx
+// __mac_set_lctx
+// Setlcid
+// Read_nocancel
+// Write_nocancel
+// Open_nocancel
+// Close_nocancel
+// Wait4_nocancel
+// Recvmsg_nocancel
+// Sendmsg_nocancel
+// Recvfrom_nocancel
+// Accept_nocancel
+// Msync_nocancel
+// Fcntl_nocancel
+// Select_nocancel
+// Fsync_nocancel
+// Connect_nocancel
+// Sigsuspend_nocancel
+// Readv_nocancel
+// Writev_nocancel
+// Sendto_nocancel
+// Pread_nocancel
+// Pwrite_nocancel
+// Waitid_nocancel
+// Poll_nocancel
+// Msgsnd_nocancel
+// Msgrcv_nocancel
+// Sem_wait_nocancel
+// Aio_suspend_nocancel
+// __sigwait_nocancel
+// __semwait_signal_nocancel
+// __mac_mount
+// __mac_get_mount
+// __mac_getfsstat


Reply via email to