diff options
author | Jim Meyering <meyering@redhat.com> | 2012-01-09 19:42:49 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-01-09 20:39:35 +0100 |
commit | e977fafd31d61a6fca60e20b86f536048fdaa68e (patch) | |
tree | 54e1d835cae45b7aee8db436368e053174493ed9 /include/parted/natmath.in.h | |
parent | ace74051ebdadd2d6d428948af1982543149ae79 (diff) | |
download | parted-e977fafd31d61a6fca60e20b86f536048fdaa68e.tar.gz |
maint: rename public .h files to .in.h
Generate .h files from .in.h files, so that we can continue
to use _GL_ATTRIBUTE_PURE and _GL_ATTRIBUTE_CONST in the primary
sources, without including them in publicly-installed files.
Each generated (and later installed) header file gets expansions
of those macros.
* include/parted/Makefile.am: New rules.
* .gitignore: Ignore the generated files.
* Makefile.am (SUBDIRS): Reorder so we build in include/ before
libparted, i.e., so that we generate the .h files we'll need.
Diffstat (limited to 'include/parted/natmath.in.h')
-rw-r--r-- | include/parted/natmath.in.h | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/include/parted/natmath.in.h b/include/parted/natmath.in.h new file mode 100644 index 0000000..e1d09eb --- /dev/null +++ b/include/parted/natmath.in.h @@ -0,0 +1,112 @@ +/* + libparted - a library for manipulating disk partitions + Copyright (C) 2000, 2007-2012 Free Software Foundation, Inc. + + This program 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 3 of the License, or + (at your option) any later version. + + This program 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 this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +/** + * \addtogroup PedAlignment + * @{ + */ + +/** \file natmath.h */ + +#ifndef PED_NATMATH_H_INCLUDED +#define PED_NATMATH_H_INCLUDED + + +typedef struct _PedAlignment PedAlignment; + +#include <parted/disk.h> +#include <parted/device.h> +#include <parted/geom.h> + +#define PED_MIN(a, b) ( ((a)<(b)) ? (a) : (b) ) +#define PED_MAX(a, b) ( ((a)>(b)) ? (a) : (b) ) + +/* this is weird (I'm still not sure I should be doing this!) + * + * For the functions: new, destroy, duplicate and merge: the following values + * for align are valid: + * * align == NULL (!) represents no solution + * * align->grain_size == 0 represents a single solution + * (align->offset) + * * align->grain_size > 0 represents a set of solutions + * + * These are invalid: + * * align->offset < 0 Note: this gets "normalized" + * * align->grain_size < 0 + * + * For the align_* operations, there must be a solution. i.e. align != NULL + * All solutions must be greater than zero. + */ + +struct _PedAlignment { + PedSector offset; + PedSector grain_size; +}; + +extern PedSector ped_round_up_to (PedSector sector, PedSector grain_size) + _GL_ATTRIBUTE_CONST; +extern PedSector ped_round_down_to (PedSector sector, PedSector grain_size) + _GL_ATTRIBUTE_CONST; +extern PedSector ped_round_to_nearest (PedSector sector, PedSector grain_size) + _GL_ATTRIBUTE_CONST; +extern PedSector ped_greatest_common_divisor (PedSector a, PedSector b) + _GL_ATTRIBUTE_PURE; + +extern int ped_alignment_init (PedAlignment* align, PedSector offset, + PedSector grain_size); +extern PedAlignment* ped_alignment_new (PedSector offset, PedSector grain_size); +extern void ped_alignment_destroy (PedAlignment* align); +extern PedAlignment* ped_alignment_duplicate (const PedAlignment* align); +extern PedAlignment* ped_alignment_intersect (const PedAlignment* a, + const PedAlignment* b); + +extern PedSector +ped_alignment_align_up (const PedAlignment* align, const PedGeometry* geom, + PedSector sector) _GL_ATTRIBUTE_PURE; +extern PedSector +ped_alignment_align_down (const PedAlignment* align, const PedGeometry* geom, + PedSector sector) _GL_ATTRIBUTE_PURE; +extern PedSector +ped_alignment_align_nearest (const PedAlignment* align, const PedGeometry* geom, + PedSector sector) _GL_ATTRIBUTE_PURE; + +extern int +ped_alignment_is_aligned (const PedAlignment* align, const PedGeometry* geom, + PedSector sector) _GL_ATTRIBUTE_PURE; + +extern const PedAlignment* ped_alignment_any; +extern const PedAlignment* ped_alignment_none; + +static inline PedSector +ped_div_round_up (PedSector numerator, PedSector divisor) +{ + return (numerator + divisor - 1) / divisor; +} + + +static inline PedSector +ped_div_round_to_nearest (PedSector numerator, PedSector divisor) +{ + return (numerator + divisor/2) / divisor; +} + +#endif /* PED_NATMATH_H_INCLUDED */ + +/** + * @} + */ |