Yasm Assembler mainline development tree (ffmpeg 依赖)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.7 KiB

Massive libyasm / module interface update - Phase 1 As yasm has evolved, various minor additions have been made to libyasm to support the new features. These minor additions have accumulated, and some contain significant redundancies. In addition, the core focus of yasm has begun to move away from the front-end commandline program "yasm" to focusing on libyasm, a collection of reusable routines for use in all sorts of programs dealing with code at the assembly level, and the modules that provide specific features for parsing such code. This libyasm/module update focuses on cleaning up much of the cruft that has accumulated in libyasm, standardizing function names, eliminating redundancies, making many of the core objects more reusable for future extensions, and starting to make libyasm and the modules thread-safe by eliminating static variables. Specific changes include: - Making a symbol table data structure (no longer global). It follows a factory model for creating symrecs. - Label symbols now refer only to bytecodes; bytecodes have a pointer to their containing section. - Standardizing on *_create() and *_destroy() for allocation/deallocation. - Adding a standardized callback mechanism for all data structures that allow associated data. Allowed the removal of objfmt and dbgfmt-specific data callbacks in their interfaces. - Unmodularizing linemgr, but allowing multiple linemap instances (linemgr is now renamed linemap). - Remove references to lindex; all virtual lines (from linemap) are now just "line"s. - Eliminating the bytecode "type" enum, instead adding a standardized callback mechanism for custom (and standard internal) bytecode types. This will make it much easier to add new bytecodes, and eliminate the possibility of type collisions. This also allowed the removal of the of_data and df_data bytecodes, as objfmts and dbgfmts can now easily implement their own bytecodes, and the cleanup of arch's bytecode usage. - Remove the bytecodehead and sectionhead pseudo-containers, instead making true containers: section now implements all the functions of bytecodehead, and the new object data structure implements all the functions of sectionhead. - Add object data structure: it's a container that contains sections, a symbol table, and a line mapping for a single object. Every former use of sectionhead now takes an object. - Make arch interface and all standard architectures thread-safe: yasm_arch_module is the module interface; it contains a create() function that returns a yasm_arch * to store local yasm_arch data; all yasm_arch_module functions take the yasm_arch *. - Make nasm parser thread-safe. To be done in phase 2: making other module interfaces thread-safe. Note that while the module interface may be thread-safe, not all modules may be written in such a fashion (hopefully all the "standard" ones will be, but this is yet to be determined). svn path=/trunk/yasm/; revision=1058
21 years ago
/**
* \file assocdat.h
* \brief YASM associated data storage (libyasm internal use)
*
* \rcs
* $Id$
Massive libyasm / module interface update - Phase 1 As yasm has evolved, various minor additions have been made to libyasm to support the new features. These minor additions have accumulated, and some contain significant redundancies. In addition, the core focus of yasm has begun to move away from the front-end commandline program "yasm" to focusing on libyasm, a collection of reusable routines for use in all sorts of programs dealing with code at the assembly level, and the modules that provide specific features for parsing such code. This libyasm/module update focuses on cleaning up much of the cruft that has accumulated in libyasm, standardizing function names, eliminating redundancies, making many of the core objects more reusable for future extensions, and starting to make libyasm and the modules thread-safe by eliminating static variables. Specific changes include: - Making a symbol table data structure (no longer global). It follows a factory model for creating symrecs. - Label symbols now refer only to bytecodes; bytecodes have a pointer to their containing section. - Standardizing on *_create() and *_destroy() for allocation/deallocation. - Adding a standardized callback mechanism for all data structures that allow associated data. Allowed the removal of objfmt and dbgfmt-specific data callbacks in their interfaces. - Unmodularizing linemgr, but allowing multiple linemap instances (linemgr is now renamed linemap). - Remove references to lindex; all virtual lines (from linemap) are now just "line"s. - Eliminating the bytecode "type" enum, instead adding a standardized callback mechanism for custom (and standard internal) bytecode types. This will make it much easier to add new bytecodes, and eliminate the possibility of type collisions. This also allowed the removal of the of_data and df_data bytecodes, as objfmts and dbgfmts can now easily implement their own bytecodes, and the cleanup of arch's bytecode usage. - Remove the bytecodehead and sectionhead pseudo-containers, instead making true containers: section now implements all the functions of bytecodehead, and the new object data structure implements all the functions of sectionhead. - Add object data structure: it's a container that contains sections, a symbol table, and a line mapping for a single object. Every former use of sectionhead now takes an object. - Make arch interface and all standard architectures thread-safe: yasm_arch_module is the module interface; it contains a create() function that returns a yasm_arch * to store local yasm_arch data; all yasm_arch_module functions take the yasm_arch *. - Make nasm parser thread-safe. To be done in phase 2: making other module interfaces thread-safe. Note that while the module interface may be thread-safe, not all modules may be written in such a fashion (hopefully all the "standard" ones will be, but this is yet to be determined). svn path=/trunk/yasm/; revision=1058
21 years ago
* \endrcs
*
* \license
* Copyright (C) 2003 Peter Johnson
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* \endlicense
*/
#ifndef YASM_ASSOCDAT_H
#define YASM_ASSOCDAT_H
/** Associated data container. */
typedef struct yasm__assoc_data yasm__assoc_data;
/** Create an associated data container. */
/*@only@*/ yasm__assoc_data *yasm__assoc_data_create(void);
/** Get associated data for a data callback.
* \param assoc_data container of associated data
* \param callback callback used when adding data
* \return Associated data (NULL if none).
*/
/*@dependent@*/ /*@null@*/ void *yasm__assoc_data_get
(/*@null@*/ yasm__assoc_data *assoc_data,
const yasm_assoc_data_callback *callback);
/** Add associated data to a associated data container.
* \attention Deletes any existing associated data for that data callback.
* \param assoc_data container of associated data
* \param callback callback
* \param data data to associate
*/
/*@only@*/ yasm__assoc_data *yasm__assoc_data_add
(/*@null@*/ /*@only@*/ yasm__assoc_data *assoc_data,
const yasm_assoc_data_callback *callback,
/*@only@*/ /*@null@*/ void *data);
/** Destroy all associated data in a container. */
void yasm__assoc_data_destroy
(/*@null@*/ /*@only@*/ yasm__assoc_data *assoc_data);
/** Print all associated data in a container. */
void yasm__assoc_data_print(const yasm__assoc_data *assoc_data, FILE *f,
int indent_level);
#endif