mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
new syscall package: manually maintained files and scripts.
auto-generated files and deletions are in another CL. goals for new syscall: * automate as much as possible * do not let clients do unsafe things * use simple types (int not int64) * fewer files the files are renamed from foo_amd64_linux to foo_linux_amd64, both because it reads better (all the linux are related, all the amd64 less so) and because it made it easier to replace the existing ones. R=r DELTA=2336 (2260 added, 6 deleted, 70 changed) OCL=29709 CL=29723
This commit is contained in:
parent
9e0fec9c9c
commit
602a446b74
15 changed files with 2352 additions and 73 deletions
30
src/lib/syscall/errstr.go
Normal file
30
src/lib/syscall/errstr.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// 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.
|
||||
|
||||
package syscall
|
||||
|
||||
import "syscall"
|
||||
|
||||
func str(val int) string { // do it here rather than with fmt to avoid dependency
|
||||
if val < 0 {
|
||||
return "-" + str(-val);
|
||||
}
|
||||
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:len(buf)]);
|
||||
}
|
||||
|
||||
func Errstr(errno int) string {
|
||||
if errno < 0 || errno >= int(len(errors)) {
|
||||
return "error " + str(errno)
|
||||
}
|
||||
return errors[errno]
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue