]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/commitdiff
Improve <sys/cdefs.h>.
authorElliott Hughes <enh@google.com>
Mon, 18 Aug 2014 21:45:42 +0000 (14:45 -0700)
committerElliott Hughes <enh@google.com>
Mon, 18 Aug 2014 21:45:42 +0000 (14:45 -0700)
Fix and use __RENAME (and lose ___RENAME --- two underscores should be
enough for anybody). This was the point of this change, because I want
to use __RENAME to support the two basename variants and the two
strerror_r variants.

Lose a bunch of macros that weren't being used.

Lose three dead files from the DNS code.

Change-Id: I3ef645c566b16a52217bc2e68c7d54b37c7c9522

libc/dns/resolv/__dn_comp.c [deleted file]
libc/dns/resolv/__res_close.c [deleted file]
libc/dns/resolv/__res_send.c [deleted file]
libc/include/fcntl.h
libc/include/stdio.h
libc/include/string.h
libc/include/sys/cdefs.h
libc/include/sys/cdefs_elf.h
libc/include/sys/socket.h
libc/include/sys/stat.h
libc/include/unistd.h

diff --git a/libc/dns/resolv/__dn_comp.c b/libc/dns/resolv/__dn_comp.c
deleted file mode 100644 (file)
index 93d3f19..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*     $NetBSD: __dn_comp.c,v 1.4 2005/09/13 01:44:10 christos Exp $   */
-
-/*
- * written by matthew green, 22/04/97.
- * public domain.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: __dn_comp.c,v 1.4 2005/09/13 01:44:10 christos Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#if defined(__indr_reference)
-__indr_reference(__dn_comp,dn_comp)
-#else
-
-#include <sys/types.h>
-#include <netinet/in.h>
-#ifdef ANDROID_CHANGES
-#include "resolv_private.h"
-#else
-#include <resolv.h>
-#endif
-
-/* XXX THIS IS A MESS!  SEE <resolv.h> XXX */
-
-#undef dn_comp
-int    dn_comp(const char *, u_char *, int, u_char **, u_char **);
-
-int
-dn_comp(const char *exp_dn, u_char *comp_dn, u_char **dnptrs,
-    u_char **lastdnptr, int length)
-{
-
-       return __dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr);
-}
-
-#endif
diff --git a/libc/dns/resolv/__res_close.c b/libc/dns/resolv/__res_close.c
deleted file mode 100644 (file)
index 3af50b0..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*     $NetBSD: __res_close.c,v 1.4 2005/09/13 01:44:10 christos Exp $ */
-
-/*
- * written by matthew green, 22/04/97.
- * public domain.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: __res_close.c,v 1.4 2005/09/13 01:44:10 christos Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#if defined(__indr_reference)
-__indr_reference(__res_close, res_close)
-#else
-
-#include <sys/types.h>
-#include <netinet/in.h>
-#include "resolv_private.h"
-
-/* XXX THIS IS A MESS!  SEE <resolv.h> XXX */
-
-#undef res_close
-void   res_close(void);
-
-void
-res_close(void)
-{
-
-       __res_close();
-}
-
-#endif
diff --git a/libc/dns/resolv/__res_send.c b/libc/dns/resolv/__res_send.c
deleted file mode 100644 (file)
index 198b05c..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*     $NetBSD: __res_send.c,v 1.4 2005/09/13 01:44:10 christos Exp $  */
-
-/*
- * written by matthew green, 22/04/97.
- * public domain.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: __res_send.c,v 1.4 2005/09/13 01:44:10 christos Exp $");
-#endif
-
-#if defined(__indr_reference)
-__indr_reference(__res_send, res_send)
-#else
-
-#include <sys/types.h>
-#include <netinet/in.h>
-#ifdef ANDROID_CHANGES
-#include "resolv_private.h"
-#else
-#include <resolv.h>
-#endif
-
-/* XXX THIS IS A MESS!  SEE <resolv.h> XXX */
-
-#undef res_send
-int    res_send(const u_char *, int, u_char *, int);
-
-int
-res_send(const u_char *buf, int buflen, u_char *ans, int anssiz)
-{
-
-       return __res_send(buf, buflen, ans, anssiz);
-}
-
-#endif
index 4450bb65f31cced343e2b4f75378cf1acfb40251..32557d958d8447983d9a44095850f686343629ed 100644 (file)
@@ -82,9 +82,9 @@ extern ssize_t vmsplice(int, const struct iovec*, size_t, unsigned int);
 #if defined(__BIONIC_FORTIFY)
 
 extern int __open_2(const char*, int);
