4. Changes in the GCI Interfaces

Previous chapter

Next chapter

4.1  GCI changes

Added Functions and Macros

The following functions and macros have been added to the standard GCI, gci.hf.

GciCheckSigTerm

(BoolType) GciCheckSigTerm(
    );

GciFetchDateAndTime

(BoolType) GciFetchDateAndTime(
    OopType dtObj,
    GciDateAndTime *result
    );

GciFetchDateAndTimePosix

(BoolType) GciFetchDateAndTimePosix(
    OopType dtObj,
    GciPosixDateAndTime *result
    );

GciNewDateAndTime

(OopType) GciNewDateAndTime(
    const GciDateAndTime *arg
    );

GciNewDateAndTimePosix

(OopType) GciNewDateAndTimePosix(
    int64 microseconds,
    int offsetSeconds
    );

GCI_OOP_IS_SmallDate

BoolType GCI_OOP_IS_SmallDate(theOop) 

GCI_OOP_IS_SmallDateAndTime

BoolType GCI_OOP_IS_SmallDateAndTime(theOop) 

GCI_OOP_IS_SMALL_DOUBLE

BoolType GCI_OOP_IS_SMALL_DOUBLE(theOop) 

GCI_OOP_IS_SmallScaledDecimal

BoolType GCI_OOP_IS_SmallScaledDecimal(theOop) 

GCI_OOP_IS_SmallTime

BoolType GCI_OOP_IS_SmallTime(theOop) 

4.2  GCI thread-safe changes

The thread-safe GCI is provided in gcits.hf.

Added Functions

GciTsNbLogin

(GciSession) GciTsNbLogin(
    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,
    int   *loginPollSocket /* output */
    );

Starts a GciTsLogin in a separate thread. You must call GciTsLoginFinished to determine if login is complete. While the login is in progress, any GciTs call other than GciTsLoginFinished will return an error.

While the login is executing, the file descriptor returned in *loginPollSocket can be polled, when read-ready the login is complete.

Returns NULL if malloc() failed or socketpair() failed.

GciTsNbLoginFinished

(int) GciTsNbLoginFinished(
    GciSession sess,
    BoolType *executedSessionInit,
    GciErrSType *err
    );

Should be called at least once after GciTsNbLogin is called. Argument sess must be result of a GciTsNbLogin call. Function result is:

  • 0 if previous GciTsNbLogin not finished, and executedSessionInit is invalid
  • -1 if previous GciTsNbLogin failed, with details in *err
  • 1 if previous GciTsNbLogin finished; *err may include a warning

Removed Functions

The following functions have been removed:

GciTsForkContinueWith
GciTsForkExecute
GciTsForkLogin
GciTsForkPerform
GciTsForkStoreTravDoTravRefs
GciTsX509ForkedLogin

4.3  Foreign Function Interface (FFI) related changes

Support for Callout symbol version

You can now specify the symbol version for an FFI callout, to prevent accidentally calling the wrong version of the routine.

CCallout >> version

CCallout >> version: aString
The argument aString will be used as third argument to dlvsym()

Race condition in setting FFI errno

