stlport for your c++ kernel

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
18kyongjian
Posts: 2
Joined: Wed Nov 03, 2010 8:26 pm

stlport for your c++ kernel

Post 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
Attachments
screenshot
screenshot
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: stlport for your c++ kernel

Post 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
18kyongjian
Posts: 2
Joined: Wed Nov 03, 2010 8:26 pm

Re: stlport for your c++ kernel

Post 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:
Post Reply