dockapps/wmmon/ulllib.h
Doug Torrance 3ec1a9cde3 wmmon: Fix jiffy counter overflowing long on 32-bit systems.
Based on patch by Pedro Gimeno Fortea for Debian bug #670151 [1].

[1] https://bugs.debian.org/670151
2017-08-12 22:40:32 +01:00

51 lines
1.4 KiB
C

/*
* Unsigned long long arithmetic limited library, tailored for wmmon's
* specific needs.
*
* Copyright (c) 2014 Pedro Gimeno Fortea
*
* This file is part of wmmon.
*
* wmmon is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wmmon is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with wmmon; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __ULLLIB_H_
#define __ULLLIB_H_
#ifdef HAVE_LONG_LONG_INT
typedef unsigned long long ullong;
#define ullreset(x) (*(x) = 0)
#define ulladd(x, y) (*(x) += *(y))
#define ullsub(x, y) ((long)(*(x) - *(y)))
#define ullparse(x, y) (*(x) = atoll(y))
#else /* ! HAVE_LONG_LONG_INT */
typedef struct {
unsigned long H;
unsigned long L;
} ullong;
void ullreset(ullong *);
void ulladd(ullong *, const ullong *);
long ullsub(const ullong *, const ullong *);
void ullparse(ullong *, const char *);
#endif /* HAVE_LONG_LONG_INT */
#endif /* __ULLIB_H_ */