I mentioned in a private email recently that it would be useful if syslinux had a malloc implementation. I have one now if anyone's interested. -- Hebe 2004-02-08 14:26:08.183 UTC (JD 2453044.101484) X = -1.159504592, Y = 2.015990327, Z = 0.638260245 X' = -0.010415779, Y' = -0.003652077, Z' = 0.001024628
TenThumbs wrote:> I mentioned in a private email recently that it would be useful if > syslinux > had a malloc implementation. I have one now if anyone's interested. > >I just implemented a simple malloc for a 16-bit COMBOOT application. I will surely be interested in seeing your implementation. We should probably starting building an implementation of all useful C routines. Ideally, we should be able to create an include file "comboot.h", which declares all the useful C routines, and defines them to generate an error message. That way one can use any of the C libraries as long as they include comboot.h as well. If the C function cannot work under comboot, then there will be an error generated. Here is a small example. /* COMBOOT.H starts */ #define fopen 1=7 #define fclose 1=7 .... #include "heap.h" #include "string.h" extern void * malloc(unsigned int ); extern void * memset(void *, char, unsigned int); .... // COMBOOT.H ends Now any C file which includes comboot.h cannot use fopen (it will result in a compile error). If one includes <stdlib.h> and tries to use malloc, then there will be two implementations and will result in a linker error. This will be useful till we have mini libc, one can use for comboot coding. BTW, how mature is klibc to use for this? - Murali
Murali Krishnan Ganapathy wrote:> > I just implemented a simple malloc for a 16-bit COMBOOT application. I > will surely be interested in seeing your implementation. We should > probably starting building an implementation of all useful C routines. >I wanted something what would work in both 16 and 32 bit environments. I'll attach a demo tarball. The allocator is rather primitive but it's small.> Ideally, we should be able to create an include file "comboot.h", which > declares all the useful C routines, and defines them to generate an > error message. That way one can use any of the C libraries as long as > they include comboot.h as well. If the C function cannot work under > comboot, then there will be an error generated. > > [omitted] > > - MuraliSince this code isn't running in the system environment, I would just create my own header files with the usual names and tell the compiler to use mine and ignore the system ones. -- Sun 2004-02-09 12:13:47.711 UTC (JD 2453045.009580) X = 0.003583325, Y = -0.002344825, Z = -0.001089334 X' = 0.000003837, Y' = 0.000006105, Z' = 0.000002487