[project @ 2001-12-21 15:07:20 by simonmar]
[packages/random.git] / cbits / errno.c
1 /*
2 * (c) The University of Glasgow, 2000-2001
3 *
4 * $Id: errno.c,v 1.3 2001/12/21 15:07:26 simonmar Exp $
5 *
6 * GHC Error Number Conversion
7 */
8
9 #include "HsCore.h"
10
11 /* Raw errno */
12 /* Covers up the fact that on Windows this is a function */
13
14 int *ghcErrno(void) {
15 return &errno;
16 }
17
18
19 /* Wrappers for the individual error codes - boring */
20 #define ErrCode(x) HsInt prel_error_##x() { return x; }
21 #define ErrCode2(x,y) HsInt prel_error_##x() { return y; }
22
23 #ifdef E2BIG
24 ErrCode(E2BIG)
25 #else
26 ErrCode2(E2BIG,-1)
27 #endif
28
29 #ifdef EACCES
30 ErrCode(EACCES)
31 #else
32 ErrCode2(EACCES,-1)
33 #endif
34
35 #ifdef EADDRINUSE
36 ErrCode(EADDRINUSE)
37 #else
38 ErrCode2(EADDRINUSE,-1)
39 #endif
40
41 #ifdef EADDRNOTAVAIL
42 ErrCode(EADDRNOTAVAIL)
43 #else
44 ErrCode2(EADDRNOTAVAIL,-1)
45 #endif
46
47 #ifdef EADV
48 ErrCode(EADV)
49 #else
50 ErrCode2(EADV,-1)
51 #endif
52
53 #ifdef EAFNOSUPPORT
54 ErrCode(EAFNOSUPPORT)
55 #else
56 ErrCode2(EAFNOSUPPORT,-1)
57 #endif
58
59 #ifdef EAGAIN
60 ErrCode(EAGAIN)
61 #else
62 ErrCode2(EAGAIN,-1)
63 #endif
64
65 #ifdef EALREADY
66 ErrCode(EALREADY)
67 #else
68 ErrCode2(EALREADY,-1)
69 #endif
70
71 #ifdef EBADF
72 ErrCode(EBADF)
73 #else
74 ErrCode2(EBADF,-1)
75 #endif
76
77 #ifdef EBADMSG
78 ErrCode(EBADMSG)
79 #else
80 ErrCode2(EBADMSG,-1)
81 #endif
82
83 #ifdef EBADRPC
84 ErrCode(EBADRPC)
85 #else
86 ErrCode2(EBADRPC,-1)
87 #endif
88
89 #ifdef EBUSY
90 ErrCode(EBUSY)
91 #else
92 ErrCode2(EBUSY,-1)
93 #endif
94
95 #ifdef ECHILD
96 ErrCode(ECHILD)
97 #else
98 ErrCode2(ECHILD,-1)
99 #endif
100
101 #ifdef ECOMM
102 ErrCode(ECOMM)
103 #else
104 ErrCode2(ECOMM,-1)
105 #endif
106
107 #ifdef ECONNABORTED
108 ErrCode(ECONNABORTED)
109 #else
110 ErrCode2(ECONNABORTED,-1)
111 #endif
112
113 #ifdef ECONNREFUSED
114 ErrCode(ECONNREFUSED)
115 #else
116 ErrCode2(ECONNREFUSED,-1)
117 #endif
118
119 #ifdef ECONNRESET
120 ErrCode(ECONNRESET)
121 #else
122 ErrCode2(ECONNRESET,-1)
123 #endif
124
125 #ifdef EDEADLK
126 ErrCode(EDEADLK)
127 #else
128 ErrCode2(EDEADLK,-1)
129 #endif
130
131 #ifdef EDESTADDRREQ
132 ErrCode(EDESTADDRREQ)
133 #else
134 ErrCode2(EDESTADDRREQ,-1)
135 #endif
136
137 #ifdef EDIRTY
138 ErrCode(EDIRTY)
139 #else
140 ErrCode2(EDIRTY,-1)
141 #endif
142
143 #ifdef EDOM
144 ErrCode(EDOM)
145 #else
146 ErrCode2(EDOM,-1)
147 #endif
148
149 #ifdef EDQUOT
150 ErrCode(EDQUOT)
151 #else
152 ErrCode2(EDQUOT,-1)
153 #endif
154
155 #ifdef EEXIST
156 ErrCode(EEXIST)
157 #else
158 ErrCode2(EEXIST,-1)
159 #endif
160
161 #ifdef EFAULT
162 ErrCode(EFAULT)
163 #else
164 ErrCode2(EFAULT,-1)
165 #endif
166
167 #ifdef EFBIG
168 ErrCode(EFBIG)
169 #else
170 ErrCode2(EFBIG,-1)
171 #endif
172
173 #ifdef EFTYPE
174 ErrCode(EFTYPE)
175 #else
176 ErrCode2(EFTYPE,-1)
177 #endif
178
179 #ifdef EHOSTDOWN
180 ErrCode(EHOSTDOWN)
181 #else
182 ErrCode2(EHOSTDOWN,-1)
183 #endif
184
185 #ifdef EHOSTUNREACH
186 ErrCode(EHOSTUNREACH)
187 #else
188 ErrCode2(EHOSTUNREACH,-1)
189 #endif
190
191 #ifdef EIDRM
192 ErrCode(EIDRM)
193 #else
194 ErrCode2(EIDRM,-1)
195 #endif
196
197 #ifdef EILSEQ
198 ErrCode(EILSEQ)
199 #else
200 ErrCode2(EILSEQ,-1)
201 #endif
202
203 #ifdef EINPROGRESS
204 ErrCode(EINPROGRESS)
205 #else
206 ErrCode2(EINPROGRESS,-1)
207 #endif
208
209 #ifdef EINTR
210 ErrCode(EINTR)
211 #else
212 ErrCode2(EINTR,-1)
213 #endif
214
215 #ifdef EINVAL
216 ErrCode(EINVAL)
217 #else
218 ErrCode2(EINVAL,-1)
219 #endif
220
221 #ifdef EIO
222 ErrCode(EIO)
223 #else
224 ErrCode2(EIO,-1)
225 #endif
226
227 #ifdef EISCONN
228 ErrCode(EISCONN)
229 #else
230 ErrCode2(EISCONN,-1)
231 #endif
232
233 #ifdef EISDIR
234 ErrCode(EISDIR)
235 #else
236 ErrCode2(EISDIR,-1)
237 #endif
238
239 #ifdef ELOOP
240 ErrCode(ELOOP)
241 #else
242 ErrCode2(ELOOP,-1)
243 #endif
244
245 #ifdef EMFILE
246 ErrCode(EMFILE)
247 #else
248 ErrCode2(EMFILE,-1)
249 #endif
250
251 #ifdef EMLINK
252 ErrCode(EMLINK)
253 #else
254 ErrCode2(EMLINK,-1)
255 #endif
256
257 #ifdef EMSGSIZE
258 ErrCode(EMSGSIZE)
259 #else
260 ErrCode2(EMSGSIZE,-1)
261 #endif
262
263 #ifdef EMULTIHOP
264 ErrCode(EMULTIHOP)
265 #else
266 ErrCode2(EMULTIHOP,-1)
267 #endif
268
269 #ifdef ENAMETOOLONG
270 ErrCode(ENAMETOOLONG)
271 #else
272 ErrCode2(ENAMETOOLONG,-1)
273 #endif
274
275 #ifdef ENETDOWN
276 ErrCode(ENETDOWN)
277 #else
278 ErrCode2(ENETDOWN,-1)
279 #endif
280
281 #ifdef ENETRESET
282 ErrCode(ENETRESET)
283 #else
284 ErrCode2(ENETRESET,-1)
285 #endif
286
287 #ifdef ENETUNREACH
288 ErrCode(ENETUNREACH)
289 #else
290 ErrCode2(ENETUNREACH,-1)
291 #endif
292
293 #ifdef ENFILE
294 ErrCode(ENFILE)
295 #else
296 ErrCode2(ENFILE,-1)
297 #endif
298
299 #ifdef ENOBUFS
300 ErrCode(ENOBUFS)
301 #else
302 ErrCode2(ENOBUFS,-1)
303 #endif
304
305 #ifdef ENODATA
306 ErrCode(ENODATA)
307 #else
308 ErrCode2(ENODATA,-1)
309 #endif
310
311 #ifdef ENODEV
312 ErrCode(ENODEV)
313 #else
314 ErrCode2(ENODEV,-1)
315 #endif
316
317 #ifdef ENOENT
318 ErrCode(ENOENT)
319 #else
320 ErrCode2(ENOENT,-1)
321 #endif
322
323 #ifdef ENOEXEC
324 ErrCode(ENOEXEC)
325 #else
326 ErrCode2(ENOEXEC,-1)
327 #endif
328
329 #ifdef ENOLCK
330 ErrCode(ENOLCK)
331 #else
332 ErrCode2(ENOLCK,-1)
333 #endif
334
335 #ifdef ENOLINK
336 ErrCode(ENOLINK)
337 #else
338 ErrCode2(ENOLINK,-1)
339 #endif
340
341 #ifdef ENOMEM
342 ErrCode(ENOMEM)
343 #else
344 ErrCode2(ENOMEM,-1)
345 #endif
346
347 #ifdef ENOMSG
348 ErrCode(ENOMSG)
349 #else
350 ErrCode2(ENOMSG,-1)
351 #endif
352
353 #ifdef ENONET
354 ErrCode(ENONET)
355 #else
356 ErrCode2(ENONET,-1)
357 #endif
358
359 #ifdef ENOPROTOOPT
360 ErrCode(ENOPROTOOPT)
361 #else
362 ErrCode2(ENOPROTOOPT,-1)
363 #endif
364
365 #ifdef ENOSPC
366 ErrCode(ENOSPC)
367 #else
368 ErrCode2(ENOSPC,-1)
369 #endif
370
371 #ifdef ENOSR
372 ErrCode(ENOSR)
373 #else
374 ErrCode2(ENOSR,-1)
375 #endif
376
377 #ifdef ENOSTR
378 ErrCode(ENOSTR)
379 #else
380 ErrCode2(ENOSTR,-1)
381 #endif
382
383 #ifdef ENOSYS
384 ErrCode(ENOSYS)
385 #else
386 ErrCode2(ENOSYS,-1)
387 #endif
388
389 #ifdef ENOTBLK
390 ErrCode(ENOTBLK)
391 #else
392 ErrCode2(ENOTBLK,-1)
393 #endif
394
395 #ifdef ENOTCONN
396 ErrCode(ENOTCONN)
397 #else
398 ErrCode2(ENOTCONN,-1)
399 #endif
400
401 #ifdef ENOTDIR
402 ErrCode(ENOTDIR)
403 #else
404 ErrCode2(ENOTDIR,-1)
405 #endif
406
407 #ifdef ENOTEMPTY
408 ErrCode(ENOTEMPTY)
409 #else
410 ErrCode2(ENOTEMPTY,-1)
411 #endif
412
413 #ifdef ENOTSOCK
414 ErrCode(ENOTSOCK)
415 #else
416 ErrCode2(ENOTSOCK,-1)
417 #endif
418
419 #ifdef ENOTTY
420 ErrCode(ENOTTY)
421 #else
422 ErrCode2(ENOTTY,-1)
423 #endif
424
425 #ifdef ENXIO
426 ErrCode(ENXIO)
427 #else
428 ErrCode2(ENXIO,-1)
429 #endif
430
431 #ifdef EOPNOTSUPP
432 ErrCode(EOPNOTSUPP)
433 #else
434 ErrCode2(EOPNOTSUPP,-1)
435 #endif
436
437 #ifdef EPERM
438 ErrCode(EPERM)
439 #else
440 ErrCode2(EPERM,-1)
441 #endif
442
443 #ifdef EPFNOSUPPORT
444 ErrCode(EPFNOSUPPORT)
445 #else
446 ErrCode2(EPFNOSUPPORT,-1)
447 #endif
448
449 #ifdef EPIPE
450 ErrCode(EPIPE)
451 #else
452 ErrCode2(EPIPE,-1)
453 #endif
454
455 #ifdef EPROCLIM
456 ErrCode(EPROCLIM)
457 #else
458 ErrCode2(EPROCLIM,-1)
459 #endif
460
461 #ifdef EPROCUNAVAIL
462 ErrCode(EPROCUNAVAIL)
463 #else
464 ErrCode2(EPROCUNAVAIL,-1)
465 #endif
466
467 #ifdef EPROGMISMATCH
468 ErrCode(EPROGMISMATCH)
469 #else
470 ErrCode2(EPROGMISMATCH,-1)
471 #endif
472
473 #ifdef EPROGUNAVAIL
474 ErrCode(EPROGUNAVAIL)
475 #else
476 ErrCode2(EPROGUNAVAIL,-1)
477 #endif
478
479 #ifdef EPROTO
480 ErrCode(EPROTO)
481 #else
482 ErrCode2(EPROTO,-1)
483 #endif
484
485 #ifdef EPROTONOSUPPORT
486 ErrCode(EPROTONOSUPPORT)
487 #else
488 ErrCode2(EPROTONOSUPPORT,-1)
489 #endif
490
491 #ifdef EPROTOTYPE
492 ErrCode(EPROTOTYPE)
493 #else
494 ErrCode2(EPROTOTYPE,-1)
495 #endif
496
497 #ifdef ERANGE
498 ErrCode(ERANGE)
499 #else
500 ErrCode2(ERANGE,-1)
501 #endif
502
503 #ifdef EREMCHG
504 ErrCode(EREMCHG)
505 #else
506 ErrCode2(EREMCHG,-1)
507 #endif
508
509 #ifdef EREMOTE
510 ErrCode(EREMOTE)
511 #else
512 ErrCode2(EREMOTE,-1)
513 #endif
514
515 #ifdef EROFS
516 ErrCode(EROFS)
517 #else
518 ErrCode2(EROFS,-1)
519 #endif
520
521 #ifdef ERPCMISMATCH
522 ErrCode(ERPCMISMATCH)
523 #else
524 ErrCode2(ERPCMISMATCH,-1)
525 #endif
526
527 #ifdef ERREMOTE
528 ErrCode(ERREMOTE)
529 #else
530 ErrCode2(ERREMOTE,-1)
531 #endif
532
533 #ifdef ESHUTDOWN
534 ErrCode(ESHUTDOWN)
535 #else
536 ErrCode2(ESHUTDOWN,-1)
537 #endif
538
539 #ifdef ESOCKTNOSUPPORT
540 ErrCode(ESOCKTNOSUPPORT)
541 #else
542 ErrCode2(ESOCKTNOSUPPORT,-1)
543 #endif
544
545 #ifdef ESPIPE
546 ErrCode(ESPIPE)
547 #else
548 ErrCode2(ESPIPE,-1)
549 #endif
550
551 #ifdef ESRCH
552 ErrCode(ESRCH)
553 #else
554 ErrCode2(ESRCH,-1)
555 #endif
556
557 #ifdef ESRMNT
558 ErrCode(ESRMNT)
559 #else
560 ErrCode2(ESRMNT,-1)
561 #endif
562
563 #ifdef ESTALE
564 ErrCode(ESTALE)
565 #else
566 ErrCode2(ESTALE,-1)
567 #endif
568
569 #ifdef ETIME
570 ErrCode(ETIME)
571 #else
572 ErrCode2(ETIME,-1)
573 #endif
574
575 #ifdef ETIMEDOUT
576 ErrCode(ETIMEDOUT)
577 #else
578 ErrCode2(ETIMEDOUT,-1)
579 #endif
580
581 #ifdef ETOOMANYREFS
582 ErrCode(ETOOMANYREFS)
583 #else
584 ErrCode2(ETOOMANYREFS,-1)
585 #endif
586
587 #ifdef ETXTBSY
588 ErrCode(ETXTBSY)
589 #else
590 ErrCode2(ETXTBSY,-1)
591 #endif
592
593 #ifdef EUSERS
594 ErrCode(EUSERS)
595 #else
596 ErrCode2(EUSERS,-1)
597 #endif
598
599 #ifdef EWOULDBLOCK
600 ErrCode(EWOULDBLOCK)
601 #else
602 ErrCode2(EWOULDBLOCK,-1)
603 #endif
604
605 #ifdef EXDEV
606 ErrCode(EXDEV)
607 #else
608 ErrCode2(EXDEV,-1)
609 #endif
610