Unix Technical Forum

putenv for AIX and ifdef for AIX

This is a discussion on putenv for AIX and ifdef for AIX within the AIX Operating System forums, part of the Unix Operating Systems category; --> I have read several posts about putenv is not Standard C. But I'm wondering if anyone knows if it ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 12:52 PM
ClownPleco
 
Posts: n/a
Default 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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-05-2008, 12:52 PM
Paul Landay
 
Posts: n/a
Default 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 <standards.h>' 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2008, 12:52 PM
Gary R. Hook
 
Posts: n/a
Default 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-05-2008, 12:52 PM
Thomas Braunbeck
 
Posts: n/a
Default 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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-05-2008, 12:52 PM
dickd
 
Posts: n/a
Default 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.



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:12 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com