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

c++-only header files

上级 21d8da79
...@@ -26,9 +26,9 @@ extern "C" { ...@@ -26,9 +26,9 @@ extern "C" {
#include "kernel.h" #include "kernel.h"
#include "spinlock.h" #include "spinlock.h"
#include "condvar.h" #include "condvar.h"
#include "buf.h"
} }
#include "buf.hh"
#include "cpputil.hh" #include "cpputil.hh"
#include "ns.hh" #include "ns.hh"
......
...@@ -11,7 +11,7 @@ extern "C" { ...@@ -11,7 +11,7 @@ extern "C" {
#include "condvar.h" #include "condvar.h"
} }
#include "file.h" #include "file.hh"
extern "C" { extern "C" {
#include "amd64.h" #include "amd64.h"
......
...@@ -11,7 +11,7 @@ extern "C" { ...@@ -11,7 +11,7 @@ extern "C" {
#include "fs.h" #include "fs.h"
} }
#include "file.h" #include "file.hh"
extern "C" { extern "C" {
#include "elf.h" #include "elf.h"
......
...@@ -6,7 +6,7 @@ extern "C" { ...@@ -6,7 +6,7 @@ extern "C" {
#include "fs.h" #include "fs.h"
} }
#include "file.h" #include "file.hh"
extern "C" { extern "C" {
#include "stat.h" #include "stat.h"
......
#ifdef __cplusplus
#include "cpputil.hh" #include "cpputil.hh"
#include "ns.hh" #include "ns.hh"
u64 namehash(const strbuf<DIRSIZ>&); u64 namehash(const strbuf<DIRSIZ>&);
#endif
struct file { struct file {
enum { FD_NONE, FD_PIPE, FD_INODE, FD_SOCKET } type; enum { FD_NONE, FD_PIPE, FD_INODE, FD_SOCKET } type;
...@@ -30,11 +28,7 @@ struct inode { ...@@ -30,11 +28,7 @@ struct inode {
struct condvar cv; struct condvar cv;
struct spinlock lock; struct spinlock lock;
char lockname[16]; char lockname[16];
#ifdef __cplusplus
xns<strbuf<DIRSIZ>, u32, namehash> *dir; xns<strbuf<DIRSIZ>, u32, namehash> *dir;
#else
void *dir;
#endif
short type; // copy of disk inode short type; // copy of disk inode
short major; short major;
......
...@@ -19,11 +19,11 @@ extern "C" { ...@@ -19,11 +19,11 @@ extern "C" {
#include "condvar.h" #include "condvar.h"
#include "queue.h" #include "queue.h"
#include "proc.h" #include "proc.h"
#include "buf.h"
#include "fs.h" #include "fs.h"
} }
#include "file.h" #include "buf.hh"
#include "file.hh"
extern "C" { extern "C" {
#include "cpu.h" #include "cpu.h"
......
extern "C" {
#include "types.h" #include "types.h"
#include "kernel.h" #include "kernel.h"
#include "spinlock.h" #include "spinlock.h"
...@@ -6,16 +7,18 @@ ...@@ -6,16 +7,18 @@
#include "proc.h" #include "proc.h"
#include "vm.h" #include "vm.h"
#include "fs.h" #include "fs.h"
#include "file.h"
#include "wq.h" #include "wq.h"
#include "ipc.h" #include "ipc.h"
}
#include "file.hh"
static void static void
pread_work(struct work *w, void *a0, void *a1, void *a2, void *a3) pread_work(struct work *w, void *a0, void *a1, void *a2, void *a3)
{ {
struct inode *ip = a0; struct inode *ip = (inode*) a0;
void *kshared = a1; void *kshared = (void*) a1;
struct ipcctl *ipc = kshared; struct ipcctl *ipc = (ipcctl*) kshared;
size_t count = (uptr)a2; size_t count = (uptr)a2;
off_t off = (uptr)a3; off_t off = (uptr)a3;
int r; int r;
...@@ -26,7 +29,7 @@ pread_work(struct work *w, void *a0, void *a1, void *a2, void *a3) ...@@ -26,7 +29,7 @@ pread_work(struct work *w, void *a0, void *a1, void *a2, void *a3)
//cprintf("1: %p %p %lu %lu\n", ip, buf, count, off); //cprintf("1: %p %p %lu %lu\n", ip, buf, count, off);
ilock(ip, 0); ilock(ip, 0);
r = readi(ip, kshared+PGSIZE, off, count); r = readi(ip, ((char*)kshared)+PGSIZE, off, count);
iunlock(ip); iunlock(ip);
ipc->result = r; ipc->result = r;
...@@ -41,11 +44,11 @@ pread_allocwork(struct inode *ip, void *buf, size_t count, off_t off) ...@@ -41,11 +44,11 @@ pread_allocwork(struct inode *ip, void *buf, size_t count, off_t off)
{ {
struct work *w = allocwork(); struct work *w = allocwork();
if (w == NULL) if (w == NULL)
return NULL; return 0;
//cprintf("0: %p %p %lu %lu\n", ip, buf, count, off); //cprintf("0: %p %p %lu %lu\n", ip, buf, count, off);
w->rip = pread_work; w->rip = (void*) pread_work;
w->arg0 = ip; w->arg0 = ip;
w->arg1 = buf; w->arg1 = buf;
w->arg2 = (void*)count; w->arg2 = (void*)count;
...@@ -63,7 +66,7 @@ sys_kernlet(int fd, size_t count, off_t off) ...@@ -63,7 +66,7 @@ sys_kernlet(int fd, size_t count, off_t off)
if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0) if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0)
return -1; return -1;
if(f->type != FD_INODE) if(f->type != file::FD_INODE)
return -1; return -1;
fetchadd(&f->ip->ref, 1); fetchadd(&f->ip->ref, 1);
......
...@@ -11,9 +11,10 @@ extern "C" { ...@@ -11,9 +11,10 @@ extern "C" {
#include "proc.h" #include "proc.h"
#include "amd64.h" #include "amd64.h"
#include "traps.h" #include "traps.h"
#include "buf.h"
} }
#include "buf.hh"
extern u8 _fs_img_start[]; extern u8 _fs_img_start[];
extern u64 _fs_img_size; extern u64 _fs_img_size;
......
...@@ -22,7 +22,7 @@ extern "C" { ...@@ -22,7 +22,7 @@ extern "C" {
#include "fs.h" #include "fs.h"
} }
#include "file.h" #include "file.hh"
extern "C" { extern "C" {
#include "net.h" #include "net.h"
......
...@@ -9,7 +9,7 @@ extern "C" { ...@@ -9,7 +9,7 @@ extern "C" {
#include "fs.h" #include "fs.h"
} }
#include "file.h" #include "file.hh"
extern "C" { extern "C" {
#include "cpu.h" #include "cpu.h"
......
...@@ -6,7 +6,7 @@ extern "C" { ...@@ -6,7 +6,7 @@ extern "C" {
#include "fs.h" #include "fs.h"
} }
#include "file.h" #include "file.hh"
extern "C" { extern "C" {
#include "prof.h" #include "prof.h"
......
...@@ -6,7 +6,7 @@ extern "C" { ...@@ -6,7 +6,7 @@ extern "C" {
#include "kernel.h" #include "kernel.h"
} }
#include "file.h" #include "file.hh"
extern "C" { extern "C" {
#include "bits.h" #include "bits.h"
......
...@@ -12,7 +12,7 @@ extern "C" { ...@@ -12,7 +12,7 @@ extern "C" {
#include "fs.h" #include "fs.h"
} }
#include "file.h" #include "file.hh"
#if LOCKSTAT #if LOCKSTAT
static int lockstat_enable; static int lockstat_enable;
......
...@@ -10,7 +10,7 @@ extern "C" { ...@@ -10,7 +10,7 @@ extern "C" {
#include "fs.h" #include "fs.h"
} }
#include "file.h" #include "file.hh"
extern "C" { extern "C" {
#include "fcntl.h" #include "fcntl.h"
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论