summaryrefslogtreecommitdiff
path: root/util.c
AgeCommit message (Collapse)Author
2022-11-24util: silence printf format compiler warnings (Python ssize_t)Gerhard Sittig
On some platforms PY_FORMAT_SIZE_T seems to be ineffective, resulting in compiler warnings about printf format data type mismatches (observed in MXE builds). Silence the warnings. Prefer the ssize_t data type instead which we know the printf format of, reliably.
2019-12-10struct srd_decoder: Fix/improve some documentation comments.Uwe Hermann
2019-11-24decoder: internal 'always false' term, handle invalid skip and channelGerhard Sittig
Introduce an "always false" type for .wait() terms. Map invalid counts of skip conditions (zero or negative numbers) as well as invalid channel references for level/edge conditions to this type which never matches. Keep this "always false" term type an internal detail of the common support code. This is most robust and least intrusive at the same time, it keeps the existing API, and simplifies the implementation of Python decoders for rare edge cases (optional input signals or optional features, handling of initial samples at the very start of a capture). This commit passes sample counts internally in a signed data type. This is essential for proper operation, and the loss of one bit out of 64 shall not be considered a severe limitation. This fixes bug #1444.
2018-05-18Random whitespace/cosmetic/consistency fixes.Uwe Hermann
2018-05-15util.c: Add two missing PyGILState_Release() calls.Uwe Hermann
2017-06-30Acquire/release the Python GIL where needed to avoid threading issues.Uwe Hermann
With these additions, frontends can now call libsigrokdecode API functions from different threads without running into threading issues. The backend releases the GIL when it is performing tasks that might take a while and it doesn't need to run Python/C API calls during that time. This allows frontends to run multiple PD stacks (in multiple frontend threads) "at the same time" in a time-sharing, "interlocked" manner. Whenever one of the decoders is inside e.g. self.wait() it releases the GIL and thus allows other decoders to do some work in the mean time. The user-visible effect is that for use-cases such as running 3 different decoder stacks at the same time for an acquisition, the user will not have to wait for PD 1 to finish decoding, then wait for PD 2 to finish decoding, and only *then* being able to see annotations from PD 3. Instead, all three PDs will decode some chunks of data from time to time, thus the user is able to inspect annotations from all 3 PDs while the acquisition and decoding is still going on.
2017-05-31struct srd_decoder: Add list of input/output decoder IDs.Uwe Hermann
2016-12-07Add support for the new query-based PD v3 decoder API.Uwe Hermann
For the time being, both APIs (2 and 3) will remain supported until all decoders have been converted to API version 3. Then, support for API version 2 will be dropped. Decoders using PD v3 API can benefit from both readability improvements as well as performance improvements. Up to 10x speedup has been measured in some situations (depends a lot on the decoder, the amount of data, the amount of edges in the signals, the amount of oversampling etc. etc.). This is only the first set of (basic) performance improvements for libsigrokdecode, there are various additional opportunities for further changes to improve performance. This changeset has been tested to survive a run of all the test-cases in the sigrok-test repo without issues (for the converted PDs), however it is not very well-tested yet, so there might be regressions that need to be addressed.
2015-10-06util: Factor out Python module loadDaniel Elstner
Create a utility function for loading a Python module by its name in UTF-8.
2015-10-06decoder: Refactor loading code and plug leaksDaniel Elstner
2015-10-06Python: Restrict code to stable ABI subsetDaniel Elstner
Limit usage of the Python C API to the stable ABI subset as defined by PEP 384. This removes some type definitions and functions which libsigrokdecode made use of. Convert all affected code to suitable API alternatives. Also fix a few leaks that became apparent while working on the code. The most visible change is that PyTypeObject is now an opaque type. Thus, the custom Decoder and srd_logic types are now created on the heap via an alternative API. Unfortunately, since tp_name is now inaccessible, type names had to be removed from the log output. Stack traces after Python exceptions are now formatted by calling into Python, since the trace object C API is no longer available.
2015-09-13Build: Include <config.h> first in all source filesDaniel Elstner
Since Autoconf places some important feature flags only into the configuration header, it is necessary to include it globally to guarantee a consistent build.
2015-04-01Use g_malloc*() consistently, simplify error handling.Uwe Hermann
Use g_malloc*() for small allocations and assume they always succeed. Simplify error handling in a few places accordingly. Document the rules in the README file.
2014-07-08Remove dependency on Python.h from public API headerMarcus Comstedt
This prevents Python.h from being included into client code, where it can mess things up by e.g. redefining _POSIX_C_SOURCE.
2013-12-11Easier access to sequences of strings, not just lists.Bert Vermeulen
2013-05-03Main header is <libsigrokdecode/libsigrokdecode.h> now.Uwe Hermann
This matches the convention used in libsigrok. Potential other headers might end up in libsigrokdecode/, but only libsigrokdecode.h is meant to be #included by frontends directly.
2013-04-23GPL headers: Use correct project name.Uwe Hermann
2013-02-09Doxygen: Mark private functions/variables properly.Uwe Hermann
2012-05-09srd: Fix a few Doxygen errors.Uwe Hermann
2012-03-28srd: Some more (optional) consistency renames.Uwe Hermann
2012-03-18srd: Constify lots more parameters.Uwe Hermann
2012-02-28srd: properly return status codeBert Vermeulen
2012-02-11Use g_try_malloc/g_free/g_strdup consistently.Uwe Hermann
Avoid plain malloc()/free() in sr/srd, especially in the API calls. Also avoid g_malloc*() in favor of g_try_malloc*(). Use g_strdup() instead of strdup() so that we can use g_free() consistently everywhere. Exceptions: Stuff that is allocated via other libs (not using glib), should also be properly free'd using the respective free-ing function (instead of g_free()). Examples: Stuff allocated by libusb, libftdi, etc. Also, use sr_err() instead of sr_warn() for actual errors. sr_warn() is meant for non-fatal/uncritical warnings.
2012-02-10srd: s/python/Python/.Uwe Hermann
2012-02-10srd: Add/improve g_malloc() error messages.Uwe Hermann
2012-02-10srd: Add/use SRD_API/SRD_PRIV macros.Uwe Hermann
This is not yet finished, more things should be made private.
2012-02-10srd: Cosmetics, whitespace, coding-style fixes.Uwe Hermann
2012-01-26srd: Remove manual log domain ("srd: ") prefixes.Uwe Hermann
2012-01-23srd: use new exception system everywhereBert Vermeulen
2012-01-23srd: minor code cleanupBert Vermeulen
2012-01-22srd: make all debugging and error reporting uniformBert Vermeulen
2012-01-21add py_dictitem_as_str(), more checking in py_attr_as_str()Bert Vermeulen
2012-01-16srd: don't decref an object we don't ownBert Vermeulen
2012-01-15srd: clean up module loading/unloading, and the decoder structBert Vermeulen
PDs are now checked for a proper Decoder object, with at least the required attributes. The author, long_desc and func attributes in the decoder object are gone.
2012-01-07convert data coming in from a PD to C structsBert Vermeulen
This is in preparation for passing annotation data back to the calling frontend, and python data up to the next protocol in the stack.
2012-01-03sr/srd: Fix left-over #includes.Uwe Hermann
The libs themselves should use #include "sigrok.h" etc., while the frontends must use #include <sigrok.h> and so on.
2011-12-28better python memory managementBert Vermeulen
2011-12-28python 3 portBert Vermeulen
2011-12-04refactored PD framework, now using new sigrok.Decoder objectBert Vermeulen
This uses the new python unified type/class object API to construct an object for PDs to subclass. The sigrok.Decoder class has a method put() which is implemented as a C function, and receives the PD's object instance as its first parameter.