Merge "ndk: remove undefined symbols from system headers" into gingerbread

This commit is contained in:
David 'Digit' Turner
2010-10-11 06:02:15 -07:00
committed by Android (Google) Code Review
33 changed files with 3849 additions and 68 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -39,6 +39,10 @@ __BEGIN_DECLS
#define O_ASYNC FASYNC
#endif
#ifndef O_CLOEXEC
#define O_CLOEXEC 02000000
#endif
extern int open(const char* path, int mode, ...);
extern int openat(int fd, const char* path, int mode, ...);
extern int unlinkat(int dirfd, const char *pathname, int flags);

View File

@@ -71,14 +71,19 @@ int getopt_long_only(int, char * const *, const char *,
#ifndef _GETOPT_DEFINED_
#define _GETOPT_DEFINED_
int getopt(int, char * const *, const char *);
int getsubopt(char **, char * const *, char **);
extern char *optarg; /* getopt(3) external variables */
extern int opterr;
extern int optind;
extern int optopt;
extern int optreset;
#if 0 /* MISSING FROM BIONIC */
int getsubopt(char **, char * const *, char **);
extern char *suboptarg; /* getsubopt(3) external variable */
#endif /* MISSING */
#endif
__END_DECLS

View File

@@ -56,6 +56,8 @@ struct group {
__BEGIN_DECLS
struct group *getgrgid(gid_t);
#if 0 /* MISSING FROM BIONIC */
struct group *getgrnam(const char *);
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XPG_VISIBLE
struct group *getgrent(void);
@@ -71,6 +73,7 @@ void setgrfile(const char *);
int setgroupent(int);
char *group_from_gid(gid_t, int);
#endif
#endif /* MISSING */
int getgrouplist (const char *user, gid_t group,
gid_t *groups, int *ngroups);

View File

@@ -86,7 +86,7 @@
#include <sys/limits.h>
#if __POSIX_VISIBLE
#include <arch/syslimits.h>
#include <sys/syslimits.h>
#endif
#ifndef PAGESIZE

View File

@@ -53,7 +53,9 @@ extern char *setlocale(int category, const char *locale);
/* Make libstdc++-v3 happy. */
struct lconv { };
#if 0 /* MISSING FROM BIONIC */
struct lconv *localeconv(void);
#endif /* MISSING */
__END_DECLS

View File

@@ -203,51 +203,54 @@ __BEGIN_DECLS
#define h_errno (*__get_h_errno())
int* __get_h_errno(void);
/* BIONIC-END */
void endhostent(void);
void endnetent(void);
void endnetgrent(void);
void endprotoent(void);
void endservent(void);
void freehostent(struct hostent *);
struct hostent *gethostbyaddr(const char *, int, int);
int gethostbyaddr_r(const char *, int, int, struct hostent *, char *, size_t, struct hostent **, int *);
struct hostent *gethostbyname(const char *);
int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
struct hostent *gethostbyname2(const char *, int);
int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *);
struct hostent *gethostent(void);
int gethostent_r(struct hostent *, char *, size_t, struct hostent **, int *);
struct hostent *getipnodebyaddr(const void *, size_t, int, int *);
struct hostent *getipnodebyname(const char *, int, int, int *);
struct netent *getnetbyaddr(uint32_t, int);
int getnetbyaddr_r(uint32_t, int, struct netent *, char *, size_t, struct netent**, int *);
struct netent *getnetbyname(const char *);
int getnetbyname_r(const char *, struct netent *, char *, size_t, struct netent **, int *);
struct netent *getnetent(void);
int getnetent_r(struct netent *, char *, size_t, struct netent **, int *);
int getnetgrent(char **, char **, char **);
struct protoent *getprotobyname(const char *);
int getprotobyname_r(const char *, struct protoent *, char *, size_t, struct protoent **);
struct protoent *getprotobynumber(int);
int getprotobynumber_r(int, struct protoent *, char *, size_t, struct protoent **);
struct protoent *getprotoent(void);
int getprotoent_r(struct protoent *, char *, size_t, struct protoent **);
struct servent *getservbyname(const char *, const char *);
struct servent *getservbyport(int, const char *);
struct servent *getservent(void);
void herror(const char *);
const char *hstrerror(int);
int innetgr(const char *, const char *, const char *, const char *);
void sethostent(int);
void setnetent(int);
void setprotoent(int);
int getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **);
int getnameinfo(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int);
void freeaddrinfo(struct addrinfo *);
const char *gai_strerror(int);
void setnetgrent(const char *);
void setservent(int);
#if 0 /* MISSING FROM BIONIC */
void endhostent(void);
void endnetent(void);
void endnetgrent(void);
void endprotoent(void);
void freehostent(struct hostent *);
int gethostbyaddr_r(const char *, int, int, struct hostent *, char *, size_t, struct hostent **, int *);
int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *);
int gethostent_r(struct hostent *, char *, size_t, struct hostent **, int *);
struct hostent *getipnodebyaddr(const void *, size_t, int, int *);
struct hostent *getipnodebyname(const char *, int, int, int *);
int getnetbyaddr_r(uint32_t, int, struct netent *, char *, size_t, struct netent**, int *);
int getnetbyname_r(const char *, struct netent *, char *, size_t, struct netent **, int *);
int getnetent_r(struct netent *, char *, size_t, struct netent **, int *);
int getnetgrent(char **, char **, char **);
int getprotobyname_r(const char *, struct protoent *, char *, size_t, struct protoent **);
int getprotobynumber_r(int, struct protoent *, char *, size_t, struct protoent **);
struct protoent *getprotoent(void);
int getprotoent_r(struct protoent *, char *, size_t, struct protoent **);
int innetgr(const char *, const char *, const char *, const char *);
void sethostent(int);
void setnetent(int);
void setprotoent(int);
struct netent *getnetent(void);
void setnetgrent(const char *);
#endif /* MISSING */
__END_DECLS
#endif /* !_NETDB_H_ */

