Commits

Aram Hăvărneanu  committed 93b50ce

syscall: address jsing's review points

  • Participants
  • Parent commits de60e4c

Comments (0)

Files changed (4)

File src/pkg/syscall/exec_solaris.go

File contents unchanged.

File src/pkg/syscall/mksyscall_solaris.pl

 #	  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
+#	* 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 @in = parseparamlist($in);
 	my @out = parseparamlist($out);
 
-	# Dll file name.
+	# So file name.
 	if($modname eq "") {
 		$modname = "libc";
 	}

File src/pkg/syscall/so_solaris.go

 	"unsafe"
 )
 
-// SoError describes reasons for shared libraries load failures.
-type SoError struct {
+// SOError describes reasons for shared libraries load failures.
+type SOError struct {
 	Err     error
 	ObjName string
 	Msg     string
 }
 
-func (e *SoError) Error() string { return e.Msg }
+func (e *SOError) Error() string { return e.Msg }
 
 // Implemented in ../runtime/syscall_solaris.goc.
 func RawSysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
 func dlopen(name *uint8, mode uintptr) (handle uintptr, err Errno)
 func dlsym(handle uintptr, name *uint8) (proc uintptr, err Errno)
 
-// A So implements access to a single shared library object.
-type So struct {
+// A SO implements access to a single shared library object.
+type SO struct {
 	Name   string
 	Handle uintptr
 }
 
-// LoadSo loads shared library file into memory.
-func LoadSo(name string) (so *So, err error) {
+// LoadSO loads shared library file into memory.
+func LoadSO(name string) (so *SO, err error) {
 	namep, err := BytePtrFromString(name)
 	if err != nil {
 		return nil, err
 	}
-	h, e := dlopen(namep, 1) // RTLD_LAZY)
+	h, e := dlopen(namep, 1) // RTLD_LAZY
 	if e != 0 {
-		return nil, &SoError{
+		return nil, &SOError{
 			Err:     e,
 			ObjName: name,
 			Msg:     "Failed to load " + name + ": " + e.Error(),
 		}
 	}
-	d := &So{
+	d := &SO{
 		Name:   name,
 		Handle: uintptr(h),
 	}
 	return d, nil
 }
 
-// MustLoadSo is like LoadSo but panics if load operation fails.
-func MustLoadSo(name string) *So {
-	d, e := LoadSo(name)
+// MustLoadSO is like LoadSO but panics if load operation fails.
+func MustLoadSO(name string) *SO {
+	d, e := LoadSO(name)
 	if e != nil {
 		panic(e)
 	}
 
 // FindProc searches shared library d for procedure named name and returns
 // *Proc if found. It returns an error if the search fails.
-func (d *So) FindProc(name string) (proc *Proc, err error) {
+func (d *SO) FindProc(name string) (proc *Proc, err error) {
 	namep, err := BytePtrFromString(name)
 	if err != nil {
 		return nil, err
 	}
 	a, _ := dlsym(uintptr(d.Handle), namep)
 	if a == 0 {
-		return nil, &SoError{
+		return nil, &SOError{
 			Err:     ENOSYS,
 			ObjName: name,
 			Msg:     "Failed to find " + name + " procedure in " + d.Name,
 		}
 	}
 	p := &Proc{
-		So:   d,
+		SO:   d,
 		Name: name,
 		addr: a,
 	}
 }
 
 // MustFindProc is like FindProc but panics if search fails.
-func (d *So) MustFindProc(name string) *Proc {
+func (d *SO) MustFindProc(name string) *Proc {
 	p, e := d.FindProc(name)
 	if e != nil {
 		panic(e)
 }
 
 // Release unloads shared library d from memory.
-func (d *So) Release() (err error) {
+func (d *SO) Release() (err error) {
 	return dlclose(d.Handle)
 }
 
 // A Proc implements access to a procedure inside a shared library.
 type Proc struct {
-	So   *So
+	SO   *SO
 	Name string
 	addr uintptr
 }
 	return
 }
 
-// A LazySo implements access to a single shared library.  It will delay
+// A LazySO implements access to a single shared library.  It will delay
 // the load of the shared library until the first call to its Handle method
 // or to one of its LazyProc's Addr method.
-type LazySo struct {
+type LazySO struct {
 	mu   sync.Mutex
-	so   *So // non nil once So is loaded
+	so   *SO // non nil once SO is loaded
 	Name string
 }
 
 // Load loads single shared file d.Name into memory. It returns an error if
-// fails.  Load will not try to load So, if it is already loaded into memory.
-func (d *LazySo) Load() error {
+// fails.  Load will not try to load SO, if it is already loaded into memory.
+func (d *LazySO) Load() error {
 	// Non-racy version of:
 	// if d.so == nil {
 	if atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&d.so))) == nil {
 		d.mu.Lock()
 		defer d.mu.Unlock()
 		if d.so == nil {
-			so, e := LoadSo(d.Name)
+			so, e := LoadSO(d.Name)
 			if e != nil {
 				return e
 			}
 }
 
 // mustLoad is like Load but panics if search fails.
-func (d *LazySo) mustLoad() {
+func (d *LazySO) mustLoad() {
 	e := d.Load()
 	if e != nil {
 		panic(e)
 }
 
 // Handle returns d's module handle.
-func (d *LazySo) Handle() uintptr {
+func (d *LazySO) Handle() uintptr {
 	d.mustLoad()
 	return uintptr(d.so.Handle)
 }
 
-// NewProc returns a LazyProc for accessing the named procedure in the So d.
-func (d *LazySo) NewProc(name string) *LazyProc {
+// NewProc returns a LazyProc for accessing the named procedure in the SO d.
+func (d *LazySO) NewProc(name string) *LazyProc {
 	return &LazyProc{l: d, Name: name}
 }
 
-// NewLazySo creates new LazySo associated with So file.
-func NewLazySo(name string) *LazySo {
-	return &LazySo{Name: name}
+// NewLazySO creates new LazySO associated with SO file.
+func NewLazySO(name string) *LazySO {
+	return &LazySO{Name: name}
 }
 
-// A LazyProc implements access to a procedure inside a LazySo.
+// A LazyProc implements access to a procedure inside a LazySO.
 // It delays the lookup until the Addr method is called.
 type LazyProc struct {
 	mu   sync.Mutex
 	Name string
-	l    *LazySo
+	l    *LazySO
 	proc *Proc
 }
 

File src/pkg/syscall/syscall_solaris.go

  * Wrapped
  */
 
-//sysnb getgroups(ngid int, gid *_Gid_t) (n int, err error)
-//sysnb setgroups(ngid int, gid *_Gid_t) (err error)
+//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)
 	return Utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
 }
 
-//sys   fcntl(fd int, cmd int, arg int) (val int, err error)
+//sys	fcntl(fd int, cmd int, arg int) (val int, err error)
 
 func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
 	switch rsa.Addr.Family {
 	return nil, EAFNOSUPPORT
 }
 
-//sys   accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) = libsocket.accept
+//sys	accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) = libsocket.accept
 func Accept(fd int) (nfd int, sa Sockaddr, err error) {
 	var rsa RawSockaddrAny
 	var len _Socklen = SizeofSockaddrAny
 	return
 }
 
-//sys sendmsg(s int, msg *Msghdr, flags int) (err error) = libsocket.sendmsg
+//sys	sendmsg(s int, msg *Msghdr, flags int) (err error) = libsocket.sendmsg
 func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
 	var ptr uintptr
 	var salen _Socklen
 //sys	Ftruncate(fd int, length int64) (err error)
 //sys	Umask(newmask int) (oldmask int)
 //sys	Unlink(path string) (err error)
-//sys   Utimes(path string, times *[2]Timeval) (err error)
-//sys   bind(s int, addr uintptr, addrlen _Socklen) (err error) = libsocket.bind
-//sys   connect(s int, addr uintptr, addrlen _Socklen) (err error) = libsocket.connect
-//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   sendto(s int, buf []byte, flags int, to uintptr, addrlen _Socklen) (err error) = libsocket.sendto
-//sys   socket(domain int, typ int, proto int) (fd int, err error) = libsocket.socket
-//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) = libsocket.socketpair
+//sys	Utimes(path string, times *[2]Timeval) (err error)
+//sys	bind(s int, addr uintptr, addrlen _Socklen) (err error) = libsocket.bind
+//sys	connect(s int, addr uintptr, addrlen _Socklen) (err error) = libsocket.connect
+//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	sendto(s int, buf []byte, flags int, to uintptr, addrlen _Socklen) (err error) = libsocket.sendto
+//sys	socket(domain int, typ int, proto int) (fd int, err error) = libsocket.socket
+//sysnb	socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) = libsocket.socketpair
 //sys	write(fd int, p []byte) (n int, err error)
-//sys    getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
-//sysnb  getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getpeername
-//sys    getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getsockname
-//sys    setsockopt(s int, level int, name int, val uintptr, vallen uintptr) (err error) = libsocket.setsockopt
-//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) = libsocket.recvfrom
-//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.recvmsg
+//sys	getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
+//sysnb	getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getpeername
+//sys	getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getsockname
+//sys	setsockopt(s int, level int, name int, val uintptr, vallen uintptr) (err error) = libsocket.setsockopt
+//sys	recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) = libsocket.recvfrom
+//sys	recvmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.recvmsg
 
 func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
 	r0, _, e1 := Sysvicall6(procread.Addr(), 3, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf), 0, 0, 0)