reenabled swaptest. quake should now load data and start on big endian architectures...
[AROS-Contrib.git] / gnu / abc-shell / missing.c
blobb8456c6816e405c7fb26ec31056d397227f274ca
1 /*
2 * Routines which may be missing on some machines
3 */
5 #include <sys/stat.h>
6 #include "sh.h"
8 #if !defined __amigaos4__ && !defined __AROS__
9 void *
10 memmove(void *d, const void *s, size_t n)
12 char *dp = (char *) d, *sp = (char *) s;
14 if (n <= 0)
16 else if (dp < sp)
18 *dp++ = *sp++;
19 while (--n > 0);
20 else if (dp > sp) {
21 dp += n;
22 sp += n;
24 *--dp = *--sp;
25 while (--n > 0);
27 return d;
29 #endif
31 #ifdef AMIGA
32 INT32
33 ksh_times(void *tms)
35 return 0;
37 #else
38 # include "ksh_time.h"
39 # include "ksh_times.h"
40 # include <sys/timeb.h>
42 INT32
43 ksh_times(struct tms *tms)
45 static INT32 base_sec;
46 INT32 rv;
47 /* Assume times() available, but always returns 0
48 * (also assumes ftime() available)
51 struct timeb tb;
53 if (times(tms) == (INT32) -1)
54 return (INT32) -1;
55 ftime(&tb);
56 if (base_sec == 0)
57 base_sec = tb.time;
58 rv = (tb.time - base_sec) * CLK_TCK;
59 rv += tb.millitm * CLK_TCK / 1000;
61 return rv;
64 #endif
66 #ifndef __AROS__
67 int
68 dup2(int oldd, int newd)
70 int old_errno;
72 if (fcntl(oldd, F_GETFL, 0) == -1)
73 return -1; /* errno == EBADF */
75 if (oldd == newd)
76 return newd;
78 old_errno = errno;
80 close(newd); /* in case its open */
82 errno = old_errno;
84 return fcntl(oldd, F_DUPFD, newd);
86 #endif