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