Cross-Platform C Library Integration

Overview

HotPDF uses HPDFCLibs.pas as the Pascal-facing bridge between Delphi and the statically linked C object files used by HPDFZLib.pas, HPDFJpeg.pas, and HPDFTiff.pas. The unit exposes the runtime symbols those libraries expect while keeping one consistent Pascal declaration layer for both Win32 and Win64 builds.

Key Features

  • Shared runtime bridge for zlib-ng in zlib-compatible mode, zlib-ng 64-bit runtime SIMD dispatch, libjpeg-turbo 3.1.90 with NASM SIMD objects, and libtiff 4.7.1
  • Memory, stdio, string/character, and selected math/runtime helper coverage
  • 32-byte aligned malloc, free, realloc, and calloc bridging for SIMD-friendly native buffers
  • Win32 compatibility with bcc32c-built zlib-ng OMF objects and bcc32-built JPEG/TIFF OMF objects from Lib\thirdparty\Win32
  • Win64 compatibility with COFF64 obj files from Lib\thirdparty\Win64 and zlib-ng COFF objects from Lib\thirdparty\Win64x
  • Pointer-sized helper types and Pascal stubs for symbols the Delphi linker cannot import directly

High-Performance JPEG Backend

Standard JPEG workflows are backed by libjpeg-turbo 3.1.90 through the classic libjpeg-compatible API exposed by HPDFJpeg.pas. The Win32, Win64, and Win64x object builds include the relevant NASM SIMD acceleration objects, and the same bundled object set is also available to the TIFF integration layer for JPEG-compressed TIFF handling.

Zlib-ng Bridge Notes

Win64 Flate image streams use a small C bridge around zlib-ng one-shot compression. The bridge keeps native zlib-ng length types inside C while preserving HotPDF's Pascal-facing 32-bit buffer lengths and maximum compression behavior.

The Win64x and diagnostic MSVC Win64 zlib-ng object builds include runtime-dispatched SSE2, SSSE3, SSE4.1, SSE4.2, PCLMULQDQ, and AVX2 implementations with generic fallbacks. Win32 keeps the generic zlib-ng OMF objects for bcc32c compatibility, while the Win32 JPEG/TIFF path remains on classic bcc32 OMF objects.

Supported Function Groups

  • Memory Management: malloc, free, realloc, calloc with 32-byte aligned allocation
  • File and Stream Operations: fopen, fclose, fputc, fread, fwrite, fflush, ferror
  • String and Character Functions: strcpy, sprintf, memcpy, memmove, memset, tolower, toupper, towlower, towupper, getenv, atoi
  • Runtime Helpers: ftol, setjmp, log, snprintf, memcmp

Architecture Support

  • Win32: Pascal wrappers and WinAPI-backed helpers that match the bcc32c and bcc32 OMF objects linked by every supported Delphi Win32 version
  • Win64: msvcrt.dll imports plus small helper stubs required by the MSVC-generated COFF64 objects
  • Common Types: PtrInt and PtrUInt keep pointer-sized declarations aligned across both targets

See Also