Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add header guards #207

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions asm.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef ASM_H_5FC4D1F4_CAAF_11EE_AA2B_90B11C0C0FF8
#define ASM_H_5FC4D1F4_CAAF_11EE_AA2B_90B11C0C0FF8
//
// assembler macros to create x86 segments
//
Expand All @@ -16,3 +18,4 @@
#define STA_X 0x8 // Executable segment
#define STA_W 0x2 // Writeable (non-executable segments)
#define STA_R 0x2 // Readable (executable segments)
#endif
3 changes: 3 additions & 0 deletions buf.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef BUF_H_5FB86900_CAAF_11EE_8313_90B11C0C0FF8
#define BUF_H_5FB86900_CAAF_11EE_8313_90B11C0C0FF8
struct buf {
int flags;
uint dev;
Expand All @@ -12,3 +14,4 @@ struct buf {
#define B_VALID 0x2 // buffer has been read from disk
#define B_DIRTY 0x4 // buffer needs to be written to disk

#endif
3 changes: 3 additions & 0 deletions date.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef DATE_H_5FBD64BE_CAAF_11EE_B4B1_90B11C0C0FF8
#define DATE_H_5FBD64BE_CAAF_11EE_B4B1_90B11C0C0FF8
struct rtcdate {
uint second;
uint minute;
Expand All @@ -6,3 +8,4 @@ struct rtcdate {
uint month;
uint year;
};
#endif
3 changes: 3 additions & 0 deletions defs.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef DEFS_H_5FCEEDA6_CAAF_11EE_B851_90B11C0C0FF8
#define DEFS_H_5FCEEDA6_CAAF_11EE_B851_90B11C0C0FF8
struct buf;
struct context;
struct file;
Expand Down Expand Up @@ -188,3 +190,4 @@ void clearpteu(pde_t *pgdir, char *uva);

// number of elements in fixed-size array
#define NELEM(x) (sizeof(x)/sizeof((x)[0]))
#endif
3 changes: 3 additions & 0 deletions elf.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef ELF_H_5FA195AE_CAAF_11EE_8AD1_90B11C0C0FF8
#define ELF_H_5FA195AE_CAAF_11EE_8AD1_90B11C0C0FF8
// Format of an ELF executable file

#define ELF_MAGIC 0x464C457FU // "\x7FELF" in little endian
Expand Down Expand Up @@ -40,3 +42,4 @@ struct proghdr {
#define ELF_PROG_FLAG_EXEC 1
#define ELF_PROG_FLAG_WRITE 2
#define ELF_PROG_FLAG_READ 4
#endif
3 changes: 3 additions & 0 deletions fcntl.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#ifndef FCNTL_H_5FB34556_CAAF_11EE_8D47_90B11C0C0FF8
#define FCNTL_H_5FB34556_CAAF_11EE_8D47_90B11C0C0FF8
#define O_RDONLY 0x000
#define O_WRONLY 0x001
#define O_RDWR 0x002
#define O_CREATE 0x200
#endif
3 changes: 3 additions & 0 deletions file.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef FILE_H_5FBFEB30_CAAF_11EE_B018_90B11C0C0FF8
#define FILE_H_5FBFEB30_CAAF_11EE_B018_90B11C0C0FF8
struct file {
enum { FD_NONE, FD_PIPE, FD_INODE } type;
int ref; // reference count
Expand Down Expand Up @@ -35,3 +37,4 @@ struct devsw {
extern struct devsw devsw[];

#define CONSOLE 1
#endif
3 changes: 3 additions & 0 deletions fs.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef FS_H_5FC27350_CAAF_11EE_8DCB_90B11C0C0FF8
#define FS_H_5FC27350_CAAF_11EE_8DCB_90B11C0C0FF8
// On-disk file system format.
// Both the kernel and user programs use this header file.

Expand Down Expand Up @@ -55,3 +57,4 @@ struct dirent {
char name[DIRSIZ];
};

#endif
3 changes: 3 additions & 0 deletions kbd.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef KBD_H_5FC7143C_CAAF_11EE_A572_90B11C0C0FF8
#define KBD_H_5FC7143C_CAAF_11EE_A572_90B11C0C0FF8
// PC keyboard interface constants

#define KBSTATP 0x64 // kbd controller status port(I)
Expand Down Expand Up @@ -110,3 +112,4 @@ static uchar ctlmap[256] =
[0xD2] KEY_INS, [0xD3] KEY_DEL
};

#endif
3 changes: 3 additions & 0 deletions memlayout.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef MEMLAYOUT_H_5FABE5CC_CAAF_11EE_9944_90B11C0C0FF8
#define MEMLAYOUT_H_5FABE5CC_CAAF_11EE_9944_90B11C0C0FF8
// Memory layout

#define EXTMEM 0x100000 // Start of extended memory
Expand All @@ -13,3 +15,4 @@

#define V2P_WO(x) ((x) - KERNBASE) // same as V2P, but without casts
#define P2V_WO(x) ((x) + KERNBASE) // same as P2V, but without casts
#endif
3 changes: 3 additions & 0 deletions mmu.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef MMU_H_5FCC4614_CAAF_11EE_B100_90B11C0C0FF8
#define MMU_H_5FCC4614_CAAF_11EE_B100_90B11C0C0FF8
// This file contains definitions for the
// x86 memory management unit (MMU).

Expand Down Expand Up @@ -179,3 +181,4 @@ struct gatedesc {
}

#endif
#endif
3 changes: 3 additions & 0 deletions mp.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef MP_H_5FA4371E_CAAF_11EE_9652_90B11C0C0FF8
#define MP_H_5FA4371E_CAAF_11EE_9652_90B11C0C0FF8
// See MultiProcessor Specification Version 1.[14]

struct mp { // floating pointer
Expand Down Expand Up @@ -54,3 +56,4 @@ struct mpioapic { // I/O APIC table entry

//PAGEBREAK!
// Blank page.
#endif
3 changes: 3 additions & 0 deletions param.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef PARAM_H_5FA945E2_CAAF_11EE_ADF4_90B11C0C0FF8
#define PARAM_H_5FA945E2_CAAF_11EE_ADF4_90B11C0C0FF8
#define NPROC 64 // maximum number of processes
#define KSTACKSIZE 4096 // size of per-process kernel stack
#define NCPU 8 // maximum number of CPUs
Expand All @@ -12,3 +14,4 @@
#define NBUF (MAXOPBLOCKS*3) // size of disk block cache
#define FSSIZE 1000 // size of file system in blocks

#endif
3 changes: 3 additions & 0 deletions proc.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef PROC_H_5FBAE11C_CAAF_11EE_B85B_90B11C0C0FF8
#define PROC_H_5FBAE11C_CAAF_11EE_B85B_90B11C0C0FF8
// Per-CPU state
struct cpu {
uchar apicid; // Local APIC ID
Expand Down Expand Up @@ -56,3 +58,4 @@ struct proc {
// original data and bss
// fixed-size stack
// expandable heap
#endif
3 changes: 3 additions & 0 deletions sleeplock.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef SLEEPLOCK_H_5FB5EE8C_CAAF_11EE_B022_90B11C0C0FF8
#define SLEEPLOCK_H_5FB5EE8C_CAAF_11EE_B022_90B11C0C0FF8
// Long-term locks for processes
struct sleeplock {
uint locked; // Is the lock held?
Expand All @@ -8,3 +10,4 @@ struct sleeplock {
int pid; // Process holding lock
};

#endif
3 changes: 3 additions & 0 deletions spinlock.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef SPINLOCK_H_5FAE6694_CAAF_11EE_AA29_90B11C0C0FF8
#define SPINLOCK_H_5FAE6694_CAAF_11EE_AA29_90B11C0C0FF8
// Mutual exclusion lock.
struct spinlock {
uint locked; // Is the lock held?
Expand All @@ -9,3 +11,4 @@ struct spinlock {
// that locked the lock.
};

#endif
3 changes: 3 additions & 0 deletions stat.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef STAT_H_5F9EF308_CAAF_11EE_9131_90B11C0C0FF8
#define STAT_H_5F9EF308_CAAF_11EE_9131_90B11C0C0FF8
#define T_DIR 1 // Directory
#define T_FILE 2 // File
#define T_DEV 3 // Device
Expand All @@ -9,3 +11,4 @@ struct stat {
short nlink; // Number of links to file
uint size; // Size of file in bytes
};
#endif
3 changes: 3 additions & 0 deletions syscall.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef SYSCALL_H_5FC98D3E_CAAF_11EE_81F6_90B11C0C0FF8
#define SYSCALL_H_5FC98D3E_CAAF_11EE_81F6_90B11C0C0FF8
// System call numbers
#define SYS_fork 1
#define SYS_exit 2
Expand All @@ -20,3 +22,4 @@
#define SYS_link 19
#define SYS_mkdir 20
#define SYS_close 21
#endif
3 changes: 3 additions & 0 deletions traps.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef TRAPS_H_5FD18188_CAAF_11EE_ADFC_90B11C0C0FF8
#define TRAPS_H_5FD18188_CAAF_11EE_ADFC_90B11C0C0FF8
// x86 trap and interrupt constants.

// Processor-defined:
Expand Down Expand Up @@ -36,3 +38,4 @@
#define IRQ_ERROR 19
#define IRQ_SPURIOUS 31

#endif
3 changes: 3 additions & 0 deletions types.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#ifndef TYPES_H_5FA6C7AE_CAAF_11EE_B06B_90B11C0C0FF8
#define TYPES_H_5FA6C7AE_CAAF_11EE_B06B_90B11C0C0FF8
typedef unsigned int uint;
typedef unsigned short ushort;
typedef unsigned char uchar;
typedef uint pde_t;
#endif
3 changes: 3 additions & 0 deletions user.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef USER_H_5FB0CF7E_CAAF_11EE_B782_90B11C0C0FF8
#define USER_H_5FB0CF7E_CAAF_11EE_B782_90B11C0C0FF8
struct stat;
struct rtcdate;

Expand Down Expand Up @@ -37,3 +39,4 @@ void* memset(void*, int, uint);
void* malloc(uint);
void free(void*);
int atoi(const char*);
#endif
3 changes: 3 additions & 0 deletions x86.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifndef X86_H_5F9C3CA8_CAAF_11EE_B26D_90B11C0C0FF8
#define X86_H_5F9C3CA8_CAAF_11EE_B26D_90B11C0C0FF8
// Routines to let C code use special x86 instructions.

static inline uchar
Expand Down Expand Up @@ -181,3 +183,4 @@ struct trapframe {
ushort ss;
ushort padding6;
};
#endif