diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lib.c | 10 | ||||
-rw-r--r-- | lib/lib.h | 1 | ||||
-rw-r--r-- | lib/portability.h | 10 |
3 files changed, 18 insertions, 3 deletions
@@ -512,6 +512,16 @@ void msleep(long miliseconds) nanosleep(&ts, &ts); } +// return 1<<x of highest bit set +int highest_bit(unsigned long l) +{ + int i; + + for (i = 0; l; i++) l >>= 1; + + return i-1; +} + // Inefficient, but deals with unaligned access int64_t peek_le(void *ptr, unsigned size) { @@ -192,6 +192,7 @@ struct string_list **splitpath(char *path, struct string_list **list); char *readfileat(int dirfd, char *name, char *buf, off_t *len); char *readfile(char *name, char *buf, off_t len); void msleep(long miliseconds); +int highest_bit(unsigned long l); int64_t peek_le(void *ptr, unsigned size); int64_t peek_be(void *ptr, unsigned size); int64_t peek(void *ptr, unsigned size); diff --git a/lib/portability.h b/lib/portability.h index 01c77c67..e62de139 100644 --- a/lib/portability.h +++ b/lib/portability.h @@ -45,9 +45,13 @@ #define RLIMIT_RTTIME 15 #endif +// Introduced in Linux 3.1 #ifndef SEEK_DATA #define SEEK_DATA 3 #endif +#ifndef SEEK_HOLE +#define SEEK_HOLE 4 +#endif // We don't define GNU_dammit because we're not part of the gnu project, and // don't want to get any FSF on us. Unfortunately glibc (gnu libc) @@ -199,18 +203,18 @@ static inline void endutxent(void) {;} #ifndef O_NOFOLLOW #define O_NOFOLLOW 0 #endif - #ifndef O_NOATIME #define O_NOATIME 01000000 #endif - #ifndef O_CLOEXEC #define O_CLOEXEC 02000000 #endif - #ifndef O_PATH #define O_PATH 010000000 #endif +#ifndef SCHED_RESET_ON_FORK +#define SCHED_RESET_ON_FORK (1<<30) +#endif // Glibc won't give you linux-kernel constants unless you say "no, a BUD lite" // even though linux has nothing to do with the FSF and never has. |