Page 1 of 1

stlport for your c++ kernel

Posted: Wed Nov 03, 2010 9:56 pm
by 18kyongjian
stlport for your c++ kernel

the source code is from stlport-4.6.2, and take reference 'mona' os,
and it's run well in my c++ kernel.

usage:
download and tar 2 you kernel dir:
http://blogimg.chinaunix.net/blog/upfil ... 092828.bz2

need for stlport: include/_stlport.h
function in the file need implement, such as 'strcpy, memcpy, malloc, free',
and you *MUST* use stlport after memory managerment init.

test code in kernel:

Code: Select all

#include <include/common.h>
#include <drivers/char/vga.h>
#include <vector>

using namespace std;

void do_test()
{
 typedef vector<int> DataList;
 DataList list;
 list.push_back(8);
 list.push_back(6);
 list.push_back(4);
 list.push_back(12);
 list.push_back(14);
 list.push_back(16);
 list.push_back(18);
 printk_color(TEXT_COLOR_LIGHTBLUE, "stlport test: list size is %d, data is ", list.size());

 for (DataList::iterator it = list.begin(); it != list.end(); it++) {
  printk_color(TEXT_COLOR_LIGHTBLUE, "%d, ", *it);
 }
 printk_color(TEXT_COLOR_LIGHTBLUE, "\n");
}

The attachment jinix_snap.png is no longer available

Re: stlport for your c++ kernel

Posted: Thu Nov 04, 2010 3:56 am
by JamesM
Very nice! My kernel is currently using glibc + libstdc++ - very interesting that you've got stlport to compile bare metal.

Was your patch large? or did it compile out of the box? And what are its libc dependencies?

Cheers,

James

Re: stlport for your c++ kernel

Posted: Thu Nov 04, 2010 9:59 am
by 18kyongjian
hi, jamesM. i download the stlport-4.6.2, do very little modify, can use winmerge see difference.

the source file not need compile alone, just #include <list, map, ..> in cpp source file,,, add -I./stlport to CFLAGS,
nearly no increase of the kernel file size.

about 15 function need implement(no need libc):
strcpy, strncpy, strcat, strlen, strchr, strrchr, strncat, strcmp, strncmp, memmove, memset, memcpy, memcmp, malloc, free.
this function defined in "include/_stlport.h", this file should in the kernel include directory, and implement them in kernel.

Cheers :wink: