Skip to content
Alexander Saprykin edited this page Sep 10, 2023 · 12 revisions

General

In some cases you may need to create a custom platform (OS + compiler) or tune an existing one. All platform configuration files are located in the platforms subdirectory. CMake configuration script forms platform name using <os>-<compiler> pattern and tries to load configuration file named platform.cmake from the platforms/<os>-<compiler> subdirectory. If you want to add a new platform simply create new subdirectory and place configuration file there, and then re-run CMake.

Tuning platform

Every platform configuration file must specify implementation models for the following parts of the library:

  • Threading (threads, mutexes, conditional variables).
  • IPC (semaphores, shared memory).
  • Time profiler.
  • Directory iterating.
  • Shared library loading.

Additionally (not required by default) you can specify implementation models for the following parts of the library:

  • Read-write lock.

Threading models

Use PLIBSYS_THREAD_MODEL CMake variable to define threading model:

  • win: Windows native threading model.
  • posix: POSIX (pthreads) threading model, uses pthread_create() and friends.
  • solaris: Unix International threading model found on Solaris and UnixWare, uses thr_create() and friends.
  • os2: OS/2 threading model, uses _beginthread() and Dos* family of calls.
  • beos: BeOS threading model, uses spawn_thread() and friends.
  • atheos: AtheOS threading model found on AtheOS-based operating systems, similar to BeOS and also uses spawn_thread() and friends, but some calls have different names or parameters, as well as return codes.
  • none: Empty implementation.

IPC models

Use PLIBSYS_IPC_MODEL CMake variable to define IPC model:

  • win: Windows native IPC model.
  • posix: POSIX IPC model, uses sem_open(), shm_open() and friends.
  • sysv: UNIX System V IPC model, uses semget(), shmget() and friends.
  • os2: OS/2 model, uses DosAllocSharedMem() for shared memory, semaphores are not supported.
  • none: Empty implementation.

Time profiler models

Use PLIBSYS_TIME_PROFILER_MODEL CMake variable to define time profiler model:

  • win: Windows time profiler model, uses QueryPerformanceCounter() call.
  • posix: POSIX time profiler model, uses momotonic clock_gettime() or gettimeofday() calls.
  • solaris: Solaris way, uses gethrtime(), can be found also on HP-UX.
  • mach: OS X native way, uses mach_absolute_time() call.
  • os2: OS/2 native way, uses DosTmrQueryTime() call.
  • beos: BeOS native way, uses system_time() call.
  • generic: Almost unusable approach based on seconds accuracy using time() call.

Directory iterating models

Use PLIBSYS_DIR_MODEL CMake variable to define directory iterating model:

  • win: Windows native directory iterating model.
  • posix: POSIX approach based on dirent structures and calls.
  • os2: OS/2 native directory iterating model.
  • none: Empty implementation.

Shared library loading models

Use PLIBSYS_LIBRARYLOADER_MODEL CMake variable to define shared library loading model:

  • win: Windows library model, uses LoadLibrary() call.
  • posix: POSIX library model, uses dlopen() call.
  • os2: OS/2 library model, uses DosLoadModule() call.
  • beos: BeOS library model, uses load_add_on() call.
  • none: Empty implementation.

Read-write lock models

By default the same threading model is used for read-write lock implementation. But in some circumstances you may need to use different implementation model for a read-write lock (i.e. when a threading model lacks read-write lock implementation). Use PLIBSYS_RWLOCK_MODEL CMake variable to override default read-write lock model:

  • general: based on mutex and conditional variables.
  • none: Empty implementation.

Attention: Mixing different threading and read-write lock models other than listed above may lead to unpredictable behaviour. Use it only when you know what are you doing.

Additional variables

You can also tune compilation process using the following CMake variables:

  • PLIBSYS_PLATFORM_DEFINES - compiler definitions.
  • PLIBSYS_PLATFORM_CFLAGS - compiler flags.
  • PLIBSYS_PLATFORM_LINK_LIBRARIES - linker libraries.
  • PLIBSYS_PLATFORM_LDFLAGS - linker flags.
Clone this wiki locally