Code: Select all
#ifndef STDIO_H
#define STDIO_H
#include <interrupts.h>
void printf(const char *s, ...)
{
Int(0x80);
}
#endif
Code: Select all
#ifndef STDIO_H
#define STDIO_H
#include <interrupts.h>
void printf(const char *s, ...)
{
Int(0x80);
}
#endif
Code: Select all
#define __syscall3(ret,name,a1,__a1,a2,__a2,a3,__a3) \
ret name(a1 __a1,a2 __a2,a3 __a3) \
{ \
unsigned long __ret; \
asm volatile( \
"int $0xff" \
: "=a" (__ret) \
: "a" (__NR_##name),"b" ((unsigned long)__a1), \
"c" ((unsigned long)__a2),"d" ((unsigned long)__a3) \
); \
return (ret)__ret; \
}
Code: Select all
#define __NR_write 0x3
__syscall3(unsigned long,write,int,fd,const void *,buf,unsigned long,size);
Code: Select all
unsigned long write(int fd,const void *buf,unsigned long size);
Code: Select all
int printf(const char *string,...)
{
char buf[512];
/*.....*/
int n = vsnprinf(buf,sizeof(buf),string,va_args);
return write(stdout,buf,n);
}
Technically it runs at same speed.hometue wrote:Just curious, if you have the same function in the C library and kernel which one would be faster/more efficient to use?
Incoming buffer overflow!windows8 wrote: char buf[512];
/*.....*/
int n = vsnprinf(buf,sizeof(buf),string,va_args);
Thing is, I shouldn't need to. It is something that is easy to pick up from user mode programming.computertrick wrote:could you provide more information?