1 /* $NetBSD: common.h,v 1.14 2005/12/24 22:53:15 perry Exp $ */
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
36 #include <sys/syscall.h>
39 #define N_GETMAGIC(x) ((x).a_magic)
42 #define N_BSSADDR(x) (N_DATADDR(x)+(x).a_data)
53 extern struct _dynamic _DYNAMIC
;
54 static void __load_rtld
__P((struct _dynamic
*));
55 extern int __syscall
__P((int, ...));
56 int _callmain
__P((void));
57 static char *_strrchr
__P((char *, char));
59 static char *_getenv
__P((char *));
60 static int _strncmp
__P((char *, char *, int));
64 #define LDSO "/usr/lib/ld.so"
68 #define LDSO "/usr/libexec/ld.so"
73 * We need these system calls, but can't use library stubs
75 #define _exit(v) __syscall(SYS_exit, (v))
76 #define open(name, f, m) __syscall(SYS_open, (name), (f), (m))
77 #define close(fd) __syscall(SYS_close, (fd))
78 #define read(fd, s, n) __syscall(SYS_read, (fd), (s), (n))
79 #define write(fd, s, n) __syscall(SYS_write, (fd), (s), (n))
80 #define dup(fd) __syscall(SYS_dup, (fd))
81 #define dup2(fd, fdnew) __syscall(SYS_dup2, (fd), (fdnew))
83 #define mmap(addr, len, prot, flags, fd, off) \
84 __syscall(SYS_mmap, (addr), (len), (prot), _MAP_NEW|(flags), (fd), (off))
86 #define mmap(addr, len, prot, flags, fd, off) \
87 __syscall(SYS___syscall, (quad_t)SYS_mmap, (addr), (len), (prot), (flags), \
88 (fd), 0, (off_t)(off))
92 write(2, str, sizeof(str) - 1), \
97 extern int main
__P((int, char **, char **));
99 extern void monstartup
__P((u_long
, u_long
));
100 extern void _mcleanup
__P((void));
105 static char empty
[1];
106 char *__progname
= empty
;
108 struct ps_strings
*__ps_strings
= 0;
110 #define _strrchr strrchr
113 extern unsigned char etext
;
114 extern unsigned char eprol
__asm ("eprol");