xref: /titanic_50/usr/src/tools/ctf/common/ctf_headers.h (revision f3e7f55e73a39377d55a030f124cc86b3b66a9cc)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*f3e7f55eSRobert Mustacchi  * Copyright 2018 Joyent, Inc.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef _CTF_HEADERS_H
297c478bd9Sstevel@tonic-gate #define	_CTF_HEADERS_H
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  * Because the ON tools are executed on the system where they are built,
337c478bd9Sstevel@tonic-gate  * the tools need to include the headers installed on the build system,
347c478bd9Sstevel@tonic-gate  * rather than those in the ON source tree. However, some of the headers
357c478bd9Sstevel@tonic-gate  * required by the tools are part of the ON source tree, but not delivered
36*f3e7f55eSRobert Mustacchi  * as part of illumos.  These include the following:
377c478bd9Sstevel@tonic-gate  *
387c478bd9Sstevel@tonic-gate  * $(SRC)/lib/libctf/common/libctf.h
39*f3e7f55eSRobert Mustacchi  * $(SRC)/lib/libctf/common/libctf_impl.h
407c478bd9Sstevel@tonic-gate  * $(SRC)/uts/common/sys/ctf_api.h
417c478bd9Sstevel@tonic-gate  * $(SRC)/uts/common/sys/ctf.h
427c478bd9Sstevel@tonic-gate  *
437c478bd9Sstevel@tonic-gate  * These headers get installed in the proto area in the build environment
447c478bd9Sstevel@tonic-gate  * under $(ROOT)/usr/include and $(ROOT)/usr/include/sys. Though these
457c478bd9Sstevel@tonic-gate  * headers are not part of the release, in releases including and prior to
467c478bd9Sstevel@tonic-gate  * Solaris 9, they did get installed on the build system via bfu. Therefore,
477c478bd9Sstevel@tonic-gate  * we can not simply force the order of inclusion with -I/usr/include first
487c478bd9Sstevel@tonic-gate  * in Makefile.ctf because we might actually get downlevel versions of the
497c478bd9Sstevel@tonic-gate  * ctf headers. Depending on the order of the -I includes, we can also have
507c478bd9Sstevel@tonic-gate  * a problem with mismatched headers when building the ctf tools with some
517c478bd9Sstevel@tonic-gate  * headers getting pulled in from /usr/include and others from
527c478bd9Sstevel@tonic-gate  * $(SRC)/uts/common/sys.
537c478bd9Sstevel@tonic-gate  *
547c478bd9Sstevel@tonic-gate  * To address the problem, we have done two things:
557c478bd9Sstevel@tonic-gate  * 1) Created this header with a specific order of inclusion for the
567c478bd9Sstevel@tonic-gate  *    ctf headers.  Because the <libctf.h> header includes <sys/ctf_api.h>
577c478bd9Sstevel@tonic-gate  *    which in turn includes <sys/ctf.h> we need to include these in
587c478bd9Sstevel@tonic-gate  *    reverse order to guarantee that we get the correct versions of
597c478bd9Sstevel@tonic-gate  *    the headers.
607c478bd9Sstevel@tonic-gate  * 2) In $(SRC)/tools/ctf/Makefile.ctf, we order the -I includes such
617c478bd9Sstevel@tonic-gate  *    that we first search the directories where the ctf headers
627c478bd9Sstevel@tonic-gate  *    live, followed by /usr/include, followed by $(SRC)/uts/common.
637c478bd9Sstevel@tonic-gate  *    This last -I include is needed in order to prevent a build failure
647c478bd9Sstevel@tonic-gate  *    when <sys/ctf_api.h> is included via a nested #include rather than
657c478bd9Sstevel@tonic-gate  *    an explicit path #include.
66*f3e7f55eSRobert Mustacchi  *
67*f3e7f55eSRobert Mustacchi  * We'll also include the local ccompile.h - older build systems often lack
68*f3e7f55eSRobert Mustacchi  * useful definitions like __unused.  Finally, we'll also define ARRAY_SIZE:
69*f3e7f55eSRobert Mustacchi  * unfortunately, older systems sysmacros.h only have this defined for the
70*f3e7f55eSRobert Mustacchi  * kernel, and we can't easily pick it up otherwise.
717c478bd9Sstevel@tonic-gate  */
727c478bd9Sstevel@tonic-gate 
73*f3e7f55eSRobert Mustacchi #include <uts/common/sys/ccompile.h>
747c478bd9Sstevel@tonic-gate #include <uts/common/sys/ctf.h>
757c478bd9Sstevel@tonic-gate #include <uts/common/sys/ctf_api.h>
76*f3e7f55eSRobert Mustacchi #include <common/ctf/ctf_impl.h>
777c478bd9Sstevel@tonic-gate #include <lib/libctf/common/libctf.h>
78*f3e7f55eSRobert Mustacchi #include <lib/libctf/common/libctf_impl.h>
79*f3e7f55eSRobert Mustacchi 
80*f3e7f55eSRobert Mustacchi #if !defined(ARRAY_SIZE)
81*f3e7f55eSRobert Mustacchi #define	ARRAY_SIZE(x)	(sizeof (x) / sizeof (x[0]))
82*f3e7f55eSRobert Mustacchi #endif
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate #endif /* _CTF_HEADERS_H */
85