Giter Site home page Giter Site logo

saprykin / plibsys Goto Github PK

View Code? Open in Web Editor NEW
644.0 36.0 75.0 8.1 MB

Highly portable C system library: threads and synchronization primitives, sockets (TCP, UDP, SCTP), IPv4 and IPv6, IPC, hash functions (MD5, SHA-1, SHA-2, SHA-3, GOST), binary trees (RB, AVL) and more. Native code performance.

License: MIT License

CMake 6.90% C 72.26% C++ 19.19% DIGITAL Command Language 1.47% Shell 0.18%
thread-library socket ipv4 ipv6 cross-platform posix ini-parser shared-libraries profiling mutex

plibsys's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plibsys's Issues

Add wiki page about atomic operations

As different compilers may require different flags as well as there are several atomic models in the wild it should be clarified how to properly configure it.

Pass shared library handler when retrieving last error

Some platforms (i.e. BeOS) don't have a last error mechanism for shared library loading. That's why sometimes we need to store error information directly within the library handler. To do that we need to change API for p_library_loader_get_last_error() to pass a library handler.

Add port to OpenVMS system

OpenVMS is a proprietary operating system currently developed by HP and VMS Software. It supports VAX, Alpha and IA64 architectures. I have made some preliminary research and work on possible OpenVMS port with the result described below.

VAX platform is not a player for several reasons:

  • no support for 64-bit integer types;
  • lacks reliable threading support (i.e. kernel threads);
  • quite old compilers;
  • almost zero support for OpenVMS on VAX: lacks lot of POSIX calls available for Alpha and IA64 versions, barely updated (if any) by the HP/VMS Software.

Alpha and IA64 platforms are fully supported and new versions are released almost simultaneously.

The main challenge for OpenVMS port is a non-UNIX-like environment of the system. Though it has GNV (GNU-like environment with bash and friends), it doesn't simplify porting great. I have seen some threads with attempts to build CMake on OpenVMS, but none of them was completely successful. Anyway I do not like GNV approach, that why we need the following things to be done for the OpenVMS port:

  • support for OpenVMS in the code base;
  • DCL-based script to build the library (yes, there is no bash-like command line interpreter on OpenVMS);
  • DCL-based script to build and run the library tests (we can also combine it with the first one);
  • some sort of README about building on OpenVMS.

What I have already done:

  • Boost.Test is capable of building under OpenVMS, though not the latest versions (1.3x.x to 1.4x.x should be fine), so the we can run the tests;
  • the minimal OpenVMS version we need is 8.4 (the first version with POSIX and System V semaphores);
  • the compilers are fine (at least Compaq C 6.5 and HP C++ 7.1);
  • generic DCL-based script which build 32-bit or 64-bit library (no warnings so far);
  • support for OpenVMS in the library code base;
  • tried to build by hands and run some of the most complex tests like for PUThread - seems to work fine, at least we have working multithreading support.

Almost none of that work was committed and still requires to be polished, but it is not a bad start. All tests were done on an Alpha emulator, but I can check it on real hardware later. IA64 platform still needs to be evaluated more closely.

Use separate private headers

Now all the private routines are collected in the single header file. It will be better to split it to several independent header files.

Clang on Windows

It would be nice to check and add Clang compiler support for Windows.

Spinlocks

Add support for spinlocks based on atomic operations. It should provider a light-weight alternative for mutex-based locking.

Cleanup usage of reserved identifiers

7.1.3 Reserved identifiers

Each header declares or defines all identifiers listed in its associated subclause, and optionally declares or defines identifiers listed in its associated future library directions subclause and identifiers which are always reserved either for any use or for use as file scope identifiers.

— All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use.

— All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.

Thread ID

Add API to receive self thread ID.

Add endianness selection on OpenVMS

For now little endian mode is used by default and there is no way to select big endian mode. OpenVMS on Alpha and Itanium can be configured for big endian mode. Thus we should have an option for build_openvms.com script to select an endianness.

Add CPU architecture detection macros

We can detect OS and compiler, but still no way to detect CPU architecture. Thus, we can't target software for a specific hardware architecture. A set of CPU detection macros is required.

Split implementations of PLibraryLoader

