Patches for AIX

Andrey Slepuhin pooh@msu.ru
Fri, 01 Aug 1997 16:01:06 +0400


Below there are patches needed to compile omniORB 2.2.0 on AIX 4.2
with C Set++ 3.1.4 (with some comments)

Notes:
1) When shared libraries are to be created, they overwrite static
versions,
because in AIX shared objects can be inserted into archives.
2) I think that libraries can be build with GNU C without problems,
but to compile multithreaded programs on AIX crt0_r.o must be linked
instead crt0.o. C Set++ does this automatically if compiler invoked
with _r suffix (xlC_r for example). For GNU C it can be done manually,
but this is not convenient.
3) I don't know if these patches work for AIX version <4.2
(and I have not any machine such AIX version installed)
4) Please, read the patches carefully, may be you can find other
solutions

Best wishes,
Andrey

****************************************

First, makefiles:

mk/powerpc_aix_4.2.mk:
----------------------------------------
#
# powerpc_aix_4.2.mk - make variables and rules specific to AIX 4.2 on 
#                      PowerPC.
#

PLATFORM = powerpc_aix_4.2
LIBDIR   = $(TOP)/lib
BINDIR   = $(TOP)/bin

#
# C preprocessor macro definitions for this architecture
#

PLATFORM_CPPFLAGS = -D__aix__ -D__powerpc__ -D__OSVERSION__=4.2

#
# Standard programs
#

AR              = ar cq
RANLIB          = ranlib
MKDIRHIER       = /usr/bin/X11/mkdirhier
CP              = cp
MV              = mv -f
RM              = rm -f

CXX             = xlc_r
CXXFLAGS        = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(CPPFLAGS)
CXXDEBUGFLAGS   =
CXXOPTIONS      = 
CXXLINK         = xlC_r
CXXLINKOPTIONS  = $(CXXDEBUGFLAGS) $(CXXOPTIONS)

CPPFLAGS        = $(DIR_CPPFLAGS) $(PLATFORM_CPPFLAGS)


.SUFFIXES: .o .cc .C .cpp .cxx

.cc.o:
        $(CXX) -c $(CXXFLAGS) -o $@ $<

.C.o:
        $(CXX) -c $(CXXFLAGS) -o $@ $<

.cpp.o:
        $(CXX) -c $(CXXFLAGS) -o $@ $<

.cxx.o:
        $(CXX) -c $(CXXFLAGS) -o $@ $<


# I can't find pthread version anywhere, but after some attempts
# all compiles fine with -DPthreadDraftVersion=8
OMNITHREAD_POSIX_CPPFLAGS = -DNoNanoSleep -DPthreadDraftVersion=8
OMNITHREAD_CPPFLAGS = -I$(TOP)/include -D_REENTRANT
OMNITHREAD_LIB = -lomnithread -lpthreads
OMNITHREAD_STATIC_LIB = -lomnithread -lpthreads

# Default location of the omniORB2 configuration file [falls back to
this if
# the environment variable OMNIORB_CONFIG is not set] :
OMNIORB_CONFIG_DEFAULT_LOCATION = \"/etc/omniORB.cfg\"

OMNIORB_CPPFLAGS = -D__OMNIORB2__ $(OMNITHREAD_CPPFLAGS)
OMNIORB_LIB = -lomniORB2 $(OMNITHREAD_LIB) 
OMNIORB_STATIC_LIB = -lomniORB2 $(OMNITHREAD_STATIC_LIB)

# Default directory for the omniNames log files.
OMNINAMES_LOG_DEFAULT_LOCATION = \"/var/omninames\"
----------------------------------------

src/lib/omnithread/sharedlib/powerpc_aix_4.2.mk:
----------------------------------------
OBJS = posix.o
LIBS = -lpthread
DIR_CPPFLAGS = $(OMNITHREAD_CPPFLAGS) $(OMNITHREAD_POSIX_CPPFLAGS)

all:: libomnithread.so.1.0

libomnithread.so.1.0: $(OBJS)
        (set -x; \
        $(RM) $@; \
        makeC++SharedLib \
           -o $@ \
           -lpthreads -lC -lc_r -lc -p 40 $(OBJS); \
        )

clean::
        $(RM) *.o core
        $(RM) libomnithread.so.1.0