-extern int __open_real(const char*, int, ...) __asm__(__USER_LABEL_PREFIX__ "open");
+extern int __open_real(const char*, int, ...) __RENAME(open);
 extern int __openat_2(int, const char*, int);
-extern int __openat_real(int, const char*, int, ...) __asm__(__USER_LABEL_PREFIX__ "openat");
+extern int __openat_real(int, const char*, int, ...) __RENAME(openat);
 __errordecl(__creat_missing_mode, "called with O_CREAT, but missing mode");
 __errordecl(__creat_too_many_args, "too many arguments");
 
index 74e5732945162a46598ca3125d3dbb23a049a8c4..516f8cb10e960f16cea21ee2c2ab8a7c1d5e1c3d 100644 (file)
@@ -408,7 +408,7 @@ int sprintf(char *dest, const char *format, ...)
 #endif
 
 extern char* __fgets_chk(char*, int, FILE*, size_t);
-extern char* __fgets_real(char*, int, FILE*) __asm__(__USER_LABEL_PREFIX__ "fgets");
+extern char* __fgets_real(char*, int, FILE*) __RENAME(fgets);
 __errordecl(__fgets_too_big_error, "fgets called with size bigger than buffer");
 __errordecl(__fgets_too_small_error, "fgets called with size less than zero");
 
index 8df68e38dd71980050a73fc21dcf19cd5b9a79b6..643132d678d7bff13d4df1b79230b7387a3c7878 100644 (file)
@@ -180,8 +180,7 @@ void* memset(void *s, int c, size_t n) {
     return __builtin___memset_chk(s, c, n, __bos0(s));
 }
 
-extern size_t __strlcpy_real(char* __restrict, const char* __restrict, size_t)
-    __asm__(__USER_LABEL_PREFIX__ "strlcpy");
+extern size_t __strlcpy_real(char* __restrict, const char* __restrict, size_t) __RENAME(strlcpy);
 extern size_t __strlcpy_chk(char *, const char *, size_t, size_t);
 
 __BIONIC_FORTIFY_INLINE
@@ -204,8 +203,7 @@ size_t strlcpy(char* __restrict dest, const char* __restrict src, size_t size) {
     return __strlcpy_chk(dest, src, size, bos);
 }
 
-extern size_t __strlcat_real(char* __restrict, const char* __restrict, size_t)
-    __asm__(__USER_LABEL_PREFIX__ "strlcat");
+extern size_t __strlcat_real(char* __restrict, const char* __restrict, size_t) __RENAME(strlcat);
 extern size_t __strlcat_chk(char* __restrict, const char* __restrict, size_t, size_t);
 
 
index 028661628d2483151862fd5c4bf3b99d3f67991b..c3338234b625ab0cd02b9e9cdb69e6bd3d50dad1 100644 (file)
 #endif /* NO_KERNEL_RCSIDS */
 #endif /* _KERNEL */
 
