-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modified: desktop.ppm new file: ev.lua new file: ev_utils.lua new file: include/constants-arm.lua new file: include/constants-mips.lua new file: include/constants-ppc.lua new file: include/constants-x64.lua new file: include/constants-x86.lua new file: include/constants.lua new file: include/headers-x64.lua new file: include/headers-x86.lua new file: include/headers.lua new file: include/types.lua new file: input.lua new file: libev.lua new file: luaunit.lua new file: nl.lua new file: strict.lua new file: syscall.lua new file: test_libev.lua new file: test_syscall.lua new file: userland/metadata_fourcc.lua
- Loading branch information
Showing
23 changed files
with
13,510 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
-- generate C test file to check type sizes etc | ||
|
||
local S = require "syscall" | ||
local ffi = require "ffi" | ||
|
||
local s, t = S.s, S.t | ||
|
||
-- TODO fix these, various naming issues | ||
S.ctypes["struct linux_dirent64"] = nil | ||
S.ctypes["struct statfs64"] = nil | ||
S.ctypes["struct flock64"] = nil | ||
S.ctypes["struct stat64"] = nil | ||
S.ctypes["struct fdb_entry"] = nil | ||
S.ctypes["struct seccomp_data"] = nil | ||
S.ctypes["sighandler_t"] = nil | ||
S.ctypes["struct rlimit64"] = nil | ||
S.ctypes["struct mq_attr"] = nil | ||
|
||
-- fixes for constants | ||
S.__WALL = S.WALL; S.WALL = nil | ||
S.__WCLONE = S.WCLONE; S.WCLONE = nil | ||
|
||
-- remove seccomp for now as no support on the ARM box | ||
for k, _ in pairs(S) do | ||
if k:sub(1, 8) == 'SECCOMP_' then S[k] = nil end | ||
end | ||
|
||
-- fake constants | ||
S.MS_RO = nil | ||
S.MS_RW = nil | ||
S.IFF_ALL = nil | ||
S.IFF_NONE = nil | ||
|
||
-- TODO find the headers/flags for these if exist, or remove | ||
S.SA_RESTORER = nil | ||
S.AF_DECNET = nil | ||
S.SIG_HOLD = nil | ||
S.NOTHREAD = nil | ||
S.RTF_PREFIX_RT = nil | ||
S.RTF_EXPIRES = nil | ||
S.RTF_ROUTEINFO = nil | ||
S.RTF_ANYCAST = nil | ||
|
||
-- include kitchen sink, garbage can etc | ||
print [[ | ||
#include "assert.h" | ||
#define _GNU_SOURCE | ||
#define __USE_GNU | ||
#define _FILE_OFFSET_BITS 64 | ||
#define _LARGE_FILES 1 | ||
#define __USE_FILE_OFFSET64 | ||
#include <stdlib.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <fcntl.h> | ||
#include <sys/socket.h> | ||
#include <netinet/in.h> | ||
#include <arpa/inet.h> | ||
#include <sys/epoll.h> | ||
#include <signal.h> | ||
#include <sys/utsname.h> | ||
#include <time.h> | ||
#include <linux/aio_abi.h> | ||
#include <sys/resource.h> | ||
#include <sys/sysinfo.h> | ||
#include <sys/time.h> | ||
#include <sys/un.h> | ||
#include <netinet/ip.h> | ||
#include <poll.h> | ||
#include <sys/signalfd.h> | ||
#include <linux/rtnetlink.h> | ||
#include <sys/vfs.h> | ||
#include <sys/timex.h> | ||
#include <linux/posix_types.h> | ||
#include <linux/if.h> | ||
#include <linux/if_bridge.h> | ||
#include <sys/mman.h> | ||
#include <sched.h> | ||
#include <sys/xattr.h> | ||
#include <linux/if_arp.h> | ||
#include <sys/capability.h> | ||
#include <linux/sched.h> | ||
#include <termios.h> | ||
#include <unistd.h> | ||
#include <sys/prctl.h> | ||
#include <sys/mount.h> | ||
#include <sys/uio.h> | ||
#include <net/route.h> | ||
#include <sys/inotify.h> | ||
#include <sys/wait.h> | ||
#include <linux/mman.h> | ||
#include <linux/veth.h> | ||
#include <linux/sockios.h> | ||
#include <dirent.h> | ||
#include <linux/reboot.h> | ||
#include <sys/timerfd.h> | ||
#include <linux/falloc.h> | ||
#include <sys/eventfd.h> | ||
int main(int argc, char **argv) { | ||
]] | ||
|
||
-- iterate over S.ctypes | ||
for k, v in pairs(S.ctypes) do | ||
print("assert(sizeof(" .. k .. ") == " .. ffi.sizeof(v) .. ");") | ||
end | ||
|
||
-- test all the constants | ||
|
||
for k, v in pairs(S) do | ||
if type(S[k]) == "number" then | ||
print("assert(" .. k .. " == " .. v .. ");") | ||
end | ||
end | ||
|
||
-- TODO test error codes | ||
|
||
print [[ | ||
} | ||
]] | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,256 @@ | ||
-- LuaJIT binding to libev (http://libev.schmorp.de/) | ||
-- | ||
-- uses almost-identical API to lua-ev (https://github.com/brimworks/lua-ev) | ||
-- | ||
-- Author: Evan Wies <evan@neomantra.net> | ||
-- | ||
|
||
local ffi = require('ffi') | ||
|
||
local bit = require("bit") | ||
local band, bor = bit.band, bit.bor | ||
|
||
|
||
|
||
-- extracted from preprocessing <ev.h> | ||
ffi.cdef[[ | ||
|
||
/* eventmask, revents, events... */ | ||
enum { | ||
EV_UNDEF = 0xFFFFFFFF, /* guaranteed to be invalid */ | ||
EV_NONE = 0x00, /* no events */ | ||
EV_READ = 0x01, /* ev_io detected read will not block */ | ||
EV_WRITE = 0x02, /* ev_io detected write will not block */ | ||
EV__IOFDSET = 0x80, /* internal use only */ | ||
EV_IO = EV_READ, /* alias for type-detection */ | ||
EV_TIMER = 0x00000100, /* timer timed out */ | ||
EV_PERIODIC = 0x00000200, /* periodic timer timed out */ | ||
EV_SIGNAL = 0x00000400, /* signal was received */ | ||
EV_CHILD = 0x00000800, /* child/pid had status change */ | ||
EV_STAT = 0x00001000, /* stat data changed */ | ||
EV_IDLE = 0x00002000, /* event loop is idling */ | ||
EV_PREPARE = 0x00004000, /* event loop about to poll */ | ||
EV_CHECK = 0x00008000, /* event loop finished poll */ | ||
EV_EMBED = 0x00010000, /* embedded event loop needs sweep */ | ||
EV_FORK = 0x00020000, /* event loop resumed in child */ | ||
EV_CLEANUP = 0x00040000, /* event loop resumed in child */ | ||
EV_ASYNC = 0x00080000, /* async intra-loop signal */ | ||
EV_CUSTOM = 0x01000000, /* for use by user code */ | ||
EV_ERROR = 0x80000000 /* sent when an error occurs */ | ||
}; | ||
|
||
/* flag bits for ev_default_loop and ev_loop_new */ | ||
enum { | ||
/* the default */ | ||
EVFLAG_AUTO = 0x00000000U, /* not quite a mask */ | ||
/* flag bits */ | ||
EVFLAG_NOENV = 0x01000000U, /* do NOT consult environment */ | ||
EVFLAG_FORKCHECK = 0x02000000U, /* check for a fork in each iteration */ | ||
/* debugging/feature disable */ | ||
EVFLAG_NOINOTIFY = 0x00100000U, /* do not attempt to use inotify */ | ||
EVFLAG_SIGNALFD = 0x00200000U, /* attempt to use signalfd */ | ||
EVFLAG_NOSIGMASK = 0x00400000U /* avoid modifying the signal mask */ | ||
}; | ||
|
||
/* method bits to be ored together */ | ||
enum { | ||
EVBACKEND_SELECT = 0x00000001U, /* about anywhere */ | ||
EVBACKEND_POLL = 0x00000002U, /* !win */ | ||
EVBACKEND_EPOLL = 0x00000004U, /* linux */ | ||
EVBACKEND_KQUEUE = 0x00000008U, /* bsd */ | ||
EVBACKEND_DEVPOLL = 0x00000010U, /* solaris 8 */ /* NYI */ | ||
EVBACKEND_PORT = 0x00000020U, /* solaris 10 */ | ||
EVBACKEND_ALL = 0x0000003FU, /* all known backends */ | ||
EVBACKEND_MASK = 0x0000FFFFU /* all future backends */ | ||
}; | ||
|
||
typedef double ev_tstamp; | ||
|
||
ev_tstamp ev_time (void); | ||
void ev_sleep (ev_tstamp delay); /* sleep for a while */ | ||
|
||
/* ev_run flags values */ | ||
enum { | ||
EVRUN_NOWAIT = 1, /* do not block/wait */ | ||
EVRUN_ONCE = 2 /* block *once* only */ | ||
}; | ||
|
||
/* ev_break how values */ | ||
enum { | ||
EVBREAK_CANCEL = 0, /* undo unloop */ | ||
EVBREAK_ONE = 1, /* unloop once */ | ||
EVBREAK_ALL = 2 /* unloop all loops */ | ||
}; | ||
|
||
typedef struct ev_loop ev_loop; | ||
|
||
typedef struct ev_watcher | ||
{ | ||
int active; | ||
int pending; | ||
int priority; | ||
void *data; | ||
void (*cb)(struct ev_loop *loop, struct ev_watcher *w, int revents); | ||
} ev_watcher; | ||
|
||
typedef struct ev_watcher_list | ||
{ | ||
int active; | ||
int pending; | ||
int priority; | ||
void *data; | ||
void (*cb)(struct ev_loop *loop, struct ev_watcher_list *w, int revents); | ||
struct ev_watcher_list *next; | ||
} ev_watcher_list; | ||
|
||
typedef struct ev_watcher_time | ||
{ | ||
int active; | ||
int pending; | ||
int priority; | ||
void *data; | ||
void (*cb)(struct ev_loop *loop, struct ev_watcher_time *w, int revents); | ||
ev_tstamp at; | ||
} ev_watcher_time; | ||
|
||
typedef struct ev_io | ||
{ | ||
int active; | ||
int pending; | ||
int priority; | ||
void *data; | ||
void (*cb)(struct ev_loop *loop, struct ev_io *w, int revents); | ||
struct ev_watcher_list *next; | ||
int fd; | ||
int events; | ||
} ev_io; | ||
|
||
typedef struct ev_timer | ||
{ | ||
int active; | ||
int pending; | ||
int priority; | ||
void *data; | ||
void (*cb)(struct ev_loop *loop, struct ev_timer *w, int revents); | ||
ev_tstamp at; | ||
ev_tstamp repeat_; | ||
} ev_timer; | ||
|
||
typedef struct ev_periodic | ||
{ | ||
int active; | ||
int pending; | ||
int priority; | ||
void *data; | ||
void (*cb)(struct ev_loop *loop, struct ev_periodic *w, int revents); | ||
ev_tstamp at; | ||
ev_tstamp offset; | ||
ev_tstamp interval; | ||
ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now); | ||
} ev_periodic; | ||
|
||
typedef struct ev_signal | ||
{ | ||
int active; | ||
int pending; | ||
int priority; | ||
void *data; | ||
void (*cb)(struct ev_loop *loop, struct ev_signal *w, int revents); | ||
struct ev_watcher_list *next; | ||
int signum; | ||
} ev_signal; | ||
|
||
typedef struct ev_child | ||
{ | ||
int active; | ||
int pending; | ||
int priority; | ||
void *data; | ||
void (*cb)(struct ev_loop *loop, struct ev_child *w, int revents); | ||
struct ev_watcher_list *next; | ||
int flags; | ||
int pid; | ||
int rpid; | ||
int rstatus; | ||
} ev_child; | ||
|
||
typedef struct ev_idle | ||
{ | ||
int active; | ||
int pending; | ||
int priority; | ||
void *data; | ||
void (*cb)(struct ev_loop *loop, struct ev_idle *w, int revents); | ||
} ev_idle; | ||
|
||
typedef struct ev_prepare | ||
{ | ||
int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_prepare *w, int revents); | ||
} ev_prepare; | ||
|
||
typedef struct ev_check | ||
{ | ||
int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_check *w, int revents); | ||
} ev_check; | ||
|
||
typedef struct ev_fork | ||
{ | ||
int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_fork *w, int revents); | ||
} ev_fork; | ||
|
||
typedef struct ev_cleanup | ||
{ | ||
int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_cleanup *w, int revents); | ||
} ev_cleanup; | ||
|
||
typedef struct ev_embed | ||
{ | ||
int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_embed *w, int revents); | ||
struct ev_loop *other; | ||
ev_io io; | ||
ev_prepare prepare; | ||
ev_check check; | ||
ev_timer timer; | ||
ev_periodic periodic; | ||
ev_idle idle; | ||
ev_fork fork; | ||
ev_cleanup cleanup; | ||
} ev_embed; | ||
|
||
typedef int sig_atomic_t; | ||
typedef struct ev_async | ||
{ | ||
int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_async *w, int revents); | ||
sig_atomic_t volatile sent; | ||
} ev_async; | ||
|
||
void ev_signal_start (struct ev_loop *loop, ev_signal *w); | ||
void ev_signal_stop (struct ev_loop *loop, ev_signal *w); | ||
|
||
struct ev_loop *ev_default_loop (unsigned int flags ); | ||
struct ev_loop *ev_loop_new (unsigned int flags ); | ||
ev_tstamp ev_now (struct ev_loop *loop); | ||
void ev_loop_destroy (struct ev_loop *loop); | ||
unsigned int ev_iteration (struct ev_loop *loop); | ||
unsigned int ev_depth (struct ev_loop *loop); | ||
|
||
void ev_io_start (struct ev_loop *loop, ev_io *w); | ||
void ev_io_stop (struct ev_loop *loop, ev_io *w); | ||
|
||
void ev_run (struct ev_loop *loop, int flags ); | ||
void ev_break (struct ev_loop *loop, int how ); | ||
void ev_suspend (struct ev_loop *loop); | ||
void ev_resume (struct ev_loop *loop); | ||
int ev_clear_pending (struct ev_loop *loop, void *w); | ||
|
||
void ev_timer_start (struct ev_loop *loop, ev_timer *w); | ||
void ev_timer_stop (struct ev_loop *loop, ev_timer *w); | ||
void ev_timer_again (struct ev_loop *loop, ev_timer *w); | ||
ev_tstamp ev_timer_remaining (struct ev_loop *loop, ev_timer *w); | ||
|
||
void ev_idle_start (struct ev_loop *loop, ev_idle *w); | ||
void ev_idle_stop (struct ev_loop *loop, ev_idle *w); | ||
|
||
]] | ||
|
||
|
Oops, something went wrong.