]> sigrok.org Git - libsigrok.git/blobdiff - src/libsigrok-internal.h
resource: Replace ssize_t with gssize to avoid unistd.h
[libsigrok.git] / src / libsigrok-internal.h
index dc5147443bc39dabae252d80b3d04c564c579145..5ada5f99601ea03d01e84418f09de72b98ccc789 100644 (file)
@@ -150,6 +150,35 @@ struct zip_stat;
                   ((uint64_t)((const uint8_t*)(x))[6] <<  8) | \
                    (uint64_t)((const uint8_t*)(x))[7])
 
+/**
+ * Read a 64 bits little endian unsigned integer out of memory.
+ * @param x a pointer to the input memory
+ * @return the corresponding unsigned integer
+ */
+#define RL64(x)  (((uint64_t)((const uint8_t*)(x))[7] << 56) | \
+                  ((uint64_t)((const uint8_t*)(x))[6] << 48) | \
+                  ((uint64_t)((const uint8_t*)(x))[5] << 40) | \
+                  ((uint64_t)((const uint8_t*)(x))[4] << 32) | \
+                  ((uint64_t)((const uint8_t*)(x))[3] << 24) | \
+                  ((uint64_t)((const uint8_t*)(x))[2] << 16) | \
+                  ((uint64_t)((const uint8_t*)(x))[1] <<  8) | \
+                   (uint64_t)((const uint8_t*)(x))[0])
+
+/**
+ * Read a 64 bits little endian signed integer out of memory.
+ * @param x a pointer to the input memory
+ * @return the corresponding unsigned integer
+ */
+#define RL64S(x)  ((int64_t) \
+                 (((uint64_t)((const uint8_t*)(x))[7] << 56) | \
+                  ((uint64_t)((const uint8_t*)(x))[6] << 48) | \
+                  ((uint64_t)((const uint8_t*)(x))[5] << 40) | \
+                  ((uint64_t)((const uint8_t*)(x))[4] << 32) | \
+                  ((uint64_t)((const uint8_t*)(x))[3] << 24) | \
+                  ((uint64_t)((const uint8_t*)(x))[2] << 16) | \
+                  ((uint64_t)((const uint8_t*)(x))[1] <<  8) | \
+                   (uint64_t)((const uint8_t*)(x))[0]))
+
 /**
  * Read a 32 bits big endian float out of memory.
  * @param x a pointer to the input memory
@@ -646,6 +675,15 @@ SR_PRIV int sr_log(int loglevel, const char *format, ...) G_GNUC_PRINTF(2, 3);
 
 /*--- device.c --------------------------------------------------------------*/
 
+/** Scan options supported by a driver. */
+#define SR_CONF_SCAN_OPTIONS 0x7FFF0000
+
+/** Device options for a particular device. */
+#define SR_CONF_DEVICE_OPTIONS 0x7FFF0001
+
+/** Mask for separating config keys from capabilities. */
+#define SR_CONF_MASK 0x1fffffff
+
 /** Values for the changes argument of sr_dev_driver.config_channel_set. */
 enum {
        /** The enabled state of the channel has been changed. */
@@ -830,7 +868,7 @@ SR_PRIV int sr_resource_open(struct sr_context *ctx,
                G_GNUC_WARN_UNUSED_RESULT;
 SR_PRIV int sr_resource_close(struct sr_context *ctx,
                struct sr_resource *res);
-SR_PRIV ssize_t sr_resource_read(struct sr_context *ctx,
+SR_PRIV gssize sr_resource_read(struct sr_context *ctx,
                const struct sr_resource *res, void *buf, size_t count)
                G_GNUC_WARN_UNUSED_RESULT;
 SR_PRIV void *sr_resource_load(struct sr_context *ctx, int type,