-#if !defined(_STANDALONE) && !defined(_KERNEL)
-#ifdef __GNUC__
-#define        __RENAME(x)     ___RENAME(x)
-#else
-#ifdef __lint__
-#define        __RENAME(x)     __symbolrename(x)
-#else
-#error "No function renaming possible"
-#endif /* __lint__ */
-#endif /* __GNUC__ */
-#else /* _STANDALONE || _KERNEL */
-#define        __RENAME(x)     no renaming in kernel or standalone environment
-#endif
-
 /*
  * A barrier to stop the optimizer from moving code or assume live
  * register values. This is gcc specific, the version is more or less
 #endif
 
 /*
- * Macros for manipulating "link sets".  Link sets are arrays of pointers
- * to objects, which are gathered up by the linker.
- *
- * Object format-specific code has provided us with the following macros:
- *
- *     __link_set_add_text(set, sym)
- *             Add a reference to the .text symbol `sym' to `set'.
- *
- *     __link_set_add_rodata(set, sym)
- *             Add a reference to the .rodata symbol `sym' to `set'.
- *
- *     __link_set_add_data(set, sym)
- *             Add a reference to the .data symbol `sym' to `set'.
- *
- *     __link_set_add_bss(set, sym)
- *             Add a reference to the .bss symbol `sym' to `set'.
- *
- *     __link_set_decl(set, ptype)
- *             Provide an extern declaration of the set `set', which
- *             contains an array of the pointer type `ptype'.  This
- *             macro must be used by any code which wishes to reference
- *             the elements of a link set.
- *
- *     __link_set_start(set)
- *             This points to the first slot in the link set.
- *
- *     __link_set_end(set)
- *             This points to the (non-existent) slot after the last
- *             entry in the link set.
- *
- *     __link_set_count(set)
- *             Count the number of entries in link set `set'.
- *
- * In addition, we provide the following macros for accessing link sets:
- *
- *     __link_set_foreach(pvar, set)
- *             Iterate over the link set `set'.  Because a link set is
- *             an array of pointers, pvar must be declared as "type **pvar",
- *             and the actual entry accessed as "*pvar".
- *
- *     __link_set_entry(set, idx)
- *             Access the link set entry at index `idx' from set `set'.
- */
-#define        __link_set_foreach(pvar, set)                                   \
-       for (pvar = __link_set_start(set); pvar < __link_set_end(set); pvar++)
-
-#define        __link_set_entry(set, idx)      (__link_set_begin(set)[idx])
-
-/*
- * Some of the 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.
+ * Some BSD source needs these macros.
+ * Originally they embedded the rcs versions of each source file
+ * in the generated binary. We strip strings during build anyway,.
  */
-#define __FBSDID(s) /* nothing */
+#define __IDSTRING(_prefix,_s) /* nothing */
+#define __COPYRIGHT(_s) /* nothing */
+#define __FBSDID(_s) /* nothing */
+#define __RCSID(_s) /* nothing */
+#define __SCCSID(_s) /* nothing */
 
 /*-
  * The following definitions are an extension of the behavior originally
 #endif
 #define __bos0(s) __builtin_object_size((s), 0)
 
-#define __BIONIC_FORTIFY_INLINE \
-    extern __inline__ \
-    __attribute__ ((always_inline)) \
-    __attribute__ ((gnu_inline))
+#define __BIONIC_FORTIFY_INLINE extern __inline__ __always_inline __attribute__((gnu_inline))
 #endif
 #define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1)
 
+/* Used to tag non-static symbols that are private and never exposed by the shared library. */
+#define __LIBC_HIDDEN__ __attribute__((visibility("hidden")))
+
+/* Like __LIBC_HIDDEN__, but preserves binary compatibility for LP32. */
+#ifdef __LP64__
+#define __LIBC64_HIDDEN__ __LIBC_HIDDEN__
+#else
+#define __LIBC64_HIDDEN__ __LIBC_ABI_PUBLIC__
+#endif
+
+/* Used to tag non-static symbols that are public and exposed by the shared library. */
+#define __LIBC_ABI_PUBLIC__ __attribute__((visibility ("default")))
+
+/* Used to rename functions so that the compiler emits a call to 'x' rather than the function this was applied to. */
+#define __RENAME(x) __asm__(#x)
+
 #endif /* !_SYS_CDEFS_H_ */
index 4dd7dc347678859c93e4d068a96f3637f4ff3744..6bb0a5720df906d6f5beeb9da14f92607d304f1e 100644 (file)
 #ifndef _SYS_CDEFS_ELF_H_
 #define        _SYS_CDEFS_ELF_H_
 
