4. Changes in the GCI Interfaces

Previous chapter

Next chapter

4.1  Changes in standard GCI API

Added functions

GciUtf8To8bit

(BoolType) GciUtf8To8bit(
    const char* src,
    char *dest,
    ssize_t destSize
    );

This function converts Utf8 input in *src to 8 bit data in *dest. If all code points in *src are in the range 0..255, and the result fits in destSize-1, returns TRUE and *dest is null terminated, otherwise returns FALSE.

Function changes

GciPerformFetchBytes returns a result of type ssize_t rather thant int64

A number of new reserved OOPS have been added for classes that are new in v3.4.

The GciObjRepHdrSType field objectSecurityPolicyId must now be UNDEFINED_ObjectSecurityPolicyId, if the object already exists.

Removed functions

The following deprecated functions have been removed, since they functionally require constraints, and constraint implementation is now removed.

GciPathToStr
GciStrToPath

4.2  FFI-related changes

Create a CCallout from a function pointer

The following method has been added. This allows a function pointer stored into a CByteArray by C code to be used to synthesize a CCallout from that pointer.

CByteArray >> ccalloutAt: zeroBasedOffset name: aString result: resType
args: argumentTypes

Returns an instance of CCallout. aString is used to fill in the fName in the result, but not otherwise used. The 8 byte pointer value in the receiver at zeroBasedOffset is used instead of the result of a dlsym() call when building the result. resType and argumentTypes must be as documented in CCallout class >> library:name:result:args: .

CByteArray pointerAt:resultClass: allows CPointer

This method previously only allowed the resultClass: argument to be a CByteArray or a subclass of CByteArray. Now, CPointer may be specified and this method will create an instance of CPointer.

Copying CByteArray

Executing CByteArray>>copyFrom:from:to:into: with an end index that is less than the startindex returned an error. For consistency with String copyFrom:to:, this is now allowed.

This method returns the receiver. For consistency with String copy methods that return the number of bytes copied, the following method has been added:

CByteArray >> copyBytesFrom:from:to:into

4.3  Bug Fixes

GciRtlLoad with null path failed on Windows and for 32-bit GCI applications

