z/os v1r6.0 c/c++ programming guide - cvut.czoberhtom/mainframe/...repositioning within files . . ....

1032
z/OS C/C++ Programming Guide SC09-4765-05

Upload: others

Post on 24-Apr-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

  • z/OS

    C/C++Programming

    Guide

    SC09-4765-05

    ���

  • z/OS

    C/C++Programming

    Guide

    SC09-4765-05

    ���

  • Note

    Before

    using

    this

    information

    and

    the

    product

    it

    supports,

    be

    sure

    to

    read

    the

    general

    information

    under

    “Notices”

    on

    page

    939.

    Sixth

    Edition,

    September

    2004

    This

    is

    a

    major

    revision

    of

    SC09-4765-04.

    This

    edition

    applies

    to

    Version

    1

    Release

    6

    of

    z/OS

    C/C++

    (5694-A01),

    Version

    1

    Release

    6

    of

    z/OS.e

    (5655-G52),

    and

    to

    all

    subsequent

    releases

    and

    modifications

    until

    otherwise

    indicated

    in

    new

    editions.

    Order

    publications

    through

    your

    IBM

    representative

    or

    the

    IBM

    branch

    office

    serving

    your

    locality.

    Publications

    are

    not

    stocked

    at

    the

    address

    below.

    IBM

    welcomes

    your

    comments.

    A

    form

    for

    readers’

    comments

    may

    be

    provided

    at

    the

    back

    of

    this

    publication,

    or

    you

    may

    address

    your

    comments

    to

    the

    following

    address:

    International

    Business

    Machines

    Corporation

    Department

    55JA,

    Mail

    Station

    P384

    2455

    South

    Road

    Poughkeepsie,

    NY

    12601-5400

    United

    States

    of

    America

    FAX

    (United

    States

    &

    Canada):

    1+845+432-9405

    FAX

    (Other

    Countries):

    Your

    International

    Access

    Code

    +1+845+432-9405

    IBMLink™

    (United

    States

    customers

    only):

    IBMUSM10(MHVRCFS)

    Internet

    e-mail:

    [email protected]

    World

    Wide

    Web:

    http://www.ibm.com/servers/eserver/zseries/zos/webqs.html

    If

    you

    would

    like

    a

    reply,

    be

    sure

    to

    include

    your

    name,

    address,

    telephone

    number,

    or

    FAX

    number.

    Make

    sure

    to

    include

    the

    following

    in

    your

    comment

    or

    note:

    v

    Title

    and

    order

    number

    of

    this

    book

    v

    Page

    number

    or

    topic

    related

    to

    your

    comment

    When

    you

    send

    information

    to

    IBM,

    you

    grant

    IBM

    a

    nonexclusive

    right

    to

    use

    or

    distribute

    the

    information

    in

    any

    way

    it

    believes

    appropriate

    without

    incurring

    any

    obligation

    to

    you.

    ©

    Copyright

    International

    Business

    Machines

    Corporation

    1996,

    2004.

    All

    rights

    reserved.

    US

    Government

    Users

    Restricted

    Rights

    Use,

    duplication

    or

    disclosure

    restricted

    by

    GSA

    ADP

    Schedule

    Contract

    with

    IBM

    Corp.

  • Contents

    About

    this

    document

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . xxiii

    How

    to

    read

    syntax

    diagrams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . xxiii

    Symbols

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . xxiii

    Syntax

    items

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . xxiii

    Syntax

    examples

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . xxiv

    z/OS

    C/C++

    and

    related

    publications

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . xxv

    Softcopy

    documents

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . xxx

    Softcopy

    examples

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . xxx

    z/OS

    C/C++

    on

    the

    World

    Wide

    Web

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . xxx

    Where

    to

    find

    more

    information

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . xxxi

    Part

    1.

    Introduction

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 1

    Chapter

    1.

    About

    IBM

    z/OS

    C/C++

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 3

    Changes

    for

    z/OS

    V1R6

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 3

    The

    C/C++

    compilers

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 5

    The

    C

    language

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 5

    The

    C++

    language

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 5

    Common

    features

    of

    the

    z/OS

    C

    and

    C++

    compilers

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 5

    z/OS

    C

    Compiler

    specific

    features

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 7

    z/OS

    C++

    Compiler

    specific

    features

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 7

    Class

    libraries

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 7

    Utilities

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 7

    dbx

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 8

    z/OS

    Language

    Environment

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 8

    z/OS

    Language

    Environment

    downward

    compatibility

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 9

    About

    prelinking,

    linking,

    and

    binding

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 10

    Notes

    on

    the

    prelinking

    process

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 10

    File

    format

    considerations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 11

    The

    program

    management

    binder

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 11

    z/OS

    UNIX

    System

    Services

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 12

    z/OS

    C/C++

    Applications

    with

    z/OS

    UNIX

    System

    Services

    C/C++

    functions

    13

    Input

    and

    output

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 14

    I/O

    interfaces

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 14

    File

    types

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 14

    Additional

    I/O

    features

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 15

    The

    System

    Programming

    C

    facility

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 16

    Interaction

    with

    other

    IBM

    products

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 16

    Additional

    features

    of

    z/OS

    C/C++

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 18

    Part

    2.

    Input

    and

    Output

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 21

    Chapter

    2.

    Introduction

    to

    C

    and

    C++

    input

    and

    output

    .

    .

    .

    .

    .

    .

    .

    .

    . 23

    Types

    of

    C

    and

    C++

    input

    and

    output

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 23

    Text

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 23

    Binary

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 24

    Record

    I/O

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 24

    Chapter

    3.

    Understanding

    models

    of

    C

    I/O

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 25

    The

    record

    model

    for

    C

    I/O

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 25

    Record

    formats

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 25

    The

    byte

    stream

    model

    for

    C

    I/O

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 34

    ©

    Copyright

    IBM

    Corp.

    1996,

    2004

    iii

    ||

    ||

  • Mapping

    the

    C

    types

    of

    I/O

    to

    the

    byte

    stream

    model

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 34

    Chapter

    4.

    Using

    the

    Standard

    C++

    Library

    I/O

    Stream

    Classes

    .

    .

    .

    .

    . 37

    Advantages

    to

    Using

    the

    C++

    I/O

    Stream

    Classes

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 37

    Predefined

    Streams

    for

    C++

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 38

    How

    C++

    I/O

    Streams

    Relate

    to

    C

    Streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 38

    Mixing

    the

    Standard

    C++

    I/O

    Stream

    Classes,

    USL

    I/O

    Stream

    Class

    Library,

    and

    C

    I/O

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 38

    Specifying

    File

    Attributes

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 39

    Chapter

    5.

    Opening

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 41

    Prototypes

    of

    functions

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 41

    Categories

    of

    I/O

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 42

    Specifying

    what

    kind

    of

    file

    to

    use

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 44

    OS

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 44

    HFS

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 44

    VSAM

    data

    sets

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 44

    Terminal

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 44

    Memory

    files

    and

    hiperspace

    memory

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 45

    CICS

    data

    queues

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 46

    z/OS

    Language

    Environment

    Message

    file

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 46

    How

    to

    specify

    RECFM,

    LRECL,

    and

    BLKSIZE

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 46

    fopen()

    defaults

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 48

    DDnames

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 50

    Avoiding

    Undesirable

    Results

    when

    Using

    I/O

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 51

    How

    z/OS

    C/C++

    determines

    what

    kind

    of

    file

    to

    open

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 51

    MAP

    0010:

    Under

    TSO,

    MVS

    batch,

    IMS

    POSIX(ON)

    .

    .

    .

    .

    .

    .

    .

    .

    . 52

    MAP

    0020:

    Under

    TSO,

    MVS

    batch,

    IMS

    POSIX(OFF)

    .

    .

    .

    .

    .

    .

    .

    .

    . 56

    MAP

    0030:

    Under

    CICS

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 59

    Chapter

    6.

    Buffering

    of

    C

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 61

    Chapter

    7.

    Using

    ASA

    text

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 63

    Example

    of

    writing

    to

    an

    ASA

    file

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 63

    CCNGAS1

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 63

    ASA

    file

    control

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 64

    Chapter

    8.

    z/OS

    C

    Support

    for

    the

    double-byte

    character

    set

    .

    .

    .

    .

    .

    . 67

    Opening

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 68

    Reading

    streams

    and

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 68

    Writing

    streams

    and

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 69

    Writing

    text

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 70

    Writing

    binary

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 71

    Flushing

    buffers

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 71

    Flushing

    text

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 71

    Flushing

    binary

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 72

    ungetwc()

    considerations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 72

    Setting

    positions

    within

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 73

    Repositioning

    within

    text

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 73

    Repositioning

    within

    binary

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 73

    ungetwc()

    considerations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 73

    Closing

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 74

    Manipulating

    wide

    character

    array

    functions

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 74

    Chapter

    9.

    Using

    C

    and

    C++

    standard

    streams

    and

    redirection

    .

    .

    .

    .

    .

    . 75

    Default

    open

    modes

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 76

    iv

    z/OS

    V1R6.0

    C/C++

    Programming

    Guide

    ||

  • Interleaving

    the

    standard

    streams

    with

    sync_with_stdio()

    .

    .

    .

    .

    .

    .

    .

    .

    . 76

    Interleaving

    the

    standard

    streams

    without

    sync_with_stdio()

    .

    .

    .

    .

    .

    .

    .

    . 78

    Redirecting

    standard

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 80

    Redirecting

    streams

    from

    the

    command

    line

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 80

    Using

    the

    redirection

    symbols

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 81

    Assigning

    the

    standard

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 82

    Using

    the

    freopen()

    library

    function

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 82

    Redirecting

    streams

    with

    the

    MSGFILE

    option

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 82

    MSGFILE

    considerations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 82

    Redirecting

    streams

    under

    z/OS

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 84

    Under

    MVS

    batch

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 84

    Under

    TSO

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 86

    Under

    IMS

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 86

    Under

    CICS

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 86

    Passing

    C

    and

    C++

    standard

    streams

    across

    a

    system()

    call

    .

    .

    .

    .

    .

    .

    .

    . 87

    Passing

    binary

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 87

    Passing

    text

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 88

    Passing

    record

    I/O

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 89

    Using

    global

    standard

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 90

    Command

    line

    redirection

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 91

    Direct

    assignment

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 93

    freopen()

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 93

    MSGFILE()

    run-time

    option

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 93

    fclose()

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 93

    File

    position

    and

    visible

    data

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 93

    C++

    I/O

    stream

    library

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 93

    Chapter

    10.

    Performing

    OS

    I/O

    operations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 95

    Opening

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 95

    Using

    fopen()

    or

    freopen()

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 95

    Generation

    data

    group

    I/O

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 98

    Regular

    and

    extended

    partitioned

    data

    sets

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 102

    Partitioned

    and

    sequential

    concatenated

    data

    sets

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 103

    In-stream

    data

    sets

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 105

    SYSOUT

    data

    sets

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 105

    Tapes

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 106

    Multivolume

    data

    sets

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 106

    Striped

    data

    sets

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 107

    Other

    devices

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 107

    fopen()

    and

    freopen()

    parameters

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 108

    Buffering

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 111

    Multiple

    buffering

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 112

    DCB

    (Data

    Control

    Block)

    attributes

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 113

    Reading

    from

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 115

    Reading

    from

    binary

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 115

    Reading

    from

    text

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 116

    Reading

    from

    record

    I/O

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 116

    Writing

    to

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 117

    Writing

    to

    binary

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 117

    Writing

    to

    text

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 118

    Writing

    to

    record

    I/O

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 121

    Flushing

    buffers

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 121

    Updating

    existing

    records

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 121

    Reading

    updated

    records

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 121

    Writing

    new

    records

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 122

    ungetc()

    considerations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 123

    Contents

    v

  • Repositioning

    within

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 124

    ungetc()

    considerations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 124

    How

    long

    fgetpos()

    and

    ftell()

    values

    last

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 125

    Using

    fseek()

    and

    ftell()

    in

    binary

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 125

    Using

    fseek()

    and

    ftell()

    in

    text

    files

    (ASA

    and

    Non-ASA)

    .

    .

    .

    .

    .

    .

    .

    . 126

    Using

    fseek()

    and

    ftell()

    in

    record

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 127

    Porting

    old

    C

    code

    that

    uses

    fseek()

    or

    ftell()

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 127

    Closing

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 127

    CCNGOS4

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 129

    Renaming

    and

    removing

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 130

    fldata()

    behavior

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 130

    Chapter

    11.

    Performing

    UNIX

    file

    system

    I/O

    operations

    .

    .

    .

    .

    .

    .

    .

    . 133

    Creating

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 133

    Regular

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 133

    Link

    and

    symbolic

    link

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 134

    Directory

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 134

    Character

    special

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 134

    FIFO

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 134

    Opening

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 134

    Using

    fopen()

    or

    freopen()

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 135

    Reading

    from

    HFS

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 138

    Opening

    and

    reading

    from

    HFS

    directory

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 139

    Writing

    to

    HFS

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 139

    Flushing

    records

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 139

    Setting

    positions

    within

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 140

    Closing

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 140

    Deleting

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 140

    Pipe

    I/O

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 141

    Using

    unnamed

    pipes

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 141

    Using

    named

    pipes

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 142

    Character

    special

    file

    I/O

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 146

    Low-level

    z/OS

    UNIX

    System

    Services

    I/O

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 146

    Example

    of

    HFS

    I/O

    functions

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 147

    CCNGHF3

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 147

    CCNGHF4

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 150

    fldata()

    behavior

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 152

    File

    tagging

    and

    conversion

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 153

    Access

    Control

    Lists

    (ACLs)

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 154

    Chapter

    12.

    Performing

    VSAM

    I/O

    operations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 157

    VSAM

    types

    (data

    set

    organization)

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 157

    Access

    method

    services

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 158

    Choosing

    VSAM

    data

    set

    types

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 158

    Keys,

    RBAs

    and

    RRNs

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 160

    Summary

    of

    VSAM

    I/O

    operations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 161

    Opening

    VSAM

    data

    sets

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 163

    Using

    fopen()

    or

    freopen()

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 163

    Buffering

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 167

    Record

    I/O

    in

    VSAM

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 167

    RRDS

    record

    structure

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 167

    Reading

    record

    I/O

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 168

    Writing

    to

    record

    I/O

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 169

    Updating

    record

    I/O

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 170

    Deleting

    records

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 171

    Repositioning

    within

    record

    I/O

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 171

    vi

    z/OS

    V1R6.0

    C/C++

    Programming

    Guide

    ||

  • Flushing

    buffers

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 173

    Summary

    of

    VSAM

    record

    I/O

    operations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 174

    VSAM

    record

    level

    sharing

    and

    transactional

    VSAM

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 174

    Error

    reporting

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 176

    Text

    and

    binary

    I/O

    in

    VSAM

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 176

    Reading

    from

    text

    and

    binary

    I/O

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 177

    Writing

    to

    and

    updating

    text

    and

    binary

    I/O

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 177

    Deleting

    records

    in

    text

    and

    binary

    I/O

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 177

    Repositioning

    within

    text

    and

    binary

    I/O

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 177

    Flushing

    buffers

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 179

    Summary

    of

    VSAM

    text

    I/O

    operations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 179

    Summary

    of

    VSAM

    binary

    I/O

    operations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 180

    Closing

    VSAM

    data

    sets

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 182

    VSAM

    return

    codes

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 182

    VSAM

    examples

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 182

    KSDS

    example

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 183

    RRDS

    example

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 191

    fldata()

    behavior

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 194

    Chapter

    13.

    Performing

    terminal

    I/O

    operations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 197

    Opening

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 197

    Using

    fopen()

    and

    freopen()

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 197

    Buffering

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 199

    Reading

    from

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 200

    Reading

    from

    binary

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 200

    Reading

    from

    text

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 201

    Reading

    from

    record

    I/O

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 201

    Writing

    to

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 201

    Writing

    to

    binary

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 202

    Writing

    to

    text

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 202

    Writing

    to

    record

    I/O

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 203

    Flushing

    records

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 203

    Text

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 203

    Binary

    streams

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 203

    Record

    I/O

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 204

    Repositioning

    within

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 204

    Closing

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 204

    fldata()

    behavior

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 204

    Chapter

    14.

    Performing

    memory

    file

    and

    hiperspace

    I/O

    operations

    .

    .

    . 207

    Using

    hiperspace

    operations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 207

    Opening

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 208

    Using

    fopen()

    or

    freopen()

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 208

    Simulating

    partitioned

    data

    sets

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 212

    Buffering

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 214

    Reading

    from

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 215

    Writing

    to

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 216

    Flushing

    records

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 216

    ungetc()

    considerations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 216

    Repositioning

    within

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 217

    Closing

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 217

    Performance

    tips

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 217

    Removing

    memory

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 218

    fldata()

    behavior

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 218

    Example

    program

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 219

    CCNGMF3

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 219

    Contents

    vii

  • CCNGMF4

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 220

    Chapter

    15.

    Performing

    CICS

    I/O

    operations

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 221

    Chapter

    16.

    Language

    Environment

    Message

    file

    operations

    .

    .

    .

    .

    .

    . 223

    Opening

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 223

    Reading

    from

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 223

    Writing

    to

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 224

    Flushing

    buffers

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 224

    Repositioning

    within

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 224

    Closing

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 224

    Chapter

    17.

    Debugging

    I/O

    programs

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 225

    Using

    the

    __amrc

    structure

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 225

    CCNGDI1

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 227

    Using

    the

    __amrc2

    structure

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 228

    Using

    __last_op

    codes

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 229

    Using

    the

    SIGIOERR

    signal

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 232

    CCNGDI2

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 232

    Part

    3.

    Interlanguage

    Calls

    with

    z/OS

    C/C++

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 235

    Chapter

    18.

    Using

    Linkage

    Specifications

    in

    C

    or

    C++

    .

    .

    .

    .

    .

    .

    .

    .

    . 237

    Syntax

    for

    Linkage

    in

    C

    or

    C++

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 237

    Syntax

    for

    Linkage

    in

    C

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 237

    Syntax

    for

    Linkage

    in

    C++

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 238

    Kinds

    of

    Linkage

    used

    by

    C

    or

    C++

    Interlanguage

    Programs

    .

    .

    .

    .

    .

    .

    . 238

    Using

    Linkage

    Specifications

    in

    C++

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 240

    Chapter

    19.

    Combining

    C

    or

    C++

    and

    Assembler

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 243

    Establishing

    the

    z/OS

    C/C++

    environment

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 243

    Specifying

    linkage

    for

    C

    or

    C++

    to

    Assembler

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 244

    Parameter

    lists

    for

    OS

    linkage

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 245

    XPLINK

    Assembler

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 245

    Using

    standard

    macros

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 247

    Non-XPLINK

    assembler

    prolog

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 248

    Non-XPLINK

    assembler

    epilog

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 248

    XPLINK

    Assembler

    prolog

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 248

    XPLINK

    Call

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 250

    XPLINK

    Assembler

    epilog

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 252

    Accessing

    automatic

    memory

    in

    the

    non-XPLINK

    stack

    .

    .

    .

    .

    .

    .

    .

    . 252

    Calling

    C

    code

    from

    Assembler

    C

    example

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 253

    CCNGCA4

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 253

    CCNGCA2

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 254

    CCNGCA5

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 254

    Calling

    run-time

    library

    routines

    from

    Assembler

    C++

    example

    .

    .

    .

    .

    .

    . 255

    CCNGCA1

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 255

    CCNGCA2

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 255

    CCNGCA3

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 256

    Register

    content

    at

    entry

    to

    a

    non-XPLINK

    ASM

    routine

    using

    OS

    linkage

    256

    Register

    content

    at

    exit

    from

    a

    non-XPLINK

    ASM

    routine

    to

    z/OS

    C/C++

    .

    .

    . 256

    Retaining

    the

    C

    environment

    using

    preinitialization

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 257

    Setting

    up

    the

    interface

    for

    preinitializable

    programs

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 258

    Preinitializing

    a

    C

    program

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 261

    Multiple

    preinitialization

    compatibility

    interface

    C

    environments

    .

    .

    .

    .

    .

    . 268

    Using

    the

    service

    vector

    and

    associated

    routines

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 271

    viii

    z/OS

    V1R6.0

    C/C++

    Programming

    Guide

    ||

  • Part

    4.

    Coding:

    Advanced

    Topics

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 277

    Chapter

    20.

    Building

    and

    using

    Dynamic

    Link

    Libraries

    (DLLs)

    .

    .

    .

    .

    . 279

    Support

    for

    DLLs

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 280

    DLL

    concepts

    and

    terms

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 280

    Loading

    a

    DLL

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 281

    Loading

    a

    DLL

    implicitly

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 281

    Loading

    a

    DLL

    explicitly

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 282

    Managing

    the

    use

    of

    DLLs

    when

    running

    DLL

    applications

    .

    .

    .

    .

    .

    .

    .

    . 286

    Loading

    DLLs

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 287

    Sharing

    DLLs

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 288

    Freeing

    DLLs

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 288

    Creating

    a

    DLL

    or

    a

    DLL

    application

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 289

    Building

    a

    simple

    DLL

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 289

    Example

    of

    building

    a

    simple

    C

    DLL

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 289

    Example

    of

    building

    a

    simple

    C++

    DLL

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 290

    Compiling

    your

    code

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 291

    Binding

    your

    code

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 292

    Building

    a

    simple

    DLL

    application

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 293

    Steps

    for

    using

    an

    implicitly

    loaded

    DLL

    in

    your

    simple

    DLL

    application

    293

    Creating

    and

    using

    DLLs

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 294

    DLL

    restrictions

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 295

    Improving

    performance

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 297

    Chapter

    21.

    Building

    complex

    DLLs

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 299

    Rules

    for

    compiling

    source

    code

    with

    XPLINK

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 300

    XPLINK

    applications

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 300

    Non-XPLINK

    applications

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 300

    Compatibility

    issues

    between

    DLL

    and

    non-DLL

    code

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 303

    Pointer

    assignment

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 305

    Function

    pointers

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 305

    DLL

    function

    pointer

    call

    in

    non-DLL

    code

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 307

    C

    example

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 308

    Non-DLL

    function

    pointer

    call

    in

    DLL(CBA)

    code

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 310

    Non-DLL

    function

    pointer

    call

    in

    DLL

    code

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 312

    Function

    pointer

    comparison

    in

    non-DLL

    code

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 313

    Function

    pointer

    comparison

    in

    DLL

    code

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 316

    Using

    DLLs

    that

    call

    each

    other

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 318

    Chapter

    22.

    Programming

    for

    a

    z/OS

    64-bit

    environment

    .

    .

    .

    .

    .

    .

    .

    . 325

    Overview

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 325

    When

    to

    port

    programs

    to

    a

    64-bit

    environment

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 325

    31-bit

    versus

    32-bit

    terminology

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 326

    Using

    prototypes

    to

    avoid

    debugging

    problems

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 326

    The

    LP64

    data

    model

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 326

    LP64

    restrictions

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 326

    ILP32

    and

    LP64

    type

    sizes

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 327

    z/OS

    C/C++

    compiler

    behavior

    under

    ILP32

    and

    LP64

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 327

    Impact

    of

    data

    model

    on

    structure

    alignment

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 328

    Impact

    of

    data

    model

    on

    pointer

    size

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 332

    Impact

    of

    data

    model

    on

    a

    printf

    subroutine

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 333

    Preprocessor

    macro

    selection

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 333

    Potential

    pointer

    corruption

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 334

    Incorrect

    pointer-to-int

    and

    int-to-pointer

    conversions

    .

    .

    .

    .

    .

    .

    .

    .

    . 334

    Potential

    loss

    of

    data

    in

    constant

    expressions

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 335

    Example

    of

    potential

    data

    alignment

    problems

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 336

    Contents

    ix

    ||

    ||

    ||||||||||||||||||||||||||||||||||

  • Defining

    pad

    members

    to

    avoid

    data

    alignment

    problems

    .

    .

    .

    .

    .

    .

    .

    . 337

    Mixing

    object

    files

    during

    binding

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 339

    LP64

    application

    performance

    and

    program

    size

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 339

    Migrating

    applications

    from

    ILP32

    to

    LP64

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 340

    Checklist

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 340

    Using

    header

    files

    to

    provide

    type

    definitions

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 341

    Aligning

    data

    mode

    and

    data

    types

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 341

    Using

    locales

    under

    different

    data

    modes

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 347

    Using

    converters

    under

    different

    data

    modes

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 347

    Searching

    source

    code

    for

    migration

    issues

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 348

    Using

    diagnostics

    to

    identify

    potential

    problems

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 348

    Using

    the

    CHECKOUT

    or

    INFO

    option

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 348

    Using

    the

    WARN64

    option

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 349

    Chapter

    23.

    Using

    threads

    in

    z/OS

    UNIX

    System

    Services

    applications

    351

    Models

    and

    requirements

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 351

    Functions

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 351

    Creating

    a

    thread

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 351

    Synchronization

    primitives

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 352

    Thread-specific

    data

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 356

    Signals

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 358

    Generating

    a

    signal

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 358

    Thread

    cancellation

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 359

    Cleanup

    for

    threads

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 360

    Behaviors

    and

    restrictions

    in

    z/OS

    UNIX

    System

    Services

    applications

    .

    .

    .

    . 361

    Using

    threads

    with

    MVS

    files

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 361

    Thread-scoped

    functions

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 362

    Unsafe

    thread

    functions

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 363

    Fetched

    functions

    and

    writable

    statics

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 363

    MTF

    and

    z/OS

    UNIX

    System

    Services

    threading

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 363

    Thread

    queuing

    function

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 363

    Thread

    scheduling

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 363

    iconv()

    family

    of

    functions

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 364

    Chapter

    24.

    Reentrancy

    in

    z/OS

    C/C++

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 365

    Natural

    or

    constructed

    reentrancy

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 366

    Limitations

    of

    constructed

    reentrancy

    for

    C

    programs

    .

    .

    .

    .

    .

    .

    .

    .

    . 366

    Controlling

    external

    static

    in

    C

    programs

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 366

    Controlling

    writable

    strings

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 367

    Controlling

    the

    memory

    area

    in

    C++

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 368

    Controlling

    where

    string

    literals

    exist

    in

    C++

    code

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 369

    Example

    of

    how

    to

    make

    string

    literals

    modifiable

    (CCNGRE2)

    .

    .

    .

    .

    .

    . 369

    Using

    writable

    static

    in

    Assembler

    code

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 369

    Example

    of

    referencing

    objects

    in

    the

    writeable

    static-area,

    Part

    1

    (CCNGRE3)

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 370

    Example

    of

    referencing

    objects

    in

    the

    writeable

    static-area,

    Part

    2

    (CCNGRE4)

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 371

    Chapter

    25.

    Using

    the

    decimal

    data

    type

    in

    C

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 373

    Declaring

    decimal

    types

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 373

    Declaring

    fixed-point

    decimal

    constants

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 374

    Declaring

    decimal

    variables

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 374

    Defining

    decimal-related

    constants

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    . 375

    Using

    operators

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .

    .