4. Changes in the GCI Interfaces

Previous chapter

Next chapter

This chapter describes changes and updated information related to the GemBuilder for C and FFI interfaces, including:

GCI changes

GCI thread-safe changes

Foreign Function Interface (FFI) related changes

Updated Compile and Link Information

4.1  GCI changes

GciDirtyTrackedObjs functionality removed

The Dirty Tracked Objects set is no longer needed, and has been removed.

Removed GCI calls


Removed Image Methods related to TrackedObjects

The GciLibrary functions associated with the removed GCI calls are no longer included.

In addition, this method has been removed:

System class >> gciTrackedObjsInit

GsBitmap hiddenSetSpecifiers

#TrackedDirtyObjs is now #TrackedDirtyObjs_NotImplemented

#GciTrackedObjs is now #GciTrackedObjs_NotImplemented

Added Lz4 compression functions


(int) GciCompressUsingLz4(
    const char* src,
    char* dst,
    int srcSize,
    int dstCapacity );

Wrapper for the lz4 function LZ4_compress_default().

Compress srcSize bytes from buffer src into already allocated dst buffer of size dstCapacity. Compression is faster, and guaranteed to succeed, if dstCapacity >= LZ4_compressBound(srcSize).

If the function cannot compress src into a more limited dst buffer size, compression stops, function result is zero, and dst content is undefined (invalid).


(int) GciUncompressUsingLz4(
    const char* src,
    char* dst,
    int compressedSize,
    int dstCapacity );

Wrapper for LZ4_decompress_safe().

Decompress the compressed string at *src and place the result in *dst. *dst must be already allocated. The exact size of the compressed string at *src, and the maximum size for the destination must be provided; if dstCapacity is insufficient, decompression stops and the functions returns a negative result.

Returns the number of bytes decompressed into *dst.

Added variants of existing functions


(BoolType) GciDbgEstablishToFile_(
const char *fileName,
GciErrSType *err);

A variant of GciDbgEstablishToFile(), with the additional argument *err. GciDbgEstablishToFile_() returns error info in *err if the function result is FALSE.

One-time login support

The new feature to allow a one-time login password to be created (described starting here) can be used in GemBuilder for C, by specifying the new flag GCI_ONETIME_PASSWORD (0x400) with the loginFlags in the argument for GciLoginEx() or GciLoginEx_().

Configuration file handling support

v3.7 includes additional options and finer control over where and how GemStone executable and system configuration files are handled; this is described starting here.

Support for this in GBC is provided by GciInit_, which is a variation of GciInit that includes additional arguments, and the new class GciCfgFileArgs.


(int) GciInit_(
BoolType quietMode,
GciProcessType gciProcessType,
GciCfgFileArgs *gciCfgFileArgs,
char *configFileWarn,
size_t warnSize);

A variant of GciInit, with additional arguments to support new configuration file semantics. Only one of GciInit/GciInit_ should be used.

*gciCfgFileArgs is the results of parsing command line arguments for configuration files; see the definition for GciCfgFileArgs in gci.ht. gciProcessType should be GCI_PROCESS_GEM in linked customer applications; GciProcessType is defined in gci.ht.

This function returns 0 for success, -1 for errors in the configuration file, and -2 for memory allocation errors in libgcilnk.

Removed Mnemonics

The definitions for the obsolete classes OOP_CLASS_EUC_STRING, OOP_CLASS_INVARIANT_EUC_STRING, OOP_CLASS_EUC_SYMBOL, OOP_CLASS_JIS_CHARACTER, and OOP_CLASS_JIS_STRING have been renamed to include an additional _.

4.2  GCI thread-safe changes

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

Added Thread-safe functions


(GciSession) GciTsDebugConnectToGem(
	int gemPid,
	GciErrSType *anEerr	);

Connect to a gem's listening debug port on localhost; only supported for gems running on the same node. See the GEM_LISTEN_FOR_DEBUG configuration parameter and DEBUGGEM topaz command. The gemPid argument to GcitsDebugConnectToGem is the first arg to topaz DEBUGGEM. A call to GciTsDebugConnectToGem must be followed by a call to GciTsDebugStartDebugService.


(BoolType) GciTsDebugStartDebugService(
	GciSession aSession,
	uint64 debugToken,
	GciErrSType *anErr	);

This function must be preceded by GciTsDebugConnectToGem which creates a GciSession. Using this session, GciTsDebugStartDebugService will validate the debugToken argument and interrupt any Smalltalk execution in progress in the target gem by the equivalent of GciTsBreak(aSession, FALSE, &anErr). debugToken is the second arg to topaz DEBUGGEM. To terminate the debug session, and assumming the session being debugged was waiting in System class >> waitForDebug, the client should execute System cancelWaitForDebug or System _cancelWaitForDebugExitClient, and then call GciTsLogout.