View File

@@ -153,6 +153,7 @@ typedef struct {
* Default sourcelists (if nsswitch.conf is missing, corrupt,
* or the requested database doesn't have an entry)
*/
#if 0 /* MISSING FROM BIONIC */
extern const ns_src __nsdefaultsrc[];
extern const ns_src __nsdefaultcompat[];
extern const ns_src __nsdefaultcompat_forceall[];
@@ -160,7 +161,7 @@ extern const ns_src __nsdefaultfiles[];
extern const ns_src __nsdefaultfiles_forceall[];
extern const ns_src __nsdefaultnis[];
extern const ns_src __nsdefaultnis_forceall[];
#endif /* MISSING */
/*
* ns_mtab - `nsswitch method table'

View File

@@ -28,6 +28,10 @@
#ifndef _PATHCONF_H_
#define _PATHCONF_H_
#include <sys/cdefs.h>
__BEGIN_DECLS
/* constants to be used for the 'name' paremeter of pathconf/fpathconf */
#define _PC_FILESIZEBITS 0x0000
@@ -54,5 +58,7 @@
extern long fpathconf(int fildes, int name);
extern long pathconf(const char *path, int name);
__END_DECLS
#endif /* _PATHCONF_H_ */

View File

@@ -113,12 +113,14 @@ __BEGIN_DECLS
struct passwd* getpwnam(const char*);
struct passwd* getpwuid(uid_t);
void endpwent(void);
#if 0 /* MISSING FROM BIONIC */
int getpwnam_r(const char*, struct passwd*, char*, size_t, struct passwd**);
int getpwuid_r(uid_t, struct passwd*, char*, size_t, struct passwd**);
void endpwent(void);
struct passwd* getpwent(void);
int setpwent(void);
#endif /* MISSING */
__END_DECLS

View File

@@ -41,8 +41,10 @@
#include <sys/cdefs.h>
__BEGIN_DECLS
#if 0 /* MISSING FROM BIONIC */
int gtty(int, struct sgttyb *);
int stty(int, struct sgttyb *);
#endif /* MISSING */
__END_DECLS
#endif /* _SGTTY_H_ */

View File

@@ -300,12 +300,14 @@ __END_DECLS
#define L_cuserid 9 /* size for cuserid(); UT_NAMESIZE + 1 */
__BEGIN_DECLS
#if 0 /* MISSING FROM BIONIC */
char *ctermid(char *);
char *cuserid(char *);
#endif /* MISSING */
FILE *fdopen(int, const char *);
int fileno(FILE *);
#if (__POSIX_VISIBLE >= 199209) || 1 /* ANDROID: Bionic does include this */
#if (__POSIX_VISIBLE >= 199209)
int pclose(FILE *);
FILE *popen(const char *, const char *);
#endif

View File

@@ -50,13 +50,11 @@ __BEGIN_DECLS
extern __noreturn void exit(int);
extern __noreturn void abort(void);
extern int atexit(void (*)(void));
extern int on_exit(void (*)(int, void *), void *);
extern char *getenv(const char *);
extern int putenv(const char *);
extern int setenv(const char *, const char *, int);
extern int unsetenv(const char *);
extern int clearenv(void);
extern char *mktemp (char *);
extern int mkstemp (char *);
@@ -107,6 +105,8 @@ extern long mrand48(void);
extern long nrand48(unsigned short *);
extern long lrand48(void);
extern unsigned short *seed48(unsigned short*);
extern double erand48(unsigned short xsubi[3]);
extern double drand48(void);
extern void srand48(long);
extern unsigned int arc4random(void);
extern void arc4random_stir(void);
@@ -162,6 +162,7 @@ typedef struct {
extern lldiv_t lldiv(long long, long long);
#if 1 /* MISSING FROM BIONIC - ENABLED FOR STLPort and libstdc++-v3 */
/* make STLPort happy */
extern int mblen(const char *, size_t);
extern size_t mbstowcs(wchar_t *, const char *, size_t);
@@ -170,8 +171,15 @@ extern int mbtowc(wchar_t *, const char *, size_t);
/* Likewise, make libstdc++-v3 happy. */
extern int wctomb(char *, wchar_t);
extern size_t wcstombs(char *, const wchar_t *, size_t);
#endif /* MISSING */
#define MB_CUR_MAX 1
#if 0 /* MISSING FROM BIONIC */
extern int on_exit(void (*)(int, void *), void *);
extern int clearenv(void);
#endif /* MISSING */
__END_DECLS
#endif /* _STDLIB_H_ */

View File

@@ -43,14 +43,16 @@
#include <sys/cdefs.h>
__BEGIN_DECLS
int bcmp(const void *, const void *, size_t);
void bcopy(const void *, void *, size_t);
void bzero(void *, size_t);
int ffs(int);
char *index(const char *, int);
char *rindex(const char *, int);
int strcasecmp(const char *, const char *);
int strncasecmp(const char *, const char *, size_t);
#if 0 /* MISSING FROM BIONIC */
int bcmp(const void *, const void *, size_t);
char *rindex(const char *, int);
#endif /* MISSING */
__END_DECLS
#endif /* !defined(_STRINGS_H_) */

View File

@@ -62,11 +62,6 @@
#define __GNUC_PREREQ__(x, y) 0
#endif
//XXX #include <machine/cdefs.h>
/* BIONIC: simpler definition */
#define __BSD_VISIBLE 1
#include <sys/cdefs_elf.h>
#if defined(__cplusplus)
@@ -371,6 +366,142 @@
#define __link_set_entry(set, idx) (__link_set_begin(set)[idx])
/*
* Some of the recend FreeBSD sources used in Bionic need this.
* Originally, this is used to embed the rcs versions of each source file
* in the generated binary. We certainly don't want this in Bionic.
*/
#define __FBSDID(s) struct __hack
/*-
* The following definitions are an extension of the behavior originally
* implemented in <sys/_posix.h>, but with a different level of granularity.
* POSIX.1 requires that the macros we test be defined before any standard
* header file is included.
*
* Here's a quick run-down of the versions:
* defined(_POSIX_SOURCE) 1003.1-1988
* _POSIX_C_SOURCE == 1 1003.1-1990
* _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
* _POSIX_C_SOURCE == 199309 1003.1b-1993
* _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
* and the omnibus ISO/IEC 9945-1: 1996
* _POSIX_C_SOURCE == 200112 1003.1-2001
* _POSIX_C_SOURCE == 200809 1003.1-2008
*
* In addition, the X/Open Portability Guide, which is now the Single UNIX
* Specification, defines a feature-test macro which indicates the version of
* that specification, and which subsumes _POSIX_C_SOURCE.
*
* Our macros begin with two underscores to avoid namespace screwage.
*/
/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
#define _POSIX_C_SOURCE 199009
#endif
/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199209
#endif
/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
#ifdef _XOPEN_SOURCE
#if _XOPEN_SOURCE - 0 >= 700
#define __XSI_VISIBLE 700
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809
#elif _XOPEN_SOURCE - 0 >= 600
#define __XSI_VISIBLE 600
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112
#elif _XOPEN_SOURCE - 0 >= 500
#define __XSI_VISIBLE 500
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199506
#endif
#endif
/*
* Deal with all versions of POSIX. The ordering relative to the tests above is
* important.
*/
#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 198808
#endif
#ifdef _POSIX_C_SOURCE
#if _POSIX_C_SOURCE >= 200809
#define __POSIX_VISIBLE 200809
#define __ISO_C_VISIBLE 1999
#elif _POSIX_C_SOURCE >= 200112
#define __POSIX_VISIBLE 200112
#define __ISO_C_VISIBLE 1999
#elif _POSIX_C_SOURCE >= 199506
#define __POSIX_VISIBLE 199506
#define __ISO_C_VISIBLE 1990
#elif _POSIX_C_SOURCE >= 199309
#define __POSIX_VISIBLE 199309
#define __ISO_C_VISIBLE 1990
#elif _POSIX_C_SOURCE >= 199209
#define __POSIX_VISIBLE 199209
#define __ISO_C_VISIBLE 1990
#elif _POSIX_C_SOURCE >= 199009
#define __POSIX_VISIBLE 199009
#define __ISO_C_VISIBLE 1990
#else
#define __POSIX_VISIBLE 198808
#define __ISO_C_VISIBLE 0
#endif /* _POSIX_C_SOURCE */
#else
/*-
* Deal with _ANSI_SOURCE:
* If it is defined, and no other compilation environment is explicitly
* requested, then define our internal feature-test macros to zero. This
* makes no difference to the preprocessor (undefined symbols in preprocessing
* expressions are defined to have value zero), but makes it more convenient for
* a test program to print out the values.
*
* If a program mistakenly defines _ANSI_SOURCE and some other macro such as
* _POSIX_C_SOURCE, we will assume that it wants the broader compilation
* environment (and in fact we will never get here).
*/
#if defined(_ANSI_SOURCE) /* Hide almost everything. */
#define __POSIX_VISIBLE 0
#define __XSI_VISIBLE 0
#define __BSD_VISIBLE 0
#define __ISO_C_VISIBLE 1990
#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
#define __POSIX_VISIBLE 0
#define __XSI_VISIBLE 0
#define __BSD_VISIBLE 0
#define __ISO_C_VISIBLE 1999
#else /* Default environment: show everything. */
#define __POSIX_VISIBLE 200809
#define __XSI_VISIBLE 700
#define __BSD_VISIBLE 1
#define __ISO_C_VISIBLE 1999
#endif
#endif
/*
* Default values.
*/
#ifndef __XPG_VISIBLE
# define __XPG_VISIBLE 700
#endif
#ifndef __POSIX_VISIBLE
# define __POSIX_VISIBLE 200809
#endif
#ifndef __ISO_C_VISIBLE
# define __ISO_C_VISIBLE 1999
#endif
#ifndef __BSD_VISIBLE
# define __BSD_VISIBLE 1
#endif
#define __BIONIC__ 1
#endif /* !_SYS_CDEFS_H_ */

View File

@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#include <sys/types.h>
// ANDROID: needed for flock()
/* ANDROID: needed for flock() */
#include <unistd.h>
#include <fcntl.h>

View File

@@ -33,8 +33,10 @@
__BEGIN_DECLS
#if 0 /* MISSING FROM BIONIC */
extern int setfsuid(uid_t);
extern int setfsgid(gid_t);
#endif /* MISSING */
__END_DECLS

View File

@@ -39,8 +39,8 @@
#ifndef _SYS_IOCTL_COMPAT_H_
#define _SYS_IOCTL_COMPAT_H_
//#include <sys/ttychars.h>
//#include <sys/ttydev.h>
/*#include <sys/ttychars.h>*/
/*#include <sys/ttydev.h>*/
struct tchars {
char t_intrc; /* interrupt */

View File

@@ -92,7 +92,10 @@ extern int mount(const char *, const char *,
const void *);
extern int umount(const char *);
extern int umount2(const char *, int);
#if 0 /* MISSING FROM BIONIC */
extern int pivot_root(const char *, const char *);
#endif /* MISSING */
__END_DECLS

View File

@@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#include <sys/types.h>
// For all of the defines
/* For all of the defines */
#include <linux/ptrace.h>
__BEGIN_DECLS

View File

@@ -33,7 +33,9 @@
__BEGIN_DECLS
#if 0 /* MISSING FROM BIONIC */
extern int sysinfo (struct sysinfo *info);
#endif /* MISSING */
__END_DECLS

View File

@@ -62,8 +62,10 @@ typedef __kernel_ino_t ino_t;
typedef __kernel_key_t key_t;
typedef __kernel_mode_t mode_t;
typedef __kernel_nlink_t nlink_t;
#ifndef _OFF_T_DEFINED_
#define _OFF_T_DEFINED_
typedef __kernel_off_t off_t;
#endif
typedef __kernel_loff_t loff_t;
typedef loff_t off64_t; /* GLibc-specific */

View File

@@ -86,8 +86,10 @@ extern void tzset(void);
/* global includes */
extern char* tzname[];
#if 0 /* MISSING FROM BIONIC */
extern int daylight;
extern long int timezone;
#endif /* MISSING */
#define CLOCKS_PER_SEC 1000000

View File

@@ -61,16 +61,13 @@ extern pid_t getppid(void);
extern pid_t getpgrp(void);
extern int setpgrp(void);
extern pid_t setsid(void);
extern pid_t getsid(pid_t);
extern int execv(const char *, char * const *);
extern int execvp(const char *, char * const *);
extern int execve(const char *, char * const *, char * const *);
extern int execvpe(const char *, char * const *, char * const *);
extern int execl(const char *, const char *, ...);
extern int execlp(const char *, const char *, ...);
extern int execle(const char *, const char *, ...);
extern int execlpe(const char *, const char *, ...);
extern int capget(cap_user_header_t hdrp, cap_user_data_t datap);
extern int capset(cap_user_header_t hdrp, const cap_user_data_t datap);
extern int prctl(int option, unsigned long arg2, unsigned long arg3,
@@ -94,11 +91,8 @@ extern int setresuid(uid_t, uid_t, uid_t);
extern int setresgid(gid_t, gid_t, gid_t);
extern int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);
extern int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid);
extern int getfsuid(uid_t);
extern int setfsuid(uid_t);
extern int issetugid(void);
extern char* getlogin(void);
extern int getlogin_r(char* name, size_t namesize);
/* Macros for access() */
@@ -140,7 +134,6 @@ extern int fcntl(int, int, ...);
extern int ioctl(int, int, ...);
extern int flock(int, int);
extern int fsync(int);
extern int fdatasync(int);
extern int ftruncate(int, off_t);
extern int pause(void);
@@ -149,9 +142,6 @@ extern unsigned int sleep(unsigned int);
extern void usleep(unsigned long);
extern int gethostname(char *, size_t);
extern int sethostname(const char *, size_t);
extern int getdomainname(char *, size_t);
extern int setdomainname(const char *, size_t);
extern int getdtablesize(void);
@@ -164,6 +154,7 @@ extern char *optarg;
extern int optind, opterr, optopt;
extern int isatty(int);
extern char* ttyname(int);
extern int acct(const char* filepath);
@@ -186,6 +177,31 @@ extern int cacheflush(long start, long end, long flags);
extern pid_t tcgetpgrp(int fd);
extern int tcsetpgrp(int fd, pid_t _pid);
#if 0 /* MISSING FROM BIONIC */
extern pid_t getsid(pid_t);
extern int execvpe(const char *, char * const *, char * const *);
extern int execlpe(const char *, const char *, ...);
extern int getfsuid(uid_t);
extern int setfsuid(uid_t);
extern int fdatasync(int);
extern int getlogin_r(char* name, size_t namesize);
extern char* getusershell(void);
extern void setusershell(void);
extern void endusershell(void);
extern int sethostname(const char *, size_t);
extern int getdomainname(char *, size_t);
extern int setdomainname(const char *, size_t);
extern int ttyname_r(int, char*, size_t);
#endif /* MISSING */
/* Used to retry syscalls that can return EINTR. */
#define TEMP_FAILURE_RETRY(exp) ({ \
typeof (exp) _rc; \
do { \
_rc = (exp); \
} while (_rc == -1 && errno == EINTR); \
_rc; })
__END_DECLS
#endif /* _UNISTD_H_ */

View File

@@ -87,4 +87,4 @@ struct utmp* getutent();
__END_DECLS
#endif // _UTMP_H_
#endif /* _UTMP_H_ */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -69,7 +69,9 @@ extern int sched_rr_get_interval(pid_t pid, struct timespec *tp);
#define CLONE_CHILD_SETTID 0x01000000
#define CLONE_STOPPED 0x02000000
#ifdef _GNU_SOURCE
extern int clone(int (*fn)(void*), void *child_stack, int flags, void *arg);
#endif
__END_DECLS

View File

@@ -120,6 +120,7 @@ extern int siginterrupt(int sig, int flag);
extern int raise(int);
extern int kill(pid_t, int);
extern int killpg(int pgrp, int sig);
extern int sigaltstack(const stack_t *ss, stack_t *oss);
__END_DECLS

View File

@@ -300,8 +300,10 @@ __END_DECLS
#define L_cuserid 9 /* size for cuserid(); UT_NAMESIZE + 1 */
__BEGIN_DECLS
#if 0 /* MISSING FROM BIONIC */
char *ctermid(char *);
char *cuserid(char *);
#endif /* MISSING */
FILE *fdopen(int, const char *);
int fileno(FILE *);

View File

@@ -0,0 +1,185 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _STDLIB_H_
#define _STDLIB_H_
#include <sys/cdefs.h>
/* wchar_t is required in stdlib.h according to POSIX.
* note that defining __need_wchar_t prevents stddef.h
* to define all other symbols it does normally */
#define __need_wchar_t
#include <stddef.h>
#include <stddef.h>
#include <string.h>
#include <alloca.h>
#include <strings.h>
#include <memory.h>
__BEGIN_DECLS
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
extern __noreturn void exit(int);
extern __noreturn void abort(void);
extern int atexit(void (*)(void));
extern char *getenv(const char *);
extern int putenv(const char *);
extern int setenv(const char *, const char *, int);
extern int unsetenv(const char *);
extern int clearenv(void);
extern char *mktemp (char *);
extern int mkstemp (char *);
extern long strtol(const char *, char **, int);
extern long long strtoll(const char *, char **, int);
extern unsigned long strtoul(const char *, char **, int);
extern unsigned long long strtoull(const char *, char **, int);
extern double strtod(const char *nptr, char **endptr);
static __inline__ float strtof(const char *nptr, char **endptr)
{
return (float)strtod(nptr, endptr);
}
extern int atoi(const char *);
extern long atol(const char *);
extern long long atoll(const char *);
static __inline__ double atof(const char *nptr)
{
return (strtod(nptr, NULL));
}
static __inline__ int abs(int __n) {
return (__n < 0) ? -__n : __n;
}
static __inline__ long labs(long __n) {
return (__n < 0L) ? -__n : __n;
}
static __inline__ long long llabs(long long __n) {
return (__n < 0LL) ? -__n : __n;
}
extern char * realpath(const char *path, char *resolved);
extern int system(const char * string);
extern void * bsearch(const void *key, const void *base0,
size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
extern long jrand48(unsigned short *);
extern long mrand48(void);
extern long nrand48(unsigned short *);
extern long lrand48(void);
extern unsigned short *seed48(unsigned short*);
extern double erand48(unsigned short xsubi[3]);
extern double drand48(void);
extern void srand48(long);
extern unsigned int arc4random(void);
extern void arc4random_stir(void);
extern void arc4random_addrandom(unsigned char *, int);
#define RAND_MAX 0x7fffffff
static __inline__ int rand(void) {
return (int)lrand48();
}
static __inline__ void srand(unsigned int __s) {
srand48(__s);
}
static __inline__ long random(void)
{
return lrand48();
}
static __inline__ void srandom(unsigned int __s)
{
srand48(__s);
}
/* Basic PTY functions. These only work if devpts is mounted! */
extern int unlockpt(int);
extern char* ptsname(int);
extern char* ptsname_r(int, char*, size_t);
extern int getpt(void);
static __inline__ int grantpt(int __fd)
{
(void)__fd;
return 0; /* devpts does this all for us! */
}
typedef struct {
int quot;
int rem;
} div_t;
extern div_t div(int, int);
typedef struct {
long int quot;
long int rem;
} ldiv_t;
extern ldiv_t ldiv(long, long);
typedef struct {
long long int quot;
long long int rem;
} lldiv_t;
extern lldiv_t lldiv(long long, long long);
#if 1 /* MISSING FROM BIONIC - ENABLED FOR STLPort and libstdc++-v3 */
/* make STLPort happy */
extern int mblen(const char *, size_t);
extern size_t mbstowcs(wchar_t *, const char *, size_t);
extern int mbtowc(wchar_t *, const char *, size_t);
/* Likewise, make libstdc++-v3 happy. */
extern int wctomb(char *, wchar_t);
extern size_t wcstombs(char *, const wchar_t *, size_t);
#endif /* MISSING */
#define MB_CUR_MAX 1
#if 0 /* MISSING FROM BIONIC */
extern int on_exit(void (*)(int, void *), void *);
#endif /* MISSING */
__END_DECLS
#endif /* _STDLIB_H_ */

View File

@@ -0,0 +1,115 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _TIME_H_
#define _TIME_H_
#include <sys/cdefs.h>
#include <sys/time.h>
#define __ARCH_SI_UID_T __kernel_uid32_t
#include <asm/siginfo.h>
#undef __ARCH_SI_UID_T
__BEGIN_DECLS
extern time_t time(time_t *);
extern int nanosleep(const struct timespec *, struct timespec *);
extern char *strtotimeval(const char *str, struct timeval *tv);
struct tm {
int tm_sec; /* seconds */
int tm_min; /* minutes */
int tm_hour; /* hours */
int tm_mday; /* day of the month */
int tm_mon; /* month */
int tm_year; /* year */
int tm_wday; /* day of the week */
int tm_yday; /* day in the year */
int tm_isdst; /* daylight saving time */
long int tm_gmtoff; /* Seconds east of UTC. */
const char *tm_zone; /* Timezone abbreviation. */
};
/* defining TM_ZONE indicates that we have a "timezone abbreviation" field in
* struct tm, the value should be the field name
*/
#define TM_ZONE tm_zone
extern char* asctime(const struct tm* a);
extern char* asctime_r(const struct tm* a, char* buf);
/* Return the difference between TIME1 and TIME0. */
extern double difftime (time_t __time1, time_t __time0);
extern time_t mktime (struct tm *a);
extern struct tm* localtime(const time_t *t);
extern struct tm* localtime_r(const time_t *timep, struct tm *result);
extern struct tm* gmtime(const time_t *timep);
extern struct tm* gmtime_r(const time_t *timep, struct tm *result);
extern char* strptime(const char *buf, const char *fmt, struct tm *tm);
extern size_t strftime(char *s, size_t max, const char *format, const struct tm *tm);
extern char *ctime(const time_t *timep);
extern char *ctime_r(const time_t *timep, char *buf);
extern void tzset(void);
/* global includes */
extern char* tzname[];
extern int daylight;
extern long int timezone;
#define CLOCKS_PER_SEC 1000000
extern clock_t clock(void);
/* BIONIC: extra linux clock goodies */
extern int clock_getres(int, struct timespec *);
extern int clock_gettime(int, struct timespec *);
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 1
#define CLOCK_PROCESS_CPUTIME_ID 2
#define CLOCK_THREAD_CPUTIME_ID 3
#define CLOCK_REALTIME_HR 4
#define CLOCK_MONOTONIC_HR 5
extern int timer_create(int, struct sigevent*, timer_t*);
extern int timer_delete(timer_t);
extern int timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue);
extern int timer_gettime(timer_t timerid, struct itimerspec *value);
extern int timer_getoverrun(timer_t timerid);
__END_DECLS
#endif /* _TIME_H_ */

View File

@@ -61,16 +61,13 @@ extern pid_t getppid(void);
extern pid_t getpgrp(void);
extern int setpgrp(void);
extern pid_t setsid(void);
extern pid_t getsid(pid_t);
extern int execv(const char *, char * const *);
extern int execvp(const char *, char * const *);
extern int execve(const char *, char * const *, char * const *);
extern int execvpe(const char *, char * const *, char * const *);
extern int execl(const char *, const char *, ...);
extern int execlp(const char *, const char *, ...);
extern int execle(const char *, const char *, ...);
extern int execlpe(const char *, const char *, ...);
extern int capget(cap_user_header_t hdrp, cap_user_data_t datap);
extern int capset(cap_user_header_t hdrp, const cap_user_data_t datap);
extern int prctl(int option, unsigned long arg2, unsigned long arg3,
@@ -94,11 +91,8 @@ extern int setresuid(uid_t, uid_t, uid_t);
extern int setresgid(gid_t, gid_t, gid_t);
extern int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);
extern int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid);
extern int getfsuid(uid_t);
extern int setfsuid(uid_t);
extern int issetugid(void);
extern char* getlogin(void);
extern int getlogin_r(char* name, size_t namesize);
extern char* getusershell(void);
extern void setusershell(void);
extern void endusershell(void);
@@ -144,7 +138,6 @@ extern int fcntl(int, int, ...);
extern int ioctl(int, int, ...);
extern int flock(int, int);
extern int fsync(int);
extern int fdatasync(int);
extern int ftruncate(int, off_t);
extern int pause(void);
@@ -153,9 +146,6 @@ extern unsigned int sleep(unsigned int);
extern int usleep(unsigned long);
extern int gethostname(char *, size_t);
extern int sethostname(const char *, size_t);
extern int getdomainname(char *, size_t);
extern int setdomainname(const char *, size_t);
extern int getdtablesize(void);
@@ -192,6 +182,19 @@ extern int cacheflush(long start, long end, long flags);
extern pid_t tcgetpgrp(int fd);
extern int tcsetpgrp(int fd, pid_t _pid);
#if 0 /* MISSING FROM BIONIC */
extern pid_t getsid(pid_t);
extern int execvpe(const char *, char * const *, char * const *);
extern int execlpe(const char *, const char *, ...);
extern int getfsuid(uid_t);
extern int setfsuid(uid_t);
extern int fdatasync(int);
extern int getlogin_r(char* name, size_t namesize);
extern int sethostname(const char *, size_t);
extern int getdomainname(char *, size_t);
extern int setdomainname(const char *, size_t);
#endif /* MISSING */
/* Used to retry syscalls that can return EINTR. */
#define TEMP_FAILURE_RETRY(exp) ({ \
typeof (exp) _rc; \