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