提交 9bbaf1df 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

all c++ userspace except for system calls and lwip

上级 bfea5822
...@@ -26,7 +26,7 @@ COMFLAGS := -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall \ ...@@ -26,7 +26,7 @@ COMFLAGS := -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall \
-DHW_$(HW) -include param.h -include compiler.h -DHW_$(HW) -include param.h -include compiler.h
COMFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector) COMFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
CFLAGS := $(COMFLAGS) -std=c99 CFLAGS := $(COMFLAGS) -std=c99
CXXFLAGS := $(COMFLAGS) -std=c++0x CXXFLAGS := $(COMFLAGS) -std=c++0x -Wno-sign-compare
ASFLAGS = -m64 -gdwarf-2 -MD ASFLAGS = -m64 -gdwarf-2 -MD
LDFLAGS += -m elf_x86_64 LDFLAGS += -m elf_x86_64
......
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
}
char buf[512]; char buf[512];
......
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "mtrace.h" #include "mtrace.h"
#include "amd64.h" #include "amd64.h"
#include "fcntl.h" #include "fcntl.h"
}
enum { nthread = 2 }; enum { nthread = 2 };
enum { nloop = 100 }; enum { nloop = 100 };
......
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
}
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
......
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "mtrace.h" #include "mtrace.h"
#include "amd64.h" #include "amd64.h"
}
#define NITERS 16 #define NITERS 16
......
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "mtrace.h" #include "mtrace.h"
}
#define NCHILD 2 #define NCHILD 2
#define NDEPTH 7 #define NDEPTH 7
......
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "mtrace.h" #include "mtrace.h"
}
#define NCHILD 2 #define NCHILD 2
#define NDEPTH 5 #define NDEPTH 5
......
extern "C" {
#include "types.h" #include "types.h"
#include "user.h" #include "user.h"
#include "lib.h" #include "lib.h"
#include "unet.h" #include "unet.h"
#include "fcntl.h" #include "fcntl.h"
#include "stat.h" #include "stat.h"
}
#define VERSION "0.1" #define VERSION "0.1"
#define HTTP_VERSION "1.0" #define HTTP_VERSION "1.0"
......
// init: The initial user-level program // init: The initial user-level program
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "fcntl.h" #include "fcntl.h"
#include "lib.h" #include "lib.h"
}
static const char *sh_argv[] = { "sh", 0 }; static const char *sh_argv[] = { "sh", 0 };
static const char *app_argv[][MAXARG] = { static const char *app_argv[][MAXARG] = {
......
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "fcntl.h" #include "fcntl.h"
#include "amd64.h" #include "amd64.h"
#include "lockstat.h" #include "lockstat.h"
}
static void static void
xwrite(int fd, char c) xwrite(int fd, char c)
......
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "fs.h" #include "fs.h"
}
const char* const char*
fmtname(const char *path) fmtname(const char *path)
......
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "mtrace.h" #include "mtrace.h"
#include "amd64.h" #include "amd64.h"
#include "uspinlock.h" #include "uspinlock.h"
}
static struct uspinlock l; static struct uspinlock l;
static volatile int tcount; static volatile int tcount;
......
...@@ -55,7 +55,7 @@ main(void) ...@@ -55,7 +55,7 @@ main(void)
} }
sbrk(4096); sbrk(4096);
forkt(sbrk(0), thr, 0); forkt(sbrk(0), (void*) thr, 0);
acquire(&l); acquire(&l);
state = 1; state = 1;
......
...@@ -37,7 +37,7 @@ void ...@@ -37,7 +37,7 @@ void
vprintfmt(void (*putch) (void*, char), void *putarg, vprintfmt(void (*putch) (void*, char), void *putarg,
const char *fmt, va_list ap) const char *fmt, va_list ap)
{ {
char *s; const char *s;
int c, i, state; int c, i, state;
state = 0; state = 0;
...@@ -58,7 +58,7 @@ vprintfmt(void (*putch) (void*, char), void *putarg, ...@@ -58,7 +58,7 @@ vprintfmt(void (*putch) (void*, char), void *putarg,
state = 'l'; state = 'l';
continue; continue;
} else if(c == 's'){ } else if(c == 's'){
s = (char*) va_arg(ap, char*); s = (const char*) va_arg(ap, const char*);
if(s == 0) if(s == 0)
s = "(null)"; s = "(null)";
while(*s != 0){ while(*s != 0){
...@@ -119,7 +119,7 @@ struct bufstate { ...@@ -119,7 +119,7 @@ struct bufstate {
static void static void
writebuf(void *arg, char c) writebuf(void *arg, char c)
{ {
struct bufstate *bs = arg; struct bufstate *bs = (bufstate*) arg;
if (bs->p < bs->e) { if (bs->p < bs->e) {
bs->p[0] = c; bs->p[0] = c;
bs->p++; bs->p++;
......
// Shell. // Shell.
extern "C" {
#include "types.h" #include "types.h"
#include "user.h" #include "user.h"
#include "fcntl.h" #include "fcntl.h"
}
// Parsed command representation // Parsed command representation
#define EXEC 1 #define EXEC 1
......
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "fcntl.h" #include "fcntl.h"
#include "amd64.h" #include "amd64.h"
}
int int
main(int ac, char *av[]) main(int ac, char *av[])
......
extern "C" {
#include "types.h" #include "types.h"
#include "user.h" #include "user.h"
#include "unet.h" #include "unet.h"
}
int int
main(void) main(void)
......
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "mtrace.h" #include "mtrace.h"
#include "amd64.h" #include "amd64.h"
#include "uspinlock.h" #include "uspinlock.h"
}
static struct uspinlock l; static struct uspinlock l;
static volatile int tcount; static volatile int tcount;
......
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
#include "fcntl.h" #include "fcntl.h"
#include "amd64.h" #include "amd64.h"
}
int int
main(int ac, const char *av[]) main(int ac, const char *av[])
......
...@@ -124,8 +124,8 @@ memmove(void *vdst, const void *vsrc, int n) ...@@ -124,8 +124,8 @@ memmove(void *vdst, const void *vsrc, int n)
const char *src; const char *src;
char *dst; char *dst;
dst = vdst; dst = (char*) vdst;
src = vsrc; src = (const char*) vsrc;
while(n-- > 0) while(n-- > 0)
*dst++ = *src++; *dst++ = *src++;
return vdst; return vdst;
......
#ifdef LWIP #ifdef LWIP
extern "C" {
#include "lwip/sockets.h" #include "lwip/sockets.h"
// system calls // system calls
...@@ -7,6 +8,7 @@ extern int bind(int sockfd, const struct sockaddr *addr, ...@@ -7,6 +8,7 @@ extern int bind(int sockfd, const struct sockaddr *addr,
socklen_t addrlen); socklen_t addrlen);
extern int listen(int sockfd, int backlog); extern int listen(int sockfd, int backlog);
extern int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); extern int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
}
static inline const char * static inline const char *
ipaddr(struct sockaddr_in *sin) ipaddr(struct sockaddr_in *sin)
......
struct stat; struct stat;
// system calls // system calls
extern "C" {
int fork(int); int fork(int);
int exit(void) __attribute__((noreturn)); int exit(void) __attribute__((noreturn));
int wait(void); int wait(void);
...@@ -25,6 +26,7 @@ int uptime(void); ...@@ -25,6 +26,7 @@ int uptime(void);
int map(void *addr, int len); int map(void *addr, int len);
int unmap(void *addr, int len); int unmap(void *addr, int len);
void halt(void); void halt(void);
}
// ulib.c // ulib.c
int stat(char*, struct stat*); int stat(char*, struct stat*);
...@@ -42,7 +44,9 @@ void free(void*); ...@@ -42,7 +44,9 @@ void free(void*);
int atoi(const char*); int atoi(const char*);
// uthread.S // uthread.S
extern "C" {
int forkt(void *sp, void *pc, void *arg); int forkt(void *sp, void *pc, void *arg);
}
// printf.c // printf.c
void printf(int, const char*, ...); void printf(int, const char*, ...);
......
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
...@@ -6,7 +5,6 @@ extern "C" { ...@@ -6,7 +5,6 @@ extern "C" {
#include "fcntl.h" #include "fcntl.h"
#include "syscall.h" #include "syscall.h"
#include "traps.h" #include "traps.h"
}
char buf[2048]; char buf[2048];
char name[3]; char name[3];
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论