sgs.h revision 3edf445cce90224c4218c6987d6709e8481cae58
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1988 AT&T
* All Rights Reserved
*
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Global include file for all sgs.
*/
#ifndef _SGS_H
#define _SGS_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/* <assert.h> keys off of NDEBUG */
#ifdef DEBUG
#else
#define NDEBUG
#endif
#ifndef _ASM
#include <stdlib.h>
#include <libelf.h>
#include <assert.h>
#include <alist.h>
#endif /* _ASM */
/*
* Software identification.
*/
#define SGS ""
#define SGU_PKG "Software Generation Utilities"
#define SGU_REL "(SGU) Solaris-ELF (4.0)"
#ifndef _ASM
/*
* link_ver_string[] contains a version string for use by the link-editor
* and all other linker components. It is found in libconv, and is
* generated by sgs/libconv/common/bld_vernote.ksh. That script produces
* libconv.
*/
extern const char link_ver_string[];
/*
* Macro to round to next double word boundary.
*/
/*
* General align and round macros.
*/
/*
* Bit manipulation macros; generic bit mask and is `v' in the range
* supportable in `n' bits?
*/
/*
* Yet another definition of the OFFSETOF macro, used with the AVL routines.
*/
#define SGSOFFSETOF(s, m) ((size_t)(&(((s *)0)->m)))
/*
* When casting between integer and pointer types, gcc will complain
* if the integer type used is not large enough to hold the pointer
* value without loss. Although a dubious practice in general, this
* is sometimes done by design. In those cases, the general solution
* is to introduce an intermediate cast to widen the integer value. The
* CAST_PTRINT macro does this, and its use documents the fact that
* the programmer is doing that sort of cast.
*/
#ifdef __GNUC__
#else
#endif
/*
* General typedefs.
*/
typedef enum {
FALSE = 0,
TRUE = 1
} Boolean;
/*
* Types of errors (used by eprintf()), together with a generic error return
* value.
*/
typedef enum {
ERR_NUM /* Must be last */
} Error;
#else
#endif
/*
* LIST_TRAVERSE() is used as the only "argument" of a "for" loop to
* traverse a linked list. The node pointer `node' is set to each node in
* turn and the corresponding data pointer is copied to `data'. The macro
* is used as in
* for (LIST_TRAVERSE(List *list, Listnode *node, void *data)) {
* process(data);
* }
*/
#define LIST_TRAVERSE(L, N, D) \
(N) != NULL; \
struct listnode { /* a node on a linked list */
void *data; /* the data item */
};
struct list { /* a linked list */
};
#ifdef _SYSCALL32
typedef struct listnode32 Listnode32;
struct listnode32 { /* a node on a linked list */
};
struct list32 { /* a linked list */
};
#endif /* _SYSCALL32 */
/*
* Structure to maintain rejected files elf information. Files that are not
* applicable to the present link-edit are rejected and a search for an
* appropriate file may be resumed. The first rejected files information is
* retained so that a better error diagnostic can be given should an appropriate
* file not be located.
*/
typedef struct {
const char *rej_str; /* associated with error */
const char *rej_name; /* object name - expanded library */
/* name and archive members */
} Rej_desc;
#define SGS_REJ_NONE 0
/* required */
/*
* For those source files used both inside and outside of the
* libld source base (tools/common/string_table.c) we can
* automatically switch between the allocation models
* based off of the 'cc -DUSE_LIBLD_MALLOC' flag.
*/
#ifdef USE_LIBLD_MALLOC
#define free libld_free
#define malloc libld_malloc
#define realloc libld_realloc
extern void libld_free(void *);
extern void *libld_malloc(size_t);
extern void *libld_realloc(void *, size_t);
#endif
/*
* Data structures (defined in libld.h).
*/
typedef struct group_desc Group_desc;
typedef struct sym_avlnode Sym_avlnode;
typedef struct audit_desc Audit_desc;
typedef struct audit_info Audit_info;
typedef struct audit_list Audit_list;
/*
* Data structures defined in machrel.h.
*/
/*
* Data structures defined in rtld.h.
*/
#ifdef _SYSCALL32
#endif /* _SYSCALL32 */
/*
* For the various utilities that include sgs.h
*/
extern int assfail(const char *, const char *, int);
extern char *sgs_demangle(char *);
extern uint_t sgs_str_hash(const char *);
#endif /* _ASM */
#ifdef __cplusplus
}
#endif
#endif /* _SGS_H */