summaryrefslogtreecommitdiff
path: root/libyasm
diff options
context:
space:
mode:
authorPeter Johnson <peter@tortall.net>2008-05-09 06:46:02 +0000
committerPeter Johnson <peter@tortall.net>2008-05-09 06:46:02 +0000
commitcbf0c7befdecd2da9bf4f866c3b25bb0f6b173f0 (patch)
tree9c826aade374450549a3aca820112a5c71fc7c05 /libyasm
parentd8a6f8c3765cbbd8f2908965cb4b2adee1499c56 (diff)
downloadyasm-cbf0c7befdecd2da9bf4f866c3b25bb0f6b173f0.tar.gz
Split NASM preprocessor standard macro set between various modules.
Standard macro sets are looked up based on parser and preprocessor keyword from individual modules. The "standard" NASM parser macros now reside in the NASM parser, so when the GAS parser is used with the NASM preprocessor, the NASM-specific macros are no longer defined. Object-format specific macros are now individually defined by each object formatm module. This allows for the object formats to be independent of the NASM preprocessor module and yields a small optimization benefit as unused object format macros don't need to be skipped over. Also add GAS macro equivalents for the Win64 SEH more complex directives [1]. [1] Requested by Brian Gladman <brg@gladman.plus.com> svn path=/trunk/yasm/; revision=2082
Diffstat (limited to 'libyasm')
-rw-r--r--libyasm/coretype.h15
-rw-r--r--libyasm/objfmt.h3
-rw-r--r--libyasm/parser.h3
-rw-r--r--libyasm/preproc.h16
4 files changed, 37 insertions, 0 deletions
diff --git a/libyasm/coretype.h b/libyasm/coretype.h
index 5c99816c..b23e3eae 100644
--- a/libyasm/coretype.h
+++ b/libyasm/coretype.h
@@ -52,6 +52,21 @@ typedef struct yasm_objfmt_module yasm_objfmt_module;
/** Debug format module interface. \see dbgfmt.h for details. */
typedef struct yasm_dbgfmt_module yasm_dbgfmt_module;
+/** Standard macro structure for modules that allows association of a set of
+ * standard macros with a parser/preprocessor combination.
+ * A NULL-terminated array of these structures is used in a number of module
+ * interfaces.
+ */
+typedef struct yasm_stdmac {
+ const char *parser; /**< Parser keyword */
+ const char *preproc; /**< Preprocessor keyword */
+
+ /** NULL-terminated array of standard macros. May be NULL if no standard
+ * macros should be added for this preprocessor.
+ */
+ const char **macros;
+} yasm_stdmac;
+
/** YASM associated data callback structure. Many data structures can have
* arbitrary data associated with them.
*/
diff --git a/libyasm/objfmt.h b/libyasm/objfmt.h
index 0c40c4a3..c65e76c1 100644
--- a/libyasm/objfmt.h
+++ b/libyasm/objfmt.h
@@ -77,6 +77,9 @@ struct yasm_objfmt_module {
/** NULL-terminated list of directives. NULL if none. */
/*@null@*/ const yasm_directive *directives;
+ /** NULL-terminated list of standard macro lookups. NULL if none. */
+ const yasm_stdmac *stdmacs;
+
/** Create object format.
* Module-level implementation of yasm_objfmt_create().
* Call yasm_objfmt_create() instead of calling this function.
diff --git a/libyasm/parser.h b/libyasm/parser.h
index fcbb20c4..26c347be 100644
--- a/libyasm/parser.h
+++ b/libyasm/parser.h
@@ -51,6 +51,9 @@ typedef struct yasm_parser_module {
/** Default preprocessor. */
const char *default_preproc_keyword;
+ /** NULL-terminated list of standard macro lookups. NULL if none. */
+ const yasm_stdmac *stdmacs;
+
/** Parse a source file into an object.
* \param object object to parse into (already created)
* \param pp preprocessor
diff --git a/libyasm/preproc.h b/libyasm/preproc.h
index fff40daa..0b8c54ff 100644
--- a/libyasm/preproc.h
+++ b/libyasm/preproc.h
@@ -105,6 +105,11 @@ typedef struct yasm_preproc_module {
* Call yasm_preproc_builtin_define() instead of calling this function.
*/
void (*define_builtin) (yasm_preproc *preproc, const char *macronameval);
+
+ /** Module-level implementation of yasm_preproc_add_standard().
+ * Call yasm_preproc_add_standard() instead of calling this function.
+ */
+ void (*add_standard) (yasm_preproc *preproc, const char **macros);
} yasm_preproc_module;
/** Initialize preprocessor.
@@ -169,6 +174,14 @@ void yasm_preproc_undefine_macro(yasm_preproc *preproc, const char *macroname);
void yasm_preproc_define_builtin(yasm_preproc *preproc,
const char *macronameval);
+/** Define additional standard macros, preprocessed after the builtins but
+ * prior to any user-defined macros.
+ * \param preproc preprocessor
+ * \param macros NULL-terminated array of macro strings
+ */
+void yasm_preproc_add_standard(yasm_preproc *preproc,
+ const char **macros);
+
#ifndef YASM_DOXYGEN
/* Inline macro implementations for preproc functions */
@@ -192,6 +205,9 @@ void yasm_preproc_define_builtin(yasm_preproc *preproc,
#define yasm_preproc_define_builtin(preproc, macronameval) \
((yasm_preproc_base *)preproc)->module->define_builtin(preproc, \
macronameval)
+#define yasm_preproc_add_standard(preproc, macros) \
+ ((yasm_preproc_base *)preproc)->module->add_standard(preproc, \
+ macros)
#endif