set GLIBTOP_MAX_FSUSAGE properly, use gint in the headers instead of int

2004-03-15  Bastien Nocera  <hadess@hadess.net>

	* include/glibtop/fsusage.h: set GLIBTOP_MAX_FSUSAGE properly,
	use gint in the headers instead of int (Closes: #125049)


2004-03-15  Bastien Nocera  <hadess@hadess.net>

	* fsusage.c:
	* fsusage.h: remove use of uintmax_t
This commit is contained in:
Bastien Nocera
2004-03-16 10:10:41 +00:00
committed by Bastien Nocera
parent 1cffda35ec
commit 2b221cbb1f
5 changed files with 26 additions and 25 deletions

View File

@@ -1,3 +1,8 @@
2004-03-15 Bastien Nocera <hadess@hadess.net>
* include/glibtop/fsusage.h: set GLIBTOP_MAX_FSUSAGE properly,
use gint in the headers instead of int (Closes: #125049)
2004-03-11 Kjartan Maraas <kmaraas@gnome.org>
* configure.in: Up versions etc.

View File

@@ -35,7 +35,7 @@ G_BEGIN_DECLS
#define GLIBTOP_FSUSAGE_FFREE 4
#define GLIBTOP_FSUSAGE_BLOCK_SIZE 6
#define GLIBTOP_MAX_FSUSAGE 5
#define GLIBTOP_MAX_FSUSAGE 6
typedef struct _glibtop_fsusage glibtop_fsusage;
@@ -48,7 +48,7 @@ struct _glibtop_fsusage
bavail, /* Free blocks available to non-superuser. */
files, /* Total file nodes. */
ffree; /* Free file nodes. */
int block_size; /* Size of a block in bytes. */
gint block_size; /* Size of a block in bytes. */
};
#define glibtop_get_fsusage(fsusage,disk) glibtop_get_fsusage_l(glibtop_global_server, fsusage, disk)

View File

@@ -1,3 +1,8 @@
2004-03-15 Bastien Nocera <hadess@hadess.net>
* fsusage.c:
* fsusage.h: remove use of uintmax_t
2004-03-09 Bastien Nocera <hadess@hadess.net>
* fsusage.c: fix build (we don't have "full-read.h" here)

View File

@@ -20,17 +20,6 @@
# include <config.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#else
# if HAVE_STDINT_H
# include <stdint.h>
# endif
#endif
#ifndef UINTMAX_MAX
# define UINTMAX_MAX ((uintmax_t) -1)
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include "fsusage.h"
@@ -81,23 +70,23 @@ int statvfs ();
/* Many space usage primitives use all 1 bits to denote a value that is
not applicable or unknown. Propagate this information by returning
a uintmax_t value that is all 1 bits if X is all 1 bits, even if X
is unsigned and narrower than uintmax_t. */
a guint64 value that is all 1 bits if X is all 1 bits, even if X
is unsigned and narrower than guint64. */
#define PROPAGATE_ALL_ONES(x) \
((sizeof (x) < sizeof (uintmax_t) \
((sizeof (x) < sizeof (guint64) \
&& (~ (x) == (sizeof (x) < sizeof (int) \
? - (1 << (sizeof (x) * CHAR_BIT)) \
: 0))) \
? UINTMAX_MAX : (x))
? G_MAXUINT64 : (x))
/* Extract the top bit of X as an uintmax_t value. */
/* Extract the top bit of X as an guint64 value. */
#define EXTRACT_TOP_BIT(x) ((x) \
& ((uintmax_t) 1 << (sizeof (x) * CHAR_BIT - 1)))
& ((guint64) 1 << (sizeof (x) * CHAR_BIT - 1)))
/* If a value is negative, many space usage primitives store it into an
integer variable by assignment, even if the variable's type is unsigned.
So, if a space usage variable X's top bit is set, convert X to the
uintmax_t value V such that (- (uintmax_t) V) is the negative of
guint64 value V such that (- (guint64) V) is the negative of
the original value. If X's top bit is clear, just yield X.
Use PROPAGATE_TOP_BIT if the original value might be negative;
otherwise, use PROPAGATE_ALL_ONES. */

View File

@@ -17,18 +17,20 @@
/* Space usage statistics for a filesystem. Blocks are 512-byte. */
#include <glib.h>
#if !defined FSUSAGE_H_
# define FSUSAGE_H_
struct fs_usage
{
int fsu_blocksize; /* Size of a block. */
uintmax_t fsu_blocks; /* Total blocks. */
uintmax_t fsu_bfree; /* Free blocks available to superuser. */
uintmax_t fsu_bavail; /* Free blocks available to non-superuser. */
guint64 fsu_blocks; /* Total blocks. */
guint64 fsu_bfree; /* Free blocks available to superuser. */
guint64 fsu_bavail; /* Free blocks available to non-superuser. */
int fsu_bavail_top_bit_set; /* 1 if fsu_bavail represents a value < 0. */
uintmax_t fsu_files; /* Total file nodes. */
uintmax_t fsu_ffree; /* Free file nodes. */
guint64 fsu_files; /* Total file nodes. */
guint64 fsu_ffree; /* Free file nodes. */
};
# ifndef PARAMS