Cross Reference: natmath.h
xref
: /
osnet-11
/
usr
/
src
/
lib
/
libparted
/
common
/
include
/
parted
/
natmath.h
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
1
N/A
/*
1
N/A
libparted - a library for manipulating disk partitions
1
N/A
Copyright (C) 2000, 2007-2010 Free Software Foundation, Inc.
1
N/A
1
N/A
This program is free software; you can redistribute it
and
/
or
modify
1
N/A
it under the terms of the GNU General Public License as published by
1
N/A
the Free Software Foundation; either version 3 of the License, or
1
N/A
(at your option) any later version.
1
N/A
1
N/A
This program is distributed in the hope that it will be useful,
1
N/A
but WITHOUT ANY WARRANTY; without even the implied warranty of
1
N/A
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1
N/A
GNU General Public License for more details.
1
N/A
1
N/A
You should have received a copy of the GNU General Public License
1
N/A
along with this program. If not, see <
http://www.gnu.org/licenses/
>.
1
N/A
*/
1
N/A
1
N/A
/**
1
N/A
* \addtogroup PedAlignment
1
N/A
* @{
1
N/A
*/
1
N/A
1
N/A
/** \file
natmath.h
*/
1
N/A
1
N/A
#
ifndef
PED_NATMATH_H_INCLUDED
1
N/A
#
define
PED_NATMATH_H_INCLUDED
1
N/A
1
N/A
1
N/A
typedef
struct
_PedAlignment
PedAlignment
;
1
N/A
1
N/A
#
include
<
parted
/
disk.h
>
1
N/A
#
include
<
parted
/
device.h
>
1
N/A
#
include
<
parted
/
geom.h
>
1
N/A
1
N/A
#
define
PED_MIN
(a, b) ( ((a)<(b)) ? (a) : (b) )
1
N/A
#
define
PED_MAX
(a, b) ( ((a)>(b)) ? (a) : (b) )
1
N/A
1
N/A
/* this is weird (I'm still not sure I should be doing this!)
1
N/A
*
1
N/A
* For the functions: new, destroy, duplicate and merge: the following values
1
N/A
* for align are valid:
1
N/A
* * align == NULL (!) represents no solution
1
N/A
* * align->grain_size == 0 represents a single solution
1
N/A
* (align->offset)
1
N/A
* * align->grain_size > 0 represents a set of solutions
1
N/A
*
1
N/A
* These are invalid:
1
N/A
* * align->offset < 0 Note: this gets "normalized"
1
N/A
* * align->grain_size < 0
1
N/A
*
1
N/A
* For the align_* operations, there must be a solution. i.e. align != NULL
1
N/A
* All solutions must be greater than zero.
1
N/A
*/
1
N/A
1
N/A
struct
_PedAlignment
{
1
N/A
PedSector
offset
;
1
N/A
PedSector
grain_size
;
1
N/A
};
1
N/A
1
N/A
extern
PedSector
ped_round_up_to
(
PedSector
sector
,
PedSector
grain_size
);
1
N/A
extern
PedSector
ped_round_down_to
(
PedSector
sector
,
PedSector
grain_size
);
1
N/A
extern
PedSector
ped_round_to_nearest
(
PedSector
sector
,
PedSector
grain_size
);
1
N/A
extern
PedSector
ped_greatest_common_divisor
(
PedSector
a,
PedSector
b);
1
N/A
1
N/A
extern
int
ped_alignment_init
(
PedAlignment
*
align
,
PedSector
offset
,
1
N/A
PedSector
grain_size
);
1
N/A
extern
PedAlignment
*
ped_alignment_new
(
PedSector
offset
,
PedSector
grain_size
);
1
N/A
extern
void
ped_alignment_destroy
(
PedAlignment
*
align
);
1
N/A
extern
PedAlignment
*
ped_alignment_duplicate
(
const
PedAlignment
*
align
);
1
N/A
extern
PedAlignment
*
ped_alignment_intersect
(
const
PedAlignment
* a,
1
N/A
const
PedAlignment
* b);
1
N/A
1
N/A
extern
PedSector
1
N/A
ped_alignment_align_up
(
const
PedAlignment
*
align
,
const
PedGeometry
*
geom
,
1
N/A
PedSector
sector
);
1
N/A
extern
PedSector
1
N/A
ped_alignment_align_down
(
const
PedAlignment
*
align
,
const
PedGeometry
*
geom
,
1
N/A
PedSector
sector
);
1
N/A
extern
PedSector
1
N/A
ped_alignment_align_nearest
(
const
PedAlignment
*
align
,
const
PedGeometry
*
geom
,
1
N/A
PedSector
sector
);
1
N/A
1
N/A
extern
int
1
N/A
ped_alignment_is_aligned
(
const
PedAlignment
*
align
,
const
PedGeometry
*
geom
,
1
N/A
PedSector
sector
);
1
N/A
1
N/A
extern
const
PedAlignment
*
ped_alignment_any
;
1
N/A
extern
const
PedAlignment
*
ped_alignment_none
;
1
N/A
1
N/A
static
inline
PedSector
1
N/A
ped_div_round_up
(
PedSector
numerator
,
PedSector
divisor
)
1
N/A
{
1
N/A
return
(
numerator
+
divisor
-
1
) /
divisor
;
1
N/A
}
1
N/A
1
N/A
1
N/A
static
inline
PedSector
1
N/A
ped_div_round_to_nearest
(
PedSector
numerator
,
PedSector
divisor
)
1
N/A
{
1
N/A
return
(
numerator
+
divisor
/
2
) /
divisor
;
1
N/A
}
1
N/A
1
N/A
#
endif
/* PED_NATMATH_H_INCLUDED */
1
N/A
1
N/A
/**
1
N/A
* @}
1
N/A
*/