e2ae388324ff9a59d354478a553b6f40fc2f6447
5 #include <internal/tls.h>
14 return (int*)(&GetThreadData()->tdoserrno
);
22 return(&GetThreadData()->terrno
);
26 int __set_doserrno(int error
)
28 PTHREADDATA ThreadData
;
30 ThreadData
= GetThreadData();
32 ThreadData
->tdoserrno
= error
;
37 int __set_errno(int error
)
39 PTHREADDATA ThreadData
;
41 ThreadData
= GetThreadData();
43 ThreadData
->terrno
= error
;
49 * This function sets both doserrno to the passed in OS error code
50 * and also maps this to an appropriate errno code. The mapping
51 * has been deduced automagically by running this functions, which
52 * exists in MSVCRT but is undocumented, on all the error codes in
55 void _dosmaperr(unsigned long oserror
)
59 __set_doserrno(oserror
);
61 /* Use binary chop to find the corresponding errno code */
62 for (base
=0, lim
=sizeof(doserrmap
)/sizeof(doserrmap
[0]); lim
; lim
>>= 1) {
63 pos
= base
+(lim
>> 1);
64 if (doserrmap
[pos
].winerr
== oserror
) {
65 __set_errno(doserrmap
[pos
].en
);
67 } else if (doserrmap
[pos
].winerr
< oserror
) {
72 /* EINVAL appears to be the default */