7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
26 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
27 */
28
29 #include <libdisasm.h>
30 #include <stdlib.h>
31 #ifdef DIS_STANDALONE
32 #include <mdb/mdb_modapi.h>
33 #define _MDB
34 #include <mdb/mdb_io.h>
35 #else
36 #include <stdio.h>
37 #endif
38
39 #include "libdisasm_impl.h"
40
41 static int _dis_errno;
42
43 /*
44 * If we're building the standalone library, then we only want to
45 * include support for disassembly of the native architecture.
46 * The regular shared library should include support for all
47 * architectures.
48 */
49 #if !defined(DIS_STANDALONE) || defined(__i386) || defined(__amd64)
50 extern dis_arch_t dis_arch_i386;
51 #endif
52 #if !defined(DIS_STANDALONE) || defined(__sparc)
53 extern dis_arch_t dis_arch_sparc;
54 #endif
55 #if !defined(DIS_STANDALONE) || defined(__s390) || defined(__s390x)
56 extern dis_arch_t dis_arch_s390;
57 #endif
58
59 static dis_arch_t *dis_archs[] = {
60 #if !defined(DIS_STANDALONE) || defined(__i386) || defined(__amd64)
61 &dis_arch_i386,
62 #endif
63 #if !defined(DIS_STANDALONE) || defined(__sparc)
64 &dis_arch_sparc,
65 #endif
66 #if !defined(DIS_STANDALONE) || defined(__s390) || defined(__s390x)
67 &dis_arch_s390,
68 #endif
69 NULL
70 };
71
72 /*
73 * For the standalone library, we need to link against mdb's malloc/free.
74 * Otherwise, use the standard malloc/free.
75 */
76 #ifdef DIS_STANDALONE
77 void *
78 dis_zalloc(size_t bytes)
79 {
80 return (mdb_zalloc(bytes, UM_SLEEP));
81 }
82
83 void
84 dis_free(void *ptr, size_t bytes)
85 {
86 mdb_free(ptr, bytes);
87 }
88 #else
|
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
26 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
27 * Copyright 2018, Joyent, Inc.
28 */
29
30 #include <libdisasm.h>
31 #include <stdlib.h>
32 #ifdef DIS_STANDALONE
33 #include <mdb/mdb_modapi.h>
34 #define _MDB
35 #include <mdb/mdb_io.h>
36 #else
37 #include <stdio.h>
38 #endif
39
40 #include "libdisasm_impl.h"
41
42 static int _dis_errno;
43
44 /*
45 * If we're building the standalone library, then we only want to
46 * include support for disassembly of the native architecture.
47 * The regular shared library should include support for all
48 * architectures.
49 */
50 #if !defined(DIS_STANDALONE) || defined(__i386) || defined(__amd64)
51 extern dis_arch_t dis_arch_i386;
52 #endif
53 #if !defined(DIS_STANDALONE) || defined(__sparc)
54 extern dis_arch_t dis_arch_sparc;
55 #endif
56 #if !defined(DIS_STANDALONE) || defined(__s390) || defined(__s390x)
57 extern dis_arch_t dis_arch_s390;
58 #endif
59 #if !defined(DIS_STANDALONE) || defined(__riscv)
60 extern dis_arch_t dis_arch_riscv;
61 #endif
62
63 static dis_arch_t *dis_archs[] = {
64 #if !defined(DIS_STANDALONE) || defined(__i386) || defined(__amd64)
65 &dis_arch_i386,
66 #endif
67 #if !defined(DIS_STANDALONE) || defined(__sparc)
68 &dis_arch_sparc,
69 #endif
70 #if !defined(DIS_STANDALONE) || defined(__s390) || defined(__s390x)
71 &dis_arch_s390,
72 #endif
73 #if !defined(DIS_STANDALONE) || defined(__riscv)
74 &dis_arch_riscv,
75 #endif
76 NULL
77 };
78
79 /*
80 * For the standalone library, we need to link against mdb's malloc/free.
81 * Otherwise, use the standard malloc/free.
82 */
83 #ifdef DIS_STANDALONE
84 void *
85 dis_zalloc(size_t bytes)
86 {
87 return (mdb_zalloc(bytes, UM_SLEEP));
88 }
89
90 void
91 dis_free(void *ptr, size_t bytes)
92 {
93 mdb_free(ptr, bytes);
94 }
95 #else
|