Generic

Use glib API calls if available

We use glib in (e.g. in libsigrok, libsigrokdecode, and other subprojects) as a helper library for various purposes. One of the advantages of glib is that it has many API calls that already take care of various portability issues for us. Thus, if there is a glib function for a certain task it should generally be preferred over the "native" way of doing the same task (since the latter will be more likely to break on other OSes or architectures).

Endianness

Any sigrok code should be able to work on systems of any endianness (big endian, little endian, or others). Care has to be taken in various places in the code to ensure there will be no endianness issues.

The configure script of e.g. libsigrok uses AC_C_BIGENDIAN to check for the endianness of the host where you compile (and seems to use some grep magic when cross-compiling). Per default it'll add a #define named WORDS_BIGENDIAN to config.h if it detects a big-endian host, otherwise WORDS_BIGENDIAN will not be defined. Thus, any code can use #ifdef WORDS_BIGENDIAN et al to handle endianness correctly.

32bit vs. 64bit systems

Linux

udev

usbtmc

Mac OS X

HID

Windows

FDs vs. sockets

Polling

HID

File handling

FreeBSD

libusb

While this library mimics the API of libusb-1.0 quite closely in order to be a compatible drop-in replacement from the point of view of applications that link this library, there are a few differences that have to be taken into account.

Missing libusb_handle_events_timeout_completed()

Problem: The libusb_handle_events_timeout_completed() call is not available in FreeBSD's libusb.

Solution: Since libusb_handle_events_timeout_completed() is mostly libusb_handle_events_timeout() with an additional (unused by us) parameter, a simple #define in libsigrok-internal.h can be used as workaround.