Skip to content

Commit

Permalink
refactor: mark functions as static
Browse files Browse the repository at this point in the history
Signed-off-by: thehxdev <hossein.khosravi.ce@gmail.com>
  • Loading branch information
thehxdev committed Nov 21, 2024
1 parent 60fc18b commit 657bfd8
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ HANDLE hStdin = INVALID_HANDLE_VALUE;
DWORD fdwMode, fdwOldMode;
#endif

void disable_input_buffering() {
static void disable_input_buffering(void) {
#ifdef LC3_PLAT_UNIX
tcgetattr(STDIN_FILENO, &original_tio);
struct termios new_tio = original_tio;
Expand All @@ -110,15 +110,15 @@ void disable_input_buffering() {
#endif
}

void restore_input_buffering() {
static void restore_input_buffering(void) {
#ifdef LC3_PLAT_UNIX
tcsetattr(STDIN_FILENO, TCSANOW, &original_tio);
#else
SetConsoleMode(hStdin, fdwOldMode);
#endif
}

uint16_t check_key() {
static uint16_t check_key(void) {
#ifdef LC3_PLAT_UNIX
fd_set readfds;
FD_ZERO(&readfds);
Expand All @@ -133,7 +133,7 @@ uint16_t check_key() {
#endif
}

uint16_t mem_read(uint16_t addr) {
static uint16_t mem_read(uint16_t addr) {
if (addr == MR_KBSR) {
if (check_key()) {
memory[MR_KBSR] = (1 << 15);
Expand All @@ -145,18 +145,18 @@ uint16_t mem_read(uint16_t addr) {
return memory[addr];
}

void mem_write(uint16_t addr, uint16_t value) {
static void mem_write(uint16_t addr, uint16_t value) {
memory[addr] = value;
}

uint16_t sign_extend(uint16_t num, int bit_count) {
static uint16_t sign_extend(uint16_t num, int bit_count) {
if ((num >> (bit_count-1)) & 0x1) {
num |= (0xffff << bit_count);
}
return num;
}

void update_flags(uint16_t r) {
static void update_flags(uint16_t r) {
if (reg[r] == 0)
reg[R_COND] = FL_ZRO;
else if (reg[r] >> 15)
Expand All @@ -165,11 +165,11 @@ void update_flags(uint16_t r) {
reg[R_COND] = FL_POS;
}

uint16_t swap16(uint16_t x) {
static uint16_t swap16(uint16_t x) {
return ((x << 8) | (x >> 8));
}

void read_image_file(FILE *fp) {
static void read_image_file(FILE *fp) {
uint16_t origin;
fread(&origin, sizeof(origin), 1, fp);
origin = swap16(origin);
Expand All @@ -185,7 +185,7 @@ void read_image_file(FILE *fp) {
}
}

int read_image(const char path[]) {
static int read_image(const char path[]) {
FILE *fp = fopen(path, "rb");
if (!fp)
return 0;
Expand All @@ -194,11 +194,11 @@ int read_image(const char path[]) {
return 1;
}

void shutdown() {
static void shutdown(void) {
restore_input_buffering();
}

void handle_interrupt(int signal) {
static void handle_interrupt(int signal) {
(void)signal;

shutdown();
Expand Down

0 comments on commit 657bfd8

Please sign in to comment.