Clang module map files for zircon, fdio and musl

These are needed to enable the use of Clang modules.

Change-Id: I90848d9abf7b8a4e6858e63785bd61979a18c57a
diff --git a/system/public/zircon/module.modulemap b/system/public/zircon/module.modulemap
new file mode 100644
index 0000000..b170477
--- /dev/null
+++ b/system/public/zircon/module.modulemap
@@ -0,0 +1,283 @@
+// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Unlike the Libc module map, this one does not explictly "export *" any
+// symbols up the parent module requiring that you explictly import what
+// modules you are using. For that reason module names in this file can break
+// imports in langauges that can refernece them directly.
+module Zircon [system] [extern_c] {
+  use Libc
+
+  textual header "assert.h"
+  textual header "compiler.h"
+
+  module crashlogger [extern_c] {
+    header "crashlogger.h"
+  }
+
+  module errors [extern_c] {
+    header "errors.h"
+  }
+
+  module ktrace [extern_c] {
+    textual header "ktrace-def.h"
+    header "ktrace.h"
+  }
+
+  module listnode [extern_c] {
+    header "listnode.h"
+  }
+
+  module mtrace [extern_c] {
+    header "mtrace.h"
+  }
+
+  module pixelformat [extern_c] {
+    header "pixelformat.h"
+  }
+
+  module processargs [extern_c] {
+    header "processargs.h"
+  }
+
+  module process [extern_c] {
+    header "process.h"
+  }
+
+  module rights [extern_c] {
+    header "rights.h"
+  }
+
+  module syscalls [extern_c] {
+    // This module refers to both the "syscalls.h" in the root and all of the
+    // headers in the "syscalls" folder.
+
+    module debug {
+      header "syscalls/debug.h"
+      // explictly require you include this if you use it.
+    }
+    module exception {
+      header "syscalls/exception.h"
+      export *
+    }
+    module hypervisor {
+      header "syscalls/hypervisor.h"
+      export *
+    }
+    module log {
+      header "syscalls/log.h"
+      export *
+    }
+    module object {
+      header "syscalls/object.h"
+      export *
+    }
+    module pci {
+      header "syscalls/pci.h"
+      export *
+    }
+    module policy {
+      header "syscalls/policy.h"
+      export *
+    }
+    module port {
+      header "syscalls/port.h"
+      export *
+    }
+    module resource {
+      header "syscalls/resource.h"
+      export *
+    }
+    module profile {
+      header "syscalls/profile.h"
+      export *
+    }
+    module smc {
+      header "syscalls/smc.h"
+      export *
+    }
+    module system {
+      header "syscalls/system.h"
+      export *
+    }
+    module types {
+      header "syscalls/types.h"
+      export *
+    }
+
+    header "syscalls.h"
+  }
+
+  module tls [extern_c] {
+    header "tls.h"
+  }
+
+  module types [extern_c] {
+    header "types.h"
+  }
+
+  module boot [extern_c] {
+    module bootdata {
+      header "boot/bootdata.h"
+    }
+    module multiboot {
+      header "boot/multiboot.h"
+    }
+    module netboot {
+      header "boot/netboot.h"
+    }
+  }
+
+  module device [extern_c] {
+    umbrella "device"
+
+    module audio {
+      header "device/audio.h"
+      export *
+    }
+    module block {
+      header "device/block.h"
+      export *
+    }
+    module bt_hci {
+      header "device/bt-hci.h"
+      export *
+    }
+    module camera_proto {
+      requires cplusplus
+      header "device/camera-proto.h"
+      export *
+    }
+    module camera {
+      header "device/camera.h"
+      export *
+    }
+    module device {
+      header "device/device.h"
+      export *
+    }
+    module display {
+      header "device/display.h"
+      export *
+    }
+    module dmctl {
+      header "device/dmctl.h"
+      export *
+    }
+    module ethernet {
+      header "device/ethernet.h"
+      export *
+    }
+    module ethertap {
+      header "device/ethertap.h"
+      export *
+    }
+    module hidctl {
+      header "device/hidctl.h"
+      export *
+    }
+    module i2c {
+      header "device/i2c.h"
+      export *
+    }
+    module input {
+      header "device/input.h"
+      export *
+    }
+    module intel_hda {
+      header "device/intel-hda.h"
+      export *
+    }
+    module ioctl {
+      header "device/ioctl.h"
+      export *
+    }
+    module ioctl_wrapper {
+      header "device/ioctl-wrapper.h"
+      export *
+    }
+    module ktrace {
+      header "device/ktrace.h"
+      export *
+    }
+    module media_codec {
+      header "device/media-codec.h"
+      export *
+    }
+    module midi {
+      header "device/midi.h"
+      export *
+    }
+    module power {
+      header "device/power.h"
+      export *
+    }
+    module pty {
+      header "device/pty.h"
+      export *
+    }
+    module ramdisk {
+      header "device/ramdisk.h"
+      export *
+    }
+    module rtc {
+      header "device/rtc.h"
+      export *
+    }
+    module sysinfo {
+      header "device/sysinfo.h"
+      export *
+    }
+    module test {
+      header "device/test.h"
+      export *
+    }
+    module thermal {
+      header "device/thermal.h"
+      export *
+    }
+    module tpm {
+      header "device/tpm.h"
+      export *
+    }
+    module usb_device {
+      header "device/usb-device.h"
+      export *
+    }
+    module usb {
+      header "device/usb.h"
+      export *
+    }
+    module vfs {
+      header "device/vfs.h"
+      export *
+    }
+
+    export *
+  }
+
+  module driver [extern_c] {
+    // glob each header into it's own module decl
+    umbrella "driver"
+    explicit module * {
+      export *
+    }
+  }
+
+  module hw [extern_c] {
+    // glob each header into it's own module decl
+    umbrella "hw"
+    explicit module * {
+      export *
+    }
+  }
+
+  module misc [extern_c] {
+    // glob each header into it's own module decl
+    umbrella "misc"
+    explicit module * {
+      export *
+    }
+  }
+}
diff --git a/system/ulib/fdio/include/lib/fdio/module.modulemap b/system/ulib/fdio/include/lib/fdio/module.modulemap
new file mode 100644
index 0000000..4fbbd62
--- /dev/null
+++ b/system/ulib/fdio/include/lib/fdio/module.modulemap
@@ -0,0 +1,55 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module Fdio [system] [extern_c] {
+  use Libc
+  use Zircon
+
+  link "fdio"
+
+  textual header "debug.h"
+
+  module io {
+    header "io.h"
+    export *
+  }
+  module limits {
+    header "limits.h"
+    export *
+  }
+  module "private" {
+    header "private.h"
+    export *
+  }
+  module "namespace" {
+    header "namespace.h"
+    export *
+  }
+  module remoteio {
+    header "remoteio.h"
+    export *
+  }
+  module spawn {
+    header "spawn.h"
+    export *
+  }
+  module socket {
+    header "socket.h"
+    export *
+  }
+  module util {
+    header "util.h"
+    export *
+  }
+  module vfs {
+    header "vfs.h"
+    export *
+  }
+  module watcher {
+    header "watcher.h"
+    export *
+  }
+
+  export *
+}
diff --git a/third_party/ulib/musl/include/module.modulemap b/third_party/ulib/musl/include/module.modulemap
new file mode 100644
index 0000000..8cbd298
--- /dev/null
+++ b/third_party/ulib/musl/include/module.modulemap
@@ -0,0 +1,525 @@
+module Libc [system] {
+  link "c"
+  config_macros _ALL_SOURCE,_BSD_SOURCE,_GNU_SOURCE,_KERNEL,_POSIX_C_SOURCE,_POSIX_SOURCE,_XOPEN_SOURCE
+
+  module C [extern_c] {
+    textual header "assert.h" // POSIX/C89
+
+    module alloca { // POSIX
+      header "alloca.h"
+      export *
+    }
+    module byteswap { // GNU extension
+      header "byteswap.h"
+      export *
+    }
+    module complex { // C99
+      header "complex.h"
+      export *
+    }
+    module ctype { // C89
+      header "ctype.h"
+      export *
+    }
+    module err { // BSD extension
+      header "err.h"
+      export *
+    }
+    module errno { // POSIX/C89
+      header "errno.h"
+      export *
+    }
+    module features { // POSIX?
+      textual header "features.h"
+      export *
+    }
+    module fenv { // C99
+      header "fenv.h"
+      export *
+    }
+    module float { // C/POSIX
+      header "float.h"
+      export *
+    }
+    module inttypes { // C99
+      header "inttypes.h"
+      export *
+    }
+    module iso646 { // C95
+      header "iso646.h"
+      export *
+    }
+    module limits { // C99
+      header "limits.h"
+      export *
+    }
+    module locale { // C90?
+      header "locale.h"
+      export *
+    }
+    module malloc { // C89
+      header "malloc.h"
+      export *
+    }
+    module math { // C89
+      header "math.h"
+      export *
+    }
+    module memory { // Legacy header
+      export string
+    }
+    module setjmp {  // C89/POSIX
+      header "setjmp.h"
+      export *
+    }
+    module signal { // C89/POSIX
+      header "signal.h"
+      export *
+    }
+    // defined in clang
+    // module stdatomic { // C11
+    //    header "stdatomic.h"
+    //    export *
+    // }
+    module stdalign { // C11
+      header "stdalign.h"
+      export *
+    }
+    module stdarg { // C89
+      header "stdarg.h"
+      export *
+    }
+    module stdbool { // C99
+      header "stdbool.h"
+      export *
+    }
+    module stdint { // C99
+      header "stdint.h" // This might be deleted in favor of clang provided version
+      export *
+    }
+    module stdio { // C89
+      header "stdio.h"
+      export *
+    }
+    module stdlib { // C89
+      header "stddef.h"
+      header "stdlib.h"
+      export malloc // HACK: Our stdlib re-defines some other functions from other headers
+      export *
+    }
+    module stdnoreturn { // C11
+      header "stdnoreturn.h"
+      export *
+    }
+    module string { // C89
+      header "string.h"
+      export *
+    }
+    module threads { // C11
+      header "threads.h"
+      export *
+    }
+    module time {
+      header "time.h"
+      export *
+    }
+    module uchar { // C11
+      header "uchar.h"
+      export *
+    }
+    module wchar { // C89
+      header "wchar.h"
+      export *
+    }
+    module wctype { // C89
+      header "wctype.h"
+      export *
+    }
+    export *
+  }
+  module POSIX [extern_c]  {
+    module ar { // GNU?
+      header "ar.h"
+      export *
+    }
+    module cpio { // POSIX?
+      header "cpio.h"
+      export *
+    }
+    module dirent { // POSIX
+      header "dirent.h"
+      export *
+    }
+    module dlfcn { // POSIX
+      header "dlfcn.h"
+      export *
+    }
+    module elf { // BSD/Linux
+      header "elf.h"
+      export *
+    }
+    module endian { // POSIX
+      header "endian.h"
+      export *
+    }
+    module fcntl { // POSIX
+      header "fcntl.h"
+      export *
+    }
+    module fmtmsg { // POSIX
+      header "fmtmsg.h"
+      export *
+    }
+    module fnmatch { // POSIX
+      header "fnmatch.h"
+      export *
+    }
+    module getopt { // POSIX
+      header "getopt.h"
+      export *
+    }
+    module glob { // POSIX
+      header "glob.h"
+      export *
+    }
+    module iconv { // POSIX
+      header "iconv.h"
+      export *
+    }
+    module ifaddrs { // POSIX
+      header "ifaddrs.h"
+      export *
+    }
+    module langinfo { // POSIX
+      header "langinfo.h"
+      export *
+    }
+    module libgen { // POSIX
+      header "libgen.h"
+      export *
+    }
+    module "link" { // POSIX (quoted because `link` is a reserved keyword)
+      header "link.h"
+      export *
+    }
+    module monetary { // POSIX
+      header "monetary.h"
+      export *
+    }
+    module netdb { // POSIX
+      header "netdb.h"
+      export *
+    }
+    module nl_types { // POSIX
+      header "nl_types.h" // Unimplemented in Fuchsia
+      export *
+    }
+    module poll { // POSIX
+      header "poll.h"
+      export *
+    }
+    module pthread { // POSIX
+      header "pthread.h"
+      export *
+    }
+    module regex { // POSIX
+      header "regex.h"
+      export *
+    }
+    module resolv { // POSIX
+      header "resolv.h"
+      export *
+    }
+    module sched { // POSIX
+      header "sched.h"
+      export Libc.C.string // HACK: redefines some functions from string.h with _GNU_SOURCE
+      export *
+    }
+    module search { // POSIX
+      header "search.h"
+      export *
+    }
+    module semaphore { // POSIX
+      header "semaphore.h" // sem_open is unimplemented on Fuchisa
+      export *
+    }
+    module strings { // POSIX
+      header "strings.h"
+      export *
+    }
+    module stropts { // POSIX
+      header "stropts.h"
+      export *
+    }
+    module sysexits { // POSIX
+      header "sysexits.h"
+      export *
+    }
+    module tar { // POSIX
+      header "tar.h"
+      export *
+    }
+    module unistd { // POSIX
+      header "unistd.h"
+      export *
+      export C.stdio // HACK: both stdio and unistd define ssize_t (depending on _GNU_SOURCE)
+    }
+    module utime { // POSIX
+      header "utime.h"
+      export *
+    }
+    module values {
+      header "values.h"
+      export *
+    }
+    module wait { // Legacy
+      export sys.wait
+    }
+    module wordexp { // POSIX
+      header "wordexp.h"
+      export *
+    }
+
+    // Folders
+    module arpa {
+      module ftp {
+        header "arpa/ftp.h"
+        export *
+      }
+      module inet {
+        header "arpa/inet.h"
+        export *
+      }
+      module nameser {
+        header "arpa/nameser.h"
+        export *
+      }
+      module nameser_compat {
+        header "arpa/nameser_compat.h"
+        export *
+      }
+      module telnet {
+        header "arpa/telnet.h"
+        export *
+      }
+      module tftp {
+        header "arpa/tftp.h"
+        export *
+      }
+      export *
+    }
+    module net {
+      module ethernet {
+        header "net/ethernet.h"
+        export *
+      }
+      module if_arp {
+        header "net/if_arp.h"
+        export *
+      }
+      module if {
+        header "net/if.h"
+        export *
+      }
+      module route {
+        header "net/if.h"
+        export *
+      }
+      export *
+    }
+    module netinet {
+      module ether {
+        header "netinet/ether.h"
+        export *
+      }
+      module icmp6 {
+        header "netinet/icmp6.h"
+        export *
+      }
+      module if_ether {
+        header "netinet/if_ether.h"
+        export *
+      }
+      module igmp {
+        header "netinet/igmp.h"
+        export *
+      }
+      module in {
+        header "netinet/in.h"
+        export *
+      }
+      module in_systm {
+        header "netinet/in_systm.h"
+        export *
+      }
+      module ip {
+        header "netinet/ip.h"
+        export *
+      }
+      module ip6 {
+        header "netinet/ip6.h"
+        export *
+      }
+      module ip_icmp {
+        header "netinet/ip_icmp.h"
+        export *
+      }
+      module tcp {
+        header "netinet/tcp.h"
+        export *
+      }
+      module udp {
+        header "netinet/udp.h"
+        export *
+      }
+      export *
+    }
+    module netpacket {
+      module packet {
+        header "netpacket/packet.h"
+        export *
+      }
+      export *
+    }
+    module sys { // TODO(zbowling): this incomplete
+      module file {
+        header "sys/file.h"
+        export *
+      }
+      module ioctl {
+        header "sys/ioctl.h"
+        export *
+      }
+      module ipc {
+        header "sys/ipc.h"
+        export *
+      }
+      module mman {
+        header "sys/mman.h"
+        export *
+      }
+      module msg {
+        header "sys/msg.h"
+        export *
+      }
+      module select {
+        header "sys/select.h"
+        export *
+      }
+      module socket {
+        header "sys/socket.h"
+        export *
+      }
+      module sem {
+        header "sys/sem.h"
+        export *
+      }
+      module sendfile {
+        header "sys/sendfile.h"
+        export *
+      }
+      module shm {
+        header "sys/shm.h"
+        export *
+      }
+      module stat {
+        header "sys/stat.h"
+        export *
+      }
+      module statfs {
+        header "sys/statfs.h"
+        export *
+      }
+      module statvfs {
+        header "sys/statvfs.h"
+        export *
+      }
+      module time {
+        header "sys/time.h"
+        export *
+      }
+      module times {
+        header "sys/times.h"
+        export *
+      }
+      module types {
+        header "sys/types.h"
+        export *
+      }
+      module uio {
+        header "sys/uio.h"
+        export *
+      }
+      module un {
+        header "sys/un.h"
+        export *
+      }
+      module utsname {
+        header "sys/utsname.h"
+        export *
+      }
+      module wait {
+        header "sys/wait.h"
+        export *
+      }
+      export *
+    }
+    export *
+  }
+  export *
+}
+
+// Headers that exist that are part of POSIX, C, or GNU that are not functional on Fuchsia
+module NonLibc [extern_c] {
+  use Libc
+
+  module crypt { // POSIX
+    header "crypt.h"
+    export *
+  }
+  module ftw { // POSIX
+    header "ftw.h"
+    export *
+  }
+  module grp { // POSIX
+    header "grp.h" // Non-functional in Fuchsia
+    export *
+  }
+  module mntent { // Unimplemented - common header
+    header "mntent.h" // Unimplemented in Fuchsia
+    export *
+  }
+  module paths { // GNU extension
+    header "paths.h" // Defines paths are not correct for Fuchsia
+    export *
+  }
+  module pty { // BSD defined (also GLIBC).
+    header "pty.h" // Non-functional on Fuchsia
+    export *
+  }
+  module pwd { // POSIX
+    header "pwd.h" // Non-functional in Fuchsia
+    export *
+  }
+  module shadown { // POSIX
+    header "shadow.h"
+    export *
+  }
+  module spawn { // POSIX
+    header "spawn.h" // Process management - use launchpad instead
+    export *
+  }
+  module syslog { // POSIX
+    header "syslog.h"
+    export *
+  }
+  module termios { // POSIX
+    header "termios.h"
+    export *
+  }
+  module ucontext { // POSIX
+    header "ucontext.h"
+    export *
+  }
+  export *
+}