source: release/1.9/source/lisp-kernel/unix-calls.c @ 16083

Last change on this file since 16083 was 14516, checked in by gb, 9 years ago

Build the android kernel using r5 of the ndk, which has a better
idea of what's actually implemented in android 2.2.

sigaltstack() and dladdr() are actually implemented in 2.2.

File size: 2.8 KB
Line 
1/*
2   Copyright (C) 2008-2009, Clozure Associates and contributors
3   This file is part of Clozure CL. 
4
5   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public
6   License , known as the LLGPL and distributed with Clozure CL as the
7   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
8   which is distributed with Clozure CL as the file "LGPL".  Where these
9   conflict, the preamble takes precedence. 
10
11   Clozure CL is referenced in the preamble as the "LIBRARY."
12
13   The LLGPL is also available online at
14   http://opensource.franz.com/preamble.html
15*/
16
17/* Provide wrappers around some standard C library functions that
18   can't easily be called from CCL's FFI for some reason (or where
19   we want to override/extend the function's default behavior.)
20 
21   Functions in this file should be referenced via the kernel
22   imports table.
23
24   Callers should generally expect standard C library error-handling
25   conventions (e.g., return -1 or NULL and set errno on error.)
26*/
27
28#ifndef _LARGEFILE64_SOURCE_
29#define _LARGEFILE64_SOURCE_
30#endif
31#include <errno.h>
32#include <unistd.h>
33#include <sys/stat.h>
34#include <dirent.h>
35#include <sys/syscall.h>
36#include <sys/time.h>
37#include <stdint.h>
38#include <signal.h>
39#include <fcntl.h>
40
41ssize_t
42lisp_read(int fd, void *buf, size_t count)
43{
44  return read(fd,buf,count);
45}
46
47ssize_t
48lisp_write(int fd, void *buf, size_t count)
49{
50  return write(fd,buf,count);
51}
52
53int
54lisp_open(char *path, int flags, mode_t mode)
55{
56  return open(path,flags,mode);
57}
58
59int
60lisp_fchmod(int fd, mode_t mode)
61{
62  return fchmod(fd,mode);
63}
64
65int64_t
66lisp_lseek(int fd, int64_t offset, int whence)
67{
68#ifdef LINUX
69  return lseek64(fd,offset,whence);
70#else
71  return lseek(fd,offset,whence);
72#endif
73}
74
75int
76lisp_close(int fd)
77{
78  return close(fd);
79}
80
81int
82lisp_ftruncate(int fd, off_t length)
83{
84  return ftruncate(fd,length);
85}
86
87int
88lisp_stat(char *path, void *buf)
89{
90  return stat(path,buf);
91}
92
93int
94lisp_fstat(int fd, void *buf)
95{
96  return fstat(fd,buf);
97}
98
99
100int
101lisp_futex(int *uaddr, int op, int val, void *timeout, int *uaddr2, int val3)
102{
103#ifdef LINUX
104  return syscall(SYS_futex,uaddr,op,val,timeout,uaddr2,val3);
105#else
106  errno = ENOSYS;
107  return -1;
108#endif
109}
110
111DIR *
112lisp_opendir(char *path)
113{
114  return opendir(path);
115}
116
117struct dirent *
118lisp_readdir(DIR *dir)
119{
120  return readdir(dir);
121}
122
123int
124lisp_closedir(DIR *dir)
125{
126  return closedir(dir);
127}
128
129int
130lisp_pipe(int pipefd[2])
131{
132  return pipe(pipefd);
133}
134
135int
136lisp_gettimeofday(struct timeval *tp, void *tzp)
137{
138  return gettimeofday(tp, tzp);
139}
140
141int
142lisp_sigexit(int signum)
143{
144  signal(signum, SIG_DFL);
145  return kill(getpid(), signum);
146}
147
148#ifdef ANDROID_NEEDS_SIGALTSTACK
149/* I for one welcome our new Android overlords. */
150#ifndef __NR_sigaltstack
151#define __NR_sigaltstack                (__NR_SYSCALL_BASE+186)
152#endif
153int
154sigaltstack(stack_t *in, stack_t *out)
155{
156  return syscall(__NR_sigaltstack,in,out);
157}
158#endif
Note: See TracBrowser for help on using the repository browser.