install:: libomnithread.so.1.0
        @(set -x; \
          $(MKDIRHIER) $(LIBDIR); \
          $(CP) libomnithread.so.1.0 $(LIBDIR); \
          cd $(LIBDIR); \
          $(RM) libomnithread.a; \
          ar -rv -s libomnithread.a libomnithread.so.1.0; \
          $(RM) libomnithread.so.1.0; \
        )

posix.o: ../posix.cc
        $(CXX) -c $(CXXFLAGS) -o $@ ../posix.cc
----------------------------------------

src/lib/omniORB2/sharedlib/powerpc_aix_4.2.mk:
----------------------------------------
all:: libomniORB2.so.2.0

libomniORB2.so.2.0: $(ORB2_OBJS)
        (set -x; \
        $(RM) $@; \
        makeC++SharedLib \
           -o $@ \
           -L$(LIBDIR) $(OMNITHREAD_LIB) \
           -lpthreads -lC -lc_r -lc -p 40 $(ORB2_OBJS); \
        )

clean::
        $(RM) *.o core
        $(RM) libomniORB2.so.2.0

install:: libomniORB2.so.2.0
        @(set -x; \
          $(MKDIRHIER) $(LIBDIR); \
          $(CP) libomniORB2.so.2.0 $(LIBDIR); \
          cd $(LIBDIR); \
          $(RM) libomniORB2.a; \
          ar -rv libomniORB2.a libomniORB2.so.2.0; \
          $(RM) libomniORB2.so.2.0; \
        )
----------------------------------------

Patches to sources:

AIX uses POSIX threads:
----------------------------------------
diff -r omniORB_2.2.0/include/omnithread.h
omniORB_2.2.0.orig/include/omnithread.h
70,71d69
< #if defined(__powerpc__) && defined(__aix__)
< #include "omnithread/posix.h"
73c71
< #elif defined(__arm__) && defined(__atmos__)
---
> #if defined(__arm__) && defined(__atmos__)
----------------------------------------

PowerPC is BIG_ENDIAN:
----------------------------------------
diff -r omniORB_2.2.0/include/omniORB2/CORBA_sysdep.h
omniORB_2.2.0.orig/include/omniORB2/CORBA_sysdep.h
115,116d114
< #elif defined(__powerpc__)
< #define _OMNIORB_HOST_BYTE_ORDER_ 0
----------------------------------------

Only in omniORB_2.2.0/mk: powerpc_aix_4.2.1.mk


This is needed because C Set++ does not like expressions such as
OSLEVEL == <something> (it says that this is invalid constant
expression)
----------------------------------------
diff -r omniORB_2.2.0/src/appl/omniNames/log.cc
omniORB_2.2.0.orig/src/appl/omniNames/log.cc
271d270
< #ifndef __aix__
276d274
< #endif
505d502
< #ifndef __aix__
510d506
< #endif
518d513
< #ifndef __aix__
522d516
< #endif
536d529
< #ifndef __aix__
539d531
< #endif
----------------------------------------

This is because compiler can't recognize which call of
operator<< is used (operator<<(const void*) or operator<<(const char*)):
----------------------------------------
diff -r omniORB_2.2.0/src/appl/utils/nameclt/nameclt.cc
omniORB_2.2.0.orig/src/appl/utils/nameclt/nameclt.cc
191,192c191,192
<         cerr << "(" << (char*)((*bl)[i].binding_name[0].id) << ","
<              << (char*)((*bl)[i].binding_name[0].kind) << ") binding
type "
---
>         cerr << "(" << (*bl)[i].binding_name[0].id << ","
>              << (*bl)[i].binding_name[0].kind << ") binding type "
----------------------------------------

The same reason:
----------------------------------------
diff -r omniORB_2.2.0/src/examples/echo/greeting.cc
omniORB_2.2.0.orig/src/examples/echo/greeting.cc
28,29c28,29
<   cerr << "I said,\"" << (char*)src << "\"."
<        << " The Object said,\"" << (char*)dest <<"\"" << endl;
---
>   cerr << "I said,\"" << src << "\"."
>        << " The Object said,\"" << dest <<"\"" << endl;
----------------------------------------

