home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / programming / misc_programming / MSC / READ.ME < prev   
Encoding:
Text File  |  1991-06-08  |  13.2 KB  |  300 lines

  1.  
  2.  
  3.  
  4.     Meridian Ada / Microsoft C Mixed Language Interface
  5.     ---------------------------------------------------
  6.  
  7.  
  8.     ( Note that versions 5.0 and 5.1 of the Microsoft C
  9.       product were used in developing this capability. )
  10.  
  11.     These notes provide additional information regarding the
  12.     use of Microsoft C code with Ada programs.  Please read
  13.     the Ada Compiler User's Guide and associated Release Notes
  14.     before reading this material.  This information is
  15.     particularly important if you want to use any part of the
  16.     Microsoft C run-time library and/or floating point data types
  17.     within Microsoft C code.
  18.  
  19.  
  20.     ===================================
  21.      Initial Setup and Sample Programs
  22.     ===================================
  23.  
  24.     In order to be able to more fully utilize Microsoft C
  25.     compiled routines and its associated run-time support with
  26.     Ada programs, the following procedures should be followed:
  27.  
  28.     1.  Install the Microsoft C library which uses the large
  29.     memory model and the 80x87 coprocessor for floating point
  30.     support.  This library is normally called LLIBC7 and is
  31.     normally located in the file \MSC\LIB\LLIBC7.LIB.  Note
  32.     that the provided batch files will need to be modified if
  33.     the Microsoft C product is not installed in its normal
  34.     place.
  35.  
  36.     2.  Make a modified Microsoft C library which is compatible
  37.     with the Ada run-time by running the supplied batch file
  38.     MAKELIB.BAT.  This will delete certain incompatible
  39.     start-up object modules from LLIBC7 and replace them with
  40.     Ada-specific start-up modules.  Note that the modified
  41.     library is placed in the file ADALIBC7.LIB and that the
  42.     original library is unchanged.
  43.  
  44.     3.  In the Ada program which interfaces to Microsoft C code,
  45.     include a call to the Microsoft C function MSC_START
  46.     before calling any other Microsoft C functions.  This will
  47.     initialize the Microsoft C run-time.  Also, at the end of
  48.     the Ada program (or at least after calling the last
  49.     Microsoft C function) include a call to the Microsoft C
  50.     function MSC_END to terminate the Microsoft C run-time.
  51.  
  52.     4.  Compile and link the Ada and Microsoft C code as described
  53.     in the User's Guide but be sure to link the code with the
  54.     modified Microsoft C library ADALIBC7.LIB.  If in the link
  55.     step, a Microsoft C library module is found to have
  56.     undefined external references, then use of the module is
  57.     most likely incompatible with the Ada runtime and should
  58.     be removed.
  59.  
  60.  
  61.     Included with this release are some sample Ada and Microsoft C
  62.     programs which illustrate the use of pragma interface(Microsoft_C)
  63.     and the above run-time interfacing procedures.  These programs are
  64.     called MSCTEST.ADA, CINTTST.C and CFLTTST.C.  After running
  65.     MAKELIB and creating an Ada program library with NEWLIB, simply
  66.     run the batch file MAKEMSC to compile and link these programs.
  67.     Note the definitions of and the placement of the calls to
  68.     MSC_START and MSC_END in the Ada program.  Also note in the
  69.     CFLTTST.C program that Ada floating point data items must be
  70.     defined as "double" in Microsoft C.  There is no support for
  71.     32-bit floating point values in Ada programs.
  72.  
  73.  
  74.     ==================================================
  75.      Meridian Ada vs. Microsoft C Memory Model Issues
  76.     ==================================================
  77.  
  78.     Normally, when a Meridian Ada program is produced, the Global
  79.     Data Segment (pointed to by the DS register) and the Stack
  80.     Segment (pointed to by SS), occupy separate segments of up
  81.     to 64K each.  This memory model is different from that of the
  82.     standard Microsoft C model in which the Stack and Data
  83.     Segments must fit into the same 64K segment and in which DS
  84.     and SS have the same value.  For most Microsoft C code, this
  85.     difference is transparent to the program.  However, there are
  86.     some Microsoft C run-time functions which depend on this
  87.     aspect of the memory model.  It is important to be aware of
  88.     these issues when developing Meridian Ada programs which
  89.     interface to the Microsoft C run-time.
  90.  
  91.     To more fully accomodate the Microsoft C run-time functions an
  92.     option is available to build a Meridian Ada/Microsoft C program
  93.     which uses Microsoft C's standard memory model for combined
  94.     Stack and Data Segments.  To enable this option you must link
  95.     in the object file MSCRTIO.OBJ from the Ada compiler's MSC
  96.     subdirectory into your program.  For example:
  97.  
  98.     ada example.ada
  99.     auglib example c:\ada\msc\mscrtio.obj
  100.     bamp -r example
  101.     cl /AL /Gs /c cexample.c
  102.     link /nod example cexample,,,adalibc7
  103.  
  104.     This special object file will then cause the Ada run-time to setup
  105.     its SS and DS segment registers so that they have the same value.
  106.  
  107.     NOTE: If the amount of global data in your program plus the size
  108.       the program's stack (as specified by the bamp -M and bamp -s
  109.       options, or their default values) exceeds 64K, then the Stack
  110.       and Data Segments cannot be combined and your program will
  111.       abort at run-time with exit code 16.  Therefore, you should
  112.       try not to declare large data objects in Ada library packages
  113.       or subprogram locals.  Instead, you should allocate these
  114.       from the heap (with new).
  115.  
  116.     NOTE: This capability is only available for real mode programs.
  117.       You cannot use it in extended (or protected) mode programs.
  118.  
  119.  
  120.     =========================================
  121.      Microsoft C Run-Time Environment Issues
  122.     =========================================
  123.  
  124.     A number of the Microsoft C run-time functions require information
  125.     about the DOS environment variables such as PATH or COMSPEC.  The
  126.     original Microsoft C run-time code for accessing and maintaining
  127.     these variables is incompatible with the way the Meridian Ada run-
  128.     time currently operates.  To better accomodate the Microsoft C
  129.     run-time, an implementation of the C getenv() funtion which works
  130.     with the Meridian Ada run-time, is included.  This function is
  131.     provided only in C source form in the file GETENV.C in the Ada
  132.     compiler's MSC subdirectory.  As such, you may modify it to meet
  133.     your particular application's needs, compile it and link it into
  134.     your program.
  135.  
  136.     Note that the substitute getenv has a maximum number of environment
  137.     variables that it will support.  Also, note that getenv() must be
  138.     called to properly initialize the Microsoft C _environ variable
  139.     which may be used by other Microsoft C functions.  This getenv()
  140.     also declares the __child Microsoft C variable which may be useful
  141.     if you discover that this variable is undefined when you link your
  142.     program.
  143.  
  144.  
  145.     =====================================================
  146.      Meridian Ada vs. Microsoft C Run-Time Compatibility
  147.     =====================================================
  148.  
  149.     The following table lists those Microsoft C functions which have
  150.     been tested with the Meridian Ada run-time and notes the degree
  151.     to which each function is deemed compatible with Ada.  Those
  152.     functions listed as "Ok" worked with Ada programs regardless of
  153.     whether the Stack and Data Segments were combined.  Some of the
  154.     "Ok" functions require the special version of getenv().  Those
  155.     functions noted as "NOT compatible with Ada" failed to work (at
  156.     least under some circumstances) in either case.  The rest of the
  157.     functions only work if the Stack and Data Segments are combined.
  158.  
  159.     Note that the testing performed did not necessarily exercise all
  160.     aspects of the C functions, so it is possible that some of the "Ok"
  161.     functions will fail under certain circumstances.
  162.  
  163.  
  164.      Function                Compatibilty
  165.     -------------------------------------------------------------------
  166.       access                 Ok
  167.       assert                 NOT compatible with Ada (if it fails)
  168.       atexit                 Ok
  169.       atof                   Ok
  170.       atoi                   Ok
  171.     -------------------------------------------------------------------
  172.       atol                   Ok
  173.      _bios_disk              Ok
  174.      _bios_equiplist         Ok
  175.      _bios_keybrd            Ok
  176.      _bios_memsize           Ok
  177.     -------------------------------------------------------------------
  178.      _bios_timeofday         Ok
  179.       chdir                  Requires combined Stack and Data
  180.       close                  Ok
  181.       creat                  Ok
  182.       ctime                  Ok
  183.     -------------------------------------------------------------------
  184.      _dos_findfirst          Ok
  185.      _dos_findnext           Ok
  186.       fclose                 Ok
  187.       feof                   Ok
  188.       fflush                 Ok
  189.     -------------------------------------------------------------------
  190.      _ffree                  Ok
  191.       fgetc                  Ok
  192.       fgets                  Ok
  193.      _fmalloc                Ok
  194.       fmod                   Requires combined Stack and Data
  195.     -------------------------------------------------------------------
  196.       fopen                  Ok
  197.       fprintf                Ok
  198.       fputc                  Ok
  199.       fputs                  Ok
  200.       fread                  Ok
  201.     -------------------------------------------------------------------
  202.       free                   Ok
  203.       fscanf (no floats)     Ok
  204.     "    (with floats)   Requires combined Stack and Data
  205.       fseek                  Ok
  206.       ftell                  Ok
  207.       ftime                  Ok
  208.     -------------------------------------------------------------------
  209.       funlink                Ok
  210.       fwrite                 Ok
  211.       getch                  Ok
  212.       getcwd                 Requires combined Stack and Data
  213.       getenv                 Ok, but needs new getenv()
  214.     -------------------------------------------------------------------
  215.       getpid                 Ok
  216.       int86                  Ok, as long as do not depend on DS == SS,
  217.                  else requires combined Stack and Data
  218.       int86x                 Ok
  219.       intdos                 Ok, as long as do not depend on DS == SS,
  220.                  else requires combined Stack and Data
  221.       isalnum                Ok
  222.     -------------------------------------------------------------------
  223.       isalpha                Ok
  224.       isascii                Ok
  225.       isatty                 Ok
  226.       iscntrl                Ok
  227.       isdigit                Ok
  228.     -------------------------------------------------------------------
  229.       isgraph                Ok
  230.       islower                Ok
  231.       isprint                Ok
  232.       ispunct                Ok
  233.       isspace                Ok
  234.     -------------------------------------------------------------------
  235.       isupper                Ok
  236.       isxdigit               Ok
  237.       kbhit                  Ok
  238.       localtime              Ok
  239.       locking                Ok
  240.     -------------------------------------------------------------------
  241.       log                    Requires combined Stack and Data
  242.       lseek                  Ok
  243.       malloc                 Ok
  244.       memcmp                 Ok
  245.       memmove                Ok
  246.     -------------------------------------------------------------------
  247.       memset                 Ok
  248.       mkdir                  Ok
  249.       mktemp                 Ok
  250.       open                   Ok
  251.      _osmajor                Ok
  252.     -------------------------------------------------------------------
  253.       printf                 Ok
  254.       raise                  NOT compatible with Ada
  255.       read                   Ok
  256.       realloc                Ok
  257.       rename                 Ok
  258.     -------------------------------------------------------------------
  259.       rmdir                  Ok
  260.       signal                 Ok, but needs new getenv()
  261.      _splitpath              Ok
  262.       sprintf (no floats)    Ok
  263.      "    (with floats)  Requires combined Stack and Data
  264.       sscanf                 Ok
  265.     -------------------------------------------------------------------
  266.       stat                   Requires combined Stack and Data
  267.       strcat                 Ok
  268.       strchr                 Ok
  269.       strcmp                 Ok
  270.       strcpy                 Ok
  271.     -------------------------------------------------------------------
  272.       stricmp                Ok
  273.       strlen                 Ok
  274.       strncat                Ok
  275.       strncmp                Ok
  276.       strncpy                Ok
  277.     -------------------------------------------------------------------
  278.       strnicmp               Ok
  279.       strpbrk                Ok
  280.       strrchr                Ok
  281.       system                 Ok, but needs new getenv()
  282.       tell                   Ok
  283.     -------------------------------------------------------------------
  284.       time                   Ok
  285.       toascii                Ok
  286.       tolower                Ok
  287.      _tolower                Ok
  288.       toupper                Ok
  289.     -------------------------------------------------------------------
  290.      _toupper                Ok
  291.       unlink                 Ok
  292.       utime                  Requires combined Stack and Data
  293.       write                  Ok
  294.     -------------------------------------------------------------------
  295.  
  296.  
  297.     =============
  298.      END OF FILE
  299.     =============
  300.