Windows and POSIX implementation reside in a single source file. For a better flexibility they should be split. Also a new corresponding model should be available for platform configuration.

Shared library test doesn't work on HPPA-RISC32 with HP-UX model

HPPA-RISC32 architecture doesn't support reference count in shl_unload(). Thus, it unloads all references (including our own), which leads to a test crash. To prevent this behaviour, we need to detect HPPA-RISC32 architecture and adopt the test properly.

This issue depends on #44.

Tests with memory allocation errors

All tests are done using almost normal situations with invalid input parameters. We can enhance testing with memory allocation failures using PMemVTable with fake memory management calls.

Add shared library loading model based on shl_load()

On HP-UX prior to 11.xx dlopen() and its family functions may not be implemented. Instead there is a family of HP-UX specific calls shl_*.

HP-UX manual says that developer should use dlopen() family, so we need to test its presence and choose an appropriate implementation model.

Rewrite thread priorities support

Current imlementation is working only on a limited number of POSIX-compliant systems. New implementation should dynamically calculate priority based on system capabilities.

Make testing on QNX 7

A new version of QNX 7 SDP is available. It has 30-days evaluation period, thus can be used for testing builds also.

Add support for code coverage on Solaris

Solaris has its own code coverage tool named tcov.

About using tcov: Analyzing Program Performance with Sun WorkShop.

About -xprofile option for Oracle/Sun compiler: Oracle docs.

I have also found some useful information about Oracle/Sun compiler versions: old versions and newer versions. We need it because there two ways to enable code coverage, and according to some threads a new way was supported at least since SunPro C 4.x version.

During library configuration we should select one of the code coverage ways.

Properly handle EINTR when calling close() for a socket

Simply looping ans checking for the EINTR return code may lead to weird things in multithread environment. You can double-close a socket descriptor: the first time your own, and the next time allocated for another thread (with the same descriptor value). The problem is specifically unpleasant on some systems which may return with EINTR without actually closing a socket descriptor.

There is no general way to handle the close() call on all operating systems, so we need to do some checks.

Some related links:
http://alobbs.com/post/54503240599/close-and-eintr
https://bugs.chromium.org/p/chromium/issues/detail?id=269623
http://austingroupbugs.net/view.php?id=529
http://www.daemonology.net/blog/2011-12-17-POSIX-close-is-broken.html

Add port to OS/2 system

OS/2 is a proprietary operating system which supports x86 hardware architecture. Despite being quite old it is still in use and there are some (compatible) reincarnations (eComStation, Blue Lion) with ongoing support and new features. So, overall, the system is alive and it would be nice to support it.

The amount of work depends on the way we choose:

  • EMX environment with old GCC 2.x.
  • kLIBC C runtime library with GCC (including the latest 6.x versions) based on it.
  • Use native system calls whenever is possible.

First way is definitely not a deal. Second one lets work to be done quickly using emulated POSIX environment, but some of the required parts are still not available (pthreads, mmap). The last one should be the most tricky and requires more efforts, but is gives full control over the situation and shouldn't impact on overall performance.

As we should avoid additional external dependencies like kLIBC, it will be better to start with a native way and go with IBM's Developer Toolkit 4.5.x (provides headers and import libraries).

Anyway, we need development environment with bash, make and CMake, which are freely available. There are several compilers for OS/2 (GCC, Watcom, VisualAge), but we should start with GCC as one of the most popular.

To port the library we need to implement the following models:

  • Threads (we should use _beginthread() and friends from C runtime library) and synchronisation primitives.
  • Diretory iterating.
  • Shared library loading.
  • Replace mmap() with something like DosAllocMem().
  • IPC still need more checks on its possibility, but it seems that OS/2 doesn't have system semaphore primitive. For shared memory we can use DosAllocSharedMem() along with a process-wide mutex.
  • Time profiler (need to look at DosTmrQueryTime () or DosGetDateTime() more closely).

So, on the first impression, it is possible to make a native port to OS/2, maybe not feature-complete, but with most of them.

Add support for scope ID and flow info to IPv6 address

Currently scope ID and flow info are not explicitly supported by API (partially some OS can handle given addresses properly). We need to use getaddrinfo() when converting string address to native structure. Also it would be nice to have an ability to read those attributes from the socket address object.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.