OSDN Git Service

auto import from //branches/cupcake/...@125939
authorThe Android Open Source Project <initial-contribution@android.com>
Sat, 10 Jan 2009 01:50:54 +0000 (17:50 -0800)
committerThe Android Open Source Project <initial-contribution@android.com>
Sat, 10 Jan 2009 01:50:54 +0000 (17:50 -0800)
33 files changed:
libc/Android.mk
libc/arch-arm/bionic/ffs.S [new file with mode: 0644]
libc/include/locale.h
libc/include/netdb.h
libc/include/setjmp.h
libc/include/stdlib.h
libc/include/string.h
libc/include/sys/tls.h
libc/include/wchar.h
libc/kernel/arch-arm/asm/param.h
libc/kernel/arch-x86/asm/param.h
libc/kernel/common/linux/dm-ioctl.h [new file with mode: 0644]
libc/kernel/common/linux/keychord.h [new file with mode: 0644]
libc/kernel/common/linux/msm_audio.h [new file with mode: 0644]
libc/kernel/tools/clean_header.py
libc/kernel/tools/cpp.py
libc/kernel/tools/defaults.py
libc/private/arpa_nameser.h [moved from libc/arpa_nameser.h with 100% similarity]
libc/private/arpa_nameser_compat.h [moved from libc/arpa_nameser_compat.h with 100% similarity]
libc/private/ctype_private.h [moved from libc/ctype_private.h with 100% similarity]
libc/private/isc/assertions.h [moved from libc/include/isc/assertions.h with 100% similarity]
libc/private/isc/dst.h [moved from libc/include/isc/dst.h with 100% similarity]
libc/private/isc/eventlib.h [moved from libc/include/isc/eventlib.h with 100% similarity]
libc/private/isc/heap.h [moved from libc/include/isc/heap.h with 100% similarity]
libc/private/isc/list.h [moved from libc/include/isc/list.h with 100% similarity]
libc/private/isc/memcluster.h [moved from libc/include/isc/memcluster.h with 100% similarity]
libc/private/nsswitch.h [moved from libc/nsswitch.h with 100% similarity]
libc/private/rand48.h [moved from libc/rand48.h with 100% similarity]
libc/private/resolv_cache.h [moved from libc/resolv_cache.h with 100% similarity]
libc/private/resolv_private.h [moved from libc/resolv_private.h with 100% similarity]
libc/private/resolv_static.h [moved from libc/resolv_static.h with 100% similarity]
libc/private/syscommon.h [moved from libc/syscommon.h with 100% similarity]
libc/private/thread_private.h [moved from libc/thread_private.h with 100% similarity]

index 57919ad..f950c7e 100644 (file)
@@ -277,6 +277,7 @@ libc_common_src_files += \
        arch-arm/bionic/_setjmp.S \
        arch-arm/bionic/atomics_arm.S \
        arch-arm/bionic/clone.S \
+       arch-arm/bionic/ffs.S \
        arch-arm/bionic/kill.S \
        arch-arm/bionic/tkill.S \
        arch-arm/bionic/memcmp.S \
@@ -330,7 +331,8 @@ libc_common_cflags := \
                -DSOFTFLOAT                     \
                -DFLOATING_POINT                \
                -DNEED_PSELECT=1                \
-               -DINET6
+               -DINET6 \
+               -I$(LOCAL_PATH)/private \
 
 ifeq ($(TARGET_BUILD_TYPE),debug)
   libc_common_cflags += -DDEBUG
