1 // log2.h -- Utility functions for power of two values. -*- C++ -*-
3 // Copyright (C) 2001 Red Hat.
4 // This file is part of SID and is licensed under the GPL.
5 // See the file COPYING.SID for conditions for redistribution.
10 // Is V a power of two (ie. 32, 64)?
13 bool power_of_two_p (const V& v1)
18 for (int i = 0; i < 8 * sizeof (V); i++)
22 // Only one bit was set in v1.
29 int log2 (const V& v1)
31 assert (power_of_two_p (v1));
34 for (int i = 0; i < 8 * sizeof (V); i++)