From: Bert Vermeulen Date: Thu, 20 Nov 2014 02:11:14 +0000 (+0100) Subject: Add sr_rational_set() convenience function. X-Git-Tag: libsigrok-0.4.0~718 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=90cefe0cc7d498ed8a8c7cdb1e95c16296ca5059;p=libsigrok.git Add sr_rational_set() convenience function. --- diff --git a/include/libsigrok/proto.h b/include/libsigrok/proto.h index 7770e175..8179c815 100644 --- a/include/libsigrok/proto.h +++ b/include/libsigrok/proto.h @@ -33,6 +33,7 @@ SR_API int sr_analog_to_float(const struct sr_datafeed_analog2 *analog, SR_API int sr_analog_float_to_string(float value, int digits, char **result); SR_API int sr_analog_unit_to_string(const struct sr_datafeed_analog2 *analog, char **result); +SR_API inline void sr_rational_set(struct sr_rational *r, uint64_t p, uint64_t q); /*--- backend.c -------------------------------------------------------------*/ diff --git a/src/analog.c b/src/analog.c index 9e01566f..01704fd7 100644 --- a/src/analog.c +++ b/src/analog.c @@ -229,3 +229,15 @@ SR_API int sr_analog_unit_to_string(const struct sr_datafeed_analog2 *analog, return SR_OK; } +/* + * Set sr_rational r to the given value. + * + * @param p Numerator + * @param q Denominator + */ +SR_API inline void sr_rational_set(struct sr_rational *r, uint64_t p, uint64_t q) +{ + r->p = p; + r->q = q; +} +