]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
refactor: move sysroot compat headers into project + update build.sh
authorTulio A M Mendes <[email protected]>
Sat, 14 Mar 2026 09:11:24 +0000 (06:11 -0300)
committerTulio A M Mendes <[email protected]>
Sat, 14 Mar 2026 09:11:24 +0000 (06:11 -0300)
All 71 Linux/POSIX compatibility headers that were previously created
directly in /opt/adros-toolchain/i686-adros/include/ are now stored
in newlib/sysroot_headers/ and installed by build.sh via cp -r.

Headers include: asm/*, linux/*, net/*, netinet/*, netpacket/*,
sys/socket.h, sys/mman.h, sys/mount.h, sys/epoll.h, poll.h, netdb.h,
mntent.h, paths.h, shadow.h, syslog.h, utmp.h, endian.h, byteswap.h,
features.h, dlfcn.h, ifaddrs.h, arpa/telnet.h, and more.

Also moved existing inline heredoc headers (sys/ioctl.h, sys/termios.h,
sys/dirent.h) from build.sh into sysroot_headers/ for consistency.

Newlib header patches (sys/stat.h, sys/signal.h, sys/wait.h, glob.h)
are now applied via idempotent sed commands in build.sh:
- sys/stat.h: expose lstat()/mknod() for __adros__
- sys/signal.h: add SA_RESTART/SA_NODEFER/SA_RESETHAND/SA_NOCLDWAIT
- sys/wait.h: add WCOREDUMP macro
- glob.h: add GLOB_NOMATCH

build.sh also updated to compile posix_compat.c into libadros.a.

Tests: 101/101 smoke, cppcheck clean

72 files changed:
newlib/sysroot_headers/arpa/telnet.h [new file with mode: 0644]
newlib/sysroot_headers/asm/ioctls.h [new file with mode: 0644]
newlib/sysroot_headers/asm/termios.h [new file with mode: 0644]
newlib/sysroot_headers/asm/types.h [new file with mode: 0644]
newlib/sysroot_headers/asm/unistd.h [new file with mode: 0644]
newlib/sysroot_headers/byteswap.h [new file with mode: 0644]
newlib/sysroot_headers/dlfcn.h [new file with mode: 0644]
newlib/sysroot_headers/endian.h [new file with mode: 0644]
newlib/sysroot_headers/features.h [new file with mode: 0644]
newlib/sysroot_headers/ifaddrs.h [new file with mode: 0644]
newlib/sysroot_headers/linux/capability.h [new file with mode: 0644]
newlib/sysroot_headers/linux/elf-em.h [new file with mode: 0644]
newlib/sysroot_headers/linux/ethtool.h [new file with mode: 0644]
newlib/sysroot_headers/linux/fb.h [new file with mode: 0644]
newlib/sysroot_headers/linux/fd.h [new file with mode: 0644]
newlib/sysroot_headers/linux/filter.h [new file with mode: 0644]
newlib/sysroot_headers/linux/fs.h [new file with mode: 0644]
newlib/sysroot_headers/linux/hdreg.h [new file with mode: 0644]
newlib/sysroot_headers/linux/i2c.h [new file with mode: 0644]
newlib/sysroot_headers/linux/if.h [new file with mode: 0644]
newlib/sysroot_headers/linux/if_addr.h [new file with mode: 0644]
newlib/sysroot_headers/linux/if_arp.h [new file with mode: 0644]
newlib/sysroot_headers/linux/if_bonding.h [new file with mode: 0644]
newlib/sysroot_headers/linux/if_infiniband.h [new file with mode: 0644]
newlib/sysroot_headers/linux/if_link.h [new file with mode: 0644]
newlib/sysroot_headers/linux/if_packet.h [new file with mode: 0644]
newlib/sysroot_headers/linux/if_tun.h [new file with mode: 0644]
newlib/sysroot_headers/linux/if_vlan.h [new file with mode: 0644]
newlib/sysroot_headers/linux/input.h [new file with mode: 0644]
newlib/sysroot_headers/linux/jffs2.h [new file with mode: 0644]
newlib/sysroot_headers/linux/kd.h [new file with mode: 0644]
newlib/sysroot_headers/linux/major.h [new file with mode: 0644]
newlib/sysroot_headers/linux/mii.h [new file with mode: 0644]
newlib/sysroot_headers/linux/msdos_fs.h [new file with mode: 0644]
newlib/sysroot_headers/linux/neighbour.h [new file with mode: 0644]
newlib/sysroot_headers/linux/netlink.h [new file with mode: 0644]
newlib/sysroot_headers/linux/pkt_sched.h [new file with mode: 0644]
newlib/sysroot_headers/mntent.h [new file with mode: 0644]
newlib/sysroot_headers/net/ethernet.h [new file with mode: 0644]
newlib/sysroot_headers/net/if.h [new file with mode: 0644]
newlib/sysroot_headers/net/route.h [new file with mode: 0644]
newlib/sysroot_headers/netdb.h [new file with mode: 0644]
newlib/sysroot_headers/netinet/in.h [new file with mode: 0644]
newlib/sysroot_headers/netinet/tcp.h [new file with mode: 0644]
newlib/sysroot_headers/netinet/udp.h [new file with mode: 0644]
newlib/sysroot_headers/netpacket/packet.h [new file with mode: 0644]
newlib/sysroot_headers/paths.h [new file with mode: 0644]
newlib/sysroot_headers/poll.h [new file with mode: 0644]
newlib/sysroot_headers/shadow.h [new file with mode: 0644]
newlib/sysroot_headers/sys/dirent.h [new file with mode: 0644]
newlib/sysroot_headers/sys/epoll.h [new file with mode: 0644]
newlib/sysroot_headers/sys/ioctl.h [new file with mode: 0644]
newlib/sysroot_headers/sys/mman.h [new file with mode: 0644]
newlib/sysroot_headers/sys/mount.h [new file with mode: 0644]
newlib/sysroot_headers/sys/poll.h [new file with mode: 0644]
newlib/sysroot_headers/sys/prctl.h [new file with mode: 0644]
newlib/sysroot_headers/sys/reboot.h [new file with mode: 0644]
newlib/sysroot_headers/sys/resource.h [new file with mode: 0644]
newlib/sysroot_headers/sys/sendfile.h [new file with mode: 0644]
newlib/sysroot_headers/sys/socket.h [new file with mode: 0644]
newlib/sysroot_headers/sys/statfs.h [new file with mode: 0644]
newlib/sysroot_headers/sys/swap.h [new file with mode: 0644]
newlib/sysroot_headers/sys/sysinfo.h [new file with mode: 0644]
newlib/sysroot_headers/sys/sysmacros.h [new file with mode: 0644]
newlib/sysroot_headers/sys/termios.h [new file with mode: 0644]
newlib/sysroot_headers/sys/un.h [new file with mode: 0644]
newlib/sysroot_headers/sys/utsname.h [new file with mode: 0644]
newlib/sysroot_headers/sys/vfs.h [new file with mode: 0644]
newlib/sysroot_headers/syslog.h [new file with mode: 0644]
newlib/sysroot_headers/utmp.h [new file with mode: 0644]
newlib/sysroot_headers/utmpx.h [new file with mode: 0644]
toolchain/build.sh

diff --git a/newlib/sysroot_headers/arpa/telnet.h b/newlib/sysroot_headers/arpa/telnet.h
new file mode 100644 (file)
index 0000000..624e2a0
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef _ARPA_TELNET_H
+#define _ARPA_TELNET_H
+#define IAC  255
+#define DONT 254
+#define DO   253
+#define WONT 252
+#define WILL 251
+#define SB   250
+#define SE   240
+#define TELOPT_ECHO 1
+#define TELOPT_SGA  3
+#define TELOPT_TTYPE 24
+#define TELOPT_NAWS  31
+#endif
diff --git a/newlib/sysroot_headers/asm/ioctls.h b/newlib/sysroot_headers/asm/ioctls.h
new file mode 100644 (file)
index 0000000..364405b
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _ASM_IOCTLS_H
+#define _ASM_IOCTLS_H
+#include <sys/ioctl.h>
+#endif
diff --git a/newlib/sysroot_headers/asm/termios.h b/newlib/sysroot_headers/asm/termios.h
new file mode 100644 (file)
index 0000000..c948fb9
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _ASM_TERMIOS_H
+#define _ASM_TERMIOS_H
+#include <sys/termios.h>
+#endif
diff --git a/newlib/sysroot_headers/asm/types.h b/newlib/sysroot_headers/asm/types.h
new file mode 100644 (file)
index 0000000..1c43b59
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _ASM_TYPES_H
+#define _ASM_TYPES_H
+#include <stdint.h>
+typedef uint8_t  __u8;
+typedef uint16_t __u16;
+typedef uint32_t __u32;
+typedef uint64_t __u64;
+typedef int8_t   __s8;
+typedef int16_t  __s16;
+typedef int32_t  __s32;
+typedef int64_t  __s64;
+#endif
diff --git a/newlib/sysroot_headers/asm/unistd.h b/newlib/sysroot_headers/asm/unistd.h
new file mode 100644 (file)
index 0000000..251c080
--- /dev/null
@@ -0,0 +1,3 @@
+#ifndef _ASM_UNISTD_H
+#define _ASM_UNISTD_H
+#endif
diff --git a/newlib/sysroot_headers/byteswap.h b/newlib/sysroot_headers/byteswap.h
new file mode 100644 (file)
index 0000000..090b19b
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef _BYTESWAP_H
+#define _BYTESWAP_H
+
+#include <stdint.h>
+
+static inline uint16_t bswap_16(uint16_t x) {
+    return (uint16_t)((x >> 8) | (x << 8));
+}
+
+static inline uint32_t bswap_32(uint32_t x) {
+    return ((x >> 24) & 0x000000FFU) |
+           ((x >>  8) & 0x0000FF00U) |
+           ((x <<  8) & 0x00FF0000U) |
+           ((x << 24) & 0xFF000000U);
+}
+
+static inline uint64_t bswap_64(uint64_t x) {
+    return ((uint64_t)bswap_32((uint32_t)x) << 32) |
+           (uint64_t)bswap_32((uint32_t)(x >> 32));
+}
+
+#endif
diff --git a/newlib/sysroot_headers/dlfcn.h b/newlib/sysroot_headers/dlfcn.h
new file mode 100644 (file)
index 0000000..b62e4b7
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef _DLFCN_H
+#define _DLFCN_H
+#define RTLD_LAZY   1
+#define RTLD_NOW    2
+#define RTLD_GLOBAL 0x100
+#define RTLD_LOCAL  0
+void* dlopen(const char* filename, int flags);
+void* dlsym(void* handle, const char* symbol);
+int dlclose(void* handle);
+char* dlerror(void);
+#endif
diff --git a/newlib/sysroot_headers/endian.h b/newlib/sysroot_headers/endian.h
new file mode 100644 (file)
index 0000000..f6b704f
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef _ENDIAN_H
+#define _ENDIAN_H
+
+#define __LITTLE_ENDIAN 1234
+#define __BIG_ENDIAN    4321
+#define __BYTE_ORDER    __LITTLE_ENDIAN
+
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#define BIG_ENDIAN    __BIG_ENDIAN
+#define BYTE_ORDER    __BYTE_ORDER
+
+#include <byteswap.h>
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define htobe16(x) bswap_16(x)
+#define htole16(x) (x)
+#define be16toh(x) bswap_16(x)
+#define le16toh(x) (x)
+#define htobe32(x) bswap_32(x)
+#define htole32(x) (x)
+#define be32toh(x) bswap_32(x)
+#define le32toh(x) (x)
+#define htobe64(x) bswap_64(x)
+#define htole64(x) (x)
+#define be64toh(x) bswap_64(x)
+#define le64toh(x) (x)
+#endif
+
+#endif
diff --git a/newlib/sysroot_headers/features.h b/newlib/sysroot_headers/features.h
new file mode 100644 (file)
index 0000000..34ed8b1
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef _FEATURES_H
+#define _FEATURES_H
+
+/* Minimal features.h for AdrOS/newlib */
+#ifndef __GLIBC__
+#define __GLIBC__ 2
+#define __GLIBC_MINOR__ 0
+#endif
+
+#ifndef _DEFAULT_SOURCE
+#define _DEFAULT_SOURCE 1
+#endif
+
+#ifndef _GNU_SOURCE
+/* leave undefined unless explicitly requested */
+#endif
+
+#endif
diff --git a/newlib/sysroot_headers/ifaddrs.h b/newlib/sysroot_headers/ifaddrs.h
new file mode 100644 (file)
index 0000000..c8d291a
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef _IFADDRS_H
+#define _IFADDRS_H
+#include <sys/socket.h>
+struct ifaddrs {
+    struct ifaddrs* ifa_next;
+    char* ifa_name;
+    unsigned int ifa_flags;
+    struct sockaddr* ifa_addr;
+    struct sockaddr* ifa_netmask;
+    struct sockaddr* ifa_broadaddr;
+    void* ifa_data;
+};
+int getifaddrs(struct ifaddrs** ifap);
+void freeifaddrs(struct ifaddrs* ifa);
+#endif
diff --git a/newlib/sysroot_headers/linux/capability.h b/newlib/sysroot_headers/linux/capability.h
new file mode 100644 (file)
index 0000000..2f7bd20
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef _LINUX_CAPABILITY_H
+#define _LINUX_CAPABILITY_H
+#include <stdint.h>
+typedef struct { uint32_t version; int pid; } cap_header_t;
+typedef struct { uint32_t effective; uint32_t permitted; uint32_t inheritable; } cap_data_t;
+#define CAP_NET_RAW 13
+#define CAP_SYS_ADMIN 21
+#endif
diff --git a/newlib/sysroot_headers/linux/elf-em.h b/newlib/sysroot_headers/linux/elf-em.h
new file mode 100644 (file)
index 0000000..20380ea
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_ELF_EM_H
+#define _LINUX_ELF_EM_H
+/* Stub for AdrOS */
+#endif
diff --git a/newlib/sysroot_headers/linux/ethtool.h b/newlib/sysroot_headers/linux/ethtool.h
new file mode 100644 (file)
index 0000000..6811980
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_ETHTOOL_H
+#define _LINUX_ETHTOOL_H
+/* Stub for AdrOS */
+#endif
diff --git a/newlib/sysroot_headers/linux/fb.h b/newlib/sysroot_headers/linux/fb.h
new file mode 100644 (file)
index 0000000..6bf6458
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef _LINUX_FB_H
+#define _LINUX_FB_H
+#include <stdint.h>
+struct fb_fix_screeninfo {
+    char id[16]; unsigned long smem_start; uint32_t smem_len;
+    uint32_t type; uint32_t visual; uint16_t xpanstep; uint16_t ypanstep;
+    uint16_t ywrapstep; uint32_t line_length; unsigned long mmio_start;
+    uint32_t mmio_len; uint32_t accel;
+};
+struct fb_bitfield { uint32_t offset; uint32_t length; uint32_t msb_right; };
+struct fb_var_screeninfo {
+    uint32_t xres; uint32_t yres; uint32_t xres_virtual; uint32_t yres_virtual;
+    uint32_t xoffset; uint32_t yoffset; uint32_t bits_per_pixel; uint32_t grayscale;
+    struct fb_bitfield red; struct fb_bitfield green; struct fb_bitfield blue;
+    struct fb_bitfield transp;
+};
+#define FBIOGET_VSCREENINFO 0x4600
+#define FBIOPUT_VSCREENINFO 0x4601
+#define FBIOGET_FSCREENINFO 0x4602
+#endif
diff --git a/newlib/sysroot_headers/linux/fd.h b/newlib/sysroot_headers/linux/fd.h
new file mode 100644 (file)
index 0000000..9af8bb8
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_FD_H
+#define _LINUX_FD_H
+/* Stub for AdrOS */
+#endif
diff --git a/newlib/sysroot_headers/linux/filter.h b/newlib/sysroot_headers/linux/filter.h
new file mode 100644 (file)
index 0000000..7949e49
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_FILTER_H
+#define _LINUX_FILTER_H
+/* Stub for AdrOS */
+#endif
diff --git a/newlib/sysroot_headers/linux/fs.h b/newlib/sysroot_headers/linux/fs.h
new file mode 100644 (file)
index 0000000..b63e9d9
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef _LINUX_FS_H
+#define _LINUX_FS_H
+#define BLKGETSIZE   0x1260
+#define BLKGETSIZE64 0x80041272
+#define BLKFLSBUF    0x1261
+#define BLKROSET     0x125D
+#define BLKROGET     0x125E
+#define BLKSSZGET    0x1268
+#define BLKRRPART    0x125F
+#define FIBMAP       1
+#define FIGETBSZ     2
+#define FS_IOC_GETFLAGS 0x80046601
+#define FS_IOC_SETFLAGS 0x40046602
+#endif
diff --git a/newlib/sysroot_headers/linux/hdreg.h b/newlib/sysroot_headers/linux/hdreg.h
new file mode 100644 (file)
index 0000000..61a4fce
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _LINUX_HDREG_H
+#define _LINUX_HDREG_H
+struct hd_driveid { unsigned short config; /* empty stub */ };
+#define HDIO_GET_IDENTITY 0x030D
+#endif
diff --git a/newlib/sysroot_headers/linux/i2c.h b/newlib/sysroot_headers/linux/i2c.h
new file mode 100644 (file)
index 0000000..b5ee70e
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_I2C_H
+#define _LINUX_I2C_H
+/* Stub for AdrOS */
+#endif
diff --git a/newlib/sysroot_headers/linux/if.h b/newlib/sysroot_headers/linux/if.h
new file mode 100644 (file)
index 0000000..c5e0069
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_IF_H
+#define _LINUX_IF_H
+#include <net/if.h>
+#endif
diff --git a/newlib/sysroot_headers/linux/if_addr.h b/newlib/sysroot_headers/linux/if_addr.h
new file mode 100644 (file)
index 0000000..f3445cb
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_IF_ADDR_H
+#define _LINUX_IF_ADDR_H
+#include <net/if.h>
+#endif
diff --git a/newlib/sysroot_headers/linux/if_arp.h b/newlib/sysroot_headers/linux/if_arp.h
new file mode 100644 (file)
index 0000000..bc59968
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_IF_ARP_H
+#define _LINUX_IF_ARP_H
+#include <net/if.h>
+#endif
diff --git a/newlib/sysroot_headers/linux/if_bonding.h b/newlib/sysroot_headers/linux/if_bonding.h
new file mode 100644 (file)
index 0000000..de114b4
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_IF_BONDING_H
+#define _LINUX_IF_BONDING_H
+#include <net/if.h>
+#endif
diff --git a/newlib/sysroot_headers/linux/if_infiniband.h b/newlib/sysroot_headers/linux/if_infiniband.h
new file mode 100644 (file)
index 0000000..f5d3bb3
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_IF_INFINIBAND_H
+#define _LINUX_IF_INFINIBAND_H
+#include <net/if.h>
+#endif
diff --git a/newlib/sysroot_headers/linux/if_link.h b/newlib/sysroot_headers/linux/if_link.h
new file mode 100644 (file)
index 0000000..4365748
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_IF_LINK_H
+#define _LINUX_IF_LINK_H
+#include <net/if.h>
+#endif
diff --git a/newlib/sysroot_headers/linux/if_packet.h b/newlib/sysroot_headers/linux/if_packet.h
new file mode 100644 (file)
index 0000000..c3ccc95
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_IF_PACKET_H
+#define _LINUX_IF_PACKET_H
+#include <net/if.h>
+#endif
diff --git a/newlib/sysroot_headers/linux/if_tun.h b/newlib/sysroot_headers/linux/if_tun.h
new file mode 100644 (file)
index 0000000..61e377a
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_IF_TUN_H
+#define _LINUX_IF_TUN_H
+#include <net/if.h>
+#endif
diff --git a/newlib/sysroot_headers/linux/if_vlan.h b/newlib/sysroot_headers/linux/if_vlan.h
new file mode 100644 (file)
index 0000000..0a9fad7
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_IF_VLAN_H
+#define _LINUX_IF_VLAN_H
+#include <net/if.h>
+#endif
diff --git a/newlib/sysroot_headers/linux/input.h b/newlib/sysroot_headers/linux/input.h
new file mode 100644 (file)
index 0000000..a0b4163
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _LINUX_INPUT_H
+#define _LINUX_INPUT_H
+#include <stdint.h>
+struct input_event {
+    struct { uint32_t tv_sec; uint32_t tv_usec; } time;
+    uint16_t type; uint16_t code; int32_t value;
+};
+#define EV_SYN 0x00
+#define EV_KEY 0x01
+#define EV_REL 0x02
+#define EV_ABS 0x03
+#endif
diff --git a/newlib/sysroot_headers/linux/jffs2.h b/newlib/sysroot_headers/linux/jffs2.h
new file mode 100644 (file)
index 0000000..46032d6
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_JFFS2_H
+#define _LINUX_JFFS2_H
+/* Stub for AdrOS */
+#endif
diff --git a/newlib/sysroot_headers/linux/kd.h b/newlib/sysroot_headers/linux/kd.h
new file mode 100644 (file)
index 0000000..c9b1448
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef _LINUX_KD_H
+#define _LINUX_KD_H
+#define KDGKBTYPE 0x4B33
+#define KB_84     0x01
+#define KB_101    0x02
+#define KB_OTHER  0x03
+#define KDSETMODE 0x4B3A
+#define KDGETMODE 0x4B3B
+#define KD_TEXT   0x00
+#define KD_GRAPHICS 0x01
+#endif
diff --git a/newlib/sysroot_headers/linux/major.h b/newlib/sysroot_headers/linux/major.h
new file mode 100644 (file)
index 0000000..3e32641
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _LINUX_MAJOR_H
+#define _LINUX_MAJOR_H
+#define MEM_MAJOR 1
+#define TTY_MAJOR 4
+#define TTYAUX_MAJOR 5
+#define LP_MAJOR 6
+#define LOOP_MAJOR 7
+#define SCSI_DISK0_MAJOR 8
+#define MISC_MAJOR 10
+#define IDE0_MAJOR 3
+#define IDE1_MAJOR 22
+#endif
diff --git a/newlib/sysroot_headers/linux/mii.h b/newlib/sysroot_headers/linux/mii.h
new file mode 100644 (file)
index 0000000..6bedf40
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_MII_H
+#define _LINUX_MII_H
+/* Stub for AdrOS */
+#endif
diff --git a/newlib/sysroot_headers/linux/msdos_fs.h b/newlib/sysroot_headers/linux/msdos_fs.h
new file mode 100644 (file)
index 0000000..2a82616
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_MSDOS_FS_H
+#define _LINUX_MSDOS_FS_H
+/* Stub for AdrOS */
+#endif
diff --git a/newlib/sysroot_headers/linux/neighbour.h b/newlib/sysroot_headers/linux/neighbour.h
new file mode 100644 (file)
index 0000000..6538461
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef _LINUX_NEIGHBOUR_H
+#define _LINUX_NEIGHBOUR_H
+struct ndmsg { unsigned char ndm_family; int ndm_ifindex; uint16_t ndm_state; uint8_t ndm_flags; uint8_t ndm_type; };
+#define NDA_DST 1
+#define NDA_LLADDR 2
+#define NUD_INCOMPLETE 0x01
+#define NUD_REACHABLE 0x02
+#define NUD_STALE 0x04
+#endif
diff --git a/newlib/sysroot_headers/linux/netlink.h b/newlib/sysroot_headers/linux/netlink.h
new file mode 100644 (file)
index 0000000..564b8a8
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef _LINUX_NETLINK_H
+#define _LINUX_NETLINK_H
+#include <stdint.h>
+struct sockaddr_nl { uint16_t nl_family; uint16_t nl_pad; uint32_t nl_pid; uint32_t nl_groups; };
+struct nlmsghdr { uint32_t nlmsg_len; uint16_t nlmsg_type; uint16_t nlmsg_flags; uint32_t nlmsg_seq; uint32_t nlmsg_pid; };
+#define NETLINK_ROUTE 0
+#define NLM_F_REQUEST 1
+#define NLM_F_MULTI 2
+#define NLM_F_ROOT 0x100
+#define NLM_F_MATCH 0x200
+#define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH)
+#define NLMSG_ALIGNTO 4
+#define NLMSG_ALIGN(len) (((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1))
+#define NLMSG_HDRLEN ((int)NLMSG_ALIGN(sizeof(struct nlmsghdr)))
+#define NLMSG_LENGTH(len) ((len)+NLMSG_HDRLEN)
+#define NLMSG_DATA(nlh) ((void*)(((char*)(nlh))+NLMSG_HDRLEN))
+#define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), (struct nlmsghdr*)(((char*)(nlh))+NLMSG_ALIGN((nlh)->nlmsg_len)))
+#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && (nlh)->nlmsg_len <= (unsigned int)(len))
+#define NLMSG_DONE 3
+#define NLMSG_ERROR 2
+#define RTM_NEWLINK 16
+#define RTM_GETLINK 18
+#define RTM_NEWADDR 20
+#define RTM_GETADDR 22
+#define RTM_NEWROUTE 24
+#define RTM_GETROUTE 26
+#define RTM_NEWNEIGH 28
+#define RTM_GETNEIGH 30
+#endif
diff --git a/newlib/sysroot_headers/linux/pkt_sched.h b/newlib/sysroot_headers/linux/pkt_sched.h
new file mode 100644 (file)
index 0000000..241c776
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _LINUX_PKT_SCHED_H
+#define _LINUX_PKT_SCHED_H
+/* Stub for AdrOS */
+#endif
diff --git a/newlib/sysroot_headers/mntent.h b/newlib/sysroot_headers/mntent.h
new file mode 100644 (file)
index 0000000..b14739e
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _MNTENT_H
+#define _MNTENT_H
+#include <stdio.h>
+struct mntent {
+    char* mnt_fsname; char* mnt_dir; char* mnt_type;
+    char* mnt_opts; int mnt_freq; int mnt_passno;
+};
+#define MOUNTED "/etc/mtab"
+FILE* setmntent(const char* filename, const char* type);
+struct mntent* getmntent(FILE* fp);
+int endmntent(FILE* fp);
+#endif
diff --git a/newlib/sysroot_headers/net/ethernet.h b/newlib/sysroot_headers/net/ethernet.h
new file mode 100644 (file)
index 0000000..937eea2
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef _NET_ETHERNET_H
+#define _NET_ETHERNET_H
+#include <stdint.h>
+#define ETH_ALEN 6
+struct ether_header {
+    uint8_t ether_dhost[ETH_ALEN];
+    uint8_t ether_shost[ETH_ALEN];
+    uint16_t ether_type;
+};
+#endif
diff --git a/newlib/sysroot_headers/net/if.h b/newlib/sysroot_headers/net/if.h
new file mode 100644 (file)
index 0000000..f580cda
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef _NET_IF_H
+#define _NET_IF_H
+#define IF_NAMESIZE 16
+#define IFNAMSIZ IF_NAMESIZE
+struct ifreq {
+    char ifr_name[IFNAMSIZ];
+    union {
+        struct sockaddr ifr_addr;
+        struct sockaddr ifr_dstaddr;
+        struct sockaddr ifr_broadaddr;
+        struct sockaddr ifr_netmask;
+        short ifr_flags;
+        int ifr_ifindex;
+        int ifr_metric;
+        int ifr_mtu;
+        char ifr_slave[IFNAMSIZ];
+        char ifr_newname[IFNAMSIZ];
+        void* ifr_data;
+    };
+};
+unsigned int if_nametoindex(const char* ifname);
+char* if_indextoname(unsigned int ifindex, char* ifname);
+#endif
diff --git a/newlib/sysroot_headers/net/route.h b/newlib/sysroot_headers/net/route.h
new file mode 100644 (file)
index 0000000..9b9067a
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef _NET_ROUTE_H
+#define _NET_ROUTE_H
+#include <sys/socket.h>
+struct rtentry {
+    unsigned long rt_pad1;
+    struct sockaddr rt_dst;
+    struct sockaddr rt_gateway;
+    struct sockaddr rt_genmask;
+    unsigned short rt_flags;
+    short rt_pad2;
+    unsigned long rt_pad3;
+    void* rt_pad4;
+    short rt_metric;
+    char* rt_dev;
+    unsigned long rt_mtu;
+    unsigned long rt_window;
+    unsigned short rt_irtt;
+};
+#define RTF_UP      0x0001
+#define RTF_GATEWAY 0x0002
+#define RTF_HOST    0x0004
+#endif
diff --git a/newlib/sysroot_headers/netdb.h b/newlib/sysroot_headers/netdb.h
new file mode 100644 (file)
index 0000000..7b5ce73
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef _NETDB_H
+#define _NETDB_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+struct hostent {
+    char* h_name;
+    char** h_aliases;
+    int h_addrtype;
+    int h_length;
+    char** h_addr_list;
+};
+
+struct servent {
+    char* s_name;
+    char** s_aliases;
+    int s_port;
+    char* s_proto;
+};
+
+struct addrinfo {
+    int ai_flags;
+    int ai_family;
+    int ai_socktype;
+    int ai_protocol;
+    unsigned int ai_addrlen;
+    struct sockaddr* ai_addr;
+    char* ai_canonname;
+    struct addrinfo* ai_next;
+};
+
+#define AI_PASSIVE     1
+#define AI_CANONNAME   2
+#define AI_NUMERICHOST 4
+#define NI_MAXHOST     1025
+#define NI_MAXSERV     32
+#define NI_NUMERICHOST 1
+#define NI_NUMERICSERV 2
+#define NI_NAMEREQD    8
+#define NI_DGRAM       16
+#define NI_NOFQDN      4
+
+extern int h_errno;
+#define HOST_NOT_FOUND 1
+#define TRY_AGAIN 2
+#define NO_RECOVERY 3
+#define NO_DATA 4
+
+struct hostent* gethostbyname(const char* name);
+struct hostent* gethostbyaddr(const void* addr, unsigned int len, int type);
+struct servent* getservbyname(const char* name, const char* proto);
+int getaddrinfo(const char* node, const char* service,
+                const struct addrinfo* hints, struct addrinfo** res);
+void freeaddrinfo(struct addrinfo* res);
+const char* gai_strerror(int errcode);
+int getnameinfo(const void* sa, unsigned int salen,
+                char* host, unsigned int hostlen,
+                char* serv, unsigned int servlen, int flags);
+
+#endif
diff --git a/newlib/sysroot_headers/netinet/in.h b/newlib/sysroot_headers/netinet/in.h
new file mode 100644 (file)
index 0000000..c001491
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef _NETINET_IN_H
+#define _NETINET_IN_H
+#include <stdint.h>
+#include <sys/socket.h>
+#define IPPROTO_IP   0
+#define IPPROTO_ICMP 1
+#define IPPROTO_TCP  6
+#define IPPROTO_UDP  17
+#define INADDR_ANY       ((uint32_t)0x00000000)
+#define INADDR_BROADCAST ((uint32_t)0xffffffff)
+#define INADDR_LOOPBACK  ((uint32_t)0x7f000001)
+#define INET_ADDRSTRLEN  16
+#define INET6_ADDRSTRLEN 46
+struct in_addr { uint32_t s_addr; };
+struct sockaddr_in {
+    uint16_t sin_family;
+    uint16_t sin_port;
+    struct in_addr sin_addr;
+    char sin_zero[8];
+};
+struct in6_addr { uint8_t s6_addr[16]; };
+struct sockaddr_in6 {
+    uint16_t sin6_family; uint16_t sin6_port;
+    uint32_t sin6_flowinfo; struct in6_addr sin6_addr;
+    uint32_t sin6_scope_id;
+};
+uint32_t htonl(uint32_t hostlong);
+uint16_t htons(uint16_t hostshort);
+uint32_t ntohl(uint32_t netlong);
+uint16_t ntohs(uint16_t netshort);
+#endif
diff --git a/newlib/sysroot_headers/netinet/tcp.h b/newlib/sysroot_headers/netinet/tcp.h
new file mode 100644 (file)
index 0000000..83ce91e
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _NETINET_TCP_H
+#define _NETINET_TCP_H
+#define TCP_NODELAY 1
+#endif
diff --git a/newlib/sysroot_headers/netinet/udp.h b/newlib/sysroot_headers/netinet/udp.h
new file mode 100644 (file)
index 0000000..36db648
--- /dev/null
@@ -0,0 +1,3 @@
+#ifndef _NETINET_UDP_H
+#define _NETINET_UDP_H
+#endif
diff --git a/newlib/sysroot_headers/netpacket/packet.h b/newlib/sysroot_headers/netpacket/packet.h
new file mode 100644 (file)
index 0000000..482f025
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _NETPACKET_PACKET_H
+#define _NETPACKET_PACKET_H
+struct sockaddr_ll {
+    unsigned short sll_family; unsigned short sll_protocol;
+    int sll_ifindex; unsigned short sll_hatype;
+    unsigned char sll_pkttype; unsigned char sll_halen;
+    unsigned char sll_addr[8];
+};
+#define PACKET_HOST 0
+#define PACKET_BROADCAST 1
+#define PACKET_MULTICAST 2
+#endif
diff --git a/newlib/sysroot_headers/paths.h b/newlib/sysroot_headers/paths.h
new file mode 100644 (file)
index 0000000..092b4cc
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef _PATHS_H
+#define _PATHS_H
+#define _PATH_CONSOLE "/dev/console"
+#define _PATH_TTY "/dev/tty"
+#define _PATH_DEVNULL "/dev/null"
+#define _PATH_TMP "/tmp/"
+#define _PATH_VARRUN "/var/run/"
+#define _PATH_DEFPATH "/usr/bin:/bin"
+#define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_WTMP "/var/log/wtmp"
+#define _PATH_UTMP "/var/run/utmp"
+#define _PATH_SHADOW "/etc/shadow"
+#define _PATH_PASSWD "/etc/passwd"
+#define _PATH_NOLOGIN "/etc/nologin"
+#define _PATH_MOUNTED "/etc/mtab"
+#define _PATH_MNTTAB "/etc/fstab"
+#endif
diff --git a/newlib/sysroot_headers/poll.h b/newlib/sysroot_headers/poll.h
new file mode 100644 (file)
index 0000000..7155061
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _POLL_H
+#define _POLL_H
+#define POLLIN   0x0001
+#define POLLPRI  0x0002
+#define POLLOUT  0x0004
+#define POLLERR  0x0008
+#define POLLHUP  0x0010
+#define POLLNVAL 0x0020
+struct pollfd { int fd; short events; short revents; };
+typedef unsigned int nfds_t;
+int poll(struct pollfd* fds, nfds_t nfds, int timeout);
+#endif
diff --git a/newlib/sysroot_headers/shadow.h b/newlib/sysroot_headers/shadow.h
new file mode 100644 (file)
index 0000000..38ec256
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef _SHADOW_H
+#define _SHADOW_H
+struct spwd {
+    char* sp_namp; char* sp_pwdp;
+    long sp_lstchg; long sp_min; long sp_max;
+    long sp_warn; long sp_inact; long sp_expire;
+    unsigned long sp_flag;
+};
+struct spwd* getspnam(const char* name);
+void endspent(void);
+#endif
diff --git a/newlib/sysroot_headers/sys/dirent.h b/newlib/sysroot_headers/sys/dirent.h
new file mode 100644 (file)
index 0000000..1b57a23
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef _SYS_DIRENT_H
+#define _SYS_DIRENT_H
+
+#include <sys/types.h>
+
+#define MAXNAMLEN 255
+
+struct dirent {
+    ino_t  d_ino;
+    char   d_name[MAXNAMLEN + 1];
+};
+
+typedef struct {
+    int    dd_fd;
+    int    dd_loc;
+    int    dd_size;
+    char  *dd_buf;
+} DIR;
+
+DIR *opendir(const char *);
+struct dirent *readdir(DIR *);
+int closedir(DIR *);
+void rewinddir(DIR *);
+
+#endif /* _SYS_DIRENT_H */
diff --git a/newlib/sysroot_headers/sys/epoll.h b/newlib/sysroot_headers/sys/epoll.h
new file mode 100644 (file)
index 0000000..ad36855
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef _SYS_EPOLL_H
+#define _SYS_EPOLL_H
+#include <stdint.h>
+#define EPOLLIN  1
+#define EPOLLOUT 4
+#define EPOLLERR 8
+#define EPOLLHUP 16
+typedef union epoll_data { void* ptr; int fd; uint32_t u32; uint64_t u64; } epoll_data_t;
+struct epoll_event { uint32_t events; epoll_data_t data; };
+int epoll_create(int size);
+int epoll_ctl(int epfd, int op, int fd, struct epoll_event* event);
+int epoll_wait(int epfd, struct epoll_event* events, int maxevents, int timeout);
+#define EPOLL_CTL_ADD 1
+#define EPOLL_CTL_DEL 2
+#define EPOLL_CTL_MOD 3
+#endif
diff --git a/newlib/sysroot_headers/sys/ioctl.h b/newlib/sysroot_headers/sys/ioctl.h
new file mode 100644 (file)
index 0000000..81e8177
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef _SYS_IOCTL_H
+#define _SYS_IOCTL_H
+
+/* Minimal ioctl definitions for AdrOS */
+#define TIOCGPGRP 0x540F
+#define TIOCSPGRP 0x5410
+#define TIOCGWINSZ 0x5413
+#define TIOCSWINSZ 0x5414
+#define FIONREAD  0x541B
+
+struct winsize {
+    unsigned short ws_row;
+    unsigned short ws_col;
+    unsigned short ws_xpixel;
+    unsigned short ws_ypixel;
+};
+
+int ioctl(int fd, unsigned long request, ...);
+
+#endif /* _SYS_IOCTL_H */
diff --git a/newlib/sysroot_headers/sys/mman.h b/newlib/sysroot_headers/sys/mman.h
new file mode 100644 (file)
index 0000000..47b6b96
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef _SYS_MMAN_H
+#define _SYS_MMAN_H
+#include <sys/types.h>
+#define PROT_NONE  0
+#define PROT_READ  1
+#define PROT_WRITE 2
+#define PROT_EXEC  4
+#define MAP_SHARED  1
+#define MAP_PRIVATE 2
+#define MAP_FIXED   0x10
+#define MAP_ANONYMOUS 0x20
+#define MAP_ANON MAP_ANONYMOUS
+#define MAP_FAILED ((void*)-1)
+#define MREMAP_MAYMOVE 1
+#define MS_ASYNC 1
+#define MS_SYNC 4
+#define MS_INVALIDATE 2
+#define MADV_DONTNEED 4
+void* mmap(void* addr, size_t length, int prot, int flags, int fd, off_t offset);
+int munmap(void* addr, size_t length);
+int mprotect(void* addr, size_t len, int prot);
+int msync(void* addr, size_t length, int flags);
+int madvise(void* addr, size_t length, int advice);
+int mlock(const void* addr, size_t len);
+int munlock(const void* addr, size_t len);
+void* mremap(void* old_addr, size_t old_size, size_t new_size, int flags, ...);
+#endif
diff --git a/newlib/sysroot_headers/sys/mount.h b/newlib/sysroot_headers/sys/mount.h
new file mode 100644 (file)
index 0000000..81d5732
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef _SYS_MOUNT_H
+#define _SYS_MOUNT_H
+#define MS_RDONLY 1
+#define MS_NOSUID 2
+#define MS_NODEV  4
+#define MS_NOEXEC 8
+#define MS_REMOUNT 32
+#define MS_BIND 4096
+#define MNT_FORCE 1
+#define MNT_DETACH 2
+int mount(const char* source, const char* target, const char* fstype, unsigned long flags, const void* data);
+int umount(const char* target);
+int umount2(const char* target, int flags);
+#endif
diff --git a/newlib/sysroot_headers/sys/poll.h b/newlib/sysroot_headers/sys/poll.h
new file mode 100644 (file)
index 0000000..779ec77
--- /dev/null
@@ -0,0 +1 @@
+#include <poll.h>
diff --git a/newlib/sysroot_headers/sys/prctl.h b/newlib/sysroot_headers/sys/prctl.h
new file mode 100644 (file)
index 0000000..570ea4f
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _SYS_PRCTL_H
+#define _SYS_PRCTL_H
+#define PR_SET_NAME 15
+#define PR_GET_NAME 16
+int prctl(int option, ...);
+#endif
diff --git a/newlib/sysroot_headers/sys/reboot.h b/newlib/sysroot_headers/sys/reboot.h
new file mode 100644 (file)
index 0000000..35f9ef0
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef _SYS_REBOOT_H
+#define _SYS_REBOOT_H
+#define RB_AUTOBOOT    0x01234567
+#define RB_HALT_SYSTEM 0xCDEF0123
+#define RB_POWER_OFF   0x4321FEDC
+int reboot(int cmd);
+#endif
diff --git a/newlib/sysroot_headers/sys/resource.h b/newlib/sysroot_headers/sys/resource.h
new file mode 100644 (file)
index 0000000..d0a048d
--- /dev/null
@@ -0,0 +1,63 @@
+#ifndef _SYS_RESOURCE_H_
+#define _SYS_RESOURCE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/time.h>
+
+#define RUSAGE_SELF     0
+#define RUSAGE_CHILDREN -1
+
+struct rusage {
+    struct timeval ru_utime;
+    struct timeval ru_stime;
+};
+
+int getrusage(int, struct rusage*);
+
+/* Priority constants */
+#define PRIO_PROCESS 0
+#define PRIO_PGRP    1
+#define PRIO_USER    2
+
+int getpriority(int which, int who);
+int setpriority(int which, int who, int prio);
+
+/* Resource limits */
+typedef unsigned long rlim_t;
+
+#define RLIM_INFINITY (~(rlim_t)0)
+#define RLIM_SAVED_MAX RLIM_INFINITY
+#define RLIM_SAVED_CUR RLIM_INFINITY
+
+#define RLIMIT_CPU     0
+#define RLIMIT_FSIZE   1
+#define RLIMIT_DATA    2
+#define RLIMIT_STACK   3
+#define RLIMIT_CORE    4
+#define RLIMIT_RSS     5
+#define RLIMIT_NPROC   6
+#define RLIMIT_NOFILE  7
+#define RLIMIT_MEMLOCK 8
+#define RLIMIT_AS      9
+#define RLIMIT_LOCKS   10
+#define RLIMIT_SIGPENDING 11
+#define RLIMIT_MSGQUEUE   12
+#define RLIMIT_NICE       13
+#define RLIMIT_RTPRIO     14
+#define RLIMIT_NLIMITS    15
+
+struct rlimit {
+    rlim_t rlim_cur;
+    rlim_t rlim_max;
+};
+
+int getrlimit(int resource, struct rlimit* rlim);
+int setrlimit(int resource, const struct rlimit* rlim);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !_SYS_RESOURCE_H_ */
diff --git a/newlib/sysroot_headers/sys/sendfile.h b/newlib/sysroot_headers/sys/sendfile.h
new file mode 100644 (file)
index 0000000..cc86197
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef _SYS_SENDFILE_H
+#define _SYS_SENDFILE_H
+#include <sys/types.h>
+ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count);
+#endif
diff --git a/newlib/sysroot_headers/sys/socket.h b/newlib/sysroot_headers/sys/socket.h
new file mode 100644 (file)
index 0000000..462fd2f
--- /dev/null
@@ -0,0 +1,108 @@
+#ifndef _SYS_SOCKET_H
+#define _SYS_SOCKET_H
+#include <sys/types.h>
+#include <stdint.h>
+
+#define AF_UNSPEC  0
+#define AF_UNIX    1
+#define AF_LOCAL   AF_UNIX
+#define AF_INET    2
+#define AF_INET6   10
+#define AF_PACKET  17
+
+#define PF_UNSPEC  AF_UNSPEC
+#define PF_UNIX    AF_UNIX
+#define PF_LOCAL   AF_LOCAL
+#define PF_INET    AF_INET
+#define PF_INET6   AF_INET6
+
+#define SOCK_STREAM    1
+#define SOCK_DGRAM     2
+#define SOCK_RAW       3
+#define SOCK_SEQPACKET 5
+#define SOCK_CLOEXEC   0x80000
+#define SOCK_NONBLOCK  0x800
+#define SOCK_RDM       4
+
+#define SOL_SOCKET 1
+#define SO_REUSEADDR 2
+#define SO_ERROR     4
+#define SO_BROADCAST 6
+#define SO_SNDBUF    7
+#define SO_RCVBUF    8
+#define SO_KEEPALIVE 9
+#define SO_LINGER   13
+#define SO_REUSEPORT 15
+#define SO_RCVTIMEO 20
+#define SO_SNDTIMEO 21
+#define SO_BINDTODEVICE 25
+
+#define MSG_OOB       1
+#define MSG_PEEK      2
+#define MSG_DONTROUTE 4
+#define MSG_DONTWAIT  0x40
+#define MSG_NOSIGNAL  0x4000
+
+#define SHUT_RD   0
+#define SHUT_WR   1
+#define SHUT_RDWR 2
+
+typedef unsigned int socklen_t;
+typedef unsigned short sa_family_t;
+
+struct sockaddr {
+    sa_family_t sa_family;
+    char sa_data[14];
+};
+
+struct sockaddr_storage {
+    sa_family_t ss_family;
+    char __ss_padding[126];
+};
+
+struct linger {
+    int l_onoff;
+    int l_linger;
+};
+
+struct iovec {
+    void* iov_base;
+    size_t iov_len;
+};
+
+struct msghdr {
+    void* msg_name;
+    socklen_t msg_namelen;
+    struct iovec* msg_iov;
+    size_t msg_iovlen;
+    void* msg_control;
+    size_t msg_controllen;
+    int msg_flags;
+};
+
+struct cmsghdr {
+    size_t cmsg_len;
+    int cmsg_level;
+    int cmsg_type;
+};
+
+int socket(int domain, int type, int protocol);
+int bind(int sockfd, const struct sockaddr* addr, socklen_t addrlen);
+int listen(int sockfd, int backlog);
+int accept(int sockfd, struct sockaddr* addr, socklen_t* addrlen);
+int connect(int sockfd, const struct sockaddr* addr, socklen_t addrlen);
+ssize_t send(int sockfd, const void* buf, size_t len, int flags);
+ssize_t recv(int sockfd, void* buf, size_t len, int flags);
+ssize_t sendto(int sockfd, const void* buf, size_t len, int flags,
+               const struct sockaddr* dest_addr, socklen_t addrlen);
+ssize_t recvfrom(int sockfd, void* buf, size_t len, int flags,
+                 struct sockaddr* src_addr, socklen_t* addrlen);
+ssize_t sendmsg(int sockfd, const struct msghdr* msg, int flags);
+ssize_t recvmsg(int sockfd, struct msghdr* msg, int flags);
+int setsockopt(int sockfd, int level, int optname, const void* optval, socklen_t optlen);
+int getsockopt(int sockfd, int level, int optname, void* optval, socklen_t* optlen);
+int getpeername(int sockfd, struct sockaddr* addr, socklen_t* addrlen);
+int getsockname(int sockfd, struct sockaddr* addr, socklen_t* addrlen);
+int shutdown(int sockfd, int how);
+int socketpair(int domain, int type, int protocol, int sv[2]);
+#endif
diff --git a/newlib/sysroot_headers/sys/statfs.h b/newlib/sysroot_headers/sys/statfs.h
new file mode 100644 (file)
index 0000000..53b3b5e
--- /dev/null
@@ -0,0 +1 @@
+#include <sys/vfs.h>
diff --git a/newlib/sysroot_headers/sys/swap.h b/newlib/sysroot_headers/sys/swap.h
new file mode 100644 (file)
index 0000000..ebf925b
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _SYS_SWAP_H
+#define _SYS_SWAP_H
+#define SWAP_FLAG_PREFER 0x8000
+int swapon(const char* path, int flags);
+int swapoff(const char* path);
+#endif
diff --git a/newlib/sysroot_headers/sys/sysinfo.h b/newlib/sysroot_headers/sys/sysinfo.h
new file mode 100644 (file)
index 0000000..6d6f841
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef _SYS_SYSINFO_H
+#define _SYS_SYSINFO_H
+struct sysinfo {
+    long uptime; unsigned long loads[3]; unsigned long totalram;
+    unsigned long freeram; unsigned long sharedram; unsigned long bufferram;
+    unsigned long totalswap; unsigned long freeswap;
+    unsigned short procs; unsigned long totalhigh; unsigned long freehigh;
+    unsigned int mem_unit;
+};
+int sysinfo(struct sysinfo* info);
+#endif
diff --git a/newlib/sysroot_headers/sys/sysmacros.h b/newlib/sysroot_headers/sys/sysmacros.h
new file mode 100644 (file)
index 0000000..621dfc4
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _SYS_SYSMACROS_H
+#define _SYS_SYSMACROS_H
+#define major(dev) ((unsigned)((dev) >> 8) & 0xff)
+#define minor(dev) ((unsigned)(dev) & 0xff)
+#define makedev(maj,min) (((maj) << 8) | (min))
+#endif
diff --git a/newlib/sysroot_headers/sys/termios.h b/newlib/sysroot_headers/sys/termios.h
new file mode 100644 (file)
index 0000000..7fe9c5b
--- /dev/null
@@ -0,0 +1,125 @@
+#ifndef _SYS_TERMIOS_H
+#define _SYS_TERMIOS_H
+
+#include <sys/types.h>
+
+#define NCCS 32
+
+typedef unsigned int tcflag_t;
+typedef unsigned char cc_t;
+typedef unsigned int speed_t;
+
+struct termios {
+    tcflag_t c_iflag;
+    tcflag_t c_oflag;
+    tcflag_t c_cflag;
+    tcflag_t c_lflag;
+    cc_t     c_cc[NCCS];
+    speed_t  c_ispeed;
+    speed_t  c_ospeed;
+};
+
+/* c_lflag bits */
+#define ECHO    0x0008
+#define ECHOE   0x0010
+#define ECHOK   0x0020
+#define ECHONL  0x0040
+#define ICANON  0x0002
+#define ISIG    0x0001
+#define NOFLSH  0x0080
+#define TOSTOP  0x0100
+#define IEXTEN  0x8000
+#define ECHOCTL 0x0200
+#define ECHOKE  0x0400
+
+/* c_iflag bits */
+#define IGNBRK  0x0001
+#define BRKINT  0x0002
+#define IGNPAR  0x0004
+#define PARMRK  0x0008
+#define INPCK   0x0010
+#define ISTRIP  0x0020
+#define INLCR   0x0040
+#define IGNCR   0x0080
+#define ICRNL   0x0100
+#define IXON    0x0400
+#define IXOFF   0x1000
+#define IXANY   0x0800
+#define IMAXBEL 0x2000
+
+/* c_oflag bits */
+#define OPOST   0x0001
+#define ONLCR   0x0004
+
+/* c_cflag bits */
+#define CSIZE   0x0030
+#define CS5     0x0000
+#define CS6     0x0010
+#define CS7     0x0020
+#define CS8     0x0030
+#define CSTOPB  0x0040
+#define CREAD   0x0080
+#define PARENB  0x0100
+#define PARODD  0x0200
+#define HUPCL   0x0400
+#define CLOCAL  0x0800
+
+/* c_cc indices */
+#define VEOF    0
+#define VEOL    1
+#define VERASE  2
+#define VKILL   3
+#define VINTR   4
+#define VQUIT   5
+#define VSUSP   6
+#define VSTART  7
+#define VSTOP   8
+#define VMIN    9
+#define VTIME   10
+
+/* tcsetattr actions */
+#define TCSANOW   0
+#define TCSADRAIN 1
+#define TCSAFLUSH 2
+#define TCOON 1
+#define TCOOFF 0
+#define TCION 2
+#define TCIOFF 3
+#define TCIFLUSH 0
+#define TCOFLUSH 1
+#define TCIOFLUSH 2
+
+/* Baud rates */
+#define B0       0
+#define B50      1
+#define B75      2
+#define B110     3
+#define B134     4
+#define B150     5
+#define B200     6
+#define B300     7
+#define B600     8
+#define B1200    9
+#define B1800    10
+#define B2400    11
+#define B4800    12
+#define B9600    13
+#define B19200   14
+#define B38400   15
+#define B57600   16
+#define B115200  17
+
+int tcgetattr(int, struct termios *);
+int tcsetattr(int, int, const struct termios *);
+pid_t tcgetpgrp(int);
+int tcsetpgrp(int, pid_t);
+speed_t cfgetispeed(const struct termios *);
+speed_t cfgetospeed(const struct termios *);
+int cfsetispeed(struct termios *, speed_t);
+int cfsetospeed(struct termios *, speed_t);
+int tcdrain(int);
+int tcflow(int, int);
+int tcflush(int, int);
+int tcsendbreak(int, int);
+
+#endif /* _SYS_TERMIOS_H */
diff --git a/newlib/sysroot_headers/sys/un.h b/newlib/sysroot_headers/sys/un.h
new file mode 100644 (file)
index 0000000..5a7f9b1
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef _SYS_UN_H
+#define _SYS_UN_H
+struct sockaddr_un {
+    unsigned short sun_family;
+    char sun_path[108];
+};
+#endif
diff --git a/newlib/sysroot_headers/sys/utsname.h b/newlib/sysroot_headers/sys/utsname.h
new file mode 100644 (file)
index 0000000..eabdf5d
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _SYS_UTSNAME_H
+#define _SYS_UTSNAME_H
+#define _UTSNAME_LENGTH 65
+struct utsname {
+    char sysname[_UTSNAME_LENGTH];
+    char nodename[_UTSNAME_LENGTH];
+    char release[_UTSNAME_LENGTH];
+    char version[_UTSNAME_LENGTH];
+    char machine[_UTSNAME_LENGTH];
+};
+int uname(struct utsname *buf);
+#endif
diff --git a/newlib/sysroot_headers/sys/vfs.h b/newlib/sysroot_headers/sys/vfs.h
new file mode 100644 (file)
index 0000000..d3e7a4b
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef _SYS_VFS_H
+#define _SYS_VFS_H
+#include <sys/types.h>
+struct statfs {
+    long f_type; long f_bsize; long f_blocks; long f_bfree;
+    long f_bavail; long f_files; long f_ffree; long f_fsid;
+    long f_namelen;
+};
+int statfs(const char* path, struct statfs* buf);
+int fstatfs(int fd, struct statfs* buf);
+#endif
diff --git a/newlib/sysroot_headers/syslog.h b/newlib/sysroot_headers/syslog.h
new file mode 100644 (file)
index 0000000..c340250
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef _SYSLOG_H
+#define _SYSLOG_H
+#include <stdarg.h>
+#define LOG_EMERG   0
+#define LOG_ALERT   1
+#define LOG_CRIT    2
+#define LOG_ERR     3
+#define LOG_WARNING 4
+#define LOG_NOTICE  5
+#define LOG_INFO    6
+#define LOG_DEBUG   7
+#define LOG_KERN    (0<<3)
+#define LOG_USER    (1<<3)
+#define LOG_DAEMON  (3<<3)
+#define LOG_AUTH    (4<<3)
+#define LOG_LOCAL0  (16<<3)
+#define LOG_PID     0x01
+#define LOG_CONS    0x02
+#define LOG_NDELAY  0x08
+#define LOG_PERROR  0x20
+void openlog(const char* ident, int option, int facility);
+void syslog(int priority, const char* format, ...);
+void closelog(void);
+#endif
diff --git a/newlib/sysroot_headers/utmp.h b/newlib/sysroot_headers/utmp.h
new file mode 100644 (file)
index 0000000..5997abb
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef _UTMP_H
+#define _UTMP_H
+#define UT_LINESIZE 32
+#define UT_NAMESIZE 32
+#define UT_HOSTSIZE 256
+#define EMPTY 0
+#define RUN_LVL 1
+#define BOOT_TIME 2
+#define NEW_TIME 3
+#define OLD_TIME 4
+#define INIT_PROCESS 5
+#define LOGIN_PROCESS 6
+#define USER_PROCESS 7
+#define DEAD_PROCESS 8
+struct utmp {
+    short ut_type; int ut_pid;
+    char ut_line[UT_LINESIZE]; char ut_id[4];
+    char ut_user[UT_NAMESIZE]; char ut_host[UT_HOSTSIZE];
+    long ut_tv_sec; long ut_tv_usec;
+};
+#define utmpx utmp
+#endif
diff --git a/newlib/sysroot_headers/utmpx.h b/newlib/sysroot_headers/utmpx.h
new file mode 100644 (file)
index 0000000..5fa45ee
--- /dev/null
@@ -0,0 +1 @@
+#include <utmp.h>
index 0170a459ca03b999d32630633b1b9989e34ef356..76b3ba17f74908fcb443b62bc99d30921aad959e 100755 (executable)
@@ -431,7 +431,7 @@ patch_bash
 # with Newlib's POSIX-compliant headers (signal.h, errno.h, stdio.h, etc.).
 # ulibc headers are for AdrOS userland built with -nostdlib; the cross-
 # toolchain uses Newlib headers instead.  Only truly AdrOS-specific headers