When the path argument to GciRtlLoad is NULL, it uses a default path. This previously used the 64-bit UNIX path, $GEMSTONE/lib. On Windows, the shared libraries are distributed in the bin directory, and for 32-bit applications, the library path is $GEMSTONE/bin32. In these cases, GciRtlLoad did not find the libraries and failed. Now, the correct path is computed on Windows. (#46506)

GciStoreTravDoTravRefs error if same oop in both GCed set and noLongerReplicated set

If the same oop is both in arguments for the set of OOPs GCed and the noLongerReplicatedSet, it results in an error rtErrNotInExportSet. (#46883)

It was possible to encounter this if a client GBS process was terminated at the wrong moment.

4.4  Changes in Thread-safe GCI

Status of User Actions and GsFile operations

The thread-safe GCI does not support client-side user actions. This means that thread-safe GCI applications also cannot evaluate Smalltalk code that performs client-side GsFile operations.

New Thread-Safe feature to Fork execution

The following API calls have been added to support forked execution:

GciTsForkContinueWith

(BoolType) GciTsForkContinueWith(
    GciSession sess,
    OopType gsProcess,
    OopType replaceTopOfStack,
    GciErrSType *continueWithError,
    int flags,
    GciErrSType *err,
    GciTsCallbackFType *callback
    );

Execute GciTsContinueWith in a separate C thread, calling *callback when finished. Function result is TRUE if call initiated, FALSE if call could not be started, with details in *err.

GciTsForkExecute

(BoolType) GciTsForkExecute(
    GciSession sess,
    const char sourceStr,
    OopType sourceOop,
    OopType contextObject,
    OopType symbolList,
    int flags,
    ushort environmentId / normally zero ,
    GciErrSType *err,
    GciTsCallbackFType *callback
    );

Execute GciTsExecute in a separate C thread, calling *callback when finished. Function result is TRUE if call initiated, FALSE if call could not be started, with details in *err.

GciTsForkLogin

(BoolType) GciTsForkLogin(
    const char *StoneNameNrs,
    const char *HostUserId,
    const char *HostPassword,
    BoolType hostPwIsEncrypted,
    const char *GemServiceNrs,
    const char *gemstoneUsername,
    const char *gemstonePassword,
    unsigned int loginFlags,
    int haltOnErrNum,
    GciErrSType *err,
    GciTsCallbackFType *callback
    );

Execute GciTsLogin in a separate C thread, calling *callback when finished. Function result is TRUE if call initiated, FALSE if call could not be started, with details in *err. Upon completion, the first argument to the callback is the newly allocated session and second argument is a SmallInteger value 0 for clean login, 1 if a warning was returned in *err

GciTsForkPerform

(BoolType) GciTsForkPerform(
    GciSession sess,
    OopType receiver,
    OopType aSymbol,
    const char selectorStr,
    const OopType *args,
    int numArgs,
    int flags,
    ushort environmentId / normally zero ,
    GciErrSType *err,
    GciTsCallbackFType *callback
    );

Execute GciTsPerform in a separate C thread, calling *callback when finished. Function result is TRUE if call initiated, FALSE if call could not be started, with details in *err.

GciTsForkStoreTravDoTravRefs

(BoolType) GciTsForkStoreTravDoTravRefs(
    GciSession sess,
    const OopType *oopsNoLongerReplicated,
    int numNotReplicated,
    const OopType *oopsGcedOnClient,
    int numGced,
    GciStoreTravDoArgsSType *stdArgs,
    GciClampedTravArgsSType *ctArgs,
    GciErrSType *err,
    GciTsCallbackFType *callback
    );

Execute GciTsStoreTravDoTravRefs in a separate C thread , calling *callback when finished. Function result is TRUE if call initiated, FALSE if call could not be started, with details in *err. Upon completion, the second argument to the callback is the int result of GciTsStoreTravDoTravRefs expressed as a SmallInteger.

Other Added Thread-Safe functions

GciTsCallInProgress

(int) GciTsCallInProgress(
    GciSession sess,
    GciErrSType *err
    );

Returns 1 if a call is in progress on the specified session, 0 if a call is not in progress, -1 if sess is invalid in which case *err contains the details.

GciTsFetchTraversal

(int) GciTsFetchTraversal(
    GciSession sess,
    const OopType *theOops,
    int numOops,
    GciClampedTravArgsSType *ctArgs,
    GciTravBufType *travBuff,
    int flag,
    GciErrSType *err
    );

Performs a traversal starting at the oops specified by theOops and numOops, as specified by *ctArgs and flags, returning object reports in *travBuff . Returns 1 if traversal completed, 0 if data returned but traversal not complete, -1 if error returned in *err (in which case *travBuff undefined). If result == 1, call GciTsMoreTraversal again to fetch the remainder of the traversal result.

4.5  Updated Compile and Link Information

Compile and link changes in this release are minor.

Linux Compile and Link Information

Complier version

Red Hat 6.x: gcc/g++ 4.4.7

Red Hat 7.x: gcc/g++ 4.8.5

Ubuntu Linux 14.04: gcc/g++ 4.8.4

Ubuntu Linux 16.04: gcc/g++ 5.4.0

SUSE Linux 12: gcc/g++ 4.8.5

Debugger version

Red Hat 6.x: GNU gdb 7.2-90.el6

Red Hat 7.1: GNU gdb 7.6.1-80.el7

Ubuntu Linux 14.04: GNU gdb 7.7.1

Ubuntu Linux 16.04: GNU gdb 7.11.1

SUSE Linux 12: GNU gdb 7.9.1

Compiling a user action or GCI application

g++ -fmessage-length=0 -fcheck-new -O3 -ggdb -m64 -pipe 
-D_REENTRANT -D_GNU_SOURCE -pthread -fPIC -fno-strict-aliasing
-fno-exceptions -I$GEMSTONE/include -x c++ -c userCode.c 
-o userCode.o 

The following warn flags are recommended for compilation:

-Wformat -Wtrigraphs -Wcomment -Wsystem-headers -Wtrigraphs 
-Wno-aggregate-return -Wswitch -Wshadow -Wunused-value 
-Wunused-variable -Wunused-label -Wno-unused-function 
-Wchar-subscripts -Wmissing-braces -Wmissing-declarations
-Wmultichar -Wparentheses -Wsign-compare -Wsign-promo 
-Wwrite-strings -Wreturn-type -Wuninitialized

Linking a user action library

g++ -shared -Wl,-Bdynamic,-hlibuserAct.so userCode.o 
$GEMSTONE/lib/gciualib.o -o libuserAct.so -m64 
-Wl,--no-as-needed -lpthread -Wl,--as-needed
-lcrypt -ldl -lc -lm -lrt -lpam -lpam_misc -Wl,-z,muldefs 
-Wl,--warn-unresolved-symbols

Linking a GCI application

g++ userCode.o $GEMSTONE/lib/gcirtlobj.o -Wl,-traditional
-Wl,--warn-unresolved-symbols -m64 -Wl,--no-as-needed -lpthread
-Wl,--as-needed -lcrypt -ldl -lc -lm -lrt -lpam -lpam_misc 
-Wl,-z,muldefs -o userAppl

Solaris on x86 Compile and Link Information

Complier version

CC: Studio 12.5 Sun C++ 5.14 SunOS_i386 2016/05/31

Debugger version

Sun DBX Debugger 7.7 SunOS_i386 2009/06/03

Compiling a user action or GCI application

CC -xO4 -m64 -xarch=generic -Kpic -mt -D_REENTRANT 
-D_POSIX_PTHREAD_SEMANTICS -I$GEMSTONE/include 
-features=no%except -c userCode.c -o userCode.o

Linking a user action library

CC -m64 -xarch=generic -G -Bsymbolic -h libuserAct.so -i userCode.o
$GEMSTONE/lib/gciualib.o -o libuserAct.so -Bdynamic -lc 
-lpthread -ldl -lrt -lsocket -lnsl -lm -lpam -lCrun -z nodefs

Linking a GCI application

CC -xildoff -m64 -xarch=generic -i userCode.o 
$GEMSTONE/lib/gcirtlobj.o -z nodefs -Bdynamic -lc -lpthread 
-ldl -lrt -lsocket -lnsl -lm -lpam -lCrun -o userAppl

AIX Compile and Link Information

Complier version

AIX 6.1, and 7.1 on POWER7: IBM XL C/C++ for AIX, V11.1

AIX 7.1 on POWER8: IBM XL C/C++ for AIX, V13.1.2

Debugger version

dbx

Compiling a user action or GCI application

xlC_r -O3 -qstrict -qalias=noansi -q64 -+ -qpic 
-qthreaded -qarch=pwr6 -qtune=balanced -D_LARGEFILE64_SOURCE 
-DFLG_AIX_VERSION=version -D_REENTRANT -D_THREAD_SAFE 
-qminimaltoc -qlist=offset -qmaxmem=-1 -qsuppress=1500-010:1500
-029:1540-1103:1540-2907:1540-0804:1540-1281:1540-1090 -qnoeh 
-I$GEMSTONE/include -c userCode.c -o userCode.o

Depending on your version of AIX, you need to include either -DFLG_AIX_VERSION=61 or -DFLG_AIX_VERSION=71.

Also note that there is no space in the -qsuppress arguments that are continued on the following line.

Linking a user action library

xlC_r -G -Wl,-bdatapsize:64K -Wl,-btextpsize:64K 
-Wl,-bstackpsize:64K -q64 userCode.o $GEMSTONE/lib/gciualib.o 
-o libuserAct.so -e GciUserActionLibraryMain -L/usr/vacpp/lib 
-lpthreads -lc_r -lC_r -lm -ldl -lbsd -lpam -Wl,-berok

Linking a GCI application

xlC_r -Wl,-bdatapsize:64K -Wl,-btextpsize:64K 
-Wl,-bstackpsize:64K -q64 userCode.o $GEMSTONE/lib/gcirtlobj.o 
-Wl,-berok -L/usr/vacpp/lib -lpthreads -lc_r -lC_r -lm -ldl 
-lbsd -lpam -Wl,-brtllib -o userAppl

DARWIN Compile and Link Information

Complier version

Apple LLVM version 6.0 (clang-600.0.56)

Debugger version

GNU gdb 6.3.50.20050815-cvs (Thu Nov 21 15:33:19 UTC 2013)

Compiling a user action or GCI application

g++ -fmessage-length=0 -O3 -ggdb -m64 -pipe -fPIC 
-fno-strict-aliasing  -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE 
-D_REENTRANT -D_GNU_SOURCE -I$GEMSTONE/include -x c++ 
-c userCode.c -o userCode.o 

The following warn flags are recommended for compilation:

-Wformat -Wtrigraphs -Wcomment -Wsystem-headers -Wtrigraphs 
-Wno-aggregate-return -Wswitch -Wshadow -Wunused-value 
-Wunused-variable -Wunused-label -Wno-unused-function 
-Wchar-subscripts -Wconversion -Wmissing-braces -Wmultichar 
-Wparentheses -Wsign-compare -Wsign-promo -Wwrite-strings 
-Wreturn-type 

Linking a user action library

g++ -dynamiclib userCode.o $GEMSTONE/lib/gciualib.o 
-o libuserAct.dylib -m64 -lpthread -ldl -lc -lm -lpam -undefined
dynamic_lookup 

Linking a GCI application

g++ userCode.o $GEMSTONE/lib/gcirtlobj.o -undefined dynamic_lookup 
-m64 -lpthread -ldl -lc -lm -lpam -o userAppl

Windows Compile and Link Information

Complier/Debugger version

Microsoft Visual Studio 2010 Version 10.0.30319.1 RTMRel

Microsoft Visual C++ 2010 01021-532-2002102-70611

Compiling a GCI application

cl /W3 /Zi /MD /O2 /Oy- -DNDEBUG /TP /nologo /D_LP64 /D_AMD64_
/D_CONSOLE /D_DLL /DWIN32_LEAN_AND_MEAN
/D_CRT_SECURE_NO_WARNINGS /EHsc 
/DNATIVE /I 'VisualStudioInstallPath\atlmfc\include' 
/I 'VisualStudioInstallPath\VC\include' 
/I 'C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\Include'
/I '%GEMSTONE%\include' -c userCode.c -FouserCode.obj

Linking a GCI application

link /LIBPATH:"VisualStudioInstallPath\VC\lib\amd64" 
/LIBPATH:"C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\Lib\x64" -RELEASE
/OPT:REF /INCREMENTAL:NO /MAP /nologo /MANIFEST 
/MANIFESTFILE:userAppl.exe.manifest 
/MANIFESTUAC:"level='asInvoker'" userCode.obj 
%GEMSTONE%\lib\gcirpc.lib ws2_32.lib netapi32.lib advapi32.lib
comdlg32.lib user32.lib gdi32.lib kernel32.lib winspool.lib
Secur32.lib /out:userAppl.exe

 

Previous chapter

Next chapter