[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / lib / std / cbits / errno.c
1 /* 
2  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
3  *
4  * $Id: errno.c,v 1.3 1998/12/02 13:27:20 simonm Exp $
5  *
6  * GHC Error Number Conversion
7  */
8
9 #include "Rts.h"
10 #include "stgio.h"
11
12 int ghc_errno = 0;
13 int ghc_errtype = 0;
14
15 char *ghc_errstr = NULL;
16
17 StgAddr
18 getErrStr__()
19 { return ((StgAddr)ghc_errstr); }
20
21 StgInt
22 getErrNo__()
23 { return ((StgInt)ghc_errno); }
24
25 StgInt
26 getErrType__()
27 { return ((StgInt)ghc_errtype); }
28
29
30 /* Collect all of the grotty #ifdef's in one place. */
31
32 void cvtErrno(void)
33 {
34     switch(errno) {
35 #ifdef E2BIG
36     case E2BIG:
37         ghc_errno = GHC_E2BIG;
38         break;
39 #endif
40 #ifdef EACCES
41     case EACCES:
42         ghc_errno = GHC_EACCES;
43         break;
44 #endif
45 #ifdef EADDRINUSE
46     case EADDRINUSE:
47         ghc_errno = GHC_EADDRINUSE;
48         break;
49 #endif
50 #ifdef EADDRNOTAVAIL
51     case EADDRNOTAVAIL:
52         ghc_errno = GHC_EADDRNOTAVAIL;
53         break;
54 #endif
55 #ifdef EADV
56     case EADV:
57         ghc_errno = GHC_EADV;
58         break;
59 #endif
60 #ifdef EAFNOSUPPORT
61     case EAFNOSUPPORT:
62         ghc_errno = GHC_EAFNOSUPPORT;
63         break;
64 #endif
65 #ifdef EAGAIN
66     case EAGAIN:
67         ghc_errno = GHC_EAGAIN;
68         break;
69 #endif
70 #ifdef EALREADY
71     case EALREADY:
72         ghc_errno = GHC_EALREADY;
73         break;
74 #endif
75 #ifdef EBADF
76     case EBADF:
77         ghc_errno = GHC_EBADF;
78         break;
79 #endif
80 #ifdef EBADMSG
81     case EBADMSG:
82         ghc_errno = GHC_EBADMSG;
83         break;
84 #endif
85 #ifdef EBADRPC
86     case EBADRPC:
87         ghc_errno = GHC_EBADRPC;
88         break;
89 #endif
90 #ifdef EBUSY
91     case EBUSY:
92         ghc_errno = GHC_EBUSY;
93         break;
94 #endif
95 #ifdef ECHILD
96     case ECHILD:
97         ghc_errno = GHC_ECHILD;
98         break;
99 #endif
100 #ifdef ECOMM
101     case ECOMM:
102         ghc_errno = GHC_ECOMM;
103         break;
104 #endif
105 #ifdef ECONNABORTED
106     case ECONNABORTED:
107         ghc_errno = GHC_ECONNABORTED;
108         break;
109 #endif
110 #ifdef ECONNREFUSED
111     case ECONNREFUSED:
112         ghc_errno = GHC_ECONNREFUSED;
113         break;
114 #endif
115 #ifdef ECONNRESET
116     case ECONNRESET:
117         ghc_errno = GHC_ECONNRESET;
118         break;
119 #endif
120 #ifdef EDEADLK
121     case EDEADLK:
122         ghc_errno = GHC_EDEADLK;
123         break;
124 #endif
125 #ifdef EDESTADDRREQ
126     case EDESTADDRREQ:
127         ghc_errno = GHC_EDESTADDRREQ;
128         break;
129 #endif
130 #ifdef EDIRTY
131     case EDIRTY:
132         ghc_errno = GHC_EDIRTY;
133         break;
134 #endif
135 #ifdef EDOM
136     case EDOM:
137         ghc_errno = GHC_EDOM;
138         break;
139 #endif
140 #ifdef EDQUOT
141     case EDQUOT:
142         ghc_errno = GHC_EDQUOT;
143         break;
144 #endif
145 #ifdef EEXIST
146     case EEXIST:
147         ghc_errno = GHC_EEXIST;
148         break;
149 #endif
150 #ifdef EFAULT
151     case EFAULT:
152         ghc_errno = GHC_EFAULT;
153         break;
154 #endif
155 #ifdef EFBIG
156     case EFBIG:
157         ghc_errno = GHC_EFBIG;
158         break;
159 #endif
160 #ifdef EFTYPE
161     case EFTYPE:
162         ghc_errno = GHC_EFTYPE;
163         break;
164 #endif
165 #ifdef EHOSTDOWN
166     case EHOSTDOWN:
167         ghc_errno = GHC_EHOSTDOWN;
168         break;
169 #endif
170 #ifdef EHOSTUNREACH
171     case EHOSTUNREACH:
172         ghc_errno = GHC_EHOSTUNREACH;
173         break;
174 #endif
175 #ifdef EIDRM
176     case EIDRM:
177         ghc_errno = GHC_EIDRM;
178         break;
179 #endif
180 #ifdef EILSEQ
181     case EILSEQ:
182         ghc_errno = GHC_EILSEQ;
183         break;
184 #endif
185 #ifdef EINPROGRESS
186     case EINPROGRESS:
187         ghc_errno = GHC_EINPROGRESS;
188         break;
189 #endif
190 #ifdef EINTR
191     case EINTR:
192         ghc_errno = GHC_EINTR;
193         break;
194 #endif
195 #ifdef EINVAL
196     case EINVAL:
197         ghc_errno = GHC_EINVAL;
198         break;
199 #endif
200 #ifdef EIO
201     case EIO:
202         ghc_errno = GHC_EIO;
203         break;
204 #endif
205 #ifdef EISCONN
206     case EISCONN:
207         ghc_errno = GHC_EISCONN;
208         break;
209 #endif
210 #ifdef EISDIR
211     case EISDIR:
212         ghc_errno = GHC_EISDIR;
213         break;
214 #endif
215 #ifdef ELOOP
216     case ELOOP:
217         ghc_errno = GHC_ELOOP;
218         break;
219 #endif
220 #ifdef EMFILE
221     case EMFILE:
222         ghc_errno = GHC_EMFILE;
223         break;
224 #endif
225 #ifdef EMLINK
226     case EMLINK:
227         ghc_errno = GHC_EMLINK;
228         break;
229 #endif
230 #ifdef EMSGSIZE
231     case EMSGSIZE:
232         ghc_errno = GHC_EMSGSIZE;
233         break;
234 #endif
235 #ifdef EMULTIHOP
236     case EMULTIHOP:
237         ghc_errno = GHC_EMULTIHOP;
238         break;
239 #endif
240 #ifdef ENAMETOOLONG
241     case ENAMETOOLONG:
242         ghc_errno = GHC_ENAMETOOLONG;
243         break;
244 #endif
245 #ifdef ENETDOWN
246     case ENETDOWN:
247         ghc_errno = GHC_ENETDOWN;
248         break;
249 #endif
250 #ifdef ENETRESET
251     case ENETRESET:
252         ghc_errno = GHC_ENETRESET;
253         break;
254 #endif
255 #ifdef ENETUNREACH
256     case ENETUNREACH:
257         ghc_errno = GHC_ENETUNREACH;
258         break;
259 #endif
260 #ifdef ENFILE
261     case ENFILE:
262         ghc_errno = GHC_ENFILE;
263         break;
264 #endif
265 #ifdef ENOBUFS
266     case ENOBUFS:
267         ghc_errno = GHC_ENOBUFS;
268         break;
269 #endif
270 #ifdef ENODATA
271     case ENODATA:
272         ghc_errno = GHC_ENODATA;
273         break;
274 #endif
275 #ifdef ENODEV
276     case ENODEV:
277         ghc_errno = GHC_ENODEV;
278         break;
279 #endif
280 #ifdef ENOENT
281     case ENOENT:
282         ghc_errno = GHC_ENOENT;
283         break;
284 #endif
285 #ifdef ENOEXEC
286     case ENOEXEC:
287         ghc_errno = GHC_ENOEXEC;
288         break;
289 #endif
290 #ifdef ENOLCK
291     case ENOLCK:
292         ghc_errno = GHC_ENOLCK;
293         break;
294 #endif
295 #ifdef ENOLINK
296     case ENOLINK:
297         ghc_errno = GHC_ENOLINK;
298         break;
299 #endif
300 #ifdef ENOMEM
301     case ENOMEM:
302         ghc_errno = GHC_ENOMEM;
303         break;
304 #endif
305 #ifdef ENOMSG
306     case ENOMSG:
307         ghc_errno = GHC_ENOMSG;
308         break;
309 #endif
310 #ifdef ENONET
311     case ENONET:
312         ghc_errno = GHC_ENONET;
313         break;
314 #endif
315 #ifdef ENOPROTOOPT
316     case ENOPROTOOPT:
317         ghc_errno = GHC_ENOPROTOOPT;
318         break;
319 #endif
320 #ifdef ENOSPC
321     case ENOSPC:
322         ghc_errno = GHC_ENOSPC;
323         break;
324 #endif
325 #ifdef ENOSR
326     case ENOSR:
327         ghc_errno = GHC_ENOSR;
328         break;
329 #endif
330 #ifdef ENOSTR
331     case ENOSTR:
332         ghc_errno = GHC_ENOSTR;
333         break;
334 #endif
335 #ifdef ENOSYS
336     case ENOSYS:
337         ghc_errno = GHC_ENOSYS;
338         break;
339 #endif
340 #ifdef ENOTBLK
341     case ENOTBLK:
342         ghc_errno = GHC_ENOTBLK;
343         break;
344 #endif
345 #ifdef ENOTCONN
346     case ENOTCONN:
347         ghc_errno = GHC_ENOTCONN;
348         break;
349 #endif
350 #ifdef ENOTDIR
351     case ENOTDIR:
352         ghc_errno = GHC_ENOTDIR;
353         break;
354 #endif
355 #ifndef aix_TARGET_OS
356 /* AIX returns EEXIST where 4.3BSD used ENOTEMPTY.
357  * there is an ENOTEMPTY defined as the same as EEXIST, and
358  * therefore it won't work properly on a case statement.
359  * another option is to define _ALL_SOURCE for aix, which
360  * gives a different number for ENOTEMPTY.
361  * I haven't tried that. -- andre.
362  */
363 #ifdef ENOTEMPTY
364     case ENOTEMPTY:
365         ghc_errno = GHC_ENOTEMPTY;
366         break;
367 #endif
368 #endif
369 #ifdef ENOTSOCK
370     case ENOTSOCK:
371         ghc_errno = GHC_ENOTSOCK;
372         break;
373 #endif
374 #ifdef ENOTTY
375     case ENOTTY:
376         ghc_errno = GHC_ENOTTY;
377         break;
378 #endif
379 #ifdef ENXIO
380     case ENXIO:
381         ghc_errno = GHC_ENXIO;
382         break;
383 #endif
384 #ifdef EOPNOTSUPP
385     case EOPNOTSUPP:
386         ghc_errno = GHC_EOPNOTSUPP;
387         break;
388 #endif
389 #ifdef EPERM
390     case EPERM:
391         ghc_errno = GHC_EPERM;
392         break;
393 #endif
394 #ifdef EPFNOSUPPORT
395     case EPFNOSUPPORT:
396         ghc_errno = GHC_EPFNOSUPPORT;
397         break;
398 #endif
399 #ifdef EPIPE
400     case EPIPE:
401         ghc_errno = GHC_EPIPE;
402         break;
403 #endif
404 #ifdef EPROCLIM
405     case EPROCLIM:
406         ghc_errno = GHC_EPROCLIM;
407         break;
408 #endif
409 #ifdef EPROCUNAVAIL
410     case EPROCUNAVAIL:
411         ghc_errno = GHC_EPROCUNAVAIL;
412         break;
413 #endif
414 #ifdef EPROGMISMATCH
415     case EPROGMISMATCH:
416         ghc_errno = GHC_EPROGMISMATCH;
417         break;
418 #endif
419 #ifdef EPROGUNAVAIL
420     case EPROGUNAVAIL:
421         ghc_errno = GHC_EPROGUNAVAIL;
422         break;
423 #endif
424 #ifdef EPROTO
425     case EPROTO:
426         ghc_errno = GHC_EPROTO;
427         break;
428 #endif
429 #ifdef EPROTONOSUPPORT
430     case EPROTONOSUPPORT:
431         ghc_errno = GHC_EPROTONOSUPPORT;
432         break;
433 #endif
434 #ifdef EPROTOTYPE
435     case EPROTOTYPE:
436         ghc_errno = GHC_EPROTOTYPE;
437         break;
438 #endif
439 #ifdef ERANGE
440     case ERANGE:
441         ghc_errno = GHC_ERANGE;
442         break;
443 #endif
444 #ifdef EREMCHG
445     case EREMCHG:
446         ghc_errno = GHC_EREMCHG;
447         break;
448 #endif
449 #ifdef EREMOTE
450     case EREMOTE:
451         ghc_errno = GHC_EREMOTE;
452         break;
453 #endif
454 #ifdef EROFS
455     case EROFS:
456         ghc_errno = GHC_EROFS;
457         break;
458 #endif
459 #ifdef ERPCMISMATCH
460     case ERPCMISMATCH:
461         ghc_errno = GHC_ERPCMISMATCH;
462         break;
463 #endif
464 #ifdef ERREMOTE
465     case ERREMOTE:
466         ghc_errno = GHC_ERREMOTE;
467         break;
468 #endif
469 #ifdef ESHUTDOWN
470     case ESHUTDOWN:
471         ghc_errno = GHC_ESHUTDOWN;
472         break;
473 #endif
474 #ifdef ESOCKTNOSUPPORT
475     case ESOCKTNOSUPPORT:
476         ghc_errno = GHC_ESOCKTNOSUPPORT;
477         break;
478 #endif
479 #ifdef ESPIPE
480     case ESPIPE:
481         ghc_errno = GHC_ESPIPE;
482         break;
483 #endif
484 #ifdef ESRCH
485     case ESRCH:
486         ghc_errno = GHC_ESRCH;
487         break;
488 #endif
489 #ifdef ESRMNT
490     case ESRMNT:
491         ghc_errno = GHC_ESRMNT;
492         break;
493 #endif
494 #ifdef ESTALE
495     case ESTALE:
496         ghc_errno = GHC_ESTALE;
497         break;
498 #endif
499 #ifdef ETIME
500     case ETIME:
501         ghc_errno = GHC_ETIME;
502         break;
503 #endif
504 #ifdef ETIMEDOUT
505     case ETIMEDOUT:
506         ghc_errno = GHC_ETIMEDOUT;
507         break;
508 #endif
509 #ifdef ETOOMANYREFS
510     case ETOOMANYREFS:
511         ghc_errno = GHC_ETOOMANYREFS;
512         break;
513 #endif
514 #ifdef ETXTBSY
515     case ETXTBSY:
516         ghc_errno = GHC_ETXTBSY;
517         break;
518 #endif
519 #ifdef EUSERS
520     case EUSERS:
521         ghc_errno = GHC_EUSERS;
522         break;
523 #endif
524 #if 0
525 #ifdef EWOULDBLOCK
526     case EWOULDBLOCK:
527         ghc_errno = GHC_EWOULDBLOCK;
528         break;
529 #endif
530 #endif
531 #ifdef EXDEV
532     case EXDEV:
533         ghc_errno = GHC_EXDEV;
534         break;
535 #endif
536     default:
537         ghc_errno = errno;
538         break;
539     }
540 }
541
542 void
543 stdErrno(void)
544 {
545     switch(ghc_errno) {
546     default:
547         ghc_errtype = ERR_OTHERERROR;
548         ghc_errstr = "unexpected error";
549         break;
550     case 0:
551         ghc_errtype = ERR_OTHERERROR;
552         ghc_errstr = "no error";
553     case GHC_E2BIG:
554         ghc_errtype = ERR_RESOURCEEXHAUSTED;
555         ghc_errstr = "argument list too long";
556         break;
557     case GHC_EACCES:
558         ghc_errtype = ERR_PERMISSIONDENIED;
559         ghc_errstr = "inadequate access permission";
560         break;
561     case GHC_EADDRINUSE:
562         ghc_errtype = ERR_RESOURCEBUSY;
563         ghc_errstr = "address already in use";
564         break;
565     case GHC_EADDRNOTAVAIL:
566         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
567         ghc_errstr = "address not available";
568         break;
569     case GHC_EADV:
570         ghc_errtype = ERR_OTHERERROR;
571         ghc_errstr = "RFS advertise error";
572         break;
573     case GHC_EAFNOSUPPORT:
574         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
575         ghc_errstr = "address family not supported by protocol family";
576         break;
577     case GHC_EAGAIN:
578         ghc_errtype = ERR_RESOURCEEXHAUSTED;
579         ghc_errstr = "insufficient resources";
580         break;
581     case GHC_EALREADY:
582         ghc_errtype = ERR_ALREADYEXISTS;
583         ghc_errstr = "operation already in progress";
584         break;
585     case GHC_EBADF:
586         ghc_errtype = ERR_OTHERERROR;
587         ghc_errstr = "internal error (EBADF)";
588         break;
589     case GHC_EBADMSG:
590         ghc_errtype = ERR_INAPPROPRIATETYPE;
591         ghc_errstr = "next message has wrong type";
592         break;
593     case GHC_EBADRPC:
594         ghc_errtype = ERR_OTHERERROR;
595         ghc_errstr = "invalid RPC request or response";
596         break;
597     case GHC_EBUSY:
598         ghc_errtype = ERR_RESOURCEBUSY;
599         ghc_errstr = "device busy";
600         break;
601     case GHC_ECHILD:
602         ghc_errtype = ERR_NOSUCHTHING;
603         ghc_errstr = "no child processes";
604         break;
605     case GHC_ECOMM:
606         ghc_errtype = ERR_RESOURCEVANISHED;
607         ghc_errstr = "no virtual circuit could be found";
608         break;
609     case GHC_ECONNABORTED:
610         ghc_errtype = ERR_OTHERERROR;
611         ghc_errstr = "aborted connection";
612         break;
613     case GHC_ECONNREFUSED:
614         ghc_errtype = ERR_NOSUCHTHING;
615         ghc_errstr = "no listener on remote host";
616         break;
617     case GHC_ECONNRESET:
618         ghc_errtype = ERR_RESOURCEVANISHED;
619         ghc_errstr = "connection reset by peer";
620         break;
621     case GHC_EDEADLK:
622         ghc_errtype = ERR_RESOURCEBUSY;
623         ghc_errstr = "resource deadlock avoided";
624         break;
625     case GHC_EDESTADDRREQ:
626         ghc_errtype = ERR_INVALIDARGUMENT;
627         ghc_errstr = "destination address required";
628         break;
629     case GHC_EDIRTY:
630         ghc_errtype = ERR_UNSATISFIEDCONSTRAINTS;
631         ghc_errstr = "file system dirty";
632         break;
633     case GHC_EDOM:
634         ghc_errtype = ERR_INVALIDARGUMENT;
635         ghc_errstr = "argument too large";
636         break;
637     case GHC_EDQUOT:
638         ghc_errtype = ERR_PERMISSIONDENIED;
639         ghc_errstr = "quota exceeded";
640         break;
641     case GHC_EEXIST:
642         ghc_errtype = ERR_ALREADYEXISTS;
643         ghc_errstr = "file already exists";
644         break;
645     case GHC_EFAULT:
646         ghc_errtype = ERR_OTHERERROR;
647         ghc_errstr = "internal error (EFAULT)";
648         break;
649     case GHC_EFBIG:
650         ghc_errtype = ERR_PERMISSIONDENIED;
651         ghc_errstr = "file too large";
652         break;
653     case GHC_EFTYPE:
654         ghc_errtype = ERR_INAPPROPRIATETYPE;
655         ghc_errstr = "inappropriate NFS file type or format";
656         break;
657     case GHC_EHOSTDOWN:
658         ghc_errtype = ERR_NOSUCHTHING;
659         ghc_errstr = "destination host down";
660         break;
661     case GHC_EHOSTUNREACH:
662         ghc_errtype = ERR_NOSUCHTHING;
663         ghc_errstr = "remote host is unreachable";
664         break;
665     case GHC_EIDRM:
666         ghc_errtype = ERR_RESOURCEVANISHED;
667         ghc_errstr = "IPC identifier removed";
668         break;
669     case GHC_EILSEQ:
670         ghc_errtype = ERR_INVALIDARGUMENT;
671         ghc_errstr = "invalid wide character";
672         break;
673     case GHC_EINPROGRESS:
674         ghc_errtype = ERR_ALREADYEXISTS;
675         ghc_errstr = "operation now in progress";
676         break;
677     case GHC_EINTR:
678         ghc_errtype = ERR_INTERRUPTED;
679         ghc_errstr = "interrupted system call";
680         break;
681     case GHC_EINVAL:
682         ghc_errtype = ERR_INVALIDARGUMENT;
683         ghc_errstr = "invalid argument";
684         break;
685     case GHC_EIO:
686         ghc_errtype = ERR_HARDWAREFAULT;
687         ghc_errstr = "unknown I/O fault";
688         break;
689     case GHC_EISCONN:
690         ghc_errtype = ERR_ALREADYEXISTS;
691         ghc_errstr = "socket is already connected";
692         break;
693     case GHC_EISDIR:
694         ghc_errtype = ERR_INAPPROPRIATETYPE;
695         ghc_errstr = "file is a directory";
696         break;
697     case GHC_ELOOP:
698         ghc_errtype = ERR_INVALIDARGUMENT;
699         ghc_errstr = "too many symbolic links";
700         break;
701     case GHC_EMFILE:
702         ghc_errtype = ERR_RESOURCEEXHAUSTED;
703         ghc_errstr = "process file table full";
704         break;
705     case GHC_EMLINK:
706         ghc_errtype = ERR_RESOURCEEXHAUSTED;
707         ghc_errstr = "too many links";
708         break;
709     case GHC_EMSGSIZE:
710         ghc_errtype = ERR_RESOURCEEXHAUSTED;
711         ghc_errstr = "message too long";
712         break;
713     case GHC_EMULTIHOP:
714         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
715         ghc_errstr = "multi-hop RFS request";
716         break;
717     case GHC_ENAMETOOLONG:
718         ghc_errtype = ERR_INVALIDARGUMENT;
719         ghc_errstr = "filename too long";
720         break;
721     case GHC_ENETDOWN:
722         ghc_errtype = ERR_RESOURCEVANISHED;
723         ghc_errstr = "network is down";
724         break;
725     case GHC_ENETRESET:
726         ghc_errtype = ERR_RESOURCEVANISHED;
727         ghc_errstr = "remote host rebooted; connection lost";
728         break;
729     case GHC_ENETUNREACH:
730         ghc_errtype = ERR_NOSUCHTHING;
731         ghc_errstr = "remote network is unreachable";
732         break;
733     case GHC_ENFILE:
734         ghc_errtype = ERR_RESOURCEEXHAUSTED;
735         ghc_errstr = "system file table full";
736         break;
737     case GHC_ENOBUFS:
738         ghc_errtype = ERR_RESOURCEEXHAUSTED;
739         ghc_errstr = "no buffer space available";
740         break;
741     case GHC_ENODATA:
742         ghc_errtype = ERR_NOSUCHTHING;
743         ghc_errstr = "no message on the stream head read queue";
744         break;
745     case GHC_ENODEV:
746         ghc_errtype = ERR_NOSUCHTHING;
747         ghc_errstr = "no such device";
748         break;
749     case GHC_ENOENT:
750         ghc_errtype = ERR_NOSUCHTHING;
751         ghc_errstr = "no such file or directory";
752         break;
753     case GHC_ENOEXEC:
754         ghc_errtype = ERR_INVALIDARGUMENT;
755         ghc_errstr = "not an executable file";
756         break;
757     case GHC_ENOLCK:
758         ghc_errtype = ERR_RESOURCEEXHAUSTED;
759         ghc_errstr = "no file locks available";
760         break;
761     case GHC_ENOLINK:
762         ghc_errtype = ERR_RESOURCEVANISHED;
763         ghc_errstr = "RFS link has been severed";
764         break;
765     case GHC_ENOMEM:
766         ghc_errtype = ERR_RESOURCEEXHAUSTED;
767         ghc_errstr = "not enough virtual memory";
768         break;
769     case GHC_ENOMSG:
770         ghc_errtype = ERR_NOSUCHTHING;
771         ghc_errstr = "no message of desired type";
772         break;
773     case GHC_ENONET:
774         ghc_errtype = ERR_NOSUCHTHING;
775         ghc_errstr = "host is not on a network";
776         break;
777     case GHC_ENOPROTOOPT:
778         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
779         ghc_errstr = "operation not supported by protocol";
780         break;
781     case GHC_ENOSPC:
782         ghc_errtype = ERR_RESOURCEEXHAUSTED;
783         ghc_errstr = "no space left on device";
784         break;
785     case GHC_ENOSR:
786         ghc_errtype = ERR_RESOURCEEXHAUSTED;
787         ghc_errstr = "out of stream resources";
788         break;
789     case GHC_ENOSTR:
790         ghc_errtype = ERR_INVALIDARGUMENT;
791         ghc_errstr = "not a stream device";
792         break;
793     case GHC_ENOSYS:
794         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
795         ghc_errstr = "function not implemented";
796         break;
797     case GHC_ENOTBLK:
798         ghc_errtype = ERR_INVALIDARGUMENT;
799         ghc_errstr = "not a block device";
800         break;
801     case GHC_ENOTCONN:
802         ghc_errtype = ERR_INVALIDARGUMENT;
803         ghc_errstr = "socket is not connected";
804         break;
805     case GHC_ENOTDIR:
806         ghc_errtype = ERR_INAPPROPRIATETYPE;
807         ghc_errstr = "not a directory";
808         break;
809     case GHC_ENOTEMPTY:
810         ghc_errtype = ERR_UNSATISFIEDCONSTRAINTS;
811         ghc_errstr = "directory not empty";
812         break;
813     case GHC_ENOTSOCK:
814         ghc_errtype = ERR_INVALIDARGUMENT;
815         ghc_errstr = "not a socket";
816         break;
817     case GHC_ENOTTY:
818         ghc_errtype = ERR_ILLEGALOPERATION;
819         ghc_errstr = "inappropriate ioctl for device";
820         break;
821     case GHC_ENXIO:
822         ghc_errtype = ERR_NOSUCHTHING;
823         ghc_errstr = "no such device or address";
824         break;
825     case GHC_EOPNOTSUPP:
826         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
827         ghc_errstr = "operation not supported on socket";
828         break;
829     case GHC_EPERM:
830         ghc_errtype = ERR_PERMISSIONDENIED;
831         ghc_errstr = "privileged operation";
832         break;
833     case GHC_EPFNOSUPPORT:
834         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
835         ghc_errstr = "protocol family not supported";
836         break;
837     case GHC_EPIPE:
838         ghc_errtype = ERR_RESOURCEVANISHED;
839         ghc_errstr = "broken pipe";
840         break;
841     case GHC_EPROCLIM:
842         ghc_errtype = ERR_PERMISSIONDENIED;
843         ghc_errstr = "too many processes";
844         break;
845     case GHC_EPROCUNAVAIL:
846         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
847         ghc_errstr = "unimplemented RPC procedure";
848         break;
849     case GHC_EPROGMISMATCH:
850         ghc_errtype = ERR_PROTOCOLERROR;
851         ghc_errstr = "unsupported RPC program version";
852         break;
853     case GHC_EPROGUNAVAIL:
854         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
855         ghc_errstr = "RPC program unavailable";
856         break;
857     case GHC_EPROTO:
858         ghc_errtype = ERR_PROTOCOLERROR;
859         ghc_errstr = "error in streams protocol";
860         break;
861     case GHC_EPROTONOSUPPORT:
862         ghc_errtype = ERR_PROTOCOLERROR;
863         ghc_errstr = "protocol not supported";
864         break;
865     case GHC_EPROTOTYPE:
866         ghc_errtype = ERR_PROTOCOLERROR;
867         ghc_errstr = "wrong protocol for socket";
868         break;
869     case GHC_ERANGE:
870         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
871         ghc_errstr = "result too large";
872         break;
873     case GHC_EREMCHG:
874         ghc_errtype = ERR_RESOURCEVANISHED;
875         ghc_errstr = "remote address changed";
876         break;
877     case GHC_EREMOTE:
878         ghc_errtype = ERR_ILLEGALOPERATION;
879         ghc_errstr = "too many levels of remote in path";
880         break;
881     case GHC_EROFS:
882         ghc_errtype = ERR_PERMISSIONDENIED;
883         ghc_errstr = "read-only file system";
884         break;
885     case GHC_ERPCMISMATCH:
886         ghc_errtype = ERR_PROTOCOLERROR;
887         ghc_errstr = "RPC version is wrong";
888         break;
889     case GHC_ERREMOTE:
890         ghc_errtype = ERR_ILLEGALOPERATION;
891         ghc_errstr = "object is remote";
892         break;
893     case GHC_ESHUTDOWN:
894         ghc_errtype = ERR_ILLEGALOPERATION;
895         ghc_errstr = "can't send after socket shutdown";
896         break;
897     case GHC_ESOCKTNOSUPPORT:
898         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
899         ghc_errstr = "socket type not supported";
900         break;
901     case GHC_ESPIPE:
902         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
903         ghc_errstr = "can't seek on a pipe";
904         break;
905     case GHC_ESRCH:
906         ghc_errtype = ERR_NOSUCHTHING;
907         ghc_errstr = "no such process";
908         break;
909     case GHC_ESRMNT:
910         ghc_errtype = ERR_UNSATISFIEDCONSTRAINTS;
911         ghc_errstr = "RFS resources still mounted by remote host(s)";
912         break;
913     case GHC_ESTALE:
914         ghc_errtype = ERR_RESOURCEVANISHED;
915         ghc_errstr = "stale NFS file handle";
916         break;
917     case GHC_ETIME:
918         ghc_errtype = ERR_TIMEEXPIRED;
919         ghc_errstr = "timer expired";
920         break;
921     case GHC_ETIMEDOUT:
922         ghc_errtype = ERR_TIMEEXPIRED;
923         ghc_errstr = "connection timed out";
924         break;
925     case GHC_ETOOMANYREFS:
926         ghc_errtype = ERR_RESOURCEEXHAUSTED;
927         ghc_errstr = "too many references; can't splice";
928         break;
929     case GHC_ETXTBSY:
930         ghc_errtype = ERR_RESOURCEBUSY;
931         ghc_errstr = "text file in-use";
932         break;
933     case GHC_EUSERS:
934         ghc_errtype = ERR_RESOURCEEXHAUSTED;
935         ghc_errstr = "quota table full";
936         break;
937     case GHC_EWOULDBLOCK:
938         ghc_errtype = ERR_OTHERERROR;
939         ghc_errstr = "operation would block";
940         break;
941     case GHC_EXDEV:
942         ghc_errtype = ERR_UNSUPPORTEDOPERATION;
943         ghc_errstr = "can't make a cross-device link";
944         break;
945     }
946 }
947
948 void
949 convertErrno(void)
950 {
951  cvtErrno();
952  stdErrno();
953 }