OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [readline/] [examples/] [rlfe/] [os.h] - Blame information for rev 822

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
/* Copyright (c) 1993-2002
2
 *      Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
3
 *      Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
4
 * Copyright (c) 1987 Oliver Laumann
5
 *
6
 * This program is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2, or (at your option)
9
 * any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program (see the file COPYING); if not, write to the
18
 * Free Software Foundation, Inc.,
19
 * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
20
 *
21
 ****************************************************************
22
 */
23
 
24
#include <stdio.h>
25
#include <errno.h>
26
 
27
#include <sys/param.h>
28
 
29
/* In strict ANSI mode, HP-UX machines define __hpux but not hpux */
30
#if defined(__hpux) && !defined(hpux)
31
# define hpux
32
#endif
33
 
34
#if defined(__bsdi__) || defined(__386BSD__) || defined(_CX_UX) || defined(hpux) || defined(_IBMR2) || defined(linux)
35
# include <signal.h>
36
#endif /* __bsdi__ || __386BSD__ || _CX_UX || hpux || _IBMR2 || linux */
37
 
38
#ifdef ISC
39
# ifdef ENAMETOOLONG
40
#  undef ENAMETOOLONG
41
# endif
42
# ifdef ENOTEMPTY
43
#  undef ENOTEMPTY
44
# endif
45
# include <sys/bsdtypes.h>
46
# include <net/errno.h>
47
#endif
48
 
49
#ifdef sun
50
# define getpgrp __getpgrp
51
# define exit __exit
52
#endif
53
#ifdef POSIX
54
# include <unistd.h>
55
# if defined(__STDC__)
56
#  include <stdlib.h>
57
# endif /* __STDC__ */
58
#endif /* POSIX */
59
#ifdef sun
60
# undef getpgrp
61
# undef exit
62
#endif /* sun */
63
 
64
#ifndef linux /* all done in <errno.h> */
65
extern int errno;
66
#endif /* linux */
67
#ifndef HAVE_STRERROR
68
/* No macros, please */
69
#undef strerror
70
#endif
71
 
72
#if !defined(SYSV) && !defined(linux)
73
# ifdef NEWSOS
74
#  define strlen ___strlen___
75
#  include <strings.h>
76
#  undef strlen
77
# else /* NEWSOS */
78
#  include <strings.h>
79
# endif /* NEWSOS */
80
#else /* SYSV */
81
# if defined(SVR4) || defined(NEWSOS)
82
#  define strlen ___strlen___
83
#  include <string.h>
84
#  undef strlen
85
#  if !defined(NEWSOS) && !defined(__hpux)
86
    extern size_t strlen(const char *);
87
#  endif
88
# else /* SVR4 */
89
#  include <string.h>
90
# endif /* SVR4 */
91
#endif /* SYSV */
92
 
93
#ifdef USEVARARGS
94
# if defined(__STDC__)
95
#  include <stdarg.h>
96
#  define VA_LIST(var) va_list var;
97
#  define VA_DOTS ...
98
#  define VA_DECL
99
#  define VA_START(ap, fmt) va_start(ap, fmt)
100
#  define VA_ARGS(ap) ap
101
#  define VA_END(ap) va_end(ap)
102
# else
103
#  include <varargs.h>
104
#  define VA_LIST(var) va_list var;
105
#  define VA_DOTS va_alist
106
#  define VA_DECL va_dcl
107
#  define VA_START(ap, fmt) va_start(ap)
108
#  define VA_ARGS(ap) ap
109
#  define VA_END(ap) va_end(ap)
110
# endif
111
#else
112
# define VA_LIST(var)
113
# define VA_DOTS p1, p2, p3, p4, p5, p6
114
# define VA_DECL unsigned long VA_DOTS;
115
# define VA_START(ap, fmt)
116
# define VA_ARGS(ap) VA_DOTS
117
# define VA_END(ap)
118
# undef vsnprintf
119
# define vsnprintf xsnprintf
120
#endif
121
 
122
#if !defined(sun) && !defined(B43) && !defined(ISC) && !defined(pyr) && !defined(_CX_UX)
123
# include <time.h>
124
#endif
125
#include <sys/time.h>
126
 
127
#ifdef M_UNIX   /* SCO */
128
# include <sys/stream.h>
129
# include <sys/ptem.h>
130
# define ftruncate(fd, s) chsize(fd, s)
131
#endif
132
 
133
#ifdef SYSV
134
# define index strchr
135
# define rindex strrchr
136
# define bzero(poi,len) memset(poi,0,len)
137
# define bcmp memcmp
138
# define killpg(pgrp,sig) kill( -(pgrp), sig)
139
#endif
140
 
