home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / emxtutor.zip / emxdevj.zip / emxdev.doc < prev    next >
Text File  |  1996-03-03  |  154KB  |  3,878 lines

  1. ===============================================================================
  2. emxdev.doc        emx 0.9a     APPLICATION DEVELOPER'S GUIDE        05-Dec-1994
  3. ===============================================================================
  4.                                      Copyright (c) 1990-1994 by Eberhard Mattes
  5.  
  6.  
  7. 1 Table of Contents
  8. ===================
  9.  
  10. 1      Table of Contents
  11. 2      Introduction to the emx Application Developer's Guide
  12. 3      Managing bound .exe files with emxbind
  13. 3.1      Creating an .exe file
  14. 3.2      Changing the type of an .exe file
  15. 3.3      Extracting the a.out file from a bound .exe file
  16. 3.4      Displaying and changing the emx options of a bound .exe file
  17. 3.5      Updating emx.exe in a bound .exe file
  18. 3.6      Stripping the symbol table from a bound .exe file
  19. 3.7      Module definition files
  20. 3.7.1      Module definition statements
  21. 3.7.2      Reserved words
  22. 4      Using emx options
  23. 5      More emx utilities
  24. 5.1      updt
  25. 5.2      emximp
  26. 5.2.1      What is an emx import list file?
  27. 5.2.2      Creating an emx import list file from an OMF import library
  28. 5.2.3      Creating an emx import list file from a module definition file
  29. 5.2.4      Creating an emx import library for method (I1)
  30. 5.2.5      Creating an a.out import library for method (I2)
  31. 5.2.6      Creating an OMF import library for method (I3)
  32. 5.2.7      Creating a module definition file for method (I3)
  33. 5.3      emxomf
  34. 5.4      emxomfld
  35. 5.5      emxomfar
  36. 5.6      emxexp
  37. 5.7      emxaout
  38. 5.8      emxcat
  39. 5.9      emxload
  40. 5.10     emxrev
  41. 5.11     listomf
  42. 6      Hints for porting Unix programs to emx
  43. 7      Creating OS/2 programs
  44. 7.1      Calling OS/2 API functions
  45. 7.2      Importing from OS/2 DLLs
  46. 7.3      Creating Presentation Manager applications using ld and emxbind
  47. 7.4      Creating Presentation Manager applications using emxomf and LINK386
  48. 7.5      Creating Workplace Shell applications
  49. 7.6      Creating dynamic link libraries
  50. 7.6.1      Creating dynamic link libraries that use a C library DLL
  51. 7.6.2      Creating custom C runtime DLLs
  52. 7.6.3      Creating C runtime forwarder DLLs
  53. 7.6.4      Creating stand-alone dynamic link libraries
  54. 7.6.5      Creating dynamic link libraries without C runtime environment
  55. 7.6.6      Creating resource DLLs
  56. 7.6.7      Creating dynamic link libraries using C++
  57. 7.7      Using the DLL version of the C library
  58. 7.8      Creating multithread programs
  59. 7.9      Calling 16-bit functions
  60. 8      Customizing
  61. 8.1      Increasing the heap size
  62. 8.2      Increasing the stack size
  63. 8.3      Increasing the number of files
  64. 9      Debugger (DOS)
  65. 10     Executable file format
  66. 11     Known problems
  67.  
  68.  
  69. 2 Introduction to the emx Application Developer's Guide
  70. =======================================================
  71.  
  72. This document describes how to use emx utilities to create programs
  73. running under emx and how to create OS/2 programs with the emx
  74. utilities.  In this document, OS/2 stands for OS/2 2.x and OS/2 3.x.
  75.  
  76. The GNU utilities are described in /emx/doc/gnudev.doc and
  77. /emx/book/gnudev.inf.
  78.  
  79. There are three methods for creating executable files:
  80.  
  81. (E1)    using ld and emxbind
  82.  
  83. (E2)    using emxomf, emxomfld and LINK386, the program will use the
  84.         emx.dll dynamic link library for performing system calls
  85.  
  86. (E3)    using emxomf, emxomfld and LINK386, the program will be linked
  87.         with a system call library (creating a stand-alone application
  88.         or DLL)
  89.  
  90. The assembler creates a Unix-style a.out object file (.o file).  When
  91. using method (E1), .o files created by the assembler are linked by a
  92. Unix-style linker with Unix-style libraries (.a files) to create a
  93. Unix-style a.out file.  Then, emxbind is used to turn this file into
  94. an .exe file that can be executed under both OS/2 and DOS.  Using
  95. method (E1) enables core dumps and fork().  Moreover, programs created
  96. with method (E1) can be debugged using GDB, the GNU debugger.
  97. Programs created using method (E1) use emx (emx.dll under OS/2,
  98. emx.exe under DOS) for system calls.
  99.  
  100. When using method (E2), the .o files created by the assembler are
  101. converted to Object Module Format files (.obj files).  These files are
  102. linked with the OS/2 linker LINK386.  The libraries are .lib files.
  103. emxomfld is a front end to LINK386 which converts the ld command line
  104. to a LINK386 command line.  Programs created with method (E2) cannot
  105. create core dumps, cannot call fork() and cannot be debugged with GDB.
  106. Method (E2) works only under OS/2 and creates programs that work only
  107. under OS/2.  You can use IBM's IPMD debugger to debug programs created
  108. with methods (E2) and (E3).  Files created with method (E2) are
  109. usually smaller.  The emx.dll dynamic link library is used for system
  110. calls.  The -Zomf option of GCC selects method (E2).
  111.  
  112. When using method (E3), the program won't call the emx.dll dynamic
  113. link library.  A system call library (emx emulator) is linked to the
  114. program.  The system call library maps system calls to OS/2 API calls.
  115. Only a subset of the emx system calls is available with method (E3).
  116. For instance, the general terminal interface is not available.
  117. Functions which are not available or are limited with method (E3) are
  118. marked [*] in the library reference.  Use a module definition file and
  119. the STACKSIZE statement to set the stack size.  Alternatively, you can
  120. use the -Zstack option of GCC.  The default stack size is 0x8000
  121. bytes.  Note that the command line arguments and environment pointers
  122. are copied to the stack on startup.
  123.  
  124. The following table summarizes the methods for creating executable
  125. files.
  126.  
  127.   Method                         │  (E1)        │  (E2)       │  (E3)
  128.   ───────────────────────────────┼──────────────┼─────────────┼──────────────
  129.   GCC options                    │              │ -Zomf       │ -Zomf -Zsys
  130.   Object file format             │ a.out        │ OMF         │ OMF
  131.   Object file name extension     │ .o           │ .obj        │ .obj
  132.   Library file name extension    │ .a           │ .lib        │ .lib
  133.   Executable file format         │ LX & a.out   │ LX          │ LX
  134.   Object files converted by      │ N/A          │ emxomf      │ emxomf
  135.   Executable files converted by  │ emxbind      │ N/A         │ N/A
  136.   Linker                         │ ld           │ LINK386     │ LINK386
  137.   Librarian                      │ ar           │ emxomfar    │ emxomfar
  138.   Minimal set of libraries       │ c gcc        │ c gcc       │ c gcc
  139.                                  │              │ emx emx2    │ sys os2
  140.   Methods for importing          │ (I1) (I2)    │ (I3)        │ (I3)
  141.   Can link with OMF libraries    │ NO (note 1)  │ NO (note 1) │ YES
  142.   Debugger                       │ GDB          │ IPMD        │ IPMD
  143.   emx.dll required at run time   │ YES          │ YES         │ NO
  144.   Library support                │ +++          │ ++          │ +
  145.   Core dumps                     │ YES          │ NO          │ NO
  146.   Size overhead                  │ big          │ none        │ (note 2)
  147.   Programs run under DOS         │ YES          │ NO          │ NO
  148.   Can create DLLs                │ YES (note 3) │ YES         │ YES
  149.   EMXOPT environment variable    │ YES          │ YES         │ NO
  150.   -Zmt supported                 │ YES          │ YES         │ YES
  151.   -Zcrtdll supported             │ YES          │ YES         │ NO
  152.  
  153. Note 1:
  154.         import libraries can be used after conversion with emximp
  155.  
  156. Note 2:
  157.         depends on the set of syscalls used by the program
  158.  
  159. Note 3:
  160.         not recommended
  161.  
  162. See also section `Startup modules and libraries' of gnudev.doc.
  163.  
  164. Programs created with method (E1) or (E2) can use emxlibcm.dll or
  165. emxlibcs.dll, dynamic link libraries containing the C library.  Use
  166. the -Zcrtdll option to make a program that uses emxlibcm.dll
  167. (multithread library) or emxlibcs.dll (single-thread library).
  168. Programs which use emxlibcm.dll or emxlibcs.dll don't run under DOS.
  169. For running the application, either emxlibcm.dll or emlibcs.dll
  170. (depending on whether the application is a single-thread or
  171. multithread program) and emx.dll are required.  There are three
  172. advantages of using emxlibcm.dll and emxlibcs.dll:
  173.  
  174. - reduced executable size
  175.  
  176. - reduced memory requirements
  177.  
  178. - programs don't have to be re-linked when the C library is changed.
  179.  
  180. Use -Zomf -Zcrtdll -lwrap -s to minimize the size of the executable
  181. file.
  182.  
  183. Please note that you should change the name of emxlibcm.dll or
  184. emxlibcs.dll if you want to distribute your program with modified
  185. versions of those dynamic link libraries.
  186.  
  187. For using floating point arithmetic, a coprocessor is required (80387
  188. or i486).  All exceptions are masked, that is, computation continues
  189. with +#INF, -#INF, +#NAN or -#NAN after an error.
  190.  
  191. A 387 coprocessor is not required for doing floating point arithmetic
  192. under OS/2.  Under DOS, a 387 coprocessor (or i486) is required for
  193. doing floating point arithmetic.
  194.  
  195. A core dump file will be written if a program is terminated by signal
  196. SIGSEGV (protection violation), SIGILL (illegal instruction), SIGABRT
  197. (abort()), SIGFPE (floating point exception), SIGTRAP (breakpoint),
  198. SIGBUS, SIGEMT, SIGQUIT, or SIGSYS.  You can later debug the program
  199. using the .exe file and the core dump file.  The name of the core dump
  200. file is core, and it is put into the current working directory.  Use
  201. the -c emx option to suppress writing a core dump file.  When linking
  202. a program using method (E2) or (E3), core dump files are not written
  203. by that program.
  204.  
  205. OS/2 and DOS support both the forward slash and the backslash for
  206. separating directories.  Unix utilities usually treat the backslash
  207. character specially, therefore you should use the forward slash.  This
  208. document uses forward slash unless an OS/2 or DOS command is shown
  209. (cmd.exe and command.com use backslashes).
  210.  
  211. File name extensions (the list is incomplete):
  212.  
  213.     a                       Unix-style library (archive)
  214.     bat                     DOS batch file
  215.     c                       C source file
  216.     cc                      C++ source file
  217.     cmd                     OS/2 batch file
  218.     cpp                     C++ source file
  219.     cxx                     C++ source file
  220.     def                     Module definition file
  221.     doc                     Documentation file
  222.     dll                     Dynamic link library
  223.     dvi                     Device independent file, created by TeX
  224.     exe                     Executable file
  225.     h                       C include file (header file)
  226.     i<digits>               Split GNU info file
  227.     imp                     emx import list file
  228.     inf                     GNU info file (use `info' for reading) or
  229.                             OS/2 on-line book (use `VIEW' for reading)
  230.     lib                     OMF library
  231.     m                       Objective C source file
  232.     map                     Map file, created by LINK386 or emxbind
  233.     o                       Object file (Unix style, a.out)
  234.     obj                     Object file (OMF)
  235.     rc                      Resource script file
  236.     res                     Binary resource file
  237.     s                       Assembler source file
  238.     tex                     TeX (or texinfo) source file
  239.  
  240. Directories:
  241.  
  242.     /emx                    Main directory, contains no files
  243.     /emx/bin                Executable files and batch files
  244.     /emx/dll                OS/2 DLL files
  245.     /emx/doc                Documentation
  246.     /emx/include            Header files (C language)
  247.     /emx/lib                Libraries
  248.     /emx/lib/mt             Multithread libraries
  249.     /emx/lib/st             Single-thread libraries
  250.     /emx/new                New .exe files created by the makebin batch file
  251.     /emx/samples            Sample programs
  252.     /emx/src                Source code
  253.     /emx/test               Test programs
  254.  
  255.  
  256. 3 Managing bound .exe files with emxbind
  257. ========================================
  258.  
  259. The emxbind utility is used to create and modify bound .exe files
  260. using method (E1).  The action to be performed is specified by a
  261. command letter which looks like a command line option.
  262.  
  263.  
  264. 3.1 Creating an .exe file
  265. -------------------------
  266.  
  267. emxbind binds emx.exe and an emx executable file into one executable
  268. file which runs both under OS/2 (6.167 or later) and DOS.
  269.  
  270. Usage:
  271.  
  272.     emxbind [-b] [<emxbind_options>]
  273.             <emx>[.exe] <input_file> [<output_file>[.exe]] [<emx_options>]
  274.  
  275.     emxbind [-b] [<emxbind_options>] <input_file> [<emx_options>]
  276.  
  277. <emxbind_options>
  278.  
  279.     The following options can be given to emxbind.  They must appear
  280.     at the beginning of the emxbind arguments.
  281.  
  282.     -b (optional)
  283.             this emxbind command means `bind' and is the default.  If
  284.             you want to use the -s option (strip symbol table), -b
  285.             cannot be omitted, that is, you should type -bs
  286.             (otherwise, emxbind would perform the -s command described
  287.             below)
  288.  
  289.     -c[<core_file>]
  290.             combine an a.out file and a core dump file created for
  291.             that a.out file into one program.  This can be used to
  292.             create a a program with preloaded data.  Note that the
  293.             .exe file will waste a lot of disk space.  If you don't
  294.             enter <core_file>, core is used
  295.  
  296.     -d[<def_file>]
  297.             read the module definition file <def_file>.  The default
  298.             extension is .def.  If <def_file> is omitted, <input_file>
  299.             with .def extension is used instead.  See section 3.7 for
  300.             details on module definition files
  301.  
  302.     -E<dll>
  303.             use <dll>.dll instead of emx.dll.  This option is used for
  304.             referencing an alternate, renamed emx.dll.  If -E<dll> is
  305.             not used, emxbind takes the name of the DLL from the
  306.             EMXBIND_DLL environment variable.  For instance, to use
  307.             myx.dll instead of emx.dll, use the following command:
  308.  
  309.                 set emxbind_dll=myx
  310.  
  311.             If both -E<dll> and EMXBIND_DLL are not set, emxbind uses
  312.             emx.dll
  313.  
  314.     -f      set application type to `full screen'.  See also the -e
  315.             command
  316.  
  317.     -h<heap_size>
  318.             set heap size for OS/2.  This is the space available for
  319.             allocation by malloc() and _tmalloc().  The number is
  320.             given in decimal, octal or hexadecimal, using C notation.
  321.             The heap size is specified in megabytes (1 through 512).
  322.             The default value is 32.  For DOS, the heap size is
  323.             controlled by the -s# emx option (see section 4)
  324.  
  325.     -k<stack_size>
  326.             set the size of the stack object of the executable file.
  327.             The number is given in decimal, octal or hexadecimal,
  328.             using C notation.  The stack size set by this option is
  329.             used under OS/2.  The stack size is given in KByte, the
  330.             default is 8192 (8 MByte).  The stack size must be between
  331.             20 and 524288 (512 MByte).  The stack size should not be
  332.             less than 32 KByte.  You should not use -k without -b, as
  333.             a -k command is planned for a future version of emxbind
  334.  
  335.     -m<map_file>
  336.             write the map file <map_file>.  The format is simular to
  337.             that of map files written by LINK386.  The default
  338.             extension is `map'.
  339.  
  340.     -p      set application type to `Presentation Manager'.  See also
  341.             the -e command
  342.  
  343.     -q      don't display emxbind banner line
  344.  
  345.     -r<res_file>
  346.             put resources from binary resource file <res_file> (no
  347.             default extension) into the .exe file.  Use rc -r to
  348.             create the binary resource file.  Do not use rc to put the
  349.             resources into the .exe file
  350.  
  351.     -s      strip symbols (requires -b).  You can also strip the
  352.             symbol table before creating the .exe file by calling
  353.             strip.exe or after creating the .exe file by using the -s
  354.             command of emxbind
  355.  
  356.     -v      display more information: list resources, display path
  357.             name of emxl.exe unless given on command line, display the
  358.             statements in the module definition file that are ignored
  359.  
  360.     -w      set application type to `windowed' (default).  See also
  361.             the -e command
  362.  
  363.     Only one of the options -f, -p and -w can be used.  If none of
  364.     these options is used, the application type is taken from the NAME
  365.     statement of the module definition file (-d option).  If no module
  366.     definition file is used, -w is the default.
  367.  
  368. <emx> (optional if no output file is given)
  369.  
  370.     path name of emx (default extension: .exe), that is emx.exe,
  371.     emxd.exe or emxl.exe.  Using emxl.exe is recommended.  If this
  372.     argument is omitted (in this case the <output_file> argument must
  373.     be omitted as well), the filename from the STUB statement of the
  374.     module definition file is used.  emxbind searches the directories
  375.     listed in the EMXPATH and PATH environment variables for that
  376.     file.  If no module definition file is used or if the STUB
  377.     statement isn't used, the file /emx/bin/emxl.exe will be used.  If
  378.     that file doesn't exist, emxbind searches the directories listed
  379.     in the EMXPATH and PATH environment variables for emxl.exe.  If
  380.     that fails, emxl.exe is taken from the current working directory.
  381.     If the -v option is given, the path name of emxl.exe will be
  382.     displayed unless a STUB statement is present
  383.  
  384. <input_file>
  385.  
  386.     path name of the a.out file to be read
  387.  
  388. <output_file> (optional)
  389.  
  390.     path name of the bound executable file.  The default extension is
  391.     .exe unless the LIBRARY statement is used in the module definition
  392.     file.  If LIBRARY is used in the module definition file (that is,
  393.     when you are creating a dynamic link library), the default
  394.     extension is .dll.  If the <output_file> parameter is omitted, the
  395.     <input_file> parameter will be used instead (do not specify an
  396.     extension for the input file to avoid overwriting the input
  397.     file!).  Moreover, the output file name (or <input_file>, if
  398.     <output_file> is omitted) sans directory part and extension is
  399.     used as module name for the .exe file unless a module name is
  400.     defined with a NAME or LIBRARY statement in the module definition
  401.     file
  402.  
  403. <emx_options> (optional)
  404.  
  405.     emx options to be used when running the bound program.  These
  406.     options will be examined before those given in EMXOPT.  emxbind
  407.     does not completely check the validity of the options.  See
  408.     section 4 for details.
  409.  
  410.     -a*     [DOS] Enable dangerous features
  411.  
  412.     -c      Disable core dumps caused by signals and exceptions
  413.  
  414.     -d      [DOS] Don't use extended memory
  415.  
  416.     -e      [DOS] Redirect standard error to standard output
  417.  
  418.     -h#     Set file handle limit
  419.  
  420.     -n      [OS/2] Suppress exception popups
  421.  
  422.     -o      [DOS] Send the register dump of an exception to stdout
  423.             instead of the CON device
  424.  
  425.     -p      [DOS] Don't use low memory (lower Megabyte)
  426.  
  427.     -q      Quote all arguments passed to child processes
  428.  
  429.     -s#     [DOS] Set stack size (KByte)
  430.  
  431.     -t      Truncate file names to 8.3
  432.  
  433.     -x      [OS/2] Don't suppress wildcard expansion and response
  434.             files if the `MKS Korn shell' method of passing command
  435.             line arguments is used
  436.  
  437.     -C#     [DOS] Commit memory
  438.  
  439.     -E      Run debuggee in same session
  440.  
  441.     -K      Avoid using DosKillThread
  442.  
  443.     -L      [DOS] Disable preloading of pages from the executable file
  444.  
  445.     -Z      [DOS] TODO
  446.  
  447. Example:
  448.  
  449.     emxbind \emx\bin\emxl myprog -s16384 -p
  450.  
  451. This example will bind myprog and emxl.exe into myprog.exe.  The stack
  452. size will be set to 16384 KByte (under DOS) if this value is not
  453. overridden by EMXOPT when myprog.exe is run.  The program will be able
  454. to run DOS programs.  This example can be abbreviated to
  455.  
  456.     emxbind myprog -s16384 -p
  457.  
  458. The bound program does not run under DOS versions prior to 3.0.  emx
  459. options cannot be put onto the command line; use EMXOPT instead.
  460.  
  461. Do not compress the bound executable with a program like TINYPROG,
  462. PKLITE, or LZEXE, which makes the program uncompress itself when
  463. started.
  464.  
  465. emx can be used for running bound .exe files created using the same
  466. version of emx.  spawn*() and exec*() also work on bound .exe files.
  467.  
  468. The GNU programs GDB, nm, objdump and size (but not strip) have been
  469. modified to work with bound .exe files.
  470.  
  471. You can use the emx loader emxl.exe to save disk space.  When the
  472. bound executable is run, emxl.exe will load emx.exe to run the
  473. program.  There is a small speed penalty due to locating and loading
  474. emx.exe.
  475.  
  476. If the EMX environment variable is set, emxl.exe first tries to load
  477. the file specified by that variable.  Use
  478.  
  479.     SET EMX=c:\emx\bin\emx.exe
  480.  
  481. to speed up locating emx.exe.  You can also use emxd.exe this way.
  482.  
  483. If the EMX environment variable is not set or the emx.exe file
  484. specified by EMX could not be loaded, emxl.exe will try emx.exe in the
  485. current working directory, then emx.exe in all directories listed in
  486. the PATH environment variable.
  487.  
  488.  
  489. 3.2 Changing the type of an .exe file
  490. -------------------------------------
  491.  
  492. You can change the application type after creating an .exe file with
  493. emxbind.  For instance, this can be used after creating an .exe file
  494. with GCC.  Exactly one of the options -f, -p and -w must be given.
  495. Note that you can set the application type while creating an .exe file
  496. with the -b command.
  497.  
  498. Usage:
  499.  
  500.     emxbind -e <emxbind_options> <program_file>[.exe]
  501.  
  502. <emxbind_options>
  503.  
  504.     The following options can be given to emxbind.  They must appear
  505.     at the beginning of the emxbind arguments.
  506.  
  507.     -e      change the type of an .exe file
  508.  
  509.     -f      set application type to `full screen'
  510.  
  511.     -p      set application type to `Presentation Manager'
  512.  
  513.     -q      don't display emxbind banner line
  514.  
  515.     -w      set application type to `windowed'
  516.  
  517.     Exactly one of the options -f, -p and -w must be given.
  518.  
  519. <program_file>
  520.  
  521.     path name of the bound .exe file to be changed.  The default
  522.     extension is .exe
  523.  
  524. Example:
  525.  
  526.     gcc -o myprog.exe myprog.c
  527.     emxbind -ep myprog
  528.  
  529. Alternatively, you can create a file named myprog.def containing
  530.  
  531.     NAME WINDOWAPI
  532.  
  533. and invoke GCC with the following command line:
  534.  
  535.     gcc -o myprog.exe myprog.def
  536.  
  537.  
  538. 3.3 Extracting the a.out file from a bound .exe file
  539. ----------------------------------------------------
  540.  
  541. Usage:
  542.  
  543.     emxbind -x [<emxbind_options>] <input_file>[.exe] <output_file>
  544.  
  545. <emxbind_options>
  546.  
  547.     The following options can be given to emxbind.  They must appear
  548.     at the beginning of the emxbind arguments.
  549.  
  550.     -q      don't display emxbind banner line
  551.  
  552.     -x      extract a.out file
  553.  
  554. <input_file>
  555.  
  556.     path name of a bound .exe file to be read.  The default extension
  557.     is .exe
  558.  
  559. <output_file>
  560.  
  561.     path name of the a.out file to be created
  562.  
  563. After extracting the a.out file from an .exe file which was created
  564. using a core dump file, you should not use that file for creating an
  565. .exe file.  Use the -u command if you want to replace emx.exe,
  566. emxl.exe or emxd.exe contained in a bound .exe file.
  567.  
  568. The relocation information is removed by emxbind while binding an .exe
  569. file.  Therefore, the a.out file extracted from a bound .exe file does
  570. not include relocation information.  This applies to dynamic link
  571. libraries and a.out files linked with the -R option of ld.  Import
  572. information will be lost.
  573.  
  574.  
  575. 3.4 Displaying and changing the emx options of a bound .exe file
  576. ----------------------------------------------------------------
  577.  
  578. emxbind also can display or change the emx options of a bound .exe
  579. file.  Note that the -i option was called -s in previous versions of
  580. emxbind.
  581.  
  582. Usage (showing options):
  583.  
  584.     emxbind -i [<emxbind_options>] <program_file>[.exe]
  585.  
  586. Usage (altering options):
  587.  
  588.     emxbind -a [<emxbind_options>] <program_file>[.exe] [<emx_options>]
  589.  
  590. <emxbind_options>
  591.  
  592.     The following options can be given to emxbind.  They must appear
  593.     at the beginning of the emxbind arguments.
  594.  
  595.     -a      change emx options
  596.  
  597.     -q      don't display emxbind banner line
  598.  
  599. <program_file>
  600.  
  601.     path name of a bound .exe file to be read or changed,
  602.     respectively.  The default extension is .exe
  603.  
  604. <emx_options>
  605.  
  606.     remove the options if empty, otherwise put these options into the
  607.     .exe file (see also the -b command)
  608.  
  609.  
  610. 3.5 Updating emx.exe in a bound .exe file
  611. -----------------------------------------
  612.  
  613. emxbind also can replace the DOS loader in an existing bound .exe
  614. file.  You should use this only if you can't rebuild the .exe file
  615. because you don't have the a.out file.  Note that you usually have to
  616. re-link your program when using a new release of emx due to
  617. differences in the system interface.
  618.  
  619. Usage:
  620.  
  621.     emxbind -u [<emxbind_options>] <emx>[.exe] <program_file>[.exe]
  622.  
  623. <emxbind_options>
  624.  
  625.     The following options can be given to emxbind.  They must appear
  626.     at the beginning of the emxbind arguments.
  627.  
  628.     -q      don't display emxbind banner line
  629.  
  630.     -u      replace DOS loader
  631.  
  632. <emx>
  633.  
  634.     path name of emxd.exe, emx.exe or emxl.exe.  This DOS loader is
  635.     copied to the <program_file>.  The default extension is .exe.
  636.  
  637. <program_file>
  638.  
  639.     path name of the bound .exe file to be changed.  The default
  640.     extension is .exe.  Better make a backup copy of the file before
  641.     using emxbind -u.
  642.  
  643.  
  644. 3.6 Stripping the symbol table from a bound .exe file
  645. -----------------------------------------------------
  646.  
  647. emxbind can also be used to remove the symbol table from a bound .exe
  648. file strip.exe cannot be used on .exe files).  You can also strip the
  649. symbol table while creating the .exe file by using the -s option with
  650. the -b command.
  651.  
  652. Usage:
  653.  
  654.     emxbind -s [<emxbind_options>] <program_file>[.exe]
  655.  
  656. <emxbind_options>
  657.  
  658.     The following options can be given to emxbind.  They must appear
  659.     at the beginning of the emxbind arguments.
  660.  
  661.     -q      don't display emxbind banner line
  662.  
  663.     -s      strip symbol table
  664.  
  665. <program_file>
  666.  
  667.     path name of the bound .exe file to be changed.  The default
  668.     extension is .exe.  If you cannot recreate the .exe file, make a
  669.     backup copy of the file before using emxbind -s.
  670.  
  671.  
  672. 3.7 Module definition files
  673. ---------------------------
  674.  
  675. emxbind reads LINK386 compatible module definition files.  In the
  676. following list of available module definition statements, optional
  677. parts are enclosed in brackets.  Case is ignored for keywords (though
  678. IBM says you should use upper case for keywords).  See below a list of
  679. reserved words.  You cannot use keywords for function names, module
  680. names etc.  In case of a conflict, enclose the offending name in
  681. single or double quotes.  Quotes are also required if a name contains
  682. a special character such as blank, tab, `@', `=', `.' or `;'.  Lines
  683. starting with a semicolon are treated as comment lines and are
  684. completely ignored.  Numbers can be given in decimal, octal or
  685. hexadecimal, using C syntax.
  686.  
  687.  
  688. 3.7.1 Module definition statements
  689. ----------------------------------
  690.  
  691. CODE ...
  692.  
  693.     Define default attributes for code segments.  Ignored by emxbind.
  694.  
  695. DATA ...
  696.  
  697.     Define default attributes for data segments.  Ignored by emxbind.
  698.  
  699. DESCRIPTION '<text>'
  700.  
  701.     Put a text into the .exe or .dll file.  The text must be enclosed
  702.     in single or double quotes.  To include a single quote in single
  703.     quotes or a double quote in double quotes, simply enter the quote
  704.     twice.  The text will be put at the start of the nonresident name
  705.     table, which is put at the end of the .exe or .dll file.
  706.     Typically, DESCRIPTION is used to insert a copyright message.
  707.  
  708.     Example:
  709.  
  710.         DESCRIPTION 'HAL9000 -- Copyright (c) 2001 by Space Odyssey Inc.'
  711.  
  712. EXETYPE ...
  713.  
  714.     Identifies the operating system.  Ignored by emxbind (the
  715.     operating system is always OS/2).
  716.  
  717. EXPORTS <entryname> [=<internalname>] [@<ordinal> [RESIDENTNAME|NONAME]]
  718.  
  719.     Make functions and variables visible outside the .exe or .dll
  720.     file.  All entry points of a dynamic link library must be exported
  721.     using EXPORTS.  Exporting entry points of .exe files is less
  722.     common.
  723.  
  724.     Following the EXPORTS keyword, you can enter any number of
  725.  
  726.         <entryname> [=<internalname>] [@<ordinal> [RESIDENTNAME|NONAME]]
  727.  
  728.     lines, one for each entrypoint.  <entryname> is the name of the
  729.     function as made visible outside of the .exe or .dll file.
  730.     <entryname> is always converted to upper case.  <internalname> is
  731.     the name of the function as defined in your program.  If
  732.     =<internalname> is omitted, it is assumed to be identical to
  733.     <entryname>.  <internalname> is case sensitive.  Exported
  734.     functions not only have a name (<entryname>), they also have an
  735.     ordinal number, the position within the name table.  Using ordinal
  736.     numbers when importing saves space and is supposed to be faster.
  737.     You can assign a specific ordinal number to an exported function
  738.     by entering @<ordinal>.  <ordinal> is the ordinal number to be
  739.     used (1 through 65535).  If @<ordinal> is not given, emxbind
  740.     chooses an unused ordinal number, but you won't know the ordinal
  741.     number and therefore cannot use it for importing.  If @<ordinal>
  742.     is specified, <entryname> is by default put into the nonresident
  743.     name table, which is not kept in memory while the .exe or .dll
  744.     file is running or loaded, respectively.  This saves space.  To
  745.     put <entryname> into the resident name table, enter RESIDENTNAME.
  746.     Then, OS/2 will keep <entryname> in memory while the .exe or .dll
  747.     file is running or loaded, respectively.  This saves time.
  748.     Example:
  749.  
  750.         EXPORTS my_qsort=qsort1 @1 RESIDENTNAME
  751.                 my_hsort
  752.  
  753.     Use NONAME to avoid putting <entryname> into the name tables.
  754.     This may be required for dynamic link libraries which export many
  755.     functions and variables.
  756.  
  757. HEAPSIZE <number>
  758.  
  759.     Set the size of the local heap.  <number> can be MAXVAL as well.
  760.     Ignored by emxbind.
  761.  
  762. IMPORTS [<internalname>=]<modulename>.<entry>
  763.  
  764.     Define imported symbols.  Ignored by emxbind.  Use emximp instead.
  765.  
  766. LIBRARY [<libraryname>] [<initialization>] [<termination>]
  767.  
  768.     Create dynamic link library (.dll file).  If LIBRARY is used, it
  769.     must be the first statement of the module definition file.
  770.     <libraryname> is the name of the module.  The name is the first
  771.     entry of the resident name table and must match the base name of
  772.     the .dll file.  If <libraryname> is not specified, the name of the
  773.     output file sans directory and extension is used.
  774.     <initialization> can be either INITGLOBAL or INITINSTANCE.
  775.     INITGLOBAL causes the library initialization function to be called
  776.     when the DLL is initially loaded into memory.  INITINSTANCE causes
  777.     the library initialization function to be called each time a
  778.     process loads the DLL and each time a process referencing the DLL
  779.     is started.  <termination> can be either TERMGLOBAL or
  780.     TERMINSTANCE.  TERMGLOBAL causes the library termination function
  781.     to be called when the DLL is no longer used by any process.
  782.     TERMINSTANCE causes the library termination function to be called
  783.     each time a process frees the DLL and each time a process
  784.     referencing the DLL terminates.
  785.  
  786.     Currently, TERMGLOBAL seems to cause the termination function not
  787.     to be called at all.
  788.  
  789.     See _DLL_InitTerm() for details about the library initialization
  790.     function and the library termination function.
  791.  
  792.     If <initialization> and <termination> are omitted, INITGLOBAL and
  793.     TERMGLOBAL are used.  If one of <initialization> and <termination>
  794.     is specified, the other one defaults to an appropriate value, as
  795.     shown by the following table:
  796.  
  797.                               │ (no termination) │ TERMGLOBAL   │ TERMINSTANCE
  798.         ──────────────────────┼──────────────────┼──────────────┼─────────────
  799.           (no initialization) │ INITGLOBAL       │ INITGLOBAL   │ INITINSTANCE
  800.                               │ TERMGLOBAL       │ TERMGLOBAL   │ TERMINSTANCE
  801.         ──────────────────────┼──────────────────┼──────────────┼─────────────
  802.           INITGLOBAL          │ INITGLOBAL       │ INITGLOBAL   │ INITGLOBAL
  803.                               │ TERMGLOBAL       │ TERMGLOBAL   │ TERMINSTANCE
  804.         ──────────────────────┼──────────────────┼──────────────┼─────────────
  805.           INITINSTANCE        │ INITINSTANCE     │ INITINSTANCE │ INITINSTANCE
  806.                               │ TERMINSTANCE     │ TERMGLOBAL   │ TERMINSTANCE
  807.  
  808.     Examples:
  809.  
  810.         LIBRARY
  811.         LIBRARY INITINSTANCE
  812.         LIBRARY mylib
  813.         LIBRARY mylib INITINSTANCE TERMGLOBAL
  814.  
  815. NAME [<appname>] [<apptype>] [NEWFILES]
  816.  
  817.     Create an .exe file.  If NAME is used, it must be the first
  818.     statement.  <appname> is the name of the module.  The name is the
  819.     first entry of the resident name table.  If <appname> is not
  820.     specified, the name of the output file sans directory and
  821.     extension is used.  <apptype> can be one of the following
  822.     keywords:
  823.  
  824.     NOTWINDOWCOMPAT
  825.             the program will run full-screen
  826.  
  827.     WINDOWAPI
  828.             the program is a Presentation Manager application
  829.  
  830.     WINDOWCOMPAT
  831.             the program will run in a text window
  832.  
  833.     The default is WINDOWCOMPAT.  <apptype> can be overridden on the
  834.     emxbind command line with the -f, -p and -w options.
  835.  
  836.     The NEWFILES keyword (LONGNAMES is an alias) is ignored, emx
  837.     applications always use long file names.  Examples:
  838.  
  839.         NAME WINDOWAPI
  840.         NAME myprog
  841.         NAME myprog NOTWINDOWCOMPAT
  842.  
  843. OLD '<library>'
  844.  
  845.     Preserve import information.  Ignored by emxbind.
  846.  
  847. PROTMODE
  848.  
  849.     Executable runs only in protected mode.  Ignored by emxbind.
  850.  
  851. SEGMENTS ...
  852.  
  853.     Set segment attributes.  Ignored by emxbind.
  854.  
  855. STACKSIZE <number>
  856.  
  857.     Set the stack size for OS/2 programs.  Always use this statement
  858.     as the default is too small.  The stack size should be 32768 or
  859.     more.  The stack size for DOS programs is controlled by the -s#
  860.     emx option.
  861.  
  862. STUB '<program>'
  863.  
  864.     Use <program> as DOS executable file.  This program is run if the
  865.     .exe or .dll file is started under DOS.  <program> is sought in
  866.     the directories listed in the EMXPATH and PATH environment
  867.     variables unless the filename includes a directory.  If the <emx>
  868.     argument is given on the emxbind command line, the STUB statement
  869.     is ignored.  If <emx> is not given and the STUB statement is not
  870.     present, \emx\bin\emxl.exe is used.  If that file does not exist,
  871.     emxbind searches the directories listed in the EMXPATH and PATH
  872.     environment variables and the current working directory for
  873.     emxl.exe.  Example:
  874.  
  875.         STUB 'emx.exe'
  876.  
  877.  
  878. 3.7.2 Reserved words
  879. --------------------
  880.  
  881. The following words are reserved.  You cannot use them as function
  882. names, module names, etc. unless enclosed in quotes.
  883.  
  884.     ALIAS                    INVALID                  PHYSICAL
  885.     BASE                     IOPL                     PRELOAD
  886.     CLASS                    LIBRARY                  PRIVATE
  887.     CODE                     LOADONCALL               PRIVATELIB
  888.     CONFORMING               LONGNAMES                PROTECT
  889.     CONTIGUOUS               MAXVAL                   PROTMODE
  890.     DATA                     MIXED1632                PURE
  891.     DESCRIPTION              MOVABLE                  READONLY
  892.     DEV386                   MOVEABLE                 READWRITE
  893.     DEVICE                   MULTIPLE                 REALMODE
  894.     DISCARDABLE              NAME                     RESIDENT
  895.     DOS4                     NEWFILES                 RESIDENTNAME
  896.     DYNAMIC                  NODATA                   SEGMENTS
  897.     EXECUTEONLY              NOEXPANDDOWN             SHARED
  898.     EXECUTE-ONLY             NOIOPL                   SINGLE
  899.     EXECUTEREAD              NONAME                   STACKSIZE
  900.     EXETYPE                  NONCONFORMING            STUB
  901.     EXPANDDOWN               NONDISCARDABLE           SWAPPABLE
  902.     EXPORTS                  NONE                     TERMGLOBAL
  903.     FIXED                    NONPERMANENT             TERMINSTANCE
  904.     HEAPSIZE                 NONSHARED                UNKNOWN
  905.     HUGE                     NOTWINDOWCOMPAT          VIRTUAL
  906.     IMPORTS                  OBJECTS                  WINDOWAPI
  907.     IMPURE                   OLD                      WINDOWCOMPAT
  908.     INCLUDE                  ORDER                    WINDOWS
  909.     INITGLOBAL               OS2
  910.     INITINSTANCE             PERMANENT
  911.  
  912.  
  913. 4 Using emx options
  914. ===================
  915.  
  916. Under DOS, emx options can be given on the emx command line:
  917.  
  918.     emx [<options>] <program> [<arguments>]
  919.  
  920. where <program> is either a bound .exe file or an a.out file.  Options
  921. marked [*] for DOS below affect only the emx program given on the
  922. command line.  All other options are `sticky' and apply to all
  923. processes started by that instance of emx.  Options of this type put
  924. by emxbind into the executable file are ignored when running an emx
  925. program by running emx.  If you need one of these options, put them on
  926. the emx command line.
  927.  
  928. Under OS/2 and DOS, emx options can also be given in the EMXOPT
  929. environment variable.  These options apply to all processes.
  930.  
  931. Moreover, you can use emxbind to put emx options into the executable
  932. file (see above for restrictions).  In this case, options marked [*]
  933. below apply only to the program for which they have been set.  All
  934. other options are `sticky' and apply to all processes started by the
  935. current instance of emx (unless you are running emx manually as shown
  936. above).
  937.  
  938. Options given on the emx command line override options given in
  939. EMXOPT.  Options given in EMXOPT override options stored in the
  940. executable file.
  941.  
  942. The following emx options are available:
  943.  
  944. -a*     [DOS*] Enable dangerous features: -ac makes data and the stack
  945.         executable, -am enables _memaccess(), -aw enables write access
  946.         to all memory areas, -ai enables _portaccess().  By default,
  947.         only the .text section is executable, _memaccess() and
  948.         _portaccess() are disabled.  You can combine letters: for
  949.         instance, -aim enables both _memaccess() and _portaccess(),
  950.         -aciw enables all dangerous features.  Note: -ac is
  951.         automatically set in programs run with P_DEBUG mode of
  952.         spawn*().  This is used to be able to call functions of the
  953.         debuggee by putting code into the stack.
  954.  
  955. -c      [*] Disable core dumps caused by signals.  Core dumps created
  956.         by _core() are not disabled by -c.
  957.  
  958. -d      [DOS] Don't use extended memory.  Only low memory (below 1
  959.         MByte) will be used.  Use this if you suspect a bug in the
  960.         extended memory management of emx or a bug in an extended
  961.         memory manager.
  962.  
  963. -e      [DOS*] Redirect the standard error handle (2) to standard
  964.         output (1)
  965.  
  966. -h#     [DOS, OS/2*] Set file handle limit.  Under DOS, the DOS file
  967.         handle limit for the emx process is set to #.  The number #
  968.         must be between 10 and 255.  This option is ignored for DOS
  969.         versions earlier than 3.30.  This option does not change the
  970.         emx limit for the number of files per process -- that limit is
  971.         always 40.  Under OS/2, the file handle limit for the current
  972.         process is set to #.  The number # must be between 10 and 255.
  973.  
  974. -m#     [DOS] Select machine.  -m1 selects Fujitsu FMR70 (not
  975.         implemented yet), -m2 selects NEC PC-98 (not implemented yet),
  976.         -m3 selects Inboard 386/PC.
  977.  
  978. -o      [DOS] Send the register dump of an exception to stdout.
  979.         Without -o, the register dump is sent to the CON device.  You
  980.         need -o for redirecting the register dump to a file.
  981.  
  982. -p      [DOS] Don't use low memory (lower Megabyte); use this if the
  983.         program runs a DOS program; not required for running emx
  984.         programs (either a.out and bound .exe) unless command.com is
  985.         called to run the programs (as done by the system() library
  986.         function).  If -p is not given, low memory will be used and
  987.         there won't be enough low memory for running DOS programs.
  988.  
  989. -q      [*] All command line arguments passed to child processes will
  990.         be quoted unconditionally, that is, wildcard expansion and
  991.         response files won't work in child processes of processes for
  992.         which the -q option is in effect.
  993.  
  994. -r*     [*] Prepend drive letter * to absolute path names.  If a path
  995.         name starts with / but does not start with //, /dev/ or
  996.         /pipe/, * followed by a colon will be prepended.  If -rd has
  997.         been given, the filename \mydir\abc will be translated to
  998.         d:\mydir\abc.  Note: this option can cause unexpected effects.
  999.  
  1000. -s#     [DOS*] Set stack size (KByte), minimum: -s8, maximum:
  1001.         -s524288, default: -s8192.  Note that under DOS, the heap and
  1002.         the stack share the same memory area.  The pages not used by
  1003.         the stack are available for the heap.  Therefore, you should
  1004.         use -s# if you need more than 8 MByte of heap and stack.
  1005.  
  1006. -t      [*] Truncate file names to 8.3 format.  Each part of a
  1007.         pathname is truncated to 8.3 format by taking the first 8
  1008.         characters before the dot and the first 3 characters after the
  1009.         dot.  This is useful to compile programs on a FAT filesystem
  1010.         with minimal changes.
  1011.  
  1012. -x      [OS/2] Don't suppress wildcard expansion and response files if
  1013.         the `MKS Korn shell' method of passing command line arguments
  1014.         is used.
  1015.  
  1016. -C#     [DOS*] Commit memory.  By default, memory is allocated as soon
  1017.         as a page is accessed.  If there isn't enough memory (and swap
  1018.         space), the process is terminated.  With -C#, memory is
  1019.         allocated when creating the process and when enlarging the
  1020.         data segment with brk() and sbrk().  If there isn't enough
  1021.         memory (and swap space), the process brk(), sbrk(), malloc()
  1022.         etc. return an error.  The number # specifies how many KByte
  1023.         should be allocated for the stack.  If # is omitted, 0 is
  1024.         used.  The -C# option is not yet completely implemented -- if
  1025.         an allocation request succeeds partly, the allocated pages are
  1026.         not freed.
  1027.  
  1028. -E      [OS/2*] Run debuggee in same session.  By default, a debugger
  1029.         for emx (such as GDB) runs the child process in a separate
  1030.         session.  The P_NOSESSION flag of spawn*() has the same effect
  1031.         as -E.
  1032.  
  1033.         [DOS] Don't check for 387 coprocessor.  Assume no coprocessor
  1034.         is present.  This option is used for testing.
  1035.  
  1036. -F      [DOS] Use fast A20 switching.  By default, the standard method
  1037.         for switching A20 is used.  A faster method is available on
  1038.         some machines.  That method will be used if the -F option is
  1039.         present.
  1040.  
  1041. -K      [OS/2*] Don't use DosKillThread.  Due to bugs in OS/2,
  1042.         DosKillThread may cause problems.  emx.dll automatically
  1043.         avoids using DosKillThread for OS/2 2.1 and older.  For OS/2
  1044.         2.11 and later, you can use the -K option to disable usage of
  1045.         DosKillThread.  Currently, DosKillThread is used only if
  1046.         select() is applied to socket handles
  1047.  
  1048. -L      [DOS*] Disable preloading of pages from the executable file.
  1049.         By default, the complete code and data areas are read into
  1050.         memory before a program is started.  If there is not enough
  1051.         memory, no pages are preloaded.  With -L (or if not enough
  1052.         memory is available), pages are loaded as soon as they are
  1053.         accessed.
  1054.  
  1055. -O      [DOS] Override XMS version check.  By default, emx checks for
  1056.         XMS version number 2.00 or later and for XMS driver revision
  1057.         2.06 or later, as older himem.sys drivers don't work
  1058.         correctly.  You can override this check by giving the -O
  1059.         option (for drivers using a different revision numbering
  1060.         scheme), but emx may not work with your XMS driver, anyway.
  1061.         Actually, emx has not been tested with himem.sys 2.05; 2.04
  1062.         fails, 2.06 works.
  1063.  
  1064. -P      [DOS] Use patched code for A20 switching.  There is a patch
  1065.         area in emx.exe where you can put alternate code for switching
  1066.         A20.  The -P option enables the code in the patch area.
  1067.  
  1068. -S#     [DOS] Enable the emx kernel debugger.  Use the -S option to
  1069.         operate the debugger through the keyboard and display.  If you
  1070.         want to debug using a terminal, enter -S1 to use COM1, -S2 to
  1071.         use COM2.
  1072.  
  1073. -V      Display emx version.  On program start, the emx version will
  1074.         be displayed.
  1075.  
  1076. -Z      [DOS*] Don't zero-fill pages.  This option is used for
  1077.         testing.
  1078.  
  1079.  
  1080. 5 More emx utilities
  1081. ====================
  1082.  
  1083.  
  1084. 5.1 updt
  1085. --------
  1086.  
  1087. - Copy file if contents have changed:
  1088.  
  1089.       updt [-v] <source_file> <target_file>
  1090.  
  1091.   updt copies the source file to the target file if the target file
  1092.   does not exist or if the source and target files differ in contents.
  1093.   This is used by the makefile for GCC.
  1094.  
  1095. - Copy file if source file is newer:
  1096.  
  1097.       updt [-v] -t <source_file> <target_file>
  1098.  
  1099.   updt copies the source file to the target file if the target file
  1100.   does not exist or if the source file is newer than the target file.
  1101.   This is used for configuring GCC.
  1102.  
  1103. The -v option turns on information messages.
  1104.  
  1105.  
  1106. 5.2 emximp
  1107. ----------
  1108.  
  1109. emximp manages files required for importing functions from dynamic
  1110. link libraries.
  1111.  
  1112. Three different methods for importing are used for the two methods of
  1113. creating executable files.  When using ld and emxbind, there are two
  1114. methods for importing:
  1115.  
  1116. (I1)    The import library contains a small piece of code for each
  1117.         function which loads the AL register with the number of
  1118.         argument words and jumps to the imported function.
  1119.         Information on imported functions is stored in tables in the
  1120.         text segment of the program.  emxbind reads these tables to
  1121.         create appropriate fixups in the .exe file.  When an imported
  1122.         function is called while running the resulting program under
  1123.         DOS, an error message will be displayed and the program will
  1124.         be terminated.  Data cannot be imported with method (I1).  You
  1125.         have to use the -R option of ld.
  1126.  
  1127. (I2)    The import library does not contain code for import
  1128.         definitions.  Instead, it contains special symbol table
  1129.         entries, which are copied to the a.out file.  One of these
  1130.         entries makes ld create a relocatable output file.  emxbind
  1131.         reads the symbol table and creates appropriate fixups in the
  1132.         .exe file.  The AL register isn't loaded with the number of
  1133.         argument words.  The program will be aborted (protection
  1134.         violation) when an imported function is called under DOS.  The
  1135.         -R option of ld is automatically turned on when referencing an
  1136.         import definition of type (I2).
  1137.  
  1138. When using emxomf and LINK386, the standard OS/2 method is used:
  1139.  
  1140. (I3)    LINK386 reads a .lib import library or a module definition
  1141.         file to create appropriate fixups.  The AL register isn't
  1142.         loaded with the number of argument words.  The program won't
  1143.         run under DOS.
  1144.  
  1145. Methods (I2) and (I3) are recommended unless the dynamic link library
  1146. requires the AL register to be loaded with the number of argument
  1147. words.  os2.a uses method (I2).
  1148.  
  1149. emximp is used to create appropriate files for all these methods.
  1150. Information on functions exported by dynamic link libraries is
  1151. provided in emx import list files.
  1152.  
  1153. The following table summarizes the features of the three methods:
  1154.  
  1155.     Method               │  (I1)  │   (I2)  │   (I3)
  1156.     ─────────────────────┼────────┼─────────┼──────────
  1157.     Linker               │  ld    │   ld    │ LINK386
  1158.     Import by name       │  YES   │   NO    │ YES
  1159.     Load AL register     │  YES   │   NO    │ NO
  1160.     Code overhead        │  YES   │   NO    │ NO
  1161.     Catch call under DOS │  YES   │   NO    │ NO
  1162.     Import library type  │ .o .a  │   .a    │ .lib .def
  1163.     Can import functions │  YES   │   YES   │ YES
  1164.     Can import data      │  NO    │   YES   │ YES
  1165.     Additive fixups      │  NO    │   YES   │ YES
  1166.     Linker options       │  -R    │         │
  1167.  
  1168.  
  1169. 5.2.1 What is an emx import list file?
  1170. --------------------------------------
  1171.  
  1172. An emx import list file defines how functions can be imported from
  1173. dynamic link libraries.  For each function, the import list file
  1174. defines the name of the function, the module name (that's the name of
  1175. the dynamic link library exporting the function), either the ordinal
  1176. number or the name of the function as exported by the dynamic link
  1177. library, and the number of argument 32-bit words expected by the
  1178. function (this is the number of arguments unless structures are passed
  1179. by value).
  1180.  
  1181. For method (I1), emximp is used to turn an import list file into an .a
  1182. import library which can be linked to a program using the ld linker.
  1183. emximp either creates assembler source files (.s) or automatically
  1184. calls the assembler to create object files (.o).  The object files can
  1185. be packed into a library with the ar program.
  1186.  
  1187. For method (I2), emximp is used to turn an import list file or an OMF
  1188. import library (.lib file) directly into an .a import library which
  1189. can be linked to a program using the ld linker.
  1190.  
  1191. For method (I3), emximp can convert an import list file into a module
  1192. definition file or an OMF import library.  emximp can also convert a
  1193. module definition file into an OMF import library.
  1194.  
  1195. Comments in an import list file are started with a semicolon.  Empty
  1196. lines are ignored.
  1197.  
  1198. For each function you have to put one line into the import list file.
  1199. Here's an example of an import list file:
  1200.  
  1201.     ; myimport.imp
  1202.     DosStartTimer       doscalls 351 3
  1203.     DosStopTimer        doscalls 290 1
  1204.  
  1205. Such a line consists of four components which are separated by one or
  1206. more blanks.  The first word is the name of the function, as used in C
  1207. programs.  The second word is the name of the DLL.  The third word is
  1208. either the ordinal number of the DLL entry or the name of the DLL
  1209. entry.  You have to use ordinal numbers for OS/2 API functions.  The
  1210. fourth word is the number of 32-bit words of arguments expected by the
  1211. function.  This is the number of arguments unless structures are
  1212. passed by value.
  1213.  
  1214. A question mark used as forth word is equivalent to using the number
  1215. 0.  A question mark should be used if the number of arguments is
  1216. unknown or if the entry point is not a function (data can also be
  1217. exported).  Using a question mark causes a warning when creating files
  1218. for method (I1).
  1219.  
  1220. An R used as forth word causes the AL register not to be loaded with
  1221. method (I1) -- this is used for functions which expect an argument in
  1222. the EAX register.
  1223.  
  1224. An F used as forth word specifies a 16-bit function.  emximp adds _16_
  1225. in front of the function name to notify emxbind and emxomf of the
  1226. 16-bitness of the function.  References to symbols starting with _16_
  1227. are fixed up by 16:16 far pointers.
  1228.  
  1229.  
  1230. 5.2.2 Creating an emx import list file from an OMF import library
  1231. -----------------------------------------------------------------
  1232.  
  1233. To create an emx import list file from an OMF import library, type
  1234.  
  1235.     emximp -o <output_file>.imp <input_file>.lib ...
  1236.  
  1237. <output_file> is the name of the emx import list file to be created.
  1238. The name must end with .imp.  <input_file> is the name of an existing
  1239. import library file.  The name must end with .lib.  You can give one
  1240. or more input filenames on the command line.
  1241.  
  1242. As the number of argument words of the functions cannot be derived
  1243. from the import library, a question mark instead of a number for the
  1244. number of argument words is written to the import list file.
  1245.  
  1246. When encountering a module with static code or data, emximp displays a
  1247. warning message.
  1248.  
  1249.  
  1250. 5.2.3 Creating an emx import list file from a module definition file
  1251. --------------------------------------------------------------------
  1252.  
  1253. To create an emx import list file from a module definition file, type
  1254.  
  1255.     emximp -o <output_file>.imp <input_file>.def ...
  1256.  
  1257. <output_file> is the name of the emx import list file to be created.
  1258. The name must end with .imp.  <input_file> is the name of an existing
  1259. module definition file.  The name must end with .def.  You can give
  1260. one or more input filenames on the command line.
  1261.  
  1262. As the number of argument words of the functions cannot be derived
  1263. from the module definition file, a question mark instead of a number
  1264. for the number of argument words is written to the import list file.
  1265.  
  1266.  
  1267. 5.2.4 Creating an emx import library for method (I1)
  1268. ----------------------------------------------------
  1269.  
  1270. To create an emx import library for method (I1), type
  1271.  
  1272.     emximp [-a<assembler>] [-b<base_name>|<prefix_length>] [-p<module>]...
  1273.            [-s] <input_file>.imp ...
  1274.  
  1275. <input_file> is the name of the import list file.  The name must end
  1276. with .imp.  You can give one or more input filenames on the command
  1277. line.
  1278.  
  1279. The names of the output files are either taken from the import list
  1280. file or automatically generated by emximp.  A line in starting with
  1281. `+' starts a new assembly language file or object file (module).  The
  1282. name of the output file is given after the `+':
  1283.  
  1284.     +os2mem1.s          ; start a new output file
  1285.  
  1286. This feature is used only for method (I1).  All the functions defined
  1287. in one module are linked if at least one of the functions is
  1288. referenced.
  1289.  
  1290. It's possible to let emximp automatically write one file per function.
  1291. The output filenames are constructed by appending the ordinal number
  1292. or a sequential number to a fixed prefix or to a prefix of the DLL
  1293. name.  To let emximp automatically choose output filenames, use the -b
  1294. command line option.  If -b is given, the import list file must not
  1295. contain lines starting with `+'.  The argument of the -b option is
  1296. either a number or a string.  If the argument is a string, that string
  1297. is used as base name of the output files.  If the argument is a
  1298. number, that many characters are taken from the start of each DLL name
  1299. to create the base name of the output file.  A number is appended to
  1300. the base name.  If -s is given, a sequential number is appended,
  1301. starting with the number 1.  The number is incremented for each output
  1302. file.  If -s is not given, the ordinal number of the function is
  1303. appended; giving entry names instead of ordinal numbers in the import
  1304. list file is not allowed for that reason.  Note that appending ordinal
  1305. numbers to the names may cause problems (output for different
  1306. functions written to the same file) if multiple DLLs are used in the
  1307. import list file and the argument of the -b option is a string (or too
  1308. small a number to make the prefixes unique).  These problems also
  1309. occur if the import list file defines multiple functions to refer to
  1310. the same entry point.  The extension of the output files is .o if the
  1311. -a option is used, .s otherwise.
  1312.  
  1313. By default, emximp creates assembler source files.  emximp can
  1314. automatically call an assembler to assemble the output files.  This
  1315. feature is turned on by the -a command line option.  The argument of
  1316. the -a option is the name of the assembler (there must be no blanks
  1317. between -a and the argument).  If the argument is omitted, as.exe is
  1318. used.  The default extension is .exe, the program will be sought in
  1319. the directories listed in the PATH environment variable.
  1320.  
  1321. The object files will have the same name as the assembler source
  1322. files, with the .s extension replaced by .o.
  1323.  
  1324. Under OS/2, the assembly language files are not actually written, a
  1325. pipe is used instead.  Under DOS, the assembly language files created
  1326. by emximp will be deleted automatically after running the assembler.
  1327.  
  1328. To save space in the executable file, DLL names which are often used
  1329. should be put into separate files, see above for an example.  Use the
  1330. -p option of emximp to use separate files for the DLL names.  The
  1331. argument of the -p option is the name of the DLL.  emximp prepends
  1332. __os2_ to the DLL name for making the label used for referencing the
  1333. DLL name.  You can use multiple -p options.  Here's how to write a
  1334. separate file which defines a DLL name:
  1335.  
  1336.             .globl  __os2_pmgpi
  1337.             .text
  1338.     __os2_pmgpi:
  1339.             .asciz  "PMGPI"
  1340.  
  1341. This file declares the DLL name PMGPI.  Use the -p pmgpi option of
  1342. emximp to tell emximp to create code that references this file.
  1343.  
  1344. Technical details:
  1345.  
  1346. Let's examine the .s file created by emximp for the DosSelectSession
  1347. function.
  1348.  
  1349.     1)              .globl  _DosSelectSession
  1350.     2)              .align  2, 144
  1351.     3)      _DosSelectSession:
  1352.     4)              movb    $1, %al
  1353.     5)      1:      jmp     __os2_bad
  1354.     6)      2:      .long   1, 1b+1, L1, 38
  1355.     7)      L1:     .asciz  "sesmgr"
  1356.     8)              .stabs  "__os2dll", 23, 0, 0, 2b
  1357.  
  1358. Line 1 is obvious: it exports _DosSelectSession from os2.a so that ld
  1359. will link this module when _DosSelectSession is referenced.
  1360.  
  1361. Line 2 is a speed hack: the 386 performs much better when jumping to
  1362. an address which is an integral multiple of 4.
  1363.  
  1364. Line 3 declares _DosSelectSession.  Your program calls this code when
  1365. calling DosSelectSession.
  1366.  
  1367. Line 4 stores the number of arguments in the AL register (or rather,
  1368. the number of argument 32-bit words).
  1369.  
  1370. Line 5 jumps to __os2_bad which displays an error message and stops
  1371. execution.  This is what happens if you run the program on DOS.
  1372.  
  1373. Line 6 creates a small table which is read by emxbind: It consists of
  1374. four words:
  1375.  
  1376. - a word of flag bits.  Currently, only bit 0 is defined: it's 0 for
  1377.   import by name, 1 for import by ordinal.
  1378.  
  1379. - the address of the word to be fixed up for referencing the DLL.
  1380.   `1b+1' means `local label 1, looking backwards, add one to address'.
  1381.   Therefore, the address used by the JMP instruction is used.
  1382.  
  1383. - a pointer to the name of the module (null-terminated ASCII string).
  1384.   For often used names the pointer should point to a string in a
  1385.   separate, common module to save space, see the -p option.
  1386.  
  1387. - the ordinal number or a pointer to the name of the entry point
  1388.   (null-terminated ASCII string), respectively, depending on bit 0 of
  1389.   the flags word.
  1390.  
  1391. Line 7 defines the module name pointed to by the table.
  1392.  
  1393. Line 8 is the tricky part: it contains a special symbol table entry to
  1394. make ld build a table named __os2dll which contains pointers to all
  1395. the small tables (2b is the address of the small table).  See also
  1396. crt0.s, where the table is initialized.  crt0 contains a pointer to
  1397. the table in a fixed location so that emxbind can find the table of
  1398. pointers, read all the small tables (as described above) and create
  1399. the necessary OS/2 fixups.
  1400.  
  1401.  
  1402. 5.2.5 Creating an a.out import library for method (I2)
  1403. ------------------------------------------------------
  1404.  
  1405. To create an a.out import library for method (I2), type
  1406.  
  1407.     emximp -o <output_file>.a <input_file>.imp ...
  1408.     emximp -o <output_file>.a <input_file>.lib ...
  1409.  
  1410. <output_file>.a is the name of the archive file to be created.  The
  1411. name must end with .a.
  1412.  
  1413. <input_file>.imp is the name of an emx import list file.  The name
  1414. must end with .imp.
  1415.  
  1416. <input_file>.lib is the name of an import library (OMF).  The name
  1417. must end with .lib.  Modules in the input files which are not import
  1418. definitions are ignored.
  1419.  
  1420. You can give one or more input filenames on the command line; all
  1421. input file must be of the same type, either .imp or .lib.
  1422.  
  1423. All import records of the input files are converted to import modules
  1424. for method (I2).  After creating the output file, you should run ar s
  1425. on the output file to increase linking efficiency.
  1426.  
  1427. When encountering a module with static code or data in a .lib file,
  1428. emximp displays a warning message.  You may have to use extract those
  1429. modules from the library, convert them with emxaout, and add them to
  1430. the target library with emxomfar.
  1431.  
  1432. Technical details:
  1433.  
  1434. A member named __.IMPORT is added to the archive.  GNU ld (the one
  1435. ported to emx) has been patched to turn on relocatable output if it
  1436. finds a member named __.IMPORT in a library.  As only the __.SYMDEF
  1437. member is scanned if present, __.IMPORT defines the special symbol
  1438. __IMPORT!.  When patched GNU ld finds the definition of a symbol named
  1439. __IMPORT! in the __.SYMDEF member, relocatable output is turned on.
  1440. (Relocatable output can also be turned on by using the -R option of
  1441. ld.)
  1442.  
  1443. For each function in the input files, emximp adds an a.out-type module
  1444. to the output file.  Such a module defines two symbols.  One symbol
  1445. defines the entry point, the other symbol gives information on the DLL
  1446. name and the ordinal number or procedure name.  For instance, for
  1447.  
  1448.     LIBRARY doscalls
  1449.     EXPORTS DosBeep @286
  1450.  
  1451. the two symbols `_DosBeep' and `_DosBeep=doscalls.286' are defined.
  1452. The symbol types 0x69 and 0x6b are used, respectively.  GNU ld has
  1453. been patched to keep references to symbols of type 0x69 in the
  1454. relocation table.
  1455.  
  1456. emxbind scans the relocation table for references to symbols of type
  1457. 0x69 and scans the symbol table for a matching symbol of type 0x6b
  1458. which defines the entry point.
  1459.  
  1460.  
  1461. 5.2.6 Creating an OMF import library for method (I3)
  1462. ----------------------------------------------------
  1463.  
  1464. To create an OMF import library for method (I3), use one of the
  1465. following invokations of emximp, depending on the input format:
  1466.  
  1467.     emximp -o <output_file>.lib <input_file>.def ...
  1468.     emximp -o <output_file>.lib <input_file>.imp ...
  1469.  
  1470. <output_file>.lib is the name of the import library file to be
  1471. created.  The name must end with .lib.
  1472.  
  1473. <input_file>.def is the name of a module definition file containing
  1474. one or more EXPORTS statements.
  1475.  
  1476. <input_file>.imp is the name of an emx import list file.
  1477.  
  1478. You can give one or more input filenames on the command line.
  1479.  
  1480. All the import list files must define functions that are in the same
  1481. dynamic link library.  Lines start with `+' are ignored.
  1482.  
  1483. The number of argument words is lost after that conversion, that is,
  1484. you cannot recreated the import list file using emximp.
  1485.  
  1486.  
  1487. 5.2.7 Creating a module definition file for method (I3)
  1488. -------------------------------------------------------
  1489.  
  1490. To create a module definition file for method (I3), type
  1491.  
  1492.     emximp -o <output_file>.def <input_file>.imp ...
  1493.  
  1494. <output_file> is the name of the module definition file to be created.
  1495. The name must end with .def.
  1496.  
  1497. <input_file> is the name of an emx import list file.  The name must
  1498. end with .imp.  You can give one or more input filenames on the
  1499. command line.
  1500.  
  1501. All the import list files must define functions that are in the same
  1502. dynamic link library.  Lines start with `+' are ignored.
  1503.  
  1504. The number of argument words is lost after that conversion, that is,
  1505. you cannot recreated the import list file using emximp.
  1506.  
  1507.  
  1508. 5.3 emxomf
  1509. ----------
  1510.  
  1511. The emxomf tool converts a.out object files (.o files) to Object
  1512. Module Formats (.obj files).  The converted files can be used with the
  1513. OS/2 linker link386.exe.
  1514.  
  1515. emxomf keeps itself in memory for N minutes if the environment
  1516. variable GCCLOAD is set to N.
  1517.  
  1518.     emxomf [-d] [-l[<symbol>]] [-g] [-s] [-p <page_size>] [-m <symbol>]
  1519.            [-i <default_lib>] [-I <idmdll>] [-D <dataseg>]
  1520.            -o <output_file> <input_file>
  1521.  
  1522. Convert a single .o or .a file (<input_file>) to an .obj or .lib file
  1523. (<output_file>).  There are no default extensions.  If the -d option
  1524. is given, the input file is deleted after successful conversion.  If
  1525. the input file is an archive, it is not deleted.
  1526.  
  1527.     emxomf [-d] [-l[<symbol>]] [-g] [-s] [-x] [-p <page_size>]
  1528.     [-m <symbol>]
  1529.            [-O <directory>] [-r|R<response_file>] [-i <default_lib>]
  1530.            [-I <idmdll>] [-D <dataseg>] <input_file>...
  1531.  
  1532. Convert multiple .o and .a files to .obj and .lib files (more than one
  1533. <input_file> can be given on the command line).  The names of the
  1534. output files are constructed by replacing the extension of the
  1535. <input_file>s with .obj or .lib, respectively.  If the -x option is
  1536. given, all members (which must be a.out modules) of archives (.a
  1537. files) are converted to .obj files.  The names of the output files are
  1538. constructed by replacing the extension of the member names with .obj.
  1539. If the -x option is not given, archives (.a files) are converted to
  1540. libraries (.lib files).  If the -O option is given, the output files
  1541. are written to the directory <directory>.  A LIB response file
  1542. <response_file> is created if you use the -r or -R option.  When using
  1543. -r, the response file will contain commands to add the modules to a
  1544. library file, when using -R, it will contain commands to replace the
  1545. modules in a library file.  If the -d option is given, all the input
  1546. files except for archives are deleted after successful conversion.  If
  1547. the -s option is given, debugging information is omitted.
  1548.  
  1549. You can put emxomf options into the environment variable EMXOMFOPT.
  1550. These options will be read before the options given on the command
  1551. line.
  1552.  
  1553. Options common to both calling sequences:
  1554.  
  1555. -D <dataseg>
  1556.  
  1557.     Change the name of the data segment.  By default, all initialized
  1558.     variables are put into the DATA32 segment which is a member of the
  1559.     DGROUP group.  By using the -D option, the segment used for
  1560.     initialized variables can be changed.  That segment won't be a
  1561.     member of the DGROUP.  This can be used for creating dynamic link
  1562.     libraries with both instance data and shared data.  Define all
  1563.     variables which should be private to the instances of the DLL in a
  1564.     separate source file, initialize all the variables, use the -D
  1565.     option of emxomf to put these variables into a separate segment
  1566.     and set the attributes of that segment in the module definition
  1567.     file to NONSHARED.  All other variables will go into the default
  1568.     data segment, which is shared by all instances of the DLL.
  1569.     Alternatively, you can make variables private by default and put
  1570.     the shared variables into a separate segment.  You have to list
  1571.     all the segments of class DATA in the module definition file.
  1572.     Example:
  1573.  
  1574.         SEGMENTS
  1575.           PRIV CLASS 'DATA' NONSHARED
  1576.           DATA32 CLASS 'DATA' SHARED
  1577.           BSS32 CLASS 'BSS' SHARED
  1578.  
  1579.     In this example, variables are shared by default.  The segment
  1580.     PRIV contains private variables.
  1581.  
  1582. -g
  1583.  
  1584.     Create groups for sets, as did previous versions of emxomf.  This
  1585.     causes an extra object to be created for each set (such as
  1586.     __CTOR__LIST__).  By default, all sets are merged into the text
  1587.     object.
  1588.  
  1589. -i <default_lib>
  1590.  
  1591.     Add default library request.  LINK386 is informed that the .obj
  1592.     file should be linked with the library <default_lib>.  If
  1593.     <default_lib> doesn't include a file name extension, LINK386 uses
  1594.     the default extension .lib.  You can specify multiple libraries by
  1595.     using multiple -i options.
  1596.  
  1597. -I <idmdll>
  1598.  
  1599.     Change the name of the identifier manipulation DLL.  That DLL is
  1600.     used by LINK386 to demangle C++ symbol names in error messages.  A
  1601.     special record (IDMDLL) is inserted into the .obj file by emxomf
  1602.     to tell LINK386 about the name of the DLL.  emxomf inserts that
  1603.     record only if it recognizes the input file as being compiled by
  1604.     G++.  The default for the identifier manipulation DLL is gppdemid.
  1605.     Use -I- to suppress the insertion of the IDMDLL record.
  1606.  
  1607. -l[<symbol>]
  1608.  
  1609.     The module (all the modules of an archive when converting an
  1610.     archive) is supposed to be a library modules.  A library module
  1611.     doesn't define a stack segment and doesn't request libraries.  If
  1612.     <symbol> is given (following directly -l, without space), it is
  1613.     used as name of the entry point, that is, the function that should
  1614.     be called when the DLL is started.  If <symbol> is not specified,
  1615.     no entry point will be defined.  If -l and -m are missing, the
  1616.     module is supposed to be part of a program but not the main
  1617.     module.  Such a module doesn't define a stack segment and doesn't
  1618.     have an entry point.
  1619.  
  1620. -m <symbol>
  1621.  
  1622.     The module is supposed to be the main module of a program.  A main
  1623.     module defines a default stack segment (0x8000 bytes) and has an
  1624.     entry point.  <symbol> is the name of the entry point, that is,
  1625.     the function that should be called when the program is started.
  1626.     -m is used for the startup code module crt0 and should not be used
  1627.     for user modules.  If -l and -m are missing, the module is
  1628.     supposed to be part of a program but not the main module.  Such a
  1629.     module doesn't define a stack segment and doesn't have an entry
  1630.     point.
  1631.  
  1632. -p <page_size>
  1633.  
  1634.     Set the page size of .lib files to <page_size> bytes (16, 32, 64,
  1635.     ..., 32768).  If -p is not given, a page size of 16 bytes will be
  1636.     used.  Increase the page size if emxomf complains about too big a
  1637.     library.  If emxomf doesn't complain, you shouldn't increase the
  1638.     page size to save disk space.
  1639.  
  1640. -s
  1641.  
  1642.     If the -s option is given, debugging information is omitted.  By
  1643.     default, debugging information is converted from a.out DBX-style
  1644.     (with GNU extensions) to HLL version 3 format (as used by IBM's
  1645.     IPMD debugger of the C/C++ Tools 2.0 package).  If emxomf cannot
  1646.     translate debugging information, a warning message is displayed.
  1647.     Types not recognized by emxomf are treated as `int' to be able to
  1648.     continue conversion.  Restrictions:
  1649.  
  1650.     - The Objective C language is not supported yet.
  1651.  
  1652.     - Structures (or unions) without declarator within another
  1653.       structure (or union) are ignored as GCC doesn't emit suitable
  1654.       debugging information.
  1655.  
  1656.     - Variable-length automatic arrays are not supported.
  1657.  
  1658.     - `long long' and `unsigned long long' types are translated to the
  1659.       following structure, as HLL version 3 debugging information
  1660.       doesn't support 64-bit integers:
  1661.  
  1662.           struct _long_long
  1663.           {
  1664.              unsigned long lo;
  1665.              unsigned long hi;
  1666.           }
  1667.  
  1668.     - Pointer to member (C++) is not yet supported.
  1669.  
  1670.  
  1671. 5.4 emxomfld
  1672. ------------
  1673.  
  1674. emxomfld is a front end to LINK386, providing an ld-like command line
  1675. syntax for LINK386.  After parsing the command line, LINK386 is called
  1676. with equivalent command line arguments.
  1677.  
  1678.     emxomfld -o <file> [-l <lib>] [-L <libdir>] [-T <base>] [-sS]
  1679.              [-Zexe] [-Zdll] [-Zstack <stack_size>] [-Zmap[=<map_file>]]
  1680.              [-O <option>] <file>...
  1681.  
  1682. The files given on the emxomfld command line are assumed to be .obj
  1683. files to be linked unless the extension is .def, .lib or .res.  A file
  1684. having a .def extension is used as module definition file.  There may
  1685. be at most one module definition file.  A file having a .lib extension
  1686. is used as library file.  A file having a .res extension is used as
  1687. binary resource file; rc is called to attach the resources to the
  1688. output file.
  1689.  
  1690. Example:
  1691.  
  1692.     emxomfld -o test -lc -Lc:/mylibs test1 test2 test.def test.res
  1693.  
  1694. Create file test.exe (or test.dll, depending on the contents of
  1695. test.def), by linking test1.obj and obj2.obj with c.lib.  c.lib is
  1696. sought in c:/mylibs.  Use the module definition file test.def.  Call
  1697. rc to copy the resources from test.res to test.exe (or test.dll).
  1698.  
  1699. The following options are available:
  1700.  
  1701. -i
  1702.  
  1703.     Pass the /INFORMATION option to LINK386, causing filenames to be
  1704.     displayed while linking.  This is used for debugging emxomfld.
  1705.  
  1706. -l <lib>
  1707.  
  1708.     Link with the library <lib>.lib.  For instance, -lc causes c.lib
  1709.     to be used.
  1710.  
  1711. -L <libdir>
  1712.  
  1713.     Add the directory <libdir> to the library search path.  Libraries
  1714.     are sought in the directories given by -L options.  emxomfld
  1715.     prepends the directories to the LIB environment variable.
  1716.  
  1717. -o <file>
  1718.  
  1719.     <file> is the output file.  The default extension (.exe or .dll)
  1720.     is provided by LINK386.  If -o is omitted, $$$ will be used.
  1721.  
  1722. -O <option>
  1723.  
  1724.     Pass the option <option> to LINK386.  For each option to be passed
  1725.     to LINK386, one -O has to be used.  <option> should start with a
  1726.     slash.  Example:
  1727.  
  1728.         -O/runfromvdm
  1729.  
  1730.     See also the -Zlinker option of GCC.
  1731.  
  1732. -s
  1733.  
  1734.     Strip all symbols, including debugging information.  If -s and -S
  1735.     are not used, emxomfld passes the /DEBUG option to LINK386.
  1736.  
  1737. -S
  1738.  
  1739.     Strip debugging symbols (emxomfld strips all symbols, including
  1740.     debugging information, if -S is used).  If -s and -S are not used,
  1741.     emxomfld passes the /DEBUG option to LINK386.
  1742.  
  1743. -T <base>
  1744.  
  1745.     Set the base address of the text segment.  This option is
  1746.     translated to the /BASE option of LINK386.  emxomfld automatically
  1747.     passes /BASE:0x10000 to LINK386 unless -T is used or a DLL is
  1748.     built.  If neither -T nor -Zdll is used, the module definition
  1749.     file is read to learn whether a DLL is being built or not.
  1750.  
  1751. -x
  1752.  
  1753.     Discard all local symbols (this option is ignored by emxomfld).
  1754.  
  1755. -X
  1756.  
  1757.     Discard local symbols starting with L (this option is ignored by
  1758.     emxomfld).
  1759.  
  1760. -Zdll
  1761.  
  1762.     Build a DLL.  If the -Zdll option is present, emxomfld does not
  1763.     automatically pass /BASE:0x10000 to LINK386.  The -Zdll option
  1764.     isn't necesary as a module definition file is required when
  1765.     building a DLL and emxomfld reads the module definition file to
  1766.     learn whether a DLL is to be built or not.
  1767.  
  1768. -Zexe
  1769.  
  1770.     If the -Zexe option is present, emxomfld deletes the output file
  1771.     (whose name is given on the command line) and adds .exe to the
  1772.     output filename.  After calling LINK386, emxomfld creates an empty
  1773.     output file (without .exe).  This feature is used for minimizing
  1774.     changes to Unixoid makefiles.  See also the -Zexe option of GCC
  1775.     and ld.
  1776.  
  1777. -Zmap[=<map_file>]
  1778.  
  1779.     Let LINK386 write the map file <map_file>.  LINK386 adds the
  1780.     default extension `map'.  If =<map_file> is not specified, the
  1781.     name of the map file will be derived from the output file name.
  1782.  
  1783. -Zstack <stack_size>
  1784.  
  1785.     Set the stack size of the executable, in Kbyte.  The argument of
  1786.     the -Zstack option is multiplied by 1024 and turned into a /STACK
  1787.     LINK386 option.  The number can be given in decimal, octal or
  1788.     hexadecimal, using C notation.
  1789.  
  1790.  
  1791. 5.5 emxomfar
  1792. ------------
  1793.  
  1794. emxomfar is a librarian for OMF .lib files with a command line
  1795. interface similar to ar to simplify makefiles.
  1796.  
  1797.     emxomfar [-p#] <command> <library_file> [<module>]...
  1798.  
  1799. The default extension for <library_file> is .lib.  When modifying a
  1800. library file, a backup file with .bak extension is created.
  1801.  
  1802. Here's a description of ar commands:
  1803.  
  1804. d       Delete modules from library.  The module name __.SYMDEF is
  1805.         ignored.
  1806.  
  1807. m       Move members to the end of the archive.  Not implemented in
  1808.         emxomfar.
  1809.  
  1810. p       Copy members to standard output.  Not implemented in emxomfar.
  1811.  
  1812. q       Quick append.  This command is equivalent to the r command in
  1813.         emxomfar.
  1814.  
  1815. r       Replace modules in library.  Modules which are not in the
  1816.         library are added to the library.  The default extension for
  1817.         modules is .obj.
  1818.  
  1819. s       Build the __.SYMDEF symbol table member.  This command is
  1820.         ignored by emxomfar.
  1821.  
  1822. t       List table of contents.  Use the v option to also list public
  1823.         symbols.
  1824.  
  1825. x       Extract modules from library.  The default extension for
  1826.         modules is .obj.
  1827.  
  1828. You can additionally use the following modifiers in the <command>
  1829. argument:
  1830.  
  1831. a       Position after specified member.  Not implemented in emxomfar
  1832.  
  1833. b       Position before specified member.  Not implemented in emxomfar
  1834.  
  1835. c       Don't display warning when creating new library.
  1836.  
  1837. i       Position before specified member.  Not implemented in emomfar
  1838.  
  1839. l       Create temporary file in current directory.  Ignored by
  1840.         emxomfar
  1841.  
  1842. o       Preserve dates.  Ignored by emxomfar
  1843.  
  1844. u       Don't replace members with older files (update).  Ignored by
  1845.         emxomfar
  1846.  
  1847. v       Verbose output.
  1848.  
  1849. The following option must precede <command> if used:
  1850.  
  1851. -p#     Set page size to # bytes (16, 32, 64, ..., 32768).  If -p is
  1852.         not given, a page size of 16 bytes will be used.  Increase the
  1853.         page size if emxomfar complains about too big a library.  If
  1854.         emxomfar doesn't complain, you shouldn't increase the page
  1855.         size to save disk space.
  1856.  
  1857. Example:
  1858.  
  1859.     emxomfar -p32 rc newlib *.obj
  1860.  
  1861.  
  1862. 5.6 emxexp
  1863. ----------
  1864.  
  1865. The emxexp tool creates an export list for a module definition file
  1866. from object files and libraries.  This is used for building dynamic
  1867. link libraries written in C++.
  1868.  
  1869.     emxexp [-n] [-o[<ordinal>]] <input_file>...
  1870.  
  1871. For each public symbol (except for uninitialized variables) of the
  1872. input files (which can be .o, .a, .obj or .lib files), emxexp prints
  1873. to the standard output an export definition for the EXPORTS statement
  1874. of a module definition file.  For mangled names, a comment is
  1875. generated which shows the demangled name.  The following options are
  1876. available:
  1877.  
  1878. -n
  1879.  
  1880.     Add the NONAME keyword to each export definition to keep LINK386
  1881.     from putting the name into the name tables.  This is required for
  1882.     dynamic link libraries which export too many names.
  1883.  
  1884. -o[<ordinal>]
  1885.  
  1886.     Add ordinal numbers to the export definitions.  If <ordinal> is
  1887.     given, ordinal numbers will start with that number.  Otherwise,
  1888.     ordinal numbers will start with 1.
  1889.  
  1890.  
  1891. 5.7 emxaout
  1892. -----------
  1893.  
  1894. The emxaout tool converts OMF object files (.obj files) to a.out
  1895. object files (.o files).  The converted files can be used with the
  1896. Unix-style linker ld.  By using emxaout, you can create .o files with
  1897. MASM 6.0.
  1898.  
  1899.     emxaout [-u] [-o <output_file>] <input_file>
  1900.  
  1901. Convert the OMF file <input_file> to a.out format.  The default
  1902. extension for <input_file> is .obj.  If the -o option is used, the
  1903. a.out file is written to <output_file>.  Otherwise, the name of the
  1904. output file is constructed by replacing the extension of <input_file>
  1905. with .o.
  1906.  
  1907. The following option is available:
  1908.  
  1909. -u
  1910.  
  1911.     Don't add leading underscores to symbol names.  By default,
  1912.     emxaout prepends an underscore to every symbol name.
  1913.  
  1914.     When using the PROC C, PROTO C and EXTERNDEF C directives of MASM
  1915.     6.0, you should use the -u option of emxaout because MASM prepends
  1916.     an underscore to symbols defined with those directives.
  1917.  
  1918. The OMF file must have 32-bit OS/2 format, that is, you should use the
  1919. following MASM directives:
  1920.  
  1921.     .386
  1922.     .MODEL FLAT
  1923.  
  1924. emxaout discards debugging information.
  1925.  
  1926.  
  1927. 5.8 emxcat
  1928. ----------
  1929.  
  1930. The emxcat tool concatenates assembler or C source files.  This is
  1931. used for building emxwrap.dll.
  1932.  
  1933.     emxcat [-D<symbol>]... -o <output_file> <input_file>...
  1934.  
  1935. All the <input_file>s are concatenated and written to <output_file>.
  1936. If the output file is included in the input files, it is not copied;
  1937. emxcat simply compares the filenames, therefore it's possible to fool
  1938. emxcat and make it copying until the disk is full.
  1939.  
  1940. Your code should not depend on the order in which the files are copied
  1941. to the output file.  A different version of emxcat may copy the files
  1942. files in a different order.
  1943.  
  1944. At the very beginning of the output file, the symbols given on the
  1945. command line are defined.  Note that there must not be a space between
  1946. -D and the name of the symbol.
  1947.  
  1948. #include statements are collected at the start of the output file.
  1949. The (partial) order of the include files is maintained.  If there is
  1950. an inconsistency in the order of include files in different input
  1951. files, emxomf prints a warning message.  For instance, this happens
  1952. for the following three input files:
  1953.  
  1954.     /* file1.c */
  1955.     #include "a.h"
  1956.     #include "b.h"
  1957.     
  1958.     /* file2.c */
  1959.     #include "b.h"
  1960.     #include "c.h"
  1961.     
  1962.     /* file3.c */
  1963.     #include "c.h"
  1964.     #include "a.h"
  1965.  
  1966. The statement
  1967.  
  1968.     #include <sys/emx.h>
  1969.  
  1970. is treated specially: it always precedes all other #include statements
  1971. if present in one of the input files.
  1972.  
  1973. When concatenating .s files, lines starting with CONST_ are omitted if
  1974. already copied to the output file -- only the first instance is
  1975. retained.
  1976.  
  1977. All macros #defined by an input file are #undefined after copying the
  1978. input file.  Constants starting with INCL_ are an exception and are
  1979. collected at the start of the output file, before the #include
  1980. statements.
  1981.  
  1982. emxcat leaves alone #define and #include statements which do not start
  1983. at the first column of the line.  If you put blanks before #define and
  1984. #include, emxcat copies these statements to the output file without
  1985. treating them specially.
  1986.  
  1987.  
  1988. 5.9 emxload
  1989. -----------
  1990.  
  1991. The emxload tool preloads OS/2 programs.  Preloading programs speeds
  1992. up loading these programs if you have enough memory.  If you have too
  1993. little memory, preloading may degrade performance.  Preloading is
  1994. especially useful with a compiler such as GCC which runs many
  1995. processes to complete its task.
  1996.  
  1997. emxload starts the emxload server process (emxload.exe contains both
  1998. the client program described here and the server program).  The server
  1999. process runs until stopped with the -q option of emxload.
  2000.  
  2001. When using emxload to load a program which is already preloaded by
  2002. emxload, the expiry time of that program will be reset to the new
  2003. value.
  2004.  
  2005. There are library functions for using the emxload server in your
  2006. programs.  See _emxload_prog() etc. for details.
  2007.  
  2008. The GNU C compiler keeps itself in memory for N minutes if the
  2009. environment variable GCCLOAD is set to N.  For example, to keep the
  2010. passes of GCC in memory for 5 minutes, type
  2011.  
  2012.     SET GCCLOAD=5
  2013.  
  2014. The following programs use GCCLOAD: gcc.exe, cpp.exe, cc1.exe,
  2015. cc1plus.exe, cc1obj.exe, as.exe and emxomf.exe.
  2016.  
  2017.     emxload [-m<limit>] [-s<limit>] [-e] [-u[w]]
  2018.             [-gcc] [-g++] [-gobjc] [-omf] <program>...
  2019.  
  2020. All the <program>s are preloaded.  The default extension is .exe.
  2021. There are shortcuts for preloading the GNU C compiler:
  2022.  
  2023. -gcc
  2024.  
  2025.     This option preloads the complete GNU C compiler for compiling C
  2026.     programs and generating a.out-style output.  The following
  2027.     programs will be preloaded: gcc.exe, cpp.exe, cc1.exe, ld.exe,
  2028.     as.exe and emxbind.exe.
  2029.  
  2030. -g++
  2031.  
  2032.     This option preloads the complete GNU C compiler for compiling C++
  2033.     programs and generating a.out-style output.  The following
  2034.     programs will be preloaded: gcc.exe, cpp.exe, cc1plus.exe, ld.exe,
  2035.     as.exe and emxbind.exe.
  2036.  
  2037. -gobjc
  2038.  
  2039.     This option preloads the complete GNU C compiler for compiling
  2040.     programs written in the Objective C programming language and
  2041.     generating a.out-style output.  The following programs will be
  2042.     preloaded: gcc.exe, cpp.exe, cc1obj.exe, ld.exe, as.exe and
  2043.     emxbind.exe.
  2044.  
  2045. -omf
  2046.  
  2047.     Use this option in addition to one of the options for preloading
  2048.     GCC to preload the programs used for generating OMF-style output.
  2049.     The following programs will be preloaded: emxomf.exe, emxomfld.exe
  2050.     and link386.exe.
  2051.  
  2052. You can use one or more of the above options.  For instance, if you
  2053. want to compile C and C++ programs, use
  2054.  
  2055.     emxload -gcc -g++
  2056.  
  2057. This will preload gcc.exe, cpp.exe, cc1.exe, cc1plus.exe, ld.exe,
  2058. as.exe and emxbind.exe.
  2059.  
  2060. There are additional options for controlling the operation of emxload:
  2061.  
  2062. -m<limit>
  2063.  
  2064.     Automatically unload the specified programs after <limit> minutes.
  2065.     This option overrides the -s<limit> option.  By default, programs
  2066.     are unloaded after 10 minutes.
  2067.  
  2068. -s<limit>
  2069.  
  2070.     Automatically unload the specified programs after <limit> seconds.
  2071.     This option overrides the -m<limit> option.  By default, programs
  2072.     are unloaded after 600 seconds.
  2073.  
  2074. -e
  2075.  
  2076.     Don't unload the specified programs automatically.  This option
  2077.     overrides the -m<limit> and -s<limit> options.  By default,
  2078.     emxload unloads a program after 10 minutes.
  2079.  
  2080. -u
  2081.  
  2082.     Unload the specified programs.  By default, emxload preloads the
  2083.     specified programs.  With the -u option, all specified programs
  2084.     will be unloaded.  Don't wait until the server has unloaded the
  2085.     programs.
  2086.  
  2087. -uw
  2088.  
  2089.     Like -u, but wait until the server has unloaded the programs.
  2090.  
  2091. Two special calling sequences are available:
  2092.  
  2093.     emxload -l
  2094.  
  2095. List the preloaded programs with the number of minutes and seconds
  2096. left until automatic unloading.
  2097.  
  2098.     emxload -q[w]
  2099.  
  2100. Stop the emxload server process.  All preloaded programs will be
  2101. unloaded.  Use -qw to wait until the server is stopped.  -q doesn't
  2102. wait.
  2103.  
  2104.  
  2105. 5.10 emxrev
  2106. -----------
  2107.  
  2108. emxrev displays the revision number of emx DLLs (emx.dll, emxio.dll,
  2109. emxlibc.dll, emxlibcm.dll, emxlibcs.dll, and emxwrap.dll).  The
  2110. revision number is incremented every time a changed version of a DLL
  2111. is released.  By looking at the revision numbers of the DLLs, you can
  2112. tell which one is the newest one.
  2113.  
  2114. To display the revision number of the default emx DLLs, type
  2115.  
  2116.     emxrev
  2117.  
  2118. The default DLLs are those used by the operating system when starting
  2119. a program.
  2120.  
  2121. To display the revision number of a specific file, type
  2122.  
  2123.     emxrev -f <file>
  2124.  
  2125. If a directory is included in <file>, append .dll to the name.  If no
  2126. directory is included in <file>, don't append .dll to the name.
  2127.  
  2128. To display the revision numbers of the emx DLLs in directory <dir>,
  2129. type
  2130.  
  2131.     emxrev -d <dir>
  2132.  
  2133. To display the revision numbers of the emx DLLs in all directories of
  2134. drive <drive> (c:, for instance), type
  2135.  
  2136.     emxrev -c <drive>
  2137.  
  2138. To display the revision numbers of the emx DLLs in all directories of
  2139. all hard disks, type
  2140.  
  2141.     emxrev -a
  2142.  
  2143. To display the revision numbers of the emx DLLs in the directories
  2144. listed in the LIBPATH statement of a config.sys file, type
  2145.  
  2146.     emxrev -p <file>
  2147.  
  2148. where <file> is the name of the config.sys file.
  2149.  
  2150.  
  2151. 5.11 listomf
  2152. ------------
  2153.  
  2154. listomf lists an .obj file in (more or less) human-readable form.
  2155. Give the name of the object file on the command line.  There is no
  2156. default extension.
  2157.  
  2158. Warning: listomf is a quick and dirty program which was used for
  2159. developing emxomf.
  2160.  
  2161.  
  2162. 6 Hints for porting Unix programs to emx
  2163. ========================================
  2164.  
  2165. - If you want Unix-like wildcard expansion built into the program, use
  2166.  
  2167.       int main (int argc, char *argv[])
  2168.       {
  2169.         _wildcard (&argc, &argv);
  2170.         /* ... the program ... */
  2171.       }
  2172.  
  2173.   This should be done at the very beginning of main(), before ARGC and
  2174.   ARGV are used.  See _wildcard() and _response().
  2175.  
  2176. - Change all open(), fopen(), fdopen() and freopen() calls to use
  2177.   O_BINARY or "b", respectively, for binary files.  If a file contains
  2178.   both binary and textual data, read the file in binary mode and do
  2179.   the conversion yourself.
  2180.  
  2181. - Though fseek() and ftell() now work on text files, the offsets are
  2182.   different from what Unix programs expect.  You may have to open the
  2183.   files in binary mode and ignore carriage returns (this has been done
  2184.   in GDB).
  2185.  
  2186. - Replace fork() and exec*() with spawn*().  Under OS/2, fork() is
  2187.   inefficient.  Under DOS, fork() is not implemented.
  2188.  
  2189. - Replace exec*() with spawn*() and exit() if the parent process waits
  2190.   for the termination of the new process (by calling wait() or by
  2191.   waiting for SIGCLD).  This is required to keep the process ID of the
  2192.   child process.  In a forked process, however, you don't have to do
  2193.   this because emx.dll does it for you.
  2194.  
  2195. - Programs reading a.out files should be changed to call _seek_hdr()
  2196.   or _fseek_hdr() before reading the header to support .exe files.
  2197.   More changes are usually required.
  2198.  
  2199. - Watch out for Unix file system hacks: Unix allows deleting and
  2200.   renaming an open file (the file will be deleted after being closed).
  2201.  
  2202. - Watch out for Unix file names (Unix is case sensitive, long file
  2203.   names and multiple dots are allowed).  On OS/2's HPFS multiple dots
  2204.   are also allowed; however, trailing dots are not significant (except
  2205.   for the special file names `.' and `..').
  2206.  
  2207. - The null device is called /dev/null under Unix.  The __open() system
  2208.   call translates the filenames "/dev/null" and "/dev/tty" (lower
  2209.   case, with slashes) to "nul" and "con", respectively.  However,
  2210.  
  2211.       system ("whatever >/dev/null");
  2212.  
  2213.   won't work as the standard OS/2 and DOS command interpreters don't
  2214.   recognize /dev/null.
  2215.  
  2216. - Programs using stdin, stdout or stderr for binary data should call
  2217.   _fsetmode() to switch the stream to binary mode.
  2218.  
  2219. - If you want to use \ for separating directories, changes may be
  2220.   necessary.  These changes are optional because / also works.
  2221.  
  2222. - Implement support for drive names.  This can be done by using
  2223.  
  2224.       #define getcwd _getcwd2
  2225.       #define chdir _chdir2
  2226.  
  2227.   In addition, some changes will be necessary.  For instance, you have
  2228.   to change code which checks whether a filename is an absolute path
  2229.   name.  _fullpath() and _abspath() can also be useful.
  2230.  
  2231. - Note that ///abc is a valid Unix filename.  It's equivalent to /abc.
  2232.  
  2233. - Note that chdir ("..") is a no-op under Unix if the current working
  2234.   directory is the root directory.  Under emx, chdir ("..") fails in
  2235.   the root directory.
  2236.  
  2237. - Use termio or termios or read the keyboard with _read_kbd() if you
  2238.   don't want to get input line by line.
  2239.  
  2240. - Under Unix, directories in environment variables (PATH, for
  2241.   instance) are separated by colons; use semicolons instead.
  2242.  
  2243. - Do not use the PTRACE_TRACEME request of ptrace(): use P_DEBUG
  2244.   instead when starting the process with spawn*().
  2245.  
  2246. - By default, signal processing is different when using signal():
  2247.   SIG_ACK should be used instead of the signal handler address to
  2248.   re-enable a signal by calling signal() when the signal handler has
  2249.   been called.  This behavior can be changed with the -Zbsd-signals
  2250.   and -Zsysv-signals options of GCC.  If you use POSIX.1 functions for
  2251.   signal handling, SIG_ACK is not required.
  2252.  
  2253. - The shell isn't called /bin/sh.  Use system().  system() and popen()
  2254.   don't expand wildcards (unless COMSPEC points to a shell which
  2255.   expands wildcards).
  2256.  
  2257. - Printing single characters is inefficient.  A solution is to use
  2258.  
  2259.       setvbuf (stdout, NULL, _IOLBF, BUFSIZ)
  2260.  
  2261.   and to use fflush (stdout) if you need the output immediately
  2262.   (flushing is required only after displaying prompting texts before
  2263.   reading input or displaying progress reports that don't end with a
  2264.   newline character).  GDB output has been made much faster by using
  2265.   line buffering.
  2266.  
  2267. - Note that VEOF != VMIN and VEOL != VTIME.  Programs which use VEOF
  2268.   and VEOL to access VMIN and VTIME, respectively, should be changed
  2269.   to use VMIN and VTIME.  emx uses separate fields for VEOF, VEOL,
  2270.   VMIN and VTIME.
  2271.  
  2272. - To use termio, you have to reset the IDEFAULT bit of c_lflag.  This
  2273.   does not apply to termios.
  2274.  
  2275.  
  2276. 7 Creating OS/2 programs
  2277. ========================
  2278.  
  2279. This section describes additional features available when devoloping
  2280. OS/2 programs.
  2281.  
  2282.  
  2283. 7.1 Calling OS/2 API functions
  2284. ------------------------------
  2285.  
  2286. Use
  2287.  
  2288.     #include <os2.h>
  2289.  
  2290. in your C files to call OS/2 API functions.  GCC automatically links
  2291. your program with os2.a (or os2.lib) by passing the -los2 option to
  2292. the linker.  If you call the linker manually, you have to tell the
  2293. linker to link with library os2.  Note that your program will crash if
  2294. it calls an OS/2 API function when run under DOS.
  2295.  
  2296. You can use either the header file that comes with emx (os2emx.h) or
  2297. the header files that come with the Developer's Toolkit for OS/2 (an
  2298. IBM product).  By default, os2emx.h is used when doing
  2299. #include <os2.h>.  To use the header files of the Developer's Toolkit
  2300. for OS/2, edit /emx/include/os2.h to #include os2tk.h instead of
  2301. os2emx.h, and add the toolkit include file directory to the
  2302. C_INCLUDE_PATH, CPLUS_INCLUDE_PATH and OBJC_INCLUDE_PATH environment
  2303. variables.  Instead of editing os2.h, you can #define
  2304. USE_OS2_TOOLKIT_HEADERS before doing #include <os2.h>.
  2305.  
  2306. Note that you should define INCL_WHATEVER constants when using
  2307. os2emx.h as you would with the IBM Developer's Toolkit for OS/2 --
  2308. though not all constants are tested by the current version of
  2309. os2emx.h.
  2310.  
  2311. When compiling C++ programs, you may have to define the preprocessor
  2312. symbol OS2EMX_PLAIN_CHAR.
  2313.  
  2314. When passing a pointer to a structure to a 16-bit function, the
  2315. structure must not cross a 64 KByte boundary.  This (currently) cannot
  2316. be automatically assured for structures allocated in the stack (auto
  2317. variables and function arguments).
  2318.  
  2319. To pass the address of an auto variable to a 16-bit function, you
  2320. should define the variable twice and use _THUNK_PTR_STRUCT_OK or
  2321. _THUNK_PTR_SIZE_OK to check which one is properly aligned.
  2322.  
  2323. To ensure that all structures passed to 16-bit functions are properly
  2324. aligned, define all those variables in a module of their own which
  2325. must be the first module linked.  This doesn't work if the combined
  2326. size of all those variables exceeds 64 KByte.  Use _tmalloc() to
  2327. allocate memory for structures passed to 16-bit functions.
  2328.  
  2329. The 32-bit wrappers for 16-bit OS/2 API functions are provided for
  2330. both static linking (library os2) and dynamic linking (library wrap,
  2331. emxwrap.dll).
  2332.  
  2333. os2emx.h contains declarations for the following OS/2 API functions:
  2334.  
  2335.  
  2336. Device I/O
  2337. ----------
  2338.  
  2339.     DosDevConfig                        DosPhysicalDisk
  2340.     DosDevIOCtl
  2341.  
  2342.  
  2343. Dynamic linking
  2344. ---------------
  2345.  
  2346.     DosFreeModule                       DosQueryModuleName
  2347.     DosLoadModule                       DosQueryProcAddr
  2348.     DosQueryModuleHandle                DosQueryProcType
  2349.  
  2350.  
  2351. Errors
  2352. ------
  2353.  
  2354.     DosErrClass                         DosError
  2355.  
  2356.  
  2357. Exceptions
  2358. ----------
  2359.  
  2360.     DosAcknowledgeSignalException       DosSetExceptionHandler
  2361.     DosEnterMustComplete                DosSetSignalExceptionFocus
  2362.     DosExitMustComplete                 DosUnsetExceptionHandler
  2363.     DosRaiseException                   DosUnwindException
  2364.     DosSendSignalException
  2365.  
  2366.  
  2367. File system
  2368. -----------
  2369.  
  2370.     DosCancelLockRequest                DosProtectSetFileSize
  2371.     DosClose                            DosProtectWrite
  2372.     DosCopy                             DosQueryCurrentDir
  2373.     DosCreateDir                        DosQueryCurrentDisk
  2374.     DosCreatePipe                       DosQueryFHState
  2375.     DosDelete                           DosQueryFileInfo
  2376.     DosDeleteDir                        DosQueryFSAttach
  2377.     DosDupHandle                        DosQueryFSInfo
  2378.     DosEditName                         DosQueryHType
  2379.     DosEnumAttribute                    DosQueryPathInfo
  2380.     DosFindClose                        DosQueryVerify
  2381.     DosFindFirst                        DosRead
  2382.     DosFindNext                         DosSetCurrentDir
  2383.     DosForceDelete                      DosSetDefaultDisk
  2384.     DosFSAttach                         DosSetFHState
  2385.     DosFSCtl                            DosSetFileInfo
  2386.     DosMove                             DosSetFileLocks
  2387.     DosOpen                             DosSetFilePtr
  2388.     DosProtectClose                     DosSetFileSize
  2389.     DosProtectEnumAttribute             DosSetFSInfo
  2390.     DosProtectOpen                      DosSetMaxFH
  2391.     DosProtectQueryFHState              DosSetPathInfo
  2392.     DosProtectQueryFileInfo             DosSetRelMaxFH
  2393.     DosProtectRead                      DosSetVerify
  2394.     DosProtectSetFHState                DosShutdown
  2395.     DosProtectSetFileInfo               DosResetBuffer
  2396.     DosProtectSetFileLocks              DosWrite
  2397.     DosProtectSetFilePtr
  2398.  
  2399.  
  2400. Help Manager
  2401. ------------
  2402.  
  2403.     DdfBeginList                        DdfSetFontStyle
  2404.     DdfBitmap                           DdfSetFormat
  2405.     DdfEndList                          DdfSetTextAlign
  2406.     DdfHyperText                        DdfText
  2407.     DdfInform                           WinAssociateHelpInstance
  2408.     DdfInitialize                       WinCreateHelpInstance
  2409.     DdfListItem                         WinCreateHelpTable
  2410.     DdfMetafile                         WinDestroyHelpInstance
  2411.     DdfPara                             WinLoadHelpTable
  2412.     DdfSetColor                         WinQueryHelpInstance
  2413.     DdfSetFont
  2414.  
  2415.  
  2416. Memory management
  2417. -----------------
  2418.  
  2419.     DosAllocMem                         DosQueryMem
  2420.     DosAllocSharedMem                   DosSetMem
  2421.     DosFreeMem                          DosSubAllocMem
  2422.     DosGetNamedSharedMem                DosSubFreeMem
  2423.     DosGetSharedMem                     DosSubSetMem
  2424.     DosGiveSharedMem                    DosSubUnsetMem
  2425.  
  2426.  
  2427. Messages
  2428. --------
  2429.  
  2430.     DosGetMessage                       DosPutMessage
  2431.     DosInsertMessage                    DosQueryMessageCP
  2432.  
  2433.  
  2434. Miscellanea
  2435. -----------
  2436.  
  2437.     DosQuerySysInfo                     DosSearchPath
  2438.     DosScanEnv
  2439.  
  2440.  
  2441. Named pipes
  2442. -----------
  2443.  
  2444.     DosCallNPipe                        DosQueryNPipeInfo
  2445.     DosConnectNPipe                     DosQueryNPipeSemState
  2446.     DosCreateNPipe                      DosSetNPHState
  2447.     DosDisConnectNPipe                  DosSetNPipeSem
  2448.     DosPeekNPipe                        DosTransactNPipe
  2449.     DosQueryNPHState                    DosWaitNPipe
  2450.  
  2451.  
  2452. National language support
  2453. -------------------------
  2454.  
  2455.     DosMapCase                          DosQueryCtryInfo
  2456.     DosQueryCollate                     DosQueryDBCSEnv
  2457.     DosQueryCp                          DosSetProcessCp
  2458.  
  2459.  
  2460. Queues
  2461. ------
  2462.  
  2463.     DosCloseQueue                       DosPurgeQueue
  2464.     DosCreateQueue                      DosQueryQueue
  2465.     DosOpenQueue                        DosReadQueue
  2466.     DosPeekQueue                        DosWriteQueue
  2467.  
  2468.  
  2469. Resources
  2470. ---------
  2471.  
  2472.     DosFreeResource                     DosQueryResourceSize
  2473.     DosGetResource
  2474.  
  2475.  
  2476. Semaphores
  2477. ----------
  2478.  
  2479.     DosAddMuxWaitSem                    DosOpenMuxWaitSem
  2480.     DosCloseEventSem                    DosPostEventSem
  2481.     DosCloseMutexSem                    DosQueryEventSem
  2482.     DosCloseMuxWaitSem                  DosQueryMutexSem
  2483.     DosCreateEventSem                   DosQueryMuxWaitSem
  2484.     DosCreateMutexSem                   DosReleaseMutexSem
  2485.     DosCreateMuxWaitSem                 DosRequestMutexSem
  2486.     DosDeleteMuxWaitSem                 DosResetEventSem
  2487.     DosOpenEventSem                     DosWaitEventSem
  2488.     DosOpenMutexSem                     DosWaitMuxWaitSem
  2489.  
  2490.  
  2491. Sessions
  2492. --------
  2493.  
  2494.     DosQueryAppType                     DosStartSession
  2495.     DosSelectSession                    DosStopSession
  2496.     DosSetSession
  2497.  
  2498.  
  2499. Tasking
  2500. -------
  2501.  
  2502.     DosBeep                             DosKillProcess
  2503.     DosCreateThread                     DosKillThread
  2504.     DosDebug                            DosResumeThread
  2505.     DosEnterCritSect                    DosSetPriority
  2506.     DosExecPgm                          DosSleep
  2507.     DosExit                             DosSuspendThread
  2508.     DosExitCritSect                     DosWaitChild
  2509.     DosExitList                         DosWaitThread
  2510.     DosGetInfoBlocks
  2511.  
  2512.  
  2513. Timers
  2514. ------
  2515.  
  2516.     DosAsyncTimer                       DosStopTimer
  2517.     DosGetDateTime                      DosTmrQueryFreq
  2518.     DosStartTimer                       DosTmrQueryTime
  2519.  
  2520.  
  2521. Virtual DOS machines
  2522. --------------------
  2523.  
  2524.     DosCloseVDD                         DosRequestVDD
  2525.     DosOpenVDD                          DosSetDOSProperty
  2526.     DosQueryDOSProperty
  2527.  
  2528.  
  2529. Graphics Programming Interface
  2530. ------------------------------
  2531.  
  2532.     GpiAnimatePalette                   GpiQueryFaceString
  2533.     GpiAssociate                        GpiQueryFontAction
  2534.     GpiBeginArea                        GpiQueryFontFileDescriptions
  2535.     GpiBeginElement                     GpiQueryFontMetrics
  2536.     GpiBeginPath                        GpiQueryFonts
  2537.     GpiBitBlt                           GpiQueryFullFontFileDescs
  2538.     GpiBox                              GpiQueryGraphicsField
  2539.     GpiCallSegmentMatrix                GpiQueryInitialSegmentAttrs
  2540.     GpiCharString                       GpiQueryKerningPairs
  2541.     GpiCharStringAt                     GpiQueryLineEnd
  2542.     GpiCharStringPos                    GpiQueryLineJoin
  2543.     GpiCharStringPosAt                  GpiQueryLineType
  2544.     GpiCloseFigure                      GpiQueryLineWidth
  2545.     GpiCloseSegment                     GpiQueryLineWidthGeom
  2546.     GpiCombineRegion                    GpiQueryLogColorTable
  2547.     GpiComment                          GpiQueryLogicalFont
  2548.     GpiConvert                          GpiQueryMarker
  2549.     GpiConvertWithMatrix                GpiQueryMarkerBox
  2550.     GpiCopyMetaFile                     GpiQueryMarkerSet
  2551.     GpiCorrelateChain                   GpiQueryMetaFileBits
  2552.     GpiCorrelateFrom                    GpiQueryMetaFileLength
  2553.     GpiCorrelateSegment                 GpiQueryMix
  2554.     GpiCreateBitmap                     GpiQueryModelTransformMatrix
  2555.     GpiCreateLogColorTable              GpiQueryNearestColor
  2556.     GpiCreateLogFont                    GpiQueryNumberSetIds
  2557.     GpiCreatePalette                    GpiQueryPS
  2558.     GpiCreateRegion                     GpiQueryPageViewport
  2559.     GpiCreatePS                         GpiQueryPalette
  2560.     GpiDeleteBitmap                     GpiQueryPaletteInfo
  2561.     GpiDeleteElement                    GpiQueryPattern
  2562.     GpiDeleteElementRange               GpiQueryPatternRefPoint
  2563.     GpiDeleteElementsBetweenLabels      GpiQueryPatternSet
  2564.     GpiDeleteMetaFile                   GpiQueryPel
  2565.     GpiDeletePalette                    GpiQueryPickAperturePosition
  2566.     GpiDeleteSegment                    GpiQueryPickApertureSize
  2567.     GpiDeleteSegments                   GpiQueryRealColors
  2568.     GpiDeleteSetId                      GpiQueryRegionBox
  2569.     GpiDestroyPS                        GpiQueryRegionRects
  2570.     GpiDestroyRegion                    GpiQueryRGBColor
  2571.     GpiDrawBits                         GpiQuerySegmentAttrs
  2572.     GpiDrawChain                        GpiQuerySegmentNames
  2573.     GpiDrawDynamics                     GpiQuerySegmentPriority
  2574.     GpiDrawFrom                         GpiQuerySegmentTransformMatrix
  2575.     GpiDrawSegment                      GpiQuerySetIds
  2576.     GpiElement                          GpiQueryStopDraw
  2577.     GpiEndArea                          GpiQueryTag
  2578.     GpiEndElement                       GpiQueryTextAlignment
  2579.     GpiEndPath                          GpiQueryTextBox
  2580.     GpiEqualRegion                      GpiQueryViewingLimits
  2581.     GpiErase                            GpiQueryViewingTransformMatrix
  2582.     GpiErrorSegmentData                 GpiQueryWidthTable
  2583.     GpiExcludeClipRectangle             GpiRectInRegion
  2584.     GpiFillPath                         GpiRectVisible
  2585.     GpiFloodFill                        GpiRemoveDynamics
  2586.     GpiFrameRegion                      GpiResetBoundaryData
  2587.     GpiFullArc                          GpiResetPS
  2588.     GpiGetData                          GpiRestorePS
  2589.     GpiImage                            GpiRotate
  2590.     GpiIntersectClipRectangle           GpiSaveMetaFile
  2591.     GpiLabel                            GpiSavePS
  2592.     GpiLine                             GpiScale
  2593.     GpiLoadBitmap                       GpiSelectPalette
  2594.     GpiLoadFonts                        GpiSetArcParams
  2595.     GpiLoadMetaFile                     GpiSetAttrMode
  2596.     GpiLoadPublicFonts                  GpiSetAttrs
  2597.     GpiMarker                           GpiSetBackColor
  2598.     GpiModifyPath                       GpiSetBackMix
  2599.     GpiMove                             GpiSetBitmap
  2600.     GpiOffsetClipRegion                 GpiSetBitmapBits
  2601.     GpiOffsetElementPointer             GpiSetBitmapDimension
  2602.     GpiOffsetRegion                     GpiSetBitmapId
  2603.     GpiOpenSegment                      GpiSetCharAngle
  2604.     GpiOutlinePath                      GpiSetCharBox
  2605.     GpiPaintRegion                      GpiSetCharBreakExtra
  2606.     GpiPartialArc                       GpiSetCharDirection
  2607.     GpiPathToRegion                     GpiSetCharExtra
  2608.     GpiPlayMetaFile                     GpiSetCharMode
  2609.     GpiPointArc                         GpiSetCharSet
  2610.     GpiPolyFillet                       GpiSetCharShear
  2611.     GpiPolyFilletSharp                  GpiSetClipPath
  2612.     GpiPolygons                         GpiSetClipRegion
  2613.     GpiPolyLine                         GpiSetColor
  2614.     GpiPolyLineDisjoint                 GpiSetCp
  2615.     GpiPolyMarker                       GpiSetCurrentPosition
  2616.     GpiPolySpline                       GpiSetDefArcParams
  2617.     GpiPop                              GpiSetDefAttrs
  2618.     GpiPtInRegion                       GpiSetDefaultViewMatrix
  2619.     GpiPtVisible                        GpiSetDefTag
  2620.     GpiPutData                          GpiSetDefViewingLimits
  2621.     GpiQueryArcParams                   GpiSetDrawControl
  2622.     GpiQueryAttrMode                    GpiSetDrawingMode
  2623.     GpiQueryAttrs                       GpiSetEditMode
  2624.     GpiQueryBackColor                   GpiSetElementPointer
  2625.     GpiQueryBackMix                     GpiSetElementPointerAtLabel
  2626.     GpiQueryBitmapBits                  GpiSetGraphicsField
  2627.     GpiQueryBitmapDimension             GpiSetInitialSegmentAttrs
  2628.     GpiQueryBitmapHandle                GpiSetLineEnd
  2629.     GpiQueryBitmapInfoHeader            GpiSetLineJoin
  2630.     GpiQueryBitmapParameters            GpiSetLineType
  2631.     GpiQueryBoundaryData                GpiSetLineWidth
  2632.     GpiQueryCharAngle                   GpiSetLineWidthGeom
  2633.     GpiQueryCharBox                     GpiSetMarker
  2634.     GpiQueryCharBreakExtra              GpiSetMarkerBox
  2635.     GpiQueryCharDirection               GpiSetMarkerSet
  2636.     GpiQueryCharExtra                   GpiSetMetaFileBits
  2637.     GpiQueryCharMode                    GpiSetMix
  2638.     GpiQueryCharSet                     GpiSetModelTransformMatrix
  2639.     GpiQueryCharShear                   GpiSetPageViewport
  2640.     GpiQueryCharStringPos               GpiSetPaletteEntries
  2641.     GpiQueryCharStringPosAt             GpiSetPattern
  2642.     GpiQueryClipBox                     GpiSetPatternRefPoint
  2643.     GpiQueryClipRegion                  GpiSetPatternSet
  2644.     GpiQueryColor                       GpiSetPel
  2645.     GpiQueryColorData                   GpiSetPickAperturePosition
  2646.     GpiQueryColorIndex                  GpiSetPickApertureSize
  2647.     GpiQueryCp                          GpiSetPS
  2648.     GpiQueryCurrentPosition             GpiSetRegion
  2649.     GpiQueryDefArcParams                GpiSetSegmentAttrs
  2650.     GpiQueryDefAttrs                    GpiSetSegmentPriority
  2651.     GpiQueryDefCharBox                  GpiSetSegmentTransformMatrix
  2652.     GpiQueryDefTag                      GpiSetStopDraw
  2653.     GpiQueryDefViewingLimits            GpiSetTag
  2654.     GpiQueryDefaultViewMatrix           GpiSetTextAlignment
  2655.     GpiQueryDevice                      GpiSetViewingLimits
  2656.     GpiQueryDeviceBitmapFormats         GpiSetViewingTransformMatrix
  2657.     GpiQueryDrawControl                 GpiStrokePath
  2658.     GpiQueryDrawingMode                 GpiTranslate
  2659.     GpiQueryEditMode                    GpiUnloadFonts
  2660.     GpiQueryElement                     GpiUnloadPublicFonts
  2661.     GpiQueryElementPointer              GpiWCBitBlt
  2662.     GpiQueryElementType
  2663.  
  2664.  
  2665. Device Contexts
  2666. ---------------
  2667.  
  2668.     DevCloseDC                          DevQueryCaps
  2669.     DevEscape                           DevQueryDeviceNames
  2670.     DevOpenDC                           DevQueryHardcopyCaps
  2671.     DevPostDeviceModes
  2672.  
  2673.  
  2674. Presentation Manager
  2675. --------------------
  2676.  
  2677.     WinAddAtom                          WinQueryAtomUsage
  2678.     WinAlarm                            WinQueryCapture
  2679.     WinBeginEnumWindows                 WinQueryClassInfo
  2680.     WinBeginPaint                       WinQueryClassName
  2681.     WinBroadcastMsg                     WinQueryClassThunkProc
  2682.     WinCalcFrameRect                    WinQueryClipbrdData
  2683.     WinCallMsgFilter                    WinQueryClipbrdFmtInfo
  2684.     WinCancelShutdown                   WinQueryClipbrdOwner
  2685.     WinCheckInput                       WinQueryClipbrdViewer
  2686.     WinCloseClipbrd                     WinQueryCp
  2687.     WinCompareStrings                   WinQueryCpList
  2688.     WinCopyAccelTable                   WinQueryCursorInfo
  2689.     WinCopyRect                         WinQueryDesktopBkgnd
  2690.     WinCpTranslateChar                  WinQueryDesktopWindow
  2691.     WinCpTranslateString                WinQueryDlgItemShort
  2692.     WinCreateAccelTable                 WinQueryDlgItemText
  2693.     WinCreateAtomTable                  WinQueryDlgItemTextLength
  2694.     WinCreateCursor                     WinQueryFocus
  2695.     WinCreateDlg                        WinQueryMsgPos
  2696.     WinCreateFrameControls              WinQueryMsgTime
  2697.     WinCreateMenu                       WinQueryObjectWindow
  2698.     WinCreateMsgQueue                   WinQueryPointer
  2699.     WinCreatePointer                    WinQueryPointerInfo
  2700.     WinCreatePointerIndirect            WinQueryPointerPos
  2701.     WinCreateStdWindow                  WinQueryPresParam
  2702.     WinCreateWindow                     WinQueryQueueInfo
  2703.     WinDdeInitiate                      WinQueryQueueStatus
  2704.     WinDdePostMsg                       WinQuerySysColor
  2705.     WinDdeRespond                       WinQuerySysModalWindow
  2706.     WinDefWindowProc                    WinQuerySysPointer
  2707.     WinDefDlgProc                       WinQuerySysPointerData
  2708.     WinDeleteAtom                       WinQuerySystemAtomTable
  2709.     WinDeleteLibrary                    WinQuerySysValue
  2710.     WinDeleteProcedure                  WinQueryUpdateRect
  2711.     WinDestroyAccelTable                WinQueryUpdateRegion
  2712.     WinDestroyAtomTable                 WinQueryVersion
  2713.     WinDestroyCursor                    WinQueryVisibleRegion
  2714.     WinDestroyMsgQueue                  WinQueryWindow
  2715.     WinDestroyPointer                   WinQueryWindowDC
  2716.     WinDestroyWindow                    WinQueryWindowModel
  2717.     WinDismissDlg                       WinQueryWindowPos
  2718.     WinDispatchMsg                      WinQueryWindowProcess
  2719.     WinDlgBox                           WinQueryWindowPtr
  2720.     WinDrawBitmap                       WinQueryWindowRect
  2721.     WinDrawBorder                       WinQueryWindowText
  2722.     WinDrawPointer                      WinQueryWindowTextLength
  2723.     WinDrawText                         WinQueryWindowThunkProc
  2724.     WinEmptyClipbrd                     WinQueryWindowULong
  2725.     WinEnablePhysInput                  WinQueryWindowUShort
  2726.     WinEnableWindow                     WinRealizePalette
  2727.     WinEnableWindowUpdate               WinRegisterClass
  2728.     WinEndEnumWindows                   WinRegisterUserDatatype
  2729.     WinEndPaint                         WinRegisterUserMsg
  2730.     WinEnumClipbrdFmts                  WinReleaseHook
  2731.     WinEnumDlgItem                      WinReleasePS
  2732.     WinEqualRect                        WinRemovePresParam
  2733.     WinExcludeUpdateRegion              WinRequestMutexSem
  2734.     WinFillRect                         WinSaveWindowPos
  2735.     WinFindAtom                         WinScrollWindow
  2736.     WinFlashWindow                      WinSendMsg
  2737.     WinFocusChange                      WinSendDlgItemMsg
  2738.     WinFreeErrorInfo                    WinSetAccelTable
  2739.     WinGetClipPS                        WinSetActiveWindow
  2740.     WinGetCurrentTime                   WinSetCapture
  2741.     WinGetDlgMsg                        WinSetClassMsgInterest
  2742.     WinGetErrorInfo                     WinSetClassThunkProc
  2743.     WinGetKeyState                      WinSetClipbrdData
  2744.     WinGetLastError                     WinSetClipbrdOwner
  2745.     WinGetMaxPosition                   WinSetClipbrdViewer
  2746.     WinGetMinPosition                   WinSetCp
  2747.     WinGetMsg                           WinSetDesktopBkgnd
  2748.     WinGetNextWindow                    WinSetDlgItemShort
  2749.     WinGetPhysKeyState                  WinSetDlgItemText
  2750.     WinGetPS                            WinSetFocus
  2751.     WinGetScreenPS                      WinSetHook
  2752.     WinGetSysBitmap                     WinSetKeyboardStateTable
  2753.     WinInflateRect                      WinSetMsgInterest
  2754.     WinInitialize                       WinSetMsgMode
  2755.     WinInSendMsg                        WinSetMultWindowPos
  2756.     WinIntersectRect                    WinSetOwner
  2757.     WinInvalidateRect                   WinSetParent
  2758.     WinInvalidateRegion                 WinSetPointer
  2759.     WinInvertRect                       WinSetPointerOwner
  2760.     WinIsChild                          WinSetPointerPos
  2761.     WinIsPhysInputEnabled               WinSetPresParam
  2762.     WinIsRectEmpty                      WinSetRect
  2763.     WinIsThreadActive                   WinSetRectEmpty
  2764.     WinIsWindow                         WinSetSynchroMode
  2765.     WinIsWindowEnabled                  WinSetSysColors
  2766.     WinIsWindowShowing                  WinSetSysModalWindow
  2767.     WinIsWindowVisible                  WinSetSysPointerData
  2768.     WinLoadAccelTable                   WinSetSysValue
  2769.     WinLoadDlg                          WinSetVisibleRegionNotify
  2770.     WinLoadMenu                         WinSetWindowBits
  2771.     WinLoadLibrary                      WinSetWindowPos
  2772.     WinLoadMessage                      WinSetWindowPtr
  2773.     WinLoadPointer                      WinSetWindowText
  2774.     WinLoadProcedure                    WinSetWindowThunkProc
  2775.     WinLoadString                       WinSetWindowULong
  2776.     WinLockPointerUpdate                WinSetWindowUShort
  2777.     WinLockVisRegions                   WinShowCursor
  2778.     WinLockWindowUpdate                 WinShowPointer
  2779.     WinMakePoints                       WinShowTrackRect
  2780.     WinMakeRect                         WinShowWindow
  2781.     WinMapDlgPoints                     WinStartTimer
  2782.     WinMapWindowPoints                  WinStopTimer
  2783.     WinMessageBox                       WinSubclassWindow
  2784.     WinMultWindowFromIDs                WinSubstituteStrings
  2785.     WinNextChar                         WinSubtractRect
  2786.     WinOffsetRect                       WinTerminate
  2787.     WinOpenClipbrd                      WinTrackRect
  2788.     WinOpenWindowDC                     WinTranslateAccel
  2789.     WinPeekMsg                          WinUnionRect
  2790.     WinPopupMenu                        WinUpdateWindow
  2791.     WinPostMsg                          WinUpper
  2792.     WinPostQueueMsg                     WinUpperChar
  2793.     WinPrevChar                         WinValidateRect
  2794.     WinProcessDlg                       WinValidateRegion
  2795.     WinPtInRect                         WinWaitEventSem
  2796.     WinQueryAccelTable                  WinWaitMsg
  2797.     WinQueryActiveWindow                WinWaitMuxWaitSem
  2798.     WinQueryAnchorBlock                 WinWindowFromDC
  2799.     WinQueryAtomLength                  WinWindowFromID
  2800.     WinQueryAtomName                    WinWindowFromPoint
  2801.  
  2802.  
  2803. Standard Dialogs
  2804. ----------------
  2805.  
  2806.     WinDefFileDlgProc                   WinFreeFileDlgList
  2807.     WinDefFontDlgProc                   WinFontDlg
  2808.     WinFileDlg
  2809.  
  2810.  
  2811. Presentation Manager Shell
  2812. --------------------------
  2813.  
  2814.     PrfAddProgram                       PrfQueryProfileInt
  2815.     PrfChangeProgram                    PrfQueryProfileSize
  2816.     PrfCloseProfile                     PrfQueryProfileString
  2817.     PrfOpenProfile                      PrfRemoveProgram
  2818.     PrfQueryDefinition                  PrfReset
  2819.     PrfQueryProgramTitles               PrfWriteProfileData
  2820.     PrfQueryProfile                     PrfWriteProfileString
  2821.     PrfQueryProfileData
  2822.     
  2823.     WinAddSwitchEntry                   WinQueryTaskSizePos
  2824.     WinChangeSwitchEntry                WinQueryTaskTitle
  2825.     WinCreateSwitchEntry                WinRemoveSwitchEntry
  2826.     WinQuerySessionTitle                WinSwitchToProgram
  2827.     WinQuerySwitchEntry                 WinStartApp
  2828.     WinQuerySwitchHandle                WinTerminateApp
  2829.     WinQuerySwitchList
  2830.  
  2831.  
  2832. Spooler
  2833. -------
  2834.  
  2835.     SplControlDevice                    SplQmClose
  2836.     SplCopyJob                          SplQmEndDoc
  2837.     SplCreateDevice                     SplQmOpen
  2838.     SplCreateQueue                      SplQmStartDoc
  2839.     SplDeleteDevice                     SplQmWrite
  2840.     SplDeleteJob                        SplQueryDevice
  2841.     SplDeleteQueue                      SplQueryJob
  2842.     SplEnumDevice                       SplQueryQueue
  2843.     SplEnumDriver                       SplReleaseJob
  2844.     SplEnumJob                          SplReleaseQueue
  2845.     SplEnumPort                         SplSetDevice
  2846.     SplEnumPrinter                      SplSetJob
  2847.     SplEnumQueue                        SplSetQueue
  2848.     SplEnumQueueProcessor               SplStdClose
  2849.     SplHoldJob                          SplStdDelete
  2850.     SplHoldQueue                        SplStdGetBits
  2851.     SplMessageBox                       SplStdOpen
  2852.     SplPurgeQueue                       SplStdQueryLength
  2853.     SplQmAbort                          SplStdStart
  2854.     SplQmAbortDoc                       SplStdStop
  2855.  
  2856.  
  2857. Monitors
  2858. --------
  2859.  
  2860.     DosMonClose                         DosMonReg
  2861.     DosMonOpen                          DosMonWrite
  2862.     DosMonRead
  2863.  
  2864.  
  2865. Keyboard Subsystem
  2866. ------------------
  2867.  
  2868.     KbdCharIn                           KbdPeek
  2869.     KbdClose                            KbdRegister
  2870.     KbdDeRegister                       KbdSetCp
  2871.     KbdFlushBuffer                      KbdSetCustXt
  2872.     KbdFreeFocus                        KbdSetFgnd
  2873.     KbdGetCp                            KbdSetHWID
  2874.     KbdGetFocus                         KbdSetStatus
  2875.     KbdGetHWID                          KbdStringIn
  2876.     KbdGetStatus                        KbdSynch
  2877.     KbdOpen                             KbdXlate
  2878.  
  2879.  
  2880. Video Subsystem
  2881. ---------------
  2882.  
  2883.     VioCheckCharType                    VioSavRedrawWait
  2884.     VioDeRegister                       VioScrLock
  2885.     VioEndPopUp                         VioScrollDn
  2886.     VioGetAnsi                          VioScrollLf
  2887.     VioGetBuf                           VioScrollRt
  2888.     VioGetConfig                        VioScrollUp
  2889.     VioGetCp                            VioScrUnLock
  2890.     VioGetCurPos                        VioSetAnsi
  2891.     VioGetCurType                       VioSetCp
  2892.     VioGetFont                          VioSetCurPos
  2893.     VioGetMode                          VioSetCurType
  2894.     VioGetPhysBuf                       VioSetFont
  2895.     VioGetState                         VioSetMode
  2896.     VioGlobalReg                        VioSetState
  2897.     VioModeUndo                         VioShowBuf
  2898.     VioModeWait                         VioWrtCellStr
  2899.     VioPopUp                            VioWrtCharStr
  2900.     VioPrtSc                            VioWrtCharStrAttr
  2901.     VioPrtScToggle                      VioWrtNAttr
  2902.     VioReadCellStr                      VioWrtNCell
  2903.     VioReadCharStr                      VioWrtNChar
  2904.     VioRegister                         VioWrtTTY
  2905.     VioSavRedrawUndo
  2906.  
  2907.  
  2908. Advanced Video
  2909. --------------
  2910.  
  2911.     VioAssociate                        VioQueryFonts
  2912.     VioCreateLogFont                    VioQuerySetIds
  2913.     VioCreatePS                         VioSetDeviceCellSize
  2914.     VioDeleteSetId                      VioSetOrg
  2915.     VioDestroyPS                        VioShowPS
  2916.     VioGetDeviceCellSize                WinDefAVioWindowProc
  2917.     VioGetOrg
  2918.  
  2919.  
  2920. Mouse Subsystem
  2921. ---------------
  2922.  
  2923.     MouClose                            MouInitReal
  2924.     MouDeRegister                       MouOpen
  2925.     MouDrawPtr                          MouReadEventQue
  2926.     MouFlushQue                         MouRegister
  2927.     MouGetDevStatus                     MouRemovePtr
  2928.     MouGetEventMask                     MouSetDevStatus
  2929.     MouGetNumButtons                    MouSetEventMask
  2930.     MouGetNumMickeys                    MouSetPtrPos
  2931.     MouGetNumQueEl                      MouSetPtrShape
  2932.     MouGetPtrPos                        MouSetScaleFact
  2933.     MouGetPtrShape                      MouSetThreshold
  2934.     MouGetScaleFact                     MouSynch
  2935.     MouGetThreshold
  2936.  
  2937.  
  2938. 7.2 Importing from OS/2 DLLs
  2939. ----------------------------
  2940.  
  2941. All functions in the list above are defined in os2.a and os2.lib.
  2942. Moreover, the 32-bit wrappers for the 16-bit OS/2 API functions are
  2943. available in the dynamic link library emxwrap.dll to reduce the size
  2944. of the executables.  The import library for emxwrap.dll is wrap.  To
  2945. import functions not defined in os2.a and os2.lib, you have to create
  2946. an import list file for these functions.
  2947.  
  2948. See the emximp documentation for details.
  2949.  
  2950. Please note that you cannot directly call 16-bit functions not listed
  2951. above.  See below for details.
  2952.  
  2953.  
  2954. 7.3 Creating Presentation Manager applications using ld and emxbind
  2955. -------------------------------------------------------------------
  2956.  
  2957. To create a Presentation Manager application using ld and emxbind,
  2958.  
  2959. - #include <os2.h>
  2960.  
  2961. - link with os2.a (done automatically when using GCC to link)
  2962.  
  2963. - use rc -r to compile the resource-definition file into a binary
  2964.   resource file (.res file)
  2965.  
  2966. - use emxbind -ep or a module definition file to set the application
  2967.   type
  2968.  
  2969. - use the -r option of emxbind to put the resources from the binary
  2970.   resource file into the .exe file.  If there is a .res file on the
  2971.   GCC or ld command line, it is automatically passed to emxbind
  2972.  
  2973. Do not use rc to put the resources into the .exe file!
  2974.  
  2975. Example:
  2976.  
  2977.     cd \emx\test
  2978.     rc -r pm1.rc
  2979.     gcc -o pm1 pm1.c
  2980.     emxbind -bp -rpm1.res /emx/bin/emxl pm1
  2981.  
  2982. Ditto, using a module definition file:
  2983.  
  2984.     cd \emx\test
  2985.     rc -r pm1.rc
  2986.     gcc -o pm1.exe pm1.c pm1.def pm1.res
  2987.  
  2988. Example (compiling the `template' toolkit sample program):
  2989.  
  2990.     cd \toolkt20\c\samples\template
  2991.     copy ..\prodinfo.bmp
  2992.     rc -r main.rc
  2993.     gcc -s -o template.exe *.c template.def main.res
  2994.  
  2995.  
  2996. 7.4 Creating Presentation Manager applications using emxomf and LINK386
  2997. -----------------------------------------------------------------------
  2998.  
  2999. To create a Presentation Manager application using emxomf and LINK386,
  3000.  
  3001. - #include <os2.h>
  3002.  
  3003. - link with os2.lib (done automatically when using GCC to link)
  3004.  
  3005. - use a module definition file which uses the WINDOWAPI keyword of the
  3006.   NAME statement
  3007.  
  3008. - use rc -r to compile the resource-definition file into a binary
  3009.   resource file (.res file)
  3010.  
  3011. - use rc or emxomfld to add the binary resource file to the .exe file.
  3012.   Optionally, you can compile the resource-definition file and add it
  3013.   to the .exe file using rc in one step.  Using two steps is
  3014.   recommended in makefiles.
  3015.  
  3016. Example:
  3017.  
  3018.     cd \emx\test
  3019.     rc -r pm1.rc
  3020.     gcc -o pm1.exe pm1.c pm1.def pm1.res -Zomf
  3021.  
  3022. Example (compiling the `template' toolkit sample program):
  3023.  
  3024.     cd \toolkt20\c\samples\template
  3025.     copy ..\prodinfo.bmp
  3026.     rc -r main.rc
  3027.     gcc -Zomf -o template.exe *.c template.def main.res
  3028.  
  3029. If you want to use the -Zsys option, you should increase the stack
  3030. size by editing the STACKSIZE statement in the .def file.  Note that
  3031. the command line arguments and the complete environment are copied to
  3032. the stack!  The stack size should be at least 32768.
  3033.  
  3034.  
  3035. 7.5 Creating Workplace Shell applications
  3036. -----------------------------------------
  3037.  
  3038. Dynamic link libraries for Workplace Shell objects should be either
  3039. DLLs without C runtime environment or stand-alone DLLs (see below).
  3040.  
  3041. For creating Workplace Shell applications, you need the SOM headers
  3042. and the SOM compiler from the Developer's Toolkit for OS/2 (an IBM
  3043. product).
  3044.  
  3045. See the `flag' example in /emx/samples.
  3046.  
  3047.  
  3048. 7.6 Creating dynamic link libraries
  3049. -----------------------------------
  3050.  
  3051. There are six types of dynamic link libraries:
  3052.  
  3053. 1.  DLLs which use emxlibcm.dll or emxlibcs.dll or a custom C runtime
  3054.     DLL.  These DLLs don't contain C library functions.  Calls to C
  3055.     library functions are resolved by emxlibcm.dll or emxlibcs.dll or
  3056.     a custom C runtime DLL (and, in all three cases, emx.dll).  The
  3057.     main program and all DLLs must use the same C runtime DLL.
  3058.  
  3059. 2.  Custom C runtime DLLs.  These DLLs contain the C library or parts
  3060.     thereof and export the C library functions to other DLLs and to
  3061.     the main program.  An application (main program and DLLs) should
  3062.     use only one custom C runtime DLL; emxlibcm.dll and emxlibcs.dll
  3063.     should not be used.  Either the system call library sys.lib or
  3064.     emx.dll can be used.  This type of DLL is recommended if you want
  3065.     to ship your application with your own DLLs, but without any emx
  3066.     DLLs.  This type of DLL can also be used when replacing library
  3067.     functions such as malloc() which are referenced by other library
  3068.     functions.
  3069.  
  3070. 3.  C runtime forwarder DLLs.  These DLLs forward all C runtime
  3071.     functions to emxlibcm.dll or emxlibcs.dll, and add some functions
  3072.     of their own.  However, they cannot safely replace functions of
  3073.     emxlibcm.dll or emxlibcs.dll as the latter ones won't call the
  3074.     replacement functions.
  3075.  
  3076. 4.  Stand-alone DLLs.  These DLLs contain the C library or parts
  3077.     thereof, which is used privately by the DLL.  The main program and
  3078.     the other DLLs use a different C runtime environment.  You should
  3079.     use only `simple' C library functions such as memcpy() which don't
  3080.     require global variables.
  3081.  
  3082.     Keep in mind that the DLL and the program using the DLL don't
  3083.     share global variables such as errno, timezone, and -- very
  3084.     important -- the variables used for I/O.
  3085.  
  3086. 5.  DLLs without C runtime environment.  These DLLs don't call any C
  3087.     library functions which require a runtime environment.  Only OS/2
  3088.     API functions and simple C library functions such as strcpy() can
  3089.     be called.
  3090.  
  3091. 6.  Resource DLLs.  These DLLs contain only resources.  Some bits of
  3092.     code are required for library initialization.
  3093.  
  3094. Write a module definition file (.def file) that contains a LIBRARY
  3095. statement and an EXPORTS statement.  The EXPORTS statement has to list
  3096. all functions to be exported by your DLL.  The .def file should have
  3097. the same name as the .dll file to be created.
  3098.  
  3099. Compile and link your program using the -Zdll option of GCC.  This
  3100. option causes the dll0 startup to be used instead of crt0 and selects
  3101. appropriate libraries.  As DLLs are usually multithread libraries, you
  3102. should also use the -Zmt option.  Specify the name of the .def file on
  3103. the GCC or ld command line, respectively.
  3104.  
  3105. Using the -mprobe GCC option is recommended for creating DLLs as the
  3106. DLL might be called from a thread with uncommitted stack.
  3107.  
  3108. Linking with LINK386 (using GCC -Zomf) is recommended for dynamic link
  3109. libraries.  Using ld and emxbind offers no advantages when creating
  3110. dynamic link libraries.
  3111.  
  3112.  
  3113. 7.6.1 Creating dynamic link libraries that use a C library DLL
  3114. --------------------------------------------------------------
  3115.  
  3116. Dynamic link libraries that use emxlibcm.dll or emxlibcs.dll (or a
  3117. custom C runtime DLL) are allowed to call all library functions,
  3118. including stream I/O, as long as they are used together with programs
  3119. and other dynamic link libraries that use the same emxlibcm.dll or
  3120. emxlibcs.dll (or the same custom C runtime DLL used by the DLL).  That
  3121. is, all I/O done by C library functions must be done in a single
  3122. place, emxlibcm.dll, emxlibcs.dll, or the custom C runtime DLL.  As
  3123. the C library is initialized by the program using the DLL, your
  3124. library initialization function need not call _CRT_init().  The
  3125. following GCC options are used for building a DLL which uses a C
  3126. library DLL: -Zdll -Zcrtdll.  To link an application with your import
  3127. library, use the GCC option -Zcrtdll=<lib>.
  3128.  
  3129. The default _DLL_InitTerm() function calls constructors and
  3130. destructors, but does not call _CRT_init() and _CRT_term() as the
  3131. client application of the DLL initializes the runtime environment by
  3132. calling appropriate functions of the C library DLL.
  3133.  
  3134. See /emx/test/testdll3.cc for an example.
  3135.  
  3136.  
  3137. 7.6.2 Creating custom C runtime DLLs
  3138. ------------------------------------
  3139.  
  3140. Creating a custom C runtime DLL means creating a DLL which contains
  3141. your own code and some or all code of emxlibcm.dll or emxlibcs.dll.
  3142. Write a module definition file which exports your functions and all C
  3143. library functions and variables referenced by the main program and
  3144. other DLLs using the custom C runtime DLL.  You can use
  3145. /emx/lib/cdll.def as template.  Don't forget to use the following
  3146. statement:
  3147.  
  3148.     DATA
  3149.       MULTIPLE NONSHARED
  3150.  
  3151. Use the following GCC option for building a custom C runtime DLL:
  3152. -Zdll.  The options -Zomf and -Zsys are optional.
  3153.  
  3154. The following object files should be added to the import library for
  3155. your DLL: appinit.obj, dllinit.obj, ctor.obj, and dtor.obj.  These
  3156. object files and analogous .o files live in directory /emx/lib.
  3157.  
  3158. If clients of your DLL call the hardware port I/O functions such as
  3159. _inp8(), either link the clients with -lemxio or use
  3160. /emx/src/lib/cdll/emxio.def in addition to your module definition file
  3161. for creating the import library (it is essential to import the
  3162. functions from emxio.dll, therefore appending emxio.def to your module
  3163. definition file won't work).
  3164.  
  3165. To use your custom C runtime DLL, you should invoke LINK386 instead of
  3166. GCC to link (or give crt0 or dll0 on the command line and use the
  3167. -nostdlib option and your import library).
  3168.  
  3169. The default _DLL_InitTerm() function calls constructors and
  3170. destructors, but does not call _CRT_init() and _CRT_term() as the
  3171. client application of the DLL initializes the runtime environment by
  3172. calling appropriate functions of the DLL.
  3173.  
  3174. See /emx/test/testdll4.c for an example.
  3175.  
  3176.  
  3177. 7.6.3 Creating C runtime forwarder DLLs
  3178. ---------------------------------------
  3179.  
  3180. Creating a C runtime forwarder DLL is similar to creating a custom C
  3181. runtime DLL (see above).  However, instead of statically linking the C
  3182. runtime library, it is linked dynamically.  That is, the exports of
  3183. the forwarder DLL are resolved by imports from emxlibcm.dll or
  3184. emxlibcs.dll.
  3185.  
  3186. Use the following GCC option for building a forwarder DLL: -Zdll -Zomf
  3187. -Zcrtdll.  As emxbind does not support forwarders, you have to use
  3188. -Zomf.
  3189.  
  3190.  
  3191. 7.6.4 Creating stand-alone dynamic link libraries
  3192. -------------------------------------------------
  3193.  
  3194. A stand-alone dynamic link library has its own runtime environment
  3195. which is not shared with the client application or other DLLs.  Use
  3196. the following GCC options for creating a stand-alone DLL: -Zdll -Zso
  3197. -Zsys -Zomf.
  3198.  
  3199. The default _DLL_InitTerm() function calls constructors and
  3200. destructors, and calls _CRT_init() and _CRT_term() to initialize and
  3201. terminate the runtime environment.
  3202.  
  3203. See /emx/test/testdll5.c for an example.
  3204.  
  3205.  
  3206. 7.6.5 Creating dynamic link libraries without C runtime environment
  3207. -------------------------------------------------------------------
  3208.  
  3209. To create a dynamic link library without C runtime, do not reference
  3210. any C library function which requires a runtime environment.  As the
  3211. new operator of C++ calls malloc(), you cannot use C++ to create a DLL
  3212. of this type unless you provide your own memory management.  Do not
  3213. use -Zmt even if the DLL is used by multithread programs; you have to
  3214. use Mutex semaphores when using functions such as strtok() which are
  3215. not thread-safe.  Use the following GCC options to build a DLL without
  3216. C runtime environment: -Zdll -Zno-rte -Zomf.
  3217.  
  3218. The default _DLL_InitTerm() function calls constructors and
  3219. destructors, but does not call _CRT_init() and _CRT_term() as there is
  3220. no runtime environment to initialize.
  3221.  
  3222. See /emx/test/testdll1.c for an example.
  3223.  
  3224.  
  3225. 7.6.6 Creating resource DLLs
  3226. ----------------------------
  3227.  
  3228. To create a resource DLL, build a DLL from /emx/lib/res0.obj and add
  3229. the resources with rc:
  3230.  
  3231.     link386 \emx\lib\res0,myres.dll,nul,,myres.def
  3232.     rc myres.res myres.dll
  3233.  
  3234. The module definition file should start with a LIBRARY statement.
  3235.  
  3236.  
  3237. 7.6.7 Creating dynamic link libraries using C++
  3238. -----------------------------------------------
  3239.  
  3240. You should not use the GNU C++ libraries (gpp and iostream) if you
  3241. create a DLL (unless you are building a stand-alone DLL or a private C
  3242. runtime DLL) as there is not yet a DLL version of these libraries.
  3243.  
  3244. As creating the module definition file for the DLL by hand is quite
  3245. boring, you should let your computer do it: see the description of the
  3246. emxexp tool for details.  The sign sample of emxample.zip uses emxexp
  3247. to create the module definition file.
  3248.  
  3249. To call the constructors and destructors for static objects in the
  3250. DLL, make sure that the _DLL_InitTerm() function of the DLL calls
  3251. __ctordtorInit() and __ctordtorTerm().
  3252.  
  3253.  
  3254. 7.7 Using the DLL version of the C library
  3255. ------------------------------------------
  3256.  
  3257. To use emxlibcm.dll or emxlibcs.dll, simply type -Zcrtdll on the GCC
  3258. command line.  This links your program with the import libraries
  3259. c_import.a or c_import.lib instead of the static C library (c, c_app,
  3260. gcc, emx).  -Zcrtdll can be used with methods (E1) and (E2).  See the
  3261. introduction for further information.
  3262.  
  3263. Note that emxlibcm.dll and emxlibcs.dll use emx.dll.  Thus, the
  3264. restrictions of -Zsys do not apply.
  3265.  
  3266. Do not redefine functions in your program which are contained in
  3267. emxlibcm.dll or emxlibcs.dll.  Other functions in emxlibcm.dll or
  3268. emxlibcs.dll will continue to use the original versions in that DLL
  3269. which will cause problems.  If you have to replace library functions
  3270. and want to use a C library DLL, create a new DLL (which must not be
  3271. called emxlibc.dll, emxlibcm.dll, or emxlibcs.dll), add your
  3272. replacement functions and all the functions of emxlibcm.dll or
  3273. emxlibcs.dll except for the functions you are replacing.
  3274.  
  3275.  
  3276. 7.8 Creating multithread programs
  3277. ---------------------------------
  3278.  
  3279. Multithread programs have to use either the multithread static
  3280. libraries or the dynamic link library emxlibcm.dll.  You have to say
  3281. -Zmt on the GCC command line.
  3282.  
  3283. Use _beginthread() to start a new thread.  Do not use DosCreateThread
  3284. unless the new thread doesn't call C library functions.
  3285.  
  3286. The C library functions in mt/c.a, mt/c.lib, and emxlibcm.dll are not
  3287. yet completely thread-safe: access to the stream I/O data should be
  3288. serialized.  The -Zmt, -Zmts, and -Zmtd options define the __MT__
  3289. preprocessor macro.  The C library header files check for __MT__ to
  3290. use alternate definitions suitable for multithread programs when -Zmt,
  3291. -Zmts, or -Zmtd is used.
  3292.  
  3293. Each thread has its own errno value.  To create a library which can be
  3294. used for both single-thread and multithread programs, use the _errno()
  3295. function instead of the errno variable.
  3296.  
  3297. If you are very careful, you can write multithread programs that use
  3298. the single-thread libraries.  Only the main thread is allowed to call
  3299. library functions that have side effects, including functions that set
  3300. errno.  All other threads should use OS/2 API functions instead.
  3301.  
  3302. For performance reasons, single-thread programs should be linked with
  3303. the single-thread libraries (that is, without the -Zmt option).
  3304.  
  3305.  
  3306. 7.9 Calling 16-bit functions
  3307. ----------------------------
  3308.  
  3309. Limited support for calling 16-bit functions is available.  You can
  3310. call 16-bit OS/2 API functions and other 16-bit functions that use the
  3311. pascal (_pascal) or C (_cdecl) calling convention and are exported by
  3312. a dynamic link library.  As no changes have been made to GCC to
  3313. support direct calls to 16-bit functions (this would require big
  3314. changes to GCC), you have to call 16-bit functions by applying the
  3315. (awkward) C preprocessor macros and functions described below.  There
  3316. are two sets of macros, one for the pascal calling convention
  3317. (_THUNK_PASCAL_***) and one for the C calling convention
  3318. (_THUNK_C_***).  For convenience and compatibility with emx 0.8f,
  3319. there are also macros _THUNK_*** which are aliases for the
  3320. _THUNK_PASCAL_*** macros.  For brevity, only the _THUNK_*** macros are
  3321. explained below.  To call a _cdecl function, use _THUNK_C_FUNCTION
  3322. etc. instead of _THUNK_FUNCTION etc.
  3323.  
  3324. _THUNK_FUNCTION(FUNCTION)
  3325.  
  3326.     This macro is used for declaring the 16-bit function.  The
  3327.     function is declared as usual, using a prototype, but
  3328.     _THUNK_FUNCTION is applied to the function name.  The 16-bit
  3329.     function must not be called directly.
  3330.  
  3331. _THUNK_PROLOG(SIZE)
  3332.  
  3333.     For each call to the 16-bit function, this macro must be called
  3334.     first.  SIZE is the number of bytes in the argument list of the
  3335.     16-bit function.  After calling _THUNK_PROLOG, the following
  3336.     macros are used to build the argument list.  The macros are to be
  3337.     applied left-to-right, that is, the first argument is handled
  3338.     first both for the pascal and the C calling convention.
  3339.  
  3340. _THUNK_CHAR(ARG)
  3341.  
  3342.     Pass an 8-bit argument to the function.
  3343.  
  3344. _THUNK_SHORT(ARG)
  3345.  
  3346.     Pass a 16-bit argument to the function.
  3347.  
  3348. _THUNK_LONG(ARG)
  3349.  
  3350.     Pass a 32-bit argument to the function.
  3351.  
  3352. _THUNK_FLAT(ARG)
  3353.  
  3354.     Pass a 32-bit (flat) pointer to the function.
  3355.  
  3356. _THUNK_FAR16(ARG)
  3357.  
  3358.     Pass a 16:16-bit far pointer to the function.  After building the
  3359.     argument list, the 16-bit function is called by invoking the
  3360.     following macro.
  3361.  
  3362. _THUNK_CALL(FUNCTION)
  3363.  
  3364.     Call the 16-bit function FUNCTION.  Do not apply _THUNK_FUNCTION
  3365.     to the function name.
  3366.  
  3367. _THUNK_CALLI(FUNCTION)
  3368.  
  3369.     Call the 16-bit function pointed to by the 16:16-bit far pointer
  3370.     FUNCTION.  Use this macro instead of _THUNK_CALL when employing
  3371.     DosLoadModule and DosQueryProcAddr.  The pointer returned by
  3372.     DosQueryProcAddr must be turned into a 16:16-bit far pointer by
  3373.     calling _emx_32to16().
  3374.  
  3375. There should be no statements other than calls to the _THUNK macros
  3376. between _THUNK_PROLOG and _THUNK_CALL.  _THUNK_PROLOG starts an
  3377. expression which is terminated by _THUNK_CALL.  Therefore, the return
  3378. value of the 16-bit function is returned by _THUNK_CALL and by the
  3379. entire sequences of statements from _THUNK_PROLOG to _THUNK_CALL.  The
  3380. return value is the value returned by the 16-bit function in the DX
  3381. and AX registers.  If the function returns a 16-bit value, you have to
  3382. typecast the return value to SHORT or USHORT to discard the upper 16
  3383. bits.
  3384.  
  3385. See the description of _emx_16to32() and _emx_32to16() for converting
  3386. 16-bit far pointers to 32-bit flat pointers and vice versa.  This
  3387. conversion is not done automatically.
  3388.  
  3389. You will get a warning about the variable _tp being unused if the
  3390. 16-bit function doesn't take arguments.  This warning is harmless.
  3391.  
  3392. When passing a pointer to a structure to a 16-bit function, the
  3393. structure must not cross a 64 KByte boundary.  This (currently) cannot
  3394. be assured for structures allocated in the stack (auto variables and
  3395. function arguments).  To ensure that all structures passed to 16-bit
  3396. functions are properly aligned, define all those variables in a module
  3397. of their own which must be the first module linked.  This doesn't work
  3398. if the combined size of all those variables exceeds 64 KByte.
  3399. Alternatively, you can define the variable twice and use
  3400. _THUNK_PTR_STRUCT_OK or _THUNK_PTR_SIZE_OK to check which one is
  3401. properly aligned.  Use _tmalloc() to allocate memory for structures
  3402. passed to 16-bit functions.  Example:
  3403.  
  3404.     #include <os2.h>                /* define _THUNK_*** macros */
  3405.     
  3406.     /* Declare 16-bit function */
  3407.     USHORT _THUNK_FUNCTION (Dos16Beep) (USHORT usFrequency, USHORT usDuration);
  3408.     
  3409.     void beep (int frequency, int duration)
  3410.     {
  3411.       _THUNK_PROLOG (2+2);
  3412.       _THUNK_SHORT (frequency);
  3413.       _THUNK_SHORT (duration);
  3414.       _THUNK_CALL (Dos16Beep);
  3415.     }
  3416.  
  3417. See /emx/test/c16test1.c, /emx/test/c16test2.c,
  3418. /emx/src/lib/sys/scrsize.c, and /emx/src/lib/os2/*.c for more
  3419. examples.
  3420.  
  3421.  
  3422. 8 Customizing
  3423. =============
  3424.  
  3425. Default values are provided for the heap size, the stack size and the
  3426. number of files that can be open simultaneously.  The following
  3427. sections describe how to increase the limits.
  3428.  
  3429.  
  3430. 8.1 Increasing the heap size
  3431. ----------------------------
  3432.  
  3433. The maximum size of the heap available for malloc() is fixed.  The
  3434. default for the combined size of the heap and stack is 8 MByte under
  3435. DOS.  Use the -s# emx option (see section 4) to increase the heap and
  3436. stack size.
  3437.  
  3438. The default heap size is 32 MByte under OS/2.  When using ld and
  3439. emxbind, you can change the heap size with the -h<heap_size> option of
  3440. emxbind.
  3441.  
  3442. When using emxomf and LINK386 without -Zsys, the heap size cannot be
  3443. changed (currently).  When using -Zsys, you have to build new sys.lib
  3444. libraries after changing /emx/src/lib/sys/init.c.  The following line
  3445. of that file defines the heap size:
  3446.  
  3447.     _sys_heap_size = 0x2000000;
  3448.  
  3449. See build.doc for information about rebuilding libraries.
  3450.  
  3451.  
  3452. 8.2 Increasing the stack size
  3453. -----------------------------
  3454.  
  3455. The default for the combined size of the heap and stack is 8 MByte
  3456. under DOS.  When using emxbind, the default stack size is 8 MB under
  3457. OS/2.  When using emxomf and LINK386, the default stack size is 0x8000
  3458. bytes under OS/2.
  3459.  
  3460. The stack size for DOS can be changed with the -s# emx option.
  3461. emxbind can put this option into the executable file.
  3462.  
  3463. The stack size for OS/2 can be changed with the -k<stack_size> option
  3464. of emxbind when using emxbind.  When using LINK386, use the STACKSIZE
  3465. statement in a module definition file.  The stack size should be at
  3466. least 32768 bytes.  You can also use the -Zstack option of GCC.
  3467.  
  3468. If you are using certain beta versions of LINK386, bits 16 through 23
  3469. of the stack size should not equal 0x20000 or 0x40000 bits set.
  3470. Otherwise, your program will crash under OS/2 2.0 due to a bug in OS/2
  3471. 2.0.  Use only stack sizes where both the 0x20000 and 0x40000 bits are
  3472. zero or the 0x10000 or 0x80000 bits are one.
  3473.  
  3474.  
  3475. 8.3 Increasing the number of files
  3476. ----------------------------------
  3477.  
  3478. Under DOS and when using emx.dll under OS/2, you can set the number of
  3479. file handles supported by the emx runtime by setting the EMXOPT
  3480. environment variable or by using emxbind to put emx options into the
  3481. .exe file.  See section 4 for the -h# emx option.
  3482.  
  3483. Note that you might have to change the FILES settings in the
  3484. config.sys file under DOS.
  3485.  
  3486. When using the system call library (-Zsys, sys.lib) you have to call
  3487. DosSetMaxFH to increase the number of file handles.
  3488.  
  3489. The number of file handles and streams supported by the C library is
  3490. given by the _NFILES constant in /emx/include/sys/emx.h.  The default
  3491. value is 40.  After changing emx.h, you have to rebuild the libraries.
  3492. (At least stdio.c and iodata.c in /emx/src/lib/io must be recompiled.)
  3493. Note that at least three file handles (for stdin, stdout and stderr)
  3494. are (almost) always predefined.
  3495.  
  3496. The number of file handles and streams supported by emxlibcm.dll,
  3497. emxlibcs.dll, and custom C runtime DLLs is 256.
  3498.  
  3499.  
  3500. 9 Debugger (DOS)
  3501. ================
  3502.  
  3503. emxd.exe contains a debugger (that's the difference between emx.exe
  3504. and emxd.exe).  Use the -S option to enable the debugger.  If you want
  3505. to debug using a terminal, enter -S1 to use COM1, -S2 to use COM2.  To
  3506. debug an emx program, type
  3507.  
  3508.     emxd -S [<options>] <program> [<arguments>]
  3509.  
  3510. (which works with all emx programs) or
  3511.  
  3512.     set emx=c:\emx\bin\emxd.exe
  3513.     set emxopt=-S
  3514.     <program>
  3515.  
  3516. (which doesn't work if emx.exe is bound to the program).  When
  3517. starting an emx program by running emx.exe or emxd.exe, the emx
  3518. options -d, -h#, -m#, -o, -p, -E, -F, -O, -P and -V set by emxbind are
  3519. ignored.  Pass these options on the command line instead.
  3520.  
  3521. Command keys:
  3522.  
  3523. .       display registers and next instruction
  3524.  
  3525. :       show CS:EIP and next instruction (toggle)
  3526.  
  3527. BLANK   1 step
  3528.  
  3529. 0       10 steps
  3530.  
  3531. 1-9     1 through 9 steps
  3532.  
  3533. C       set breakpoint after next instruction and start program.  This
  3534.         command should only be used on CALL instructions
  3535.  
  3536. F       display floating point (387) status
  3537.  
  3538. N       step without stopping
  3539.  
  3540. F2      display registers and next instruction
  3541.  
  3542. F5      start program without setting breakpoint
  3543.  
  3544. F8      1 step
  3545.  
  3546. F10     set breakpoint after next instruction and start program
  3547.  
  3548. Commands:
  3549.  
  3550. A <address>
  3551.  
  3552.     display inforomation about <address> (virtual, physical and
  3553.     external addresses)
  3554.  
  3555. A <range>
  3556.  
  3557.     ditto, loop through <range> in steps of 1000H bytes
  3558.  
  3559. B
  3560.  
  3561.     display breakpoints and watchpoints
  3562.  
  3563. B <address>
  3564.  
  3565.     set breakpoint (default segment: CS).  Up to 3 breakpoints and
  3566.     watchpoints can be set
  3567.  
  3568. D
  3569.  
  3570.     continue last D command
  3571.  
  3572. D <address>
  3573.  
  3574.     display hex dump: 16 lines (default segment: DS)
  3575.  
  3576. D <range>
  3577.  
  3578.     display hex dump (default segment: DS)
  3579.  
  3580. G
  3581.  
  3582.     start program
  3583.  
  3584. G <address>
  3585.  
  3586.     set temporary breakpoint at <address> (default segment: CS) and
  3587.     start program
  3588.  
  3589. I
  3590.  
  3591.     display process table: process index, process id, parent process
  3592.     id, and file handle mapping
  3593.  
  3594. K
  3595.  
  3596.     display breakpoints and watchpoints
  3597.  
  3598. K <value>
  3599.  
  3600.     delete breakpoint or watchpoint (by number)
  3601.  
  3602. L <value>
  3603.  
  3604.     display info about selector <value>
  3605.  
  3606. L <value> <value>
  3607.  
  3608.     ditto, loop through range in steps of 8 (not 4!)
  3609.  
  3610. Q
  3611.  
  3612.     quit, return value 0
  3613.  
  3614. Q <value>
  3615.  
  3616.     quit and set the return value to <value>
  3617.  
  3618. R
  3619.  
  3620.     display registers and next instruction
  3621.  
  3622. R <register> <value>
  3623.  
  3624.     set register to <value>
  3625.  
  3626. R <condition>
  3627.  
  3628.     set/reset processor flag
  3629.  
  3630. S <range> <list>
  3631.  
  3632.     search memory
  3633.  
  3634. U
  3635.  
  3636.     continue last U command
  3637.  
  3638. U <address>
  3639.  
  3640.     unassemble (default segment: CS)
  3641.  
  3642. V <value>
  3643.  
  3644.     display info about virtual address
  3645.  
  3646. V <value> <value>
  3647.  
  3648.     ditto, loop through range in steps of 1000H bytes
  3649.  
  3650. VP
  3651.  
  3652.     display info about pages that have physical memory assigned
  3653.  
  3654. VP <value>
  3655.  
  3656.     display info by physical address
  3657.  
  3658. VP <value> <value>
  3659.  
  3660.     ditto, loop through range in steps of 1000H bytes
  3661.  
  3662. VX
  3663.  
  3664.     display info about pages that have an external address
  3665.  
  3666. VX <value>
  3667.  
  3668.     display info by external address
  3669.  
  3670. VX <value> <value>
  3671.  
  3672.     ditto, loop through range in steps of 1000H bytes
  3673.  
  3674. W
  3675.  
  3676.     display breakpoints and watchpoints
  3677.  
  3678. W<l><a> <address>
  3679.  
  3680.     set watchpoint at given address (default segment: DS).  <l> is B
  3681.     (byte), W (word, <address> must be even) or D (dword, the 2 low
  3682.     bits of <address> must be zero).  <a> is R (trap read and write
  3683.     accesses), W (trap write accesses) or X (trap modifying write
  3684.     accesses).
  3685.  
  3686. X <value>
  3687.  
  3688.     find symbol at address <value> or below
  3689.  
  3690. The following arguments are used by the commands listed above:
  3691.  
  3692. <address>
  3693.  
  3694.  
  3695.     [<value>:]<value>
  3696.  
  3697.         selector and offset.  If using the SS register for the
  3698.         selector fails, type the value of SS as hexadecimal number
  3699.  
  3700.     <symbol>
  3701.  
  3702.         use address of variable or function <symbol>.  If <symbol>
  3703.         looks like a hexadecimal number you lose
  3704.  
  3705. <condition>
  3706.  
  3707.     Each processor flag has two states:
  3708.  
  3709.     NC, CY, PE, PO, NA, AC, NZ, ZR, PL, NG, DI, EI, UP, DN, NV, OV
  3710.  
  3711. <register>
  3712.  
  3713.     The following registers can be used:
  3714.  
  3715.     EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP, EIP, EFLAGS,
  3716.     AX, BX, CX, DX, SI, DI, BP, SP, IP,
  3717.     AL, AH, BL, BH, CL, CH, DL, DH,
  3718.     CS, DS, ES, FS, GS, SS
  3719.  
  3720. <range>
  3721.  
  3722.     A <range> includes all addresses between the start address and the
  3723.     end address:
  3724.  
  3725.     <address> <address>
  3726.  
  3727.         The selectors of both addresses must be identical (the
  3728.         selector of the second address should be omitted, it defaults
  3729.         to the selector of the first address).  The second offset must
  3730.         be greater than or equal to the first offset
  3731.  
  3732. <list>
  3733.  
  3734.     A <list> is made of one or more values or multi-letter strings:
  3735.  
  3736.     <value>|'<text>' ...
  3737.  
  3738. <value>
  3739.  
  3740.     A <value> is the basic element of an expression.
  3741.  
  3742.     0 through ffffffff
  3743.  
  3744.         Hexadecimal number
  3745.  
  3746.     <register>
  3747.  
  3748.         Current value of the register <register>
  3749.  
  3750.     '<C>'
  3751.  
  3752.         Character code (ASCII) of the character <C>
  3753.  
  3754. If the -S option is used, emx will display swapper statistics when
  3755. returning to DOS.  It displays
  3756.  
  3757.     Swapper statistics: F=<f> R=<r> W=<w> N=<n> S=<s>
  3758.  
  3759. where <f> is the number of page faults, <r> is the number of swapper
  3760. file reads, <w> is the number of swapper file writes, <n> is the
  3761. number of times the swap space of present pages has been recycled, and
  3762. <s> is the size of the swapper file.  All numbers are decimal numbers.
  3763.  
  3764.  
  3765. 10 Executable file format
  3766. =========================
  3767.  
  3768. a.out   see /emx/include/a_out.h
  3769.  
  3770. exe     OS/2 LX format with additional sections, see diagram below
  3771.  
  3772.     ┌─────────────────────────────────┐
  3773.     │                                 │
  3774.     │ DOS .exe header:                │
  3775.     │                                 │
  3776.     │  ┌──────────────────────────────┤
  3777.     │  │                              │────────┐
  3778.     │  │ Control information          │────┐   │
  3779.     │  │                              │──┐ │   │
  3780.     │  ├──────────────────────────────┤<─┘ │   │
  3781.     │  │                              │    │   │
  3782.     │  │ Relocation table             │    │   │
  3783.     │  │                              │    │   │
  3784.     └──┴──────────────────────────────┘    │   │
  3785.                                            │   │
  3786.     ┌─────────────────────────────────┐<───┘   │
  3787.     │                                 │        │
  3788.     │ DOS (emx or emxl) image:        │        │
  3789.     │                                 │        │
  3790.     │  ┌──────────────────────────────┤        │
  3791.     │  │                              │        │
  3792.     │  │ emxbind header (options)     │──────┐ │
  3793.     │  │                              │      │ │
  3794.     │  ├──────────────────────────────┤      │ │
  3795.     │  │                              │      │ │
  3796.     │  │ Code & data                  │      │ │
  3797.     │  │                              │      │ │
  3798.     └──┴──────────────────────────────┘      │ │
  3799.                                              │ │
  3800.     ┌─────────────────────────────────┐<───────┘
  3801.     │                                 │      │
  3802.     │ OS/2 linear executable header:  │      │
  3803.     │                                 │      │
  3804.     │  ┌──────────────────────────────┤      │
  3805.     │  │                              │      │
  3806.     │  │ Fixed-size header            │────┐ │
  3807.     │  │                              │──┐ │ │
  3808.     │  ├──────────────────────────────┤<─┘ │ │
  3809.     │  │                              │    │ │
  3810.     │  │ Loader section               │──┐ │ │
  3811.     │  │                              │  │ │ │
  3812.     │  ├──────────────────────────────┤<───┘ │
  3813.     │  │                              │  │   │
  3814.     │  │ Fixup section                │  │   │
  3815.     │  │                              │  │   │
  3816.     └──┴──────────────────────────────┘  │   │
  3817.     ┌─────────────────────────────────┐<─┤   │
  3818.     │                                 │  │   │
  3819.     │ Resources                       │  │   │
  3820.     │                                 │  │   │
  3821.     └─────────────────────────────────┘  │   │
  3822.     ┌─────────────────────────────────┐<─│───┘
  3823.     │                                 │  │
  3824.     │ a.out executable:               │  │
  3825.     │                                 │  │
  3826.     │  ┌──────────────────────────────┤  │
  3827.     │  │                              │──│──┐
  3828.     │  │ a.out header                 │  │  │
  3829.     │  │                              │  │  │
  3830.     │  ├──────────────────────────────┤<─┤  │
  3831.     │  │                              │  │  │
  3832.     │  │ Text segment                 │  │  │
  3833.     │  │                              │  │  │
  3834.     │  ├──────────────────────────────┤<─┘<─┤
  3835.     │  │                              │     │
  3836.     │  │ Data segment                 │     │
  3837.     │  │                              │     │
  3838.     │  │  ┌───────────────────────────┤     │
  3839.     │  │  │                           │     │
  3840.     │  │  │ OS/2 emxbind header       │     │
  3841.     │  │  │                           │     │
  3842.     │  │  ├───────────────────────────┤     │
  3843.     │  │  │                           │     │
  3844.     │  │  │ Other data                │     │
  3845.     │  │  │                           │     │
  3846.     │  ├──┴───────────────────────────┤<────┘
  3847.     │  │                              │
  3848.     │  │ Symbol table                 │
  3849.     │  │                              │
  3850.     └──┴──────────────────────────────┘
  3851.  
  3852.  
  3853. 11 Known problems
  3854. =================
  3855.  
  3856. - sleep() and _sleep2() hold signals under DOS, that is, if the
  3857.   alarm() timer elapses, the signal handler for SIGALRM isn't called
  3858.   until the completion of those functions
  3859.  
  3860. - when using the -C# emx option, memory allocated by an unsuccessful
  3861.   brk() or sbrk() call isn't freed.  That is, as soon as a malloc()
  3862.   call fails, further calls will also fail.  Actually, this isn't a
  3863.   bug -- it's a lacking feature
  3864.  
  3865. - emx doesn't work under DOS if more than 64 MByte of memory is
  3866.   installed
  3867.  
  3868. - running emx programs by a DOS program started by an emx program
  3869.   seems not to work under certain circumstances [Is this still true?]
  3870.  
  3871. - breakpoints are shared by all instances of a program under OS/2 2.1
  3872.   and earlier -- this is an OS/2 bug which seems to be fixed OS/2 2.11
  3873.   (ServicePak XR06200 for OS/2 2.1)
  3874.  
  3875. - fork() doesn't work correctly in multithread programs.
  3876.  
  3877. --------------------------- END OF EMXDEV.DOC ------------------------------
  3878.