Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

stdarg.h in C

Name: Anonymous 2012-09-05 16:00

I'm currently writing a C standard library for academic purposes, and I wondered how to implement stdarg.h (the va_* macros) in C (probably with inline ASM) and if this was the libc's work, or the compiler's ?
Thanks in advance.

Name: Anonymous 2012-09-07 13:03

>>12
I'm not convinced that is even true in general, but at least for printf the time it takes to create the printable string from the format and parameters is trivial compared to the time it takes to output the buffer. So even if you changed it to be only one syscall as in

  char line[LINE_LEN];
  sprintf(line, "%2x", i);  // your specific hex-to-string function here
  strncpy(line + 2, ": ", 2);
  strcpy(line + 4, strings[i]);
  puts(line);


you wouldn't gain much. When is printf a bottle-neck anyway? Could you as easily chop another variadic function into separate functions?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List