putenv for AIX and ifdef for AIX - Aix

This is a discussion on putenv for AIX and ifdef for AIX - Aix ; I have read several posts about putenv is not Standard C. But I'm wondering if anyone knows if it is available in AIX. All of our other platforms (linux (32 and 64 bit), sgi, hpux, x86, darwin (intel and mac), ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: putenv for AIX and ifdef for AIX

  1. putenv for AIX and ifdef for AIX

    I have read several posts about putenv is not Standard C. But I'm
    wondering if anyone knows if it is available in AIX. All of our other
    platforms (linux (32 and 64 bit), sgi, hpux, x86, darwin (intel and
    mac), interix and sun) behave properly for our application. We found
    that if we run this command prior to running the application, it works
    correctly:

    set LDR_CNTRL=MAXDATA=0x80000000;export LDR_CNTRL

    Our problem is that we start a parent process that spawns the child
    application. If we set the LDR_CNTRL=MAXDATA prior to starting the
    parent process, other child applications are failing.

    Our initial solution is to have wrap around child application that
    sets the environmental variable and then spawns an additional child.
    This environmental variable would only be set if the the operating
    system is AIX.

    Second question, does anyone know the correct #ifdef statement to
    check for AIX, is it:

    #ifdef __AIX__

    I'm a very very green C programmer!

    Thanks

    Rick


  2. Re: putenv for AIX and ifdef for AIX

    ClownPleco wrote:
    > I have read several posts about putenv is not Standard C. But I'm
    > wondering if anyone knows if it is available in AIX. All of our other
    > platforms (linux (32 and 64 bit), sgi, hpux, x86, darwin (intel and
    > mac), interix and sun) behave properly for our application. We found
    > that if we run this command prior to running the application, it works
    > correctly:
    >
    > set LDR_CNTRL=MAXDATA=0x80000000;export LDR_CNTRL
    >
    > Our problem is that we start a parent process that spawns the child
    > application. If we set the LDR_CNTRL=MAXDATA prior to starting the
    > parent process, other child applications are failing.
    >
    > Our initial solution is to have wrap around child application that
    > sets the environmental variable and then spawns an additional child.
    > This environmental variable would only be set if the the operating
    > system is AIX.
    >
    > Second question, does anyone know the correct #ifdef statement to
    > check for AIX, is it:
    >
    > #ifdef __AIX__
    >
    > I'm a very very green C programmer!
    >
    > Thanks
    >
    > Rick
    >


    putenv() does exist for AIX.
    See /usr/include/stdlib.h and:
    nm /usr/lib/libc.a | grep putenv

    As for the #ifdef, it may depend on which compiler you are using.
    For example the IBM Visual Age C compiler will define some
    symbols based on the /etc/vac.cfg file, which has symbols like
    _AIX, _AIX53, etc.
    You could '#include ' and use one of the _AIX*
    symbols which are defined in /usr/include/standards.h or you
    could modify your Makefile to use the compiler flag '-D__AIX__'.

    Paul Landay

  3. Re: putenv for AIX and ifdef for AIX

    ClownPleco wrote:
    > I have read several posts about putenv is not Standard C. But I'm
    > wondering if anyone knows if it is available in AIX. All of our other
    > platforms (linux (32 and 64 bit), sgi, hpux, x86, darwin (intel and
    > mac), interix and sun) behave properly for our application. We found
    > that if we run this command prior to running the application, it works
    > correctly:
    >
    > set LDR_CNTRL=MAXDATA=0x80000000;export LDR_CNTRL
    >
    > Our problem is that we start a parent process that spawns the child
    > application. If we set the LDR_CNTRL=MAXDATA prior to starting the
    > parent process, other child applications are failing.


    The issue here doesn't appear to be putenv(), it appears to be how
    your applications expect the 32-bit address space to be laid out.
    The maxdata feature causes segments (usually reserved for shared memory
    attaches) to be used for the heap. If your applications perform
    shared memory operations and (a) presume to know the location of
    an attach, (b) have expectations on specific addresses for an attach,
    or (c) require more than 2 simultaneous attaches, then maxdata is not
    going to work for you. You might want to just use ldedit to modify
    the characteristics of the binary that requires that much heap space,
    and leave everything else alone.

    --
    -------------------------------------
    http://www.photo.net/photos/garyrhook
    Vocatus atque non vocatus deus aderit

  4. Re: putenv for AIX and ifdef for AIX

    Gary R. Hook schrieb:
    > ClownPleco wrote:
    >>
    >> set LDR_CNTRL=MAXDATA=0x80000000;export LDR_CNTRL
    >>
    >> Our problem is that we start a parent process that spawns the child
    >> application. If we set the LDR_CNTRL=MAXDATA prior to starting the
    >> parent process, other child applications are failing.

    >
    > The issue here doesn't appear to be putenv(), it appears to be how
    > your applications expect the 32-bit address space to be laid out.
    > The maxdata feature causes segments (usually reserved for shared memory
    > attaches) to be used for the heap. If your applications perform
    > shared memory operations and (a) presume to know the location of
    > an attach, (b) have expectations on specific addresses for an attach,
    > or (c) require more than 2 simultaneous attaches, then maxdata is not
    > going to work for you. You might want to just use ldedit to modify
    > the characteristics of the binary that requires that much heap space,
    > and leave everything else alone.
    >


    Or try
    LDR_CNTRL=MAXDATA=0x80000000@DSA;export LDR_CNTRL
    See the 'Large Program Support' article in the AIX
    publications and in there the part on 'Understanding
    the Very Large Address-Space Model' for more details.

  5. Re: putenv for AIX and ifdef for AIX

    There is a much easier solution to this problem. Build your client
    with the required heap space
    it requires, and you won't have to fiddle with LDR_CNTRL.

    xlc_r -bmaxdata=0x80000000 ...

    I don't think you're going to be able to achieve this with putenv.
    It's a matter of environmental scope ... you've set the variable into
    the main environment,
    but it isn't "export"ed for use in the child.

    At least that's my experience. I just gave up trying to do that.




+ Reply to Thread