aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2017-05-21 13:11:42 -0500
committerRob Landley <rob@landley.net>2017-05-21 13:11:42 -0500
commitf86f2f4e9a20d235b24ea86e4dddd0485165306f (patch)
tree83e2341019727a29ef59210926e6c83e15ccd146 /lib
parent83b3531ec2876fa76817501bf1a38d4438ac39e6 (diff)
downloadtoybox-f86f2f4e9a20d235b24ea86e4dddd0485165306f.tar.gz
Cleaup chrt
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.c10
-rw-r--r--lib/lib.h1
-rw-r--r--lib/portability.h10
3 files changed, 18 insertions, 3 deletions
diff --git a/lib/lib.c b/lib/lib.c
index ceced263..b6277f3b 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -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)
{
diff --git a/lib/lib.h b/lib/lib.h
index efdc1fa4..5d2bb4df 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -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.