Is there a list of os independent functions

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
earlz

Is there a list of os independent functions

Post by earlz »

is there a list of os independent functions in libc
i know that most of string.h is and the i86 or whatever include files for interrupts(16bit) but besides that i have no idea


the one im wondering about most though is string to int and int to string conversions like itoa if they are not then does anyone have a replacement function that is os independent
kable

Re:Is there a list of os independent functions

Post by kable »

I'm using a this, and can be easily modified to atoi.

Code: Select all

void putint(unsigned int val,unsigned int base){
   int div;
   div=val/base;
   if(div>0){
      putint(div,base);
   }
   console_putch("0123456789ABCDEF"[val%base]);
}
Sorry for the bump...
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Is there a list of os independent functions

Post by Candy »

IIRC it's in the C standard (ISO 9989:1999) under the header of a "freestanding" implementation. Freestanding here stands for "without OS layer above it".
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Is there a list of os independent functions

Post by Solar »

The "freestanding" part of the library is stddef.h, limits.h, float.h, iso646.h and two or three others - headers that are all typedef and #define, i.e. which do not introduce any code.

Actually, most functions in the C standard library are OS-independent. You need kernel support for only a handful of functions, all of them in stdio.h and stdlib.h:
  • opening a file,
  • closing a file,
  • writing to a file,
  • reading from a file,
  • positioning within a file,
  • getting environment variables,
  • terminating the process,
  • getting heap memory,
  • raising and catching a signal,
  • calling an external process (system()).
Add to that some functions that are only important for floating point maths, and perhaps one or two things I've forgotten. All the rest is handled internally by the libc.
I know that most of string.h is and the i86 or whatever include files for interrupts(16bit) but besides that i have no idea
Uh?

1) Anything that has to do with interrupts is not part of the standard C library.

2) Anything that has to do with interrupts is most certainly OS-dependent.
Every good solution is obvious once you've found it.
hendric

Re:Is there a list of os independent functions

Post by hendric »

It's difficult to transplant the exsit code from a kernel to yours as my thought for most of the code..Emm at least for me.
Post Reply