X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=include%2Fctf%2Falign.h;fp=include%2Fctf%2Falign.h;h=0000000000000000000000000000000000000000;hp=5adac7f3007306cb4d5774ce7c253f33e679b717;hb=d79865b92da224131f58ab311e75e49043b62c7a;hpb=ceb811dc38fe93065f7c1119b9509f9f29a45d76 diff --git a/include/ctf/align.h b/include/ctf/align.h deleted file mode 100644 index 5adac7f3..00000000 --- a/include/ctf/align.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef _CTF_ALIGN_H -#define _CTF_ALIGN_H - -/* - * align.h - alignment header - * - * Copyright (c) 2010 Mathieu Desnoyers - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1) -#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) -#define PTR_ALIGN(p, a) ((typeof(p)) ALIGN((unsigned long) (p), a)) -#define ALIGN_FLOOR(x, a) __ALIGN_FLOOR_MASK(x, (typeof(x)) (a) - 1) -#define __ALIGN_FLOOR_MASK(x, mask) ((x) & ~(mask)) -#define PTR_ALIGN_FLOOR(p, a) \ - ((typeof(p)) ALIGN_FLOOR((unsigned long) (p), a)) -#define IS_ALIGNED(x, a) (((x) & ((typeof(x)) (a) - 1)) == 0) - -/* - * Align pointer on natural object alignment. - */ -#define object_align(obj) PTR_ALIGN(obj, __alignof__(*(obj))) -#define object_align_floor(obj) PTR_ALIGN_FLOOR(obj, __alignof__(*(obj))) - -/** - * offset_align - Calculate the offset needed to align an object on its natural - * alignment towards higher addresses. - * @align_drift: object offset from an "alignment"-aligned address. - * @alignment: natural object alignment. Must be non-zero, power of 2. - * - * Returns the offset that must be added to align towards higher - * addresses. - */ -#define offset_align(align_drift, alignment) \ - ({ \ - MAYBE_BUILD_BUG_ON((alignment) == 0 \ - || ((alignment) & ((alignment) - 1))); \ - (((alignment) - (align_drift)) & ((alignment) - 1)); \ - }) - -/** - * offset_align_floor - Calculate the offset needed to align an object - * on its natural alignment towards lower addresses. - * @align_drift: object offset from an "alignment"-aligned address. - * @alignment: natural object alignment. Must be non-zero, power of 2. - * - * Returns the offset that must be substracted to align towards lower addresses. - */ -#define offset_align_floor(align_drift, alignment) \ - ({ \ - MAYBE_BUILD_BUG_ON((alignment) == 0 \ - || ((alignment) & ((alignment) - 1))); \ - (((align_drift) - (alignment)) & ((alignment) - 1); \ - }) - -#endif /* _CTF_ALIGN_H */