diff options
Diffstat (limited to 'WebKitTools/android/flex-2.5.4a/MISC/Macintosh')
4 files changed, 374 insertions, 0 deletions
diff --git a/WebKitTools/android/flex-2.5.4a/MISC/Macintosh/THINK_C_notes b/WebKitTools/android/flex-2.5.4a/MISC/Macintosh/THINK_C_notes new file mode 100644 index 0000000..e99c972 --- /dev/null +++ b/WebKitTools/android/flex-2.5.4a/MISC/Macintosh/THINK_C_notes @@ -0,0 +1,100 @@ +Notes on the THINK C version of Flex 2.4.6 +Scott Hofmann 23-JUL-94 +Internet: scotth@visix.com + +The only changes needed to compile Flex 2.4.6 under Symantec C++ 6.0 was +to #include <console.h> in main.c and call ccommand() just before flexinit() +in main(). The notes below are mostly of historical significance only; most +of the workarounds below were to get around restrictions/problems in earlier +versions of THINK C. The only section which still applies is Russell Finn's +description of how to make Flex generate output of type 'KAHL'. Also, 4-byte +ints must be used by any project which uses Flex output. + +If you want to recreate the project, you'll need to add the files +alloca.c and xmalloc.c in this directory. Both files are copylefted; see +the GNU General Public License for details. You will also need to recompile +both the ANSI and unix libraries to use 4 byte ints, and if you want the +files that flex creates to have 'KAHL' as the creator you'll need to apply +Russell Finn's patch. + +Notes on the THINK C version of Flex 2.3.7 +Jonas Barklund, 25-JAN-92 +Internet: jonas@csd.uu.se + +I have merged the sources for Flex version 2.3.7 with the older version +which was hacked for THINK C version 4. I have conditionalized the code +so that I think it should work with both THINK C version 4 and 5 (for +those of you who don't know: the THINK_C symbol is defined as 1 in version +4 and as 5 in version 5). I have put in some missing prototypes, so it +compiles also with "require prototypes" on. + +Most of the notes below still apply, in particular that about the MakeRes +program. + + +Notes on the THINK C version of Flex +Russell S. Finn, 19-FEB-90 +Internet: rsfinn@athena.mit.edu, rsfinn@neutron.lcs.mit.edu +CompuServe: 76377,1107 +GEnie: RSFINN + +Flex appears to be covered by a copyright notice from the University of +California, similar to the one covering Berkeley Unix; the Free Software +Foundation is not part of the picture here. So here is a version +created with THINK C 4.0, along with the source code; as with the +Bison distribution, I am including *all* of the source code I received +with the package. + +The current version (modification date January 25, 1990) has only the +bare-bones interface provided by the THINK C library routine "ccommand", +which allows the user to type a command line and to redirect the output. +Perhaps someday I may try to implement a "real" user interface; perhaps +not. + +The only modifications made to the source file are surrounded by "#ifdef +THINK_C"..."#endif"; in theory, then, these sources could be recompiled +on another system if necessary. These are the actual files modified: +alloca.c, dfa.c, flexdef.h, main.c, misc.c, scan.c, sym.c. Most of these +changes were minor, and many of them would have been unnecessary if the +original Flex source code had been written for an ANSI-compliant C compiler. +In addition, the file "macutils.c" is completely new; see the discussion +of "MakeRes" below. + +THINK C users may find it convenient to have the output text files written +by Flex be THINK C documents. To do this, create a copy of the "ANSI" +project called "ANSI-KAHL", and a copy of the file "fopen.c" called +"fopen-KAHL.c". In the copy, find the routine "setfiletype", and replace +the lines: + if (!(oflag & F_BINARY)) + pb.ioFlFndrInfo.fdType = 'TEXT'; +with the lines: + if (!(oflag & F_BINARY)) { + pb.ioFlFndrInfo.fdType = 'TEXT'; + pb.ioFlFndrInfo.fdCreator = 'KAHL'; + } +Replace "fopen.c" with the new "fopen-KAHL.c", rebuild the new project +"ANSI-KAHL", and use this project in the project file "Flex.¹" +instead of the "ANSI" project. + +** The "MakeRes" program + +The output files created by Flex contain large amounts of preinitialized +static data; the file "scan.c" contained in the Flex.¹ project is one +such file. However, the Macintosh architecture limits normal applications +to 32K of global data. In many cases (including Flex), this limit can +be surpassed by the static data generated by Flex. + +The solution I have implemented for the THINK C version of Flex is to +extract the data tables from the Flex output file, and paste them into +the file "MakeRes.c". Then, by recompiling and running the program in +the "MakeRes.¹" project (it is not necessary to create an application), +a resource file called "Flex.¹.rsrc" is created in the current directory. +The Flex output file "scan.c" has been modified to load the static data +from the resource fork of the Flex application. This is done by calling +the "load_table" function, which is defined in the file "macutils.c". + +In the application for which I needed Flex, the data tables were small +enough that I didn't need to do this. However, if your application +requires you to do this, simply follow the model of "scan.c"; the MakeRes +project and source code has been included for your use. + diff --git a/WebKitTools/android/flex-2.5.4a/MISC/Macintosh/alloca.c b/WebKitTools/android/flex-2.5.4a/MISC/Macintosh/alloca.c new file mode 100644 index 0000000..9cb6fa0 --- /dev/null +++ b/WebKitTools/android/flex-2.5.4a/MISC/Macintosh/alloca.c @@ -0,0 +1,195 @@ +/* + alloca -- (mostly) portable public-domain implementation -- D A Gwyn + + last edit: 86/05/30 rms + include config.h, since on VMS it renames some symbols. + Use xmalloc instead of malloc. + + This implementation of the PWB library alloca() function, + which is used to allocate space off the run-time stack so + that it is automatically reclaimed upon procedure exit, + was inspired by discussions with J. Q. Johnson of Cornell. + + It should work under any C implementation that uses an + actual procedure stack (as opposed to a linked list of + frames). There are some preprocessor constants that can + be defined when compiling for your specific system, for + improved efficiency; however, the defaults should be okay. + + The general concept of this implementation is to keep + track of all alloca()-allocated blocks, and reclaim any + that are found to be deeper in the stack than the current + invocation. This heuristic does not reclaim storage as + soon as it becomes invalid, but it will do so eventually. + + As a special case, alloca(0) reclaims storage without + allocating any. It is a good idea to use alloca(0) in + your main control loop, etc. to force garbage collection. +*/ +#ifndef lint +static char SCCSid[] = "@(#)alloca.c 1.1"; /* for the "what" utility */ +#endif + +#ifdef emacs +#include "config.h" +#ifdef static +/* actually, only want this if static is defined as "" + -- this is for usg, in which emacs must undefine static + in order to make unexec workable + */ +#ifndef STACK_DIRECTION +you +lose +-- must know STACK_DIRECTION at compile-time +#endif /* STACK_DIRECTION undefined */ +#endif /* static */ +#endif /* emacs */ + +#ifndef alloca /* If compiling with GCC, this file's not needed. */ + +#ifdef __STDC__ +typedef void *pointer; /* generic pointer type */ +#else +typedef char *pointer; /* generic pointer type */ +#endif + +#define NULL 0 /* null pointer constant */ + +extern void free(); +extern pointer xmalloc(); + +/* + Define STACK_DIRECTION if you know the direction of stack + growth for your system; otherwise it will be automatically + deduced at run-time. + + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown +*/ + +#ifndef STACK_DIRECTION +#define STACK_DIRECTION 0 /* direction unknown */ +#endif + +#if STACK_DIRECTION != 0 + +#define STACK_DIR STACK_DIRECTION /* known at compile-time */ + +#else /* STACK_DIRECTION == 0; need run-time code */ + +static int stack_dir; /* 1 or -1 once known */ +#define STACK_DIR stack_dir + +static void +find_stack_direction (/* void */) +{ + static char *addr = NULL; /* address of first + `dummy', once known */ + auto char dummy; /* to get stack address */ + + if (addr == NULL) + { /* initial entry */ + addr = &dummy; + + find_stack_direction (); /* recurse once */ + } + else /* second entry */ + if (&dummy > addr) + stack_dir = 1; /* stack grew upward */ + else + stack_dir = -1; /* stack grew downward */ +} + +#endif /* STACK_DIRECTION == 0 */ + +/* + An "alloca header" is used to: + (a) chain together all alloca()ed blocks; + (b) keep track of stack depth. + + It is very important that sizeof(header) agree with malloc() + alignment chunk size. The following default should work okay. +*/ + +#ifndef ALIGN_SIZE +#define ALIGN_SIZE sizeof(double) +#endif + +typedef union hdr +{ + char align[ALIGN_SIZE]; /* to force sizeof(header) */ + struct + { + union hdr *next; /* for chaining headers */ + char *deep; /* for stack depth measure */ + } h; +} header; + +/* + alloca( size ) returns a pointer to at least `size' bytes of + storage which will be automatically reclaimed upon exit from + the procedure that called alloca(). Originally, this space + was supposed to be taken from the current stack frame of the + caller, but that method cannot be made to work for some + implementations of C, for example under Gould's UTX/32. +*/ + +static header *last_alloca_header = NULL; /* -> last alloca header */ + +pointer +alloca (size) /* returns pointer to storage */ + unsigned size; /* # bytes to allocate */ +{ + auto char probe; /* probes stack depth: */ + register char *depth = &probe; + +#if STACK_DIRECTION == 0 + if (STACK_DIR == 0) /* unknown growth direction */ + find_stack_direction (); +#endif + + /* Reclaim garbage, defined as all alloca()ed storage that + was allocated from deeper in the stack than currently. */ + + { + register header *hp; /* traverses linked list */ + + for (hp = last_alloca_header; hp != NULL;) + if ((STACK_DIR > 0 && hp->h.deep > depth) + || (STACK_DIR < 0 && hp->h.deep < depth)) + { + register header *np = hp->h.next; + + free ((pointer) hp); /* collect garbage */ + + hp = np; /* -> next header */ + } + else + break; /* rest are not deeper */ + + last_alloca_header = hp; /* -> last valid storage */ + } + + if (size == 0) + return NULL; /* no allocation required */ + + /* Allocate combined header + user data storage. */ + + { + register pointer new = xmalloc (sizeof (header) + size); + + /* address of header */ + + ((header *)new)->h.next = last_alloca_header; + ((header *)new)->h.deep = depth; + + last_alloca_header = (header *)new; + + /* User storage begins just after header. */ + + return (pointer)((char *)new + sizeof(header)); + } +} + +#endif /* no alloca */ diff --git a/WebKitTools/android/flex-2.5.4a/MISC/Macintosh/alloca.h b/WebKitTools/android/flex-2.5.4a/MISC/Macintosh/alloca.h new file mode 100644 index 0000000..f48eaf2 --- /dev/null +++ b/WebKitTools/android/flex-2.5.4a/MISC/Macintosh/alloca.h @@ -0,0 +1,10 @@ +/**************** +** alloca.h +** +** header for alloca() +*****************/ + +typedef void *pointer; + +pointer alloca(unsigned size); + diff --git a/WebKitTools/android/flex-2.5.4a/MISC/Macintosh/xmalloc.c b/WebKitTools/android/flex-2.5.4a/MISC/Macintosh/xmalloc.c new file mode 100644 index 0000000..5bef831 --- /dev/null +++ b/WebKitTools/android/flex-2.5.4a/MISC/Macintosh/xmalloc.c @@ -0,0 +1,69 @@ +/* xmalloc.c -- malloc with out of memory checking + Copyright (C) 1990, 1991 Free Software Foundation, Inc. + + This program 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 2, or (at your option) + any later version. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#if STDC_HEADERS || THINK_C +#include <stdlib.h> +#else +char *malloc (); +char *realloc (); +void free (); +#endif + +#ifdef THINK_C +#define error(x, y, z) perror(z) /* Throw out meaningless arguments */ +#else +void error (); +#endif + +/* Allocate N bytes of memory dynamically, with error checking. */ + +char * +xmalloc (n) + unsigned n; +{ + char *p; + + p = malloc (n); + if (p == 0) + /* Must exit with 2 for `cmp'. */ + error (2, 0, "virtual memory exhausted"); + return p; +} + +/* Change the size of an allocated block of memory P to N bytes, + with error checking. + If P is NULL, run xmalloc. + If N is 0, run free and return NULL. */ + +char * +xrealloc (p, n) + char *p; + unsigned n; +{ + if (p == 0) + return xmalloc (n); + if (n == 0) + { + free (p); + return 0; + } + p = realloc (p, n); + if (p == 0) + /* Must exit with 2 for `cmp'. */ + error (2, 0, "virtual memory exhausted"); + return p; +} |