forked from mit-pdos/xv6-public
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
5,399 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,6 @@ | |
|
||
#define N 1000 | ||
|
||
void | ||
printf(int fd, char *s, ...) | ||
{ | ||
write(fd, s, strlen(s)); | ||
} | ||
|
||
void | ||
forktest(void) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef _CTYPE_H_ | ||
#define _CTYPE_H_ | ||
|
||
int iscntrl(int c); | ||
int isprint(int c); | ||
int isspace(int c); | ||
int isblank(int c); | ||
int isgraph(int c); | ||
int ispunct(int c); | ||
int isalnum(int c); | ||
int isalpha(int c); | ||
int isupper(int c); | ||
int islower(int c); | ||
int isdigit(int c); | ||
int isxdigit(int c); | ||
int toupper(int c); | ||
int tolower(int c); | ||
|
||
#endif /* !_CTYPE_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef _MACHINE_FLOAT_H_ | ||
#define _MACHINE_FLOAT_H_ 1 | ||
|
||
#define FLT_RADIX 2 /* b */ | ||
#define FLT_ROUNDS 1 /* FP addition rounds to nearest */ | ||
|
||
#define FLT_MANT_DIG 24 /* p */ | ||
#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ | ||
#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */ | ||
#define FLT_MIN_EXP (-125) /* emin */ | ||
#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */ | ||
#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */ | ||
#define FLT_MAX_EXP 128 /* emax */ | ||
#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */ | ||
#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */ | ||
|
||
#define DBL_MANT_DIG 53 | ||
#define DBL_EPSILON 2.2204460492503131E-16 | ||
#define DBL_DIG 15 | ||
#define DBL_MIN_EXP (-1021) | ||
#define DBL_MIN 2.2250738585072014E-308 | ||
#define DBL_MIN_10_EXP (-307) | ||
#define DBL_MAX_EXP 1024 | ||
#define DBL_MAX 1.7976931348623157E+308 | ||
#define DBL_MAX_10_EXP 308 | ||
|
||
#define LDBL_MANT_DIG DBL_MANT_DIG | ||
#define LDBL_EPSILON DBL_EPSILON | ||
#define LDBL_DIG DBL_DIG | ||
#define LDBL_MIN_EXP DBL_MIN_EXP | ||
#define LDBL_MIN DBL_MIN | ||
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP | ||
#define LDBL_MAX_EXP DBL_MAX_EXP | ||
#define LDBL_MAX DBL_MAX | ||
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP | ||
#endif /* _MACHINE_FLOAT_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// | ||
// Created by freeman on 17-6-16. | ||
// | ||
|
||
#ifndef LIMITS_H | ||
#define LIMITS_H | ||
|
||
#define _POSIX_ARG_MAX 4096 | ||
#define _POSIX_CHILD_MAX 6 | ||
#define _POSIX_LINK_MAX 8 | ||
#define _POSIX_MAX_CANON 255 | ||
#define _POSIX_MAX_INPUT 255 | ||
#define _POSIX_NAME_MAX 14 | ||
#define _POSIX_NGROUPS_MAX 0 | ||
#define _POSIX_OPEN_MAX 16 | ||
#define _POSIX_PATH_MAX 255 | ||
#define _POSIX_PIPE_BUF 512 | ||
|
||
#define _POSIX2_BC_BASE_MAX 99 | ||
#define _POSIX2_BC_DIM_MAX 2048 | ||
#define _POSIX2_BC_SCALE_MAX 99 | ||
#define _POSIX2_BC_STRING_MAX 1000 | ||
#define _POSIX2_EQUIV_CLASS_MAX 2 | ||
#define _POSIX2_EXPR_NEST_MAX 32 | ||
#define _POSIX2_LINE_MAX 2048 | ||
#define _POSIX2_RE_DUP_MAX 255 | ||
|
||
#define CHAR_BIT 8 /* number of bits in a char */ | ||
#define MB_LEN_MAX 6 /* allow 21-bit UTF2 */ | ||
|
||
#define SCHAR_MIN (-0x7f-1) /* max value for a signed char */ | ||
#define SCHAR_MAX 0x7f /* min value for a signed char */ | ||
|
||
#define UCHAR_MAX 0xff /* max value for an unsigned char */ | ||
#define CHAR_MAX 0x7f /* max value for a char */ | ||
#define CHAR_MIN (-0x7f-1) /* min value for a char */ | ||
|
||
#define USHRT_MAX 0xffff /* max value for an unsigned short */ | ||
#define SHRT_MAX 0x7fff /* max value for a short */ | ||
#define SHRT_MIN (-0x7fff-1) /* min value for a short */ | ||
|
||
#define UINT_MAX 0xffffffff /* max value for an unsigned int */ | ||
#define INT_MAX 0x7fffffff /* max value for an int */ | ||
#define INT_MIN (-0x7fffffff-1) /* min value for an int */ | ||
|
||
#define ULONG_MAX 0xffffffff /* max value for an unsigned long */ | ||
#define LONG_MAX 0x7fffffff /* max value for a long */ | ||
#define LONG_MIN (-0x7fffffff-1) /* min value for a long */ | ||
|
||
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) | ||
#define CLK_TCK 128 /* ticks per second */ | ||
#define UQUAD_MAX 0xffffffffffffffffLL /* max unsigned quad */ | ||
#define QUAD_MAX 0x7fffffffffffffffLL /* max signed quad */ | ||
#define QUAD_MIN (-0x7fffffffffffffffLL-1) /* min signed quad */ | ||
|
||
#define ARG_MAX 20480 /* max bytes for an exec function */ | ||
#define CHILD_MAX 40 /* max simultaneous processes */ | ||
#define LINK_MAX 32767 /* max file link count */ | ||
#define MAX_CANON 255 /* max bytes in terminal canonical input line */ | ||
#define MAX_INPUT 255 /* max bytes in terminal input */ | ||
#define NAME_MAX 255 /* max number of bytes in a file name */ | ||
#define NGROUPS_MAX 16 /* max number of supplemental group id's */ | ||
#define OPEN_MAX 64 /* max open files per process */ | ||
#define PATH_MAX 1024 /* max number of bytes in pathname */ | ||
#define PIPE_BUF 512 /* max number of bytes for atomic pipe writes */ | ||
|
||
#define BC_BASE_MAX 99 /* max ibase/obase values allowed by bc(1) */ | ||
#define BC_DIM_MAX 2048 /* max array elements allowed by bc(1) */ | ||
#define BC_SCALE_MAX 99 /* max scale value allowed by bc(1) */ | ||
#define BC_STRING_MAX 1000 /* max const string length allowed by bc(1) */ | ||
#define EQUIV_CLASS_MAX 2 /* max weights for order keyword; see locale */ | ||
#define EXPR_NEST_MAX 32 /* max expressions nested in expr(1) */ | ||
#define LINE_MAX 2048 /* max length in bytes of an input line */ | ||
#define RE_DUP_MAX 255 /* max repeated RE's using interval notation */ | ||
|
||
#endif | ||
|
||
#endif //LIMITS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef MATH_H | ||
#define MATH_H | ||
|
||
int isnan(double d); | ||
int isinf(double d); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef SETJMP_H | ||
#define SETJMP_H | ||
|
||
typedef int jmp_buf[10]; | ||
|
||
int setjmp(jmp_buf); | ||
void longjmp(jmp_buf, int); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef STDARG_H | ||
#define STDARG_H | ||
|
||
typedef char *va_list; | ||
#define va_arg(ap, type) ((type *)(ap += sizeof(type)))[-1] | ||
#define va_end(ap) | ||
#define __va_promote(type) (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) | ||
#define va_start(ap, last) (ap = ((char *)&(last) + __va_promote(last))) | ||
|
||
typedef unsigned char u_char; | ||
typedef unsigned long u_long; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef STDDEF_H | ||
#define STDDEF_H | ||
|
||
typedef int ptrdiff_t; | ||
typedef unsigned int size_t; | ||
|
||
#ifndef NULL | ||
#define NULL 0 | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef STDINT_H | ||
#define STDINT_H | ||
|
||
typedef signed char int8_t; | ||
typedef short int16_t; | ||
typedef int int32_t; | ||
|
||
typedef unsigned char uint8_t; | ||
typedef unsigned short uint16_t; | ||
typedef unsigned int uint32_t; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#ifndef STDIO_H | ||
#define STDIO_H | ||
|
||
#ifndef EOF | ||
#define EOF (-1) | ||
#endif | ||
|
||
#define __SRD 0x0004 /* OK to read */ | ||
#define __SWR 0x0008 /* OK to write */ | ||
/* RD and WR are never simultaneously asserted */ | ||
#define __SRW 0x0010 /* open for reading & writing */ | ||
#define BUFSIZ 1024 | ||
|
||
typedef struct { | ||
int fd; | ||
int buffer_size; | ||
int buffer_end; | ||
int cur; | ||
int reserve; | ||
char *buffer; | ||
short flags; | ||
} FILE; | ||
|
||
extern FILE _std_files[]; | ||
#define stdin (&_std_files[0]) | ||
#define stdout (&_std_files[1]) | ||
#define stderr (&_std_files[2]) | ||
#define __sgetc(p) __srget(p) | ||
int __srget (FILE *); | ||
int __sputc (int _c, FILE *_p); | ||
|
||
|
||
|
||
#define putc(x, fp) __sputc(x, fp) | ||
#define fputc(x, fp) __sputc(x, fp) | ||
|
||
#define getchar() getc(stdin) | ||
|
||
#define putchar(x) putc(x, stdout) | ||
|
||
#define getc(fp) __sgetc(fp) | ||
#define fgetc(fp) __sgetc(fp) | ||
|
||
int myprintf(char const *fmt, ...); | ||
int fprintf(FILE *fp, const char *fmt, ...); | ||
int puts(char const *s); | ||
int fputs(const char *s, FILE *fp); | ||
char *mygets(char *buf); | ||
char *fgets(char *buf, int max, FILE *fp); | ||
FILE *fopen(const char *file, const char *mode); | ||
int fclose(FILE *fp); | ||
int ungetc(int ch, FILE *stream); | ||
int scanf(const char *, ...); | ||
int fscanf(FILE *fp, char *fmt, ...); | ||
|
||
double strtod(const char *s00, char **se); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef STDLIB_H | ||
#define STDLIB_H | ||
|
||
#include <stddef.h> | ||
|
||
void* malloc(unsigned int); | ||
void free(void*); | ||
int abs(int); | ||
|
||
#define RAND_MAX 0x7fffffff | ||
|
||
void srand(unsigned); | ||
int rand(); | ||
|
||
void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); | ||
void abort(); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef STRING_H | ||
#define STRING_H | ||
|
||
#include <stddef.h> | ||
|
||
unsigned int strlen(const char *str); | ||
char * strchr(register const char *p, register const char ch); | ||
char *strrchr(register const char *p, register const char *ch); | ||
char *strcat(register char *s, register const char *append); | ||
char *strncat(char *dst, const char *src, register unsigned int n); | ||
int strcmp(register const char *s1, register const char *s2); | ||
int strncmp(register const char *s1, register const char *s2, register unsigned int n); | ||
char* strcpy(register char *to, register const char *from); | ||
char *strncpy(char *dst, const char *src, register unsigned int n); | ||
char *strstr(register const char *s, register const char *find); | ||
void *memcpy(void *dst0, const void *src0, register unsigned int length); | ||
void *memmove(void *vdst, const void *vsrc, register unsigned int n); | ||
void *memccpy(void *t, const void *f, int c, register unsigned int n); | ||
void *memchr(const void *s, register unsigned char c, register unsigned int n); | ||
int memcmp(const void *s1, const void *s2, unsigned int n); | ||
void* memset(void*, int, unsigned int); | ||
|
||
#endif |
Oops, something went wrong.