141
#ifndef HAVE_GETCWD
142
# define getcwd(b,l) getwd(b)
143
#endif
144
 
145
#ifndef USEBCOPY
146
# ifdef USEMEMMOVE
147
#  define bcopy(s,d,len) memmove(d,s,len)
148
# else
149
#  ifdef USEMEMCPY
150
#   define bcopy(s,d,len) memcpy(d,s,len)
151
#  else
152
#   define NEED_OWN_BCOPY
153
#   define bcopy xbcopy
154
#  endif
155
# endif
156
#endif
157
 
158
#ifdef hpux
159
# define setreuid(ruid, euid) setresuid(ruid, euid, -1)
160
# define setregid(rgid, egid) setresgid(rgid, egid, -1)
161
#endif
162
 
163
#if defined(HAVE_SETEUID) || defined(HAVE_SETREUID)
164
# define USE_SETEUID
165
#endif
166
 
167
#if !defined(HAVE__EXIT) && !defined(_exit)
168
#define _exit(x) exit(x)
169
#endif
170
 
171
#ifndef HAVE_UTIMES
172
# define utimes utime
173
#endif
174
 
175
#ifdef BUILTIN_TELNET
176
# include <netinet/in.h>
177
# include <arpa/inet.h>
178
#endif
179
 
180
#if defined(USE_LOCALE) && (!defined(HAVE_SETLOCALE) || !defined(HAVE_STRFTIME))
181
# undef USE_LOCALE
182
#endif
183
 
184
/*****************************************************************
185
 *    terminal handling
186
 */
187
 
188
#ifdef POSIX
189
# include <termios.h>
190
# ifdef hpux
191
#  include <bsdtty.h>
192
# endif /* hpux */
193
# ifdef NCCS
194
#  define MAXCC NCCS
195
# else
196
#  define MAXCC 256
197
# endif
198
#else /* POSIX */
199
# ifdef TERMIO
200
#  include <termio.h>
201
#  ifdef NCC
202
#   define MAXCC NCC
203
#  else
204
#   define MAXCC 256
205
#  endif
206
#  ifdef CYTERMIO
207
#   include <cytermio.h>
208
#  endif
209
# else /* TERMIO */
210
#  include <sgtty.h>
211
# endif /* TERMIO */
212
#endif /* POSIX */
213
 
214
#ifndef VDISABLE
215
# ifdef _POSIX_VDISABLE
216
#  define VDISABLE _POSIX_VDISABLE
217
# else
218
#  define VDISABLE 0377
219
# endif /* _POSIX_VDISABLE */
220
#endif /* !VDISABLE */
221
 
222
 
223
/* on sgi, regardless of the stream head's read mode (RNORM/RMSGN/RMSGD)
224
 * TIOCPKT mode causes data loss if our buffer is too small (IOSIZE)
225
 * to hold the whole packet at first read().
226
 * (Marc Boucher)
227
 *
228
 * matthew green:
229
 * TIOCPKT is broken on dgux 5.4.1 generic AViiON mc88100
230
 *
231
 * Joe Traister: On AIX4, programs like irc won't work if screen
232
 * uses TIOCPKT (select fails to return on pty read).
233
 */
234
#if defined(sgi) || defined(DGUX) || defined(_IBMR2)
235
# undef TIOCPKT
236
#endif
237
 
238
/* linux ncurses is broken, we have to use our own tputs */
239
#if defined(linux) && defined(TERMINFO)
240
# define tputs xtputs
241
#endif
242
 
243
/* Alexandre Oliva: SVR4 style ptys don't work with osf */
244
#ifdef __osf__
245
# undef HAVE_SVR4_PTYS
246
#endif
247
 
248
/*****************************************************************
249
 *   utmp handling
250
 */
251
 
252
#ifdef GETUTENT
253
  typedef char *slot_t;
254
#else
255
  typedef int slot_t;
256
#endif
257
 
258
#if defined(UTMPOK) || defined(BUGGYGETLOGIN)
259
# if defined(SVR4) && !defined(DGUX) && !defined(__hpux) && !defined(linux)
260
#  include <utmpx.h>
261
#  define UTMPFILE      UTMPX_FILE
262
#  define utmp          utmpx
263
#  define getutent      getutxent
264
#  define getutid       getutxid
265
#  define getutline     getutxline
266
#  define pututline     pututxline
267
#  define setutent      setutxent
268
#  define endutent      endutxent
269
#  define ut_time       ut_xtime
270
# else /* SVR4 */
271
#  include <utmp.h>
272
# endif /* SVR4 */
273
# ifdef apollo
274
   /*
275
    * We don't have GETUTENT, so we dig into utmp ourselves.
276
    * But we save the permanent filedescriptor and
277
    * open utmp just when we need to.
278
    * This code supports an unsorted utmp. jw.
279
    */