Previously, the FFI errno was in session state, and could be accessed incorrectly if the GsProcess was preempted at the wrong time. Now, the FFI errno is part of the GsProcess state. This does not affect customer code. (#48524)

Added methods

The following methods have been added:

CByteArray >> utf16From: zeroBasedStart to: zeroBasedEnd
Return a new instance of Utf16 containing the specified bytes of the receiver.

CByteArray >> utf8From: zeroBasedStart to: zeroBasedEnd
Return a new instance of Utf8 containing the specified bytes of the receiver.

CByteArray class >> withAll: anObject nullTerminate: aBoolean
anObject
may be a String, ByteArray, Utf8, Utf16 or CByteArray. Returns a new instance of the receiver containing a copy of the bytes of the argument. If aBoolean is true, the resulting CByteArray contains the bytes of the argument plus a terminator byte (or Utf16 codepoint) with value zero. If argument is a Utf16, the result has code points in CPU byte order.
Note that ByteArray usually stores integers in big-endian order, not CPU native byte order.

4.4  UserAction changes

Handling Errors in user actions

In earlier releases, the error handling block of an on:do: could not handle an error in a user action, and then return from the error handling block. This case resulted in infinite recursion signaling an UncontinuableError.(#49040)

An error from a user action now signals the new error 2758, ERR_EXC_RETURN_DISALLOWED: A return from on:do: would cross frame of C primitive, user action, or FFI call. This is handled correctly by the on:do:.

To allow debugging of the original error, a new Gem runtime parameter, GemDebuggerActive, allows you to retrieve a stack trace for the original error. When GemDebuggerActive is set to true, the on:do: does not handle error 2758, and control returns to the command line. At this point, in topaz, you can fetch the stack using commands such as where.

Invoking a client useraction from non-blocking GCI call could freeze Gem

In an execution that was started from a GciNbPerform* or GciNbExecute* call, if the code invokes a client useraction, the gem would freeze until a further call such as GciNbEnd. (#48658)

User actions are now disallowed during non-blocking GCI execution. User actions have always been disallowed when using the thread safe GCI, GciTs.

The flag GCI_PERFORM_NON_BLOCKING was renamed to GCI_PERFORM_noClientUseraction.

4.5  Updated Compile and Link Information

Linux Compile and Link Information

Complier version

Red Hat Linux ES 8.1: gcc/g++ 8.3.1

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

Ubuntu 20.04 LTS: gcc/g++ 9.3.0

Ubuntu 18.04 LTS: gcc/g++ 8.4.0

Ubuntu 16.04 LTS: gcc/g++ 5.4.0

Debugger version

Red Hat Linux ES 8.1: gdb 8.2-11

Red Hat Linux ES 7.4: gdb 7.6.1-100

Ubuntu 20.04 LTS: gdb 9.1

Ubuntu 18.04 LTS: gdb 8.2.50

Ubuntu 16.04 LTS: gdb 8.2.50

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 -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 -Wno-format-truncation
-Wuninitialized
Linking a user action library
g++ -shared -Wl,-hlibuserAct.so userCode.o $GEMSTONE/lib/gciualib.o
-o libuserAct.so -m64 -Wl,-Bdynamic,--no-as-needed -lpthread 
-Wl,--as-needed -lcrypt -ldl -lc -lm -lrt 
Linking a GCI application
g++ userCode.o $GEMSTONE/lib/gcirtlobj.o -m64 
-Wl,-Bdynamic,--no-as-needed -lpthread -Wl,--as-needed -lcrypt
-ldl -lc -lm -lrt -Wl,-traditional -Wl,-z,lazy -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 8.1 SunOS_i386 2016/06/01

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 -h libuserAct.so -i userCode.o
$GEMSTONE/lib/gciualib.o -o libuserAct.so -Bdynamic -lc 
-lpthread -ldl -lrt -lsocket -lnsl -lm -lpam -lCrun -lsendfile
-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 -lsendfile -o userAppl

AIX Compile and Link Information

Complier version

IBM XL C/C++ for AIX, V16.1

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:1540-2988
-qnoeh -I$GEMSTONE/include -c userCode.c -o userCode.o

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

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 -LcompilerInstallDir/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/compilerInstallDir/lib -lpthreads -lc_r -lC_r -lm -ldl 
-lbsd -lpam -Wl,-brtllib -o userAppl

DARWIN Compile and Link Information

Complier version

Apple clang version 11.0.3 (clang-1103.0.32.62

Debugger version

lldb

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:

-Wno-format -Wtrigraphs -Wcomment -Wsystem-headers -Wtrigraphs
-Wno-aggregate-return -Wswitch -Wshadow -Wunused-value 
-Wunused-variable -Wunused-label -Wno-unused-function 
-Wchar-subscripts -Wno-conversion -Wmissing-braces -Wmultichar
-Wparentheses -Wsign-compare -Wsign-promo -Wwrite-strings 
-Wreturn-type -Wno-nullability-completeness 
-Wno-expansion-to-defined 
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