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
maxwen27116ba2015-08-14 21:41:28 +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 *);
maxwen27116ba2015-08-14 21:41:28 +020033char *bb_mktemp(char *);
Tanguy Pruvot8aeb3712011-06-30 08:59:26 +020034
Tanguy Pruvot301d3112012-07-14 01:49:18 +020035/* SYSCALLS */
maxwen27116ba2015-08-14 21:41:28 +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
maxwen27116ba2015-08-14 21:41:28 +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
maxwen27116ba2015-08-14 21:41:28 +020055/* local definitions in android/libc/pty.c */
56#include <fcntl.h>
57#ifndef SPLICE_F_GIFT
58/* if this constant is not defined,
59 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
maxwen27116ba2015-08-14 21:41:28 +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);
maxwen27116ba2015-08-14 21:41:28 +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
maxwen27116ba2015-08-14 21:41:28 +020086#if !defined(BIONIC_L) && !defined(BLOATCHECK)
Tanguy Pruvot8a6c2c22012-04-28 00:24:09 +020087#define _SOCKLEN_T_DECLARED
88typedef int socklen_t;
maxwen27116ba2015-08-14 21:41:28 +020089#endif
90
91/* wait3 was removed in android L */
92#ifdef BIONIC_L
93#define wait3(status, options, rusage) wait4(-1, status, options, rusage)
94#endif
Tanguy Pruvot8a6c2c22012-04-28 00:24:09 +020095
Tanguy Pruvot8aeb3712011-06-30 08:59:26 +020096#endif