2 * Misc. functions for systems that don't have them
4 * Copyright 1996 Alexandre Julliard
13 unsigned int usleep (unsigned int useconds) { DosSleep(useconds); }
15 unsigned int usleep (unsigned int useconds)
20 delay.tv_usec = useconds;
22 select( 0, 0, 0, 0, &delay );
26 #endif /* HAVE_USLEEP */
29 void *memmove( void *dest, const void *src, unsigned int len )
31 register char *dst = dest;
33 /* Use memcpy if not overlapping */
34 if ((dst + len <= (char *)src) || ((char *)src + len <= dst))
36 memcpy( dst, src, len );
38 /* Otherwise do it the hard way (FIXME: could do better than this) */
41 while (len--) *dst++ = *((char *)src)++;
46 src = (char *)src + len - 1;
47 while (len--) *dst-- = *((char *)src)--;
51 #endif /* HAVE_MEMMOVE */
54 const char *strerror( int err )
56 /* Let's hope we have sys_errlist then */
57 return sys_errlist[err];
59 #endif /* HAVE_STRERROR */
61 #if !defined(HAVE_CLONE) && defined(__linux__)
65 int clone( int (*fn)(void *), void *stack, int flags, void *arg )
69 void **stack_ptr = (void **)stack;
70 *--stack_ptr = arg; /* Push argument on stack */
71 *--stack_ptr = fn; /* Push function pointer (popped into ebx) */
72 __asm__ __volatile__( "pushl %%ebx\n\t"
75 "popl %%ebx\n\t" /* Contains fn in the child */
76 "testl %%eax,%%eax\n\t"
78 "call *%%ebx\n\t" /* Should never return */
79 "xorl %%eax,%%eax\n\t" /* Just in case it does*/
82 : "0" (SYS_clone), "g" (flags), "c" (stack_ptr) );
83 assert( ret ); /* If ret is 0, we returned from the child function */
84 if (ret > 0) return ret;
92 #endif /* !HAVE_CLONE && __linux__ */