280
#  define UTNOKEEP
281
# endif /* apollo */
282
 
283
# ifndef UTMPFILE
284
#  ifdef UTMP_FILE
285
#   define UTMPFILE     UTMP_FILE
286
#  else
287
#   ifdef _PATH_UTMP
288
#    define UTMPFILE    _PATH_UTMP
289
#   else
290
#    define UTMPFILE    "/etc/utmp"
291
#   endif /* _PATH_UTMP */
292
#  endif
293
# endif
294
 
295
#endif /* UTMPOK || BUGGYGETLOGIN */
296
 
297
#if !defined(UTMPOK) && defined(USRLIMIT)
298
# undef USRLIMIT
299
#endif
300
 
301
#ifdef LOGOUTOK
302
# ifndef LOGINDEFAULT
303
#  define LOGINDEFAULT 0
304
# endif
305
#else
306
# ifdef LOGINDEFAULT
307
#  undef LOGINDEFAULT
308
# endif
309
# define LOGINDEFAULT 1
310
#endif
311
 
312
 
313
/*****************************************************************
314
 *    file stuff
315
 */
316
 
317
#ifndef F_OK
318
#define F_OK 0
319
#endif
320
#ifndef X_OK
321
#define X_OK 1
322
#endif
323
#ifndef W_OK
324
#define W_OK 2
325
#endif
326
#ifndef R_OK
327
#define R_OK 4
328
#endif
329
 
330
#ifndef S_IFIFO
331
#define S_IFIFO  0010000
332
#endif
333
#ifndef S_IREAD
334
#define S_IREAD  0000400
335
#endif
336
#ifndef S_IWRITE
337
#define S_IWRITE 0000200
338
#endif
339
#ifndef S_IEXEC
340
#define S_IEXEC  0000100
341
#endif
342
 
343
#if defined(S_IFIFO) && defined(S_IFMT) && !defined(S_ISFIFO)
344
#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
345
#endif
346
#if defined(S_IFSOCK) && defined(S_IFMT) && !defined(S_ISSOCK)
347
#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
348
#endif
349
#if defined(S_IFCHR) && defined(S_IFMT) && !defined(S_ISCHR)
350
#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
351
#endif
352
#if defined(S_IFDIR) && defined(S_IFMT) && !defined(S_ISDIR)
353
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
354
#endif
355
#if defined(S_IFLNK) && defined(S_IFMT) && !defined(S_ISLNK)
356
#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
357
#endif
358
 
359
/*
360
 * SunOS 4.1.3: `man 2V open' has only one line that mentions O_NOBLOCK:
361
 *
362
 *     O_NONBLOCK     Same as O_NDELAY above.
363
 *
364
 * on the very same SunOS 4.1.3, I traced the open system call and found
365
 * that an open("/dev/ttyy08", O_RDWR|O_NONBLOCK|O_NOCTTY) was blocked,
366
 * whereas open("/dev/ttyy08", O_RDWR|O_NDELAY  |O_NOCTTY) went through.
367
 *
368
 * For this simple reason I now favour O_NDELAY. jw. 4.5.95
369
 */
370
#if defined(sun) && !defined(SVR4)
371
# undef O_NONBLOCK
372
#endif
373
 
374
#if !defined(O_NONBLOCK) && defined(O_NDELAY)
375
# define O_NONBLOCK O_NDELAY
376
#endif
377
 
378
#if !defined(FNBLOCK) && defined(FNONBLOCK)
379
# define FNBLOCK FNONBLOCK
380
#endif
381
#if !defined(FNBLOCK) && defined(FNDELAY)
382
# define FNBLOCK FNDELAY
383
#endif
384
#if !defined(FNBLOCK) && defined(O_NONBLOCK)
385
# define FNBLOCK O_NONBLOCK
386
#endif
387
 
388
#ifndef POSIX
389
#undef mkfifo
390
#define mkfifo(n,m) mknod(n,S_IFIFO|(m),0)
391
#endif
392
 
393
#if !defined(HAVE_LSTAT) && !defined(lstat)
394
# define lstat stat
395
#endif
396
 
397
/*****************************************************************
398
 *    signal handling
399
 */
400
 
