On 17 June 2017 at 07:15, Russ Cox <
r...@golang.org> wrote:
> On Fri, Jun 16, 2017 at 2:56 PM, Jessica Hamilton
> <
jessica.l...@gmail.com> wrote:
>>
>> Haiku uses negative errno values. However, it also provides a posix
>> error mapper library to return positive values instead in combination
>> with -DB_USE_POSITIVE_POSIX_ERRORS.
>>
>> But even with positive posix errno values, the values are far too large.
>>
>> E.g. a quick test at
golang.org with the following:
>> package main
>>
>> import "fmt"
>>
>> var errors = [...]string{
>> 0: "no error",
>>
2147454916: "no such attribute",
>>
2147454917: "text file busy",
>> }
>
>
> Are the negative values reasonably small? Instead of using that flag, try
> negating the values before returning them from the system call. It's not
> uncommon for the register result from a system call signaling an error to be
> a negative errno. On those systems, the Go assembly negates it before
> returning it.
No, they're not small,
https://github.com/haiku/haiku/blob/master/headers/os/support/Errors.h
Negative values are INT_MIN + value, positive values being -error.
I'm currently trying generating the errors array with e - 0x7fff8000,
with the largest number being 32767. I assume the array won't be
sparse? So this probably still isn't ideal.
But I can't seem to use "runtime/internal/sys" package as an import
with syscalls/syscall_unix.go: use of internal package not allowed
Was trying do something along the lines of
s = errors[e - sys.GoosHaiku * 0x7fff8000]
In: func (e Errno) Error() string
I guess the way forward is to duplicate syscall_unix.go, just for this
one function? And if I go this route, would it be recommended to use a
map instead for the errno => string table?