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