You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

linux_api.h 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (C) 2010 Piotr Jaroszyński <p.jaroszynski@gmail.com>
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #ifndef _LINUX_API_H
  19. #define _LINUX_API_H
  20. /** * @file
  21. *
  22. * Linux API prototypes.
  23. * Most of the functions map directly to linux syscalls and are the equivalent
  24. * of POSIX functions with the linux_ prefix removed.
  25. */
  26. FILE_LICENCE(GPL2_OR_LATER);
  27. #include <bits/linux_api.h>
  28. #include <bits/linux_api_platform.h>
  29. #include <stdint.h>
  30. #define __KERNEL_STRICT_NAMES
  31. #include <linux/types.h>
  32. #include <linux/posix_types.h>
  33. typedef __kernel_pid_t pid_t;
  34. typedef __kernel_suseconds_t suseconds_t;
  35. typedef __kernel_loff_t loff_t;
  36. #include <linux/time.h>
  37. #include <linux/mman.h>
  38. #include <linux/fcntl.h>
  39. #include <linux/ioctl.h>
  40. #include <linux/poll.h>
  41. typedef unsigned long nfds_t;
  42. typedef uint32_t useconds_t;
  43. typedef uint32_t socklen_t;
  44. struct sockaddr;
  45. #define MAP_FAILED ( ( void * ) -1 )
  46. #define SEEK_SET 0
  47. extern long linux_syscall ( int number, ... );
  48. extern int linux_open ( const char *pathname, int flags );
  49. extern int linux_close ( int fd );
  50. extern off_t linux_lseek ( int fd, off_t offset, int whence );
  51. extern __kernel_ssize_t linux_read ( int fd, void *buf, __kernel_size_t count );
  52. extern __kernel_ssize_t linux_write ( int fd, const void *buf,
  53. __kernel_size_t count );
  54. extern int linux_fcntl ( int fd, int cmd, ... );
  55. extern int linux_ioctl ( int fd, int request, ... );
  56. extern int linux_poll ( struct pollfd *fds, nfds_t nfds, int timeout );
  57. extern int linux_nanosleep ( const struct timespec *req, struct timespec *rem );
  58. extern int linux_usleep ( useconds_t usec );
  59. extern int linux_gettimeofday ( struct timeval *tv, struct timezone *tz );
  60. extern void * linux_mmap ( void *addr, __kernel_size_t length, int prot,
  61. int flags, int fd, off_t offset );
  62. extern void * linux_mremap ( void *old_address, __kernel_size_t old_size,
  63. __kernel_size_t new_size, int flags );
  64. extern int linux_munmap ( void *addr, __kernel_size_t length );
  65. extern int linux_socket ( int domain, int type_, int protocol );
  66. extern int linux_bind ( int fd, const struct sockaddr *addr,
  67. socklen_t addrlen );
  68. extern ssize_t linux_sendto ( int fd, const void *buf, size_t len, int flags,
  69. const struct sockaddr *daddr, socklen_t addrlen );
  70. extern const char * linux_strerror ( int errnum );
  71. #endif /* _LINUX_API_H */