401
#ifdef SIGVOID
402
# define SIGRETURN
403
# define sigret_t void
404
#else
405
# define SIGRETURN return 0;
406
# define sigret_t int
407
#endif
408
 
409
/* Geeeee, reverse it? */
410
#if defined(SVR4) || (defined(SYSV) && defined(ISC)) || defined(_AIX) || defined(linux) || defined(ultrix) || defined(__386BSD__) || defined(__bsdi__) || defined(POSIX) || defined(NeXT)
411
# define SIGHASARG
412
#endif
413
 
414
#ifdef SIGHASARG
415
# define SIGPROTOARG   (int)
416
# define SIGDEFARG     (sigsig) int sigsig;
417
# define SIGARG        0
418
#else
419
# define SIGPROTOARG   (void)
420
# define SIGDEFARG     ()
421
# define SIGARG
422
#endif
423
 
424
#ifndef SIGCHLD
425
#define SIGCHLD SIGCLD
426
#endif
427
 
428
#if defined(POSIX) || defined(hpux)
429
# define signal xsignal
430
#else
431
# ifdef USESIGSET
432
#  define signal sigset
433
# endif /* USESIGSET */
434
#endif
435
 
436
/* used in screen.c and attacher.c */
437
#ifndef NSIG            /* kbeal needs these w/o SYSV */
438
# define NSIG 32
439
#endif /* !NSIG */
440
 
441
 
442
/*****************************************************************
443
 *    Wait stuff
444
 */
445
 
446
#if (!defined(sysV68) && !defined(M_XENIX)) || defined(NeXT) || defined(M_UNIX)
447
# include <sys/wait.h>
448
#endif
449
 
450
#ifndef WTERMSIG
451
# ifndef BSDWAIT /* if wait is NOT a union: */
452
#  define WTERMSIG(status) (status & 0177)
453
# else
454
#  define WTERMSIG(status) status.w_T.w_Termsig 
455
# endif
456
#endif
457
 
458
#ifndef WSTOPSIG
459
# ifndef BSDWAIT /* if wait is NOT a union: */
460
#  define WSTOPSIG(status) ((status >> 8) & 0377)
461
# else
462
#  define WSTOPSIG(status) status.w_S.w_Stopsig 
463
# endif
464
#endif
465
 
466
/* NET-2 uses WCOREDUMP */
467
#if defined(WCOREDUMP) && !defined(WIFCORESIG)
468
# define WIFCORESIG(status) WCOREDUMP(status)
469
#endif
470
 
471
#ifndef WIFCORESIG
472
# ifndef BSDWAIT /* if wait is NOT a union: */
473
#  define WIFCORESIG(status) (status & 0200)
474
# else
475
#  define WIFCORESIG(status) status.w_T.w_Coredump
476
# endif
477
#endif
478
 
479
#ifndef WEXITSTATUS
480
# ifndef BSDWAIT /* if wait is NOT a union: */
481
#  define WEXITSTATUS(status) ((status >> 8) & 0377)
482
# else
483
#  define WEXITSTATUS(status) status.w_T.w_Retcode
484
# endif
485
#endif
486
 
487
 
488
/*****************************************************************
489
 *    select stuff
490
 */
491
 
492
#if defined(M_XENIX) || defined(M_UNIX) || defined(_SEQUENT_)
493
#include <sys/select.h>         /* for timeval + FD... */
494
#endif
495
 
496
/*
497
 * SunOS 3.5 - Tom Schmidt - Micron Semiconductor, Inc - 27-Jul-93
498
 * tschmidt@vax.micron.com
499
 */
500
#ifndef FD_SET
501
# ifndef SUNOS3
502
typedef struct fd_set { int fds_bits[1]; } fd_set;
503
# endif
504
# define FD_ZERO(fd) ((fd)->fds_bits[0] = 0)
505
# define FD_SET(b, fd) ((fd)->fds_bits[0] |= 1 << (b))
506
# define FD_ISSET(b, fd) ((fd)->fds_bits[0] & 1 << (b))
507
# define FD_SETSIZE 32
508
#endif
509
 
510
 
511
/*****************************************************************
512
 *    user defineable stuff
513
 */
514
 
515
#ifndef TERMCAP_BUFSIZE
516
# define TERMCAP_BUFSIZE 2048
517
#endif
518
 
519
#ifndef MAXPATHLEN
520
# define MAXPATHLEN 1024
521
#endif
522
 
523
/*
524
 * you may try to vary this value. Use low values if your (VMS) system
525
 * tends to choke when pasting. Use high values if you want to test
526
 * how many characters your pty's can buffer.
527
 */
528
#define IOSIZE          4096
529
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.