Chapter Contents |
Previous |
Next |
MVS Low-Level I/O Functions |
The
BSAM interfaces require that you allocate and initialize a DCB (data control
block) using
osbdcb
or
osdcb
. The address of the DCB
is then passed to the other I/O routines as an argument. Many BSAM functions
require you to extract or modify data in the DCB. The header file
<osio.h>
contains a C structure definition
for the DCB defining all necessary fields and constants.
When you use BSAM in assembler, you specify DCB exits
by creating an exit list. Each entry in the list contains an
exit type code and an entry address. The list of exits is then accessed via
the DCBEXLST field of the DCB. When you use the SAS/C BSAM interface, the
process is similar but not identical. You create a list of exits in which
each entry contains an exit type code and a function address. (The C exit
list format is not the same as the assembler format because of the need to
support 31-bit addressing.) The list of exits is passed to
osbdcb
or
osdcb
as an argument. This routine then transforms the C exit list
into a similar assembler exit list, modifies the DCB, and actually performs
the OPEN. (Note that some entries in an exit list are used as data addresses,
such as a JFCB buffer address, rather than as function addresses. A different
field name is used for storing a data pointer rather than a function pointer
in an exit list.
When an exit routine is entered in assembler, parameters
such as the address of the DCB or an I/O status block are passed in registers
0 and 1. When a corresponding C exit routine is called, it is passed two
parameters, the first of which is the value that would be passed to the assembler
exit in register 1, and the second is the register 0 contents. All exit functions
should be declared as returning
int
, and the value returned is returned to BSAM in register 15.
The BSAM interface supports escape from a DCB exit routine
using the
longjmp
function.
However, control is returned to data management with a value of
0
in register 15 before the
longjmp
is allowed to complete.
Note:
When a DCB exit routine is running, use of some system
services may cause
task interlocks or ABENDs. Dynamic allocation and open are examples of such
services. This means that you should not open a file in a routine called
from a DCB exit. Also, be careful performing I/O to
stdin
,
stdout
, or
stderr
from a DCB exit because an operating system OPEN will be issued for these
files if they have not been previously used. Finally, when debugging a DCB
exit with the source level debugger, use the
auto nolist
command to prevent debugger access to the program source
because the debugger uses dynamic allocation to gain access to the program
source.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.