Skip to content

Commit

Permalink
modify constructure
Browse files Browse the repository at this point in the history
  • Loading branch information
segzix committed Oct 9, 2024
1 parent 44b0d87 commit 5ef4503
Show file tree
Hide file tree
Showing 17 changed files with 1,312 additions and 1,155 deletions.
17 changes: 10 additions & 7 deletions lib/lib.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ CC = gcc
CCC = gcc
FC = gfortran # gfortran is more common

# define VPATH to search dependent file
VPATH = ./$(SRCDIR) ./$(UTILSDIR)

# define dirs
SRCDIR = ../../src
UTILSDIR = ../../src/utils
INCLUDEDIR = $(SRCDIR)/include
CFLAGS += -I./${INCLUDEDIR} $(ARCH_FLAGS) -DDOSTAT -g

# define files
SRCS := $(wildcard $(SRCDIR)/*.c)
SRCS += $(wildcard $(UTILSDIR)/*.c)
SRCS := $(wildcard $(SRCDIR)/*/*.c)
DIRS := $(filter-out %.h, $(wildcard $(SRCDIR)/*))
OBJS := $(patsubst %.c, %.o, $(foreach file, $(SRCS), $(notdir $(file))))

# define VPATH to search dependent file
VPATH = $(DIRS)

TARGET = libjia.a

# 暂时没有.d文件时通过这个依赖关系来进行第一次创建
Expand All @@ -33,14 +32,18 @@ TARGET = libjia.a
@$(SHELL) -ec "$(FC) -c -MM $< | sed 's/$*\.o/& $@/g' > $@"

$(TARGET):$(OBJS)
$(info srcs : $(OBJS))
ar rv $(TARGET) $?

all:$(TARGET)

clean:
rm -f *.[od] $(TARGET)

.PHONY: clean
debug:
$(info srcs : $(SRCS))

.PHONY: clean debug

# .d文件只通过显式规则来表明.o文件与.d文件的依赖项,并不提供重新构建的规则
# 如果需要进行重新构建,需要调用本makefile中的隐式规则
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
56 changes: 56 additions & 0 deletions src/include/mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,63 @@ typedef struct {
} jiapage_t;

/* Function Declaration */

/* server */
void diffserver(jia_msg_t *);
void getpserver(jia_msg_t *req);

/* mmsync */
int replacei(int cachei);
void savepage(int cachei);
void senddiffs();
void sigsegv_handler(int signo, siginfo_t *sip, void *context);

/* mem */
void memprotect(void *addr, size_t len, int prot);
void addwtvect(int homei, wtvect_t wv, int from);
void memmap(void *addr, size_t len, int prot);
void memunmap(void *addr, size_t len);

/**
* @brief s2l --
*
* @param str
* @return unsigned long
*/
static inline unsigned long
s2l(unsigned char *str) // TODO: unsigned long now is 8 bytes (we need to
// support both 32bit and 64bit machine)
{
union {
unsigned long l;
// unsigned char c[Intbytes];
unsigned char c[sizeof(unsigned char *)];
} notype;

notype.c[0] = str[0];
notype.c[1] = str[1];
notype.c[2] = str[2];
notype.c[3] = str[3];
notype.c[4] = str[4];
notype.c[5] = str[5];
notype.c[6] = str[6];
notype.c[7] = str[7];

return (notype.l);
}

/**
* @brief xor -- get the index of the first page of the set based on the addr,
* setnum group connection
*
* @param addr address of a byte in one page
* @return int - the first cache index of the page's corresponding setnum in
* the cache
*
*/
static inline int xor (address_t addr) {
return ((((unsigned long)(addr - Startaddr) / Pagesize) % Setnum) *
Setpages);
}

#endif /*JIAMEM_H*/
1 change: 1 addition & 0 deletions src/include/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ wtnt_t *newwtnt();
void newtwin(address_t *twin);
void freetwin(address_t *twin);
void emptyprintf();
unsigned int get_usecs();

#endif /* TOOLS_H */
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 5ef4503

Please sign in to comment.