⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 book.txt

📁 操作系统设计与实现源码
💻 TXT
📖 第 1 页 / 共 5 页
字号:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
				include/ansi.h	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

00000	/* The <ansi.h> header attempts to decide whether the compiler has enough
00001	 * conformance to Standard C for Minix to take advantage of.  If so, the
00002	 * symbol _ANSI is defined (as 31415).  Otherwise _ANSI is not defined
00003	 * here, but it may be defined by applications that want to bend the rules.
00004	 * The magic number in the definition is to inhibit unnecessary bending
00005	 * of the rules.  (For consistency with the new '#ifdef _ANSI" tests in
00006	 * the headers, _ANSI should really be defined as nothing, but that would
00007	 * break many library routines that use "#if _ANSI".)
00008	
00009	 * If _ANSI ends up being defined, a macro
00010	 *
00011	 *      _PROTOTYPE(function, params)
00012	 *
00013	 * is defined.  This macro expands in different ways, generating either
00014	 * ANSI Standard C prototypes or old-style K&R (Kernighan & Ritchie)
00015	 * prototypes, as needed.  Finally, some programs use _CONST, _VOIDSTAR etc
00016	 * in such a way that they are portable over both ANSI and K&R compilers.
00017	 * The appropriate macros are defined here.
00018	 */
00019	
00020	#ifndef _ANSI_H
00021	#define _ANSI_H
00022	
00023	#if __STDC__ == 1
00024	#define _ANSI           31459   /* compiler claims full ANSI conformance */
00025	#endif
00026	
00027	#ifdef __GNUC__
00028	#define _ANSI           31459   /* gcc conforms enough even in non-ANSI mode */
00029	#endif
00030	
00031	#ifdef _ANSI
00032	
00033	/* Keep everything for ANSI prototypes. */
00034	#define _PROTOTYPE(function, params)    function params
00035	#define _ARGS(params)                   params
00036	
00037	#define _VOIDSTAR       void *
00038	#define _VOID           void
00039	#define _CONST          const
00040	#define _VOLATILE       volatile
00041	#define _SIZET          size_t
00042	
00043	#else
00044	
00045	/* Throw away the parameters for K&R prototypes. */
00046	#define _PROTOTYPE(function, params)    function()
00047	#define _ARGS(params)                   ()
00048	
00049	#define _VOIDSTAR       void *
00050	#define _VOID           void
00051	#define _CONST
00052	#define _VOLATILE
00053	#define _SIZET          int
00054	
00055	#endif /* _ANSI */
00056	
00057	#endif /* ANSI_H */

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
				include/limits.h	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

