1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef AlignmentUtils_h__ 8 #define AlignmentUtils_h__ 9 10 #define IS_ALIGNED16(ptr) ((((uintptr_t)ptr + 15) & ~0x0F) == (uintptr_t)ptr) 11 12 #ifdef DEBUG 13 # define ASSERT_ALIGNED16(ptr) \ 14 MOZ_ASSERT(IS_ALIGNED16(ptr), \ 15 #ptr " has to be aligned to a 16 byte boundary"); 16 #else 17 # define ASSERT_ALIGNED16(ptr) 18 #endif 19 20 #ifdef DEBUG 21 # define ASSERT_MULTIPLE16(v) \ 22 MOZ_ASSERT(v % 16 == 0, #v " has to be a a multiple of 16"); 23 #else 24 # define ASSERT_MULTIPLE16(v) 25 #endif 26 27 #define ALIGNED16(ptr) (float*)(((uintptr_t)ptr + 15) & ~0x0F); 28 29 #endif 30