-#ifdef __LEADING_UNDERSCORE
-#define        _C_LABEL(x)     __CONCAT(_,x)
-#define _C_LABEL_STRING(x)     "_"x
-#else
-#define        _C_LABEL(x)     x
-#define _C_LABEL_STRING(x)     x
-#endif
+#define __strong_alias(alias, sym) \
+    __asm__(".global " #alias "\n" \
+            #alias " = " #sym);
 
-#define        ___RENAME(x)    __asm__(___STRING(_C_LABEL(x)))
-
-#define        __indr_reference(sym,alias)     /* nada, since we do weak refs */
-
-#define        __strong_alias(alias,sym)                                       \
-    __asm__(".global " _C_LABEL_STRING(#alias) "\n"                    \
-           _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
-
-#define        __weak_alias(alias,sym)                                         \
-    __asm__(".weak " _C_LABEL_STRING(#alias) "\n"                      \
-           _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
-#define        __weak_extern(sym)                                              \
-    __asm__(".weak " _C_LABEL_STRING(#sym));
+#define __weak_alias(alias,sym) \
+    __asm__(".weak " #alias "\n" \
+            #alias " = " #sym);
 
 /* We use __warnattr instead of __warn_references.
  * TODO: remove this and put an empty definition in one of the upstream-* compatibility headers.
 #define        __warn_references(sym,msg)                                      \
     /*__asm__(".section .gnu.warning." #sym "\n\t.ascii \"" msg "\"\n\t.text");*/
 
-#define        __SECTIONSTRING(_sec, _str)                                     \
-       __asm__(".section " #_sec "\n\t.asciz \"" _str "\"\n\t.previous")
-
-/* Used to tag non-static symbols that are private and never exposed by the shared library. */
-#define __LIBC_HIDDEN__ __attribute__((visibility ("hidden")))
-
-/* Like __LIBC_HIDDEN__, but preserves binary compatibility for LP32. */
-#ifdef __LP64__
-#define __LIBC64_HIDDEN__ __LIBC_HIDDEN__
-#else
-#define __LIBC64_HIDDEN__ __LIBC_ABI_PUBLIC__
-#endif
-
-/* Used to tag non-static symbols that are public and exposed by the shared library. */
-#define __LIBC_ABI_PUBLIC__ __attribute__((visibility ("default")))
-
-#define        __IDSTRING(_n,_s)               __SECTIONSTRING(.ident,_s)
-
-#define        __RCSID(_s)                     __IDSTRING(rcsid,_s)
-#define        __SCCSID(_s)
-#define __SCCSID2(_s)
-#if 0  /* XXX userland __COPYRIGHTs have \ns in them */
-#define        __COPYRIGHT(_s)                 __SECTIONSTRING(.copyright,_s)
-#else
-#define        __COPYRIGHT(_s)                                                 \
-       static const char copyright[]                                   \
-           __attribute__((__unused__,__section__(".copyright"))) = _s
-#endif
-
-#define        __KERNEL_RCSID(_n, _s)          __RCSID(_s)
-#define        __KERNEL_SCCSID(_n, _s)
-#if 0  /* XXX see above */
-#define        __KERNEL_COPYRIGHT(_n, _s)      __COPYRIGHT(_s)
-#else
-#define        __KERNEL_COPYRIGHT(_n, _s)      __SECTIONSTRING(.copyright, _s)
-#endif
-
-#ifndef __lint__
-#define        __link_set_make_entry(set, sym)                                 \
-       static void const * const __link_set_##set##_sym_##sym          \
-           __section("link_set_" #set) __used = &sym
-#define        __link_set_make_entry2(set, sym, n)                             \
-       static void const * const __link_set_##set##_sym_##sym##_##n    \
-           __section("link_set_" #set) __used = &sym[n]
-#else
-#define        __link_set_make_entry(set, sym)                                 \
-       extern void const * const __link_set_##set##_sym_##sym
-#define        __link_set_make_entry2(set, sym, n)                             \
-       extern void const * const __link_set_##set##_sym_##sym##_##n
-#endif /* __lint__ */
-
-#define        __link_set_add_text(set, sym)   __link_set_make_entry(set, sym)
-#define        __link_set_add_rodata(set, sym) __link_set_make_entry(set, sym)
-#define        __link_set_add_data(set, sym)   __link_set_make_entry(set, sym)
-#define        __link_set_add_bss(set, sym)    __link_set_make_entry(set, sym)
-#define        __link_set_add_text2(set, sym, n)   __link_set_make_entry2(set, sym, n)
-#define        __link_set_add_rodata2(set, sym, n) __link_set_make_entry2(set, sym, n)
-#define        __link_set_add_data2(set, sym, n)   __link_set_make_entry2(set, sym, n)
-#define        __link_set_add_bss2(set, sym, n)    __link_set_make_entry2(set, sym, n)
-
-#define        __link_set_decl(set, ptype)                                     \
-       extern ptype * const __start_link_set_##set[];                  \
-       extern ptype * const __stop_link_set_##set[]                    \
-
-#define        __link_set_start(set)   (__start_link_set_##set)
-#define        __link_set_end(set)     (__stop_link_set_##set)
-
-#define        __link_set_count(set)                                           \
-       (__link_set_end(set) - __link_set_start(set))
-
 #endif /* !_SYS_CDEFS_ELF_H_ */
index ae2f2381e4b887d36c8bd8d54e999988c2e56dc1..a8840ff46c17ec6ae439012441a04f6faa22ca91 100644 (file)
@@ -294,8 +294,7 @@ __socketcall ssize_t recvfrom(int, void*, size_t, int, const struct sockaddr*, s
 #if defined(__BIONIC_FORTIFY)
 __errordecl(__recvfrom_error, "recvfrom called with size bigger than buffer");
 extern ssize_t __recvfrom_chk(int, void*, size_t, size_t, int, const struct sockaddr*, socklen_t*);
-extern ssize_t __recvfrom_real(int, void*, size_t, int, const struct sockaddr*, socklen_t*)
-    __asm__(__USER_LABEL_PREFIX__ "recvfrom");
+extern ssize_t __recvfrom_real(int, void*, size_t, int, const struct sockaddr*, socklen_t*) __RENAME(recvfrom);
 
 __BIONIC_FORTIFY_INLINE
 ssize_t recvfrom(int fd, void* buf, size_t len, int flags, const struct sockaddr* src_addr, socklen_t* addr_len) {
index c0c168b2ef16c370bfddcbeda8e2d9b6220dd46a..a6cc368cf5e7691233bde1fc0d42440e4d14d6a8 100644 (file)
@@ -162,7 +162,7 @@ extern mode_t umask(mode_t);
 #if defined(__BIONIC_FORTIFY)
 
 extern mode_t __umask_chk(mode_t);
-extern mode_t __umask_real(mode_t) __asm__(__USER_LABEL_PREFIX__ "umask");
+extern mode_t __umask_real(mode_t) __RENAME(umask);
 __errordecl(__umask_invalid_mode, "umask called with invalid mode");
 
 __BIONIC_FORTIFY_INLINE
index 7fbafdf27dd5b88b3bf535e8c1b7d617fe433654..781fc443542857faf3030e53e7269562af231202 100644 (file)
@@ -201,8 +201,7 @@ extern int   tcsetpgrp(int fd, pid_t _pid);
 extern ssize_t __read_chk(int, void*, size_t, size_t);
 __errordecl(__read_dest_size_error, "read called with size bigger than destination");
 __errordecl(__read_count_toobig_error, "read called with count > SSIZE_MAX");
-extern ssize_t __read_real(int, void*, size_t)
-    __asm__(__USER_LABEL_PREFIX__ "read");
+extern ssize_t __read_real(int, void*, size_t) __RENAME(read);
 
 __BIONIC_FORTIFY_INLINE
 ssize_t read(int fd, void* buf, size_t count) {