summaryrefslogtreecommitdiff
path: root/libc/misc/aliases.c
blob: d23ea653f1e34b272a15b86d98f3e9c909be49b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
 * This file is part of the Linux-8086 C library and is distributed
 * under the GNU Library General Public License.
 */
#include <string.h>
#include <sys/types.h>

#ifdef L_abs
int
abs(arg1)
int arg1;
{
   return arg1>0?arg1:-arg1;
}
#endif

#ifdef L_raise
int
raise(signo)
int signo;
{
   return kill(getpid(), signo);
}
#endif

#ifdef L_bcopy
#undef bcopy
void
bcopy(src, dest, len)
__const void * src;
void *dest;
int len;
{
   (void) memcpy(dest, src, len);
}
#endif

#ifdef L_bzero
#undef bzero
void
bzero(dest, len)
void *dest;
int len;
{
   (void) memset(dest, '\0', len);
}
#endif

#ifdef L_bcmp
#undef bcmp
int
bcmp(dest, src, len)
__const void * src, *dest;
int len;
{
   return memcmp(dest, src, len);
}
#endif

#ifdef L_index
#undef index
char *
index(src, chr)
__const char *src;
int chr;
{
   return strchr(src, chr);
}
#endif

#ifdef L_rindex
#undef rindex
char *
rindex(src, chr)
__const char *src;
int chr;
{
   return strrchr(src, chr);
}
#endif

#ifdef L_remove
#include <errno.h>

int
remove(src)
__const char *src;
{
   extern int errno;
   int er = errno;
   int rv = unlink(src);
   if( rv < 0 && errno == EISDIR )
      rv = rmdir(src);
   if( rv >= 0 ) errno = er;
   return rv;
}
#endif

#ifdef L_creat
#include <fcntl.h>

int
creat(file, mode)
__const char * file;
mode_t mode;
{
   return open(file, O_TRUNC|O_CREAT|O_WRONLY, mode);
}
#endif