-# (syscall numbers, ioctl defs) are installed under a kernel_ prefix.
+# (syscall numbers, ioctl defs) are installed.
 msg "Installing AdrOS-specific sysroot headers"
 mkdir -p "${SYSROOT}/include/sys"
 for h in syscall.h; do
@@ -441,140 +441,50 @@ for h in syscall.h; do
     fi
 done
 
-# Create sys/ioctl.h stub (newlib doesn't provide one)
-if [[ ! -f "${SYSROOT}/include/sys/ioctl.h" ]]; then
-    cat > "${SYSROOT}/include/sys/ioctl.h" << 'IOCTL_H'
-#ifndef _SYS_IOCTL_H
-#define _SYS_IOCTL_H
-#define TIOCGPGRP  0x540F
-#define TIOCSPGRP  0x5410
-#define TIOCGWINSZ 0x5413
-#define TIOCSWINSZ 0x5414
-#define FIONREAD   0x541B
-struct winsize {
-    unsigned short ws_row;
-    unsigned short ws_col;
-    unsigned short ws_xpixel;
-    unsigned short ws_ypixel;
-};
-int ioctl(int fd, unsigned long request, ...);
-#endif
-IOCTL_H
-    step "Created sys/ioctl.h stub"
+# Install Linux/POSIX compatibility headers from newlib/sysroot_headers/.
+# These provide stubs for headers that newlib doesn't supply but that
+# ported software (Bash, Busybox) expects: asm/*, linux/*, net/*,
+# netinet/*, sys/socket.h, poll.h, mntent.h, etc.
+COMPAT_HEADERS="$ADROS_ROOT/newlib/sysroot_headers"
+if [[ -d "$COMPAT_HEADERS" ]]; then
+    cp -r "$COMPAT_HEADERS"/* "${SYSROOT}/include/"
+    step "Installed $(find "$COMPAT_HEADERS" -type f | wc -l) sysroot compat headers"
 fi
 
-# Create sys/termios.h (newlib's termios.h includes it but doesn't provide it)
-if [[ ! -f "${SYSROOT}/include/sys/termios.h" ]]; then
-    cat > "${SYSROOT}/include/sys/termios.h" << 'TERMIOS_H'
-#ifndef _SYS_TERMIOS_H
-#define _SYS_TERMIOS_H
-#include <sys/types.h>
-#define NCCS 32
-typedef unsigned int tcflag_t;
-typedef unsigned char cc_t;
-typedef unsigned int speed_t;
-struct termios {
-    tcflag_t c_iflag; tcflag_t c_oflag;
-    tcflag_t c_cflag; tcflag_t c_lflag;
-    cc_t c_cc[NCCS]; speed_t c_ispeed; speed_t c_ospeed;
-};
-#define ECHO 0x0008
-#define ECHOE 0x0010
-#define ECHOK 0x0020
-#define ECHONL 0x0040
-#define ICANON 0x0002
-#define ISIG 0x0001
-#define NOFLSH 0x0080
-#define TOSTOP 0x0100
-#define IEXTEN 0x8000
-#define ECHOCTL 0x0200
-#define ECHOKE 0x0400
-#define IGNBRK 0x0001
-#define BRKINT 0x0002
-#define IGNPAR 0x0004
-#define PARMRK 0x0008
-#define INPCK 0x0010
-#define ISTRIP 0x0020
-#define INLCR 0x0040
-#define IGNCR 0x0080
-#define ICRNL 0x0100
-#define IXON 0x0400
-#define IXOFF 0x1000
-#define IXANY 0x0800
-#define OPOST 0x0001
-#define ONLCR 0x0004
-#define CSIZE 0x0030
-#define CS5 0x0000
-#define CS6 0x0010
-#define CS7 0x0020
-#define CS8 0x0030
-#define CSTOPB 0x0040
-#define CREAD 0x0080
-#define PARENB 0x0100
-#define HUPCL 0x0400
-#define CLOCAL 0x0800
-#define VEOF 0
-#define VEOL 1
-#define VERASE 2
-#define VKILL 3
-#define VINTR 4
-#define VQUIT 5
-#define VSUSP 6
-#define VSTART 7
-#define VSTOP 8
-#define VMIN 9
-#define VTIME 10
-#define TCSANOW 0
-#define TCSADRAIN 1
-#define TCSAFLUSH 2
-#define TCOON 1
-#define TCOOFF 0
-#define TCION 2
-#define TCIOFF 3
-#define TCIFLUSH 0
-#define TCOFLUSH 1
-#define TCIOFLUSH 2
-#define B0 0
-#define B9600 13
-#define B19200 14
-#define B38400 15
-#define B57600 16
-#define B115200 17
-int tcgetattr(int, struct termios *);
-int tcsetattr(int, int, const struct termios *);
-pid_t tcgetpgrp(int);
-int tcsetpgrp(int, pid_t);
-speed_t cfgetispeed(const struct termios *);
-speed_t cfgetospeed(const struct termios *);
-int cfsetispeed(struct termios *, speed_t);
-int cfsetospeed(struct termios *, speed_t);
-int tcsendbreak(int, int);
-#endif
-TERMIOS_H
-    step "Created sys/termios.h stub"
+# Patch newlib headers that need small AdrOS-specific additions.
+# sys/stat.h — expose lstat()/mknod() for __adros__ (newlib guards them)
+if ! grep -q '__adros__' "${SYSROOT}/include/sys/stat.h" 2>/dev/null; then
+    sed -i 's/defined(__SPU__) || defined(__rtems__) || defined(__CYGWIN__)/defined(__SPU__) || defined(__rtems__) || defined(__CYGWIN__) || defined(__adros__)/' \
+        "${SYSROOT}/include/sys/stat.h"
+    step "Patched sys/stat.h (lstat/mknod for __adros__)"
 fi
 
-# Create sys/dirent.h (newlib's default one just #errors)
-if grep -q '#error' "${SYSROOT}/include/sys/dirent.h" 2>/dev/null; then
-    cat > "${SYSROOT}/include/sys/dirent.h" << 'DIRENT_H'
-#ifndef _SYS_DIRENT_H
-#define _SYS_DIRENT_H
-#include <sys/types.h>
-#define MAXNAMLEN 255
-struct dirent {
-    ino_t  d_ino;
-    char   d_name[MAXNAMLEN + 1];
-};
-typedef struct {
-    int dd_fd; int dd_loc; int dd_size; char *dd_buf;
-} DIR;
-DIR *opendir(const char *);
-struct dirent *readdir(DIR *);
-int closedir(DIR *);
-void rewinddir(DIR *);
-#endif
-DIRENT_H
-    step "Created sys/dirent.h stub"
+# sys/signal.h — add SA_RESTART and friends to the non-rtems block
+if ! grep -q 'SA_RESTART' "${SYSROOT}/include/sys/signal.h" 2>/dev/null; then
+    sed -i '/^#define SA_NOCLDSTOP 1/a\
+#define SA_RESTART   0x10000000\
+#define SA_NODEFER   0x40000000\
+#define SA_RESETHAND 0x80000000\
+#define SA_NOCLDWAIT 0x20000000\
+#define SA_SIGINFO   0x2' \
+        "${SYSROOT}/include/sys/signal.h"
+    step "Patched sys/signal.h (SA_RESTART etc.)"
+fi
+
+# sys/wait.h — add WCOREDUMP macro
+if ! grep -q 'WCOREDUMP' "${SYSROOT}/include/sys/wait.h" 2>/dev/null; then
+    sed -i '/#define WTERMSIG/a\
+#define WCOREDUMP(w) ((w) \& 0x80)' \
+        "${SYSROOT}/include/sys/wait.h"
+    step "Patched sys/wait.h (WCOREDUMP)"
+fi
+
+# glob.h — add GLOB_NOMATCH
+if ! grep -q 'GLOB_NOMATCH' "${SYSROOT}/include/glob.h" 2>/dev/null; then
+    sed -i '/#define.*GLOB_ABEND/a\
+#define GLOB_NOMATCH    (-3)    /* No match found. */' \
+        "${SYSROOT}/include/glob.h"
+    step "Patched glob.h (GLOB_NOMATCH)"
 fi
 
 # ==================================================================