In AIX third parameter of accept() also of size_t type:
----------------------------------------
diff -r omniORB_2.2.0/src/lib/omniORB2/tcpSocket_UNIX.cc
omniORB_2.2.0.orig/src/lib/omniORB2/tcpSocket_UNIX.cc
53d52
< #if !defined(__aix__)
57d55
< #endif
662c660
< #if defined(__aix__) || (defined(__GLIBC__) && __GLIBC__ >= 2)
---
> #if defined(__GLIBC__) && __GLIBC__ >= 2
729c727
< #if defined(__aix__) || (defined(__GLIBC__) && __GLIBC__ >= 2)
---
> #if defined(__GLIBC__) && __GLIBC__ >= 2
----------------------------------------

I can't understand why $< needed, but this cause errors:
----------------------------------------
diff -r omniORB_2.2.0/src/lib/omniORB2/sharedlib/Makefile
omniORB_2.2.0.orig/src/lib/omniORB2/sharedlib/Makefile
49c49
<       $(CXX) -c $(CXXFLAGS) -o $@ ../NamingSK.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../NamingSK.cc
73c73
<       $(CXX) -c $(CXXFLAGS) -o $@ ../constants.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../constants.cc
98c98
<       $(CXX) -c $(CXXFLAGS) -o $@ ../corbaBoa.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../corbaBoa.cc
123c123
<       $(CXX) -c $(CXXFLAGS) -o $@ ../corbaObject.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../corbaObject.cc
148c148
<       $(CXX) -c $(CXXFLAGS) -o $@ ../corbaOrb.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../corbaOrb.cc
173c173
<       $(CXX) -c $(CXXFLAGS) -o $@ ../corbaString.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../corbaString.cc
198c198
<       $(CXX) -c $(CXXFLAGS) -o $@ ../exception.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../exception.cc
223c223
<       $(CXX) -c $(CXXFLAGS) -o $@ ../giopClient.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../giopClient.cc
248c248
<       $(CXX) -c $(CXXFLAGS) -o $@ ../giopServer.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../giopServer.cc
273c273
<       $(CXX) -c $(CXXFLAGS) -o $@ ../initFile.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../initFile.cc
298c298
<       $(CXX) -c $(CXXFLAGS) -o $@ ../ior.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../ior.cc
324c324
<       $(CXX) -c $(CXXFLAGS) -o $@ ../libcWrapper.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../libcWrapper.cc
349c349
<       $(CXX) -c $(CXXFLAGS) -o $@ ../mbufferedStream.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../mbufferedStream.cc
374c374
<       $(CXX) -c $(CXXFLAGS) -o $@ ../nbufferedStream.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../nbufferedStream.cc
399c399
<       $(CXX) -c $(CXXFLAGS) -o $@ ../object.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../object.cc
424c424
<       $(CXX) -c $(CXXFLAGS) -o $@ ../objectKey.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../objectKey.cc
450c450
<       $(CXX) -c $(CXXFLAGS) -o $@ ../objectRef.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../objectRef.cc
476c476
<       $(CXX) -c $(CXXFLAGS) -o $@ ../orb.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../orb.cc
501c501
<       $(CXX) -c $(CXXFLAGS) -o $@ ../strand.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../strand.cc
528c528
<       $(CXX) -c $(CXXFLAGS) -o $@ ../tcpSocket_UNIX.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../tcpSocket_UNIX.cc
555c555
<       $(CXX) -c $(CXXFLAGS) -o $@ ../unshared.cc
---
>       $(CXX) -c $< $(CXXFLAGS) -o $@ ../unshared.cc
----------------------------------------

AIX hasn't nanosleep() but has usleep() (there is also nsleep() which is
similar to nanosleep()):
----------------------------------------
diff -r omniORB_2.2.0/src/lib/omnithread/posix.cc
omniORB_2.2.0.orig/src/lib/omnithread/posix.cc
931c931
< #elif defined(__linux__) || defined (__aix__)
---
> #elif defined(__linux__)
956c956
< #if defined(__linux__) || defined(__aix__)
---
> #ifdef __linux__
----------------------------------------

----------------------------------------
diff -r omniORB_2.2.0/src/tool/omniidl2/driver/drv_fork.cc
omniORB_2.2.0.orig/src/tool/omniidl2/driver/drv_fork.cc
100,104d99
< #if defined(__aix__)
< #include        <unistd.h>              // POSIX standard types
< #include        <sys/wait.h>                // POSIX definition of
wait()
< #endif
< 
----------------------------------------