Skip to content

Commit 88c4271

Browse files
Merge pull request #34 from Qwinci/release-fixes
Fixes for building in release mode
2 parents 4ecd6af + a48a341 commit 88c4271

File tree

5 files changed

+22
-15
lines changed

5 files changed

+22
-15
lines changed

asm/boot.asm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ extern enable_sse
99

1010
; Entry point for the BSP.
1111
boot_bsp:
12+
push 0
1213
call enable_fpu
1314
call enable_sse
1415
mov rax, kmain

src/basic/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,12 @@ void library_statement(struct basic_ctx* ctx)
292292

293293
/* Load the library file from VFS */
294294
size_t library_len = file_info->size;
295-
char* temp_library = kmalloc(library_len);
295+
char* temp_library = kmalloc(library_len + 1);
296296
if (!temp_library) {
297297
tokenizer_error_print(ctx, "Not enough memory to load library file");
298298
return;
299299
}
300-
char* clean_library = kmalloc(library_len);
300+
char* clean_library = kmalloc(library_len + 1);
301301
if (!clean_library) {
302302
kfree_null(&temp_library);
303303
tokenizer_error_print(ctx, "Not enough memory to load library file");

src/memcpy.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,29 @@ void* memset(void* dest, char val, uint64_t len)
99

1010
static inline void* movsb(void* dst, const void* src, size_t size)
1111
{
12-
__asm__ volatile("rep movsb" : "+D"(dst), "+S"(src), "+c"(size) : : "memory");
12+
void *copy = dst;
13+
__asm__ volatile("rep movsb" : "+D"(copy), "+S"(src), "+c"(size) : : "memory");
1314
return dst;
1415
}
1516

1617
static inline void* movsl(void* dst, const void* src, size_t size)
1718
{
18-
__asm__ volatile("rep movsl" : "+D"(dst), "+S"(src), "+c"(size) : : "memory");
19+
void *copy = dst;
20+
__asm__ volatile("rep movsl" : "+D"(copy), "+S"(src), "+c"(size) : : "memory");
1921
return dst;
2022
}
2123

2224
static inline void* movsw(void* dst, const void* src, size_t size)
2325
{
24-
__asm__ volatile("rep movsw" : "+D"(dst), "+S"(src), "+c"(size) : : "memory");
26+
void *copy = dst;
27+
__asm__ volatile("rep movsw" : "+D"(copy), "+S"(src), "+c"(size) : : "memory");
2528
return dst;
2629
}
2730

2831
static inline void* movsq(void* dst, const void* src, size_t size)
2932
{
30-
__asm__ volatile("rep movsq" : "+D"(dst), "+S"(src), "+c"(size) : : "memory");
33+
void *copy = dst;
34+
__asm__ volatile("rep movsq" : "+D"(copy), "+S"(src), "+c"(size) : : "memory");
3135
return dst;
3236
}
3337

src/string.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ char* strdup(const char* string)
234234
if (!string) {
235235
return NULL;
236236
}
237-
uint32_t len = strlen(string) + 1;
238-
char* result = kmalloc(len);
239-
strlcpy(result, string, len);
237+
uint32_t len = strlen(string);
238+
char* result = kmalloc(len + 1);
239+
strlcpy(result, string, len + 1);
240240
*(result + len) = 0;
241241
return result;
242242
}
@@ -246,9 +246,9 @@ char* gc_strdup(const char* string)
246246
if (!string) {
247247
return NULL;
248248
}
249-
uint32_t len = strlen(string) + 1;
250-
char* result = kmalloc(len);
251-
strlcpy(result, string, len);
249+
uint32_t len = strlen(string);
250+
char* result = kmalloc(len + 1);
251+
strlcpy(result, string, len + 1);
252252
*(result + len) = 0;
253253

254254
if (gc_list == NULL) {

src/video.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,14 @@ void init_console()
166166
wait_forever();
167167
}
168168
rr_console_init_from_limine();
169-
clearscreen(c);
170169

171170
struct limine_framebuffer* fb = framebuffer_request.response->framebuffers[0];
172171

172+
screen_graphics_x = fb->width;
173+
screen_graphics_y = fb->height;
174+
175+
clearscreen(c);
176+
173177
dprintf("Bringing up flanterm...\n");
174178

175179
struct limine_module_response* mods = module_request.response;
@@ -211,8 +215,6 @@ void init_console()
211215
flanterm_get_dimensions(ft_ctx, &x, &y);
212216
screen_x = x;
213217
screen_y = y;
214-
screen_graphics_x = fb->width;
215-
screen_graphics_y = fb->height;
216218
dprintf("Framebuffer address: %llx x resolution=%d y resolution=%d\n", framebuffer_address(), screen_get_width(), screen_get_height());
217219

218220
setforeground(current_console, COLOUR_LIGHTYELLOW);

0 commit comments

Comments
 (0)