3630b18d1c2bcb6893e5bf5c21047998692c9da3
2 #include <msvcrt/errno.h>
3 #include "../../msvcrt/stdlib/doserrmap.h"
22 int __set_errno (int error
)
31 int * __fpecode ( void )
41 _doserrno
= GetLastError();
46 * This function sets both doserrno to the passed in OS error code
47 * and also maps this to an appropriate errno code. The mapping
48 * has been deduced automagically by running this functions, which
49 * exists in MSVCRT but is undocumented, on all the error codes in
52 void _dosmaperr(unsigned long oserror
)
56 SetLastError(oserror
);
58 /* Use binary chop to find the corresponding errno code */
59 for (base
=0, lim
=sizeof(doserrmap
)/sizeof(doserrmap
[0]); lim
; lim
>>= 1) {
60 pos
= base
+(lim
>> 1);
61 if (doserrmap
[pos
].winerr
== oserror
) {
62 __set_errno(doserrmap
[pos
].en
);
64 } else if (doserrmap
[pos
].winerr
> oserror
) {
69 /* EINVAL appears to be the default */