1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * |
5 | * |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
7 | * the terms of the Affero GNU General Public License as published by the |
7 | * the terms of the Affero GNU General Public License as published by the |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
9 | * option) any later version. |
9 | * option) any later version. |
… | |
… | |
240 | absdir (int d) |
240 | absdir (int d) |
241 | { |
241 | { |
242 | return ((d - 1) & 7) + 1; |
242 | return ((d - 1) & 7) + 1; |
243 | } |
243 | } |
244 | |
244 | |
|
|
245 | // avoid ctz name because netbsd or freebsd spams it's namespace with it |
|
|
246 | #if GCC_VERSION(3,4) |
|
|
247 | static inline int least_significant_bit (uint32_t x) |
|
|
248 | { |
|
|
249 | return __builtin_ctz (x); |
|
|
250 | } |
|
|
251 | #else |
|
|
252 | int least_significant_bit (uint32_t x); |
|
|
253 | #endif |
|
|
254 | |
|
|
255 | #define for_all_bits_sparse_32(mask, idxvar) \ |
|
|
256 | for (uint32_t idxvar, mask_ = mask; \ |
|
|
257 | mask_ && ((idxvar = least_significant_bit (mask_)), mask_ &= ~(1 << idxvar), 1);) |
|
|
258 | |
245 | extern ssize_t slice_alloc; // statistics |
259 | extern ssize_t slice_alloc; // statistics |
246 | |
260 | |
247 | void *salloc_ (int n) throw (std::bad_alloc); |
261 | void *salloc_ (int n) throw (std::bad_alloc); |
248 | void *salloc_ (int n, void *src) throw (std::bad_alloc); |
262 | void *salloc_ (int n, void *src) throw (std::bad_alloc); |
249 | |
263 | |