summaryrefslogtreecommitdiffstats
path: root/otherlibs/unix/lseek.c
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/unix/lseek.c')
-rw-r--r--otherlibs/unix/lseek.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/otherlibs/unix/lseek.c b/otherlibs/unix/lseek.c
new file mode 100644
index 000000000..05d6d2422
--- /dev/null
+++ b/otherlibs/unix/lseek.c
@@ -0,0 +1,24 @@
+#include <mlvalues.h>
+#include "unix.h"
+
+#ifdef HAS_UNISTD
+#include <unistd.h>
+#else
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+static int seek_command_table[] = {
+ SEEK_SET, SEEK_CUR, SEEK_END
+};
+
+value unix_lseek(fd, ofs, cmd) /* ML */
+ value fd, ofs, cmd;
+{
+ long ret;
+ ret = lseek(Int_val(fd), Long_val(ofs),
+ seek_command_table[Tag_val(cmd)]);
+ if (ret == -1) uerror("lseek", Nothing);
+ return Val_long(ret);
+}