diff --git a/libc/arch-arm/bionic/ffs.S b/libc/arch-arm/bionic/ffs.S
new file mode 100644 (file)
index 0000000..f11141c
--- /dev/null
@@ -0,0 +1,82 @@
+/*     $NetBSD: ffs.S,v 1.5 2003/04/05 23:08:52 bjh21 Exp $    */
+/*
+ * Copyright (c) 2001 Christopher Gilbert
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The name of the company nor the name of the author may be used to
+ *    endorse or promote products derived from this software without specific
+ *    prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * ffs - find first set bit, this algorithm isolates the first set
+ * bit, then multiplies the number by 0x0450fbaf which leaves the top
+ * 6 bits as an index into the table.  This algorithm should be a win
+ * over the checking each bit in turn as per the C compiled version.
+ *
+ * under ARMv5 there's an instruction called CLZ (count leading Zero's) that
+ * could be used
+ *
+ * This is the ffs algorithm devised by d.seal and posted to comp.sys.arm on
+ * 16 Feb 1994.
+ */
+
+ENTRY(ffs)
+       /* Standard trick to isolate bottom bit in r0 or 0 if r0 = 0 on entry */
+       rsb     r1, r0, #0
+       ands    r0, r0, r1
+#ifndef __ARM_ARCH_5__
+       /*
+        * now r0 has at most one set bit, call this X
+        * if X = 0, all further instructions are skipped
+        */
+       adrne   r2, .L_ffs_table
+       orrne   r0, r0, r0, lsl #4  /* r0 = X * 0x11 */ 
+       orrne   r0, r0, r0, lsl #6  /* r0 = X * 0x451 */
+       rsbne   r0, r0, r0, lsl #16 /* r0 = X * 0x0450fbaf */
+              
+       /* now lookup in table indexed on top 6 bits of r0 */
+       ldrneb  r0, [ r2, r0, lsr #26 ]
+
+       bx              lr
+
+.text;
+.type .L_ffs_table, _ASM_TYPE_OBJECT;
+.L_ffs_table:
+/*               0   1   2   3   4   5   6   7           */
+       .byte    0,  1,  2, 13,  3,  7,  0, 14  /*  0- 7 */
+       .byte    4,  0,  8,  0,  0,  0,  0, 15  /*  8-15 */
+       .byte   11,  5,  0,  0,  9,  0,  0, 26  /* 16-23 */
+       .byte    0,  0,  0,  0,  0, 22, 28, 16  /* 24-31 */
+       .byte   32, 12,  6,  0,  0,  0,  0,  0  /* 32-39 */
+       .byte   10,  0,  0, 25,  0,  0, 21, 27  /* 40-47 */
+       .byte   31,  0,  0,  0,  0, 24,  0, 20  /* 48-55 */
+       .byte   30,  0, 23, 19, 29, 18, 17,  0  /* 56-63 */
+#else
+       clzne   r0, r0
+       rsbne   r0, r0, #32
+       bx              lr
+#endif
+
index 2a11b04..65b5c7d 100644 (file)
@@ -51,6 +51,10 @@ enum {
 
 extern char *setlocale(int category, const char *locale);
 
+/* Make libstdc++-v3 happy.  */
+struct lconv { };
+struct lconv *localeconv(void);
+
 __END_DECLS
 
 #endif /* _LOCALE_H_ */
index e824a3a..b0c3b72 100644 (file)
@@ -73,6 +73,8 @@
 #define        _PATH_PROTOCOLS "/system/etc/protocols"
 #define        _PATH_SERVICES  "/system/etc/services"
 
+#define  MAXHOSTNAMELEN  256
+
 /* BIONIC-BEGIN */
 #define  h_errno   (*__get_h_errno())
 extern int*  __get_h_errno(void);
index c3a197e..68fdcef 100644 (file)
 #include <sys/cdefs.h>
 #include <machine/setjmp.h>
 
-#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
 typedef long sigjmp_buf[_JBLEN + 1];
-#endif /* __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE */
-
 typedef long jmp_buf[_JBLEN];
 
 __BEGIN_DECLS
 
-/* BIONIC SPECIAL: we *don't* save the signal mask in setjmp/longjmp
- *                 this means we comply with ANSI, not with POSIX, and
- *                 our runtime runs well instead of getting stuck
- */
-#if 1
-#define  setjmp(x)   _setjmp(x)
-#define  longjmp(x,y)  _longjmp(x,y)
-#else
-int    setjmp(jmp_buf);
-void   longjmp(jmp_buf, int);
-#endif
+int     _setjmp(jmp_buf);
+void    _longjmp(jmp_buf, int);
+void    longjmperror(void);
+
+int     setjmp(jmp_buf);
+void    longjmp(jmp_buf, int);
 
-#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
-int    sigsetjmp(sigjmp_buf, int);
-void   siglongjmp(sigjmp_buf, int);
-#endif /* __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE */
+int     sigsetjmp(sigjmp_buf, int);
+void    siglongjmp(sigjmp_buf, int);
 
-#if __BSD_VISIBLE || __XPG_VISIBLE
-int    _setjmp(jmp_buf);
-void   _longjmp(jmp_buf, int);
-void   longjmperror(void);
-#endif /* __BSD_VISIBLE || __XPG_VISIBLE */
 __END_DECLS
 
 #endif /* !_SETJMP_H_ */
index 15925e3..a821e03 100644 (file)
@@ -160,6 +160,11 @@ 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);
+#define MB_CUR_MAX 1
+
 __END_DECLS
 
 #endif /* _STDLIB_H_ */
index b46100a..435923b 100644 (file)
@@ -82,6 +82,10 @@ extern size_t strspn(const char *, const char *);
 
 extern char*  strsignal(int  sig);
 
+/* Just declared to make libstdc++-v3 happy.  */
+extern int    strcoll (const char *, const char *);
+extern size_t strxfrm (char *, const char *, size_t);
+
 __END_DECLS
 
 #endif /* _STRING_H_ */
index d59f1c3..da34344 100644 (file)
 
 __BEGIN_DECLS
 
+/** WARNING WARNING WARNING
+ **
+ ** This header file is *NOT* part of the public Bionic ABI/API
+ ** and should not be used/included by user-serviceable parts of
+ ** the system (e.g. applications).
+ **
+ ** It is only provided here for the benefit of the system dynamic
+ ** linker and the OpenGL sub-system (which needs to access the
+ ** pre-allocated slot directly for performance reason).
+ **/
+
 /* maximum number of elements in the TLS array */
 #define BIONIC_TLS_SLOTS            64
 
index d2d022a..3dadc98 100644 (file)
@@ -144,6 +144,11 @@ extern wchar_t          *wmemset(wchar_t *, wchar_t, size_t);
 extern int               wprintf(const wchar_t *, ...);
 extern int               wscanf(const wchar_t *, ...);
 
+/* No really supported.  These are just for making libstdc++-v3 happy.  */
+typedef void *wctrans_t;
+extern wint_t           towctrans(wint_t, wctrans_t);
+extern wctrans_t        wctrans (const char *);
+
 __END_DECLS
 
 #endif /* _WCHAR_H_ */
index 23d45c7..6814fe3 100644 (file)
@@ -20,7 +20,6 @@
 #define NOGROUP (-1)
 #endif
 
-#define MAXHOSTNAMELEN 64
 
 #endif
 
index 0825173..3fafd55 100644 (file)
@@ -22,6 +22,5 @@
 #define NOGROUP (-1)
 #endif
 
-#define MAXHOSTNAMELEN 64  
 
 #endif
diff --git a/libc/kernel/common/linux/dm-ioctl.h b/libc/kernel/common/linux/dm-ioctl.h
new file mode 100644 (file)
index 0000000..ead7744
--- /dev/null
@@ -0,0 +1,146 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _LINUX_DM_IOCTL_V4_H
+#define _LINUX_DM_IOCTL_V4_H
+
+#include <linux/types.h>
+
+#define DM_DIR "mapper"  
+#define DM_MAX_TYPE_NAME 16
+#define DM_NAME_LEN 128
+#define DM_UUID_LEN 129
+
+struct dm_ioctl {
+
+ uint32_t version[3];
+ uint32_t data_size;
+
+ uint32_t data_start;
+
+ uint32_t target_count;
+ int32_t open_count;
+ uint32_t flags;
+ uint32_t event_nr;
+ uint32_t padding;
+
+ uint64_t dev;
+
+ char name[DM_NAME_LEN];
+ char uuid[DM_UUID_LEN];
+ char data[7];
+};
+
+struct dm_target_spec {
+ uint64_t sector_start;
+ uint64_t length;
+ int32_t status;
+
+ uint32_t next;
+
+ char target_type[DM_MAX_TYPE_NAME];
+
+};
+
+struct dm_target_deps {
+ uint32_t count;
+ uint32_t padding;
+ uint64_t dev[0];
+};
+
+struct dm_name_list {
+ uint64_t dev;
+ uint32_t next;
+ char name[0];
+};
+
+struct dm_target_versions {
+ uint32_t next;
+ uint32_t version[3];
+
+ char name[0];
+};
+
+struct dm_target_msg {
+ uint64_t sector;
+
+ char message[0];
+};
+
+enum {
+
+ DM_VERSION_CMD = 0,
+ DM_REMOVE_ALL_CMD,
+ DM_LIST_DEVICES_CMD,
+
+ DM_DEV_CREATE_CMD,
+ DM_DEV_REMOVE_CMD,
+ DM_DEV_RENAME_CMD,
+ DM_DEV_SUSPEND_CMD,
+ DM_DEV_STATUS_CMD,
+ DM_DEV_WAIT_CMD,
+
+ DM_TABLE_LOAD_CMD,
+ DM_TABLE_CLEAR_CMD,
+ DM_TABLE_DEPS_CMD,
+ DM_TABLE_STATUS_CMD,
+
+ DM_LIST_VERSIONS_CMD,
+ DM_TARGET_MSG_CMD,
+ DM_DEV_SET_GEOMETRY_CMD
+};
+
+#define DM_IOCTL 0xfd
+
+#define DM_VERSION _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
+#define DM_REMOVE_ALL _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl)
+#define DM_LIST_DEVICES _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl)
+
+#define DM_DEV_CREATE _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, struct dm_ioctl)
+#define DM_DEV_REMOVE _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, struct dm_ioctl)
+#define DM_DEV_RENAME _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, struct dm_ioctl)
+#define DM_DEV_SUSPEND _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, struct dm_ioctl)
+#define DM_DEV_STATUS _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, struct dm_ioctl)
+#define DM_DEV_WAIT _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, struct dm_ioctl)
+
+#define DM_TABLE_LOAD _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, struct dm_ioctl)
+#define DM_TABLE_CLEAR _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, struct dm_ioctl)
+#define DM_TABLE_DEPS _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
+#define DM_TABLE_STATUS _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
+
+#define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
+
+#define DM_TARGET_MSG _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
+#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
+
+#define DM_VERSION_MAJOR 4
+#define DM_VERSION_MINOR 14
+#define DM_VERSION_PATCHLEVEL 0
+#define DM_VERSION_EXTRA "-ioctl (2008-04-23)"
+
+#define DM_READONLY_FLAG (1 << 0)  
+#define DM_SUSPEND_FLAG (1 << 1)  
+#define DM_PERSISTENT_DEV_FLAG (1 << 3)  
+
+#define DM_STATUS_TABLE_FLAG (1 << 4)  
+
+#define DM_ACTIVE_PRESENT_FLAG (1 << 5)  
+#define DM_INACTIVE_PRESENT_FLAG (1 << 6)  
+
+#define DM_BUFFER_FULL_FLAG (1 << 8)  
+
+#define DM_SKIP_BDGET_FLAG (1 << 9)  
+
+#define DM_SKIP_LOCKFS_FLAG (1 << 10)  
+
+#define DM_NOFLUSH_FLAG (1 << 11)  
+
+#endif
diff --git a/libc/kernel/common/linux/keychord.h b/libc/kernel/common/linux/keychord.h
new file mode 100644 (file)
index 0000000..9148431
--- /dev/null
@@ -0,0 +1,30 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __LINUX_KEYCHORD_H_
+#define __LINUX_KEYCHORD_H_
+
+#include <linux/input.h>
+
+#define KEYCHORD_VERSION 1
+
+struct input_keychord {
+
+ __u16 version;
+
+ __u16 id;
+
+ __u16 count;
+
+ __u16 keycodes[];
+};
+
+#endif
diff --git a/libc/kernel/common/linux/msm_audio.h b/libc/kernel/common/linux/msm_audio.h
new file mode 100644 (file)
index 0000000..58dc6f3
--- /dev/null
@@ -0,0 +1,81 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __LINUX_MSM_AUDIO_H
+#define __LINUX_MSM_AUDIO_H
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+#include <asm/sizes.h>
+
+#define AUDIO_IOCTL_MAGIC 'a'
+
+#define AUDIO_START _IOW(AUDIO_IOCTL_MAGIC, 0, unsigned)
+#define AUDIO_STOP _IOW(AUDIO_IOCTL_MAGIC, 1, unsigned)
+#define AUDIO_FLUSH _IOW(AUDIO_IOCTL_MAGIC, 2, unsigned)
+#define AUDIO_GET_CONFIG _IOR(AUDIO_IOCTL_MAGIC, 3, unsigned)
+#define AUDIO_SET_CONFIG _IOW(AUDIO_IOCTL_MAGIC, 4, unsigned)
+#define AUDIO_GET_STATS _IOR(AUDIO_IOCTL_MAGIC, 5, unsigned)
+#define AUDIO_ENABLE_AUDPP _IOW(AUDIO_IOCTL_MAGIC, 6, unsigned)
+#define AUDIO_SET_ADRC _IOW(AUDIO_IOCTL_MAGIC, 7, unsigned)
+#define AUDIO_SET_EQ _IOW(AUDIO_IOCTL_MAGIC, 8, unsigned)
+#define AUDIO_SET_RX_IIR _IOW(AUDIO_IOCTL_MAGIC, 9, unsigned)
+#define AUDIO_SET_VOLUME _IOW(AUDIO_IOCTL_MAGIC, 10, unsigned)
+
+struct msm_audio_config {
+ uint32_t buffer_size;
+ uint32_t buffer_count;
+ uint32_t channel_count;
+ uint32_t sample_rate;
+ uint32_t type;
+ uint32_t unused[3];
+};
+
+struct msm_audio_stats {
+ uint32_t byte_count;
+ uint32_t sample_count;
+ uint32_t unused[2];
+};
+
+#define SND_IOCTL_MAGIC 's'
+
+#define SND_MUTE_UNMUTED 0
+#define SND_MUTE_MUTED 1
+
+struct msm_snd_device_config {
+ uint32_t device;
+ uint32_t ear_mute;
+ uint32_t mic_mute;
+};
+
+#define SND_SET_DEVICE _IOW(SND_IOCTL_MAGIC, 2, struct msm_device_config *)
+
+#define SND_METHOD_VOICE 0
+
+struct msm_snd_volume_config {
+ uint32_t device;
+ uint32_t method;
+ uint32_t volume;
+};
+
+#define SND_SET_VOLUME _IOW(SND_IOCTL_MAGIC, 3, struct msm_snd_volume_config *)
+
+#define SND_GET_NUM_ENDPOINTS _IOR(SND_IOCTL_MAGIC, 4, unsigned *)
+
+struct msm_snd_endpoint {
+ int id;
+ char name[64];
+};
+
+#define SND_GET_ENDPOINT _IOWR(SND_IOCTL_MAGIC, 5, struct msm_snd_endpoint *)
+
+#endif
+
index bed9926..de4bf85 100755 (executable)
@@ -69,6 +69,7 @@ def  cleanupFile( path ):
     list.removeVarsAndFuncs( statics )
     list.removeComments()
     list.removeEmptyLines()
+    list.removeMacroDefines( kernel_ignored_macros )
     list.insertDisclaimer( kernel.kernel_disclaimer )
 
     out = StringOutput()
index 54ebaf4..4b4bd38 100644 (file)
@@ -1571,6 +1571,13 @@ class Block:
         """returns True iff this is a conditional directive block"""
         return self.directive in ["if","ifdef","ifndef","else","elif","endif"]
 
+    def isDefine(self):
+        """returns the macro name in a #define directive, or None otherwise"""
+        if self.directive != "define":
+            return None
+
+        return self.tokens[0].value
+
     def isIf(self):
         """returns True iff this is an #if-like directive block"""
         return self.directive in ["if","ifdef","ifndef","elif"]
@@ -1678,6 +1685,10 @@ class BlockList:
             if b.isIf():
                 b.expr.optimize(macros)
 
+    def removeMacroDefines(self,macros):
+        """remove known macro definitions from a BlockList"""
+        self.blocks = remove_macro_defines(self.blocks,macros)
+
     def removePrefixed(self,prefix,names):
         for b in self.blocks:
             if b.isIf():
@@ -1994,6 +2005,16 @@ def test_BlockParser():
 #####################################################################################
 #####################################################################################
 
+def  remove_macro_defines( blocks, excludedMacros=set() ):
+    """remove macro definitions like #define <macroName>  ...."""
+    result = []
+    for b in blocks:
+        macroName = b.isDefine()
+        if macroName == None or not macroName in excludedMacros:
+            result.append(b)
+
+    return result
+
 def  find_matching_endif( blocks, i ):
     n     = len(blocks)
     depth = 1
index da78b87..aad0092 100644 (file)
@@ -73,6 +73,17 @@ kernel_known_statics = {
         "x86" : kernel_known_x86_statics
     }
 
+# this is a list of macros which we want to specifically exclude from
+# the generated files.
+#
+kernel_ignored_macros = set(
+        [ "MAXHOSTNAMELEN",  # for some reason, Linux defines it to 64
+                             # while most of the BSD code expects this to be 256
+                             # so ignore the kernel-provided definition and
+                             # define it in the Bionic headers instead
+        ]
+    )
+
 # this is the standard disclaimer
 #
 kernel_disclaimer = """\
similarity index 100%
rename from libc/nsswitch.h
rename to libc/private/nsswitch.h
similarity index 100%
rename from libc/rand48.h
rename to libc/private/rand48.h
similarity index 100%
rename from libc/syscommon.h
rename to libc/private/syscommon.h