2 * Misc. functions for systems that don't have them
4 * Copyright 1996 Alexandre Julliard
11 #include <sys/ioctl.h>
21 unsigned int usleep (unsigned int useconds) { DosSleep(useconds); }
23 unsigned int usleep (unsigned int useconds)
28 delay.tv_usec = useconds;
30 select( 0, 0, 0, 0, &delay );
34 #endif /* HAVE_USLEEP */
37 void *memmove( void *dest, const void *src, unsigned int len )
39 register char *dst = dest;
41 /* Use memcpy if not overlapping */
42 if ((dst + len <= (char *)src) || ((char *)src + len <= dst))
44 memcpy( dst, src, len );
46 /* Otherwise do it the hard way (FIXME: could do better than this) */
49 while (len--) *dst++ = *((char *)src)++;
54 src = (char *)src + len - 1;
55 while (len--) *dst-- = *((char *)src)--;
59 #endif /* HAVE_MEMMOVE */
62 const char *strerror( int err )
64 /* Let's hope we have sys_errlist then */
65 return sys_errlist[err];
67 #endif /* HAVE_STRERROR */
69 #if !defined(HAVE_CLONE) && defined(__linux__)
73 int clone( int (*fn)(void *), void *stack, int flags, void *arg )
77 void **stack_ptr = (void **)stack;
78 *--stack_ptr = arg; /* Push argument on stack */
79 *--stack_ptr = fn; /* Push function pointer (popped into ebx) */
80 __asm__ __volatile__( "pushl %%ebx\n\t"
83 "popl %%ebx\n\t" /* Contains fn in the child */
84 "testl %%eax,%%eax\n\t"
86 "call *%%ebx\n\t" /* Should never return */
87 "xorl %%eax,%%eax\n\t" /* Just in case it does*/
90 : "0" (SYS_clone), "g" (flags), "c" (stack_ptr) );
91 assert( ret ); /* If ret is 0, we returned from the child function */
92 if (ret > 0) return ret;
100 #endif /* !HAVE_CLONE && __linux__ */
104 * It looks like the openpty that comes with glibc in RedHat 5.0
105 * is buggy (second call returns what looks like a dup of 0 and 1
106 * instead of a new pty), this is a generic replacement.
108 /** We will have an autoconf check for this soon... */
110 int wine_openpty(int *master, int *slave, char *name,
111 struct termios *term, struct winsize *winsize)
116 strcpy (pts_name, "/dev/ptyXY");
118 for (ptr1 = "pqrstuvwxyzPQRST"; *ptr1 != 0; ptr1++) {
120 for (ptr2 = "0123456789abcdef"; *ptr2 != 0; ptr2++) {
123 if ((*master = open(pts_name, O_RDWR)) < 0) {
130 if ((*slave = open(pts_name, O_RDWR)) < 0) {
136 tcsetattr(*slave, TCSANOW, term);
138 ioctl(*slave, TIOCSWINSZ, winsize);
140 strcpy(name, pts_name);