resource: Replace ssize_t with gssize to avoid unistd.h

This commit is contained in:
Daniel Elstner 2016-01-04 18:53:30 +01:00 committed by Uwe Hermann
parent c61e208d26
commit 32ba0d8005
5 changed files with 9 additions and 11 deletions

View File

@ -101,7 +101,7 @@ SR_PRIV int ResourceReader::close_callback(struct sr_resource *res,
return SR_OK;
}
SR_PRIV ssize_t ResourceReader::read_callback(const struct sr_resource *res,
SR_PRIV gssize ResourceReader::read_callback(const struct sr_resource *res,
void *buf, size_t count, void *cb_data) noexcept
{
try {

View File

@ -232,7 +232,7 @@ private:
const char *name, void *cb_data) noexcept;
static SR_PRIV int close_callback(struct sr_resource *res,
void *cb_data) noexcept;
static SR_PRIV ssize_t read_callback(const struct sr_resource *res,
static SR_PRIV gssize read_callback(const struct sr_resource *res,
void *buf, size_t count, void *cb_data) noexcept;
friend class Context;
};

View File

@ -20,8 +20,6 @@
#ifndef LIBSIGROK_PROTO_H
#define LIBSIGROK_PROTO_H
#include <unistd.h>
/**
* @file
*
@ -208,7 +206,7 @@ typedef int (*sr_resource_open_callback)(struct sr_resource *res,
const char *name, void *cb_data);
typedef int (*sr_resource_close_callback)(struct sr_resource *res,
void *cb_data);
typedef ssize_t (*sr_resource_read_callback)(const struct sr_resource *res,
typedef gssize (*sr_resource_read_callback)(const struct sr_resource *res,
void *buf, size_t count, void *cb_data);
SR_API int sr_resource_set_hooks(struct sr_context *ctx,

View File

@ -868,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,

View File

@ -173,7 +173,7 @@ static int resource_close_default(struct sr_resource *res, void *cb_data)
return SR_OK;
}
static ssize_t resource_read_default(const struct sr_resource *res,
static gssize resource_read_default(const struct sr_resource *res,
void *buf, size_t count, void *cb_data)
{
FILE *file;
@ -186,7 +186,7 @@ static ssize_t resource_read_default(const struct sr_resource *res,
sr_err("%s: invalid handle.", __func__);
return SR_ERR_ARG;
}
if (count > SSIZE_MAX) {
if (count > G_MAXSSIZE) {
sr_err("%s: count %zu too large.", __func__, count);
return SR_ERR_ARG;
}
@ -309,10 +309,10 @@ SR_PRIV int sr_resource_close(struct sr_context *ctx, struct sr_resource *res)
*
* @private
*/
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)
{
ssize_t n_read;
gssize n_read;
n_read = (*ctx->resource_read_cb)(res, buf, count,
ctx->resource_cb_data);
@ -342,7 +342,7 @@ SR_PRIV void *sr_resource_load(struct sr_context *ctx,
struct sr_resource res;
void *buf;
size_t res_size;
ssize_t n_read;
gssize n_read;
if (sr_resource_open(ctx, &res, type, name) != SR_OK)
return NULL;