Permalink
Browse files

several fixes from Enrico Scholz (printf, string routines on big end…

…ian)

  add some more syscalls
  some minor cleanups
  shrink some string functions (Kris Katterjohn)
  • Loading branch information...
1 parent 7ee7362 commit 913c90686ad1168844debd4d225947ca4b8746f4 leitner committed Feb 19, 2008
View
@@ -5,6 +5,10 @@
add statvfs, fstatvfs
add some amd64 asm string routines
add some constants for inotify
+ several fixes from Enrico Scholz (printf, string routines on big endian)
+ add some more syscalls
+ some minor cleanups
+ shrink some string functions (Kris Katterjohn)
0.31:
getopt_long and getopt_long_only now refuse ambiguous abbreviations
View
@@ -1,32 +0,0 @@
-#include <string.h>
-
-static const unsigned long long magic = 0x0101010101010101LL;
-
-size_t strlen(const char *s)
-{
- const char *t = s;
- unsigned long long word;
-
- if (!s) return 0;
-
- /* Byte compare up until 64 bit word boundary */
- for (; ((unsigned long long) t & 7); t++)
- if (!*t) return t - s;
-
- /* Word compare */
- do {
- word = *((unsigned long long *) t); t += 8;
- word = (word - magic) &~ word;
- word &= (magic << 7);
- } while (word == 0);
-
- /* word & 0x8080808080808080 == word */
- word = (word - 1) & (magic << 8);
- word += (word << 32);
- word += (word << 16);
- word += (word << 8);
- t += word >> 56;
- return ((const char *) t) - 8 - s;
-}
-
-
View
@@ -380,6 +380,38 @@
#define __NR_inotify_init 444
#define __NR_inotify_add_watch 445
#define __NR_inotify_rm_watch 446
+#define __NR_fdatasync 447
+#define __NR_kexec_load 448
+#define __NR_migrate_pages 449
+#define __NR_openat 450
+#define __NR_mkdirat 451
+#define __NR_mknodat 452
+#define __NR_fchownat 453
+#define __NR_futimesat 454
+#define __NR_fstatat64 455
+#define __NR_unlinkat 456
+#define __NR_renameat 457
+#define __NR_linkat 458
+#define __NR_symlinkat 459
+#define __NR_readlinkat 460
+#define __NR_fchmodat 461
+#define __NR_faccessat 462
+#define __NR_pselect6 463
+#define __NR_ppoll 464
+#define __NR_unshare 465
+#define __NR_set_robust_list 466
+#define __NR_get_robust_list 467
+#define __NR_splice 468
+#define __NR_sync_file_range 469
+#define __NR_tee 470
+#define __NR_vmsplice 471
+#define __NR_move_pages 472
+#define __NR_getcpu 473
+#define __NR_epoll_pwait 474
+#define __NR_utimensat 475
+#define __NR_signalfd 476
+#define __NR_timerfd 477
+#define __NR_eventfd 478
#define syscall_weak(name,wsym,sym) \
View
@@ -293,6 +293,38 @@
#define __NR_mbind (__NR_SYSCALL_BASE+319)
#define __NR_get_mempolicy (__NR_SYSCALL_BASE+320)
#define __NR_set_mempolicy (__NR_SYSCALL_BASE+321)
+#define __NR_openat (__NR_SYSCALL_BASE+322)
+#define __NR_mkdirat (__NR_SYSCALL_BASE+323)
+#define __NR_mknodat (__NR_SYSCALL_BASE+324)
+#define __NR_fchownat (__NR_SYSCALL_BASE+325)
+#define __NR_futimesat (__NR_SYSCALL_BASE+326)
+#define __NR_fstatat64 (__NR_SYSCALL_BASE+327)
+#define __NR_unlinkat (__NR_SYSCALL_BASE+328)
+#define __NR_renameat (__NR_SYSCALL_BASE+329)
+#define __NR_linkat (__NR_SYSCALL_BASE+330)
+#define __NR_symlinkat (__NR_SYSCALL_BASE+331)
+#define __NR_readlinkat (__NR_SYSCALL_BASE+332)
+#define __NR_fchmodat (__NR_SYSCALL_BASE+333)
+#define __NR_faccessat (__NR_SYSCALL_BASE+334)
+ /* 335 for pselect6 */
+ /* 336 for ppoll */
+#define __NR_unshare (__NR_SYSCALL_BASE+337)
+#define __NR_set_robust_list (__NR_SYSCALL_BASE+338)
+#define __NR_get_robust_list (__NR_SYSCALL_BASE+339)
+#define __NR_splice (__NR_SYSCALL_BASE+340)
+#define __NR_arm_sync_file_range (__NR_SYSCALL_BASE+341)
+#define __NR_sync_file_range2 __NR_arm_sync_file_range
+#define __NR_tee (__NR_SYSCALL_BASE+342)
+#define __NR_vmsplice (__NR_SYSCALL_BASE+343)
+#define __NR_move_pages (__NR_SYSCALL_BASE+344)
+#define __NR_getcpu (__NR_SYSCALL_BASE+345)
+ /* 346 for epoll_pwait */
+#define __NR_kexec_load (__NR_SYSCALL_BASE+347)
+#define __NR_utimensat (__NR_SYSCALL_BASE+348)
+#define __NR_signalfd (__NR_SYSCALL_BASE+349)
+#define __NR_timerfd (__NR_SYSCALL_BASE+350)
+#define __NR_eventfd (__NR_SYSCALL_BASE+351)
+#define __NR_fallocate (__NR_SYSCALL_BASE+352)
/*
* The following SWIs are ARM private.
@@ -610,6 +642,39 @@
#define __ARGS_get_mempolicy 1
#define __ARGS_set_mempolicy 1
+#define __ARGS_openat 0
+#define __ARGS_mkdirat 0
+#define __ARGS_mknodat 0
+#define __ARGS_fchownat 1
+#define __ARGS_futimesat 0
+#define __ARGS_fstatat64 0
+#define __ARGS_unlinkat 0
+#define __ARGS_renameat 0
+#define __ARGS_linkat 1
+#define __ARGS_symlinkat 0
+#define __ARGS_readlinkat 0
+#define __ARGS_fchmodat 0
+#define __ARGS_faccessat 0
+ /* 335 for pselect6 */
+ /* 336 for ppoll */
+#define __ARGS_unshare 0
+#define __ARGS_set_robust_list 0
+#define __ARGS_get_robust_list 0
+#define __ARGS_splice 1
+#define __ARGS_arm_sync_file_range 0
+#define __ARGS_sync_file_range2 0
+#define __ARGS_tee 0
+#define __ARGS_vmsplice 0
+#define __ARGS_move_pages 1
+#define __ARGS_getcpu 0
+ /* 346 for epoll_pwait */
+#define __ARGS_kexec_load 0
+#define __ARGS_utimensat 0
+#define __ARGS_signalfd 0
+#define __ARGS_timerfd 0
+#define __ARGS_eventfd 0
+#define __ARGS_fallocate 0
+
#ifdef __ASSEMBLER__
#define syscall_weak(name,wsym,sym) __syscall_weak $__NR_##name, wsym, sym, __ARGS_##name
View
@@ -11,6 +11,16 @@
# define STRALIGN(x) (((unsigned long)x&3)?4-((unsigned long)x&3):0)
#endif
+/* GFC(x) - returns first character */
+/* INCSTR(x) - moves to next character */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# define GFC(x) ((x)&0xff)
+# define INCSTR(x) do { x >>= 8; } while (0)
+#else
+# define GFC(x) (((x)>>(sizeof(x)*8-8))&0xff)
+# define INCSTR(x) do { x <<= 8; } while (0)
+#endif
+
#define UNALIGNED(x,y) (((unsigned long)x & (sizeof (unsigned long)-1)) ^ ((unsigned long)y & (sizeof (unsigned long)-1)))
#endif /* _DIET_STRING_H_ */
View
@@ -318,6 +318,11 @@
#define __NR_move_pages 317
#define __NR_getcpu 318
#define __NR_epoll_pwait 319
+#define __NR_utimensat 320
+#define __NR_signalfd 321
+#define __NR_timerfd 322
+#define __NR_eventfd 323
+#define __NR_fallocate 324
#define syscall_weak(name,wsym,sym) \
View
@@ -1 +0,0 @@
-#include "alpha/strlen.c"
View
@@ -279,7 +279,13 @@
#define __NR_sync_file_range 1300
#define __NR_tee 1301
#define __NR_vmsplice 1302
-
+#define __NR_fallocate 1303
+#define __NR_getcpu 1304
+#define __NR_epoll_pwait 1305
+#define __NR_utimensat 1306
+#define __NR_signalfd 1307
+#define __NR_timerfd 1308
+#define __NR_eventfd 1309
#define syscall(name, sym) \
.text; \
View
@@ -624,9 +624,51 @@ extern int fcntl64 (int __fd, int __cmd, ...) __THROW;
#endif
#if defined(_LINUX_SOURCE) || defined(_GNU_SOURCE)
-ssize_t readahead(int fd, off64_t *offset, size_t count);
+ssize_t readahead(int fd, off64_t *offset, size_t count) __THROW;
#endif
+#ifdef _GNU_SOURCE
+#define SPLICE_F_MOVE (0x01) /* move pages instead of copying */
+#define SPLICE_F_NONBLOCK (0x02) /* don't block on the pipe splicing (but */
+ /* we may still block on the fd we splice */
+ /* from/to, of course */
+#define SPLICE_F_MORE (0x04) /* expect more data */
+#define SPLICE_F_GIFT (0x08) /* pages passed in are a gift */
+
+long tee(int fd_in, int fd_out, size_t len, unsigned int flags) __THROW;
+
+#include <sys/uio.h>
+
+long vmsplice(int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags) __THROW;
+long splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) __THROW;
+
+int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags) __THROW;
+#endif
+
+#ifdef _ATFILE_SOURCE
+#define AT_FDCWD -100 /* Special value used to indicate openat should use the current working directory. */
+#define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */
+#define AT_REMOVEDIR 0x200 /* Remove directory instead of unlinking file. */
+#define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */
+
+int openat(int dirfd, const char *pathname, int flags, ...);
+int faccessat(int dirfd, const char *pathname, int mode, int flags);
+int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags);
+int fchownat(int dirfd, const char *pathname, uid_t owner, gid_t group, int flags);
+int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags);
+int futimesat(int dirfd, const char *pathname, const struct timeval times[2]);
+int linkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags);
+int mkdirat(int dirfd, const char *pathname, mode_t mode);
+int mknodat(int dirfd, const char *pathname, mode_t mode, dev_t dev);
+int readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz);
+int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath);
+int symlinkat(const char *oldpath, int newdirfd, const char *newpath);
+int unlinkat(int dirfd, const char *pathname, int flags);
+int mkfifoat(int dirfd, const char *pathname, mode_t mode);
+int utimensat(int dirfd, const char *pathname, struct timespec* t);
+#endif
+
+
__END_DECLS
#endif
View
@@ -350,6 +350,7 @@ struct ipv6hdr {
/* fnord */
#define IPPORT_RESERVED 1024
+#define INET_ADDRSTRLEN 16
#define INET6_ADDRSTRLEN 46
#undef htonl
View
@@ -1,3 +1,58 @@
/* ah, the sublime brokenness... susv3 defines poll.h, the Linux man
* page defines sys/poll.h; duh! */
-#include <sys/poll.h>
+#ifndef _POLL_H
+#define _POLL_H
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+enum {
+ POLLIN = 0x0001,
+#define POLLIN POLLIN
+ POLLPRI = 0x0002,
+#define POLLPRI POLLPRI
+ POLLOUT = 0x0004,
+#define POLLOUT POLLOUT
+ POLLERR = 0x0008,
+#define POLLERR POLLERR
+ POLLHUP = 0x0010,
+#define POLLHUP POLLHUP
+ POLLNVAL = 0x0020,
+#define POLLNVAL POLLNVAL
+ POLLRDNORM = 0x0040,
+#define POLLRDNORM POLLRDNORM
+ POLLRDBAND = 0x0080,
+#define POLLRDBAND POLLRDBAND
+ POLLWRBAND = 0x0200,
+#define POLLWRBAND POLLWRBAND
+ POLLMSG = 0x0400,
+#define POLLMSG POLLMSG
+/* POLLREMOVE is for /dev/epoll (/dev/misc/eventpoll),
+ * a new event notification mechanism for 2.6 */
+ POLLREMOVE = 0x1000,
+#define POLLREMOVE POLLREMOVE
+};
+
+#if defined(__sparc__) || defined (__mips__)
+#define POLLWRNORM POLLOUT
+#else
+#define POLLWRNORM 0x0100
+#endif
+
+struct pollfd {
+ int fd;
+ short events;
+ short revents;
+};
+
+extern int poll(struct pollfd *ufds, unsigned int nfds, int timeout) __THROW;
+
+#ifdef _GNU_SOURCE
+#include <signal.h>
+int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const sigset_t *sigmask) __THROW;
+#endif
+
+__END_DECLS
+
+#endif /* _POLL_H */
View
@@ -7,24 +7,6 @@
__BEGIN_DECLS
/*
- * cloning flags:
- */
-#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
-#define CLONE_VM 0x00000100 /* set if VM shared between processes */
-#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
-#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
-#define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */
-#define CLONE_PID 0x00001000 /* set if pid shared */
-#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
-#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
-#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
-#define CLONE_THREAD 0x00010000 /* Same thread group? */
-
-#define CLONE_SIGNAL (CLONE_SIGHAND | CLONE_THREAD)
-
-int clone(void*(*fn)(void*),void*stack,int flags,void*arg);
-
-/*
* Scheduling policies
*/
#define SCHED_OTHER 0
@@ -67,6 +49,28 @@ int sched_get_priority_min(int policy);
int __sched_rr_get_interval(pid_t pid, struct timespec* tp);
int sched_rr_get_interval(pid_t pid, struct timespec* tp);
+#ifdef _GNU_SOURCE
+/*
+ * cloning flags:
+ */
+#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
+#define CLONE_VM 0x00000100 /* set if VM shared between processes */
+#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
+#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
+#define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */
+#define CLONE_PID 0x00001000 /* set if pid shared */
+#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
+#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
+#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
+#define CLONE_THREAD 0x00010000 /* Same thread group? */
+
+#define CLONE_SIGNAL (CLONE_SIGHAND | CLONE_THREAD)
+
+int clone(void*(*fn)(void*),void*stack,int flags,void*arg);
+
+int unshare(int flags);
+#endif
+
__END_DECLS
#endif
View
@@ -4,6 +4,7 @@
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/poll.h>
+#include <signal.h>
__BEGIN_DECLS
@@ -65,6 +66,8 @@ int epoll_create(int size) __THROW;
int epoll_ctl(int epfd, int op, int fd, struct epoll_event* event) __THROW;
int epoll_wait(int epfd, struct epoll_event *events, int maxevents,
int timeout) __THROW;
+int epoll_pwait(int epfd, struct epoll_event *events, int maxevents,
+ int timeout, const sigset_t* sigmask) __THROW;
__END_DECLS
Oops, something went wrong.

0 comments on commit 913c906

Please sign in to comment.