ppc64: Don't set Kp bit on SLB
[openbios/afaerber.git] / arch / x86 / lib.c
blobeeb901b4a8ec5eaa5f1ca82cc12bf41101bc3c2e
1 /* lib.c
2 * tag: simple function library
4 * Copyright (C) 2003 Stefan Reinauer
6 * See the file "COPYING" for further information about
7 * the copyright and warranty status of this work.
8 */
10 #include "config.h"
11 #include "asm/types.h"
12 #include <stdarg.h>
13 #include "libc/stdlib.h"
14 #include "libc/vsprintf.h"
15 #include "kernel/kernel.h"
17 /* Format a string and print it on the screen, just like the libc
18 * function printf.
20 int printk( const char *fmt, ... )
22 char *p, buf[512];
23 va_list args;
24 int i;
26 va_start(args, fmt);
27 i = vsnprintf(buf, sizeof(buf), fmt, args);
28 va_end(args);
30 for( p=buf; *p; p++ )
31 putchar(*p);
32 return i;
35 // dumb quick memory allocator until we get a decent thing here.
37 #define MEMSIZE 128*1024
38 static char memory[MEMSIZE];
39 static void *memptr=memory;
40 static int memsize=MEMSIZE;
42 void *malloc(int size)
44 void *ret=(void *)0;
45 if(memsize>=size) {
46 memsize-=size;
47 ret=memptr;
48 memptr = (void *)((unsigned long)memptr + size);
50 return ret;
53 void free(void *ptr)
55 /* Nothing yet */