12 return (int*)(&GetThreadData()->tdoserrno
);
20 return(&GetThreadData()->terrno
);
24 int __set_doserrno(int error
)
26 PTHREADDATA ThreadData
;
28 ThreadData
= GetThreadData();
30 ThreadData
->tdoserrno
= error
;
35 int __set_errno(int error
)
37 PTHREADDATA ThreadData
;
39 ThreadData
= GetThreadData();
41 ThreadData
->terrno
= error
;
47 * This function sets both doserrno to the passed in OS error code
48 * and also maps this to an appropriate errno code. The mapping
49 * has been deduced automagically by running this functions, which
50 * exists in MSVCRT but is undocumented, on all the error codes in
53 void _dosmaperr(unsigned long oserror
)
57 __set_doserrno(oserror
);
59 /* Use binary chop to find the corresponding errno code */
60 for (base
=0, lim
=sizeof(doserrmap
)/sizeof(doserrmap
[0]); lim
; lim
>>= 1) {
61 pos
= base
+(lim
>> 1);
62 if (doserrmap
[pos
].winerr
== oserror
) {
63 __set_errno(doserrmap
[pos
].en
);
65 } else if (doserrmap
[pos
].winerr
< oserror
) {
70 /* EINVAL appears to be the default */