From: William F. Jolitz Date: Wed, 1 Mar 1989 22:48:44 +0000 (-0800) Subject: 386BSD 0.0 development X-Git-Tag: 386BSD-0.0~1364 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/f597777378cae2577c3fd7e12e2b40acd90ec794 386BSD 0.0 development Work on file usr/src/usr.bin/gas/xrealloc.c Work on file usr/src/usr.bin/gas/xmalloc.c Work on file usr/src/usr.bin/gas/symbols.h Work on file usr/src/usr.bin/gas/subsegs.h Co-Authored-By: Lynne Greer Jolitz Synthesized-from: 386BSD-0.0/src --- diff --git a/usr/src/usr.bin/gas/subsegs.h b/usr/src/usr.bin/gas/subsegs.h new file mode 100644 index 0000000000..b8dbaf76e5 --- /dev/null +++ b/usr/src/usr.bin/gas/subsegs.h @@ -0,0 +1,65 @@ +/* subsegs.h -> subsegs.c + Copyright (C) 1987 Free Software Foundation, Inc. + +This file is part of GAS, the GNU Assembler. + +GAS is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GAS is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GAS; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* + * For every sub-segment the user mentions in the ASsembler program, + * we make one struct frchain. Each sub-segment has exactly one struct frchain + * and vice versa. + * + * Struct frchain's are forward chained (in ascending order of sub-segment + * code number). The chain runs through frch_next of each subsegment. + * This makes it hard to find a subsegment's frags + * if programmer uses a lot of them. Most programs only use text0 and + * data0, so they don't suffer. At least this way: + * (1) There are no "arbitrary" restrictions on how many subsegments + * can be programmed; + * (2) Subsegments' frchain-s are (later) chained together in the order in + * which they are emitted for object file viz text then data. + * + * From each struct frchain dangles a chain of struct frags. The frags + * represent code fragments, for that sub-segment, forward chained. + */ + +struct frchain /* control building of a frag chain */ +{ /* FRCH = FRagment CHain control */ + struct frag * frch_root; /* 1st struct frag in chain, or NULL */ + struct frag * frch_last; /* last struct frag in chain, or NULL */ + struct frchain * frch_next; /* next in chain of struct frchain-s */ + segT frch_seg; /* SEG_TEXT or SEG_DATA. */ + subsegT frch_subseg; /* subsegment number of this chain */ +}; + +typedef struct frchain frchainS; + +extern frchainS * frchain_root; /* NULL means no frchains yet. */ + /* all subsegments' chains hang off here */ + +extern frchainS * frchain_now; + /* Frchain we are assembling into now */ + /* That is, the current segment's frag */ + /* chain, even if it contains no (complete) */ + /* frags. */ + +extern frchainS * data0_frchainP; + /* Sentinel for frchain crawling. */ + /* Points to the 1st data-segment frchain. */ + /* (Which is pointed to by the last text- */ + /* segment frchain.) */ + +/* end: subsegs.h */ diff --git a/usr/src/usr.bin/gas/symbols.h b/usr/src/usr.bin/gas/symbols.h new file mode 100644 index 0000000000..5a52790645 --- /dev/null +++ b/usr/src/usr.bin/gas/symbols.h @@ -0,0 +1,42 @@ +/* symbols.h - + Copyright (C) 1987 Free Software Foundation, Inc. + +This file is part of GAS, the GNU Assembler. + +GAS is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GAS is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GAS; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +extern struct obstack notes; /* eg FixS live here. */ + +#define symbol_table_lookup(name) ((symbolS *)(symbol_find (name))) + +extern unsigned int local_bss_counter; /* Zeroed before a pass. */ + /* Only used by .lcomm directive. */ + + +extern symbolS * symbol_rootP; /* all the symbol nodes */ +extern symbolS * symbol_lastP; /* last struct symbol we made, or NULL */ + +extern symbolS abs_symbol; + +symbolS * symbol_find(); +void symbol_begin(); +char * local_label_name(); +void local_colon(); +symbolS * symbol_new(); +void colon(); +void symbol_table_insert(); +symbolS * symbol_find_or_make(); + +/* end: symbols.h */ diff --git a/usr/src/usr.bin/gas/xmalloc.c b/usr/src/usr.bin/gas/xmalloc.c new file mode 100644 index 0000000000..78c8c7f8c4 --- /dev/null +++ b/usr/src/usr.bin/gas/xmalloc.c @@ -0,0 +1,60 @@ +/* xmalloc.c - get memory or bust + Copyright (C) 1987 Free Software Foundation, Inc. + +This file is part of GAS, the GNU Assembler. + +GAS is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GAS is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GAS; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* +NAME + xmalloc() - get memory or bust +INDEX + xmalloc() uses malloc() + +SYNOPSIS + char * my_memory; + + my_memory = xmalloc(42); / * my_memory gets address of 42 chars * / + +DESCRIPTION + + Use xmalloc() as an "error-free" malloc(). It does almost the same job. + When it cannot honour your request for memory it BOMBS your program + with a "virtual memory exceeded" message. Malloc() returns NULL and + does not bomb your program. + +SEE ALSO + malloc() + +*/ +#ifdef USG +#include +#endif + +char * xmalloc(n) + long n; +{ + char * retval; + char * malloc(); + void error(); + + if ( ! (retval = malloc ((unsigned)n)) ) + { + error("virtual memory exceeded"); + } + return (retval); +} + +/* end: xmalloc.c */ diff --git a/usr/src/usr.bin/gas/xrealloc.c b/usr/src/usr.bin/gas/xrealloc.c new file mode 100644 index 0000000000..a5010bc9b0 --- /dev/null +++ b/usr/src/usr.bin/gas/xrealloc.c @@ -0,0 +1,61 @@ +/* xrealloc.c -new memory or bust- + Copyright (C) 1987 Free Software Foundation, Inc. + +This file is part of GAS, the GNU Assembler. + +GAS is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GAS is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GAS; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + + +/* + +NAME + xrealloc () - get more memory or bust +INDEX + xrealloc () uses realloc () +SYNOPSIS + char *my_memory; + + my_memory = xrealloc (my_memory, 42); + / * my_memory gets (perhaps new) address of 42 chars * / + +DESCRIPTION + + Use xrealloc () as an "error-free" realloc ().It does almost the same + job. When it cannot honour your request for memory it BOMBS your + program with a "virtual memory exceeded" message. Realloc() returns + NULL and does not bomb your program. + +SEE ALSO + realloc () +*/ + +#ifdef USG +#include +#endif + +char * +xrealloc (ptr, n) +register char *ptr; +long n; +{ + char *realloc (); + void error(); + + if ((ptr = realloc (ptr, (unsigned)n)) == 0) + error ("virtual memory exceeded"); + return (ptr); +} + +/* end: xrealloc.c */