#include <dirent.h>
#include <errno.h>
+#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
return !memcmp(str + len - slen, suffix, slen);
}
+static inline unsigned long shl_next_pow2(unsigned long num)
+{
+ unsigned int i;
+
+ if (!num)
+ return 0;
+
+ --num;
+ for (i = 1; i < sizeof(unsigned long) * CHAR_BIT; i <<= 1)
+ num = num | num >> i;
+
+ return num + 1;
+}
+
/* This parses \arg and splits the string into a new allocated array. The array
* is stored in \out and is NULL terminated. Empty entries are removed from the
* array if \keep_empty is false. \out_num is the number of entries in the
#include "log.h"
#include "shl_dlist.h"
#include "shl_hashtable.h"
+#include "shl_misc.h"
#include "static_gl.h"
#include "text.h"
#include "uterm_video.h"
}
}
-static unsigned int next_pow2(unsigned int num)
-{
- int i;
-
- if (!num)
- return num;
-
- --num;
- for (i = 1; i < sizeof(unsigned int) * CHAR_BIT; i <<= 1)
- num = num | num >> i;
-
- return num + 1;
-}
-
/* returns an atlas with at least 1 free glyph position; NULL on error */
static struct atlas *get_atlas(struct kmscon_text *txt, unsigned int num)
{
* valid texture size that is big enough to hold as many glyphs as
* possible but at least 1 */
try_next:
- width = next_pow2(FONT_WIDTH(txt) * newsize);
- height = next_pow2(FONT_HEIGHT(txt));
+ width = shl_next_pow2(FONT_WIDTH(txt) * newsize);
+ height = shl_next_pow2(FONT_HEIGHT(txt));
gl_clear_error();