2009-06-01 23:14:57 -06:00
|
|
|
// 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
|
|
|
|
|
|
|
|
|
2009-11-05 11:55:57 -07:00
|
|
|
func str(val int) string { // do it here rather than with fmt to avoid dependency
|
2009-06-01 23:14:57 -06:00
|
|
|
if val < 0 {
|
2009-11-09 22:23:52 -07:00
|
|
|
return "-" + str(-val)
|
2009-06-01 23:14:57 -06:00
|
|
|
}
|
2009-11-05 11:55:57 -07:00
|
|
|
var buf [32]byte; // big enough for int64
|
2009-11-09 22:23:52 -07:00
|
|
|
i := len(buf) - 1;
|
2009-06-01 23:14:57 -06:00
|
|
|
for val >= 10 {
|
|
|
|
buf[i] = byte(val%10 + '0');
|
|
|
|
i--;
|
|
|
|
val /= 10;
|
|
|
|
}
|
2009-11-09 22:23:52 -07:00
|
|
|
buf[i] = byte(val + '0');
|
2009-06-01 23:14:57 -06:00
|
|
|
return string(buf[i:len(buf)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
func Errstr(errno int) string {
|
|
|
|
if errno < 0 || errno >= int(len(errors)) {
|
2009-11-09 22:23:52 -07:00
|
|
|
return "error " + str(errno)
|
2009-06-01 23:14:57 -06:00
|
|
|
}
|
2009-11-05 11:55:57 -07:00
|
|
|
return errors[errno];
|
2009-06-01 23:14:57 -06:00
|
|
|
}
|