/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/malloc.c |
---|
5,7 → 5,6 |
#include <stdlib.h> |
#include <string.h> |
#include <unistd.h> |
#include <menuet/sem.h> |
typedef struct BLOCK { |
size_t size; |
23,7 → 22,7 |
#define ALIGN 8 |
#define SMALL (NUMSMALL*ALIGN) |
DECLARE_STATIC_SEM(malloc_mutex) |
static int malloc_mutex = 0; |
static BLOCK *slop = 0; |
static BLOCK *freelist[30]; |
33,12 → 32,13 |
static inline void malloc_lock(void) |
{ |
sem_lock(&malloc_mutex); |
while (__sync_lock_test_and_set(&malloc_mutex, 1)) |
__menuet__delay100(1); |
} |
static inline void malloc_unlock(void) |
{ |
sem_unlock(&malloc_mutex); |
__sync_lock_release(&malloc_mutex); |
} |
#define MIN_SAVE_EXTRA 64 |
/programs/develop/libraries/menuetlibc/stub/Tupfile.lua |
---|
1,2 → 1,3 |
if tup.getconfig("NO_FASM") ~= "" then return end |
tup.rule("crt0_coff.asm", "fasm %f %o", "crt0.o") |
tup.rule("crt0_coff_dynstack.asm", "fasm %f %o", "crt0_dynstack.o") |
/programs/develop/libraries/menuetlibc/stub/crt0_coff_dynstack.asm |
---|
0,0 → 1,63 |
CATCH_NULL_CALL = 0 |
format MS COFF |
section '.text' code readable executable |
public start |
;EXTRN _edata |
EXTRN ___menuet__app_param_area |
EXTRN ___menuet__app_path_area |
EXTRN ___crt1_startup |
EXTRN ___memsize |
start: |
public ___menuet__app_header |
public ___menuet__memsize |
section '.A' code readable executable |
___menuet__app_header: |
db 'MENUET01' |
dd 0x01 |
dd do_start |
; dd _edata |
dd 0 |
___menuet__memsize: |
dd ___memsize |
dd app_stack |
dd ___menuet__app_param_area |
dd ___menuet__app_path_area |
do_start: |
push 68 |
pop eax |
push 11 |
pop ebx |
push eax |
int 0x40 |
pop eax |
inc ebx |
mov ecx, 0x100000 |
int 0x40 |
lea esp, [eax+ecx] |
if CATCH_NULL_CALL |
mov byte [0], 0xE9 |
mov dword [1], _libc_null_call-5 |
end if |
jmp ___crt1_startup |
if CATCH_NULL_CALL |
EXTRN ___libc_null_call |
_libc_null_call: |
push eax |
push ebx |
push ecx |
push edx |
push esi |
push edi |
push ebp |
call ___libc_null_call |
mov eax,-1 |
int 0x40 |
end if |
section '.bss' readable writeable |
rb 0x100 |
app_stack: |
/programs/use_gcc.lua |
---|
16,6 → 16,10 |
function link_gcc(input, output) |
if not output then input,output = OBJS,input end |
if STARTUP then |
table.insert(LIBDEPS, STARTUP) |
LDFLAGS = LDFLAGS .. " " .. STARTUP |
end |
if tup.getconfig("HELPERDIR") == "" and #LIBDEPS then |
if type(input) == "string" then input = {input} end |
if not input.extra_inputs then input.extra_inputs = {} end |
/programs/use_menuetlibc.lua |
---|
1,6 → 1,11 |
MELIBC = tup.getcwd() .. "/develop/libraries/menuetlibc" |
INCLUDES = INCLUDES .. " -I" .. MELIBC .. "/include" |
LDFLAGS = LDFLAGS .. string.gsub(" -T$/include/scripts/menuetos_app_v01.ld -L$/lib $/stub/crt0.o", "%$", MELIBC) |
tup.append_table(LIBDEPS, {MELIBC .. "/stub/crt0.o", MELIBC .. "/<libc>", MELIBC .. "/<libm>", MELIBC .. "/<libcpp>"}) |
STARTUP = MELIBC .. "/stub/crt0.o" |
LDFLAGS = LDFLAGS .. string.gsub(" -T$/include/scripts/menuetos_app_v01.ld -L$/lib", "%$", MELIBC) |
tup.append_table(LIBDEPS, {MELIBC .. "/<libc>", MELIBC .. "/<libm>", MELIBC .. "/<libcpp>"}) |
LIBS = LIBS .. " -lcpp -lm -lc" |
function use_dynamic_stack() |
STARTUP = MELIBC .. "/stub/crt0_dynstack.o" |
end |
/programs/use_sdl.lua |
---|
0,0 → 1,8 |
SDL_INCLUDE = tup.getcwd() .. "/../contrib/sdk/sources/SDL-1.2.2/include" |
SDL_LIB = tup.getcwd() .. "/../contrib/sdk/lib" |
tup.include("use_sound.lua") |
INCLUDES = INCLUDES .. " -I" .. SDL_INCLUDE |
table.insert(LIBDEPS, SDL_LIB .. "/<libSDL>") |
LIBS = SDL_LIB .. "/libSDL.a " .. LIBS |
/programs/use_sound.lua |
---|
0,0 → 1,5 |
SOUND = tup.getcwd() .. "/develop/sdk/trunk/sound" |
INCLUDES = INCLUDES .. " -I" .. SOUND .. "/include" |
table.insert(LIBDEPS, SOUND .. "/src/sound.lib") |
LIBS = SOUND .. "/src/sound.lib " .. LIBS |