"Fossies" - the Fresh Open Source Software Archive

Member "syslinux-6.03/com32/include/syslinux/align.h" (6 Oct 2014, 1907 Bytes) of package /linux/misc/syslinux-6.03.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /* ----------------------------------------------------------------------- *
    2  *
    3  *   Copyright 2009 Intel Corporation; author H. Peter Anvin
    4  *
    5  *   Permission is hereby granted, free of charge, to any person
    6  *   obtaining a copy of this software and associated documentation
    7  *   files (the "Software"), to deal in the Software without
    8  *   restriction, including without limitation the rights to use,
    9  *   copy, modify, merge, publish, distribute, sublicense, and/or
   10  *   sell copies of the Software, and to permit persons to whom
   11  *   the Software is furnished to do so, subject to the following
   12  *   conditions:
   13  *
   14  *   The above copyright notice and this permission notice shall
   15  *   be included in all copies or substantial portions of the Software.
   16  *
   17  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   18  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
   19  *   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
   20  *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
   21  *   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
   22  *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   23  *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
   24  *   OTHER DEALINGS IN THE SOFTWARE.
   25  *
   26  * ----------------------------------------------------------------------- */
   27 
   28 #ifndef _SYSLINUX_ALIGN_H
   29 #define _SYSLINUX_ALIGN_H
   30 
   31 #include <stdint.h>
   32 
   33 static inline uintptr_t __align_down(uintptr_t __p, uintptr_t __a)
   34 {
   35     return __p & ~(__a - 1);
   36 }
   37 
   38 static inline uintptr_t __align_up(uintptr_t __p, uintptr_t __a)
   39 {
   40     return (__p + __a - 1) & ~(__a - 1);
   41 }
   42 
   43 #define ALIGN_UP(p,a) ((__typeof__(p))__align_up((uintptr_t)(p), (a)))
   44 #define ALIGN_DOWN(p,a) ((__typeof__(p))__align_down((uintptr_t)(p), (a)))
   45 #define ALIGN_UP_FOR(p,t) ALIGN_UP(p,sizeof(t))
   46 #define ALIGN_DOWN_FOR(p,t) ALIGN_DOWN(p,sizeof(t))
   47 
   48 #endif /* _SYSLINUX_ALIGN_H */