Page 1 of 1

Is there a list of os independent functions

Posted: Sat Jan 07, 2006 2:05 pm
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

Re:Is there a list of os independent functions

Posted: Wed Mar 01, 2006 1:06 pm
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...

Re:Is there a list of os independent functions

Posted: Tue Mar 07, 2006 5:37 am
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".

Re:Is there a list of os independent functions

Posted: Tue Mar 07, 2006 5:50 am
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.

Re:Is there a list of os independent functions

Posted: Thu Mar 09, 2006 4:25 am
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.