Ignore:
Timestamp:
Sep 17, 2006, 2:44:18 PM (14 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Updated kernel 'driver', still not working, but most of the work is done
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/kernel/kernel.c

    r944 r1048  
    3030#define LOWER(x) (IS_UPPER(x)?(x-('a'-'A')):x)
    3131
     32/* Our default seed for random number generator */
     33static int seed = 0x68743284;
     34
    3235/* Our memory mapping */
    3336static uint32_t *freemem = (uint32_t*) 0x00200000;
     
    9598}
    9699
     100int getpid(void)
     101{
     102    return 0x1337;
     103}
     104
     105void srand(unsigned int s)
     106{
     107    seed = rand();
     108}
     109
     110int time(void *dummy)
     111{
     112    return rand();
     113}
     114
    97115int rand(void)
    98116{
    99     static int seed = 0x68743284;
    100117    seed = (seed * 0x7f32ba17) ^ 0xf893a735;
    101118    return seed % RAND_MAX;
     
    158175}
    159176
     177int memcmp(const char *s1, const char *s2, size_t n)
     178{
     179    while(n) {
     180        if(*s1 != *s2) return *s1-*s2;
     181        *s1++;
     182        *s2++;
     183        n--;
     184    }
     185    return 0;
     186}
     187
     188
    160189/* stdarg.h functions */
    161190int vsnprintf(char *str, size_t size, const char *format, va_list ap)
     
    182211    /* FIXME */
    183212    return NULL;
     213}
     214
     215size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
     216{
     217    return 0;
    184218}
    185219
     
    299333}
    300334
     335
     336/* XXX FIXME Converts only from little endian to big endian (x86) */
     337unsigned int htonl(unsigned int hostlong)
     338{
     339    return ((hostlong&0xFFFF0000)>>16)|((hostlong&0x0000FFFFFF)<<16);
     340}
     341
     342/* XXX FIXME Converts only from little endian to big endian (x86) */
     343unsigned short htons(unsigned short hostlong)
     344{
     345    return ((hostlong&0xFF00)>>8)|((hostlong&0x00FF)<<8);
     346}
     347
     348
     349
    301350#endif /* __KERNEL__ */
Note: See TracChangeset for help on using the changeset viewer.