00100	/* The <limits.h> header defines some basic sizes, both of the language types 
00101	 * (e.g., the number of bits in an integer), and of the operating system (e.g.
00102	 * the number of characters in a file name.
00103	 */
00104	
00105	#ifndef _LIMITS_H
00106	#define _LIMITS_H
00107	
00108	/* Definitions about chars (8 bits in MINIX, and signed). */
00109	#define CHAR_BIT           8    /* # bits in a char */
00110	#define CHAR_MIN        -128    /* minimum value of a char */
00111	#define CHAR_MAX         127    /* maximum value of a char */
00112	#define SCHAR_MIN       -128    /* minimum value of a signed char */
00113	#define SCHAR_MAX        127    /* maximum value of a signed char */
00114	#define UCHAR_MAX        255    /* maximum value of an unsigned char */
00115	#define MB_LEN_MAX         1    /* maximum length of a multibyte char */
00116	
00117	/* Definitions about shorts (16 bits in MINIX). */
00118	#define SHRT_MIN  (-32767-1)    /* minimum value of a short */
00119	#define SHRT_MAX       32767    /* maximum value of a short */
00120	#define USHRT_MAX     0xFFFF    /* maximum value of unsigned short */
00121	
00122	/* _EM_WSIZE is a compiler-generated symbol giving the word size in bytes. */
00123	#if _EM_WSIZE == 2
00124	#define INT_MIN   (-32767-1)    /* minimum value of a 16-bit int */
00125	#define INT_MAX        32767    /* maximum value of a 16-bit int */
00126	#define UINT_MAX      0xFFFF    /* maximum value of an unsigned 16-bit int */
00127	#endif
00128	
00129	#if _EM_WSIZE == 4
00130	#define INT_MIN (-2147483647-1) /* minimum value of a 32-bit int */
00131	#define INT_MAX   2147483647    /* maximum value of a 32-bit int */
00132	#define UINT_MAX  0xFFFFFFFF    /* maximum value of an unsigned 32-bit int */
00133	#endif
00134	
00135	/*Definitions about longs (32 bits in MINIX). */
00136	#define LONG_MIN (-2147483647L-1)/* minimum value of a long */
00137	#define LONG_MAX  2147483647L   /* maximum value of a long */
00138	#define ULONG_MAX 0xFFFFFFFFL   /* maximum value of an unsigned long */
00139	
00140	/* Minimum sizes required by the POSIX P1003.1 standard (Table 2-3). */
00141	#ifdef _POSIX_SOURCE            /* these are only visible for POSIX */
00142	#define _POSIX_ARG_MAX    4096  /* exec() may have 4K worth of args */
00143	#define _POSIX_CHILD_MAX     6  /* a process may have 6 children */
00144	#define _POSIX_LINK_MAX      8  /* a file may have 8 links */
00145	#define _POSIX_MAX_CANON   255  /* size of the canonical input queue */
00146	#define _POSIX_MAX_INPUT   255  /* you can type 255 chars ahead */
00147	#define _POSIX_NAME_MAX     14  /* a file name may have 14 chars */
00148	#define _POSIX_NGROUPS_MAX   0  /* supplementary group IDs are optional */
00149	#define _POSIX_OPEN_MAX     16  /* a process may have 16 files open */
00150	#define _POSIX_PATH_MAX    255  /* a pathname may contain 255 chars */
00151	#define _POSIX_PIPE_BUF    512  /* pipes writes of 512 bytes must be atomic */
00152	#define _POSIX_STREAM_MAX    8  /* at least 8 FILEs can be open at once */
00153	#define _POSIX_TZNAME_MAX    3  /* time zone names can be at least 3 chars */
00154	#define _POSIX_SSIZE_MAX 32767  /* read() must support 32767 byte reads */
00155	
00156	/* Values actually implemented by MINIX (Tables 2-4, 2-5, 2-6, and 2-7). */
00157	/* Some of these old names had better be defined when not POSIX. */
00158	#define _NO_LIMIT        100    /* arbitrary number; limit not enforced */
00159	
00160	#define NGROUPS_MAX        0    /* supplemental group IDs not available */
00161	#if _EM_WSIZE > 2
00162	#define ARG_MAX        16384    /* # bytes of args + environ for exec() */
00163	#else
00164	#define ARG_MAX         4096    /* args + environ on small machines */
00165	#endif
00166	#define CHILD_MAX  _NO_LIMIT    /* MINIX does not limit children */
00167	#define OPEN_MAX          20    /* # open files a process may have */
00168	#define LINK_MAX         127    /* # links a file may have */
00169	#define MAX_CANON        255    /* size of the canonical input queue */
00170	#define MAX_INPUT        255    /* size of the type-ahead buffer */
00171	#define NAME_MAX          14    /* # chars in a file name */
00172	#define PATH_MAX         255    /* # chars in a path name */
00173	#define PIPE_BUF        7168    /* # bytes in atomic write to a pipe */
00174	#define STREAM_MAX        20    /* must be the same as FOPEN_MAX in stdio.h */
00175	#define TZNAME_MAX         3    /* maximum bytes in a time zone name is 3 */
00176	#define SSIZE_MAX      32767    /* max defined byte count for read() */
00177	
00178	#endif /* _POSIX_SOURCE */
00179	
00180	#endif /* _LIMITS_H */

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
				include/errno.h	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