(int) GciTsNbPoll(
	GciSession session,
	int timeoutMs,
	GciErrSType *gciErr	);

Function results:

  1 - result or error is ready, call GciTsNbResult to get the result or error.

  0 - result is not ready

  -1 - error, (invalid session, no NB call in progress, peer disconnected), details will be in gciErr.

Argument timeoutMs may be:

  0 - do not block, return immediately

  -1 - block forever until the Nb call finishes or an error occurs.

  > 0 block for up to timeoutMs ms before returning the result

4.3  Foreign Function Interface (FFI) related changes

errno: unsafe; use alternate methods to access to CCallout errno

Since CCallout class methods errno and errno: access a value stored in the GsProcess, there is a risk of that two FFI calls (within a single GsProcess) may access this, and set/retrieve incorrect values. (#49432)

The methods errno and errno: now signal an error and should not be used. You may still used callWith: if you do not need access to the errno information.

The method CCallout >> callWith:errno:, which was added in v3.6.4, can be used when the errno information is needed. See the method image comments for details.

Generated library code such as GciLibrary methods now invoke callWith:errno: rather than callWith:.

In-memory GC now responsive to memory use by FFI

In-memory garbage collection scans are now also responsive to memory pressure resulting from heavy use of gcMalloc:. This avoids excessive CHeap growth with intensive use of FFI with limited pressure on memory from Smalltalk objects.

CPreprocessor failed to cleanup temporary files

CPreprocessor could leave behind temporary files (#50182)

4.4  Updated Compile and Link Information

Linux Compile and Link Information

Complier version

Red Hat Linux ES 9.2: gcc/g++ 11.3.1

Red Hat Linux ES 8.7: gcc/g++ 8.5.0

Red Hat Linux ES 7.9: gcc/g++ 4.8.5

Ubuntu 20.04 LTS: gcc/g++ 9.4.0

Ubuntu 22.04 LTS: gcc/g++ 11.3.0

Debugger version

Red Hat Linux ES 9.2: gdb 10.2-10.el9

Red Hat Linux ES 8.7: gdb 9.1

Red Hat Linux ES 7.9: gdb 9.1

Ubuntu 20.04 LTS: gdb 9.1

Ubuntu 22.04 LTS: gdb 112.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 -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 -znoexecstack 
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 -z noexecstack -Wl,-traditional -Wl,-z,lazy 
-o userAppl

AIX Compile and Link Information

Complier version

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

Debugger version


Compiling a user action or GCI application
xlC_r -O3 -qstrict -qalias=noansi -q64 -+ -qpic 
-qthreaded -qarch=pwr6 -qtune=balanced -D_LARGEFILE64_SOURCE 
-qminimaltoc -qlist=offset -qmaxmem=-1 -qsuppress=1500-010:1500
-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

Ventura: Apple clang version 14.0.3 (clang-1403.

Monterey: Apple clang version 14.0.0 (clang-1400.0.29.202)

Big Sur: Apple clang version 12.0.0 (clang-1200.0.32.28)

Debugger version

Apple Swift version 5.7

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 
-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 
Linking a user action library
g++ -dynamiclib userCode.o $GEMSTONE/lib/gciualib.o 
-o libuserAct.dylib -m64 -lpthread -ldl -lc -lm -lpam -undefined
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 Professional 2019 Version 16.11.24
Microsoft .NET Framework Version 4.8.09032
Visual C++ 2019 00435-60000-00000-AA889

Compiling a GCI application
cl  /W3 /Zi /MD /O2 /Oy- -DNDEBUG /TP /nologo /D_LP64 /D_AMD64_ 
/D_CRT_SECURE_NO_WARNINGS /EHsc -volatile:iso 
/DNATIVE /I 'VisualStudioInstallPath\include' 
/I 'VisualStudioInstallPath\Tools\MSVC\14.29.30133\atlmfc\include'
/I 'VisualStudioInstallPath\Tools\MSVC\14.29.30133\include' 
/I '%GEMSTONE%include' /c 'userCode.c' -FouserCode.obj 
Linking a GCI application
link /LIBPATH:VisualStudioInstallPath\Tools\MSVC\14.29.30133\lib\x64
/MANIFEST /MANIFESTFILE:userAppl.exe.manifest
/MANIFESTUAC:level='asInvoker' /FORCE:MULTIPLE userCode.obj
%GEMSTONE%lib\gcirtlobj.obj %GEMSTONE%lib\gcirpc.lib ws2_32.lib
netapi32.lib advapi32.lib comdlg32.lib user32.lib gdi32.lib
kernel32.lib winspool.lib Secur32.lib Dbghelp.lib
/NODEFAULTLIB:libcmt.lib /out:userAppl.exe

Previous chapter

Next chapter