diff options
Diffstat (limited to 'system')
-rw-r--r-- | system/include/emscripten/emscripten.h (renamed from system/include/emscripten.h) | 41 | ||||
-rw-r--r-- | system/include/libc/sys/_default_fcntl.h | 5 | ||||
-rw-r--r-- | system/include/libc/sys/dirent.h | 4 | ||||
-rw-r--r-- | system/include/sys/statvfs.h | 2 |
4 files changed, 50 insertions, 2 deletions
diff --git a/system/include/emscripten.h b/system/include/emscripten/emscripten.h index 4da31ec3..9bc6c410 100644 --- a/system/include/emscripten.h +++ b/system/include/emscripten/emscripten.h @@ -12,6 +12,16 @@ extern "C" { #endif /* + * Forces LLVM to not dead-code-eliminate a function. Note that + * closure may still eliminate it at the JS level, for which you + * should use EXPORTED_FUNCTIONS (see settings.js). + * + * Example usage: + * void EMSCRIPTEN_KEEPALIVE my_function() { .. } + */ +#define EMSCRIPTEN_KEEPALIVE __attribute__((used)) + +/* * Interface to the underlying JS engine. This function will * eval() the given script. */ @@ -39,6 +49,18 @@ extern void emscripten_resume_main_loop(); extern void emscripten_cancel_main_loop(); /* + * Add a function to a queue of events that will execute + * before the main loop will continue. + */ +#if EMSCRIPTEN +extern void emscripten_push_main_loop_blocker(void (*func)()); +#else +inline void emscripten_push_main_loop_blocker(void (*func)()) { + func(); +} +#endif + +/* * Call a C function asynchronously, that is, after returning * control to the JS event loop. This is done by a setTimeout. * When building natively this becomes a simple direct call, @@ -50,7 +72,7 @@ extern void emscripten_cancel_main_loop(); #if EMSCRIPTEN extern void emscripten_async_call(void (*func)(), int millis); #else -void emscripten_async_call(void (*func)(), int millis) { +inline void emscripten_async_call(void (*func)(), int millis) { SDL_Delay(millis); func(); } @@ -80,6 +102,11 @@ void emscripten_set_canvas_size(int width, int height); float emscripten_get_now(); /* + * Simple random number generation in [0, 1), maps to Math.random(). + */ +float emscripten_random(); + +/* * This macro-looking function will cause Emscripten to * generate a comment in the generated code. * XXX This is deprecated for now, because it requires us to @@ -88,6 +115,18 @@ float emscripten_get_now(); //extern void EMSCRIPTEN_COMMENT(const char *text); /* + * Emscripten file system api + */ + +/* + * Load file from url in asynchronous way. + * When file is loaded then 'onload' callback will called. + * If any error occurred 'onerror' will called. + * The callbacks are called with the file as their argument. + */ +void emscripten_async_wget(const char* url, const char* file, void (*onload)(const char*), void (*onerror)(const char*)); + +/* * Profiling tools. * INIT must be called first, with the maximum identifier that * will be used. BEGIN will add some code that marks diff --git a/system/include/libc/sys/_default_fcntl.h b/system/include/libc/sys/_default_fcntl.h index 0f2ffb07..188e25c4 100644 --- a/system/include/libc/sys/_default_fcntl.h +++ b/system/include/libc/sys/_default_fcntl.h @@ -209,6 +209,11 @@ extern int _open64 _PARAMS ((const char *, int, ...)); #define POSIX_FADV_DONTNEED 135 int posix_fadvise(int fd, off_t offset, off_t len, int advice); int posix_fallocate(int fd, off_t offset, off_t len); +#define LOCK_SH 1 +#define LOCK_EX 2 +#define LOCK_UN 4 +#define LOCK_NB 8 +int flock(int fd, int operation); #ifdef __cplusplus } diff --git a/system/include/libc/sys/dirent.h b/system/include/libc/sys/dirent.h index 1fbe2b21..9dcf34d1 100644 --- a/system/include/libc/sys/dirent.h +++ b/system/include/libc/sys/dirent.h @@ -26,6 +26,10 @@ long telldir(DIR *); DIR *readdir(DIR *); int closedir(DIR *dirp); void rewinddir(DIR *dirp); +int scandir(const char *dirp, + struct dirent ***namelist, + int (*filter)(const struct dirent *), + int (*compar)(const struct dirent **, const struct dirent **)); enum { DT_UNKNOWN = 0, diff --git a/system/include/sys/statvfs.h b/system/include/sys/statvfs.h index cf0a8c96..192be153 100644 --- a/system/include/sys/statvfs.h +++ b/system/include/sys/statvfs.h @@ -20,7 +20,7 @@ struct statvfs { int f_namemax; }; -int statvfs(char *path, struct statvfs *s); +int statvfs(const char *path, struct statvfs *s); #ifdef __cplusplus } |