From fb61ba77bc66ff07fbeb7fb4abbb5f756af7e955 Mon Sep 17 00:00:00 2001 From: David Jones Date: Thu, 16 Dec 2004 12:17:13 +0000 Subject: [PATCH] Mps: expgen script to generate a list of exported symbols. and its output. Copied from Perforce Change: 133985 ServerID: perforce.ravenbrook.com --- mps/code/expgen.sh | 118 ++++++++++++++++++++++++++++++++ mps/code/w3gen.def | 163 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 281 insertions(+) create mode 100755 mps/code/expgen.sh create mode 100644 mps/code/w3gen.def diff --git a/mps/code/expgen.sh b/mps/code/expgen.sh new file mode 100755 index 00000000000..54c8daca2dc --- /dev/null +++ b/mps/code/expgen.sh @@ -0,0 +1,118 @@ +#!/bin/sh +# $Header$ +# +# Copyright (C) 2004 Ravenbrook Limited. All rights reserved. +# +# expgen.sh +# +# Export Generator +# +# This is a script to generate the a list of exports that is required +# for Windows DLL creation. +# +# It processed the mps header files and produces a .DEF file that is +# suitable for use with the linker when producing a DLL file on Windows. +# +# When run, this script produces the following output files: +# expgen - a plain text list of functions declared in the header files. +# w3gen.def - a .def file suitable for use in the linker stage when +# building a Windows .DLL. +# +# +# Design +# +# The script works by using the -fdump-translation-unit option of gcc. +# This produces a more easily parseable rendering of the header files. +# A fairly simple awk script is used to process the output. +# +# +# Dependencies +# +# This script currently depends fairly heavily on being run in a +# Unix-like environment with access to the GNU compiler. +# +# It's also fairly sensitive to changes in the undocumented format +# produced by gcc -fdump-translation-unit. Hopefully it is fairly easy +# to adapt to changes in this output. +# +# Assumes it can freely write to the files "fun", "name-s". +# +# +# Awk crash course +# +# Awk processes files line-by-line, thus the entire script is executed +# for each line of the input file (more complex awk scripts can control +# this using "next" and "getline" and so on). +# +# In awk $exp identifies a field within the line. $1 is the first +# field, $2 is the second and so on. $0 is the whole line. By default +# fields are separated by whitespace. +# +# string ~ RE is a matching expression and evaulated to true iff the +# string is matched by the regular expression. +# +# REFERENCES +# +# [SUSV3] Single UNIX Specification Version 3, +# http://www.unix.org/single_unix_specification/ +# +# For documenation of the standard utilities: sh, awk, join, sort, sed +# +# [MSDN-LINKER-DEF] Module-Definition (.def) files, +# http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_module.2d.definition_files.asp +# +# For documentation on the format of .def files. + +tu () { + # if invoked on a file called spong.h will produce a file named + # spong.h.tu + gcc -fdump-translation-unit -o /dev/null "$@" +} + +# This list of header files is produced by +# awk '/^copy.*\.h/{print $2}' w3build.bat +# followed by manual removal of mpsw3.h mpswin.h. +# The functions declared in mpsw3.h have to be added to the .def file by +# hand later in this script. +f='mps.h +mpsavm.h +mpsacl.h +mpscamc.h +mpscams.h +mpscawl.h +mpsclo.h +mpscmv.h +mpscmvff.h +mpscsnc.h +mpsio.h +mpslib.h +mpstd.h' + +tu $f + +>expgen + +for a in $f +do + >fun + awk ' + $2=="function_decl" && $7=="srcp:" && $8 ~ /^'$a':/ {print $4 >"fun"} + $2=="identifier_node"{print $1,$4} + ' $a.tu | + sort -k 1 >name-s + + echo ';' $a >>expgen + sort -k 1 fun | + join -o 2.2 - name-s >>expgen +done + +{ + printf '%sHeader%s\n' '$' '$' + echo '; DO NOT EDIT. Automatically generated by $Header$' | sed 's/\$/!/g' + echo 'EXPORTS' + cat expgen + # This is where we manually the functions declared in mpsw3.h + echo ';' mpsw3.h - by hand + echo mps_SEH_filter + echo mps_SEH_handler +} > w3gen.def diff --git a/mps/code/w3gen.def b/mps/code/w3gen.def new file mode 100644 index 00000000000..41b6e4f22c9 --- /dev/null +++ b/mps/code/w3gen.def @@ -0,0 +1,163 @@ +$Header$ +; DO NOT EDIT. Automatically generated by !Header! +EXPORTS +; mps.h +mps_ap_fill_with_reservoir_permit +mps_ap_fill +mps_commit +mps_reserve +mps_ap_destroy +mps_ap_create_v +mps_ap_create +mps_free +mps_alloc_v +mps_alloc +mps_chain_destroy +mps_chain_create +mps_pool_destroy +mps_pool_create_v +mps_pool_create +mps_fmt_destroy +mps_fmt_create_fixed +mps_fmt_create_auto_header +mps_fmt_create_B +mps_fmt_create_A +mps_arena_retract +mps_arena_extend +mps_arena_has_addr +mps_space_committed +mps_arena_formatted_objects_walk +mps_space_reserved +mps_arena_spare_commit_limit +mps_arena_spare_commit_limit_set +mps_arena_commit_limit_set +mps_arena_commit_limit +mps_arena_spare_committed +mps_arena_committed +mps_arena_reserved +mps_space_destroy +mps_space_create +mps_arena_destroy +mps_arena_create_v +mps_arena_create +mps_space_collect +mps_space_park +mps_space_release +mps_space_clamp +mps_arena_step +mps_arena_collect +mps_arena_start_collect +mps_arena_unsafe_restore_protection +mps_arena_unsafe_expose_remember_protection +mps_arena_expose +mps_arena_park +mps_arena_release +mps_arena_clamp +mps_telemetry_flush +mps_fix +mps_pool_check_fenceposts +mps_telemetry_label +mps_telemetry_intern +mps_telemetry_control +mps_definalize +mps_finalize +mps_message_gc_not_condemned_size +mps_message_gc_condemned_size +mps_message_gc_live_size +mps_message_finalization_ref +mps_message_type +mps_message_queue_type +mps_message_discard +mps_message_get +mps_message_type_disable +mps_message_type_enable +mps_message_poll +mps_collections +mps_ld_isstale +mps_ld_merge +mps_ld_add +mps_ld_reset +mps_thread_dereg +mps_thread_reg +mps_tramp +mps_stack_scan_ambig +mps_root_destroy +mps_root_create_reg +mps_root_create_fmt +mps_root_create_table_masked +mps_root_create_table +mps_root_create +mps_reserve_with_reservoir_permit +mps_reservoir_available +mps_reservoir_limit +mps_arena_roots_walk +mps_reservoir_limit_set +mps_sac_empty +mps_pool_check_free_space +mps_sac_fill +mps_sac_flush +mps_sac_free +mps_sac_alloc +mps_sac_destroy +mps_sac_create +mps_rank_weak +mps_ap_alloc_pattern_reset +mps_rank_exact +mps_ap_alloc_pattern_end +mps_rank_ambig +mps_ap_alloc_pattern_begin +mps_alloc_pattern_ramp_collect_all +mps_alloc_pattern_ramp +mps_ap_trip +mps_ap_frame_pop +mps_ap_frame_push +; mpsavm.h +mps_arena_class_vmnz +mps_arena_class_vm +; mpsacl.h +mps_arena_class_cl +; mpscamc.h +mps_class_amc +mps_amc_apply +mps_class_amcz +; mpscams.h +mps_class_ams_debug +mps_class_ams +; mpscawl.h +mps_class_awl +; mpsclo.h +mps_class_lo +; mpscmv.h +mps_mv_size +mps_class_mv_debug +mps_mv_free_size +mps_class_mv +; mpscmvff.h +mps_mvff_size +mps_class_mvff_debug +mps_mvff_free_size +mps_class_mvff +; mpscsnc.h +mps_class_snc +; mpsio.h +mps_io_flush +mps_io_destroy +mps_io_create +mps_io_write +; mpslib.h +mps_lib_fputc +mps_lib_get_stdout +mps_lib_get_stderr +mps_lib_get_EOF +mps_clock +mps_lib_telemetry_control +mps_lib_memcmp +mps_lib_memcpy +mps_lib_memset +mps_clocks_per_sec +mps_lib_assert_fail +mps_lib_fputs +; mpstd.h +; mpsw3.h - by hand +mps_SEH_filter +mps_SEH_handler