Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1484 → Rev 1485

/uspace/trunk/libc/include/string.h
35,7 → 35,8
#define bzero(ptr, len) memset((ptr), 0, (len))
 
void * memset(void *s, int c, size_t n);
void * memcpy(void *dest, void *src, size_t n);
void * memcpy(void *dest, const void *src, size_t n);
void * memmove(void *dest, const void *src, size_t n);
 
int strcmp(const char *, const char *);
 
/uspace/trunk/libc/include/ipc/fb.h
6,46 → 6,9
#ifndef __libc__FB_H__
#define __libc__FB_H__
 
#define FB_GET_VFB 1024
#define FB_PUTCHAR 1025
#define FB_PUTCHAR 1025
#define FB_CLEAR 1026
#define FB_GET_CSIZE 1027
 
#define METHOD_WIDTH 16
#define ITEM_WIDTH 16
#define COUNT_WIDTH 16 /* Should be 8 times integer */
 
 
struct _fb_method {
unsigned m : METHOD_WIDTH;
unsigned item : ITEM_WIDTH;
} __attribute__((packed));
 
union fb_method {
struct _fb_method m;
__native fill;
} __attribute__((packed));
 
struct fb_call_args {
union fb_method method;
union {
struct {
unsigned count : COUNT_WIDTH;
char chars[3 * sizeof(__native) - (COUNT_WIDTH >> 3)];
} putchar __attribute__((packed));
} data ; // __attribute__((packed));
} __attribute__((packed));
 
struct fb_ipc_args {
__native method;
__native arg1;
__native arg2;
__native arg3;
} __attribute__((packed));
 
union fb_args {
struct fb_call_args fb_args;
struct fb_ipc_args ipc_args;
} __attribute__((packed));
 
typedef union fb_args fb_args_t;
 
#endif
/uspace/trunk/libc/generic/string.c
42,15 → 42,36
return s;
}
 
void * memcpy(void *dest, void *src, size_t n)
void * memcpy(void *dst, const void *src, size_t n)
{
char *os = src;
char *odst = dest;
while (n--)
*(odst++) = *(os++);
return dest;
int i, j;
 
for (i = 0; i < n/sizeof(unsigned long); i++)
((unsigned long *) dst)[i] = ((unsigned long *) src)[i];
for (j = 0; j < n%sizeof(unsigned long); j++)
((unsigned char *)(((unsigned long *) dst) + i))[j] = ((unsigned char *)(((unsigned long *) src) + i))[j];
return (char *)src;
}
 
void * memmove(void *dst, const void *src, size_t n)
{
int i, j;
if (src > dst)
return memcpy(dst, src, n);
 
for (j = (n%sizeof(unsigned long))-1; j >= 0; j--)
((unsigned char *)(((unsigned long *) dst) + i))[j] = ((unsigned char *)(((unsigned long *) src) + i))[j];
 
for (i = n/sizeof(unsigned long)-1; i >=0 ; i--)
((unsigned long *) dst)[i] = ((unsigned long *) src)[i];
return (char *)src;
}
 
 
/** Count the number of characters in the string, not including terminating 0.
* @param str string
* @return number of characters in string.