00200	/* The <errno.h> header defines the numbers of the various errors that can
00201	 * occur during program execution.  They are visible to user programs and 
00202	 * should be small positive integers.  However, they are also used within 
00203	 * MINIX, where they must be negative.  For example, the READ system call is 
00204	 * executed internally by calling do_read().  This function returns either a 
00205	 * (negative) error number or a (positive) number of bytes actually read.
00206	 *
00207	 * To solve the problem of having the error numbers be negative inside the
00208	 * the system and positive outside, the following mechanism is used.  All the
00209	 * definitions are are the form:
00210	 *
00211	 *      #define EPERM           (_SIGN 1)
00212	 *
00213	 * If the macro _SYSTEM is defined, then  _SIGN is set to "-", otherwise it is
00214	 * set to "".  Thus when compiling the operating system, the  macro _SYSTEM
00215	 * will be defined, setting EPERM to (- 1), whereas when when this
00216	 * file is included in an ordinary user program, EPERM has the value ( 1).
00217	 */
00218	
00219	#ifndef _ERRNO_H                /* check if <errno.h> is already included */
00220	#define _ERRNO_H                /* it is not included; note that fact */
00221	
00222	/* Now define _SIGN as "" or "-" depending on _SYSTEM. */
00223	#ifdef _SYSTEM
00224	#   define _SIGN         -
00225	#   define OK            0
00226	#else
00227	#   define _SIGN         
00228	#endif
00229	
00230	extern int errno;                 /* place where the error numbers go */
00231	
00232	/* Here are the numerical values of the error numbers. */
00233	#define _NERROR               70  /* number of errors */  
00234	
00235	#define EGENERIC      (_SIGN 99)  /* generic error */
00236	#define EPERM         (_SIGN  1)  /* operation not permitted */
00237	#define ENOENT        (_SIGN  2)  /* no such file or directory */
00238	#define ESRCH         (_SIGN  3)  /* no such process */
00239	#define EINTR         (_SIGN  4)  /* interrupted function call */
00240	#define EIO           (_SIGN  5)  /* input/output error */
00241	#define ENXIO         (_SIGN  6)  /* no such device or address */
00242	#define E2BIG         (_SIGN  7)  /* arg list too long */
00243	#define ENOEXEC       (_SIGN  8)  /* exec format error */
00244	#define EBADF         (_SIGN  9)  /* bad file descriptor */
00245	#define ECHILD        (_SIGN 10)  /* no child process */
00246	#define EAGAIN        (_SIGN 11)  /* resource temporarily unavailable */
00247	#define ENOMEM        (_SIGN 12)  /* not enough space */
00248	#define EACCES        (_SIGN 13)  /* permission denied */
00249	#define EFAULT        (_SIGN 14)  /* bad address */
00250	#define ENOTBLK       (_SIGN 15)  /* Extension: not a block special file */
00251	#define EBUSY         (_SIGN 16)  /* resource busy */
00252	#define EEXIST        (_SIGN 17)  /* file exists */
00253	#define EXDEV         (_SIGN 18)  /* improper link */
00254	#define ENODEV        (_SIGN 19)  /* no such device */
00255	#define ENOTDIR       (_SIGN 20)  /* not a directory */
00256	#define EISDIR        (_SIGN 21)  /* is a directory */
00257	#define EINVAL        (_SIGN 22)  /* invalid argument */
00258	#define ENFILE        (_SIGN 23)  /* too many open files in system */
00259	#define EMFILE        (_SIGN 24)  /* too many open files */
00260	#define ENOTTY        (_SIGN 25)  /* inappropriate I/O control operation */
00261	#define ETXTBSY       (_SIGN 26)  /* no longer used */
00262	#define EFBIG         (_SIGN 27)  /* file too large */
00263	#define ENOSPC        (_SIGN 28)  /* no space left on device */
00264	#define ESPIPE        (_SIGN 29)  /* invalid seek */
00265	#define EROFS         (_SIGN 30)  /* read-only file system */
00266	#define EMLINK        (_SIGN 31)  /* too many links */
00267	#define EPIPE         (_SIGN 32)  /* broken pipe */
00268	#define EDOM          (_SIGN 33)  /* domain error       (from ANSI C std) */
00269	#define ERANGE        (_SIGN 34)  /* result too large   (from ANSI C std) */
00270	#define EDEADLK       (_SIGN 35)  /* resource deadlock avoided */
00271	#define ENAMETOOLONG  (_SIGN 36)  /* file name too long */
00272	#define ENOLCK        (_SIGN 37)  /* no locks available */
00273	#define ENOSYS        (_SIGN 38)  /* function not implemented */
00274	#define ENOTEMPTY     (_SIGN 39)  /* directory not empty */
00275	
00276	/* The following errors relate to networking. */
00277	#define EPACKSIZE     (_SIGN 50)  /* invalid packet size for some protocol */
00278	#define EOUTOFBUFS    (_SIGN 51)  /* not enough buffers left */
00279	#define EBADIOCTL     (_SIGN 52)  /* illegal ioctl for device */
00280	#define EBADMODE      (_SIGN 53)  /* badmode in ioctl */
00281	#define EWOULDBLOCK   (_SIGN 54)
00282	#define EBADDEST      (_SIGN 55)  /* not a valid destination address */
00283	#define EDSTNOTRCH    (_SIGN 56)  /* destination not reachable */
00284	#define EISCONN       (_SIGN 57)  /* all ready connected */
00285	#define EADDRINUSE    (_SIGN 58)  /* address in use */
00286	#define ECONNREFUSED  (_SIGN 59)  /* connection refused */
00287	#define ECONNRESET    (_SIGN 60)  /* connection reset */
00288	#define ETIMEDOUT     (_SIGN 61)  /* connection timed out */
00289	#define EURG          (_SIGN 62)  /* urgent data present */
00290	#define ENOURG        (_SIGN 63)  /* no urgent data present */
00291	#define ENOTCONN      (_SIGN 64)  /* no connection (yet or anymore) */
00292	#define ESHUTDOWN     (_SIGN 65)  /* a write call to a shutdown connection */
00293	#define ENOCONN       (_SIGN 66)  /* no such connection */
00294	
00295	/* The following are not POSIX errors, but they can still happen. */
00296	#define ELOCKED      (_SIGN 101)  /* can't send message */
00297	#define EBADCALL     (_SIGN 102)  /* error on send/receive */
00298	
00299	/* The following error codes are generated by the kernel itself. */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -