blob: 651f7df5f0ae193267539d9d5d933f8b1d8ae157 [file] [log] [blame]
Tanguy Pruvot8aeb3712011-06-30 08:59:26 +02001/* vi: set sw=4 ts=4: */
2/*
3 Copyright 2010, Dylan Simon
4
5 Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
6*/
7
8#ifndef BB_ANDROID_H
9#define BB_ANDROID_H 1
10
11/* for dirname, basename */
12#include <libgen.h>
13
14#if ENABLE_FEATURE_DC_LIBM
15# include <math.h>
16#endif
17
Tanguy Pruvotd5b63cc2013-10-05 12:34:16 +020018/* lutimes doesnt exists in libc */
19#if ENABLE_FEATURE_TOUCH_NODEREF
20# define lutimes utimes
21#endif
22
Tanguy Pruvot8aeb3712011-06-30 08:59:26 +020023#define killpg_busybox(P, S) kill(-(P), S)
24
25#define setmntent fopen
26#define endmntent fclose
27
28/* defined in bionic/utmp.c */
29void endutent(void);
30
31/* defined in bionic/mktemp.c */
32char *mkdtemp(char *);
Tanguy Pruvot9d673762014-08-05 15:13:56 +020033char *bb_mktemp(char *);
Tanguy Pruvot8aeb3712011-06-30 08:59:26 +020034
Tanguy Pruvot301d3112012-07-14 01:49:18 +020035/* SYSCALLS */
Tanguy Pruvotd4d81332014-08-06 15:38:40 +020036int stime(const time_t *);
Tanguy Pruvot6fef6a32012-05-05 15:26:43 +020037int swapon(const char *, int);
38int swapoff(const char *);
39int getsid(pid_t);
Tanguy Pruvot8aeb3712011-06-30 08:59:26 +020040
Tanguy Pruvot301d3112012-07-14 01:49:18 +020041#ifndef SYS_ioprio_set
42#define SYS_ioprio_set __NR_ioprio_set
43#define SYS_ioprio_get __NR_ioprio_get
44#endif
45
Tanguy Pruvote64e94d2014-06-22 23:11:57 +020046/* XXX These need to be obtained from kernel headers. See b/9336527 */
47#define SWAP_FLAG_PREFER 0x8000
48#define SWAP_FLAG_PRIO_MASK 0x7fff
49#define SWAP_FLAG_PRIO_SHIFT 0
50#define SWAP_FLAG_DISCARD 0x10000
51
Tanguy Pruvot8aeb3712011-06-30 08:59:26 +020052/* local definition in libbb/xfuncs_printf.c */
53int fdprintf(int fd, const char *format, ...);
54
Tanguy Pruvot1071f3e2014-07-31 05:51:18 +020055/* local definitions in android/libc/pty.c */
Tanguy Pruvot477b2eb2014-07-31 05:49:11 +020056#include <fcntl.h>
57#ifndef SPLICE_F_GIFT
Tanguy Pruvot1071f3e2014-07-31 05:51:18 +020058/* if this constant is not defined,
Tanguy Pruvot477b2eb2014-07-31 05:49:11 +020059 ttyname is not in bionic */
60char* bb_ttyname(int);
61int bb_ttyname_r(int, char *, size_t);
62#define ttyname(n) bb_ttyname(n)
63#define ttyname_r(n,s,z) bb_ttyname_r(n,s,z)
64#else
65/* should be available in android M ? */
66extern char* ttyname(int);
67extern int ttyname_r(int, char *, size_t);
68#endif
Tanguy Pruvot8aeb3712011-06-30 08:59:26 +020069
Tanguy Pruvot1071f3e2014-07-31 05:51:18 +020070/* local definitions in android/android.c */
Tanguy Pruvot8aeb3712011-06-30 08:59:26 +020071char *getusershell(void);
72void setusershell(void);
73void endusershell(void);
74
75struct mntent;
76struct __sFILE;
77int addmntent(struct __sFILE *, const struct mntent *);
78struct mntent *getmntent_r(struct __sFILE *fp, struct mntent *mnt, char *buf, int buflen);
Tanguy Pruvot477b2eb2014-07-31 05:49:11 +020079char *hasmntopt(const struct mntent *, const char *);
Tanguy Pruvot8aeb3712011-06-30 08:59:26 +020080
81#define MNTOPT_NOAUTO "noauto"
82
83/* bionic's vfork is rather broken; for now a terrible bandaid: */
84#define vfork fork
85
Tanguy Pruvotddffc382014-11-07 12:33:48 +010086#if !defined(BIONIC_L) && !defined(BLOATCHECK)
Tanguy Pruvot8a6c2c22012-04-28 00:24:09 +020087#define _SOCKLEN_T_DECLARED
88typedef int socklen_t;
Tanguy Pruvotddffc382014-11-07 12:33:48 +010089#endif
Tanguy Pruvot8a6c2c22012-04-28 00:24:09 +020090
Tanguy Pruvot6a06a102014-07-03 11:34:01 +020091/* wait3 was removed in android L */
92#ifdef BIONIC_L
93#define wait3(status, options, rusage) wait4(-1, status, options, rusage)
94#endif
95
Tanguy Pruvot8aeb3712011-06-30 08:59:26 +020096#endif