@@ -664,13 +574,14 @@ fi
 msg "Building libgloss/adros (crt0.o + libadros.a)"
 if [[ ! -f "${SYSROOT}/lib/libadros.a" ]]; then
     local_gloss="$SRC_DIR/newlib-${NEWLIB_VER}/libgloss/adros"
-    ${TARGET}-gcc -c "$local_gloss/crt0.S"     -o /tmp/adros_crt0.o
-    ${TARGET}-gcc -c "$local_gloss/syscalls.c"     -o /tmp/adros_syscalls.o
-    ${TARGET}-gcc -c "$local_gloss/posix_stubs.c"  -o /tmp/adros_posix_stubs.o
-    ${TARGET}-ar rcs /tmp/libadros.a /tmp/adros_syscalls.o /tmp/adros_posix_stubs.o
+    ${TARGET}-gcc -Os -c "$local_gloss/crt0.S"          -o /tmp/adros_crt0.o
+    ${TARGET}-gcc -Os -c "$local_gloss/syscalls.c"      -o /tmp/adros_syscalls.o
+    ${TARGET}-gcc -Os -c "$local_gloss/posix_stubs.c"   -o /tmp/adros_posix_stubs.o
+    ${TARGET}-gcc -Os -c "$local_gloss/posix_compat.c"  -o /tmp/adros_posix_compat.o
+    ${TARGET}-ar rcs /tmp/libadros.a /tmp/adros_syscalls.o /tmp/adros_posix_stubs.o /tmp/adros_posix_compat.o
     cp /tmp/adros_crt0.o   "${SYSROOT}/lib/crt0.o"
     cp /tmp/libadros.a     "${SYSROOT}/lib/libadros.a"
-    rm -f /tmp/adros_crt0.o /tmp/adros_syscalls.o /tmp/adros_posix_stubs.o /tmp/libadros.a
+    rm -f /tmp/adros_crt0.o /tmp/adros_syscalls.o /tmp/adros_posix_stubs.o /tmp/adros_posix_compat.o /tmp/libadros.a
     step "crt0.o + libadros.a installed to sysroot"
 else
     step "libadros.a already installed"